ReactOS  r76032
slicer.cc File Reference
#include "slicer.h"
#include "backend.h"
#include "simplemath.h"
#include "varray.h"
#include "polyUtil.h"
#include "monoTriangulation.h"
#include "sampleMonoPoly.h"
Include dependency graph for slicer.cc:

Go to the source code of this file.

Macros

#define max(a, b)   ((a>b)? a:b)
 
#define ZERO   0.00001 /*determing whether a loop is a rectngle or not*/
 
#define equalRect(a, b)   ((glu_abs(a-b) <= ZERO)? 1:0)
 

Functions

int compInY (REAL a[2], REAL b[2])
 
void monoTriangulationLoop (Arc_ptr loop, Backend &backend, primStream *pStream)
 
static void triangulateRectGen (Arc_ptr loop, int n_ulines, int n_vlines, Backend &backend)
 
static Int is_rect (Arc_ptr loop)
 
void OPT_OUTVERT (TrimVertex &vv, Backend &backend)
 
static void triangulateRectAux (PwlArc *top, PwlArc *bot, PwlArc *left, PwlArc *right, Backend &backend)
 
static void triangulateRect (Arc_ptr loop, Backend &backend, int TB_or_LR, int ulinear, int vlinear)
 
static void triangulateRectCenter (int n_ulines, REAL *u_val, int n_vlines, REAL *v_val, Backend &backend)
 
static void triangulateRectTopGen (Arc_ptr arc, int n_ulines, REAL *u_val, Real v, int dir, int is_u, Backend &backend)
 
directedLinearcToDLine (Arc_ptr arc)
 
directedLinearcToMultDLines (directedLine *original, Arc_ptr arc)
 
directedLinearcLoopToDLineLoop (Arc_ptr loop)
 

Macro Definition Documentation

#define equalRect (   a,
  b 
)    ((glu_abs(a-b) <= ZERO)? 1:0)

Definition at line 83 of file slicer.cc.

Referenced by triangulateRectGen().

#define max (   a,
  b 
)    ((a>b)? a:b)

Definition at line 81 of file slicer.cc.

#define ZERO   0.00001 /*determing whether a loop is a rectngle or not*/

Definition at line 82 of file slicer.cc.

Referenced by is_rect().

Function Documentation

directedLine* arcLoopToDLineLoop ( Arc_ptr  loop)

Definition at line 948 of file slicer.cc.

Referenced by bin_to_DLineLoops(), and Slicer::slice_new().

949 {
950  directedLine* ret;
951 
952  if(loop == NULL)
953  return NULL;
954  ret = arcToMultDLines(NULL, loop);
955 //ret->printSingle();
956  for(Arc_ptr temp = loop->next; temp != loop; temp = temp->next){
957  ret = arcToMultDLines(ret, temp);
958 //ret->printSingle();
959  }
960 
961  return ret;
962 }
VARIANT loop
directedLine * arcToMultDLines(directedLine *original, Arc_ptr arc)
Definition: slicer.cc:907
smooth NULL
Definition: ftsmooth.c:557
int ret
static stack_node_t temp
Definition: rpn.c:18
class Arc * Arc_ptr
Definition: arc.h:50
void * next
Definition: rpn.c:5
directedLine* arcToDLine ( Arc_ptr  arc)

Definition at line 890 of file slicer.cc.

Referenced by arcToMultDLines().

891 {
892  int i;
893  Real vert[2];
894  directedLine* ret;
895  sampledLine* sline = new sampledLine(arc->pwlArc->npts);
896  for(i=0; i<arc->pwlArc->npts; i++)
897  {
898  vert[0] = arc->pwlArc->pts[i].param[0];
899  vert[1] = arc->pwlArc->pts[i].param[1];
900  sline->setPoint(i, vert);
901  }
902  ret = new directedLine(INCREASING, sline);
903  return ret;
904 }
GLenum GLclampf GLint i
Definition: glfuncs.h:14
int ret
void setPoint(Int i, Real p[2])
Definition: sampledLine.cc:45
float Real
Definition: definitions.h:36
directedLine* arcToMultDLines ( directedLine original,
Arc_ptr  arc 
)

Definition at line 907 of file slicer.cc.

Referenced by arcLoopToDLineLoop().

908 {
909  directedLine* ret = original;
910  int is_linear = 0;
911  if(arc->pwlArc->npts == 2 )
912  is_linear = 1;
913  else if(area(arc->pwlArc->pts[0].param, arc->pwlArc->pts[1].param, arc->pwlArc->pts[arc->pwlArc->npts-1].param) == 0.0)
914  is_linear = 1;
915 
916  if(is_linear)
917  {
918  directedLine *dline = arcToDLine(arc);
919  if(ret == NULL)
920  ret = dline;
921  else
922  ret->insert(dline);
923  return ret;
924  }
925  else /*not linear*/
926  {
927  for(Int i=0; i<arc->pwlArc->npts-1; i++)
928  {
929  Real vert[2][2];
930  vert[0][0] = arc->pwlArc->pts[i].param[0];
931  vert[0][1] = arc->pwlArc->pts[i].param[1];
932  vert[1][0] = arc->pwlArc->pts[i+1].param[0];
933  vert[1][1] = arc->pwlArc->pts[i+1].param[1];
934 
935  sampledLine *sline = new sampledLine(2, vert);
936  directedLine *dline = new directedLine(INCREASING, sline);
937  if(ret == NULL)
938  ret = dline;
939  else
940  ret->insert(dline);
941  }
942  return ret;
943  }
944 }
directedLine * arcToDLine(Arc_ptr arc)
Definition: slicer.cc:890
GLenum GLclampf GLint i
Definition: glfuncs.h:14
smooth NULL
Definition: ftsmooth.c:557
const GLfloat area
Definition: s_aatritemp.h:104
int ret
float Real
Definition: definitions.h:36
void insert(directedLine *nl)
int Int
Definition: definitions.h:37
int compInY ( REAL  a[2],
REAL  b[2] 
)
inline

Definition at line 132 of file slicer.cc.

Referenced by monoTriangulationLoop().

133 {
134  if(a[1] < b[1])
135  return -1;
136  else if (a[1] > b[1])
137  return 1;
138  else if(a[0] > b[0])
139  return 1;
140  else return -1;
141 }
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
static Int is_rect ( Arc_ptr  loop)
static

Definition at line 220 of file slicer.cc.

Referenced by Slicer::slice_new().

221 {
222  Int nlines =1;
223  for(Arc_ptr jarc = loop->next; jarc != loop; jarc = jarc->next)
224  {
225  nlines++;
226  if(nlines == 5)
227  break;
228  }
229  if(nlines != 4)
230  return 0;
231 
232 
233 /*
234 printf("here1\n");
235 printf("loop->tail=(%f,%f)\n", loop->tail()[0], loop->tail()[1]);
236 printf("loop->head=(%f,%f)\n", loop->head()[0], loop->head()[1]);
237 printf("loop->next->tail=(%f,%f)\n", loop->next->tail()[0], loop->next->tail()[1]);
238 printf("loop->next->head=(%f,%f)\n", loop->next->head()[0], loop->next->head()[1]);
239 if(fglu_abs(loop->tail()[0] - loop->head()[0])<0.000001)
240  printf("equal 1\n");
241 if(loop->next->tail()[1] == loop->next->head()[1])
242  printf("equal 2\n");
243 */
244 
245  if( (glu_abs(loop->tail()[0] - loop->head()[0])<=ZERO) &&
246  (glu_abs(loop->next->tail()[1] - loop->next->head()[1])<=ZERO) &&
247  (glu_abs(loop->prev->tail()[1] - loop->prev->head()[1])<=ZERO) &&
248  (glu_abs(loop->prev->prev->tail()[0] - loop->prev->prev->head()[0])<=ZERO)
249  )
250  return 1;
251  else if
252  ( (glu_abs(loop->tail()[1] - loop->head()[1]) <= ZERO) &&
253  (glu_abs(loop->next->tail()[0] - loop->next->head()[0]) <= ZERO) &&
254  (glu_abs(loop->prev->tail()[0] - loop->prev->head()[0]) <= ZERO) &&
255  (glu_abs(loop->prev->prev->tail()[1] - loop->prev->prev->head()[1]) <= ZERO)
256  )
257  return 1;
258  else
259  return 0;
260 }
VARIANT loop
REAL glu_abs(REAL x)
Definition: simplemath.h:50
#define ZERO
Definition: slicer.cc:82
class Arc * Arc_ptr
Definition: arc.h:50
int Int
Definition: definitions.h:37
void monoTriangulationLoop ( Arc_ptr  loop,
Backend backend,
primStream pStream 
)

Definition at line 143 of file slicer.cc.

144 {
145  int i;
146  //find the top, bottom, increasing and decreasing chain
147  //then call monoTrianulation
148  Arc_ptr jarc, temp;
149  Arc_ptr top;
150  Arc_ptr bot;
151  top = bot = loop;
152  if(compInY(loop->tail(), loop->prev->tail()) < 0)
153  {
154  //first find bot
155  for(temp = loop->next; temp != loop; temp = temp->next)
156  {
157  if(compInY(temp->tail(), temp->prev->tail()) > 0)
158  break;
159  }
160  bot = temp->prev;
161  //then find top
162  for(temp=loop->prev; temp != loop; temp = temp->prev)
163  {
164  if(compInY(temp->tail(), temp->prev->tail()) > 0)
165  break;
166  }
167  top = temp;
168  }
169  else //loop > loop->prev
170  {
171  for(temp=loop->next; temp != loop; temp = temp->next)
172  {
173  if(compInY(temp->tail(), temp->prev->tail()) < 0)
174  break;
175  }
176  top = temp->prev;
177  for(temp=loop->prev; temp != loop; temp = temp->prev)
178  {
179  if(compInY(temp->tail(), temp->prev->tail()) < 0)
180  break;
181  }
182  bot = temp;
183  }
184  //creat increase and decrease chains
185  vertexArray inc_chain(50); //this is a dynamci array
186  for(i=1; i<=top->pwlArc->npts-2; i++)
187  {
188  //the first vertex is the top which doesn't below to inc_chain
189  inc_chain.appendVertex(top->pwlArc->pts[i].param);
190  }
191  for(jarc=top->next; jarc != bot; jarc = jarc->next)
192  {
193  for(i=0; i<=jarc->pwlArc->npts-2; i++)
194  {
195  inc_chain.appendVertex(jarc->pwlArc->pts[i].param);
196  }
197 
198  }
199  vertexArray dec_chain(50);
200  for(jarc = top->prev; jarc != bot; jarc = jarc->prev)
201  {
202  for(i=jarc->pwlArc->npts-2; i>=0; i--)
203  {
204  dec_chain.appendVertex(jarc->pwlArc->pts[i].param);
205  }
206  }
207  for(i=bot->pwlArc->npts-2; i>=1; i--)
208  {
209  dec_chain.appendVertex(jarc->pwlArc->pts[i].param);
210  }
211 
212  monoTriangulationRec(top->tail(), bot->tail(), &inc_chain, 0,
213  &dec_chain, 0, &backend);
214 
215 }
VARIANT loop
GLenum GLclampf GLint i
Definition: glfuncs.h:14
void monoTriangulationRec(Real *topVertex, Real *botVertex, vertexArray *inc_chain, Int inc_current, vertexArray *dec_chain, Int dec_current, Backend *backend)
static stack_node_t temp
Definition: rpn.c:18
class Arc * Arc_ptr
Definition: arc.h:50
int compInY(REAL a[2], REAL b[2])
Definition: slicer.cc:132
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
void OPT_OUTVERT ( TrimVertex vv,
Backend backend 
)
inline

Definition at line 303 of file slicer.cc.

Referenced by triangulateRectAux().

304 {
305 
306 #ifdef USE_OPTTT
307  glNormal3fv(vv.cache_normal);
308  glVertex3fv(vv.cache_point);
309 #else
310 
311  backend.tmeshvert(&vv);
312 
313 #endif
314 
315 }
void tmeshvert(GridTrimVertex *)
Definition: backend.cc:269
void GLAPIENTRY glNormal3fv(const GLfloat *v)
Definition: apistubs.c:2316
void GLAPIENTRY glVertex3fv(const GLfloat *v)
Definition: apistubs.c:2716
static void triangulateRect ( Arc_ptr  loop,
Backend backend,
int  TB_or_LR,
int  ulinear,
int  vlinear 
)
static

Definition at line 319 of file slicer.cc.

Referenced by Slicer::slice_new().

320 {
321  //we know the loop is a rectangle, but not sure which is top
322  Arc_ptr top, bot, left, right;
323  if(loop->tail()[1] == loop->head()[1])
324  {
325  if(loop->tail()[1] > loop->prev->prev->tail()[1])
326  {
327 
328  top = loop;
329  }
330  else{
331 
332  top = loop->prev->prev;
333  }
334  }
335  else
336  {
337  if(loop->tail()[0] > loop->prev->prev->tail()[0])
338  {
339  //loop is the right arc
340 
341  top = loop->next;
342  }
343  else
344  {
345 
346  top = loop->prev;
347  }
348  }
349  left = top->next;
350  bot = left->next;
351  right= bot->next;
352 
353  //if u, v are both nonlinear, then if the
354  //boundary is tessellated dense, we also
355  //sample the inside to get a better tesslletant.
356  if( (!ulinear) && (!vlinear))
357  {
358  int nu = top->pwlArc->npts;
359  if(nu < bot->pwlArc->npts)
360  nu = bot->pwlArc->npts;
361  int nv = left->pwlArc->npts;
362  if(nv < right->pwlArc->npts)
363  nv = right->pwlArc->npts;
364 /*
365  if(nu > 2 && nv > 2)
366  {
367  triangulateRectGen(top, nu-2, nv-2, backend);
368  return;
369  }
370 */
371  }
372 
373  if(TB_or_LR == 1)
374  triangulateRectAux(top->pwlArc, bot->pwlArc, left->pwlArc, right->pwlArc, backend);
375  else if(TB_or_LR == -1)
376  triangulateRectAux(left->pwlArc, right->pwlArc, bot->pwlArc, top->pwlArc, backend);
377  else
378  {
379  Int maxPointsTB = top->pwlArc->npts + bot->pwlArc->npts;
380  Int maxPointsLR = left->pwlArc->npts + right->pwlArc->npts;
381 
382  if(maxPointsTB < maxPointsLR)
383  triangulateRectAux(left->pwlArc, right->pwlArc, bot->pwlArc, top->pwlArc, backend);
384  else
385  triangulateRectAux(top->pwlArc, bot->pwlArc, left->pwlArc, right->pwlArc, backend);
386  }
387 }
VARIANT loop
GLint left
Definition: glext.h:7726
GLdouble GLdouble right
Definition: glext.h:10859
class Arc * Arc_ptr
Definition: arc.h:50
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
static void triangulateRectAux(PwlArc *top, PwlArc *bot, PwlArc *left, PwlArc *right, Backend &backend)
Definition: slicer.cc:389
int Int
Definition: definitions.h:37
static void triangulateRectAux ( PwlArc top,
PwlArc bot,
PwlArc left,
PwlArc right,
Backend backend 
)
static

Definition at line 389 of file slicer.cc.

Referenced by triangulateRect().

390 { //if(maxPointsTB >= maxPointsLR)
391  {
392 
393  Int d, topd_left, topd_right, botd_left, botd_right, i,j;
394  d = left->npts /2;
395 
396 #ifdef USE_OPTTT
397  evalLineNOGE(top->pts, top->npts, backend);
398  evalLineNOGE(bot->pts, bot->npts, backend);
399  evalLineNOGE(left->pts, left->npts, backend);
400  evalLineNOGE(right->pts, right->npts, backend);
401 #endif
402 
403  if(top->npts == 2) {
404  backend.bgntfan();
405  OPT_OUTVERT(top->pts[0], backend);//the root
406  for(i=0; i<left->npts; i++){
407  OPT_OUTVERT(left->pts[i], backend);
408  }
409  for(i=1; i<= bot->npts-2; i++){
410  OPT_OUTVERT(bot->pts[i], backend);
411  }
412  backend.endtfan();
413 
414  backend.bgntfan();
415  OPT_OUTVERT(bot->pts[bot->npts-2], backend);
416  for(i=0; i<right->npts; i++){
417  OPT_OUTVERT(right->pts[i], backend);
418  }
419  backend.endtfan();
420  }
421  else if(bot->npts == 2) {
422  backend.bgntfan();
423  OPT_OUTVERT(bot->pts[0], backend);//the root
424  for(i=0; i<right->npts; i++){
425  OPT_OUTVERT(right->pts[i], backend);
426  }
427  for(i=1; i<= top->npts-2; i++){
428  OPT_OUTVERT(top->pts[i], backend);
429  }
430  backend.endtfan();
431 
432  backend.bgntfan();
433  OPT_OUTVERT(top->pts[top->npts-2], backend);
434  for(i=0; i<left->npts; i++){
435  OPT_OUTVERT(left->pts[i], backend);
436  }
437  backend.endtfan();
438  }
439  else { //both top and bot have >=3 points
440 
441  backend.bgntfan();
442 
443  OPT_OUTVERT(top->pts[top->npts-2], backend);
444 
445  for(i=0; i<=d; i++)
446  {
447  OPT_OUTVERT(left->pts[i], backend);
448  }
449  backend.endtfan();
450 
451  backend.bgntfan();
452 
453  OPT_OUTVERT(bot->pts[1], backend);
454 
455  OPT_OUTVERT(top->pts[top->npts-2], backend);
456 
457  for(i=d; i< left->npts; i++)
458  {
459  OPT_OUTVERT(left->pts[i], backend);
460  }
461  backend.endtfan();
462 
463  d = right->npts/2;
464  //output only when d<right->npts-1 and
465  //
466  if(d<right->npts-1)
467  {
468  backend.bgntfan();
469  // backend.tmeshvert(& top->pts[1]);
470  OPT_OUTVERT(top->pts[1], backend);
471  for(i=d; i< right->npts; i++)
472  {
473  // backend.tmeshvert(& right->pts[i]);
474 
475  OPT_OUTVERT(right->pts[i], backend);
476 
477  }
478  backend.endtfan();
479  }
480 
481  backend.bgntfan();
482  // backend.tmeshvert(& bot->pts[bot->npts-2]);
483  OPT_OUTVERT( bot->pts[bot->npts-2], backend);
484  for(i=0; i<=d; i++)
485  {
486  // backend.tmeshvert(& right->pts[i]);
487  OPT_OUTVERT(right->pts[i], backend);
488 
489  }
490 
491  // backend.tmeshvert(& top->pts[1]);
492  OPT_OUTVERT(top->pts[1], backend);
493 
494  backend.endtfan();
495 
496 
497  topd_left = top->npts-2;
498  topd_right = 1; //topd_left>= topd_right
499 
500  botd_left = 1;
501  botd_right = bot->npts-2; //botd_left<= bot_dright
502 
503 
504  if(top->npts < bot->npts)
505  {
506  int delta=bot->npts - top->npts;
507  int u = delta/2;
508  botd_left = 1+ u;
509  botd_right = bot->npts-2-( delta-u);
510 
511  if(botd_left >1)
512  {
513  backend.bgntfan();
514  // backend.tmeshvert(& top->pts[top->npts-2]);
515  OPT_OUTVERT(top->pts[top->npts-2], backend);
516  for(i=1; i<= botd_left; i++)
517  {
518  // backend.tmeshvert(& bot->pts[i]);
519  OPT_OUTVERT(bot->pts[i] , backend);
520  }
521  backend.endtfan();
522  }
523  if(botd_right < bot->npts-2)
524  {
525  backend.bgntfan();
526  OPT_OUTVERT(top->pts[1], backend);
527  for(i=botd_right; i<= bot->npts-2; i++)
528  OPT_OUTVERT(bot->pts[i], backend);
529  backend.endtfan();
530  }
531  }
532  else if(top->npts> bot->npts)
533  {
534  int delta=top->npts-bot->npts;
535  int u = delta/2;
536  topd_left = top->npts-2 - u;
537  topd_right = 1+delta-u;
538 
539  if(topd_left < top->npts-2)
540  {
541  backend.bgntfan();
542  // backend.tmeshvert(& bot->pts[1]);
543  OPT_OUTVERT(bot->pts[1], backend);
544  for(i=topd_left; i<= top->npts-2; i++)
545  {
546  // backend.tmeshvert(& top->pts[i]);
547  OPT_OUTVERT(top->pts[i], backend);
548  }
549  backend.endtfan();
550  }
551  if(topd_right > 1)
552  {
553  backend.bgntfan();
554  OPT_OUTVERT(bot->pts[bot->npts-2], backend);
555  for(i=1; i<= topd_right; i++)
556  OPT_OUTVERT(top->pts[i], backend);
557  backend.endtfan();
558  }
559  }
560 
561  if(topd_left <= topd_right)
562  return;
563 
564  backend.bgnqstrip();
565  for(j=botd_left, i=topd_left; i>=topd_right; i--,j++)
566  {
567  // backend.tmeshvert(& top->pts[i]);
568  // backend.tmeshvert(& bot->pts[j]);
569  OPT_OUTVERT(top->pts[i], backend);
570  OPT_OUTVERT(bot->pts[j], backend);
571  }
572  backend.endqstrip();
573 
574  }
575  }
576 }
int npts
Definition: pwlarc.h:47
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint 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 GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
void bgntfan()
Definition: backend.cc:185
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint 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 GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble * u
Definition: glfuncs.h:88
GLenum GLclampf GLint i
Definition: glfuncs.h:14
void endtfan()
Definition: backend.cc:197
void endqstrip()
Definition: backend.cc:215
#define d
Definition: ke_i.h:81
void bgnqstrip()
Definition: backend.cc:203
void OPT_OUTVERT(TrimVertex &vv, Backend &backend)
Definition: slicer.cc:303
TrimVertex * pts
Definition: pwlarc.h:46
int Int
Definition: definitions.h:37
static void triangulateRectCenter ( int  n_ulines,
REAL u_val,
int  n_vlines,
REAL v_val,
Backend backend 
)
static

Definition at line 579 of file slicer.cc.

Referenced by triangulateRectGen().

582 {
583 
584  // XXX this code was patched by Diego Santa Cruz <Diego.SantaCruz@epfl.ch>
585  // to fix a problem in which glMapGrid2f() was called with bad parameters.
586  // This has beens submitted to SGI but not integrated as of May 1, 2001.
587  if(n_ulines>1 && n_vlines>1) {
588  backend.surfgrid(u_val[0], u_val[n_ulines-1], n_ulines-1,
589  v_val[n_vlines-1], v_val[0], n_vlines-1);
590  backend.surfmesh(0,0,n_ulines-1,n_vlines-1);
591  }
592 
593  return;
594 
595  /*
596  for(i=0; i<n_vlines-1; i++)
597  {
598 
599  backend.bgnqstrip();
600  for(j=0; j<n_ulines; j++)
601  {
602  trimVert.param[0] = u_val[j];
603  trimVert.param[1] = v_val[i+1];
604  backend.tmeshvert(& trimVert);
605 
606  trimVert.param[1] = v_val[i];
607  backend.tmeshvert(& trimVert);
608  }
609  backend.endqstrip();
610 
611  }
612  */
613 }
void surfmesh(long, long, long, long)
Definition: backend.cc:136
void surfgrid(REAL, REAL, long, REAL, REAL, long)
Definition: backend.cc:126
static void triangulateRectGen ( Arc_ptr  loop,
int  n_ulines,
int  n_vlines,
Backend backend 
)
static

Definition at line 778 of file slicer.cc.

Referenced by Slicer::slice_new().

779 {
780 
781  int i;
782  //we know the loop is a rectangle, but not sure which is top
783  Arc_ptr top, bot, left, right;
784 
785  if(equalRect(loop->tail()[1] , loop->head()[1]))
786  {
787 
788  if(loop->tail()[1] > loop->prev->prev->tail()[1])
789  {
790 
791  top = loop;
792  }
793  else{
794 
795  top = loop->prev->prev;
796  }
797  }
798  else
799  {
800  if(loop->tail()[0] > loop->prev->prev->tail()[0])
801  {
802  //loop is the right arc
803 
804  top = loop->next;
805  }
806  else
807  {
808 
809  top = loop->prev;
810  }
811  }
812 
813  left = top->next;
814  bot = left->next;
815  right= bot->next;
816 
817 #ifdef COUNT_TRIANGLES
818  num_triangles += loop->pwlArc->npts +
819  left->pwlArc->npts +
820  bot->pwlArc->npts +
821  right->pwlArc->npts
822  + 2*n_ulines + 2*n_vlines
823  -8;
824  num_quads += (n_ulines-1)*(n_vlines-1);
825 #endif
826 /*
827  backend.surfgrid(left->tail()[0], right->tail()[0], n_ulines+1,
828  top->tail()[1], bot->tail()[1], n_vlines+1);
829 // if(n_ulines>1 && n_vlines>1)
830  backend.surfmesh(0,0,n_ulines+1,n_vlines+1);
831 return;
832 */
833  REAL* u_val=(REAL*) malloc(sizeof(REAL)*n_ulines);
834  assert(u_val);
835  REAL* v_val=(REAL*)malloc(sizeof(REAL) * n_vlines);
836  assert(v_val);
837  REAL u_stepsize = (right->tail()[0] - left->tail()[0])/( (REAL) n_ulines+1);
838  REAL v_stepsize = (top->tail()[1] - bot->tail()[1])/( (REAL) n_vlines+1);
839  Real temp=left->tail()[0]+u_stepsize;
840  for(i=0; i<n_ulines; i++)
841  {
842  u_val[i] = temp;
843  temp += u_stepsize;
844  }
845  temp = bot->tail()[1] + v_stepsize;
846  for(i=0; i<n_vlines; i++)
847  {
848  v_val[i] = temp;
849  temp += v_stepsize;
850  }
851 
852  triangulateRectTopGen(top, n_ulines, u_val, v_val[n_vlines-1], 1,1, backend);
853  triangulateRectTopGen(bot, n_ulines, u_val, v_val[0], 0, 1, backend);
854  triangulateRectTopGen(left, n_vlines, v_val, u_val[0], 1, 0, backend);
855  triangulateRectTopGen(right, n_vlines, v_val, u_val[n_ulines-1], 0,0, backend);
856 
857 
858 
859 
860  //triangulate the center
861  triangulateRectCenter(n_ulines, u_val, n_vlines, v_val, backend);
862 
863  free(u_val);
864  free(v_val);
865 
866 }
static void triangulateRectTopGen(Arc_ptr arc, int n_ulines, REAL *u_val, Real v, int dir, int is_u, Backend &backend)
Definition: slicer.cc:616
VARIANT loop
#define free
Definition: debug_ros.c:5
#define assert(x)
Definition: debug.h:53
GLenum GLclampf GLint i
Definition: glfuncs.h:14
GLint left
Definition: glext.h:7726
GLdouble GLdouble right
Definition: glext.h:10859
static stack_node_t temp
Definition: rpn.c:18
class Arc * Arc_ptr
Definition: arc.h:50
#define equalRect(a, b)
Definition: slicer.cc:83
float Real
Definition: definitions.h:36
#define malloc
Definition: debug_ros.c:4
static void triangulateRectCenter(int n_ulines, REAL *u_val, int n_vlines, REAL *v_val, Backend &backend)
Definition: slicer.cc:579
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
float REAL
Definition: types.h:41
static void triangulateRectTopGen ( Arc_ptr  arc,
int  n_ulines,
REAL u_val,
Real  v,
int  dir,
int  is_u,
Backend backend 
)
static

Definition at line 616 of file slicer.cc.

Referenced by triangulateRectGen().

617 {
618 
619  if(is_u)
620  {
621  int i,k;
622  REAL* upper_val = (REAL*) malloc(sizeof(REAL) * arc->pwlArc->npts);
623  assert(upper_val);
624  if(dir)
625  {
626  for(k=0,i=arc->pwlArc->npts-1; i>=0; i--,k++)
627  {
628  upper_val[k] = arc->pwlArc->pts[i].param[0];
629  }
630  backend.evalUStrip(arc->pwlArc->npts, arc->pwlArc->pts[0].param[1],
631  upper_val,
632  n_ulines, v, u_val);
633  }
634  else
635  {
636  for(k=0,i=0; i<arc->pwlArc->npts; i++,k++)
637  {
638  upper_val[k] = arc->pwlArc->pts[i].param[0];
639 
640  }
641 
642  backend.evalUStrip(
643  n_ulines, v, u_val,
644  arc->pwlArc->npts, arc->pwlArc->pts[0].param[1], upper_val
645  );
646  }
647 
648  free(upper_val);
649  return;
650  }
651  else //is_v
652  {
653  int i,k;
654  REAL* left_val = (REAL*) malloc(sizeof(REAL) * arc->pwlArc->npts);
655  assert(left_val);
656  if(dir)
657  {
658  for(k=0,i=arc->pwlArc->npts-1; i>=0; i--,k++)
659  {
660  left_val[k] = arc->pwlArc->pts[i].param[1];
661  }
662  backend.evalVStrip(arc->pwlArc->npts, arc->pwlArc->pts[0].param[0],
663  left_val,
664  n_ulines, v, u_val);
665  }
666  else
667  {
668  for(k=0,i=0; i<arc->pwlArc->npts; i++,k++)
669  {
670  left_val[k] = arc->pwlArc->pts[i].param[1];
671  }
672  backend.evalVStrip(
673  n_ulines, v, u_val,
674  arc->pwlArc->npts, arc->pwlArc->pts[0].param[0], left_val
675  );
676  }
677  free(left_val);
678  return;
679  }
680 
681  //the following is a different version of the above code. If you comment
682  //the above code, the following code will still work. The reason to leave
683  //the folliwng code here is purely for testing purpose.
684  /*
685  int i,j;
686  PwlArc* parc = arc->pwlArc;
687  int d1 = parc->npts-1;
688  int d2 = 0;
689  TrimVertex trimVert;
690  trimVert.nuid = 0;//????
691  REAL* temp_u_val = u_val;
692  if(dir ==0) //have to reverse u_val
693  {
694  temp_u_val = (REAL*) malloc(sizeof(REAL) * n_ulines);
695  assert(temp_u_val);
696  for(i=0; i<n_ulines; i++)
697  temp_u_val[i] = u_val[n_ulines-1-i];
698  }
699  u_val = temp_u_val;
700 
701  if(parc->npts > n_ulines)
702  {
703  d1 = n_ulines-1;
704 
705  backend.bgntfan();
706  if(is_u){
707  trimVert.param[0] = u_val[0];
708  trimVert.param[1] = v;
709  }
710  else
711  {
712  trimVert.param[1] = u_val[0];
713  trimVert.param[0] = v;
714  }
715 
716  backend.tmeshvert(& trimVert);
717  for(i=d1; i< parc->npts; i++)
718  backend.tmeshvert(& parc->pts[i]);
719  backend.endtfan();
720 
721 
722  }
723  else if(parc->npts < n_ulines)
724  {
725  d2 = n_ulines-parc->npts;
726 
727 
728  backend.bgntfan();
729  backend.tmeshvert(& parc->pts[parc->npts-1]);
730  for(i=0; i<= d2; i++)
731  {
732  if(is_u){
733  trimVert.param[0] = u_val[i];
734  trimVert.param[1] = v;
735  }
736  else
737  {
738  trimVert.param[1] = u_val[i];
739  trimVert.param[0] = v;
740  }
741  backend.tmeshvert(&trimVert);
742  }
743  backend.endtfan();
744 
745  }
746  if(d1>0){
747 
748 
749  backend.bgnqstrip();
750  for(i=d1, j=d2; i>=0; i--, j++)
751  {
752  backend.tmeshvert(& parc->pts[i]);
753 
754  if(is_u){
755  trimVert.param[0] = u_val[j];
756  trimVert.param[1] = v;
757  }
758  else{
759  trimVert.param[1] = u_val[j];
760  trimVert.param[0] = v;
761  }
762  backend.tmeshvert(&trimVert);
763 
764 
765 
766  }
767  backend.endqstrip();
768 
769 
770  }
771  if(dir == 0) //temp_u_val was mallocated
772  free(temp_u_val);
773  */
774 }
#define free
Definition: debug_ros.c:5
#define assert(x)
Definition: debug.h:53
GLenum GLclampf GLint i
Definition: glfuncs.h:14
PIN_DIRECTION dir
Definition: strmbase.h:226
const GLdouble * v
Definition: gl.h:2040
void evalUStrip(int n_upper, REAL v_upper, REAL *upper_val, int n_lower, REAL v_lower, REAL *lower_val)
Definition: backend.cc:221
void evalVStrip(int n_left, REAL u_left, REAL *left_val, int n_right, REAL v_right, REAL *right_val)
Definition: backend.cc:230
#define malloc
Definition: debug_ros.c:4
float REAL
Definition: types.h:41
int k
Definition: mpi.c:3369