71static Int read_flag(
char*
name);
72Int newtess_flag = read_flag(
"flagFile");
81#define max(a,b) ((a>b)? a:b)
83#define equalRect(a,b) ((glu_abs(a-b) <= ZERO)? 1:0)
88 if(
area(loop->tail(), loop->head(), loop->next->head()) <0 )
90 for(
Arc_ptr jarc = loop->next; jarc != loop; jarc = jarc->next)
92 if(
area(jarc->tail(), jarc->head(), jarc->next->head()) < 0)
102static int is_U_monotone(
Arc_ptr loop)
109 cur_sign =
compV2InX(loop->head(), loop->tail());
111 n_changes = (
compV2InX(loop->prev->head(), loop->prev->tail())
116 prev_sign = cur_sign;
118 if(cur_sign != prev_sign)
121 printf(
"***change signe\n");
126 if(n_changes == 2)
return 1;
136 else if (
a[1] >
b[1])
152 if(
compInY(loop->tail(), loop->prev->tail()) < 0)
186 for(
i=1;
i<=
top->pwlArc->npts-2;
i++)
191 for(jarc=
top->next; jarc != bot; jarc = jarc->next)
193 for(
i=0;
i<=jarc->pwlArc->npts-2;
i++)
200 for(jarc =
top->prev; jarc != bot; jarc = jarc->prev)
202 for(
i=jarc->pwlArc->npts-2;
i>=0;
i--)
207 for(
i=bot->pwlArc->npts-2;
i>=1;
i--)
213 &dec_chain, 0, &backend);
223 for(
Arc_ptr jarc = loop->next; jarc != loop; jarc = jarc->next)
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)
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)
291 evalLineNOGE_BU(verts,
n, backend);
293 evalLineNOGE_BV(verts,
n, backend);
323 if(loop->tail()[1] == loop->head()[1])
325 if(loop->tail()[1] > loop->prev->prev->tail()[1])
332 top = loop->prev->prev;
337 if(loop->tail()[0] > loop->prev->prev->tail()[0])
356 if( (!ulinear) && (!vlinear))
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;
375 else if(TB_or_LR == -1)
379 Int maxPointsTB =
top->pwlArc->npts + bot->pwlArc->npts;
380 Int maxPointsLR =
left->pwlArc->npts +
right->pwlArc->npts;
382 if(maxPointsTB < maxPointsLR)
393 Int d, topd_left, topd_right, botd_left, botd_right,
i,
j;
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);
409 for(
i=1;
i<= bot->
npts-2;
i++){
421 else if(bot->
npts == 2) {
427 for(
i=1;
i<=
top->npts-2;
i++){
497 topd_left =
top->npts-2;
501 botd_right = bot->
npts-2;
506 int delta=bot->
npts -
top->npts;
509 botd_right = bot->
npts-2-( delta-
u);
516 for(
i=1;
i<= botd_left;
i++)
523 if(botd_right < bot->npts-2)
527 for(
i=botd_right;
i<= bot->
npts-2;
i++)
536 topd_left =
top->npts-2 -
u;
537 topd_right = 1+delta-
u;
539 if(topd_left < top->npts-2)
544 for(
i=topd_left;
i<=
top->npts-2;
i++)
555 for(
i=1;
i<= topd_right;
i++)
561 if(topd_left <= topd_right)
565 for(
j=botd_left,
i=topd_left;
i>=topd_right;
i--,
j++)
580 int n_vlines,
REAL* v_val,
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);
626 for(
k=0,
i=arc->pwlArc->npts-1;
i>=0;
i--,
k++)
628 upper_val[
k] = arc->pwlArc->pts[
i].param[0];
630 backend.
evalUStrip(arc->pwlArc->npts, arc->pwlArc->pts[0].param[1],
636 for(
k=0,
i=0;
i<arc->pwlArc->npts;
i++,
k++)
638 upper_val[
k] = arc->pwlArc->pts[
i].param[0];
644 arc->pwlArc->npts, arc->pwlArc->pts[0].param[1], upper_val
658 for(
k=0,
i=arc->pwlArc->npts-1;
i>=0;
i--,
k++)
660 left_val[
k] = arc->pwlArc->pts[
i].param[1];
662 backend.
evalVStrip(arc->pwlArc->npts, arc->pwlArc->pts[0].param[0],
668 for(
k=0,
i=0;
i<arc->pwlArc->npts;
i++,
k++)
670 left_val[
k] = arc->pwlArc->pts[
i].param[1];
674 arc->pwlArc->npts, arc->pwlArc->pts[0].param[0], left_val
785 if(
equalRect(loop->tail()[1] , loop->head()[1]))
788 if(loop->tail()[1] > loop->prev->prev->tail()[1])
795 top = loop->prev->prev;
800 if(loop->tail()[0] > loop->prev->prev->tail()[0])
817#ifdef COUNT_TRIANGLES
818 num_triangles += loop->pwlArc->npts +
822 + 2*n_ulines + 2*n_vlines
824 num_quads += (n_ulines-1)*(n_vlines-1);
838 REAL v_stepsize = (
top->tail()[1] - bot->tail()[1])/( (
REAL) n_vlines+1);
840 for(
i=0;
i<n_ulines;
i++)
845 temp = bot->tail()[1] + v_stepsize;
846 for(
i=0;
i<n_vlines;
i++)
873static Int read_flag(
char*
name)
896 for(
i=0;
i<arc->pwlArc->npts;
i++)
898 vert[0] = arc->pwlArc->pts[
i].param[0];
899 vert[1] = arc->pwlArc->pts[
i].param[1];
911 if(arc->pwlArc->npts == 2 )
913 else if(
area(arc->pwlArc->pts[0].param, arc->pwlArc->pts[1].param, arc->pwlArc->pts[arc->pwlArc->npts-1].param) == 0.0)
927 for(
Int i=0;
i<arc->pwlArc->npts-1;
i++)
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];
1016 Int low =
block->get_lowGridLineIndex();
1017 Int high =
block->get_upGridLineIndex();
1019 for(
k=0,
i=high;
i>low;
i--,
k++)
1033 trimVert -> nuid = 0;
1046 trimVert->
param[0] = vertices[
k];
1047 trimVert->
param[1] = vertices[
k+1];
1080 uMin = uMax = loop->tail()[0];
1085 for(
Arc_ptr jarc=loop->next; jarc != loop; jarc = jarc->next)
1088 if(jarc->tail()[0] < uMin)
1089 uMin = jarc->tail()[0];
1090 if(jarc->tail()[0] > uMax)
1091 uMax = jarc->tail()[0];
1092 if(jarc->tail()[1] <
vMin)
1093 vMin = jarc->tail()[1];
1094 if(jarc->tail()[1] >
vMax)
1095 vMax = jarc->tail()[1];
1101 if(mydu > uMax - uMin)
1105 num_ulines = 3 + (
Int) ((uMax-uMin)/mydu);
1116 if(isRect && (num_ulines<=2 || num_vlines<=2))
1130 else if( (num_ulines<=2 || num_vlines <=2) &&
ulinear)
1134 else if( (!
ulinear) && (!
vlinear) && (num_ulines == 2) && (num_vlines > 2))
1152#ifdef COUNT_TRIANGLES
1159#ifdef COUNT_TRIANGLES
1160 printf(
"num_triangles=%i\n", num_triangles);
1161 printf(
"num_quads = %i\n", num_quads);
1168 if(read_flag(
"flagFile"))
1217 loop->getextrema( extrema );
1219 unsigned int npts = loop->numpts();
1224 long ulines =
uarray.
init(
du, extrema[1], extrema[3] );
1227 long vlines = varray.
init(
dv, extrema[0], extrema[2] );
1232 getGridExtent( &extrema[0]->pwlArc->pts[0], &extrema[0]->pwlArc->pts[0] );
1273 if(
upper.isGridVert() )
1282 if(
lower.isGridVert() )
1296 if( jarc->pwlArc->npts >= 2 ) {
1298 for(
int j = jarc->pwlArc->npts-1;
j >= 0;
j-- )
void linevert(TrimVertex *)
void tmeshvertNOGE_BV(TrimVertex *t)
void evalUStrip(int n_upper, REAL v_upper, REAL *upper_val, int n_lower, REAL v_lower, REAL *lower_val)
void tmeshvert(GridTrimVertex *)
void tmeshvertNOGE_BU(TrimVertex *t)
void surfmesh(long, long, long, long)
void evalVStrip(int n_left, REAL u_left, REAL *left_val, int n_right, REAL v_right, REAL *right_val)
void tmeshvertNOGE(TrimVertex *t)
void preEvaluateBU(REAL u)
void preEvaluateBV(REAL v)
void surfgrid(REAL, REAL, long, REAL, REAL, long)
GridTrimVertex * nextupper(GridTrimVertex *)
GridTrimVertex * nextlower(GridTrimVertex *)
void evalStream(primStream *)
void evalRBArray(rectBlockArray *rbArray, gridWrap *grid)
void setstriptessellation(REAL, REAL)
void advance(REAL, REAL, REAL)
long init(REAL, Arc_ptr, Arc_ptr)
long init(REAL, Arc *, Arc *)
void deleteSinglePolygonWithSline()
rectBlock * get_element(Int i)
void setPoint(Int i, Real p[2])
void appendVertex(Real *ptr)
Int compV2InY(Real A[2], Real B[2])
Int compV2InX(Real A[2], Real B[2])
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
GLAPI void GLAPIENTRY glVertex3fv(const GLfloat *v)
GLAPI void GLAPIENTRY glNormal3fv(const GLfloat *v)
GLdouble GLdouble GLdouble GLdouble top
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
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
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 * u
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 GLint GLint j
_Check_return_ _CRTIMP int __cdecl fscanf(_Inout_ FILE *_File, _In_z_ _Scanf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
void monoTriangulationFunBackend(Arc_ptr loop, Int(*compFun)(Real *, Real *), Backend *backend)
void monoTriangulationRec(Real *topVertex, Real *botVertex, vertexArray *inc_chain, Int inc_current, vertexArray *dec_chain, Int dec_current, Backend *backend)
static Real area(Real A[2], Real B[2], Real C[2])
static void quad(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3, GLuint pv)
void sampleMonoPoly(directedLine *polygon, gridWrap *grid, Int ulinear, Int vlinear, primStream *pStream, rectBlockArray *rbArray)
static void triangulateRectGen(Arc_ptr loop, int n_ulines, int n_vlines, Backend &backend)
static void triangulateRectAux(PwlArc *top, PwlArc *bot, PwlArc *left, PwlArc *right, Backend &backend)
static Int is_rect(Arc_ptr loop)
directedLine * arcToDLine(Arc_ptr arc)
void OPT_OUTVERT(TrimVertex &vv, Backend &backend)
directedLine * arcToMultDLines(directedLine *original, Arc_ptr arc)
directedLine * arcLoopToDLineLoop(Arc_ptr loop)
int compInY(REAL a[2], REAL b[2])
static void triangulateRect(Arc_ptr loop, Backend &backend, int TB_or_LR, int ulinear, int vlinear)
static void triangulateRectTopGen(Arc_ptr arc, int n_ulines, REAL *u_val, Real v, int dir, int is_u, Backend &backend)
void monoTriangulationLoop(Arc_ptr loop, Backend &backend, primStream *pStream)
static void triangulateRectCenter(int n_ulines, REAL *u_val, int n_vlines, REAL *v_val, Backend &backend)
static unsigned int block