5eb9f0df90f93b99aa32d0361ebba95ebde515ac
[occt.git] / src / BRepMesh / BRepMesh_EdgeTessellator.hxx
1 // Created on: 2014-08-13
2 // Created by: Oleg AGASHIN
3 // Copyright (c) 2011-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 _BRepMesh_EdgeTessellator_HeaderFile
17 #define _BRepMesh_EdgeTessellator_HeaderFile
18
19 #include <Standard.hxx>
20 #include <Standard_DefineAlloc.hxx>
21 #include <BRepMesh.hxx>
22 #include <BRepMesh_IEdgeTool.hxx>
23 #include <BRepMesh_GeomTool.hxx>
24 #include <BRepMesh_FaceAttribute.hxx>
25 #include <Handle_Geom_Surface.hxx>
26 #include <Handle_Geom2d_Curve.hxx>
27 #include <Handle_BRepAdaptor_HSurface.hxx>
28 #include <BRepAdaptor_Curve.hxx>
29
30 class Geom_Surface;
31 class Geom2d_Curve;
32 class TopoDS_Edge;
33 class BRepAdaptor_HSurface;
34 class TopTools_IndexedDataMapOfShapeListOfShape;
35
36 //! Auxiliary class implements functionality producing tessellated
37 //! representation of an edge based on edge geometry.
38 class BRepMesh_EdgeTessellator : public BRepMesh_IEdgeTool
39 {
40 public:
41
42   //! Constructor.
43   //! Automatically performs tessellation of the edge according to the
44   //! given parameters.
45   BRepMesh_EdgeTessellator(
46     const TopoDS_Edge&                               theEdge,
47     const Handle(BRepMesh_FaceAttribute)&            theFaceAttribute,
48     const TopTools_IndexedDataMapOfShapeListOfShape& theMapOfSharedFaces,
49     const Standard_Real                              theLinDeflection,
50     const Standard_Real                              theAngDeflection);
51
52   //! Returns number of dicretization points.
53   virtual Standard_Integer NbPoints() const
54   {
55     return myTool->NbPoints();
56   }
57
58   //! Returns parameters of solution with the given index.
59   //! @param theIndex index of tessellation point.
60   //! @param theParameter parameters on PCurve corresponded to the solution.
61   //! @param thePoint tessellation point.
62   //! @param theUV coordinates of tessellation point in parametric space of face.
63   virtual void Value(const Standard_Integer theIndex,
64                      Standard_Real&         theParameter,
65                      gp_Pnt&                thePoint,
66                      gp_Pnt2d&              theUV);
67
68   DEFINE_STANDARD_RTTI(BRepMesh_EdgeTessellator)
69
70 private:
71
72   //! 
73   void splitSegment(const Handle(Geom_Surface)& theSurf,
74                     const Handle(Geom2d_Curve)& theCurve2d,
75                     const Standard_Real         theFirst,
76                     const Standard_Real         theLast,
77                     const Standard_Integer      theNbIter);
78
79 private:
80   NCollection_Handle<BRepMesh_GeomTool> myTool;
81   Handle(BRepAdaptor_HSurface)          mySurface;
82   BRepAdaptor_Curve                     myCOnS;
83   Standard_Real                         mySquareEdgeDef;
84 };
85
86 DEFINE_STANDARD_HANDLE(BRepMesh_EdgeTessellator, BRepMesh_IEdgeTool)
87
88 #endif