CFx SDK Documentation  2020SP3
GeTess.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, 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-2017 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 __ODGITESSELATOR_H_INCLUDED__
25 #define __ODGITESSELATOR_H_INCLUDED__
26 
27 
28 #include "RxObject.h"
29 #include "Ge/GePoint2d.h"
30 #include "Ge/GePoint3d.h"
31 #include "Ge/GeVector2d.h"
32 
33 #include "TD_PackPush.h"
34 
35 #ifndef ODGT_NAMESPACE
36  #define ODGT_NAMESPACE OdGeTess
37  #define ODGT_PTRTYPE OdSmartPtr<Contour>
38  #define ODGT_PARENT : public OdRxObject
39  #define ODGT_MEMBERS
40  #define ODGT_HOLDER
41  #define ODGT_HOLDER2
42  #define ODGT_MEMBERS2
43 #endif
44 
49 namespace ODGT_NAMESPACE
50 {
51 
53 {
58 };
59 
60 
62 {
65  kBrNormalized = 4
66 };
67 
68 class Vertex;
69 
71 {
73  double u1;
74  bool operator < (const Intersection& op) const { return u1 < op.u1; }
75  bool operator < (double op) const { return u1 < op; }
76 };
77 
79 
80 class Contour;
81 class LocalVert;
83 
85 {
86  friend class Vertex;
88 protected:
91 
92  const void *m_pCoords;
93 
94  unsigned m_b2d:1;
95  unsigned m_bClockwise:1;
96  unsigned m_bFailed:1;
97  double m_tol;
98 
99  void addVertex(Vertex* vertex);
100  void removeVertex(Vertex* vertex);
101  void delVertex(Vertex* vertex);
102  void breakContour(Vertex* vertex);
103  bool normalize(double size);
104  void checkClockwiseOriented(int bNested);
105  static void split(Vertex* v1, Vertex* v2);
106  bool isInside(const OdGePoint2d& point) const;
107  static bool isIncommingR(const Vertex* v1, const Vertex* v2);
108  void concatContours(Vertex* pC1vert, Contour* pContour2, Vertex* pC2vert);
111  void splitPolygon(Vertex* pV1, Vertex* pV2);
112 
113  void breakToConvex2(double size);
114  double calcMaxCoordValue(double& size) const;
116 protected:
118 public:
120 
121  static ContourPtr create(const void* coords, bool b2d ODGT_HOLDER);
122  static ContourPtr create(const OdGePoint2d* coords ODGT_HOLDER) { return create(coords, true ODGT_HOLDER2); }
123  static ContourPtr create(const OdGePoint3d* coords ODGT_HOLDER) { return create(coords, false ODGT_HOLDER2); }
124  ContourPtr insert(Contour* pCntr2Ins)
125  {
126  ODA_ASSERT(pCntr2Ins!=this);
127  pCntr2Ins->m_pNextContour = m_pNextContour;
128  return (m_pNextContour = pCntr2Ins);
129  }
130  Vertex* addVertex(int index, unsigned int edgeId = 0);
131  ContourPtr breakToConvex(unsigned int options, double eps = -1.);
132  void inverse();
133 
134  const Vertex* head() const { return m_pFirstVertex; }
135  Vertex* head() { return m_pFirstVertex; }
136  bool vectorIntersects(const Vertex* v1, const Vertex* v2, bool bNested) const;
137  static bool isIncomming(const Vertex* v1, const Vertex* v2);
138  double squareValue() const;
139  ContourPtr copy(int bNested) const;
140  bool isIncommingOrOnEdgeR(const Vertex* pV1, const Vertex* pV2) const;
141  const OdGePoint2d& point(int index) const
142  {
143  if(m_b2d)
144  return reinterpret_cast<const OdGePoint2d*>(m_pCoords)[index];
145  return *reinterpret_cast<const OdGePoint2d*>(reinterpret_cast<const OdGePoint3d*>(m_pCoords) + index);
146  }
147  ContourPtr next() const { return m_pNextContour; }
148 
149  const void* coords() const { return m_pCoords; }
150  bool is2d() const { return m_b2d; }
151  bool isTriangle() const;
152  bool isLineSeg() const;
153  bool intersections(const Vertex* vert1, const Vertex* vert2, Intersections& res, bool bNested) const;
154  bool intersections_lv(const Vertex* vert1, const LocalVert* vert2, Intersections& res, bool bNested) const;
155  //FELIX_CHANGE_BEGIN
156  bool intersections(const Vertex* pVert1, const OdGePoint2d* pVert2, Intersections& res, bool bNested) const;
157  //FELIX_CHANGE_END
158  bool failed() const { return m_bFailed; }
159  double tol() const { return m_tol; }
160 };
161 
162 
164 {
165  friend class Contour;
166  Contour *m_pContour;
167 
169 
170 protected:
173  int m_nIndex;
174  unsigned int m_nEdgeId;
175 
176 public:
178  : m_pContour(0)
179  , m_pNextVertex(0)
180  , m_pPrevVertex(0)
181  , m_nIndex(0)
182  , m_nEdgeId(0)
183  {
184  }
185  void link(Vertex* vert2)
186  {
187  m_pNextVertex = vert2;
188  vert2->m_pPrevVertex = this;
189  }
190  const Vertex* next() const { return m_pNextVertex; }
191  Vertex* next() { return m_pNextVertex; }
192  const Vertex* prev() const { return m_pPrevVertex; }
193  Vertex* prev() { return m_pPrevVertex; }
194  int index() const { return m_nIndex; }
195  void setIndex(int nIndex) { m_nIndex = nIndex; }
196  unsigned int edgeId() const { return m_nEdgeId; }
197  void setEdgeId(unsigned int nEdgeId) { m_nEdgeId = nEdgeId; }
198 
199  const OdGePoint2d& point() const { return m_pContour->point(m_nIndex); }
200 
202 
203  ContourPtr contour() const { return m_pContour; }
204  void setContour(Contour* pContour) { m_pContour = pContour; }
205 
206 };
207 
208 inline bool Contour::isTriangle() const
209 {
210  return (m_pFirstVertex && m_pFirstVertex->next()->next()==m_pFirstVertex->prev());
211 }
212 
213 inline bool Contour::isLineSeg() const
214 {
215  return (m_pFirstVertex && m_pFirstVertex->next()==m_pFirstVertex->prev());
216 }
217 
218 
219 } //namespace
220 
221 #include "TD_PackPop.h"
222 
223 #undef ODGT_NAMESPACE
224 #undef ODGT_PTRTYPE
225 #undef ODGT_PARENT
226 #undef ODGT_MEMBERS
227 #undef ODGT_HOLDER
228 #undef ODGT_HOLDER2
229 #undef ODGT_MEMBERS2
230 
231 #endif // __ODGITESSELATOR_H_INCLUDED__
v1
GLfloat GLfloat v1
Definition: gles2_ext.h:295
GeVector2d.h
ODGT_NAMESPACE::ODGT_PARENT::calcMaxCoordValue
double calcMaxCoordValue(double &size) const
ODGT_NAMESPACE::ODGT_PARENT::concatContours
void concatContours(Vertex *pC1vert, Contour *pContour2, Vertex *pC2vert)
ODGT_NAMESPACE::ODGT_PARENT::intersections
bool intersections(const Vertex *vert1, const Vertex *vert2, Intersections &res, bool bNested) const
ODGT_NAMESPACE::Vertex::contour
ContourPtr contour() const
Definition: GeTess.h:203
ODGT_NAMESPACE::Vertex::edgesType
EdgesType edgesType() const
ODGT_NAMESPACE::EdgesType
EdgesType
Definition: GeTess.h:53
ODGT_NAMESPACE::ODGT_PARENT::m_pFirstVertex
Vertex * m_pFirstVertex
Definition: GeTess.h:89
ODGT_NAMESPACE::ODGT_PARENT::insert
ContourPtr insert(Contour *pCntr2Ins)
Definition: GeTess.h:124
tol
tol
Definition: DimVarDefs.h:2287
ODGT_NAMESPACE::Vertex::m_nIndex
int m_nIndex
Definition: GeTess.h:173
ODGT_NAMESPACE::Intersections
OdArray< Intersection, OdMemoryAllocator< Intersection > > Intersections
Definition: GeTess.h:78
ODGT_NAMESPACE::Vertex::Vertex
Vertex()
Definition: GeTess.h:177
ODGT_NAMESPACE::ODGT_PARENT::head
Vertex * head()
Definition: GeTess.h:135
ODGT_HOLDER2
#define ODGT_HOLDER2
Definition: GeTess.h:41
ODGT_NAMESPACE::ODGT_PARENT::isInside
bool isInside(const OdGePoint2d &point) const
ODGT_NAMESPACE::ODGT_PARENT::m_pNextContour
ContourPtr m_pNextContour
Definition: GeTess.h:90
ODGT_NAMESPACE::ODGT_PARENT::addVertex
void addVertex(Vertex *vertex)
ODGT_NAMESPACE::kBrDetectHoles
@ kBrDetectHoles
Definition: GeTess.h:64
ODGT_NAMESPACE::Vertex::point
const OdGePoint2d & point() const
Definition: GeTess.h:199
ODGT_NAMESPACE::Vertex::link
void link(Vertex *vert2)
Definition: GeTess.h:185
ODGT_NAMESPACE::ODGT_PARENT::failed
bool failed() const
Definition: GeTess.h:158
ODGT_NAMESPACE::ODGT_PARENT::splitPolygon
void splitPolygon(Vertex *pV1, Vertex *pV2)
ODGT_NAMESPACE::kEtUndef
@ kEtUndef
Definition: GeTess.h:54
ODGT_NAMESPACE::Vertex::next
const Vertex * next() const
Definition: GeTess.h:190
ODGT_NAMESPACE::ODGT_PARENT::isIncommingR
static bool isIncommingR(const Vertex *v1, const Vertex *v2)
v2
GLfloat GLfloat GLfloat v2
Definition: gles2_ext.h:296
ODGT_PTRTYPE
#define ODGT_PTRTYPE
Definition: GeTess.h:37
OdArray
Definition: OdArray.h:591
TD_PackPop.h
ODGT_NAMESPACE::ODGT_PARENT::Contour
Contour()
ODGT_MEMBERS
#define ODGT_MEMBERS
Definition: GeTess.h:39
ODGT_MEMBERS2
#define ODGT_MEMBERS2
Definition: GeTess.h:42
RxObject.h
ODGT_NAMESPACE::Vertex
Definition: GeTess.h:164
size
GLsizeiptr size
Definition: gles2_ext.h:182
ODGT_NAMESPACE::ODGT_PARENT::isLineSeg
bool isLineSeg() const
index
GLuint index
Definition: gles2_ext.h:265
ODGT_NAMESPACE::ODGT_PARENT::is2d
bool is2d() const
Definition: GeTess.h:150
ODGT_HOLDER
#define ODGT_HOLDER
Definition: GeTess.h:40
ODGT_NAMESPACE::ODGT_PARENT::m_tol
double m_tol
Definition: GeTess.h:97
ODGT_NAMESPACE::ODGT_PARENT::isTriangle
bool isTriangle() const
ODGT_NAMESPACE::ODGT_PARENT::squareValue
double squareValue() const
ODGT_NAMESPACE::ODGT_PARENT::intersections
bool intersections(const Vertex *pVert1, const OdGePoint2d *pVert2, Intersections &res, bool bNested) const
ODGT_NAMESPACE::ODGT_PARENT::breakContour
void breakContour(Vertex *vertex)
ODGT_NAMESPACE::Vertex::prev
const Vertex * prev() const
Definition: GeTess.h:192
ODGT_NAMESPACE::ODGT_PARENT::inverse
void inverse()
ODGT_NAMESPACE::ODGT_PARENT::normalize
bool normalize(double size)
ODGT_NAMESPACE::ODGT_PARENT::removeEqualVertexes
void removeEqualVertexes(const OdGeTol &tol)
ODGT_NAMESPACE::Vertex::setContour
void setContour(Contour *pContour)
Definition: GeTess.h:204
OdGePoint3d
Definition: GePoint3d.h:55
ODGT_NAMESPACE::Vertex::m_pNextVertex
Vertex * m_pNextVertex
Definition: GeTess.h:171
ODGT_NAMESPACE::ODGT_PARENT::m_pCoords
const void * m_pCoords
Definition: GeTess.h:92
ODGT_NAMESPACE::Vertex::prev
Vertex * prev()
Definition: GeTess.h:193
GePoint3d.h
ODGT_NAMESPACE::ODGT_PARENT::create
static ContourPtr create(const OdGePoint3d *coords ODGT_HOLDER)
Definition: GeTess.h:123
ODGT_NAMESPACE::kEtRight
@ kEtRight
Definition: GeTess.h:56
ODGT_NAMESPACE::Vertex::m_pPrevVertex
Vertex * m_pPrevVertex
Definition: GeTess.h:172
ODGT_NAMESPACE::ODGT_PARENT::intersections_lv
bool intersections_lv(const Vertex *vert1, const LocalVert *vert2, Intersections &res, bool bNested) const
ODGT_NAMESPACE::ODGT_PARENT::breakToConvex
ContourPtr breakToConvex(unsigned int options, double eps=-1.)
ODGT_NAMESPACE::ODGT_PARENT::point
const OdGePoint2d & point(int index) const
Definition: GeTess.h:141
ODGT_NAMESPACE::ODGT_PARENT::copy
ContourPtr copy(int bNested) const
ODGT_NAMESPACE::Vertex::edgeId
unsigned int edgeId() const
Definition: GeTess.h:196
ODGT_NAMESPACE::Vertex::setIndex
void setIndex(int nIndex)
Definition: GeTess.h:195
ODGT_NAMESPACE::Intersection::pEdgeStart
Vertex * pEdgeStart
Definition: GeTess.h:72
ODGT_NAMESPACE::ODGT_PARENT::split
static void split(Vertex *v1, Vertex *v2)
ODGT_NAMESPACE::kBrNormalized
@ kBrNormalized
Definition: GeTess.h:65
ODGT_NAMESPACE::ODGT_PARENT::~Contour
~Contour()
ODGT_NAMESPACE::ODGT_PARENT::checkClockwiseOriented
void checkClockwiseOriented(int bNested)
TD_PackPush.h
ODGT_NAMESPACE::ODGT_PARENT::coords
const void * coords() const
Definition: GeTess.h:149
ODGT_NAMESPACE::ODGT_PARENT::delVertex
void delVertex(Vertex *vertex)
ODGT_NAMESPACE::ODGT_PARENT::splitOnCoincidentPoint
bool splitOnCoincidentPoint(double size)
ODGT_NAMESPACE::ODGT_PARENT::next
ContourPtr next() const
Definition: GeTess.h:147
ODGT_NAMESPACE::ODGT_PARENT::removeVertex
void removeVertex(Vertex *vertex)
ODGT_NAMESPACE::kBrCopyResult
@ kBrCopyResult
Definition: GeTess.h:63
ODGT_NAMESPACE::Vertex::setEdgeId
void setEdgeId(unsigned int nEdgeId)
Definition: GeTess.h:197
ODGT_NAMESPACE::ODGT_PARENT::isIncommingOrOnEdgeR
bool isIncommingOrOnEdgeR(const Vertex *pV1, const Vertex *pV2) const
ODGT_NAMESPACE::ODGT_PARENT::head
const Vertex * head() const
Definition: GeTess.h:134
ODGT_NAMESPACE::Intersection::operator<
bool operator<(const Intersection &op) const
Definition: GeTess.h:74
ODA_ASSERT
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:49
ODGT_NAMESPACE::ContourPtr
ODGT_PTRTYPE ContourPtr
Definition: GeTess.h:81
ODGT_NAMESPACE::ODGT_PARENT::create
static ContourPtr create(const void *coords, bool b2d ODGT_HOLDER)
ODGT_NAMESPACE::ODGT_PARENT::m_b2d
unsigned m_b2d
Definition: GeTess.h:94
GE_TOOLKIT_EXPORT
#define GE_TOOLKIT_EXPORT
Definition: GeExport.h:49
ODGT_NAMESPACE::Vertex::m_nEdgeId
unsigned int m_nEdgeId
Definition: GeTess.h:174
ODGT_NAMESPACE::Vertex::next
Vertex * next()
Definition: GeTess.h:191
ODGT_NAMESPACE::Vertex::index
int index() const
Definition: GeTess.h:194
ODGT_NAMESPACE::kEtLeft
@ kEtLeft
Definition: GeTess.h:55
ODGT_NAMESPACE::kEtParallel
@ kEtParallel
Definition: GeTess.h:57
ODGT_NAMESPACE::ODGT_PARENT::lastContour
ContourPtr lastContour() const
ODGT_NAMESPACE::Intersection::u1
double u1
Definition: GeTess.h:73
ODGT_NAMESPACE::BreakOptions
BreakOptions
Definition: GeTess.h:62
ODGT_NAMESPACE::ODGT_PARENT::create
static ContourPtr create(const OdGePoint2d *coords ODGT_HOLDER)
Definition: GeTess.h:122
OdGeTol
Definition: GeTol.h:49
ODGT_NAMESPACE::ODGT_PARENT::isIncomming
static bool isIncomming(const Vertex *v1, const Vertex *v2)
GePoint2d.h
ODGT_NAMESPACE::ODGT_PARENT::m_bFailed
unsigned m_bFailed
Definition: GeTess.h:96
ODGT_NAMESPACE::ODGT_PARENT::tol
double tol() const
Definition: GeTess.h:159
ODGT_NAMESPACE::ODGT_PARENT
Definition: GeTess.h:85
ODGT_NAMESPACE::ODGT_PARENT::vectorIntersects
bool vectorIntersects(const Vertex *v1, const Vertex *v2, bool bNested) const
ODGT_NAMESPACE
Definition: GeTess.h:50
ODGT_NAMESPACE::ODGT_PARENT::addVertex
Vertex * addVertex(int index, unsigned int edgeId=0)
ODGT_NAMESPACE::ODGT_PARENT::m_bClockwise
unsigned m_bClockwise
Definition: GeTess.h:95
ODGT_NAMESPACE::Intersection
Definition: GeTess.h:71
ODGT_NAMESPACE::ODGT_PARENT::breakToConvex2
void breakToConvex2(double size)
OdGePoint2d
Definition: GePoint2d.h:60