0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / BRepMesh / BRepMesh_DefaultRangeSplitter.hxx
1 // Created on: 2016-07-07
2 // Copyright (c) 2016 OPEN CASCADE SAS
3 // Created by: Oleg AGASHIN
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_DefaultRangeSplitter_HeaderFile
17 #define _BRepMesh_DefaultRangeSplitter_HeaderFile
18
19 #include <Standard_Type.hxx>
20 #include <gp_Pnt2d.hxx>
21 #include <BRepAdaptor_HSurface.hxx>
22 #include <IMeshData_Types.hxx>
23 #include <IMeshData_Face.hxx>
24
25 struct IMeshTools_Parameters;
26
27 //! Default tool to define range of discrete face model and 
28 //! obtain grid points distributed within this range.
29 class BRepMesh_DefaultRangeSplitter
30 {
31 public:
32
33   //! Constructor.
34   BRepMesh_DefaultRangeSplitter()
35     : myIsValid (Standard_True)
36   {
37   }
38
39   //! Destructor.
40   virtual ~BRepMesh_DefaultRangeSplitter()
41   {
42   }
43
44   //! Resets this splitter. Must be called before first use.
45   Standard_EXPORT virtual void Reset(const IMeshData::IFaceHandle& theDFace,
46                                      const IMeshTools_Parameters& theParameters);
47
48   //! Registers border point.
49   Standard_EXPORT virtual void AddPoint(const gp_Pnt2d& thePoint);
50
51   //! Updates discrete range of surface according to its geometric range.
52   Standard_EXPORT virtual void AdjustRange();
53
54   //! Returns True if computed range is valid.
55   Standard_EXPORT virtual Standard_Boolean IsValid();
56
57   //! Scales the given point from real parametric space 
58   //! to face basis and otherwise.
59   //! @param thePoint point to be scaled.
60   //! @param isToFaceBasis if TRUE converts point to face basis,
61   //! otherwise performs reverse conversion.
62   //! @return scaled point.
63   Standard_EXPORT gp_Pnt2d Scale(const gp_Pnt2d&        thePoint,
64                                  const Standard_Boolean isToFaceBasis) const;
65
66   //! Returns list of nodes generated using surface data and specified parameters.
67   //! By default returns null ptr.
68   Standard_EXPORT virtual Handle(IMeshData::ListOfPnt2d) GenerateSurfaceNodes(
69     const IMeshTools_Parameters& theParameters) const;
70
71   //! Returns point in 3d space corresponded to the given 
72   //! point defined in parameteric space of surface.
73   inline gp_Pnt Point(const gp_Pnt2d& thePoint2d) const
74   {
75     return GetSurface()->Value(thePoint2d.X(), thePoint2d.Y());
76   }
77
78 protected:
79
80   //! Computes parametric tolerance taking length along U and V into account.
81   Standard_EXPORT virtual void computeTolerance (const Standard_Real theLenU, const Standard_Real theLenV);
82
83   //! Computes parametric delta taking length along U and V and value of tolerance into account.
84   Standard_EXPORT virtual void computeDelta (const Standard_Real theLengthU, const Standard_Real theLengthV);
85
86 public:
87   //! Returns face model.
88   inline const IMeshData::IFaceHandle& GetDFace() const
89   {
90     return myDFace;
91   }
92
93   //! Returns surface.
94   inline const Handle(BRepAdaptor_HSurface)& GetSurface() const
95   {
96     return myDFace->GetSurface();
97   }
98
99   //! Returns U range.
100   inline const std::pair<Standard_Real, Standard_Real>& GetRangeU() const
101   {
102     return myRangeU;
103   }
104
105   //! Returns V range.
106   inline const std::pair<Standard_Real, Standard_Real>& GetRangeV() const
107   {
108     return myRangeV;
109   }
110
111   //! Returns delta.
112   inline const std::pair<Standard_Real, Standard_Real>& GetDelta () const
113   {
114     return myDelta;
115   }
116
117   inline const std::pair<Standard_Real, Standard_Real>& GetToleranceUV() const
118   {
119     return myTolerance;
120   }
121
122 private:
123
124   //! Computes length along U direction.
125   Standard_Real computeLengthU();
126
127   //! Computes length along V direction.
128   Standard_Real computeLengthV();
129
130   //! Updates discrete range of surface according to its geometric range.
131   void updateRange(const Standard_Real     theGeomFirst,
132                    const Standard_Real     theGeomLast,
133                    const Standard_Boolean  isPeriodic,
134                    Standard_Real&          theDiscreteFirst,
135                    Standard_Real&          theDiscreteLast);
136
137 protected:
138   IMeshData::IFaceHandle                  myDFace;
139   std::pair<Standard_Real, Standard_Real> myRangeU;
140   std::pair<Standard_Real, Standard_Real> myRangeV;
141   std::pair<Standard_Real, Standard_Real> myDelta;
142   std::pair<Standard_Real, Standard_Real> myTolerance;
143   Standard_Boolean                        myIsValid;
144 };
145
146 #endif