0026106: BRepMesh - revision of data model
[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 <BRepAdaptor_Curve.hxx>
26 #include <Geom2dAdaptor_Curve.hxx>
27 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
28
29 class Adaptor3d_Surface;
30 class TopoDS_Edge;
31 class BRepAdaptor_HSurface;
32
33 //! Auxiliary class implements functionality producing tessellated
34 //! representation of an edge based on edge geometry.
35 class BRepMesh_EdgeTessellator : public BRepMesh_IEdgeTool
36 {
37 public:
38
39   //! Constructor.
40   //! Automatically performs tessellation of the edge according to the
41   //! given parameters.
42   BRepMesh_EdgeTessellator(
43     const TopoDS_Edge&                               theEdge,
44     const Handle(BRepMesh_FaceAttribute)&            theFaceAttribute,
45     const TopTools_IndexedDataMapOfShapeListOfShape& theMapOfSharedFaces,
46     const Standard_Real                              theLinDeflection,
47     const Standard_Real                              theAngDeflection,
48     const Standard_Real                              theMinSize);
49
50   //! Returns number of dicretization points.
51   virtual Standard_Integer NbPoints() const Standard_OVERRIDE
52   {
53     return myTool->NbPoints();
54   }
55
56   //! Returns parameters of solution with the given index.
57   //! @param theIndex index of tessellation point.
58   //! @param theParameter parameters on PCurve corresponded to the solution.
59   //! @param thePoint tessellation point.
60   //! @param theUV coordinates of tessellation point in parametric space of face.
61   //! @return True in case of valid result, false elewhere.
62   virtual Standard_Boolean Value(
63     const Standard_Integer theIndex,
64     Standard_Real&         theParameter,
65     gp_Pnt&                thePoint,
66     gp_Pnt2d&              theUV) Standard_OVERRIDE;
67
68   DEFINE_STANDARD_RTTIEXT(BRepMesh_EdgeTessellator,BRepMesh_IEdgeTool)
69
70 private:
71
72   //! 
73   void splitSegment(const Adaptor3d_Surface&    theSurf,
74                     const Geom2dAdaptor_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   Geom2dAdaptor_Curve                   myCurve2d;
84   Standard_Real                         mySquareEdgeDef;
85   Standard_Real                         mySquareMinSize;
86   Standard_Real                         myEdgeSqTol;
87   Standard_Real                         myFaceRangeU[2];
88   Standard_Real                         myFaceRangeV[2];
89 };
90
91 DEFINE_STANDARD_HANDLE(BRepMesh_EdgeTessellator, BRepMesh_IEdgeTool)
92
93 #endif