OpenLexocad  27.0
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 #include <Topo/topo_defines.h>
13 
14 #pragma warning(pop)
15 
16 namespace Topo
17 {
25 {
26 public:
28  // //
29  // --------------------- BEGIN API --------------------- //
30  // //
31  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
32  // //
34 
36  static pWire projectWireOnPlane(const Geom::Pln& pln, pConstWire wire, double precision = Geom::Precision::linear_Resolution());
38  static bool projectPointOnWire(const Geom::Pnt& p, pConstWire wire, Geom::Pnt& nearest);
40  static bool projectPointOnWire(const Geom::Pnt& p, pConstWire wire, Geom::Pnt& nearest, Geom::Dir& refDirection);
42  static bool isPlanar(pConstWire wire, Geom::Pln& plane);
44  static bool isClosed(pConstWire wire);
46  static bool close(pWire wire, double precision = Geom::Precision::linear_Resolution());
48  static pWire closed(pConstWire wire, double precision = Geom::Precision::linear_Resolution());
50  static bool addEdge(pWire wire, pEdge edge, double precision = Geom::Precision::linear_Resolution());
52  static bool addEdge(pWire wire, const std::vector<pEdge>& edges, double precision = Geom::Precision::linear_Resolution());
54  static bool addConstEdge(pWire wire, pConstEdge edge, double precision = Geom::Precision::linear_Resolution());
56  static bool addConstEdge(pWire wire, const std::vector<pEdge>& edges, double precision = Geom::Precision::linear_Resolution());
58  static pWire addedEdge(pConstWire wire, pConstEdge edge, double precision = Geom::Precision::linear_Resolution());
60  static pWire addedEdge(pConstWire wire, const std::vector<pConstEdge>& edges, double precision = Geom::Precision::linear_Resolution());
62  static pConstVertex getClosestVertexToPoint(const Geom::Pnt& p, pConstWire wire);
64  static std::vector<pConstEdge> getClosestEdgesToPoint(const Geom::Pnt& p, pConstWire wire, double& distance, double tolerance = 1E-06);
66  static std::vector<pConstEdge> getAdjacentEdgesToVertexOnWire(pConstVertex vertex, pConstWire wire);
68  static void getAdjacentEdgesToPointOnWire(const Geom::Pnt& point, pConstWire wire, std::vector<pConstEdge>& adjacentEdges);
70  static pWire makeWire(const std::vector<pEdge>& edges, double precision = Geom::Precision::linear_Resolution());
72  static pWire makeWire(pEdge edges);
75  static pWire makeWire(pConstVertex vertex);
77  static std::vector<pWire> makeWires(const std::vector<pEdge>& edges, double precision = Geom::Precision::linear_Resolution());
79  static pWire copy(pConstWire wire);
81  static pWire makePolygon(const std::vector<Geom::Pnt>& points);
83  static pWire makePolyline(const std::vector<Geom::Pnt>& points);
85  static std::vector<pConstEdge> getEdges(pConstWire wire);
87  static std::vector<pEdge> getEdgesCopy(pConstWire wire);
89  static std::vector<pConstVertex> getVertices(pConstWire wire);
91  static void getPoints(pConstWire wire, std::vector<Geom::Pnt>& pnts);
93  static bool hasOnlyLines(pConstWire wire);
95  static bool hasHelix(pConstWire wire);
97  static bool fixReorder(pWire wire);
99  static void writeDbgInfo(pConstWire wire);
101  static Geom::Pnt getCentre(pConstWire wire);
103  static bool filletWireAtVertex(pWire wire, const Geom::Pnt& p, double radius, double precision = Geom::Precision::linear_Resolution());
105  static bool chamferWireAtVertex(pWire wire, const Geom::Pnt& p, double offset, double precision = Geom::Precision::linear_Resolution());
108  static bool removeEdgesFromWire(pWire wire,
109  std::vector<pConstEdge> edges,
110  double precision = Geom::Precision::linear_Resolution(),
111  bool stayInBndBox = false);
113  static pWire transformed(pConstWire base, const Geom::Trsf& t);
115  static bool isSelfIntersecting(pConstWire wire);
117  static pWire createOffset(pConstWire wire, const Geom::Dir& refDirection, double offset);
119  static pWire reversed(pConstWire wire);
121  static pWire joined(pConstWire wire1, pConstWire wire2);
122 
124  // //
125  // ---------------------- END API ---------------------- //
126  // //
128 
129 #ifndef LXAPI // INTERFACES BELOW ARE -NOT- PART OF THE LEXOCAD API
130 
133  static void __setDefaultWireTool__(Topo::WireTool* tool) { _defaultTool = tool; }
135  static pWire reverseWirePointsConnection(pConstWire wire, double precision = Geom::Precision::linear_Resolution());
138  static pWire
139  combineWireWithWire(pConstWire hWire, pConstWire vWire, const uint& x, const uint& y, const uint& z, const double& start, const double& end);
140 
141 protected:
142  virtual pWire _projectWireOnPlane(const Geom::Pln& pln, pConstWire wire, double precision);
143  virtual bool _projectPointOnWire(const Geom::Pnt& p, pConstWire wire, Geom::Pnt& nearest);
144  virtual bool _projectPointOnWire(const Geom::Pnt& p, pConstWire wire, Geom::Pnt& nearest, Geom::Dir& refDirection);
145  virtual bool _isPlanar(pConstWire wire, Geom::Pln& plane);
146  virtual bool _isClosed(pConstWire wire);
147  virtual pWire _closed(pConstWire wire, double precision);
148  virtual pWire _addedEdge(pConstWire wire, pConstEdge edge, double precision);
149  virtual pWire _addedEdge(pConstWire wire, const std::vector<pConstEdge>& edges, double precision);
150  virtual pConstVertex _getClosestVertexToPoint(const Geom::Pnt& p, pConstWire wire);
151  virtual std::vector<pConstEdge> _getClosestEdgesToPoint(const Geom::Pnt& p, pConstWire wire, double& distance, double precision = 1E-06);
152  virtual std::vector<pConstEdge> _getAdjacentEdgesToVertexOnWire(pConstVertex vertex, pConstWire wire);
153  virtual void _getAdjacentEdgesToPointOnWire(const Geom::Pnt& point, pConstWire wire, std::vector<pConstEdge>& adjacentEdges);
154  virtual pWire _makeWire(const std::vector<pEdge>& edges, double precision);
155  virtual pWire _makeWire(pConstVertex vertex);
156  virtual std::vector<pWire> _makeWires(const std::vector<pEdge>& edges, double precision);
157  virtual pWire _copy(pConstWire wire);
158  virtual pWire _makePolygon(const std::vector<Geom::Pnt>& points);
159  virtual pWire _makePolyline(const std::vector<Geom::Pnt>& points);
160  virtual std::vector<pConstEdge> _getEdges(pConstWire wire);
161  virtual std::vector<pConstVertex> _getVertices(pConstWire wire);
162  virtual void _getPoints(pConstWire wire, std::vector<Geom::Pnt>& pnts);
163  virtual pWire _reverseWirePointsConnection(pConstWire wire, double precision);
164  virtual pWire _createOffset(pConstWire wire, const Geom::Dir& refDirection, double offset);
165  virtual bool _fixReorder(pWire wire);
166  virtual void _writeDbgInfo(pConstWire wire);
167  virtual Geom::Pnt _getCentre(pConstWire wire);
168  virtual bool _filletWireAtVertex(pWire wire, const Geom::Pnt& p, double radius, double precision);
169  virtual bool _chamferWireAtVertex(pWire wire, const Geom::Pnt& p, double offset, double precision);
170  virtual bool _removeEdgesFromWire(pWire wire, std::vector<pConstEdge> edges, double precision, bool stayInBndBox = false);
171  virtual bool _isSelfIntersecting(pConstWire wire);
172  virtual pWire _reversed(pConstWire wire);
173  virtual pWire _joined(pConstWire wire1, pConstWire wire2);
174  virtual pWire
175  _combineWireWithWire(pConstWire hWire, pConstWire vWire, const uint& x, const uint& y, const uint& z, const double& start, const double& end);
176  static Topo::WireTool* _defaultTool;
178 #endif
179 };
180 
181 } // namespace Topo
std::shared_ptr< Topo::Wire const > pConstWire
Definition: Shape.h:98
Definition: Pln.h:59
#define TOPO_EXPORT
Definition: topo_defines.h:8
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:42
std::shared_ptr< Topo::Edge const > pConstEdge
Definition: Shape.h:99
static const double linear_Resolution()
Definition: Precision.h:26
Definition: Trsf.h:58
Definition: Dir.h:46
Definition: Variant.h:70
std::shared_ptr< Topo::Vertex const > pConstVertex
Definition: Shape.h:101
Tools for creating, manipulating and querying Wires.
Definition: WireTool.h:24
std::shared_ptr< Topo::Wire > pWire
Definition: Shape.h:83
std::shared_ptr< Topo::Edge > pEdge
Definition: Shape.h:84