OpenLexocad  28.0
FaceTool.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Geom/Precision.h>
4 #include <Topo/ToolOutcome.h>
5 #include <Topo/Types.h>
6 #include <vector>
7 
8 
9 class FACE;
10 class TopoDS_Face;
11 
12 namespace Mesher
13 {
14 class ShapeTesselator;
15 class ShapeTesselator_OCC;
16 class TriangleData;
17 class TriangleData_OCC;
18 } // namespace Mesher
19 
20 namespace MesherAcis
21 {
22 class ShapeTesselator_Acis;
23 class TriangleData_Acis;
24 } // namespace MesherAcis
25 
26 
27 namespace Part
28 {
29 class SnapPointTool;
30 }
31 namespace Geom
32 {
33 class Pnt;
34 class Dir;
35 class Ax2;
36 class Circ;
37 class Trsf;
38 class Bnd_Box;
39 class Pnt2d;
40 enum class SurfaceType;
41 }
42 
43 namespace App
44 {
45 class SurfaceStyleAssignment;
46 } // namespace App
47 
48 namespace Topo
49 {
50 struct SpecialFaceInfo;
51 enum class FaceClashType;
58 class LX_TOPO_EXPORT FaceTool
59 {
60 public:
61  FaceTool(void);
62  virtual ~FaceTool(void);
63 
64  friend class Mesher::ShapeTesselator;
65  friend class Mesher::ShapeTesselator_OCC;
66  friend class MesherAcis::ShapeTesselator_Acis;
67  friend class Mesher::TriangleData;
68  friend class Mesher::TriangleData_OCC;
69  friend class MesherAcis::TriangleData_Acis;
70  friend class Part::SnapPointTool;
71 
73  // //
74  // --------------------- BEGIN API --------------------- //
75  // //
76  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
77  // //
79 
81  static pFace copy(pConstFace face);
83  static pFace makeFace(pWire outer, double precision = Geom::Precision::linear_Resolution());
85  static pFace makeFace(const Geom::Pnt& p1, const Geom::Pnt& p2, const Geom::Pnt& p3);
87  static pFace makeFace(const Geom::Pnt& p1, const Geom::Pnt& p2, const Geom::Pnt& p3, const Geom::Pnt& p4);
89  static pFace makeCylindricalFace(const Geom::Circ& aCircle, double aParam1, double aParam2, double aHeight);
92  static pFace makePlanarFace(pWire outerWire, const std::vector<pWire>& innerWires, double precision = Geom::Precision::linear_Resolution());
94  static pFace makePlanarFaceWithoutVoids(const std::vector<pWire>& wires, double precision = Geom::Precision::linear_Resolution());
96  static std::vector<pFace> makePlanarFaces(pConstBrepData data);
99  static pFace makeFace(pWire outerWire, const std::vector<pWire>& innerWires, double precision = Geom::Precision::linear_Resolution());
101  static pFace makePolygon(const std::vector<Geom::Pnt>& points);
103  static bool isValidPointForFace(const Geom::Pnt& p, pConstFace face, double precision = Geom::Precision::linear_Resolution());
109  static bool getGeomSurfaceType(FACE* face, Geom::SurfaceType& type);
111  static double getArea(pConstFace face);
115  static std::vector<pConstWire> getInnerBoundaries(pConstFace face);
117  static pShape makeConnectedFaceSet(const std::vector<int>& model, const std::vector<Geom::Pnt>& vertices);
119  static bool isNurbs(pConstFace face);
121  static pShape extrudedFace(pConstFace face, const Geom::Dir& extrudedDirection, double depth);
124  static bool extendFace(pFace face, const std::vector<pConstEdge>& edges, double offset);
126  static bool getCircularSurfaceParams(pConstFace face, Geom::Circ& circle);
128  static bool getCylinderSurfaceParams(pConstFace face, Geom::Ax2& position, double& radius);
130  static bool getCylinderSurfaceParams(FACE* face, Geom::Ax2& position, double& radius);
132  static bool getConeSurfaceParams(pConstFace face, Geom::Ax2& position, double& angle, double& radius);
134  static bool getConeSurfaceParams(FACE* face, Geom::Ax2& position, double& angle, double& radius);
138  static bool projectPointOnFace(const Geom::Pnt& p, pConstFace face, Geom::Pnt& nearest);
140  static bool projectPointOnFace(const Geom::Pnt& p, pConstFace face, double& u, double& v);
142  static bool isSelfIntersecting(pConstFace face);
144  static void getOuterBoundaryPoints(pConstFace face, std::vector<Geom::Pnt>& pnts);
146  static void getOuterBoundaryPointsFast(pConstFace face, std::vector<Geom::Pnt>& pnts);
148  static bool getPointFaceDistance(const Geom::Pnt& p, pConstFace face, Geom::Pnt& nearest, double& distance);
150  static bool containsFace(pConstFace outerface, pConstFace innerFace);
152  static std::shared_ptr<Topo::SpecialFaceInfo> getSpecialFaceInfo(pConstFace face);
154  static Topo::ToolOutcome clash(pConstFace face1, pConstFace face2, bool& hasClash);
158  static bool isRectangular(pConstFace face, Geom::Ax2& position, double& width, double& height);
159 
160  static void getOuterBoundaryPointsFast(FACE*, std::vector<Geom::Pnt>& pnt);
161 
163  // //
164  // ---------------------- END API ---------------------- //
165  // //
167 
168 #ifndef LXAPI // INTERFACES BELOW ARE -NOT- PART OF THE LEXOCAD API
169 
172  static void __setDefaultFaceTool__(Topo::FaceTool* tool) { _defaultTool = tool; }
173  static void __setAcisShapeTool__(Topo::FaceTool* tool) { _acisTool = tool; }
174  static bool isPlanarFace(pConstFace face);
175 
176 protected:
178  static bool getTopoDS_Face(pConstFace face, TopoDS_Face& topoFace);
179 
180  virtual pFace _copy(pConstFace face);
181  virtual pFace _makeFace(pWire outer, double precision);
182  virtual pFace _makeFace(pWire outerWire, const std::vector<pWire>& innerWires, double precision);
183  virtual pFace _makePolygon(const std::vector<Geom::Pnt>& points);
184  virtual bool _isValidPointForFace(const Geom::Pnt& p, pConstFace face, double precision = Geom::Precision::linear_Resolution());
185  virtual pFace _transformed(pConstFace face, const Geom::Trsf& transform);
186  virtual bool _getGeomSurfaceType(pConstFace face, Geom::SurfaceType& type);
187  virtual bool _getGeomSurfaceType(FACE* , Geom::SurfaceType& type);
188  virtual double _getArea(pConstFace face);
189  virtual bool _getTopoDS_Face(pConstFace face, TopoDS_Face& topoFace);
190  virtual pConstWire _getOuterBoundary(pConstFace face);
191  virtual std::vector<pConstWire> _getInnerBoundaries(pConstFace face);
192  virtual pShape _makeConnectedFaceSet(const std::vector<int>& model, const std::vector<Geom::Pnt>& vertices);
193  virtual pShape _extrudedFace(pConstFace face, const Geom::Dir& extrudedDirection, double depth);
194  virtual bool _extendFace(pFace face, const std::vector<pConstEdge>& edges, double offset);
195  virtual bool _getCylinderSurfaceParams(FACE* face, Geom::Ax2& position, double& radius);
196  virtual bool _getCylinderSurfaceParams(pConstFace face, Geom::Ax2& position, double& radius);
197  virtual bool _getConeSurfaceParams(FACE* face, Geom::Ax2& position, double& angle, double& radius);
198  virtual bool _getConeSurfaceParams(pConstFace face, Geom::Ax2& position, double& angle, double& radius);
199  virtual Geom::Pnt _getCentre(pConstFace face);
200  virtual bool _projectPointOnFace(const Geom::Pnt& p, pConstFace face, Geom::Pnt& nearest);
201  virtual bool _projectPointOnFace(const Geom::Pnt& p, pConstFace face, double& u, double& v);
202  virtual bool _isSelfIntersecting(pConstFace face);
203  virtual pFace _makePlanarFace(pWire outerWire, const std::vector<pWire>& innerWires, double precision);
204  virtual pFace _makePlanarFaceWithoutVoids(const std::vector<pWire>& wires, double precision);
205  virtual std::vector<pFace> _makePlanarFaces(pConstBrepData data);
206  virtual void _getOuterBoundaryPoints(pConstFace face, std::vector<Geom::Pnt>& pnts);
207  virtual void _getOuterBoundaryPointsFast(pConstFace face, std::vector<Geom::Pnt>& pnts);
208  virtual void _getOuterBoundaryPointsFast(FACE*, std::vector<Geom::Pnt>& pnts);
209  virtual bool _getPointFaceDistance(const Geom::Pnt& p, pConstFace face, Geom::Pnt& nearest, double& distance);
210  virtual bool _containsFace(pConstFace outerface, pConstFace innerFace);
211  virtual bool _createTextureCoordinates(pConstFace face,
212  const Geom::Bnd_Box& bbox,
213  const App::SurfaceStyleAssignment* ssa,
214  std::vector<Geom::Pnt2d>& coord);
215  virtual bool _isPlanarFace(pConstFace face);
216  virtual Topo::ToolOutcome _clash(pConstFace face1, pConstFace face2, bool& hasClash);
217  virtual Topo::ToolOutcome _clashFaces(pConstFace face1, pConstFace face2, Topo::FaceClashType& clashType);
218  static Topo::FaceTool* _defaultTool;
219  static Topo::FaceTool* _acisTool;
221 
222 #endif
223 };
224 
225 
226 } // namespace Topo
Topo::FaceTool::getOuterBoundaryPointsFast
static void getOuterBoundaryPointsFast(pConstFace face, std::vector< Geom::Pnt > &pnts)
Return the points of the outer boundary.
Topo::FaceTool::isRectangular
static bool isRectangular(pConstFace face, Geom::Ax2 &position, double &width, double &height)
Checks if a face is rectangular and returns its parameters.
Geom::Bnd_Box
Definition: Bnd_Box.h:67
Topo::FaceTool::getOuterBoundary
static pConstWire getOuterBoundary(pConstFace face)
Returns the outer boundary of the face.
Topo::FaceTool::isValidPointForFace
static bool isValidPointForFace(const Geom::Pnt &p, pConstFace face, double precision=Geom::Precision::linear_Resolution())
Checks if p is a valid point on face within the given tolerance.
Topo::FaceTool::isNurbs
static bool isNurbs(pConstFace face)
Returns true if surface type is BEZIERSURFACE or BSPLINESURFACE.
Base::transform
void transform(Container container, OutputIt out, BinaryFunction function)
Definition: Algorithms.h:30
Topo::FaceTool::makeFace
static pFace makeFace(const Geom::Pnt &p1, const Geom::Pnt &p2, const Geom::Pnt &p3)
Makes a face from three points.
Topo::ToolOutcome
Definition: ToolOutcome.h:6
Precision.h
Topo::FaceTool::projectPointOnFace
static bool projectPointOnFace(const Geom::Pnt &p, pConstFace face, Geom::Pnt &nearest)
Projects point 'p' on 'face'. Returns the nearest solution point.
Topo::FaceTool::clash
static Topo::ToolOutcome clash(pConstFace face1, pConstFace face2, bool &hasClash)
Performs a clash of two faces and reports if they touch one another.
Topo::FaceTool::clashFaces
static Topo::ToolOutcome clashFaces(pConstFace face1, pConstFace face2, Topo::FaceClashType &clashType)
Perform a real clash of two faces and report the way in which these shapes clash.
Topo::FaceTool::getOuterBoundaryPoints
static void getOuterBoundaryPoints(pConstFace face, std::vector< Geom::Pnt > &pnts)
Return the points of the outer boundary.
Topo::FaceTool::extendFace
static bool extendFace(pFace face, const std::vector< pConstEdge > &edges, double offset)
pConstWire
std::shared_ptr< Topo::Wire const > pConstWire
Definition: Types.h:71
Topo::FaceTool::makePlanarFaceWithoutVoids
static pFace makePlanarFaceWithoutVoids(const std::vector< pWire > &wires, double precision=Geom::Precision::linear_Resolution())
Makes a planar face from the given wires. Each closed region on each wire is covered and all of the c...
Topo::FaceTool::projectPointOnFace
static bool projectPointOnFace(const Geom::Pnt &p, pConstFace face, double &u, double &v)
Projects point 'p' on 'face'. Returns the parameter 'u' and 'v' at that point. Only the nearest solut...
Topo::FaceTool::getCircularSurfaceParams
static bool getCircularSurfaceParams(pConstFace face, Geom::Circ &circle)
Get parameters of circular face.
pFace
std::shared_ptr< Topo::Face > pFace
Definition: Types.h:53
Topo::FaceTool::getConeSurfaceParams
static bool getConeSurfaceParams(pConstFace face, Geom::Ax2 &position, double &angle, double &radius)
Get parameters of cone face.
Geom::Dir
Definition: Dir.h:45
Topo::FaceClashType
FaceClashType
Definition: Clash.h:25
Topo::FaceTool::makeFace
static pFace makeFace(const Geom::Pnt &p1, const Geom::Pnt &p2, const Geom::Pnt &p3, const Geom::Pnt &p4)
Makes a face from four points.
pShape
std::shared_ptr< Topo::Shape > pShape
Definition: Variant.h:64
pWire
std::shared_ptr< Topo::Wire > pWire
Definition: Types.h:54
Topo::FaceTool::getArea
static double getArea(pConstFace face)
Returns the area of the face.
Topo::FaceTool
Tools for creating, manipulating and querying Faces.
Definition: FaceTool.h:59
pConstFace
std::shared_ptr< Topo::Face const > pConstFace
Definition: Types.h:70
Geom::Circ
Definition: Circ.h:56
Topo::FaceTool::makeFace
static pFace makeFace(pWire outer, double precision=Geom::Precision::linear_Resolution())
Makes a face from a wire. The wire describes the outer boundary of the face.
Topo::FaceTool::extrudedFace
static pShape extrudedFace(pConstFace face, const Geom::Dir &extrudedDirection, double depth)
Extrudes a face in the given extrudedDirection with the given depth. It returns nullptr on failure.
MesherAcis
Definition: FaceTool.h:21
Geom::Pnt
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:44
Geom::Ax2
Definition: Ax2.h:66
Topo::FaceTool::isSelfIntersecting
static bool isSelfIntersecting(pConstFace face)
Returns true if the face is self-intersecting.
Topo::FaceTool::makeConnectedFaceSet
static pShape makeConnectedFaceSet(const std::vector< int > &model, const std::vector< Geom::Pnt > &vertices)
Makes a connected face set from a model description and a vector of points. Returns an empty shell on...
Topo::FaceTool::getPointFaceDistance
static bool getPointFaceDistance(const Geom::Pnt &p, pConstFace face, Geom::Pnt &nearest, double &distance)
Computes the minimum distances and the closest positions between an entity and a point.
Topo::FaceTool::~FaceTool
virtual ~FaceTool(void)
Geom::SurfaceType
SurfaceType
Definition: GeomEnums.h:24
Topo::FaceTool::makePolygon
static pFace makePolygon(const std::vector< Geom::Pnt > &points)
Makes a polygonal face from a vector of points.
Topo::FaceTool::makePlanarFace
static pFace makePlanarFace(pWire outerWire, const std::vector< pWire > &innerWires, double precision=Geom::Precision::linear_Resolution())
Geom::distance
double distance(const Geom::Vec &v1, const Geom::Vec &v2)
Returns the distance between two points.
Definition: Vec.h:341
pConstBrepData
std::shared_ptr< const Geom::BrepData > pConstBrepData
Definition: BrepData.h:31
Topo::FaceTool::getCylinderSurfaceParams
static bool getCylinderSurfaceParams(pConstFace face, Geom::Ax2 &position, double &radius)
Get parameters of cylinder face.
Topo
Definition: DbgInfo.h:17
Topo::FaceTool::makeFace
static pFace makeFace(pWire outerWire, const std::vector< pWire > &innerWires, double precision=Geom::Precision::linear_Resolution())
Types.h
Topo::FaceTool::getInnerBoundaries
static std::vector< pConstWire > getInnerBoundaries(pConstFace face)
Returns the inner boundaries of the face.
Topo::FaceTool::getSpecialFaceInfo
static std::shared_ptr< Topo::SpecialFaceInfo > getSpecialFaceInfo(pConstFace face)
Special Info for Face, Cone, Cylinder.
Topo::FaceTool::makeCylindricalFace
static pFace makeCylindricalFace(const Geom::Circ &aCircle, double aParam1, double aParam2, double aHeight)
Makes a cylindrical face.
Topo::FaceTool::getGeomSurfaceType
static bool getGeomSurfaceType(FACE *face, Geom::SurfaceType &type)
Returns the surface type of the underlying geometry of the face.
Topo::FaceTool::getOuterBoundaryPointsFast
static void getOuterBoundaryPointsFast(FACE *, std::vector< Geom::Pnt > &pnt)
Geom::Trsf
Definition: Trsf.h:58
Topo::FaceTool::getGeomSurfaceType
static bool getGeomSurfaceType(pConstFace face, Geom::SurfaceType &type)
Returns the surface type of the underlying geometry of the face.
Topo::ShapeType::FACE
@ FACE
ToolOutcome.h
Topo::FaceTool::copy
static pFace copy(pConstFace face)
Copies a face.
Topo::FaceTool::makePlanarFaces
static std::vector< pFace > makePlanarFaces(pConstBrepData data)
Makes planar faces from BrepData.
Topo::FaceTool::transformed
static pFace transformed(pConstFace face, const Geom::Trsf &transform)
Returns a copy of 'face' transformed by 'transform'.
Topo::FaceTool::containsFace
static bool containsFace(pConstFace outerface, pConstFace innerFace)
Contains Face.
Geom::Precision::linear_Resolution
static constexpr double linear_Resolution()
Definition: Precision.h:23
Topo::FaceTool::FaceTool
FaceTool(void)
Topo::FaceTool::getCentre
static Geom::Pnt getCentre(pConstFace face)
Returns centre of mass (centre of gravity) of the face.
Topo::FaceTool::getConeSurfaceParams
static bool getConeSurfaceParams(FACE *face, Geom::Ax2 &position, double &angle, double &radius)
Get parameters of cone face.
Topo::FaceTool::getCylinderSurfaceParams
static bool getCylinderSurfaceParams(FACE *face, Geom::Ax2 &position, double &radius)
Get parameters of cylinder face.
Geom
Definition: PropertyContainer.h:33