OpenLexocad  28.0
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 
23 #include <Topo/ToolResults.h>
24 namespace Base { struct Double; }
25 namespace Core { class DocObject; }
26 namespace Geom { class Trsf; }
27 namespace Geom { enum class CurveType; }
28 
29 
30 namespace Topo
31 {
37 class LX_TOPO_EXPORT EdgeTool
38 {
39 public:
40  static pEdge copy(pConstEdge e);
41  static pEdge makeEdge(const Geom::Pnt& p1, const Geom::Pnt& p2);
42  static pEdge makeEdge(Core::DocObject* curve, double startParam, double endParam);
43  static pEdge makeArcOfCircle(const Geom::Pnt& p1, const Geom::Pnt& pp, const Geom::Pnt& p2);
44  static pEdge makeArcOfCircle(const Geom::Circ& circ, double param1, double param2, bool sameSense = true);
45  static pEdge makeArcOfCircle(const Geom::Circ& circ, const Geom::Pnt& p1, const Geom::Pnt& p2, bool sameSense = true);
46  static bool projectPointOnEdge(const Geom::Pnt& p, pConstEdge edge, Geom::Pnt& nearest, Geom::Dir& refDirection);
47  static bool projectPointOnEdge(const Geom::Pnt& p, pConstEdge edge, double& u);
48  static bool projectPointOnEdge(const Geom::Pnt& p, pConstEdge edge, Base::Double& u);
49  static bool calculateOffsetFromEdgeThruPoint(pConstEdge edge, const Geom::Pnt& p, double& offset, Geom::Dir& refDirection);
50  static bool calculateOffsetFromEdgeThruPoint(pConstEdge edge, const Geom::Pnt& p, Base::Double& offset, Geom::Dir& refDirection);
51  static bool sense(pConstEdge edge, bool& sense);
52  static bool firstParameter(pConstEdge edge, double& u);
53  static bool firstParameter(pConstEdge edge, Base::Double& u);
54  static bool lastParameter(pConstEdge edge, double& u);
55  static bool lastParameter(pConstEdge edge, Base::Double& u);
56  static bool value(pConstEdge edge, double u, Geom::Pnt& p);
57  static bool d0(pConstEdge edge, double u, Geom::Pnt& p);
58  static bool d1(pConstEdge edge, double u, Geom::Pnt& p, Geom::Vec& v1);
59  static bool d2(pConstEdge edge, double u, Geom::Pnt& p, Geom::Vec& v1, Geom::Vec& v2);
60  static bool d3(pConstEdge edge, double u, Geom::Pnt& p, Geom::Vec& v1, Geom::Vec& v2, Geom::Vec& v3);
61  static bool splitEdge(pConstEdge edge, double u, pEdge& edge1, pEdge& edge2);
62  static bool getGeomCurveType(pConstEdge edge, Geom::CurveType& type);
63  static double getLength(pConstEdge edge);
64  static bool isPointOnEdge(pConstEdge edge, const Geom::Pnt& pnt);
65  static bool isStraight(pConstEdge edge);
66  static bool isCircular(pConstEdge edge);
67  static bool getArcParameters(pConstEdge edge, Geom::Circ& circle, double& startParam, double& endParam);
68  static bool getLineParameters(pConstEdge edge, Geom::Lin& line, double& startParam, double& endParam, double& scale);
70  static bool intersects(pConstEdge edge1, pConstEdge edge2, std::vector<Geom::Pnt>& intersections, double tolerance);
71  static pEdge reversed(pConstEdge edge);
73  static pShape extrudeEdge(pConstEdge edge, const Geom::Dir& extrudedDirection, double depth);
74  static bool discretizeNonLinearEdge(pConstEdge edge, std::vector<Geom::Pnt>& points, double deflection);
75  static pEdge transformed(pConstEdge base, const Geom::Trsf& t);
76  static bool areTheSameInstance(pConstEdge edge1, pConstEdge edge2);
77  static const void* getInstancePointer(pConstEdge edge);
78  static bool bspline_facet(const std::vector<Geom::Pnt>& pnts, const bool& periodic, std::vector<Geom::Pnt>& faceted_pnts, double tolerance);
79  static pEdge makeClothoidSegment(const Geom::Clothoid2d& clothoid);
80  static bool getClothoidParameters(pConstEdge edge, Geom::Ax2& ax2, Geom::Clothoid2d& clothoid);
81  static std::pair<std::vector<double>, std::vector<Geom::Pnt>> getKnotsAndControlPointsFromEdge(pConstEdge edge);
82  static pEdge join(const std::vector<pConstEdge>& edges);
83 
86 
87 
90 
94  static ET_Value_Result value(pConstEdge edge, double u);
95  static ET_D0_Result d0(pConstEdge edge, double u);
96  static ET_D1_Result d1(pConstEdge edge, double u);
97  static ET_D2_Result d2(pConstEdge edge, double u);
98  static ET_D3_Result d3(pConstEdge edge, double u);
99  static ET_SplitEdge_Result splitEdge(pConstEdge edge, double u);
101 
104  static ET_Intersects_Result intersects(pConstEdge edge1, pConstEdge edge2, double tolerance);
106  static ET_Bspline_facet_Result bspline_facet(const std::vector<Geom::Pnt>& pnts, bool periodic, double tolerance);
108 
109 
111 
112 #ifndef SWIG // INTERFACES BELOW ARE -NOT- PART OF THE LEXOCAD API
113  static void __setDefaultEdgeTool__(Topo::EdgeTool* tool) { _defaultTool = tool; }
116 
117 protected:
118  virtual pEdge _copy(pConstEdge e);
119  virtual pEdge _makeEdge(const Geom::Pnt& p1, const Geom::Pnt& p2);
120  virtual pEdge _makeEdge(Core::DocObject* curve, double startParam, double endParam);
121  virtual pEdge _makeArcOfCircle(const Geom::Pnt& p1, const Geom::Pnt& p2, const Geom::Pnt& pp);
122  virtual pEdge _makeArcOfCircle(const Geom::Circ& circ, double param1, double param2, bool sameSense);
123  virtual pEdge _makeArcOfCircle(const Geom::Circ& circ, const Geom::Pnt& p1, const Geom::Pnt& p2, bool sameSense);
124  virtual bool _projectPointOnEdge(const Geom::Pnt& p, pConstEdge edge, Geom::Pnt& nearest, Geom::Dir& refDirection);
125  virtual bool _projectPointOnEdge(const Geom::Pnt& p, pConstEdge edge, double& u);
126  virtual bool _calculateOffsetFromEdgeThruPoint(pConstEdge edge, const Geom::Pnt& p, double& offset, Geom::Dir& refDirection);
127  virtual bool _sense(pConstEdge edge, bool& sense);
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
Topo::EdgeTool::d0
static ET_D0_Result d0(pConstEdge edge, double u)
Topo::EdgeTool::getCentre
static Geom::Pnt getCentre(pConstEdge edge)
Topo::EdgeTool::makeClothoidSegment
static pEdge makeClothoidSegment(const Geom::Clothoid2d &clothoid)
Topo::EdgeTool::lastParameter
static bool lastParameter(pConstEdge edge, double &u)
Topo::EdgeTool::projectPointOnEdge
static bool projectPointOnEdge(const Geom::Pnt &p, pConstEdge edge, Base::Double &u)
Topo::ET_D1_Result
Struct holding the return values from EdgeTool::d1(). Returns ok=true if the operation was successful...
Definition: ToolResults.h:121
Topo::ET_CalculateOffsetFromEdgeThruPoint_Result
Struct holding the return values from EdgeTool::calculateOffsetFromEdgeThruPoint()....
Definition: ToolResults.h:50
Topo::EdgeTool::getGeomCurveType
static bool getGeomCurveType(pConstEdge edge, Geom::CurveType &type)
Topo::ET_D2_Result
Struct holding the return values from EdgeTool::d2(). Returns ok=true if the operation was successful...
Definition: ToolResults.h:136
Topo::ET_Bspline_facet_Result
Struct holding the return values from EdgeTool::bspline_facet(). Returns ok=true if the operation was...
Definition: ToolResults.h:259
Topo::EdgeTool::join
static pEdge join(const std::vector< pConstEdge > &edges)
Topo::ET_ArcParameters_Result
Struct holding the return values from EdgeTool::getArcParameters(). Returns ok=true if the operation ...
Definition: ToolResults.h:198
Topo::ET_D0_Result
Struct holding the return values from EdgeTool::d0(). Returns ok=true if the operation was successful...
Definition: ToolResults.h:107
Topo::EdgeTool::d1
static bool d1(pConstEdge edge, double u, Geom::Pnt &p, Geom::Vec &v1)
Topo::ET_ProjectPointOnEdge_Result1
Struct holding the return values from EdgeTool::projectPointOnEdge(). Returns ok=true if the operatio...
Definition: ToolResults.h:21
Topo::ET_SplitEdge_Result
Struct holding the return values from EdgeTool::splitEdge(). Returns ok=true if the operation was suc...
Definition: ToolResults.h:169
Geom::Lin
Definition: Lin.h:49
Topo::EdgeTool::firstParameter
static bool firstParameter(pConstEdge edge, double &u)
Topo::EdgeTool::getClothoidParameters
static bool getClothoidParameters(pConstEdge edge, Geom::Ax2 &ax2, Geom::Clothoid2d &clothoid)
Geom::Vec
Defines a non-persistent vector in 3D space.
Definition: Vec.h:41
Topo::ET_LastParameter_Result
Struct holding the return values from EdgeTool::lastParameter(). Returns ok=true if the operation was...
Definition: ToolResults.h:79
Topo::EdgeTool
Tools for creating, manipulating and querying Edges.
Definition: EdgeTool.h:38
Topo::EdgeTool::getLength
static double getLength(pConstEdge edge)
Topo::EdgeTool::calculateOffsetFromEdgeThruPoint
static bool calculateOffsetFromEdgeThruPoint(pConstEdge edge, const Geom::Pnt &p, double &offset, Geom::Dir &refDirection)
Topo::EdgeTool::splitEdge
static bool splitEdge(pConstEdge edge, double u, pEdge &edge1, pEdge &edge2)
Topo::EdgeTool::getLineParameters
static ET_LineParameters_Result getLineParameters(pConstEdge edge)
Topo::EdgeTool::isPointOnEdge
static bool isPointOnEdge(pConstEdge edge, const Geom::Pnt &pnt)
Topo::EdgeTool::sense
static bool sense(pConstEdge edge, bool &sense)
Topo::ET_Value_Result
Struct holding the return values from EdgeTool::value(). Returns ok=true if the operation was success...
Definition: ToolResults.h:93
Topo::EdgeTool::value
static ET_Value_Result value(pConstEdge edge, double u)
Topo::EdgeTool::d2
static ET_D2_Result d2(pConstEdge edge, double u)
Topo::EdgeTool::splitEdge
static ET_SplitEdge_Result splitEdge(pConstEdge edge, double u)
Topo::EdgeTool::lastParameter
static bool lastParameter(pConstEdge edge, Base::Double &u)
Topo::EdgeTool::extrudeEdge
static pShape extrudeEdge(pConstEdge edge, const Geom::Dir &extrudedDirection, double depth)
Topo::ET_ProjectPointOnEdge_Result2
Struct holding the return values from EdgeTool::projectPointOnEdge2(). Returns ok=true if the operati...
Definition: ToolResults.h:36
Topo::ET_DiscretizeNonLinearEdge_Result
Struct holding the return values from EdgeTool::discretizeNonLinearEdge(). Returns ok=true if the ope...
Definition: ToolResults.h:245
Topo::EdgeTool::makeArcOfCircle
static pEdge makeArcOfCircle(const Geom::Circ &circ, double param1, double param2, bool sameSense=true)
Geom::Dir
Definition: Dir.h:45
Topo::EdgeTool::d3
static ET_D3_Result d3(pConstEdge edge, double u)
Topo::EdgeTool::getArcParameters
static bool getArcParameters(pConstEdge edge, Geom::Circ &circle, double &startParam, double &endParam)
Topo::EdgeTool::calculateOffsetFromEdgeThruPoint
static ET_CalculateOffsetFromEdgeThruPoint_Result calculateOffsetFromEdgeThruPoint(pConstEdge edge, const Geom::Pnt &p)
Topo::ET_D3_Result
Struct holding the return values from EdgeTool::d3(). Returns ok=true if the operation was successful...
Definition: ToolResults.h:152
Topo::EdgeTool::projectPointOnEdge2
static ET_ProjectPointOnEdge_Result2 projectPointOnEdge2(const Geom::Pnt &p, pConstEdge edge)
pShape
std::shared_ptr< Topo::Shape > pShape
Definition: Variant.h:64
Core::DocObject
Definition: DocObject.h:54
pEdge
std::shared_ptr< Topo::Edge > pEdge
Definition: Types.h:55
Topo::EdgeTool::makeArcOfCircle
static pEdge makeArcOfCircle(const Geom::Circ &circ, const Geom::Pnt &p1, const Geom::Pnt &p2, bool sameSense=true)
Topo::EdgeTool::makeEdge
static pEdge makeEdge(const Geom::Pnt &p1, const Geom::Pnt &p2)
Topo::EdgeTool::copy
static pEdge copy(pConstEdge e)
Geom::Circ
Definition: Circ.h:56
Topo::EdgeTool::d3
static bool d3(pConstEdge edge, double u, Geom::Pnt &p, Geom::Vec &v1, Geom::Vec &v2, Geom::Vec &v3)
Core
Definition: Base.h:5
Topo::EdgeTool::calculateOffsetFromEdgeThruPoint
static bool calculateOffsetFromEdgeThruPoint(pConstEdge edge, const Geom::Pnt &p, Base::Double &offset, Geom::Dir &refDirection)
Topo::ET_FirstParameter_Result
Struct holding the return values from EdgeTool::firstParameter(). Returns ok=true if the operation wa...
Definition: ToolResults.h:65
Topo::EdgeTool::makeEdge
static pEdge makeEdge(Core::DocObject *curve, double startParam, double endParam)
Base::Double
Definition: Double.h:6
Geom::Pnt
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:44
Topo::EdgeTool::transformed
static pEdge transformed(pConstEdge base, const Geom::Trsf &t)
Geom::Ax2
Definition: Ax2.h:66
Topo::EdgeTool::discretizeNonLinearEdge
static bool discretizeNonLinearEdge(pConstEdge edge, std::vector< Geom::Pnt > &points, double deflection)
Topo::EdgeTool::makeArcOfCircle
static pEdge makeArcOfCircle(const Geom::Pnt &p1, const Geom::Pnt &pp, const Geom::Pnt &p2)
Geom::CurveType
CurveType
Definition: GeomEnums.h:12
Topo::EdgeTool::isCircular
static bool isCircular(pConstEdge edge)
Topo::EdgeTool::projectPointOnEdge
static ET_ProjectPointOnEdge_Result1 projectPointOnEdge(const Geom::Pnt &p, pConstEdge edge)
Topo::EdgeTool::d2
static bool d2(pConstEdge edge, double u, Geom::Pnt &p, Geom::Vec &v1, Geom::Vec &v2)
Topo::EdgeTool::isStraight
static bool isStraight(pConstEdge edge)
Topo::ET_Intersects_Result
Struct holding the return values from EdgeTool::intersects(). Returns ok=true if the operation was su...
Definition: ToolResults.h:231
Topo::EdgeTool::reversed
static pEdge reversed(pConstEdge edge)
pConstEdge
std::shared_ptr< Topo::Edge const > pConstEdge
Definition: Types.h:72
Topo::EdgeTool::firstParameter
static ET_FirstParameter_Result firstParameter(pConstEdge edge)
Topo
Definition: DbgInfo.h:17
Topo::EdgeTool::projectPointOnEdge
static bool projectPointOnEdge(const Geom::Pnt &p, pConstEdge edge, double &u)
Topo::EdgeTool::getGeomCurveType
static ET_GeomCurveType_Result getGeomCurveType(pConstEdge edge)
Topo::EdgeTool::value
static bool value(pConstEdge edge, double u, Geom::Pnt &p)
Topo::EdgeTool::discretizeNonLinearEdge
static ET_DiscretizeNonLinearEdge_Result discretizeNonLinearEdge(pConstEdge edge, double deflection)
Geom::Clothoid2d
Definition: Clothoid2d.h:20
Topo::EdgeTool::getClothoidParameters
static ET_ClothoidParameters_Result getClothoidParameters(pConstEdge edge)
Topo::EdgeTool::getKnotsAndControlPointsFromEdge
static std::pair< std::vector< double >, std::vector< Geom::Pnt > > getKnotsAndControlPointsFromEdge(pConstEdge edge)
Topo::EdgeTool::intersects
static ET_Intersects_Result intersects(pConstEdge edge1, pConstEdge edge2, double tolerance)
Topo::EdgeTool::getOrientation
static Topo::OrientationType getOrientation(pConstCoedge edge)
Topo::EdgeTool::lastParameter
static ET_LastParameter_Result lastParameter(pConstEdge edge)
Topo::EdgeTool::bspline_facet
static ET_Bspline_facet_Result bspline_facet(const std::vector< Geom::Pnt > &pnts, bool periodic, double tolerance)
Topo::ET_ClothoidParameters_Result
Struct holding the return values from EdgeTool::getClothoidParameters(). Returns ok=true if the opera...
Definition: ToolResults.h:273
Topo::EdgeTool::getLineParameters
static bool getLineParameters(pConstEdge edge, Geom::Lin &line, double &startParam, double &endParam, double &scale)
Topo::ET_GeomCurveType_Result
Struct holding the return values from EdgeTool::getGeomCurveType(). Returns ok=true if the operation ...
Definition: ToolResults.h:184
Topo::EdgeTool::d0
static bool d0(pConstEdge edge, double u, Geom::Pnt &p)
Geom::Trsf
Definition: Trsf.h:58
Topo::EdgeTool::getArcParameters
static ET_ArcParameters_Result getArcParameters(pConstEdge edge)
ToolResults.h
Topo::EdgeTool::d1
static ET_D1_Result d1(pConstEdge edge, double u)
Topo::EdgeTool::intersects
static bool intersects(pConstEdge edge1, pConstEdge edge2, std::vector< Geom::Pnt > &intersections, double tolerance)
Topo::ET_LineParameters_Result
Struct holding the return values from EdgeTool::getLineParameters(). Returns ok=true if the operation...
Definition: ToolResults.h:214
Topo::EdgeTool::bspline_facet
static bool bspline_facet(const std::vector< Geom::Pnt > &pnts, const bool &periodic, std::vector< Geom::Pnt > &faceted_pnts, double tolerance)
Topo::EdgeTool::projectPointOnEdge
static bool projectPointOnEdge(const Geom::Pnt &p, pConstEdge edge, Geom::Pnt &nearest, Geom::Dir &refDirection)
Topo::OrientationType
OrientationType
Definition: Types.h:36
Base
Definition: AbstractXMLReader.h:5
pConstCoedge
std::shared_ptr< Topo::Coedge const > pConstCoedge
Definition: Types.h:73
Topo::EdgeTool::firstParameter
static bool firstParameter(pConstEdge edge, Base::Double &u)
Geom
Definition: PropertyContainer.h:33
Topo::EdgeTool::getInstancePointer
static const void * getInstancePointer(pConstEdge edge)
Topo::EdgeTool::areTheSameInstance
static bool areTheSameInstance(pConstEdge edge1, pConstEdge edge2)