OpenLexocad  27.0
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 #include <Topo/topo_defines.h>
11 
12 class TopoDS_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 {
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);
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 double getArea(pConstFace face);
103  static pConstWire getOuterBoundary(pConstFace face);
105  static std::vector<pConstWire> getInnerBoundaries(pConstFace face);
107  static pShape makeConnectedFaceSet(const std::vector<int>& model, const std::vector<Geom::Pnt>& vertices);
109  static bool isNurbs(pConstFace face);
111  static pShape extrudedFace(pConstFace face, const Geom::Dir& extrudedDirection, double depth);
114  static bool extendFace(pFace face, const std::vector<pConstEdge>& edges, double offset);
116  static bool getCircularSurfaceParams(pConstFace face, Geom::Circ& circle);
118  static bool getCylinderSurfaceParams(pConstFace face, Geom::Ax2& position, double& radius);
120  static bool getConeSurfaceParams(pConstFace face, Geom::Ax2& position, double& angle, double& radius);
122  static Geom::Pnt getCentre(pConstFace face);
124  static bool projectPointOnFace(const Geom::Pnt& p, pConstFace face, Geom::Pnt& nearest);
126  static bool projectPointOnFace(const Geom::Pnt& p, pConstFace face, double& u, double& v);
128  static bool isSelfIntersecting(pConstFace face);
130  static void getOuterBoundaryPoints(pConstFace face, std::vector<Geom::Pnt>& pnts);
132  static void getOuterBoundaryPointsFast(pConstFace face, std::vector<Geom::Pnt>& pnts);
134  static bool getPointFaceDistance(const Geom::Pnt& p, pConstFace face, Geom::Pnt& nearest, double& distance);
136  static bool containsFace(pConstFace outerface, pConstFace innerFace);
138  static std::shared_ptr<Topo::SpecialFaceInfo> getSpecialFaceInfo(pConstFace face);
140  static Topo::ToolOutcome clash(pConstFace face1, pConstFace face2, bool& hasClash);
142  static Topo::ToolOutcome clashFaces(pConstFace face1, pConstFace face2, Topo::FaceClashType& clashType);
144  static bool isRectangular(pConstFace face, Geom::Ax2& position, double& width, double& height);
145 
147  // //
148  // ---------------------- END API ---------------------- //
149  // //
151 
152 #ifndef LXAPI // INTERFACES BELOW ARE -NOT- PART OF THE LEXOCAD API
153 
156  static void __setDefaultFaceTool__(Topo::FaceTool* tool) { _defaultTool = tool; }
157  static bool isPlanarFace(pConstFace face);
158 
159 protected:
161  static bool getTopoDS_Face(pConstFace face, TopoDS_Face& topoFace);
162 
163  virtual pFace _copy(pConstFace face);
164  virtual pFace _makeFace(pWire outer, double precision);
165  virtual pFace _makeFace(pWire outerWire, const std::vector<pWire>& innerWires, double precision);
166  virtual pFace _makePolygon(const std::vector<Geom::Pnt>& points);
167  virtual bool _isValidPointForFace(const Geom::Pnt& p, pConstFace face, double precision = Geom::Precision::linear_Resolution());
168  virtual pFace _transformed(pConstFace face, const Geom::Trsf& transform);
169  virtual bool _getGeomSurfaceType(pConstFace face, Geom::SurfaceType& type);
170  virtual double _getArea(pConstFace face);
171  virtual bool _getTopoDS_Face(pConstFace face, TopoDS_Face& topoFace);
172  virtual pConstWire _getOuterBoundary(pConstFace face);
173  virtual std::vector<pConstWire> _getInnerBoundaries(pConstFace face);
174  virtual pShape _makeConnectedFaceSet(const std::vector<int>& model, const std::vector<Geom::Pnt>& vertices);
175  virtual pShape _extrudedFace(pConstFace face, const Geom::Dir& extrudedDirection, double depth);
176  virtual bool _extendFace(pFace face, const std::vector<pConstEdge>& edges, double offset);
177  virtual bool _getCylinderSurfaceParams(pConstFace face, Geom::Ax2& position, double& radius);
178  virtual bool _getConeSurfaceParams(pConstFace face, Geom::Ax2& position, double& angle, double& radius);
179  virtual Geom::Pnt _getCentre(pConstFace face);
180  virtual bool _projectPointOnFace(const Geom::Pnt& p, pConstFace face, Geom::Pnt& nearest);
181  virtual bool _projectPointOnFace(const Geom::Pnt& p, pConstFace face, double& u, double& v);
182  virtual bool _isSelfIntersecting(pConstFace face);
183  virtual pFace _makePlanarFace(pWire outerWire, const std::vector<pWire>& innerWires, double precision);
184  virtual pFace _makePlanarFaceWithoutVoids(const std::vector<pWire>& wires, double precision);
185  virtual std::vector<pFace> _makePlanarFaces(pConstBrepData data);
186  virtual void _getOuterBoundaryPoints(pConstFace face, std::vector<Geom::Pnt>& pnts);
187  virtual void _getOuterBoundaryPointsFast(pConstFace face, std::vector<Geom::Pnt>& pnts);
188  virtual bool _getPointFaceDistance(const Geom::Pnt& p, pConstFace face, Geom::Pnt& nearest, double& distance);
189  virtual bool _containsFace(pConstFace outerface, pConstFace innerFace);
190  virtual bool _createTextureCoordinates(pConstFace face,
191  const Geom::Bnd_Box& bbox,
192  const App::SurfaceStyleAssignment* ssa,
193  std::vector<Geom::Pnt2d>& coord);
194  virtual bool _isPlanarFace(pConstFace face);
195  virtual Topo::ToolOutcome _clash(pConstFace face1, pConstFace face2, bool& hasClash);
196  virtual Topo::ToolOutcome _clashFaces(pConstFace face1, pConstFace face2, Topo::FaceClashType& clashType);
197  static Topo::FaceTool* _defaultTool;
199 
200 #endif
201 };
202 
203 } // namespace Topo
Definition: Circ.h:66
std::shared_ptr< Topo::Wire const > pConstWire
Definition: Shape.h:98
#define TOPO_EXPORT
Definition: topo_defines.h:8
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:42
static const double linear_Resolution()
Definition: Precision.h:26
Definition: Shape.h:694
Definition: FaceTool.h:24
std::shared_ptr< Topo::Face const > pConstFace
Definition: Shape.h:97
Definition: Bnd_Box.h:66
std::shared_ptr< Topo::Face > pFace
Definition: Shape.h:82
Definition: Ax2.h:69
Definition: Trsf.h:58
Definition: Dir.h:46
std::shared_ptr< const Geom::BrepData > pConstBrepData
Definition: BrepData.h:37
Definition: Variant.h:70
Tools for creating, manipulating and querying Faces.
Definition: FaceTool.h:50
SurfaceType
Definition: GeomEnums.h:26
std::shared_ptr< Topo::Wire > pWire
Definition: Shape.h:83
FaceClashType
Definition: Clash.h:24
std::shared_ptr< Topo::Shape > pShape
Definition: Variant.h:80