CFx SDK Documentation  2020SP3
FMMdlEdge.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2015, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2015 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 #ifndef __FMMDL_EDGE_H__
25 #define __FMMDL_EDGE_H__
26 
27 #include "Modeler/FMMdlVertex.h"
28 #include "Modeler/FMMdlFace.h"
29 
33 namespace FacetModeler
34 {
35 
36 const OdUInt32 AEF = FLAG(0); // silhouette edge
37 const OdUInt32 VEF = FLAG(1); // invisible edge
38 
42 class FMGEOMETRY_API Edge : public Entity
43 {
44  public:
48  Edge();
49 
54  FacetModeler::Face* pFace, Edge* pPrevEdge, Edge* pPartner );
55 
59  FacetModeler::Face::EdgeLoop* loop() const;
60 
65 
70 
71  FacetModeler::Vertex* next_vertex() const;
72 
73  const OdGePoint3d& startPoint() const;
74 
75  const OdGePoint3d& endPoint() const;
76 
77  double length() const;
78 
79  OdGeVector3d vector() const;
80 
84  Edge* next() const;
85 
89  Edge* prev() const;
90 
98  Edge* pair() const;
99 
103  Edge* nextPartner() const;
104 
108  bool isPartner( const Edge* pEdge ) const;
109 
113  bool isManifold() const;
114 
122  double angleBetweenEdges() const;
123 
130  double angleBetweenFaces() const;
131 
139 
144 
149 
153  void setNext( Edge* pNext );
154 
158  void setPrev( Edge* pPrev );
159 
163  void setPair( Edge* pPair );
164 
168  void setVertex( FacetModeler::Vertex* pVertex );
169 
173  void setFace( FacetModeler::Face* pFace );
174 
175  // Sets owner loop. Low level operation!
176  void setLoop( FacetModeler::Face::EdgeLoop* pLoop );
177 
181  void addPartner( Edge* pPartner );
182 
187 
192 
194  void debugValidate( bool bTestPartners = true ) const;
195 
197  void debugValidateLoop( bool bTestPartners = true ) const;
198 
202  void setColor(OdUInt32 iColor);
203 
207  OdUInt32 color() const;
208 
209  void zero();
210 
212  void setPartner(Edge* pPartner) { m_pNextPartner = pPartner; }
213 
214  ~Edge();
215 
216  private:
217  static void addEdge( Face::EdgeLoop& loop, Edge* pEdge, bool bInverseOrder );
218 
219  Edge(const Edge&);
220  Edge& operator=(const Edge&);
221 
222  // Owner face.
223  Face* m_pFace;
224 
225  // Owner loop
226  Face::EdgeLoop* m_pLoop;
227 
228  // Start vertex.
229  Vertex* m_pVertex;
230 
231  // Previous edge.
232  Edge* m_pPrevEdge;
233 
234  // Next edge.
235  Edge* m_pNextEdge;
236 
237  // Overlapping edge from neighboring face.
238  Edge* m_pPairEdge;
239 
240  // Next edge in a single-linked loop of overlapping edges.
241  Edge* m_pNextPartner;
242 
243  // Edge color
244  OdUInt32 m_iColor;
245 
246  friend class Body;
247  friend class BodyImpl;
248  friend class Face;
249  friend class BodyInternalConsistencyRestorer;
250 };
251 
252 
253 // Inline alias method for the statement: this->next()->vertex();
254 inline Vertex* Edge::next_vertex() const {
255  return next()->vertex();
256 }
257 
258 inline Face::EdgeLoop* Edge::loop() const {
259  return m_pLoop;
260 }
261 
262 inline const OdGePoint3d& Edge::startPoint() const {
263  return vertex()->point();
264 }
265 
266 inline const OdGePoint3d& Edge::endPoint() const {
267  return next_vertex()->point();
268 }
269 
270 inline double Edge::length() const {
271  return startPoint().distanceTo( endPoint() );
272 }
273 
274 inline OdGeVector3d Edge::vector() const {
275  return endPoint() - startPoint();
276 }
277 
278 inline void Edge::setLoop( Face::EdgeLoop* pLoop ) {
279  m_pLoop = pLoop;
280 }
281 
282 
283 #if 0
284 // debug finctions for memory leaks checking
285 class EdgeTracker
286 {
287  int m_id;
288  std::map<Edge*, int> m_edges;
289 
290 public:
291  EdgeTracker()
292  {
293  m_id = 0;
294  }
295 
296  ~EdgeTracker();
297 
298 
299  void EdgeCreated(Edge* pEdge);
300 
301  void EdgeDeleted(Edge* pEdge)
302  {
303  m_edges.erase(pEdge);
304  }
305 
306  void GetEdges(std::map<Edge*, int>& edges)
307  {
308  edges = m_edges;
309  }
310 };
311 
312 EdgeTracker* GetEdgeTracker();
313 #endif
314 
315 }
316 
317 #endif //__FMMDL_EDGE_H__
FacetModeler::Edge::direction
OdGeVector3d direction() const
FacetModeler::Edge::angleBetweenEdges
double angleBetweenEdges() const
FacetModeler::Face::EdgeLoop
DOM.
Definition: FMMdlFace.h:191
OdGeVector3d
Definition: GeVector3d.h:54
FacetModeler::Edge::removePartner
void removePartner()
FMMdlFace.h
FacetModeler::Edge::next_vertex
FacetModeler::Vertex * next_vertex() const
Definition: FMMdlEdge.h:254
FacetModeler::Edge::zero
void zero()
FacetModeler::FLAG
OdUInt32 FLAG(OdUInt32 i)
Definition: FMMdlEntity.h:35
FacetModeler
Definition: FMContour2D.h:35
FacetModeler::Edge::face
FacetModeler::Face * face() const
FacetModeler::AEF
const OdUInt32 AEF
Definition: FMMdlEdge.h:36
FacetModeler::Edge::angleBetweenFaces
double angleBetweenFaces() const
FacetModeler::Edge::calculateLoopNormal
OdGeVector3d calculateLoopNormal() const
FacetModeler::Edge::setFace
void setFace(FacetModeler::Face *pFace)
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
FacetModeler::Edge::isManifold
bool isManifold() const
FacetModeler::Edge::normal
OdGeVector3d normal() const
FacetModeler::Edge::setVertex
void setVertex(FacetModeler::Vertex *pVertex)
FacetModeler::Edge::isPartner
bool isPartner(const Edge *pEdge) const
FacetModeler::Edge::endPoint
const OdGePoint3d & endPoint() const
Definition: FMMdlEdge.h:266
FacetModeler::Edge::debugValidate
void debugValidate(bool bTestPartners=true) const
DOM.
FacetModeler::Edge::setPartner
void setPartner(Edge *pPartner)
DOM.
Definition: FMMdlEdge.h:212
FacetModeler::Body
Definition: FMMdlBody.h:47
FacetModeler::Edge::setNext
void setNext(Edge *pNext)
FacetModeler::Edge::length
double length() const
Definition: FMMdlEdge.h:270
OdGePoint3d
Definition: GePoint3d.h:55
FacetModeler::Edge::Edge
Edge(FacetModeler::Vertex *pVertex, FacetModeler::Face *pFace, Edge *pPrevEdge, Edge *pPartner)
FacetModeler::Edge::nextPartner
Edge * nextPartner() const
FacetModeler::Edge::debugValidateLoop
void debugValidateLoop(bool bTestPartners=true) const
DOM.
FacetModeler::Edge::startPoint
const OdGePoint3d & startPoint() const
Definition: FMMdlEdge.h:262
FacetModeler::Edge
Definition: FMMdlEdge.h:43
FacetModeler::Edge::vertex
FacetModeler::Vertex * vertex() const
FMMdlVertex.h
FacetModeler::Edge::vector
OdGeVector3d vector() const
Definition: FMMdlEdge.h:274
FacetModeler::Edge::setPair
void setPair(Edge *pPair)
length
GLuint GLsizei GLsizei * length
Definition: gles2_ext.h:274
FacetModeler::VEF
const OdUInt32 VEF
Definition: FMMdlEdge.h:37
FacetModeler::Vertex::point
const OdGePoint3d & point() const
FacetModeler::Edge::next
Edge * next() const
FacetModeler::Edge::updatePartnerPairs
void updatePartnerPairs()
FacetModeler::Edge::~Edge
~Edge()
FacetModeler::Edge::pair
Edge * pair() const
FacetModeler::Edge::setColor
void setColor(OdUInt32 iColor)
FacetModeler::Face
Definition: FMMdlFace.h:47
FacetModeler::Vertex
Definition: FMMdlVertex.h:42
FacetModeler::Edge::color
OdUInt32 color() const
OdGePoint3d::distanceTo
double distanceTo(const OdGePoint3d &point) const
FacetModeler::Edge::loop
FacetModeler::Face::EdgeLoop * loop() const
Definition: FMMdlEdge.h:258
FacetModeler::Edge::Edge
Edge()
FacetModeler::Edge::setPrev
void setPrev(Edge *pPrev)
FacetModeler::Edge::addPartner
void addPartner(Edge *pPartner)
FacetModeler::Entity
Definition: FMMdlEntity.h:41
FacetModeler::Edge::setLoop
void setLoop(FacetModeler::Face::EdgeLoop *pLoop)
Definition: FMMdlEdge.h:278
FacetModeler::Edge::prev
Edge * prev() const