1 // Created on: 2016-07-07
2 // Copyright (c) 2016 OPEN CASCADE SAS
3 // Created by: Oleg AGASHIN
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _BRepMesh_DefaultRangeSplitter_HeaderFile
17 #define _BRepMesh_DefaultRangeSplitter_HeaderFile
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>
25 struct IMeshTools_Parameters;
27 //! Default tool to define range of discrete face model and
28 //! obtain grid points distributed within this range.
29 class BRepMesh_DefaultRangeSplitter
34 BRepMesh_DefaultRangeSplitter()
35 : myIsValid (Standard_True)
40 virtual ~BRepMesh_DefaultRangeSplitter()
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);
48 //! Registers border point.
49 Standard_EXPORT virtual void AddPoint(const gp_Pnt2d& thePoint);
51 //! Updates discrete range of surface according to its geometric range.
52 Standard_EXPORT virtual void AdjustRange();
54 //! Returns True if computed range is valid.
55 Standard_EXPORT virtual Standard_Boolean IsValid();
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;
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;
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
75 return GetSurface()->Value(thePoint2d.X(), thePoint2d.Y());
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);
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);
91 //! Returns face model.
92 inline const IMeshData::IFaceHandle& GetDFace() const
98 inline const Handle(BRepAdaptor_HSurface)& GetSurface() const
100 return myDFace->GetSurface();
104 inline const std::pair<Standard_Real, Standard_Real>& GetRangeU() const
110 inline const std::pair<Standard_Real, Standard_Real>& GetRangeV() const
116 inline const std::pair<Standard_Real, Standard_Real>& GetDelta () const
121 inline const std::pair<Standard_Real, Standard_Real>& GetToleranceUV() const
128 //! Computes length along U direction.
129 Standard_Real computeLengthU();
131 //! Computes length along V direction.
132 Standard_Real computeLengthV();
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);
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;