CFx SDK Documentation  2023 SP0
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__
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:49
tol
Definition: DimVarDefs.h:2287
#define GE_TOOLKIT_EXPORT
Definition: GeExport.h:49
#define ODGT_HOLDER2
Definition: GeTess.h:41
#define ODGT_HOLDER
Definition: GeTess.h:40
#define ODGT_MEMBERS2
Definition: GeTess.h:42
#define ODGT_MEMBERS
Definition: GeTess.h:39
#define ODGT_PTRTYPE
Definition: GeTess.h:37
ContourPtr next() const
Definition: GeTess.h:147
static bool isIncomming(const Vertex *v1, const Vertex *v2)
const void * m_pCoords
Definition: GeTess.h:92
Vertex * addVertex(int index, unsigned int edgeId=0)
bool normalize(double size)
double tol() const
Definition: GeTess.h:159
void breakContour(Vertex *vertex)
static ContourPtr create(const OdGePoint2d *coords ODGT_HOLDER)
Definition: GeTess.h:122
ContourPtr copy(int bNested) const
static ContourPtr create(const OdGePoint3d *coords ODGT_HOLDER)
Definition: GeTess.h:123
bool isInside(const OdGePoint2d &point) const
ContourPtr m_pNextContour
Definition: GeTess.h:90
bool intersections(const Vertex *pVert1, const OdGePoint2d *pVert2, Intersections &res, bool bNested) const
bool vectorIntersects(const Vertex *v1, const Vertex *v2, bool bNested) const
static bool isIncommingR(const Vertex *v1, const Vertex *v2)
ContourPtr insert(Contour *pCntr2Ins)
Definition: GeTess.h:124
static ContourPtr create(const void *coords, bool b2d ODGT_HOLDER)
bool isIncommingOrOnEdgeR(const Vertex *pV1, const Vertex *pV2) const
const OdGePoint2d & point(int index) const
Definition: GeTess.h:141
void checkClockwiseOriented(int bNested)
static void split(Vertex *v1, Vertex *v2)
void addVertex(Vertex *vertex)
void breakToConvex2(double size)
void splitPolygon(Vertex *pV1, Vertex *pV2)
const Vertex * head() const
Definition: GeTess.h:134
double calcMaxCoordValue(double &size) const
bool intersections(const Vertex *vert1, const Vertex *vert2, Intersections &res, bool bNested) const
void delVertex(Vertex *vertex)
ContourPtr lastContour() const
ContourPtr breakToConvex(unsigned int options, double eps=-1.)
void concatContours(Vertex *pC1vert, Contour *pContour2, Vertex *pC2vert)
void removeEqualVertexes(const OdGeTol &tol)
bool splitOnCoincidentPoint(double size)
void removeVertex(Vertex *vertex)
const void * coords() const
Definition: GeTess.h:149
bool intersections_lv(const Vertex *vert1, const LocalVert *vert2, Intersections &res, bool bNested) const
const Vertex * prev() const
Definition: GeTess.h:192
void setContour(Contour *pContour)
Definition: GeTess.h:204
const Vertex * next() const
Definition: GeTess.h:190
Vertex * m_pPrevVertex
Definition: GeTess.h:172
unsigned int m_nEdgeId
Definition: GeTess.h:174
void setIndex(int nIndex)
Definition: GeTess.h:195
void setEdgeId(unsigned int nEdgeId)
Definition: GeTess.h:197
int index() const
Definition: GeTess.h:194
void link(Vertex *vert2)
Definition: GeTess.h:185
const OdGePoint2d & point() const
Definition: GeTess.h:199
ContourPtr contour() const
Definition: GeTess.h:203
EdgesType edgesType() const
Vertex * next()
Definition: GeTess.h:191
Vertex * m_pNextVertex
Definition: GeTess.h:171
Vertex * prev()
Definition: GeTess.h:193
unsigned int edgeId() const
Definition: GeTess.h:196
Definition: GeTol.h:49
GLfloat GLfloat v1
Definition: gles2_ext.h:295
GLfloat GLfloat GLfloat v2
Definition: gles2_ext.h:296
GLsizeiptr size
Definition: gles2_ext.h:182
GLuint index
Definition: gles2_ext.h:265
OdArray< Intersection, OdMemoryAllocator< Intersection > > Intersections
Definition: GeTess.h:78
ODGT_PTRTYPE ContourPtr
Definition: GeTess.h:81
@ kBrCopyResult
Definition: GeTess.h:63
@ kBrDetectHoles
Definition: GeTess.h:64
@ kBrNormalized
Definition: GeTess.h:65
bool operator<(const Intersection &op) const
Definition: GeTess.h:74