CFx SDK Documentation  2020SP3
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
FMProfile3D.h
FacetModeler::EdgeGraph::MergeDuplicatedEdges
void MergeDuplicatedEdges(bool bUseReverseEdgeAtMerge)
FacetModeler::FMGeGbl::gTol
static FMGEOMETRY_API_STATIC OdGeTol gTol
Definition: FMGeometry.h:156
FacetModeler::EdgeGraph::AddEdge
void AddEdge(const OdGePoint3d &ptS, const OdGePoint3d &ptE, const OdGePlane &pSegPlane, const OdGePlane &pCutPlane, const Edge *tag=0, const OdGeTol tol=FMGeGbl::gTol)
FacetModeler::SliceEdge::iE
OdUInt32 iE
Definition: FMEdgeGraph.h:87
OdGePlane
Definition: GePlane.h:45
FacetModeler::EdgeGraph::EdgesCount
OdUInt32 EdgesCount() const
FacetModeler::SliceNode::SliceNode
SliceNode(const OdGePoint3d &point)
Definition: FMEdgeGraph.h:42
OdGeVector3d
Definition: GeVector3d.h:54
FacetModeler::EdgeGraph::ReserveBuffers
void ReserveBuffers(size_t nFaces)
FacetModeler::SliceEdge::SliceEdge
SliceEdge(OdUInt32 s, OdUInt32 e, const Edge *_tag=0, bool _bLeaveOrder=false)
Definition: FMEdgeGraph.h:63
FacetModeler::SliceNode::SliceNode
SliceNode()
Definition: FMEdgeGraph.h:48
tol
tol
Definition: DimVarDefs.h:2287
FacetModeler::EdgeGraph::GetEdgeEndNodeIdx
OdUInt32 GetEdgeEndNodeIdx(OdUInt32 aEdgeIdx) const
FacetModeler
Definition: FMContour2D.h:35
FacetModeler::SliceEdge::IsOpposite
bool IsOpposite(const SliceEdge &edge) const
Definition: FMEdgeGraph.h:81
FacetModeler::EdgeGraph::GetEdgeEndPoint
const OdGePoint3d & GetEdgeEndPoint(OdUInt32 aEdgeIdx) const
FacetModeler::EdgeGraph::IsEdgesConcatenated
bool IsEdgesConcatenated(OdUInt32 iPreviousEdge, OdUInt32 iNextEdge) const
FacetModeler::EdgeGraph::SetEdgeProcessed
void SetEdgeProcessed(OdUInt32 aEdgeIdx)
FacetModeler::EdgeGraph::RemoveCrossLinks
void RemoveCrossLinks()
FacetModeler::EdgeGraph::aEdges
OdArray< SliceEdge, OdMemoryAllocator< SliceEdge > > aEdges
Definition: FMEdgeGraph.h:106
GeLine3d.h
FacetModeler::EdgeGraph::ResetEdgeProcessed
void ResetEdgeProcessed(OdUInt32 aEdgeIdx)
SiSpatialIndex.h
FacetModeler::EdgeGraph::AddEdge
void AddEdge(const OdGePoint3d &ptSProjected, const OdGePoint3d &ptEProjected, const OdGePoint3d &ptSOriginal, const OdGePoint3d &ptEOriginal, const OdGePlane &pSegPlane, const OdGePlane &pCutPlane)
OdArray< OdUInt32, OdMemoryAllocator< OdUInt32 > >
FacetModeler::EdgeGraph::IsEdgeProcessed
bool IsEdgeProcessed(OdUInt32 aEdgeIdx) const
FacetModeler::EdgeGraph::BuildLinks
void BuildLinks()
GePlane.h
GeLineSeg3d.h
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
OdInt16
short OdInt16
Definition: OdPlatformSettings.h:756
FacetModeler::SliceEdge::SliceEdge
SliceEdge()
Definition: FMEdgeGraph.h:72
FacetModeler::EdgeGraph::Clear
void Clear()
FacetModeler::EdgeGraph::GetEdgeEndNode
const SliceNode & GetEdgeEndNode(OdUInt32 aEdgeIdx) const
FacetModeler::EdgeGraph::LeaveOrder
bool LeaveOrder(const OdGePoint3d &ptS, const OdGePoint3d &ptE, const OdGeVector3d &vFaceNormal, const OdGeVector3d &vCutNormal)
FacetModeler::EdgeGraph::GetEdgeEndNode
SliceNode & GetEdgeEndNode(OdUInt32 aEdgeIdx)
FacetModeler::SliceEdge
Definition: FMEdgeGraph.h:62
OdGePoint3d
Definition: GePoint3d.h:55
FacetModeler::EdgeGraph::aNodes
OdArray< SliceNode > aNodes
Definition: FMEdgeGraph.h:107
FMDebugDraw.h
FacetModeler::EdgeGraph::GetEdge
SliceEdge & GetEdge(OdUInt32 aEdgeIdx)
FacetModeler::Edge
Definition: FMMdlEdge.h:43
FacetModeler::EdgeGraph::AddNode
OdUInt32 AddNode(const OdGePoint3d &pt, const OdGeTol tol=FMGeGbl::gTol)
FacetModeler::EdgeGraph::RemoveOppositeEdges
void RemoveOppositeEdges()
FacetModeler::SliceNode::aOut
OdUInt32Array aOut
Definition: FMEdgeGraph.h:54
FacetModeler::EdgeGraph::GetEdgeStartPoint
const OdGePoint3d & GetEdgeStartPoint(OdUInt32 aEdgeIdx) const
FacetModeler::EdgeGraph::GetEdgeStartNodeIdx
OdUInt32 GetEdgeStartNodeIdx(OdUInt32 aEdgeIdx) const
FMGeometryDebug.h
FacetModeler::EdgeGraph::GetNode
SliceNode & GetNode(OdUInt32 aNodeIdx)
FacetModeler::SliceEdge::tag
const Edge * tag
Definition: FMEdgeGraph.h:89
FacetModeler::SliceNode::bProcessed
bool bProcessed
Definition: FMEdgeGraph.h:55
FMGeometry.h
FacetModeler::EdgeGraph::AddEdge
void AddEdge(const OdGeLineSeg3d &lSeg, const OdGePlane &pSegPlane, const OdGePlane &pCutPlane)
FacetModeler::EdgeGraph::GetEdge
const SliceEdge & GetEdge(OdUInt32 aEdgeIdx) const
FacetModeler::EdgeGraph::ResetEdgesProcessedFlag
void ResetEdgesProcessedFlag()
FacetModeler::EdgeGraph::GetEdgeStartNode
const SliceNode & GetEdgeStartNode(OdUInt32 aEdgeIdx) const
FacetModeler::SliceEdge::bLeaveOrder
bool bLeaveOrder
Definition: FMEdgeGraph.h:90
FacetModeler::SliceNode::pt
OdGePoint3d pt
Definition: FMEdgeGraph.h:53
SiShapePlane.h
OdGeLineSeg3d
Definition: GeLineSeg3d.h:44
FacetModeler::SliceEdge::bProcessed
bool bProcessed
Definition: FMEdgeGraph.h:88
FacetModeler::EdgeGraph::NodesCount
OdUInt32 NodesCount() const
FacetModeler::EdgeGraph::GetNode
const SliceNode & GetNode(OdUInt32 aNodeIdx) const
FacetModeler::SliceEdge::iS
OdUInt32 iS
Definition: FMEdgeGraph.h:86
OdGeTol
Definition: GeTol.h:49
FacetModeler::EdgeGraph
Definition: FMEdgeGraph.h:104
FacetModeler::EdgeGraph::ReserveBuffersIfEmpty
void ReserveBuffersIfEmpty()
FacetModeler::EdgeGraph::GetNodePosition
const OdGePoint3d & GetNodePosition(OdUInt32 aNodeIdx) const
FacetModeler::EdgeGraph::GetEdgeStartNode
SliceNode & GetEdgeStartNode(OdUInt32 aEdgeIdx)
UInt32Array.h
FacetModeler::SliceNode
Definition: FMEdgeGraph.h:41