CFx SDK Documentation  2022 SP0
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__
unsigned int OdUInt32
OdGeVector3d direction() const
void addPartner(Edge *pPartner)
OdGeVector3d vector() const
Definition: FMMdlEdge.h:274
void setNext(Edge *pNext)
bool isManifold() const
const OdGePoint3d & startPoint() const
Definition: FMMdlEdge.h:262
Edge * nextPartner() const
void setPartner(Edge *pPartner)
DOM.
Definition: FMMdlEdge.h:212
double angleBetweenEdges() const
void setPair(Edge *pPair)
const OdGePoint3d & endPoint() const
Definition: FMMdlEdge.h:266
FacetModeler::Vertex * next_vertex() const
Definition: FMMdlEdge.h:254
void debugValidateLoop(bool bTestPartners=true) const
DOM.
void setFace(FacetModeler::Face *pFace)
OdUInt32 color() const
void setVertex(FacetModeler::Vertex *pVertex)
void setLoop(FacetModeler::Face::EdgeLoop *pLoop)
Definition: FMMdlEdge.h:278
FacetModeler::Face::EdgeLoop * loop() const
Definition: FMMdlEdge.h:258
Edge(FacetModeler::Vertex *pVertex, FacetModeler::Face *pFace, Edge *pPrevEdge, Edge *pPartner)
OdGeVector3d normal() const
FacetModeler::Vertex * vertex() const
OdGeVector3d calculateLoopNormal() const
double length() const
Definition: FMMdlEdge.h:270
Edge * next() const
void setPrev(Edge *pPrev)
void setColor(OdUInt32 iColor)
bool isPartner(const Edge *pEdge) const
void debugValidate(bool bTestPartners=true) const
DOM.
FacetModeler::Face * face() const
Edge * prev() const
double angleBetweenFaces() const
Edge * pair() const
const OdGePoint3d & point() const
double distanceTo(const OdGePoint3d &point) const
GLuint GLsizei GLsizei * length
Definition: gles2_ext.h:274
const OdUInt32 VEF
Definition: FMMdlEdge.h:37
OdUInt32 FLAG(OdUInt32 i)
Definition: FMMdlEntity.h:35
const OdUInt32 AEF
Definition: FMMdlEdge.h:36