CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
FMEdgeGraph.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, 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 Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 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
38namespace 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
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
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
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;
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
167 void MergeDuplicatedEdges(bool bUseReverseEdgeAtMerge);
168
170 void Clear();
171 void ReserveBuffers( size_t nFaces );
172
175 double GetAddNodeTol(const OdGeTol tol = FMGeGbl::gTol) const;
176 void RemoveEdge(OdUInt32 idx, OdGePoint2dArray* pArr = NULL);
178 bool DoesEdgeExist(OdUInt32 iS, OdUInt32 iE, OdUInt32& res) const;
179
180 // changing the order of exiting edges
181 // according to angle
182 void ReorderLinks(const OdGePlane& plane);
183
184#ifdef _DEBUG
185 public:
186
187 struct SliceEdgeData
188 {
189 SliceEdge edge;
190 int overlappedCount;
191 int oppositeCount;
192
193 SliceEdgeData() : overlappedCount(0), oppositeCount(0)
194 {}
195 };
196
197 void DebugDrawEdges() const;
198 void DebugDrawGraph();
199 void DebugDrawEdge(OdUInt32 aEdgeIdx, OdInt16 edgeBaseColor);
200 void DebugDrawColoredGraph();
201 void DebugDrawEdge(const SliceEdge& edge, OdInt16 edgeBaseColor);
202 void DebugDrawOppositeOverlappedEdge(const SliceEdge& edge, OdInt16 color);
203 void DebugDrawColoredOrderedGraph(OdInt16 edgeBaseColor = 0);
204
205 void DebugDrawEdge2d(const SliceEdge& edge, const OdGePoint2dArray nodes2d, OdInt16 edgeBaseColor);
206 void DebugDrawOppositeOverlappedEdge2d(const SliceEdge& edge, const OdGePoint2dArray& nodes2d, OdInt16 color);
207 void DebugDrawColoredOrderedGraph2d(const OdGePlane& plane, OdInt16 edgeBaseColor);
208#endif
209 };
210}
211
212#endif //AECEDGEGRAPH_H_INCLUDED
tol
Definition: DimVarDefs.h:2287
#define FMGEOMETRY_API
unsigned int OdUInt32
short OdInt16
OdUInt32 GetEdgeStartNodeIdx(OdUInt32 aEdgeIdx) const
const SliceNode & GetEdgeEndNode(OdUInt32 aEdgeIdx) const
OdUInt32 AddNode(const OdGePoint3d &pt, const OdGeTol tol=FMGeGbl::gTol)
void ReserveBuffers(size_t nFaces)
const SliceNode & GetEdgeStartNode(OdUInt32 aEdgeIdx) const
void RemoveEdge(OdUInt32 idx, OdGePoint2dArray *pArr=NULL)
bool LeaveOrder(const OdGePoint3d &ptS, const OdGePoint3d &ptE, const OdGeVector3d &vFaceNormal, const OdGeVector3d &vCutNormal)
void ResetEdgeProcessed(OdUInt32 aEdgeIdx)
SliceNode & GetNode(OdUInt32 aNodeIdx)
const OdGePoint3d & GetEdgeEndPoint(OdUInt32 aEdgeIdx) const
OdArray< SliceNode > aNodes
Definition: FMEdgeGraph.h:107
const OdGePoint3d & GetNodePosition(OdUInt32 aNodeIdx) const
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 SliceEdge & GetEdge(OdUInt32 aEdgeIdx) const
void AddEdge(const OdGeLineSeg3d &lSeg, const OdGePlane &pSegPlane, const OdGePlane &pCutPlane)
OdArray< SliceEdge, OdMemoryAllocator< SliceEdge > > aEdges
Definition: FMEdgeGraph.h:106
void ReorderLinks(const OdGePlane &plane)
void AddEdge(const OdGePoint3d &ptSProjected, const OdGePoint3d &ptEProjected, const OdGePoint3d &ptSOriginal, const OdGePoint3d &ptEOriginal, const OdGePlane &pSegPlane, const OdGePlane &pCutPlane)
OdUInt32 EdgesCount() const
SliceNode & GetEdgeStartNode(OdUInt32 aEdgeIdx)
const OdGePoint3d & GetEdgeStartPoint(OdUInt32 aEdgeIdx) const
bool IsEdgesConcatenated(OdUInt32 iPreviousEdge, OdUInt32 iNextEdge) const
bool IsEdgeProcessed(OdUInt32 aEdgeIdx) const
void MergeDuplicatedEdges(bool bUseReverseEdgeAtMerge)
void RestoreEdgeNodesIdxs(OdUInt32 idx1, OdUInt32 idx2)
void AddEdge(OdUInt32 iS, OdUInt32 iE)
OdUInt32 NodesCount() const
bool DoesEdgeExist(OdUInt32 iS, OdUInt32 iE, OdUInt32 &res) const
SliceEdge & GetEdge(OdUInt32 aEdgeIdx)
SliceNode & GetEdgeEndNode(OdUInt32 aEdgeIdx)
double GetAddNodeTol(const OdGeTol tol=FMGeGbl::gTol) const
const SliceNode & GetNode(OdUInt32 aNodeIdx) const
Definition: GeTol.h:49
static FMGEOMETRY_API_STATIC OdGeTol gTol
Definition: FMGeometry.h:169
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