Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:00

0001 // Created on: 2014-10-14
0002 // Created by: Anton POLETAEV
0003 // Copyright (c) 2013-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _StdPrs_Isolines_H__
0017 #define _StdPrs_Isolines_H__
0018 
0019 #include <BRepAdaptor_Surface.hxx>
0020 #include <Geom_Surface.hxx>
0021 #include <gp_Lin2d.hxx>
0022 #include <Prs3d_LineAspect.hxx>
0023 #include <Prs3d_NListOfSequenceOfPnt.hxx>
0024 #include <StdPrs_DeflectionCurve.hxx>
0025 #include <StdPrs_ToolTriangulatedShape.hxx>
0026 #include <TColStd_SequenceOfReal.hxx>
0027 
0028 class TopLoc_Location;
0029 
0030 //! Tool for computing isoline representation for a face or surface.
0031 //! Depending on a flags set to the given Prs3d_Drawer instance, on-surface (is used
0032 //! by default) or on-triangulation isoline builder algorithm will be used.
0033 //! If the given shape is not triangulated, on-surface isoline builder will be applied
0034 //! regardless of Prs3d_Drawer flags.
0035 class StdPrs_Isolines : public Prs3d_Root
0036 {
0037 public:
0038 
0039   //! Computes isolines presentation for a TopoDS face.
0040   //! This method chooses proper version of isoline builder algorithm : on triangulation
0041   //! or surface depending on the flag passed from Prs3d_Drawer attributes.
0042   //! This method is a default way to display isolines for a given TopoDS face.
0043   //! @param thePresentation [in] the presentation.
0044   //! @param theFace [in] the face.
0045   //! @param theDrawer [in] the display settings.
0046   //! @param theDeflection [in] the deflection for isolines-on-surface version.
0047   inline static void Add (const Handle(Prs3d_Presentation)& thePresentation,
0048                           const TopoDS_Face&                theFace,
0049                           const Handle(Prs3d_Drawer)&       theDrawer,
0050                           const Standard_Real               theDeflection)
0051   {
0052     if (theDrawer->IsoOnTriangulation() && StdPrs_ToolTriangulatedShape::IsTriangulated (theFace))
0053     {
0054       AddOnTriangulation (thePresentation, theFace, theDrawer);
0055     }
0056     else
0057     {
0058       AddOnSurface (thePresentation, theFace, theDrawer, theDeflection);
0059     }
0060   }
0061 
0062   //! Computes isolines presentation for a TopoDS face.
0063   //! This method chooses proper version of isoline builder algorithm : on triangulation
0064   //! or surface depending on the flag passed from Prs3d_Drawer attributes.
0065   //! This method is a default way to display isolines for a given TopoDS face.
0066   //! @param theFace [in] the face.
0067   //! @param theDrawer [in] the display settings.
0068   //! @param theDeflection [in] the deflection for isolines-on-surface version.
0069   static void Add (const TopoDS_Face&          theFace,
0070                    const Handle(Prs3d_Drawer)& theDrawer,
0071                    const Standard_Real         theDeflection,
0072                    Prs3d_NListOfSequenceOfPnt& theUPolylines,
0073                    Prs3d_NListOfSequenceOfPnt& theVPolylines)
0074   {
0075     if (theDrawer->IsoOnTriangulation() && StdPrs_ToolTriangulatedShape::IsTriangulated (theFace))
0076     {
0077       AddOnTriangulation (theFace, theDrawer, theUPolylines, theVPolylines);
0078     }
0079     else
0080     {
0081       AddOnSurface (theFace, theDrawer, theDeflection, theUPolylines, theVPolylines);
0082     }
0083   }
0084 
0085   //! Computes isolines on triangulation and adds them to a presentation.
0086   //! @param thePresentation [in] the presentation.
0087   //! @param theFace [in] the face.
0088   //! @param theDrawer [in] the display settings.
0089   Standard_EXPORT static void AddOnTriangulation (const Handle(Prs3d_Presentation)& thePresentation,
0090                                                   const TopoDS_Face&                theFace,
0091                                                   const Handle(Prs3d_Drawer)&       theDrawer);
0092 
0093   //! Computes isolines on triangulation.
0094   //! @param theFace [in] the face.
0095   //! @param theDrawer [in] the display settings.
0096   //! @param theUPolylines [out] the sequence of result polylines
0097   //! @param theVPolylines [out] the sequence of result polylines
0098   Standard_EXPORT static void AddOnTriangulation (const TopoDS_Face&          theFace,
0099                                                   const Handle(Prs3d_Drawer)& theDrawer,
0100                                                   Prs3d_NListOfSequenceOfPnt& theUPolylines,
0101                                                   Prs3d_NListOfSequenceOfPnt& theVPolylines);
0102 
0103   //! Computes isolines on triangulation and adds them to a presentation.
0104   //! @param thePresentation [in] the presentation.
0105   //! @param theTriangulation [in] the triangulation.
0106   //! @param theSurface [in] the definition of triangulated surface. The surface
0107   //!        adapter is used to precisely evaluate isoline points using surface
0108   //!        law and fit them on triangulation. If NULL is passed, the method will
0109   //!        use linear interpolation of triangle node's UV coordinates to evaluate
0110   //!        isoline points.
0111   //! @param theLocation [in] the location transformation defined for triangulation (surface).
0112   //! @param theDrawer [in] the display settings.
0113   //! @param theUIsoParams [in] the parameters of u isolines to compute.
0114   //! @param theVIsoParams [in] the parameters of v isolines to compute.
0115   Standard_EXPORT static void AddOnTriangulation (const Handle(Prs3d_Presentation)& thePresentation,
0116                                                   const Handle(Poly_Triangulation)& theTriangulation,
0117                                                   const Handle(Geom_Surface)&       theSurface,
0118                                                   const TopLoc_Location&            theLocation,
0119                                                   const Handle(Prs3d_Drawer)&       theDrawer,
0120                                                   const TColStd_SequenceOfReal&     theUIsoParams,
0121                                                   const TColStd_SequenceOfReal&     theVIsoParams);
0122 
0123   //! Computes isolines on surface and adds them to presentation.
0124   //! @param thePresentation [in] the presentation.
0125   //! @param theFace [in] the face.
0126   //! @param theDrawer [in] the display settings.
0127   //! @param theDeflection [in] the deflection value.
0128   Standard_EXPORT static void AddOnSurface (const Handle(Prs3d_Presentation)& thePresentation,
0129                                             const TopoDS_Face&                theFace,
0130                                             const Handle(Prs3d_Drawer)&       theDrawer,
0131                                             const Standard_Real               theDeflection);
0132 
0133   //! Computes isolines on surface and adds them to presentation.
0134   //! @param theFace [in] the face
0135   //! @param theDrawer [in] the display settings
0136   //! @param theDeflection [in] the deflection value
0137   //! @param theUPolylines [out] the sequence of result polylines
0138   //! @param theVPolylines [out] the sequence of result polylines
0139   Standard_EXPORT static void AddOnSurface (const TopoDS_Face&          theFace,
0140                                             const Handle(Prs3d_Drawer)& theDrawer,
0141                                             const Standard_Real         theDeflection,
0142                                             Prs3d_NListOfSequenceOfPnt& theUPolylines,
0143                                             Prs3d_NListOfSequenceOfPnt& theVPolylines);
0144 
0145   //! Computes isolines on surface and adds them to presentation.
0146   //! @param thePresentation [in] the presentation.
0147   //! @param theSurface [in] the surface.
0148   //! @param theDrawer [in] the display settings.
0149   //! @param theDeflection [in] the deflection value.
0150   //! @param theUIsoParams [in] the parameters of u isolines to compute.
0151   //! @param theVIsoParams [in] the parameters of v isolines to compute.
0152   Standard_EXPORT static void AddOnSurface (const Handle(Prs3d_Presentation)&   thePresentation,
0153                                             const Handle(BRepAdaptor_Surface)& theSurface,
0154                                             const Handle(Prs3d_Drawer)&         theDrawer,
0155                                             const Standard_Real                 theDeflection,
0156                                             const TColStd_SequenceOfReal&       theUIsoParams,
0157                                             const TColStd_SequenceOfReal&       theVIsoParams);
0158 
0159   //! Evaluate sequence of parameters for drawing uv isolines for a given face.
0160   //! @param theFace [in] the face.
0161   //! @param theNbIsoU [in] the number of u isolines.
0162   //! @param theNbIsoV [in] the number of v isolines.
0163   //! @param theUVLimit [in] the u, v parameter value limit.
0164   //! @param theUIsoParams [out] the sequence of u isoline parameters.
0165   //! @param theVIsoParams [out] the sequence of v isoline parameters.
0166   //! @param theUmin [out] the lower U boundary of  theFace.
0167   //! @param theUmax [out] the upper U boundary of  theFace.
0168   //! @param theVmin [out] the lower V boundary of  theFace.
0169   //! @param theVmax [out] the upper V boundary of  theFace.
0170   Standard_EXPORT static void UVIsoParameters (const TopoDS_Face&      theFace,
0171                                                const Standard_Integer  theNbIsoU,
0172                                                const Standard_Integer  theNbIsoV,
0173                                                const Standard_Real     theUVLimit,
0174                                                TColStd_SequenceOfReal& theUIsoParams,
0175                                                TColStd_SequenceOfReal& theVIsoParams,
0176                                                Standard_Real& theUmin,
0177                                                Standard_Real& theUmax, 
0178                                                Standard_Real& theVmin,
0179                                                Standard_Real& theVmax);
0180 
0181 public:
0182 
0183   //! Auxiliary structure defining 3D point on isoline.
0184   struct PntOnIso
0185   {
0186     gp_Pnt Pnt;   //!< 3D point
0187     double Param; //!< parameter along the line (for sorting)
0188   };
0189 
0190   //! Auxiliary structure defining segment of isoline.
0191   struct SegOnIso
0192   {
0193 
0194     PntOnIso Pnts[2];
0195 
0196     operator       PntOnIso*()       { return Pnts; }
0197     operator const PntOnIso*() const { return Pnts; }
0198 
0199     bool operator< (const SegOnIso& theOther) const
0200     {
0201       return Pnts[1].Param < theOther.Pnts[0].Param;
0202     }
0203 
0204   };
0205 
0206 private:
0207 
0208   //! Computes isolines on surface.
0209   //! @param theSurface [in] the surface
0210   //! @param theDrawer [in] the display settings
0211   //! @param theDeflection [in] the deflection value
0212   //! @param theUIsoParams [in] the parameters of u isolines to compute
0213   //! @param theVIsoParams [in] the parameters of v isolines to compute
0214   //! @param theUPolylines [out] the sequence of result polylines
0215   //! @param theVPolylines [out] the sequence of result polylines
0216   Standard_EXPORT static void addOnSurface (const Handle(BRepAdaptor_Surface)& theSurface,
0217                                             const Handle(Prs3d_Drawer)&         theDrawer,
0218                                             const Standard_Real                 theDeflection,
0219                                             const TColStd_SequenceOfReal&       theUIsoParams,
0220                                             const TColStd_SequenceOfReal&       theVIsoParams,
0221                                             Prs3d_NListOfSequenceOfPnt&         theUPolylines,
0222                                             Prs3d_NListOfSequenceOfPnt&         theVPolylines);
0223 
0224   //! Computes isolines on triangulation.
0225   //! @param thePresentation [in] the presentation
0226   //! @param theTriangulation [in] the triangulation
0227   //! @param theSurface [in] the definition of triangulated surface. The surface
0228   //!        adapter is used to precisely evaluate isoline points using surface
0229   //!        law and fit them on triangulation. If NULL is passed, the method will
0230   //!        use linear interpolation of triangle node's UV coordinates to evaluate
0231   //!        isoline points
0232   //! @param theLocation [in] the location transformation defined for triangulation (surface)
0233   //! @param theDrawer [in] the display settings
0234   //! @param theUIsoParams [in] the parameters of u isolines to compute
0235   //! @param theVIsoParams [in] the parameters of v isolines to compute
0236   //! @param theUPolylines [out] the sequence of result polylines
0237   //! @param theVPolylines [out] the sequence of result polylines
0238   Standard_EXPORT static void addOnTriangulation (const Handle(Poly_Triangulation)& theTriangulation,
0239                                                   const Handle(Geom_Surface)&       theSurface,
0240                                                   const TopLoc_Location&            theLocation,
0241                                                   const TColStd_SequenceOfReal&     theUIsoParams,
0242                                                   const TColStd_SequenceOfReal&     theVIsoParams,
0243                                                   Prs3d_NListOfSequenceOfPnt&       theUPolylines,
0244                                                   Prs3d_NListOfSequenceOfPnt&       theVPolylines);
0245 
0246   //! Find isoline segment on a triangle.
0247   //! @param theSurface [in] the surface.
0248   //! @param theIsU     [in] when true than U isoline is specified, V isoline otherwise
0249   //! @param theIsoline [in] the isoline in uv coordinates.
0250   //! @param theNodesXYZ [in] the XYZ coordinates of triangle nodes.
0251   //! @param theNodesUV [in] the UV coordinates of triangle nodes.
0252   //! @param theSegment [out] the XYZ points of crossed triangle's links.
0253   //!                         with U cross point parameter for V isoline
0254   //!                         or V parameters for U isoline (depending on theIsU)
0255   //! @return TRUE if the isoline passes through the triangle.
0256   Standard_EXPORT static Standard_Boolean findSegmentOnTriangulation (const Handle(Geom_Surface)& theSurface,
0257                                                                       const bool                  theIsU,
0258                                                                       const gp_Lin2d&             theIsoline,
0259                                                                       const gp_Pnt*               theNodesXYZ,
0260                                                                       const gp_Pnt2d*             theNodesUV,
0261                                                                       SegOnIso&                   theSegment);
0262 };
0263 
0264 #endif // _StdPrs_Isolines_H__