0025300: Visualization - Build wireframe representation consistent with the shape...
[occt.git] / src / StdPrs / StdPrs_Isolines.hxx
1 // Created on: 2014-10-14
2 // Created by: Anton POLETAEV
3 // Copyright (c) 2013-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _StdPrs_Isolines_H__
17 #define _StdPrs_Isolines_H__
18
19 #include <BRepAdaptor_HSurface.hxx>
20 #include <Geom_Surface.hxx>
21 #include <Prs3d_Drawer.hxx>
22 #include <Prs3d_Presentation.hxx>
23 #include <Prs3d_LineAspect.hxx>
24 #include <Prs3d_Root.hxx>
25 #include <Prs3d_NListOfSequenceOfPnt.hxx>
26 #include <Poly_Triangulation.hxx>
27 #include <StdPrs_ToolTriangulatedShape.hxx>
28 #include <TColStd_Array1OfInteger.hxx>
29 #include <TColgp_Array1OfPnt2d.hxx>
30 #include <TColStd_SequenceOfReal.hxx>
31
32 class Poly_Triangle;
33 class TopoDS_Face;
34 class TopLoc_Location;
35
36 //! Tool for computing isoline representation for a face or surface.
37 //! Depending on a flags set to the given Prs3d_Drawer instance, on-surface (is used
38 //! by default) or on-triangulation isoline builder algorithm will be used.
39 //! If the given shape is not triangulated, on-surface isoline builder will be applied
40 //! regardless of Prs3d_Drawer flags.
41 class StdPrs_Isolines : public Prs3d_Root
42 {
43 public:
44
45   //! Computes isolines presentation for a TopoDS face.
46   //! This method chooses proper version of isoline builder algorithm : on triangulation
47   //! or surface depending on the flag passed from Prs3d_Drawer attributes.
48   //! This method is a default way to display isolines for a given TopoDS face.
49   //! @param thePresentation [in] the presentation.
50   //! @param theFace [in] the face.
51   //! @param theDrawer [in] the display settings.
52   //! @param theDeflection [in] the deflection for isolines-on-surface version.
53   inline static void Add (const Handle(Prs3d_Presentation)& thePresentation,
54                           const TopoDS_Face&                theFace,
55                           const Handle(Prs3d_Drawer)&       theDrawer,
56                           const Standard_Real               theDeflection)
57   {
58     if (theDrawer->IsoOnTriangulation() && StdPrs_ToolTriangulatedShape::IsTriangulated (theFace))
59     {
60       AddOnTriangulation (thePresentation, theFace, theDrawer);
61     }
62     else
63     {
64       AddOnSurface (thePresentation, theFace, theDrawer, theDeflection);
65     }
66   }
67
68   //! Computes isolines on triangulation and adds them to a presentation.
69   //! @param thePresentation [in] the presentation.
70   //! @param theFace [in] the face.
71   //! @param theDrawer [in] the display settings.
72   Standard_EXPORT static void AddOnTriangulation (const Handle(Prs3d_Presentation)& thePresentation,
73                                                   const TopoDS_Face&                theFace,
74                                                   const Handle(Prs3d_Drawer)&       theDrawer);
75
76   //! Computes isolines on triangulation and adds them to a presentation.
77   //! @param thePresentation [in] the presentation.
78   //! @param theTriangulation [in] the triangulation.
79   //! @param theSurface [in] the definition of triangulated surface. The surface
80   //!        adapter is used to precisely evaluate isoline points using surface
81   //!        law and fit them on triangulation. If NULL is passed, the method will
82   //!        use linear interpolation of triangle node's UV coordinates to evaluate
83   //!        isoline points.
84   //! @param theLocation [in] the location transformation defined for triangulation (surface).
85   //! @param theDrawer [in] the display settings.
86   //! @param theUIsoParams [in] the parameters of u isolines to compute.
87   //! @param theVIsoParams [in] the parameters of v isolines to compute.
88   Standard_EXPORT static void AddOnTriangulation (const Handle(Prs3d_Presentation)& thePresentation,
89                                                   const Handle(Poly_Triangulation)& theTriangulation,
90                                                   const Handle(Geom_Surface)&       theSurface,
91                                                   const TopLoc_Location&            theLocation,
92                                                   const Handle(Prs3d_Drawer)&       theDrawer,
93                                                   const TColStd_SequenceOfReal&     theUIsoParams,
94                                                   const TColStd_SequenceOfReal&     theVIsoParams);
95
96   //! Computes isolines on surface and adds them to presentation.
97   //! @param thePresentation [in] the presentation.
98   //! @param theFace [in] the face.
99   //! @param theDrawer [in] the display settings.
100   //! @param theDeflection [in] the deflection value.
101   Standard_EXPORT static void AddOnSurface (const Handle(Prs3d_Presentation)& thePresentation,
102                                             const TopoDS_Face&                theFace,
103                                             const Handle(Prs3d_Drawer)&       theDrawer,
104                                             const Standard_Real               theDeflection);
105
106   //! Computes isolines on surface and adds them to presentation.
107   //! @param thePresentation [in] the presentation.
108   //! @param theSurface [in] the surface.
109   //! @param theDrawer [in] the display settings.
110   //! @param theDeflection [in] the deflection value.
111   //! @param theUIsoParams [in] the parameters of u isolines to compute.
112   //! @param theVIsoParams [in] the parameters of v isolines to compute.
113   Standard_EXPORT static void AddOnSurface (const Handle(Prs3d_Presentation)&   thePresentation,
114                                             const Handle(BRepAdaptor_HSurface)& theSurface,
115                                             const Handle(Prs3d_Drawer)&         theDrawer,
116                                             const Standard_Real                 theDeflection,
117                                             const TColStd_SequenceOfReal&       theUIsoParams,
118                                             const TColStd_SequenceOfReal&       theVIsoParams);
119
120   //! Evalute sequence of parameters for drawing uv isolines for a given face.
121   //! @param theFace [in] the face.
122   //! @param theNbIsoU [in] the number of u isolines.
123   //! @param theNbIsoV [in] the number of v isolines.
124   //! @param theUVLimit [in] the u, v parameter value limit.
125   //! @param theUIsoParams [out] the sequence of u isoline parameters.
126   //! @param theVIsoParams [out] the sequence of v isoline parameters.
127   Standard_EXPORT static void UVIsoParameters (const TopoDS_Face&      theFace,
128                                                const Standard_Integer  theNbIsoU,
129                                                const Standard_Integer  theNbIsoV,
130                                                const Standard_Real     theUVLimit,
131                                                TColStd_SequenceOfReal& theUIsoParams,
132                                                TColStd_SequenceOfReal& theVIsoParams);
133
134 private:
135
136   //! Find isoline segment on a triangle.
137   //! @param theSurface [in] the surface.
138   //! @param theIsoline [in] the isoline in uv coordinates.
139   //! @param theNodesXYZ [in] the XYZ coordinates of triangle nodes.
140   //! @param theNodesUV [in] the UV coordinates of triangle nodes.
141   //! @param theSegment [out] the XYZ points of crossed triangle's links.
142   //! @return TRUE if the isoline passes through the triangle.
143   Standard_EXPORT static Standard_Boolean findSegmentOnTriangulation (const Handle(Geom_Surface)& theSurface,
144                                                                       const gp_Lin2d&             theIsoline,
145                                                                       const gp_Pnt*               theNodesXYZ,
146                                                                       const gp_Pnt2d*             theNodesUV,
147                                                                       gp_Pnt*                     theSegment);
148 };
149
150 #endif // _StdPrs_Isolines_H__