ReactOS 0.4.15-dev-7924-g5949c20
Mesher Class Reference

#include <mesher.h>

Inheritance diagram for Mesher:
Collaboration diagram for Mesher:

Public Member Functions

 Mesher (Backend &)
 
 ~Mesher (void)
 
void init (unsigned int)
 
void mesh (void)
 
- Public Member Functions inherited from TrimRegion
 TrimRegion ()
 
void init (REAL)
 
void advance (REAL, REAL, REAL)
 
void setDu (REAL)
 
void init (long, Arc_ptr)
 
void getPts (Arc_ptr)
 
void getPts (Backend &)
 
void getGridExtent (TrimVertex *, TrimVertex *)
 
void getGridExtent (void)
 
int canTile (void)
 
- Public Member Functions inherited from Hull
 Hull (void)
 
 ~Hull (void)
 
void init (void)
 
GridTrimVertexnextlower (GridTrimVertex *)
 
GridTrimVertexnextupper (GridTrimVertex *)
 

Private Member Functions

void openMesh (void)
 
void swapMesh (void)
 
void closeMesh (void)
 
int isCcw (int)
 
int isCw (int)
 
void clearStack (void)
 
void push (GridTrimVertex *)
 
void pop (long)
 
void move (int, int)
 
int equal (int, int)
 
void copy (int, int)
 
void output (int)
 
void addUpper (void)
 
void addLower (void)
 
void addLast (void)
 
void finishUpper (GridTrimVertex *)
 
void finishLower (GridTrimVertex *)
 

Private Attributes

Backendbackend
 
Pool p
 
unsigned int stacksize
 
GridTrimVertex ** vdata
 
GridTrimVertexlast [2]
 
int itop
 
int lastedge
 

Static Private Attributes

static const float ZERO = 0.0
 

Additional Inherited Members

- Public Attributes inherited from TrimRegion
Trimline left
 
Trimline right
 
Gridline top
 
Gridline bot
 
Uarray uarray
 

Detailed Description

Definition at line 47 of file mesher.h.

Constructor & Destructor Documentation

◆ Mesher()

Mesher::Mesher ( Backend b)

Definition at line 55 of file mesher.cc.

56 : backend( b ),
57 p( sizeof( GridTrimVertex ), 100, "GridTrimVertexPool" )
58{
59 stacksize = 0;
60 vdata = 0;
61 last[0] = 0;
62 last[1] = 0;
63 itop = 0;
64 lastedge = 0; //needed to prevent purify UMR
65}
GridTrimVertex ** vdata
Definition: mesher.h:60
GridTrimVertex * last[2]
Definition: mesher.h:61
int lastedge
Definition: mesher.h:63
int itop
Definition: mesher.h:62
Backend & backend
Definition: mesher.h:56
unsigned int stacksize
Definition: mesher.h:59
Pool p
Definition: mesher.h:58
GLboolean GLboolean GLboolean b
Definition: glext.h:6204

◆ ~Mesher()

Mesher::~Mesher ( void  )

Definition at line 67 of file mesher.cc.

68{
69 if( vdata ) delete[] vdata;
70}

Member Function Documentation

◆ addLast()

void Mesher::addLast ( void  )
private

Definition at line 277 of file mesher.cc.

278{
279 int ilast = itop;
280
281 if( lastedge == 0 ) {
282 if( equal( 0, 1 ) ) {
283 output( ilast );
284 swapMesh();
285 for( int i = 2; i < ilast; i++ ) {
286 swapMesh();
287 output( i );
288 }
289 copy( ilast, ilast-1 );
290 } else if( equal( ilast-2, ilast-1) ) {
291 swapMesh();
292 output( ilast );
293 for( int i = ilast-3; i >= 0; i-- ) {
294 output( i );
295 swapMesh();
296 }
297 copy( 0, ilast );
298 } else {
299 closeMesh(); openMesh();
300 output( ilast );
301 output( 0 );
302 for( int i = 1; i < ilast; i++ ) {
303 swapMesh();
304 output( i );
305 }
306 copy( ilast, ilast-1 );
307 }
308 } else {
309 if( equal( 1, 0) ) {
310 swapMesh();
311 output( ilast );
312 for( int i = 2; i < ilast; i++ ) {
313 output( i );
314 swapMesh();
315 }
316 copy( ilast-1, ilast );
317 } else if( equal( ilast-1, ilast-2) ) {
318 output( ilast );
319 swapMesh();
320 for( int i = ilast-3; i >= 0; i-- ) {
321 swapMesh();
322 output( i );
323 }
324 copy( ilast, 0 );
325 } else {
326 closeMesh(); openMesh();
327 output( 0 );
328 output( ilast );
329 for( int i = 1; i < ilast; i++ ) {
330 output( i );
331 swapMesh();
332 }
333 copy( ilast-1, ilast );
334 }
335 }
336 closeMesh();
337 //for( long k=0; k<=ilast; k++ ) pop( k );
338}
void copy(int, int)
Definition: mesher.cc:246
void output(int)
Definition: mesher.cc:258
void swapMesh(void)
Definition: mesher.cc:108
void openMesh(void)
Definition: mesher.cc:96
void closeMesh(void)
Definition: mesher.cc:102
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define equal(x, y)
Definition: reader.cc:56

Referenced by finishLower(), and finishUpper().

◆ addLower()

void Mesher::addLower ( void  )
private

Definition at line 415 of file mesher.cc.

416{
417 int ilast = itop;
418
419 if( lastedge == 1 ) {
420 if( equal( 1, 0) ) {
421 swapMesh();
422 output( ilast );
423 for( int i = 2; i < ilast; i++ ) {
424 output( i );
425 swapMesh();
426 }
427 copy( ilast-1, ilast );
428 } else if( equal( ilast-1, ilast-2) ) {
429 output( ilast );
430 swapMesh();
431 for( int i = ilast-3; i >= 0; i-- ) {
432 swapMesh();
433 output( i );
434 }
435 copy( ilast, 0 );
436 } else {
437 closeMesh(); openMesh();
438 output( 0 );
439 output( ilast );
440 for( int i = 1; i < ilast; i++ ) {
441 output( i );
442 swapMesh();
443 }
444 copy( ilast-1, ilast );
445 }
446
447 lastedge = 0;
448 //for( long k=0; k<ilast-1; k++ ) pop( k );
449 move( 0, ilast-1 );
450 move( 1, ilast );
451 itop = 1;
452 } else {
453 if( ! isCw( ilast ) ) return;
454 do {
455 itop--;
456 } while( (itop > 1) && isCw( ilast ) );
457
458 if( equal( ilast-2, ilast-1) ) {
459 swapMesh();
460 output( ilast );
461 for( int i=ilast-3; i>=itop-1; i--) {
462 output( i );
463 swapMesh( );
464 }
465 copy( itop-1, ilast );
466 } else if( equal( itop-1, itop) ) {
467 output( ilast );
468 swapMesh();
469 for( int i=itop+1; i<ilast; i++ ) {
470 swapMesh( );
471 output( i );
472 }
473 copy( ilast, ilast-1 );
474 } else {
475 closeMesh(); openMesh();
476 output( ilast-1 );
477 output( ilast );
478 for( int i=ilast-2; i>=itop-1; i-- ) {
479 output( i );
480 swapMesh( );
481 }
482 copy( itop-1, ilast );
483 }
484 //for( int k=itop; k<ilast; k++ ) pop( k );
485 move( itop, ilast );
486 }
487}
int isCw(int)
Definition: mesher.cc:233
void move(int, int)
Definition: mesher.cc:252

Referenced by finishLower(), and mesh().

◆ addUpper()

void Mesher::addUpper ( void  )
private

Definition at line 341 of file mesher.cc.

342{
343 int ilast = itop;
344
345 if( lastedge == 0 ) {
346 if( equal( 0, 1 ) ) {
347 output( ilast );
348 swapMesh();
349 for( int i = 2; i < ilast; i++ ) {
350 swapMesh();
351 output( i );
352 }
353 copy( ilast, ilast-1 );
354 } else if( equal( ilast-2, ilast-1) ) {
355 swapMesh();
356 output( ilast );
357 for( int i = ilast-3; i >= 0; i-- ) {
358 output( i );
359 swapMesh();
360 }
361 copy( 0, ilast );
362 } else {
363 closeMesh(); openMesh();
364 output( ilast );
365 output( 0 );
366 for( int i = 1; i < ilast; i++ ) {
367 swapMesh();
368 output( i );
369 }
370 copy( ilast, ilast-1 );
371 }
372 lastedge = 1;
373 //for( long k=0; k<ilast-1; k++ ) pop( k );
374 move( 0, ilast-1 );
375 move( 1, ilast );
376 itop = 1;
377 } else {
378 if( ! isCcw( ilast ) ) return;
379 do {
380 itop--;
381 } while( (itop > 1) && isCcw( ilast ) );
382
383 if( equal( ilast-1, ilast-2 ) ) {
384 output( ilast );
385 swapMesh();
386 for( int i=ilast-3; i>=itop-1; i-- ) {
387 swapMesh();
388 output( i );
389 }
390 copy( ilast, itop-1 );
391 } else if( equal( itop, itop-1 ) ) {
392 swapMesh();
393 output( ilast );
394 for( int i = itop+1; i < ilast; i++ ) {
395 output( i );
396 swapMesh();
397 }
398 copy( ilast-1, ilast );
399 } else {
400 closeMesh(); openMesh();
401 output( ilast );
402 output( ilast-1 );
403 for( int i=ilast-2; i>=itop-1; i-- ) {
404 swapMesh();
405 output( i );
406 }
407 copy( ilast, itop-1 );
408 }
409 //for( int k=itop; k<ilast; k++ ) pop( k );
410 move( itop, ilast );
411 }
412}
int isCcw(int)
Definition: mesher.cc:226

Referenced by finishUpper(), and mesh().

◆ clearStack()

void Mesher::clearStack ( void  )
inlineprivate

Definition at line 114 of file mesher.cc.

115{
116 itop = -1;
117 last[0] = 0;
118}

Referenced by mesh().

◆ closeMesh()

void Mesher::closeMesh ( void  )
inlineprivate

Definition at line 102 of file mesher.cc.

103{
105}
void endtmesh(void)
Definition: backend.cc:460

Referenced by addLast(), addLower(), and addUpper().

◆ copy()

void Mesher::copy ( int  x,
int  y 
)
inlineprivate

Definition at line 246 of file mesher.cc.

247{
248 last[0] = vdata[x]; last[1] = vdata[y];
249}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by addLast(), addLower(), and addUpper().

◆ equal()

int Mesher::equal ( int  x,
int  y 
)
inlineprivate

Definition at line 240 of file mesher.cc.

241{
242 return( last[0] == vdata[x] && last[1] == vdata[y] );
243}

◆ finishLower()

void Mesher::finishLower ( GridTrimVertex gtlower)
private

Definition at line 121 of file mesher.cc.

122{
123 for( push(gtlower);
124 nextlower( gtlower=new(p) GridTrimVertex );
125 push(gtlower) )
126 addLower();
127 addLast();
128}
GridTrimVertex * nextlower(GridTrimVertex *)
Definition: hull.cc:142
void addLast(void)
Definition: mesher.cc:277
void addLower(void)
Definition: mesher.cc:415
void push(GridTrimVertex *)
Definition: mesher.cc:84
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by mesh().

◆ finishUpper()

void Mesher::finishUpper ( GridTrimVertex gtupper)
private

Definition at line 131 of file mesher.cc.

132{
133 for( push(gtupper);
134 nextupper( gtupper=new(p) GridTrimVertex );
135 push(gtupper) )
136 addUpper();
137 addLast();
138}
GridTrimVertex * nextupper(GridTrimVertex *)
Definition: hull.cc:116
void addUpper(void)
Definition: mesher.cc:341

Referenced by mesh().

◆ init()

void Mesher::init ( unsigned int  npts)

Definition at line 73 of file mesher.cc.

74{
75 p.clear();
76 if( stacksize < npts ) {
77 stacksize = 2 * npts;
78 if( vdata ) delete[] vdata;
80 }
81}

◆ isCcw()

int Mesher::isCcw ( int  ilast)
inlineprivate

Definition at line 226 of file mesher.cc.

227{
228 REAL area = det3( vdata[ilast]->t, vdata[itop-1]->t, vdata[itop-2]->t );
229 return (area < ZERO) ? 0 : 1;
230}
static const float ZERO
Definition: mesher.h:55
float REAL
Definition: types.h:41
GLdouble GLdouble t
Definition: gl.h:2047
static Real area(Real A[2], Real B[2], Real C[2])
Definition: polyDBG.cc:50
REAL det3(TrimVertex *a, TrimVertex *b, TrimVertex *c)
Definition: trimvertex.h:56

Referenced by addUpper().

◆ isCw()

int Mesher::isCw ( int  ilast)
inlineprivate

Definition at line 233 of file mesher.cc.

234{
235 REAL area = det3( vdata[ilast]->t, vdata[itop-1]->t, vdata[itop-2]->t );
236 return (area > -ZERO) ? 0 : 1;
237}

Referenced by addLower().

◆ mesh()

void Mesher::mesh ( void  )

Definition at line 141 of file mesher.cc.

142{
143 GridTrimVertex *gtlower, *gtupper;
144
145 Hull::init( );
146 nextupper( gtupper = new(p) GridTrimVertex );
147 nextlower( gtlower = new(p) GridTrimVertex );
148
149 clearStack();
150 openMesh();
151 push(gtupper);
152
153 nextupper( gtupper = new(p) GridTrimVertex );
154 nextlower( gtlower );
155
156 assert( gtupper->t && gtlower->t );
157
158 if( gtupper->t->param[0] < gtlower->t->param[0] ) {
159 push(gtupper);
160 lastedge = 1;
161 if( nextupper( gtupper=new(p) GridTrimVertex ) == 0 ) {
162 finishLower(gtlower);
163 return;
164 }
165 } else if( gtupper->t->param[0] > gtlower->t->param[0] ) {
166 push(gtlower);
167 lastedge = 0;
168 if( nextlower( gtlower=new(p) GridTrimVertex ) == 0 ) {
169 finishUpper(gtupper);
170 return;
171 }
172 } else {
173 if( lastedge == 0 ) {
174 push(gtupper);
175 lastedge = 1;
176 if( nextupper(gtupper=new(p) GridTrimVertex) == 0 ) {
177 finishLower(gtlower);
178 return;
179 }
180 } else {
181 push(gtlower);
182 lastedge = 0;
183 if( nextlower( gtlower=new(p) GridTrimVertex ) == 0 ) {
184 finishUpper(gtupper);
185 return;
186 }
187 }
188 }
189
190 while ( 1 ) {
191 if( gtupper->t->param[0] < gtlower->t->param[0] ) {
192 push(gtupper);
193 addUpper();
194 if( nextupper( gtupper=new(p) GridTrimVertex ) == 0 ) {
195 finishLower(gtlower);
196 return;
197 }
198 } else if( gtupper->t->param[0] > gtlower->t->param[0] ) {
199 push(gtlower);
200 addLower();
201 if( nextlower( gtlower=new(p) GridTrimVertex ) == 0 ) {
202 finishUpper(gtupper);
203 return;
204 }
205 } else {
206 if( lastedge == 0 ) {
207 push(gtupper);
208 addUpper();
209 if( nextupper( gtupper=new(p) GridTrimVertex ) == 0 ) {
210 finishLower(gtlower);
211 return;
212 }
213 } else {
214 push(gtlower);
215 addLower();
216 if( nextlower( gtlower=new(p) GridTrimVertex ) == 0 ) {
217 finishUpper(gtupper);
218 return;
219 }
220 }
221 }
222 }
223}
TrimVertex * t
void init(void)
Definition: hull.cc:63
void finishUpper(GridTrimVertex *)
Definition: mesher.cc:131
void clearStack(void)
Definition: mesher.cc:114
void finishLower(GridTrimVertex *)
Definition: mesher.cc:121
REAL param[2]
Definition: trimvertex.h:45
#define assert(x)
Definition: debug.h:53

Referenced by Slicer::slice_old().

◆ move()

void Mesher::move ( int  x,
int  y 
)
inlineprivate

Definition at line 252 of file mesher.cc.

253{
254 vdata[x] = vdata[y];
255}

Referenced by addLower(), and addUpper().

◆ openMesh()

void Mesher::openMesh ( void  )
inlineprivate

Definition at line 96 of file mesher.cc.

97{
98 backend.bgntmesh( "addedge" );
99}
void bgntmesh(const char *)
Definition: backend.cc:246

Referenced by addLast(), addLower(), addUpper(), and mesh().

◆ output()

void Mesher::output ( int  x)
inlineprivate

Definition at line 258 of file mesher.cc.

259{
261}
void tmeshvert(GridTrimVertex *)
Definition: backend.cc:269

Referenced by addLast(), addLower(), and addUpper().

◆ pop()

void Mesher::pop ( long  )
inlineprivate

Definition at line 91 of file mesher.cc.

92{
93}

◆ push()

void Mesher::push ( GridTrimVertex gt)
inlineprivate

Definition at line 84 of file mesher.cc.

85{
86 assert( itop+1 != (int)stacksize );
87 vdata[++itop] = gt;
88}

Referenced by finishLower(), finishUpper(), and mesh().

◆ swapMesh()

void Mesher::swapMesh ( void  )
inlineprivate

Definition at line 108 of file mesher.cc.

109{
111}
void swaptmesh(void)
Definition: backend.cc:442

Referenced by addLast(), addLower(), and addUpper().

Member Data Documentation

◆ backend

Backend& Mesher::backend
private

Definition at line 56 of file mesher.h.

Referenced by closeMesh(), openMesh(), output(), and swapMesh().

◆ itop

int Mesher::itop
private

Definition at line 62 of file mesher.h.

Referenced by addLast(), addLower(), addUpper(), clearStack(), isCcw(), isCw(), Mesher(), and push().

◆ last

GridTrimVertex* Mesher::last[2]
private

Definition at line 61 of file mesher.h.

Referenced by clearStack(), copy(), equal(), and Mesher().

◆ lastedge

int Mesher::lastedge
private

Definition at line 63 of file mesher.h.

Referenced by addLast(), addLower(), addUpper(), mesh(), and Mesher().

◆ p

Pool Mesher::p
private

Definition at line 58 of file mesher.h.

◆ stacksize

unsigned int Mesher::stacksize
private

Definition at line 59 of file mesher.h.

Referenced by init(), Mesher(), and push().

◆ vdata

GridTrimVertex** Mesher::vdata
private

Definition at line 60 of file mesher.h.

Referenced by copy(), equal(), init(), isCcw(), isCw(), Mesher(), move(), output(), push(), and ~Mesher().

◆ ZERO

const float Mesher::ZERO = 0.0
staticprivate

Definition at line 55 of file mesher.h.

Referenced by isCcw(), and isCw().


The documentation for this class was generated from the following files: