ReactOS  0.4.11-dev-433-g473ca91
polyDBG.h File Reference
Include dependency graph for polyDBG.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

Int DBG_edgesIntersectGen (Real A[2], Real B[2], Real C[2], Real D[2])
 
Int DBG_intersectChain (vertexArray *chain, Int start, Int end, Real A[2], Real B[2])
 
Int DBG_edgesIntersect (directedLine *l1, directedLine *l2)
 
Int DBG_polygonSelfIntersect (directedLine *poly)
 
Int DBG_edgeIntersectPoly (directedLine *edge, directedLine *poly)
 
Int DBG_polygonsIntersect (directedLine *p1, directedLine *p2)
 
Int DBG_polygonListIntersect (directedLine *pList)
 
Int DBG_isCounterclockwise (directedLine *poly)
 
Int DBG_rayIntersectEdge (Real v0[2], Real dx, Real dy, Real v10[2], Real v1[2], Real v2[2])
 
Int DBG_pointInsidePoly (Real v[2], directedLine *poly)
 
Int DBG_enclosingPolygons (directedLine *poly, directedLine *list)
 
void DBG_reverse (directedLine *poly)
 
Int DBG_check (directedLine *polyList)
 
Int DBG_isConvex (directedLine *poly)
 
Int DBG_is_U_direction (directedLine *poly)
 
Int DBG_is_U_monotone (directedLine *poly)
 
directedLineDBG_cutIntersectionAllPoly (directedLine *list)
 
directedLineDBG_cutIntersectionPoly (directedLine *polygon, int &cutOccur)
 
sampledLineDBG_collectSampledLinesAllPoly (directedLine *polygonList)
 
void DBG_collectSampledLinesPoly (directedLine *polygon, sampledLine *&retHead, sampledLine *&retTail)
 

Function Documentation

Int DBG_check ( directedLine polyList)

Definition at line 482 of file polyDBG.cc.

483 {
485  if(polyList == NULL) return 0;
486 
487  /*if there are intersections, print out error message
488  */
489  if(DBG_polygonListIntersect(polyList))
490  {
491  fprintf(stderr, "DBG_check: there are self intersections, don't know to modify the polygons\n");
492  return 1;
493  }
494 
495  /*check the connectivity of each polygon*/
496  for(temp = polyList; temp!= NULL; temp = temp ->getNextPolygon())
497  {
498  if(! DBG_checkConnectivity(temp))
499  {
500  fprintf(stderr, "DBG_check, polygon not connected\n");
501  return 1;
502  }
503  }
504 
505  /*check the orientation of each polygon*/
506  for(temp = polyList; temp!= NULL; temp = temp ->getNextPolygon())
507  {
508 
509 
510  Int correctDir;
511 
512  if( DBG_enclosingPolygons(temp, polyList) % 2 == 0)
513  correctDir = 1; /*counterclockwise*/
514  else
515  correctDir = 0; /*clockwise*/
516 
517  Int actualDir = DBG_isCounterclockwise(temp);
518 
519  if(correctDir != actualDir)
520  {
521  fprintf(stderr, "DBG_check: polygon with incorrect orientations. reversed\n");
522 
523  DBG_reverse(temp);
524  }
525 
526  }
527  return 0;
528 }
Int DBG_checkConnectivity(directedLine *polygon)
Definition: polyDBG.cc:461
Int DBG_polygonListIntersect(directedLine *pList)
Definition: polyDBG.cc:284
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
void DBG_reverse(directedLine *poly)
Definition: polyDBG.cc:435
smooth NULL
Definition: ftsmooth.c:416
Int DBG_enclosingPolygons(directedLine *poly, directedLine *list)
Definition: polyDBG.cc:412
static stack_node_t temp
Definition: rpn.c:18
FILE * stderr
Int DBG_isCounterclockwise(directedLine *poly)
Definition: polyDBG.cc:302
directedLine * getNextPolygon()
Definition: directedLine.h:75
int Int
Definition: definitions.h:37
sampledLine* DBG_collectSampledLinesAllPoly ( directedLine polygonList)

Definition at line 697 of file polyDBG.cc.

698 {
700  sampledLine* tempHead = NULL;
701  sampledLine* tempTail = NULL;
702  sampledLine* cHead = NULL;
703  sampledLine* cTail = NULL;
704 
705  if(polygonList == NULL)
706  return NULL;
707 
708  DBG_collectSampledLinesPoly(polygonList, cHead, cTail);
709 
710  assert(cHead);
711  assert(cTail);
712  for(temp = polygonList->getNextPolygon(); temp != NULL; temp = temp->getNextPolygon())
713  {
714  DBG_collectSampledLinesPoly(temp, tempHead, tempTail);
715  cTail->insert(tempHead);
716  cTail = tempTail;
717  }
718  return cHead;
719 }
#define assert(x)
Definition: debug.h:53
sampledLine * insert(sampledLine *nline)
Definition: sampledLine.cc:53
smooth NULL
Definition: ftsmooth.c:416
static stack_node_t temp
Definition: rpn.c:18
directedLine * getNextPolygon()
Definition: directedLine.h:75
void DBG_collectSampledLinesPoly(directedLine *polygon, sampledLine *&retHead, sampledLine *&retTail)
Definition: polyDBG.cc:721
void DBG_collectSampledLinesPoly ( directedLine polygon,
sampledLine *&  retHead,
sampledLine *&  retTail 
)

Definition at line 721 of file polyDBG.cc.

Referenced by DBG_collectSampledLinesAllPoly().

722 {
724  retHead = NULL;
725  retTail = NULL;
726  if(polygon == NULL)
727  return;
728 
729  retHead = retTail = polygon->getSampledLine();
730  for(temp = polygon->getNext(); temp != polygon; temp=temp->getNext())
731  {
732  retHead = temp->getSampledLine()->insert(retHead);
733  }
734 }
sampledLine * insert(sampledLine *nline)
Definition: sampledLine.cc:53
directedLine * getNext()
Definition: directedLine.h:74
smooth NULL
Definition: ftsmooth.c:416
static stack_node_t temp
Definition: rpn.c:18
sampledLine * getSampledLine()
Definition: directedLine.h:76
directedLine* DBG_cutIntersectionAllPoly ( directedLine list)

Definition at line 679 of file polyDBG.cc.

680 {
682  directedLine* tempNext=NULL;
683  directedLine* ret = NULL;
684  int cutOccur=0;
685  for(temp=list; temp != NULL; temp = tempNext)
686  {
688  tempNext = temp->getNextPolygon();
689 
690  left = DBG_cutIntersectionPoly(temp, cutOccur);
691  if(left != NULL)
692  ret=left->insertPolygon(ret);
693  }
694  return ret;
695 }
directedLine * DBG_cutIntersectionPoly(directedLine *polygon, int &cutOccur)
Definition: polyDBG.cc:549
directedLine * insertPolygon(directedLine *newpolygon)
smooth NULL
Definition: ftsmooth.c:416
GLint left
Definition: glext.h:7726
int ret
static stack_node_t temp
Definition: rpn.c:18
directedLine * getNextPolygon()
Definition: directedLine.h:75
directedLine* DBG_cutIntersectionPoly ( directedLine polygon,
int cutOccur 
)

Definition at line 549 of file polyDBG.cc.

Referenced by directedLine::cutIntersectionAllPoly(), and DBG_cutIntersectionAllPoly().

550 {
551  directedLine *begin, *end, *next;
552  begin = polygon;
553  end = polygon;
554  cutOccur = 0;
555  while( (next = end->getNext()) != begin)
556  {
557  directedLine *interc = NULL;
558  if( (interc = DBG_edgeIntersectChainD(next, begin, end)))
559  {
560  int fixed = 0;
561  if(DBG_edgesIntersect(next, interc->getNext()))
562  {
563  //trying to fix it
564  Real buf[2];
565  int i;
566  Int n=5;
567  buf[0] = interc->tail()[0];
568  buf[1] = interc->tail()[1];
569 
570  for(i=1; i<n; i++)
571  {
572  Real r = ((Real)i) / ((Real) n);
573  Real u = (1-r) * interc->head()[0] + r * interc->tail()[0];
574  Real v = (1-r) * interc->head()[1] + r * interc->tail()[1];
575  interc->tail()[0] = interc->getNext()->head()[0] = u;
576  interc->tail()[1] = interc->getNext()->head()[1] = v;
577  if( (! DBG_edgesIntersect(next, interc)) &&
578  (! DBG_edgesIntersect(next, interc->getNext())))
579  break; //we fixed it
580  }
581  if(i==n) // we didn't fix it
582  {
583  fixed = 0;
584  //back to original
585  interc->tail()[0] = interc->getNext()->head()[0] = buf[0];
586  interc->tail()[1] = interc->getNext()->head()[1] = buf[1];
587  }
588  else
589  {
590  fixed = 1;
591  }
592  }
593  if(fixed == 0)
594  {
595  cutOccur = 1;
596  begin->deleteSingleLine(next);
597 
598  if(begin != end)
599  {
600  if(DBG_polygonSelfIntersect(begin))
601  {
602  directedLine* newEnd = end->getPrev();
603  begin->deleteSingleLine(end);
604  end = newEnd;
605  }
606  }
607  }
608  else
609  {
610  end = end->getNext();
611  }
612  }
613  else
614  {
615  end = end->getNext();
616  }
617  }
618  return begin;
619 }
Real * head()
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
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
Int DBG_edgesIntersect(directedLine *l1, directedLine *l2)
Definition: polyDBG.cc:138
GLuint GLuint end
Definition: gl.h:1545
directedLine * getPrev()
Definition: directedLine.h:73
static directedLine * DBG_edgeIntersectChainD(directedLine *e, directedLine *begin, directedLine *end)
Definition: polyDBG.cc:532
GLuint n
Definition: s_context.h:57
GLenum GLclampf GLint i
Definition: glfuncs.h:14
ios_base &_STLP_CALL fixed(ios_base &__s)
Definition: _ios_base.h:332
directedLine * getNext()
Definition: directedLine.h:74
smooth NULL
Definition: ftsmooth.c:416
Int DBG_polygonSelfIntersect(directedLine *poly)
Definition: polyDBG.cc:230
static clock_t begin
Definition: xmllint.c:466
Real * tail()
static unsigned __int64 next
Definition: rand_nt.c:6
const GLdouble * v
Definition: gl.h:2040
float Real
Definition: definitions.h:36
void deleteSingleLine(directedLine *dline)
Definition: directedLine.cc:88
int Int
Definition: definitions.h:37
Int DBG_edgeIntersectPoly ( directedLine edge,
directedLine poly 
)

Definition at line 257 of file polyDBG.cc.

Referenced by DBG_polygonsIntersect().

258 {
260  if(DBG_edgesIntersect(edge, poly))
261  return 1;
262  for(temp=poly->getNext(); temp != poly; temp=temp->getNext())
263  if(DBG_edgesIntersect(edge, temp))
264  return 1;
265  return 0;
266 }
Int DBG_edgesIntersect(directedLine *l1, directedLine *l2)
Definition: polyDBG.cc:138
directedLine * getNext()
Definition: directedLine.h:74
static stack_node_t temp
Definition: rpn.c:18
Int DBG_edgesIntersect ( directedLine l1,
directedLine l2 
)

Definition at line 138 of file polyDBG.cc.

Referenced by DBG_cutIntersectionPoly(), DBG_edgeIntersectChainD(), DBG_edgeIntersectPoly(), and DBG_polygonSelfIntersect().

139 {
140  if(l1->getNext() == l2)
141  {
142  if(area(l1->head(), l1->tail(), l2->tail()) == 0) //colinear
143  {
144  if( (l1->tail()[0] - l1->head()[0])*(l2->tail()[0]-l2->head()[0]) +
145  (l1->tail()[1] - l1->head()[1])*(l2->tail()[1]-l2->head()[1]) >=0)
146  return 0; //not intersect
147  else
148  return 1;
149  }
150  //else we use the normal code
151  }
152  else if(l1->getPrev() == l2)
153  {
154  if(area(l2->head(), l2->tail(), l1->tail()) == 0) //colinear
155  {
156  if( (l2->tail()[0] - l2->head()[0])*(l1->tail()[0]-l1->head()[0]) +
157  (l2->tail()[1] - l2->head()[1])*(l1->tail()[1]-l1->head()[1]) >=0)
158  return 0; //not intersect
159  else
160  return 1;
161  }
162  //else we use the normal code
163  }
164  else //the two edges are not connected
165  {
166  if((l1->head()[0] == l2->head()[0] &&
167  l1->head()[1] == l2->head()[1]) ||
168  (l1->tail()[0] == l2->tail()[0] &&
169  l1->tail()[1] == l2->tail()[1]))
170  return 1;
171 
172  }
173 
174 
175  if(
176  (
177  area(l1->head(), l1->tail(), l2->head())
178  *
179  area(l1->head(), l1->tail(), l2->tail())
180  < 0
181  )
182  &&
183  (
184  area(l2->head(), l2->tail(), l1->head())
185  *area(l2->head(), l2->tail(), l1->tail())
186  < 0
187  )
188  )
189  return 1;
190  else
191  return 0;
192 }
Real * head()
directedLine * getPrev()
Definition: directedLine.h:73
directedLine * getNext()
Definition: directedLine.h:74
Real * tail()
static Real area(Real A[2], Real B[2], Real C[2])
Definition: polyDBG.cc:50
Int DBG_edgesIntersectGen ( Real  A[2],
Real  B[2],
Real  C[2],
Real  D[2] 
)

Definition at line 198 of file polyDBG.cc.

Referenced by DBG_intersectChain().

199 {
200  if(
201  (
202  area(A, B, C) * area(A,B,D) <0
203  )
204  &&
205  (
206  area(C,D,A) * area(C,D,B) < 0
207  )
208  )
209  return 1;
210  else
211  return 0;
212 }
#define B(row, col)
Definition: m_matrix.c:146
#define D
Definition: mbstring.h:29
Definition: ttei1.cpp:12
Definition: ttei6.cpp:27
static Real area(Real A[2], Real B[2], Real C[2])
Definition: polyDBG.cc:50
Int DBG_enclosingPolygons ( directedLine poly,
directedLine list 
)

Definition at line 412 of file polyDBG.cc.

Referenced by DBG_check().

413 {
415  Int count=0;
416 /*
417 printf("%i\n", DBG_pointInsidePoly(poly->head(),
418  list->getNextPolygon()
419  ->getNextPolygon()
420  ->getNextPolygon()
421  ->getNextPolygon()
422 ));
423 */
424 
425  for(temp = list; temp != NULL; temp = temp->getNextPolygon())
426  {
427  if(poly != temp)
428  if(DBG_pointInsidePoly(poly->head(), temp))
429  count++;
430 /* printf("count=%i\n", count);*/
431  }
432  return count;
433 }
Int DBG_pointInsidePoly(Real v[2], directedLine *poly)
Definition: polyDBG.cc:392
Real * head()
smooth NULL
Definition: ftsmooth.c:416
GLuint GLuint GLsizei count
Definition: gl.h:1545
static stack_node_t temp
Definition: rpn.c:18
directedLine * getNextPolygon()
Definition: directedLine.h:75
int Int
Definition: definitions.h:37
Int DBG_intersectChain ( vertexArray chain,
Int  start,
Int  end,
Real  A[2],
Real  B[2] 
)

Definition at line 216 of file polyDBG.cc.

Referenced by findDownCorners(), and findUpCorners().

217 {
218  Int i;
219  for(i=start; i<=end-2; i++)
220  if(DBG_edgesIntersectGen(chain->getVertex(i), chain->getVertex(i+1), A, B))
221  return 1;
222 
223  return 0;
224 }
#define B(row, col)
Definition: m_matrix.c:146
GLuint GLuint end
Definition: gl.h:1545
GLenum GLclampf GLint i
Definition: glfuncs.h:14
Int DBG_edgesIntersectGen(Real A[2], Real B[2], Real C[2], Real D[2])
Definition: polyDBG.cc:198
#define A(row, col)
Definition: m_matrix.c:145
GLuint start
Definition: gl.h:1545
Real * getVertex(Int i)
int Int
Definition: definitions.h:37
Int DBG_is_U_direction ( directedLine poly)

Definition at line 98 of file polyDBG.cc.

Referenced by sampleMonoPoly(), and triangulateConvexPoly().

99 {
100 /*
101  if(! DBG_is_U_monotone(poly))
102  return 0;
103 */
104  Int V_count = 0;
105  Int U_count = 0;
107  if( fabs(poly->head()[0] - poly->tail()[0]) <= fabs(poly->head()[1]-poly->tail()[1]))
108  V_count += poly->get_npoints();
109  else
110  U_count += poly->get_npoints();
111  /*
112  else if(poly->head()[1] == poly->tail()[1])
113  U_count += poly->get_npoints();
114  */
115  for(temp = poly->getNext(); temp != poly; temp = temp->getNext())
116  {
117  if( fabs(temp->head()[0] - temp->tail()[0]) <= fabs(temp->head()[1]-temp->tail()[1]))
118  V_count += temp->get_npoints();
119  else
120  U_count += temp->get_npoints();
121  /*
122  if(temp->head()[0] == temp->tail()[0])
123  V_count += temp->get_npoints();
124  else if(temp->head()[1] == temp->tail()[1])
125  U_count += temp->get_npoints();
126  */
127  }
128 
129  if(U_count > V_count) return 1;
130  else return 0;
131 }
Real * head()
directedLine * getNext()
Definition: directedLine.h:74
static stack_node_t temp
Definition: rpn.c:18
Real * tail()
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
Int get_npoints()
Definition: directedLine.h:72
int Int
Definition: definitions.h:37
Int DBG_is_U_monotone ( directedLine poly)

Definition at line 73 of file polyDBG.cc.

74 {
75  Int n_changes = 0;
76  Int prev_sign;
77  Int cur_sign;
79  cur_sign = compV2InX(poly->tail(), poly->head());
80 
81  n_changes = (compV2InX(poly->getPrev()->tail(), poly->getPrev()->head())
82  != cur_sign);
83 
84  for(temp = poly->getNext(); temp != poly; temp = temp->getNext())
85  {
86  prev_sign = cur_sign;
87  cur_sign = compV2InX(temp->tail(), temp->head());
88 
89  if(cur_sign != prev_sign)
90  n_changes++;
91  }
92 
93  if(n_changes ==2) return 1;
94  else return 0;
95 }
Real * head()
directedLine * getPrev()
Definition: directedLine.h:73
directedLine * getNext()
Definition: directedLine.h:74
Int compV2InX(Real A[2], Real B[2])
static stack_node_t temp
Definition: rpn.c:18
Real * tail()
int Int
Definition: definitions.h:37
Int DBG_isConvex ( directedLine poly)

Definition at line 60 of file polyDBG.cc.

Referenced by sampleMonoPoly().

61 {
63  if(area(poly->head(), poly->tail(), poly->getNext()->tail()) < 0.00000)
64  return 0;
65  for(temp = poly->getNext(); temp != poly; temp = temp->getNext())
66  {
67  if(area(temp->head(), temp->tail(), temp->getNext()->tail()) < 0.00000)
68  return 0;
69  }
70  return 1;
71 }
Real * head()
directedLine * getNext()
Definition: directedLine.h:74
static stack_node_t temp
Definition: rpn.c:18
Real * tail()
static Real area(Real A[2], Real B[2], Real C[2])
Definition: polyDBG.cc:50
Int DBG_isCounterclockwise ( directedLine poly)

Definition at line 302 of file polyDBG.cc.

Referenced by DBG_check().

303 {
304  return (poly->polyArea() > 0);
305 }
Int DBG_pointInsidePoly ( Real  v[2],
directedLine poly 
)

Definition at line 392 of file polyDBG.cc.

Referenced by DBG_enclosingPolygons().

393 {
394 /*
395 printf("enter pointInsidePoly , v=(%f,%f)\n", v[0], v[1]);
396 printf("the polygon is\n");
397 poly->printList();
398 */
399  /*for debug purpose*/
400  assert( (DBG_rayIntersectPoly(v,1,0,poly) % 2 )
401  == (DBG_rayIntersectPoly(v,1,Real(0.1234), poly) % 2 )
402  );
403  if(DBG_rayIntersectPoly(v, 1, 0, poly) % 2 == 1)
404  return 1;
405  else
406  return 0;
407 }
#define assert(x)
Definition: debug.h:53
const GLdouble * v
Definition: gl.h:2040
Int DBG_rayIntersectPoly(Real v0[2], Real dx, Real dy, directedLine *poly)
Definition: polyDBG.cc:378
float Real
Definition: definitions.h:36
Int DBG_polygonListIntersect ( directedLine pList)

Definition at line 284 of file polyDBG.cc.

Referenced by DBG_check().

285 {
287  for(temp=pList; temp != NULL; temp = temp->getNextPolygon())
288  if(DBG_polygonSelfIntersect(temp))
289  return 1;
290  directedLine* temp2;
291  for(temp=pList; temp!=NULL; temp=temp->getNextPolygon())
292  {
293  for(temp2=temp->getNextPolygon(); temp2 != NULL; temp2=temp2->getNextPolygon())
294  if(DBG_polygonsIntersect(temp, temp2))
295  return 1;
296  }
297 
298  return 0;
299 }
smooth NULL
Definition: ftsmooth.c:416
Int DBG_polygonSelfIntersect(directedLine *poly)
Definition: polyDBG.cc:230
static stack_node_t temp
Definition: rpn.c:18
Int DBG_polygonsIntersect(directedLine *p1, directedLine *p2)
Definition: polyDBG.cc:270
directedLine * getNextPolygon()
Definition: directedLine.h:75
Int DBG_polygonSelfIntersect ( directedLine poly)

Definition at line 230 of file polyDBG.cc.

Referenced by DBG_cutIntersectionPoly(), and DBG_polygonListIntersect().

231 {
232  directedLine* temp1;
233  directedLine* temp2;
234  temp1=poly;
235  for(temp2=temp1->getNext(); temp2 != temp1; temp2=temp2->getNext())
236  {
237  if(DBG_edgesIntersect(temp1, temp2))
238  {
239  return 1;
240  }
241 
242  }
243 
244  for(temp1=poly->getNext(); temp1 != poly; temp1 = temp1->getNext())
245  for(temp2=temp1->getNext(); temp2 != temp1; temp2=temp2->getNext())
246  {
247  if(DBG_edgesIntersect(temp1, temp2))
248  {
249  return 1;
250  }
251  }
252  return 0;
253 }
Int DBG_edgesIntersect(directedLine *l1, directedLine *l2)
Definition: polyDBG.cc:138
directedLine * getNext()
Definition: directedLine.h:74
Int DBG_polygonsIntersect ( directedLine p1,
directedLine p2 
)

Definition at line 270 of file polyDBG.cc.

Referenced by DBG_polygonListIntersect().

271 {
273  if(DBG_edgeIntersectPoly(p1, p2))
274  return 1;
275  for(temp=p1->getNext(); temp!= p1; temp = temp->getNext())
276  if(DBG_edgeIntersectPoly(temp, p2))
277  return 1;
278  return 0;
279 }
directedLine * getNext()
Definition: directedLine.h:74
Int DBG_edgeIntersectPoly(directedLine *edge, directedLine *poly)
Definition: polyDBG.cc:257
static stack_node_t temp
Definition: rpn.c:18
const GLfloat * p1
Definition: s_aatritemp.h:43
Int DBG_rayIntersectEdge ( Real  v0[2],
Real  dx,
Real  dy,
Real  v10[2],
Real  v1[2],
Real  v2[2] 
)

Definition at line 321 of file polyDBG.cc.

Referenced by DBG_rayIntersectPoly().

322 {
323 /*
324 if( (v1[1] >= v0[1] && v2[1]<= v0[1] )
325  ||(v2[1] >= v0[1] && v1[1]<= v0[1] )
326  )
327  printf("rayIntersectEdge, *********\n");
328 */
329 
330  Real denom = (v2[0]-v1[0])*(-dy) - (v2[1]-v1[1]) * (-dx);
331  Real nomRay = (v2[0]-v1[0]) * (v0[1] - v1[1]) - (v2[1]-v1[1])*(v0[0]-v1[0]);
332  Real nomEdge = (v0[0]-v1[0]) * (-dy) - (v0[1]-v1[1])*(-dx);
333 
334 
335  /*if the ray is parallel to the edge, return 0: not intersect*/
336  if(denom == 0.0)
337  return 0;
338 
339  /*if v0 is on the edge, return 0: not intersect*/
340  if(nomRay == 0.0)
341  return 0;
342 
343  /*if v1 is on the positive ray, and the neighbor of v1 crosses the ray
344  *return 1: intersect
345  */
346  if(nomEdge == 0)
347  { /*v1 is on the positive or negative ray*/
348 
349 /*
350  printf("v1 is on the ray\n");
351 */
352 
353  if(dx*(v1[0]-v0[0])>=0 && dy*(v1[1]-v0[1])>=0) /*v1 on positive ray*/
354  {
355  if(area(v0, v1, v10) * area(v0, v1, v2) >0)
356  return 0;
357  else
358  return 1;
359  }
360  else /*v1 on negative ray*/
361  return 0;
362  }
363 
364  /*if v2 is on the ray, always return 0: not intersect*/
365  if(nomEdge == denom) {
366 /* printf("v2 is on the ray\n");*/
367  return 0;
368  }
369 
370  /*finally */
371  if(denom*nomRay>0 && denom*nomEdge>0 && nomEdge/denom <=1.0)
372  return 1;
373  return 0;
374 }
GLfloat v0
Definition: glext.h:6061
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
INT INT dy
Definition: msvc.h:65
static Real area(Real A[2], Real B[2], Real C[2])
Definition: polyDBG.cc:50
float Real
Definition: definitions.h:36
GLfloat GLfloat v1
Definition: glext.h:6062
INT dx
Definition: msvc.h:65
void DBG_reverse ( directedLine poly)

Definition at line 435 of file polyDBG.cc.

Referenced by DBG_check().

436 {
437  if(poly->getDirection() == INCREASING)
438  poly->putDirection(DECREASING);
439  else
440  poly->putDirection(INCREASING);
441 
442  directedLine* oldNext = poly->getNext();
443  poly->putNext(poly->getPrev());
444  poly->putPrev(oldNext);
445 
447  for(temp=oldNext; temp!=poly; temp = oldNext)
448  {
449  if(temp->getDirection() == INCREASING)
450  temp->putDirection(DECREASING);
451  else
452  temp->putDirection(INCREASING);
453 
454  oldNext = temp->getNext();
455  temp->putNext(temp->getPrev());
456  temp->putPrev(oldNext);
457  }
458  printf("reverse done\n");
459 }
directedLine * getPrev()
Definition: directedLine.h:73
short getDirection()
Definition: directedLine.h:78
directedLine * getNext()
Definition: directedLine.h:74
void putDirection(short dir)
Definition: directedLine.h:79
static stack_node_t temp
Definition: rpn.c:18
void putNext(directedLine *p)
Definition: directedLine.h:81
#define printf
Definition: config.h:203
void putPrev(directedLine *p)
Definition: directedLine.h:80