OpenLexocad  27.1
FaceTool.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Geom/BrepData.h>
4 #include <Geom/Circ.h>
5 #include <Geom/Pnt.h>
6 #include <Geom/Precision.h>
7 #include <Geom/Trsf.h>
8 #include <Topo/Clash.h>
9 #include <Topo/Shape.h>
10 
11 class TopoDS_Face;
12 class FACE;
13 
14 namespace Mesher
15 {
16 class ShapeTesselator;
17 class ShapeTesselator_OCC;
18 class ShapeTesselator_Acis;
19 class TriangleData;
20 class TriangleData_OCC;
21 class TriangleData_Acis;
22 } // namespace Mesher
23 
24 namespace MesherAcis
25 {
26 class ShapeTesselator_Acis;
27 class TriangleData_Acis;
28 } // namespace MesherAcis
29 
30 
31 namespace Part
32 {
33 class SnapPointTool;
34 }
35 
36 namespace App
37 {
38 class SurfaceStyleAssignment;
39 class FaceDetail;
40 } // namespace App
41 
42 namespace Topo
43 {
50 class LX_TOPO_EXPORT FaceTool
51 {
52 public:
53  FaceTool(void);
54  virtual ~FaceTool(void);
55 
56  friend class Mesher::ShapeTesselator;
57  friend class Mesher::ShapeTesselator_OCC;
58  friend class MesherAcis::ShapeTesselator_Acis;
59  friend class Mesher::TriangleData;
60  friend class Mesher::TriangleData_OCC;
61  friend class MesherAcis::TriangleData_Acis;
62  friend class Part::SnapPointTool;
63 
65  // //
66  // --------------------- BEGIN API --------------------- //
67  // //
68  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
69  // //
71 
73  static pFace copy(pConstFace face);
75  static pFace makeFace(pWire outer, double precision = Geom::Precision::linear_Resolution());
77  static pFace makeFace(const Geom::Pnt& p1, const Geom::Pnt& p2, const Geom::Pnt& p3);
79  static pFace makeFace(const Geom::Pnt& p1, const Geom::Pnt& p2, const Geom::Pnt& p3, const Geom::Pnt& p4);
81  static pFace makeCylindricalFace(const Geom::Circ& aCircle, double aParam1, double aParam2, double aHeight);
84  static pFace makePlanarFace(pWire outerWire, const std::vector<pWire>& innerWires, double precision = Geom::Precision::linear_Resolution());
86  static pFace makePlanarFaceWithoutVoids(const std::vector<pWire>& wires, double precision = Geom::Precision::linear_Resolution());
88  static std::vector<pFace> makePlanarFaces(pConstBrepData data);
91  static pFace makeFace(pWire outerWire, const std::vector<pWire>& innerWires, double precision = Geom::Precision::linear_Resolution());
93  static pFace makePolygon(const std::vector<Geom::Pnt>& points);
95  static bool isValidPointForFace(const Geom::Pnt& p, pConstFace face, double precision = Geom::Precision::linear_Resolution());
97  static pFace transformed(pConstFace face, const Geom::Trsf& transform);
99  static bool getGeomSurfaceType(pConstFace face, Geom::SurfaceType& type);
101  static bool getGeomSurfaceType(FACE* face, Geom::SurfaceType& type);
103  static double getArea(pConstFace face);
105  static pConstWire getOuterBoundary(pConstFace face);
107  static std::vector<pConstWire> getInnerBoundaries(pConstFace face);
109  static pShape makeConnectedFaceSet(const std::vector<int>& model, const std::vector<Geom::Pnt>& vertices);
111  static bool isNurbs(pConstFace face);
113  static pShape extrudedFace(pConstFace face, const Geom::Dir& extrudedDirection, double depth);
116  static bool extendFace(pFace face, const std::vector<pConstEdge>& edges, double offset);
118  static bool getCircularSurfaceParams(pConstFace face, Geom::Circ& circle);
120  static bool getCylinderSurfaceParams(pConstFace face, Geom::Ax2& position, double& radius);
122  static bool getCylinderSurfaceParams(FACE* face, Geom::Ax2& position, double& radius);
124  static bool getConeSurfaceParams(pConstFace face, Geom::Ax2& position, double& angle, double& radius);
126  static bool getConeSurfaceParams(FACE* face, Geom::Ax2& position, double& angle, double& radius);
128  static Geom::Pnt getCentre(pConstFace face);
130  static bool projectPointOnFace(const Geom::Pnt& p, pConstFace face, Geom::Pnt& nearest);
132  static bool projectPointOnFace(const Geom::Pnt& p, pConstFace face, double& u, double& v);
134  static bool isSelfIntersecting(pConstFace face);
136  static void getOuterBoundaryPoints(pConstFace face, std::vector<Geom::Pnt>& pnts);
138  static void getOuterBoundaryPointsFast(pConstFace face, std::vector<Geom::Pnt>& pnts);
140  static bool getPointFaceDistance(const Geom::Pnt& p, pConstFace face, Geom::Pnt& nearest, double& distance);
142  static bool containsFace(pConstFace outerface, pConstFace innerFace);
144  static std::shared_ptr<Topo::SpecialFaceInfo> getSpecialFaceInfo(pConstFace face);
146  static Topo::ToolOutcome clash(pConstFace face1, pConstFace face2, bool& hasClash);
148  static Topo::ToolOutcome clashFaces(pConstFace face1, pConstFace face2, Topo::FaceClashType& clashType);
150  static bool isRectangular(pConstFace face, Geom::Ax2& position, double& width, double& height);
151 
152  static void getOuterBoundaryPointsFast(FACE*, std::vector<Geom::Pnt>& pnt);
153 
155  // //
156  // ---------------------- END API ---------------------- //
157  // //
159 
160 #ifndef LXAPI // INTERFACES BELOW ARE -NOT- PART OF THE LEXOCAD API
161 
164  static void __setDefaultFaceTool__(Topo::FaceTool* tool) { _defaultTool = tool; }
165  static void __setAcisShapeTool__(Topo::FaceTool* tool) { _acisTool = tool; }
166  static bool isPlanarFace(pConstFace face);
167 
168 protected:
170  static bool getTopoDS_Face(pConstFace face, TopoDS_Face& topoFace);
171 
172  virtual pFace _copy(pConstFace face);
173  virtual pFace _makeFace(pWire outer, double precision);
174  virtual pFace _makeFace(pWire outerWire, const std::vector<pWire>& innerWires, double precision);
175  virtual pFace _makePolygon(const std::vector<Geom::Pnt>& points);
176  virtual bool _isValidPointForFace(const Geom::Pnt& p, pConstFace face, double precision = Geom::Precision::linear_Resolution());
177  virtual pFace _transformed(pConstFace face, const Geom::Trsf& transform);
178  virtual bool _getGeomSurfaceType(pConstFace face, Geom::SurfaceType& type);
179  virtual bool _getGeomSurfaceType(FACE* , Geom::SurfaceType& type);
180  virtual double _getArea(pConstFace face);
181  virtual bool _getTopoDS_Face(pConstFace face, TopoDS_Face& topoFace);
182  virtual pConstWire _getOuterBoundary(pConstFace face);
183  virtual std::vector<pConstWire> _getInnerBoundaries(pConstFace face);
184  virtual pShape _makeConnectedFaceSet(const std::vector<int>& model, const std::vector<Geom::Pnt>& vertices);
185  virtual pShape _extrudedFace(pConstFace face, const Geom::Dir& extrudedDirection, double depth);
186  virtual bool _extendFace(pFace face, const std::vector<pConstEdge>& edges, double offset);
187  virtual bool _getCylinderSurfaceParams(FACE* face, Geom::Ax2& position, double& radius);
188  virtual bool _getCylinderSurfaceParams(pConstFace face, Geom::Ax2& position, double& radius);
189  virtual bool _getConeSurfaceParams(FACE* face, Geom::Ax2& position, double& angle, double& radius);
190  virtual bool _getConeSurfaceParams(pConstFace face, Geom::Ax2& position, double& angle, double& radius);
191  virtual Geom::Pnt _getCentre(pConstFace face);
192  virtual bool _projectPointOnFace(const Geom::Pnt& p, pConstFace face, Geom::Pnt& nearest);
193  virtual bool _projectPointOnFace(const Geom::Pnt& p, pConstFace face, double& u, double& v);
194  virtual bool _isSelfIntersecting(pConstFace face);
195  virtual pFace _makePlanarFace(pWire outerWire, const std::vector<pWire>& innerWires, double precision);
196  virtual pFace _makePlanarFaceWithoutVoids(const std::vector<pWire>& wires, double precision);
197  virtual std::vector<pFace> _makePlanarFaces(pConstBrepData data);
198  virtual void _getOuterBoundaryPoints(pConstFace face, std::vector<Geom::Pnt>& pnts);
199  virtual void _getOuterBoundaryPointsFast(pConstFace face, std::vector<Geom::Pnt>& pnts);
200  virtual void _getOuterBoundaryPointsFast(FACE*, std::vector<Geom::Pnt>& pnts);
201  virtual bool _getPointFaceDistance(const Geom::Pnt& p, pConstFace face, Geom::Pnt& nearest, double& distance);
202  virtual bool _containsFace(pConstFace outerface, pConstFace innerFace);
203  virtual bool _createTextureCoordinates(pConstFace face,
204  const Geom::Bnd_Box& bbox,
205  const App::SurfaceStyleAssignment* ssa,
206  std::vector<Geom::Pnt2d>& coord);
207  virtual bool _isPlanarFace(pConstFace face);
208  virtual Topo::ToolOutcome _clash(pConstFace face1, pConstFace face2, bool& hasClash);
209  virtual Topo::ToolOutcome _clashFaces(pConstFace face1, pConstFace face2, Topo::FaceClashType& clashType);
210  static Topo::FaceTool* _defaultTool;
211  static Topo::FaceTool* _acisTool;
213 
214 #endif
215 };
216 
217 
218 } // namespace Topo
Definition: Circ.h:53
std::shared_ptr< Topo::Wire const > pConstWire
Definition: Shape.h:97
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:43
static const double linear_Resolution()
Definition: Precision.h:24
Definition: Shape.h:693
Definition: FaceTool.h:24
std::shared_ptr< Topo::Face const > pConstFace
Definition: Shape.h:96
Definition: Bnd_Box.h:63
std::shared_ptr< Topo::Face > pFace
Definition: Shape.h:81
void transform(Container container, OutputIt out, BinaryFunction function)
Definition: Algorithms.h:29
Definition: Ax2.h:67
Definition: Trsf.h:57
Definition: Dir.h:45
std::shared_ptr< const Geom::BrepData > pConstBrepData
Definition: BrepData.h:31
Definition: Variant.h:55
Tools for creating, manipulating and querying Faces.
Definition: FaceTool.h:50
SurfaceType
Definition: GeomEnums.h:23
double distance(const Geom::Vec &v1, const Geom::Vec &v2)
Returns the distance between two points.
Definition: Vec.h:345
std::shared_ptr< Topo::Wire > pWire
Definition: Shape.h:82
FaceClashType
Definition: Clash.h:24
std::shared_ptr< Topo::Shape > pShape
Definition: Variant.h:76