CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
GeTess2.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
24#ifndef __ODGITESSELATOR_2_H_INCLUDED__
25#define __ODGITESSELATOR_2_H_INCLUDED__
26
27#include "TD_PackPush.h"
28
29#include "OdList.h"
30#include "OdArray.h"
31
32#define ODGT_NAMESPACE OdGeTess2
33#define ODGT_PTRTYPE Contour*
34#define ODGT_PARENT
35
36#define ODGT_MEMBERS2 \
37public:\
38static void *create(OdUInt32 num)\
39{\
40 return new Vertex[num];\
41}
42
43#define ODGT_MEMBERS \
44friend class OptimizedHolder;\
45 MemoryHolder *m_pHolder;\
46public:\
47static void *create(OdUInt32 num)\
48{\
49 return new Contour[num];\
50}
51
52#define ODGT_HOLDER , MemoryHolder &pHolder
53#define ODGT_HOLDER2 , pHolder
54
59namespace ODGT_NAMESPACE
60{
61 class Vertex;
62 class Contour;
63
65 {
66 public:
67 virtual Vertex *newVertex() = 0;
68 virtual void deleteVertex(Vertex *) = 0;
69
70 virtual Contour *newContour() = 0;
71 virtual void deleteContour(Contour *) = 0;
72
73 virtual ~MemoryHolder() {}
74 };
75};
76
77
78#include "GeTess.h"
79
80#define HOLDER_(A, B) struct A\
81{\
82 bool m_First;\
83 B* m_FirstPage;\
84 OdList< B* > m_Buf;\
85 OdUInt32 m_pageSize;\
86 OdUInt32 m_pos;\
87\
88 A(OdUInt32 pageSize)\
89 : m_First(true)\
90 , m_FirstPage(0)\
91 , m_pageSize(pageSize)\
92 , m_pos(0)\
93 {\
94 m_FirstPage = (B*)B::create(m_pageSize);\
95 /*m_Buf.resize(1, (B*)B::create(m_pageSize) );*/\
96 }\
97\
98 void freeMem()\
99 {\
100 delete []m_FirstPage; m_FirstPage = 0;\
101 OdList< B* >::iterator pIt = m_Buf.begin();\
102 OdList< B* >::iterator pItEnd = m_Buf.end();\
103\
104 while(pIt != pItEnd)\
105 {\
106 delete[] *pIt;\
107 ++pIt;\
108 }\
109 }\
110\
111 ~A()\
112 {\
113 freeMem();\
114 }\
115\
116 B* newOne()\
117 {\
118 if (m_pos == m_pageSize)\
119 {\
120 m_First = false;\
121 m_Buf.push_front( (B*)B::create(m_pageSize) );\
122 m_pos = 0;\
123 }\
124 if (m_First)\
125 return &m_FirstPage[m_pos++];\
126 return &(*m_Buf.begin())[m_pos++];\
127 }\
128};
129
134namespace OdGeTess2
135{
152 class GE_TOOLKIT_EXPORT OptimizedHolder : public MemoryHolder
153 {
154 HOLDER_(Holder_Contour, Contour)
155 HOLDER_(Holder_Vertex, Vertex)
156
157 Holder_Vertex m_Vxs; // Array of vertices.
158 Holder_Contour m_Ctrs; // Array of contours.
159
160 public:
171 OptimizedHolder(OdUInt32 nPreAllocVertexes, OdUInt32 nPreAllocContours);
172
176 virtual Vertex *newVertex() ODRX_OVERRIDE;
177
186 virtual void deleteVertex(Vertex * pVx) ODRX_OVERRIDE;
187
191 virtual Contour *newContour() ODRX_OVERRIDE;
192
199 virtual void deleteContour(Contour *) ODRX_OVERRIDE;
200
205 };
206};
207
208#undef ODGT_NAMESPACE
209#undef ODGT_PTRTYPE
210#undef ODGT_PARENT
211#undef ODGT_MEMBERS
212#undef ODGT_HOLDER
213#undef ODGT_HOLDER2
214
215#include "TD_PackPop.h"
216
217#endif // __ODGITESSELATOR_2_H_INCLUDED__
#define GE_TOOLKIT_EXPORT
Definition: GeExport.h:49
#define HOLDER_(A, B)
Definition: GeTess2.h:80
unsigned int OdUInt32
#define ODRX_OVERRIDE
virtual void deleteContour(Contour *)=0
virtual void deleteVertex(Vertex *)=0
virtual Contour * newContour()=0
virtual Vertex * newVertex()=0
virtual Vertex * newVertex() ODRX_OVERRIDE
OptimizedHolder(OdUInt32 nPreAllocVertexes, OdUInt32 nPreAllocContours)