OpenLexocad  27.1
EdgeTool.h
Go to the documentation of this file.
1 // //
3 // LEXOCAD API //
4 // //
5 // ©2005-2017 Cadwork Informatik. All rights reserved. //
6 // //
7 // ONLY INCLUDE OTHER INTERFACES! //
8 // Lexocad provides API Classes for public use and //
9 // Implementation Classes for private use. //
10 // //
11 // - Do ONLY include and use the LEXOCAD API in this header. //
12 // - Do not change existing interfaces. //
13 // - Document your code! //
14 // //
15 // - All types from Base, Core, Geom, Topo are allowed here. //
16 // - In the Gui modules the use of Qt types is allowed. //
17 // //
19 
20 #pragma once
21 
22 #include <Base/Double.h>
23 #include <Geom/Circ.h>
24 #include <Geom/Clothoid2d.h>
25 #include <Geom/Dir.h>
26 #include <Geom/Lin.h>
27 #include <Geom/Pnt.h>
28 #include <Geom/Vec.h>
29 #include <Topo/Shape.h>
30 #include <Topo/ToolResults.h>
31 
32 namespace Topo
33 {
39 class LX_TOPO_EXPORT EdgeTool
40 {
41 public:
42  static pEdge copy(pConstEdge e);
43  static pEdge makeEdge(const Geom::Pnt& p1, const Geom::Pnt& p2);
44  static pEdge makeEdge(Core::DocObject* curve, double startParam, double endParam);
45  static pEdge makeArcOfCircle(const Geom::Pnt& p1, const Geom::Pnt& pp, const Geom::Pnt& p2);
46  static pEdge makeArcOfCircle(const Geom::Circ& circ, double param1, double param2, bool sameSense = true);
47  static pEdge makeArcOfCircle(const Geom::Circ& circ, const Geom::Pnt& p1, const Geom::Pnt& p2, bool sameSense = true);
48  static bool projectPointOnEdge(const Geom::Pnt& p, pConstEdge edge, Geom::Pnt& nearest, Geom::Dir& refDirection);
49  static bool projectPointOnEdge(const Geom::Pnt& p, pConstEdge edge, double& u);
50  static bool projectPointOnEdge(const Geom::Pnt& p, pConstEdge edge, Base::Double& u);
51  static bool calculateOffsetFromEdgeThruPoint(pConstEdge edge, const Geom::Pnt& p, double& offset, Geom::Dir& refDirection);
52  static bool calculateOffsetFromEdgeThruPoint(pConstEdge edge, const Geom::Pnt& p, Base::Double& offset, Geom::Dir& refDirection);
53  static bool firstParameter(pConstEdge edge, double& u);
54  static bool firstParameter(pConstEdge edge, Base::Double& u);
55  static bool lastParameter(pConstEdge edge, double& u);
56  static bool lastParameter(pConstEdge edge, Base::Double& u);
57  static bool value(pConstEdge edge, double u, Geom::Pnt& p);
58  static bool d0(pConstEdge edge, double u, Geom::Pnt& p);
59  static bool d1(pConstEdge edge, double u, Geom::Pnt& p, Geom::Vec& v1);
60  static bool d2(pConstEdge edge, double u, Geom::Pnt& p, Geom::Vec& v1, Geom::Vec& v2);
61  static bool d3(pConstEdge edge, double u, Geom::Pnt& p, Geom::Vec& v1, Geom::Vec& v2, Geom::Vec& v3);
62  static bool splitEdge(pConstEdge edge, double u, pEdge& edge1, pEdge& edge2);
63  static bool getGeomCurveType(pConstEdge edge, Geom::CurveType& type);
64  static double getLength(pConstEdge edge);
65  static bool isPointOnEdge(pConstEdge edge, const Geom::Pnt& pnt);
66  static bool isStraight(pConstEdge edge);
67  static bool isCircular(pConstEdge edge);
68  static bool getArcParameters(pConstEdge edge, Geom::Circ& circle, double& startParam, double& endParam);
69  static bool getLineParameters(pConstEdge edge, Geom::Lin& line, double& startParam, double& endParam, double& scale);
70  static Topo::OrientationType getOrientation(pConstCoedge edge);
71  static bool intersects(pConstEdge edge1, pConstEdge edge2, std::vector<Geom::Pnt>& intersections, double tolerance);
72  static pEdge reversed(pConstEdge edge);
73  static Geom::Pnt getCentre(pConstEdge edge);
74  static pShape extrudeEdge(pConstEdge edge, const Geom::Dir& extrudedDirection, double depth);
75  static bool discretizeNonLinearEdge(pConstEdge edge, std::vector<Geom::Pnt>& points, double deflection);
76  static pEdge transformed(pConstEdge base, const Geom::Trsf& t);
77  static bool areTheSameInstance(pConstEdge edge1, pConstEdge edge2);
78  static const void* getInstancePointer(pConstEdge edge);
79  static bool bspline_facet(const std::vector<Geom::Pnt>& pnts, const bool& periodic, std::vector<Geom::Pnt>& faceted_pnts, double tolerance);
80  static pEdge makeClothoidSegment(const Geom::Clothoid2d& clothoid);
81  static bool getClothoidParameters(pConstEdge edge, Geom::Ax2& ax2, Geom::Clothoid2d& clothoid);
82  static std::pair<std::vector<double>, std::vector<Geom::Pnt>> getKnotsAndControlPointsFromEdge(pConstEdge edge);
83  static pEdge join(const std::vector<pConstEdge>& edges);
84 
87 
88 
89  static ET_ProjectPointOnEdge_Result1 projectPointOnEdge(const Geom::Pnt& p, pConstEdge edge);
90  static ET_ProjectPointOnEdge_Result2 projectPointOnEdge2(const Geom::Pnt& p, pConstEdge edge);
91 
92  static ET_CalculateOffsetFromEdgeThruPoint_Result calculateOffsetFromEdgeThruPoint(pConstEdge edge, const Geom::Pnt& p);
93  static ET_FirstParameter_Result firstParameter(pConstEdge edge);
94  static ET_LastParameter_Result lastParameter(pConstEdge edge);
95  static ET_Value_Result value(pConstEdge edge, double u);
96  static ET_D0_Result d0(pConstEdge edge, double u);
97  static ET_D1_Result d1(pConstEdge edge, double u);
98  static ET_D2_Result d2(pConstEdge edge, double u);
99  static ET_D3_Result d3(pConstEdge edge, double u);
100  static ET_SplitEdge_Result splitEdge(pConstEdge edge, double u);
101  static ET_GeomCurveType_Result getGeomCurveType(pConstEdge edge);
102 
103  static ET_ArcParameters_Result getArcParameters(pConstEdge edge);
104  static ET_LineParameters_Result getLineParameters(pConstEdge edge);
105  static ET_Intersects_Result intersects(pConstEdge edge1, pConstEdge edge2, double tolerance);
106  static ET_DiscretizeNonLinearEdge_Result discretizeNonLinearEdge(pConstEdge edge, double deflection);
107  static ET_Bspline_facet_Result bspline_facet(const std::vector<Geom::Pnt>& pnts, bool periodic, double tolerance);
108  static ET_ClothoidParameters_Result getClothoidParameters(pConstEdge edge);
109 
110 
112 
113 #ifndef SWIG // INTERFACES BELOW ARE -NOT- PART OF THE LEXOCAD API
114  static void __setDefaultEdgeTool__(Topo::EdgeTool* tool) { _defaultTool = tool; }
117 
118 protected:
119  virtual pEdge _copy(pConstEdge e);
120  virtual pEdge _makeEdge(const Geom::Pnt& p1, const Geom::Pnt& p2);
121  virtual pEdge _makeEdge(Core::DocObject* curve, double startParam, double endParam);
122  virtual pEdge _makeArcOfCircle(const Geom::Pnt& p1, const Geom::Pnt& p2, const Geom::Pnt& pp);
123  virtual pEdge _makeArcOfCircle(const Geom::Circ& circ, double param1, double param2, bool sameSense);
124  virtual pEdge _makeArcOfCircle(const Geom::Circ& circ, const Geom::Pnt& p1, const Geom::Pnt& p2, bool sameSense);
125  virtual bool _projectPointOnEdge(const Geom::Pnt& p, pConstEdge edge, Geom::Pnt& nearest, Geom::Dir& refDirection);
126  virtual bool _projectPointOnEdge(const Geom::Pnt& p, pConstEdge edge, double& u);
127  virtual bool _calculateOffsetFromEdgeThruPoint(pConstEdge edge, const Geom::Pnt& p, double& offset, Geom::Dir& refDirection);
128  virtual bool _firstParameter(pConstEdge edge, double& u);
129  virtual bool _lastParameter(pConstEdge edge, double& u);
130  virtual bool _value(pConstEdge edge, double u, Geom::Pnt& p);
131  virtual bool _d0(pConstEdge edge, double u, Geom::Pnt& p);
132  virtual bool _d1(pConstEdge edge, double u, Geom::Pnt& p, Geom::Vec& v1);
133  virtual bool _d2(pConstEdge edge, double u, Geom::Pnt& p, Geom::Vec& v1, Geom::Vec& v2);
134  virtual bool _d3(pConstEdge edge, double u, Geom::Pnt& p, Geom::Vec& v1, Geom::Vec& v2, Geom::Vec& v3);
135  virtual bool _splitEdge(pConstEdge edge, double u, pEdge& edge1, pEdge& edge2);
136  virtual bool _getGeomCurveType(pConstEdge edge, Geom::CurveType& type);
137  virtual double _getLength(pConstEdge edge);
138  virtual bool _isPointOnEdge(pConstEdge edge, const Geom::Pnt& pnt);
139  virtual bool _isCircular(pConstEdge edge);
140  virtual bool _isStraight(pConstEdge edge);
141  virtual bool _getArcParameters(pConstEdge edge, Geom::Circ& circle, double& startParam, double& endParam);
142  virtual bool _getLineParameters(pConstEdge edge, Geom::Lin& line, double& startParam, double& endParam, double& scale);
143  virtual Topo::OrientationType _getOrientation(pConstCoedge edge);
144  virtual bool _intersects(pConstEdge edge1, pConstEdge edge2, std::vector<Geom::Pnt>& intersections, double tolerance);
145  virtual pEdge _reversed(pConstEdge edge);
146  virtual Geom::Pnt _getCentre(pConstEdge edge);
147  virtual pShape _extrudeEdge(pConstEdge edge, const Geom::Dir& extrudedDirection, double depth);
148  virtual bool _discretizeNonLinearEdge(pConstEdge edge, std::vector<Geom::Pnt>& points, double deflection);
149  virtual bool _areTheSameInstance(pConstEdge edge1, pConstEdge edge2);
150  virtual const void* _getInstancePointer(pConstEdge edge);
151  virtual bool _bspline_facet(const std::vector<Geom::Pnt>& pnts, const bool& periodic, std::vector<Geom::Pnt>& faceted_pnts, double tolerance);
152 
153  virtual pEdge _makeClothoidSegment(const Geom::Clothoid2d& clothoid);
154  virtual bool _getClothoidParameters(pConstEdge edge, Geom::Ax2& ax2, Geom::Clothoid2d& clothoid);
155  virtual std::pair<std::vector<double>, std::vector<Geom::Pnt>> _getKnotsAndControlPointsFromEdge(pConstEdge edge);
156  virtual pEdge _join(const std::vector<pConstEdge>& edges);
157 
158  static Topo::EdgeTool* _defaultTool;
160 #endif
161 };
162 
163 
164 
165 } // namespace Topo
Definition: Circ.h:53
Struct holding the return values from EdgeTool::discretizeNonLinearEdge(). Returns ok=true if the ope...
Definition: ToolResults.h:245
Struct holding the return values from EdgeTool::intersects(). Returns ok=true if the operation was su...
Definition: ToolResults.h:231
Struct holding the return values from EdgeTool::firstParameter(). Returns ok=true if the operation wa...
Definition: ToolResults.h:65
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:43
Struct holding the return values from EdgeTool::d2(). Returns ok=true if the operation was successful...
Definition: ToolResults.h:136
std::shared_ptr< Topo::Edge const > pConstEdge
Definition: Shape.h:98
Struct holding the return values from EdgeTool::d1(). Returns ok=true if the operation was successful...
Definition: ToolResults.h:121
Struct holding the return values from EdgeTool::projectPointOnEdge(). Returns ok=true if the operatio...
Definition: ToolResults.h:21
Struct holding the return values from EdgeTool::d0(). Returns ok=true if the operation was successful...
Definition: ToolResults.h:107
Struct holding the return values from EdgeTool::lastParameter(). Returns ok=true if the operation was...
Definition: ToolResults.h:79
Struct holding the return values from EdgeTool::calculateOffsetFromEdgeThruPoint()....
Definition: ToolResults.h:50
Definition: Double.h:6
Struct holding the return values from EdgeTool::getGeomCurveType(). Returns ok=true if the operation ...
Definition: ToolResults.h:184
Struct holding the return values from EdgeTool::splitEdge(). Returns ok=true if the operation was suc...
Definition: ToolResults.h:169
Struct holding the return values from EdgeTool::projectPointOnEdge2(). Returns ok=true if the operati...
Definition: ToolResults.h:36
Definition: Ax2.h:67
Definition: Lin.h:48
Struct holding the return values from EdgeTool::bspline_facet(). Returns ok=true if the operation was...
Definition: ToolResults.h:259
Definition: Trsf.h:57
Definition: Dir.h:45
OrientationType
Definition: Shape.h:62
Struct holding the return values from EdgeTool::value(). Returns ok=true if the operation was success...
Definition: ToolResults.h:93
Struct holding the return values from EdgeTool::getArcParameters(). Returns ok=true if the operation ...
Definition: ToolResults.h:198
Definition: Variant.h:55
std::shared_ptr< Topo::Coedge const > pConstCoedge
Definition: Shape.h:99
Defines a non-persistent vector in 3D space.
Definition: Vec.h:44
CurveType
Definition: GeomEnums.h:11
Struct holding the return values from EdgeTool::getLineParameters(). Returns ok=true if the operation...
Definition: ToolResults.h:214
Tools for creating, manipulating and querying Edges.
Definition: EdgeTool.h:39
Struct holding the return values from EdgeTool::getClothoidParameters(). Returns ok=true if the opera...
Definition: ToolResults.h:273
Struct holding the return values from EdgeTool::d3(). Returns ok=true if the operation was successful...
Definition: ToolResults.h:152
Definition: DocObject.h:51
std::shared_ptr< Topo::Shape > pShape
Definition: Variant.h:76
Definition: Clothoid2d.h:20
std::shared_ptr< Topo::Edge > pEdge
Definition: Shape.h:83