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   virtual void computeTolerance(
82     const Standard_Real theLenU,
83     const Standard_Real theLenV);
84
85   //! Computes parametric delta taking length along U and V and value of tolerance into account.
86   virtual void computeDelta(
87     const Standard_Real theLengthU,
88     const Standard_Real theLengthV);
89
90 public:
91   //! Returns face model.
92   inline const IMeshData::IFaceHandle& GetDFace() const
93   {
94     return myDFace;
95   }
96
97   //! Returns surface.
98   inline const Handle(BRepAdaptor_HSurface)& GetSurface() const
99   {
100     return myDFace->GetSurface();
101   }
102
103   //! Returns U range.
104   inline const std::pair<Standard_Real, Standard_Real>& GetRangeU() const
105   {
106     return myRangeU;
107   }
108
109   //! Returns V range.
110   inline const std::pair<Standard_Real, Standard_Real>& GetRangeV() const
111   {
112     return myRangeV;
113   }
114
115   //! Returns delta.
116   inline const std::pair<Standard_Real, Standard_Real>& GetDelta () const
117   {
118     return myDelta;
119   }
120
121   inline const std::pair<Standard_Real, Standard_Real>& GetToleranceUV() const
122   {
123     return myTolerance;
124   }
125
126 private:
127
128   //! Computes length along U direction.
129   Standard_Real computeLengthU();
130
131   //! Computes length along V direction.
132   Standard_Real computeLengthV();
133
134   //! Updates discrete range of surface according to its geometric range.
135   void updateRange(const Standard_Real     theGeomFirst,
136                    const Standard_Real     theGeomLast,
137                    const Standard_Boolean  isPeriodic,
138                    Standard_Real&          theDiscreteFirst,
139                    Standard_Real&          theDiscreteLast);
140
141 protected:
142   IMeshData::IFaceHandle                  myDFace;
143   std::pair<Standard_Real, Standard_Real> myRangeU;
144   std::pair<Standard_Real, Standard_Real> myRangeV;
145   std::pair<Standard_Real, Standard_Real> myDelta;
146   std::pair<Standard_Real, Standard_Real> myTolerance;
147   Standard_Boolean                        myIsValid;
148 };
149
150 #endif