OpenLexocad  27.1
WireTool.h
Go to the documentation of this file.
1 #pragma once
2 
3 #pragma warning(push)
4 #pragma warning(disable : 4100)
5 #pragma warning(disable : 4005)
6 
7 #include <Geom/Dir.h>
8 #include <Geom/Pln.h>
9 #include <Geom/Pnt.h>
10 #include <Geom/Precision.h>
11 #include <Topo/Shape.h>
12 
13 #pragma warning(pop)
14 
15 namespace Topo
16 {
23 class LX_TOPO_EXPORT WireTool
24 {
25 public:
27  // //
28  // --------------------- BEGIN API --------------------- //
29  // //
30  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
31  // //
33 
35  static pWire projectWireOnPlane(const Geom::Pln& pln, pConstWire wire, double precision = Geom::Precision::linear_Resolution());
37  static bool projectPointOnWire(const Geom::Pnt& p, pConstWire wire, Geom::Pnt& nearest);
39  static bool projectPointOnWire(const Geom::Pnt& p, pConstWire wire, Geom::Pnt& nearest, Geom::Dir& refDirection);
41  static bool isPlanar(pConstWire wire, Geom::Pln& plane);
43  static bool isClosed(pConstWire wire);
45  static bool close(pWire wire, double precision = Geom::Precision::linear_Resolution());
47  static pWire closed(pConstWire wire, double precision = Geom::Precision::linear_Resolution());
49  static bool addEdge(pWire wire, pEdge edge, double precision = Geom::Precision::linear_Resolution());
51  static bool addEdge(pWire wire, const std::vector<pEdge>& edges, double precision = Geom::Precision::linear_Resolution());
53  static bool addConstEdge(pWire wire, pConstEdge edge, double precision = Geom::Precision::linear_Resolution());
55  static bool addConstEdge(pWire wire, const std::vector<pEdge>& edges, double precision = Geom::Precision::linear_Resolution());
57  static pWire addedEdge(pConstWire wire, pConstEdge edge, double precision = Geom::Precision::linear_Resolution());
59  static pWire addedEdge(pConstWire wire, const std::vector<pConstEdge>& edges, double precision = Geom::Precision::linear_Resolution());
61  static pConstVertex getClosestVertexToPoint(const Geom::Pnt& p, pConstWire wire);
63  static std::vector<pConstEdge> getClosestEdgesToPoint(const Geom::Pnt& p, pConstWire wire, double& distance, double tolerance = 1E-06);
65  static std::vector<pConstEdge> getAdjacentEdgesToVertexOnWire(pConstVertex vertex, pConstWire wire);
67  static void getAdjacentEdgesToPointOnWire(const Geom::Pnt& point, pConstWire wire, std::vector<pConstEdge>& adjacentEdges);
69  static pWire makeWire(const std::vector<pEdge>& edges, double precision = Geom::Precision::linear_Resolution());
71  static pWire makeWire(pEdge edges);
74  static pWire makeWire(pConstVertex vertex);
76  static std::vector<pWire> makeWires(const std::vector<pEdge>& edges, double precision = Geom::Precision::linear_Resolution());
78  static pWire copy(pConstWire wire);
80  static pWire makePolygon(const std::vector<Geom::Pnt>& points);
82  static pWire makePolyline(const std::vector<Geom::Pnt>& points);
84  static std::vector<pConstEdge> getEdges(pConstWire wire);
86  static std::vector<pEdge> getEdgesCopy(pConstWire wire);
88  static std::vector<pConstVertex> getVertices(pConstWire wire);
90  static void getPoints(pConstWire wire, std::vector<Geom::Pnt>& pnts);
92  static bool hasOnlyLines(pConstWire wire);
94  static bool hasHelix(pConstWire wire);
96  static bool fixReorder(pWire wire);
98  static void writeDbgInfo(pConstWire wire);
100  static Geom::Pnt getCentre(pConstWire wire);
102  static bool filletWireAtVertex(pWire wire, const Geom::Pnt& p, double radius, double precision = Geom::Precision::linear_Resolution());
104  static bool chamferWireAtVertex(pWire wire, const Geom::Pnt& p, double offset, double precision = Geom::Precision::linear_Resolution());
107  static bool removeEdgesFromWire(pWire wire,
108  std::vector<pConstEdge> edges,
109  double precision = Geom::Precision::linear_Resolution(),
110  bool stayInBndBox = false);
112  static pWire transformed(pConstWire base, const Geom::Trsf& t);
114  static bool isSelfIntersecting(pConstWire wire);
116  static pWire createOffset(pConstWire wire, const Geom::Dir& refDirection, double offset);
118  static pWire reversed(pConstWire wire);
120  static pWire joined(pConstWire wire1, pConstWire wire2);
121 
123  // //
124  // ---------------------- END API ---------------------- //
125  // //
127 
128 #ifndef LXAPI // INTERFACES BELOW ARE -NOT- PART OF THE LEXOCAD API
129 
132  static void __setDefaultWireTool__(Topo::WireTool* tool) { _defaultTool = tool; }
134  static pWire reverseWirePointsConnection(pConstWire wire, double precision = Geom::Precision::linear_Resolution());
137  static pWire
138  combineWireWithWire(pConstWire hWire, pConstWire vWire, const uint& x, const uint& y, const uint& z, const double& start, const double& end);
139 
140 protected:
141  virtual pWire _projectWireOnPlane(const Geom::Pln& pln, pConstWire wire, double precision);
142  virtual bool _projectPointOnWire(const Geom::Pnt& p, pConstWire wire, Geom::Pnt& nearest);
143  virtual bool _projectPointOnWire(const Geom::Pnt& p, pConstWire wire, Geom::Pnt& nearest, Geom::Dir& refDirection);
144  virtual bool _isPlanar(pConstWire wire, Geom::Pln& plane);
145  virtual bool _isClosed(pConstWire wire);
146  virtual pWire _closed(pConstWire wire, double precision);
147  virtual pWire _addedEdge(pConstWire wire, pConstEdge edge, double precision);
148  virtual pWire _addedEdge(pConstWire wire, const std::vector<pConstEdge>& edges, double precision);
149  virtual pConstVertex _getClosestVertexToPoint(const Geom::Pnt& p, pConstWire wire);
150  virtual std::vector<pConstEdge> _getClosestEdgesToPoint(const Geom::Pnt& p, pConstWire wire, double& distance, double precision = 1E-06);
151  virtual std::vector<pConstEdge> _getAdjacentEdgesToVertexOnWire(pConstVertex vertex, pConstWire wire);
152  virtual void _getAdjacentEdgesToPointOnWire(const Geom::Pnt& point, pConstWire wire, std::vector<pConstEdge>& adjacentEdges);
153  virtual pWire _makeWire(const std::vector<pEdge>& edges, double precision);
154  virtual pWire _makeWire(pConstVertex vertex);
155  virtual std::vector<pWire> _makeWires(const std::vector<pEdge>& edges, double precision);
156  virtual pWire _copy(pConstWire wire);
157  virtual pWire _makePolygon(const std::vector<Geom::Pnt>& points);
158  virtual pWire _makePolyline(const std::vector<Geom::Pnt>& points);
159  virtual std::vector<pConstEdge> _getEdges(pConstWire wire);
160  virtual std::vector<pConstVertex> _getVertices(pConstWire wire);
161  virtual void _getPoints(pConstWire wire, std::vector<Geom::Pnt>& pnts);
162  virtual pWire _reverseWirePointsConnection(pConstWire wire, double precision);
163  virtual pWire _createOffset(pConstWire wire, const Geom::Dir& refDirection, double offset);
164  virtual bool _fixReorder(pWire wire);
165  virtual void _writeDbgInfo(pConstWire wire);
166  virtual Geom::Pnt _getCentre(pConstWire wire);
167  virtual bool _filletWireAtVertex(pWire wire, const Geom::Pnt& p, double radius, double precision);
168  virtual bool _chamferWireAtVertex(pWire wire, const Geom::Pnt& p, double offset, double precision);
169  virtual bool _removeEdgesFromWire(pWire wire, std::vector<pConstEdge> edges, double precision, bool stayInBndBox = false);
170  virtual bool _isSelfIntersecting(pConstWire wire);
171  virtual pWire _reversed(pConstWire wire);
172  virtual pWire _joined(pConstWire wire1, pConstWire wire2);
173  virtual pWire
174  _combineWireWithWire(pConstWire hWire, pConstWire vWire, const uint& x, const uint& y, const uint& z, const double& start, const double& end);
175  static Topo::WireTool* _defaultTool;
177 #endif
178 };
179 
180 } // namespace Topo
std::shared_ptr< Topo::Wire const > pConstWire
Definition: Shape.h:97
Definition: Pln.h:57
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:43
std::shared_ptr< Topo::Edge const > pConstEdge
Definition: Shape.h:98
static const double linear_Resolution()
Definition: Precision.h:24
Definition: Trsf.h:57
Definition: Dir.h:45
Definition: Variant.h:55
std::shared_ptr< Topo::Vertex const > pConstVertex
Definition: Shape.h:100
double distance(const Geom::Vec &v1, const Geom::Vec &v2)
Returns the distance between two points.
Definition: Vec.h:345
Tools for creating, manipulating and querying Wires.
Definition: WireTool.h:23
std::shared_ptr< Topo::Wire > pWire
Definition: Shape.h:82
std::shared_ptr< Topo::Edge > pEdge
Definition: Shape.h:83