CFx SDK Documentation  2022 SP0
GeTess2.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_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 \
37 public:\
38 static void *create(OdUInt32 num)\
39 {\
40  return new Vertex[num];\
41 }
42 
43 #define ODGT_MEMBERS \
44 friend class OptimizedHolder;\
45  MemoryHolder *m_pHolder;\
46 public:\
47 static void *create(OdUInt32 num)\
48 {\
49  return new Contour[num];\
50 }
51 
52 #define ODGT_HOLDER , MemoryHolder &pHolder
53 #define ODGT_HOLDER2 , pHolder
54 
55 namespace ODGT_NAMESPACE
56 {
57  class Vertex;
58  class Contour;
59 
61  {
62  public:
63  virtual Vertex *newVertex() = 0;
64  virtual void deleteVertex(Vertex *) = 0;
65 
66  virtual Contour *newContour() = 0;
67  virtual void deleteContour(Contour *) = 0;
68 
69  virtual ~MemoryHolder() {}
70  };
71 };
72 
73 
74 #include "GeTess.h"
75 
76 #define HOLDER_(A, B) struct A\
77 {\
78  bool m_First;\
79  B* m_FirstPage;\
80  OdList< B* > m_Buf;\
81  OdUInt32 m_pageSize;\
82  OdUInt32 m_pos;\
83 \
84  A(OdUInt32 pageSize)\
85  : m_First(true)\
86  , m_FirstPage(0)\
87  , m_pageSize(pageSize)\
88  , m_pos(0)\
89  {\
90  m_FirstPage = (B*)B::create(m_pageSize);\
91  /*m_Buf.resize(1, (B*)B::create(m_pageSize) );*/\
92  }\
93 \
94  void freeMem()\
95  {\
96  delete []m_FirstPage; m_FirstPage = 0;\
97  OdList< B* >::iterator pIt = m_Buf.begin();\
98  OdList< B* >::iterator pItEnd = m_Buf.end();\
99 \
100  while(pIt != pItEnd)\
101  {\
102  delete[] *pIt;\
103  ++pIt;\
104  }\
105  }\
106 \
107  ~A()\
108  {\
109  freeMem();\
110  }\
111 \
112  B* newOne()\
113  {\
114  if (m_pos == m_pageSize)\
115  {\
116  m_First = false;\
117  m_Buf.push_front( (B*)B::create(m_pageSize) );\
118  m_pos = 0;\
119  }\
120  if (m_First)\
121  return &m_FirstPage[m_pos++];\
122  return &(*m_Buf.begin())[m_pos++];\
123  }\
124 };
125 
130 namespace OdGeTess2
131 {
132  class GE_TOOLKIT_EXPORT OptimizedHolder : public MemoryHolder
133  {
134  HOLDER_(Holder_Contour, Contour)
135  HOLDER_(Holder_Vertex, Vertex)
136 
137  Holder_Vertex m_Vxs;
138  Holder_Contour m_Ctrs;
139 
140  public:
141  OptimizedHolder(OdUInt32 nPreAllocVertexes, OdUInt32 nPreAllocContours);
142 
143  virtual Vertex *newVertex();
144  virtual void deleteVertex(Vertex * pVx);
145 
146  virtual Contour *newContour();
147  virtual void deleteContour(Contour *);
148 
150  };
151 };
152 
153 #undef ODGT_NAMESPACE
154 #undef ODGT_PTRTYPE
155 #undef ODGT_PARENT
156 #undef ODGT_MEMBERS
157 #undef ODGT_HOLDER
158 #undef ODGT_HOLDER2
159 
160 #include "TD_PackPop.h"
161 
162 #endif // __ODGITESSELATOR_2_H_INCLUDED__
#define GE_TOOLKIT_EXPORT
Definition: GeExport.h:49
#define HOLDER_(A, B)
Definition: GeTess2.h:76
unsigned int OdUInt32
virtual Vertex * newVertex()=0
virtual void deleteContour(Contour *)=0
virtual void deleteVertex(Vertex *)=0
virtual Contour * newContour()=0
virtual void deleteContour(Contour *)
virtual Vertex * newVertex()
virtual void deleteVertex(Vertex *pVx)
virtual Contour * newContour()
OptimizedHolder(OdUInt32 nPreAllocVertexes, OdUInt32 nPreAllocContours)