CFx SDK Documentation  2023 SP0
FMEdgeGraph.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 #ifndef AECEDGEGRAPH_H_INCLUDED
24 #define AECEDGEGRAPH_H_INCLUDED
25 
26 #include "FMProfile3D.h"
27 #include "FMGeometry.h"
28 #include "FMGeometryDebug.h"
29 
30 #include "Ge/GePlane.h"
31 #include "Ge/GeLineSeg3d.h"
32 #include <UInt32Array.h>
33 #include "Si/SiSpatialIndex.h"
34 #include "Si/SiShapePlane.h"
35 #include "Ge/GeLine3d.h"
36 #include "FMDebugDraw.h"
37 
38 namespace FacetModeler
39 {
40  struct SliceNode
41  {
42  SliceNode( const OdGePoint3d& point )
43  {
44  pt = point;
45  bProcessed = false;
46  }
47 
49  {
50  bProcessed = false;
51  }
52 
55  bool bProcessed;
56  };
57 
59  //
61  struct SliceEdge
62  {
63  SliceEdge( OdUInt32 s, OdUInt32 e, const Edge* _tag = 0, bool _bLeaveOrder = false )
64  {
65  iS = s;
66  iE = e;
67  bProcessed = false;
68  tag = _tag;
69  bLeaveOrder = _bLeaveOrder;
70  }
71 
73  {
74  iS = 0;
75  iE = 0;
76  bProcessed = false;
77  tag = 0;
78  bLeaveOrder = false;
79  }
80 
81  bool IsOpposite(const SliceEdge& edge) const
82  {
83  return (iS == edge.iE && iE == edge.iS);
84  }
85 
88  bool bProcessed;
89  const Edge* tag;
91  };
92 
93  static bool operator == (const SliceEdge& e1, const SliceEdge& e2)
94  {
95  return (e1.iS == e2.iS && e1.iE == e2.iE);
96  }
97 
98 
100  //
101  // EdgeGraph
103  class FMGEOMETRY_API EdgeGraph
104  {
105  protected:
108 
109  protected:
111  bool LeaveOrder( const OdGePoint3d& ptS, const OdGePoint3d& ptE, const OdGeVector3d& vFaceNormal, const OdGeVector3d& vCutNormal ) ;
112 
113  public:
116 
119 
120  bool IsEdgeProcessed(OdUInt32 aEdgeIdx) const;
121  void SetEdgeProcessed(OdUInt32 aEdgeIdx);
122  void ResetEdgeProcessed(OdUInt32 aEdgeIdx);
123 
124  const SliceNode& GetEdgeStartNode(OdUInt32 aEdgeIdx) const;
125  const SliceNode& GetEdgeEndNode(OdUInt32 aEdgeIdx) const;
126 
129 
130  const OdGePoint3d& GetEdgeStartPoint(OdUInt32 aEdgeIdx) const;
131  const OdGePoint3d& GetEdgeEndPoint(OdUInt32 aEdgeIdx) const;
132 
133  const SliceNode& GetNode(OdUInt32 aNodeIdx) const;
135 
136  const SliceEdge& GetEdge(OdUInt32 aEdgeIdx) const;
138 
139  const OdGePoint3d& GetNodePosition(OdUInt32 aNodeIdx) const;
140 
141  // checks if the end node of the previous edge is the same as the start node of the next edge
142  // if true, then the edges segments are connected end-to-start ( represent two segments of polyline )
143  bool IsEdgesConcatenated(OdUInt32 iPreviousEdge, OdUInt32 iNextEdge) const;
144 
145  public:
146  void AddEdge( const OdGeLineSeg3d& lSeg, const OdGePlane& pSegPlane, const OdGePlane& pCutPlane );
147 
148  void AddEdge( const OdGePoint3d& ptSProjected,
149  const OdGePoint3d& ptEProjected,
150  const OdGePoint3d& ptSOriginal,
151  const OdGePoint3d& ptEOriginal,
152  const OdGePlane& pSegPlane,
153  const OdGePlane& pCutPlane );
154 
155  void AddEdge( const OdGePoint3d& ptS,
156  const OdGePoint3d& ptE,
157  const OdGePlane& pSegPlane,
158  const OdGePlane& pCutPlane,
159  const Edge* tag = 0,
160  const OdGeTol tol = FMGeGbl::gTol );
161 
163 
164  void BuildLinks();
167  void MergeDuplicatedEdges(bool bUseReverseEdgeAtMerge);
168 
170  void Clear();
171  void ReserveBuffers( size_t nFaces );
172 
173 #ifdef _DEBUG
174  public:
175 
176  struct SliceEdgeData
177  {
178  SliceEdge edge;
179  int overlappedCount;
180  int oppositeCount;
181 
182  SliceEdgeData() : overlappedCount(0), oppositeCount(0)
183  {}
184  };
185 
186  void DebugDrawEdges() const;
187  void DebugDrawGraph();
188  void DebugDrawEdge(OdUInt32 aEdgeIdx, OdInt16 edgeBaseColor);
189  void DebugDrawColoredGraph();
190  void DebugDrawEdge(const SliceEdge& edge, OdInt16 edgeBaseColor);
191  void DebugDrawOppositeOverlappedEdge(const SliceEdge& edge, OdInt16 color);
192  void DebugDrawColoredOrderedGraph();
193 #endif
194  };
195 }
196 
197 #endif //AECEDGEGRAPH_H_INCLUDED
tol
Definition: DimVarDefs.h:2287
unsigned int OdUInt32
short OdInt16
OdUInt32 GetEdgeStartNodeIdx(OdUInt32 aEdgeIdx) const
OdUInt32 AddNode(const OdGePoint3d &pt, const OdGeTol tol=FMGeGbl::gTol)
void ReserveBuffers(size_t nFaces)
SliceNode & GetEdgeStartNode(OdUInt32 aEdgeIdx)
const SliceNode & GetNode(OdUInt32 aNodeIdx) const
bool LeaveOrder(const OdGePoint3d &ptS, const OdGePoint3d &ptE, const OdGeVector3d &vFaceNormal, const OdGeVector3d &vCutNormal)
const OdGePoint3d & GetEdgeEndPoint(OdUInt32 aEdgeIdx) const
void ResetEdgeProcessed(OdUInt32 aEdgeIdx)
SliceEdge & GetEdge(OdUInt32 aEdgeIdx)
OdArray< SliceNode > aNodes
Definition: FMEdgeGraph.h:107
void AddEdge(const OdGePoint3d &ptS, const OdGePoint3d &ptE, const OdGePlane &pSegPlane, const OdGePlane &pCutPlane, const Edge *tag=0, const OdGeTol tol=FMGeGbl::gTol)
OdUInt32 GetEdgeEndNodeIdx(OdUInt32 aEdgeIdx) const
void SetEdgeProcessed(OdUInt32 aEdgeIdx)
const SliceNode & GetEdgeStartNode(OdUInt32 aEdgeIdx) const
void AddEdge(const OdGeLineSeg3d &lSeg, const OdGePlane &pSegPlane, const OdGePlane &pCutPlane)
OdArray< SliceEdge, OdMemoryAllocator< SliceEdge > > aEdges
Definition: FMEdgeGraph.h:106
const SliceEdge & GetEdge(OdUInt32 aEdgeIdx) const
void AddEdge(const OdGePoint3d &ptSProjected, const OdGePoint3d &ptEProjected, const OdGePoint3d &ptSOriginal, const OdGePoint3d &ptEOriginal, const OdGePlane &pSegPlane, const OdGePlane &pCutPlane)
SliceNode & GetNode(OdUInt32 aNodeIdx)
OdUInt32 EdgesCount() const
const OdGePoint3d & GetEdgeStartPoint(OdUInt32 aEdgeIdx) const
bool IsEdgesConcatenated(OdUInt32 iPreviousEdge, OdUInt32 iNextEdge) const
bool IsEdgeProcessed(OdUInt32 aEdgeIdx) const
const SliceNode & GetEdgeEndNode(OdUInt32 aEdgeIdx) const
void MergeDuplicatedEdges(bool bUseReverseEdgeAtMerge)
SliceNode & GetEdgeEndNode(OdUInt32 aEdgeIdx)
const OdGePoint3d & GetNodePosition(OdUInt32 aNodeIdx) const
OdUInt32 NodesCount() const
Definition: GeTol.h:49
static FMGEOMETRY_API_STATIC OdGeTol gTol
Definition: FMGeometry.h:156
SliceEdge(OdUInt32 s, OdUInt32 e, const Edge *_tag=0, bool _bLeaveOrder=false)
Definition: FMEdgeGraph.h:63
bool IsOpposite(const SliceEdge &edge) const
Definition: FMEdgeGraph.h:81
OdUInt32Array aOut
Definition: FMEdgeGraph.h:54
SliceNode(const OdGePoint3d &point)
Definition: FMEdgeGraph.h:42