ReactOS 0.4.16-dev-336-gb667d82
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

◆ DBG_check()

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 {
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
524 }
525
526 }
527 return 0;
528}
int Int
Definition: definitions.h:37
#define NULL
Definition: types.h:112
#define stderr
Definition: stdio.h:100
_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
Int DBG_checkConnectivity(directedLine *polygon)
Definition: polyDBG.cc:461
Int DBG_enclosingPolygons(directedLine *poly, directedLine *list)
Definition: polyDBG.cc:412
Int DBG_polygonListIntersect(directedLine *pList)
Definition: polyDBG.cc:284
Int DBG_isCounterclockwise(directedLine *poly)
Definition: polyDBG.cc:302
static calc_node_t temp
Definition: rpn_ieee.c:38

◆ DBG_collectSampledLinesAllPoly()

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}
directedLine * getNextPolygon()
Definition: directedLine.h:75
sampledLine * insert(sampledLine *nline)
Definition: sampledLine.cc:53
#define assert(x)
Definition: debug.h:53
void DBG_collectSampledLinesPoly(directedLine *polygon, sampledLine *&retHead, sampledLine *&retTail)
Definition: polyDBG.cc:721

◆ DBG_collectSampledLinesPoly()

void DBG_collectSampledLinesPoly ( directedLine polygon,
sampledLine *&  retHead,
sampledLine *&  retTail 
)

Definition at line 721 of file polyDBG.cc.

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 * getSampledLine()
Definition: directedLine.h:76
directedLine * getNext()
Definition: directedLine.h:74

Referenced by DBG_collectSampledLinesAllPoly().

◆ DBG_cutIntersectionAllPoly()

directedLine * DBG_cutIntersectionAllPoly ( directedLine list)

Definition at line 679 of file polyDBG.cc.

680{
682 directedLine* tempNext=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}
Definition: list.h:37
GLint left
Definition: glext.h:7726
directedLine * DBG_cutIntersectionPoly(directedLine *polygon, int &cutOccur)
Definition: polyDBG.cc:549
int ret

◆ DBG_cutIntersectionPoly()

directedLine * DBG_cutIntersectionPoly ( directedLine polygon,
int cutOccur 
)

Definition at line 549 of file polyDBG.cc.

550{
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 {
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}
ios_base &_STLP_CALL fixed(ios_base &__s)
Definition: _ios_base.h:332
directedLine * getPrev()
Definition: directedLine.h:73
Real * head()
Real * tail()
float Real
Definition: definitions.h:36
const GLdouble * v
Definition: gl.h:2040
GLuint GLuint end
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
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
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
Definition: glfuncs.h:240
Int DBG_edgesIntersect(directedLine *l1, directedLine *l2)
Definition: polyDBG.cc:138
Int DBG_polygonSelfIntersect(directedLine *poly)
Definition: polyDBG.cc:230
static directedLine * DBG_edgeIntersectChainD(directedLine *e, directedLine *begin, directedLine *end)
Definition: polyDBG.cc:532
static unsigned __int64 next
Definition: rand_nt.c:6
static clock_t begin
Definition: xmllint.c:458

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

◆ DBG_edgeIntersectPoly()

Int DBG_edgeIntersectPoly ( directedLine edge,
directedLine poly 
)

Definition at line 257 of file polyDBG.cc.

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}

Referenced by DBG_polygonsIntersect().

◆ DBG_edgesIntersect()

Int DBG_edgesIntersect ( directedLine l1,
directedLine l2 
)

Definition at line 138 of file polyDBG.cc.

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}
static Real area(Real A[2], Real B[2], Real C[2])
Definition: polyDBG.cc:50

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

◆ DBG_edgesIntersectGen()

Int DBG_edgesIntersectGen ( Real  A[2],
Real  B[2],
Real  C[2],
Real  D[2] 
)

Definition at line 198 of file polyDBG.cc.

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 D(d)
Definition: builtin.c:4557
Definition: ehthrow.cxx:93
Definition: ehthrow.cxx:54
Definition: terminate.cpp:24

Referenced by DBG_intersectChain().

◆ DBG_enclosingPolygons()

Int DBG_enclosingPolygons ( directedLine poly,
directedLine list 
)

Definition at line 412 of file polyDBG.cc.

413{
415 Int count=0;
416/*
417printf("%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}
GLuint GLuint GLsizei count
Definition: gl.h:1545
Int DBG_pointInsidePoly(Real v[2], directedLine *poly)
Definition: polyDBG.cc:392

Referenced by DBG_check().

◆ DBG_intersectChain()

Int DBG_intersectChain ( vertexArray chain,
Int  start,
Int  end,
Real  A[2],
Real  B[2] 
)

Definition at line 216 of file polyDBG.cc.

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}
GLuint start
Definition: gl.h:1545
Int DBG_edgesIntersectGen(Real A[2], Real B[2], Real C[2], Real D[2])
Definition: polyDBG.cc:198
struct sock * chain
Definition: tcpcore.h:1

Referenced by findDownCorners(), and findUpCorners().

◆ DBG_is_U_direction()

Int DBG_is_U_direction ( directedLine poly)

Definition at line 98 of file polyDBG.cc.

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}
Int get_npoints()
Definition: directedLine.h:72
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
Definition: fabs.c:17

Referenced by sampleMonoPoly(), and triangulateConvexPoly().

◆ DBG_is_U_monotone()

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}
Int compV2InX(Real A[2], Real B[2])

◆ DBG_isConvex()

Int DBG_isConvex ( directedLine poly)

Definition at line 60 of file polyDBG.cc.

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}

Referenced by sampleMonoPoly().

◆ DBG_isCounterclockwise()

Int DBG_isCounterclockwise ( directedLine poly)

Definition at line 302 of file polyDBG.cc.

303{
304 return (poly->polyArea() > 0);
305}

Referenced by DBG_check().

◆ DBG_pointInsidePoly()

Int DBG_pointInsidePoly ( Real  v[2],
directedLine poly 
)

Definition at line 392 of file polyDBG.cc.

393{
394/*
395printf("enter pointInsidePoly , v=(%f,%f)\n", v[0], v[1]);
396printf("the polygon is\n");
397poly->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}
Int DBG_rayIntersectPoly(Real v0[2], Real dx, Real dy, directedLine *poly)
Definition: polyDBG.cc:378

Referenced by DBG_enclosingPolygons().

◆ DBG_polygonListIntersect()

Int DBG_polygonListIntersect ( directedLine pList)

Definition at line 284 of file polyDBG.cc.

285{
287 for(temp=pList; temp != NULL; temp = temp->getNextPolygon())
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}
FxChildList * pList
Int DBG_polygonsIntersect(directedLine *p1, directedLine *p2)
Definition: polyDBG.cc:270

Referenced by DBG_check().

◆ DBG_polygonSelfIntersect()

Int DBG_polygonSelfIntersect ( directedLine poly)

Definition at line 230 of file polyDBG.cc.

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}

Referenced by DBG_cutIntersectionPoly(), and DBG_polygonListIntersect().

◆ DBG_polygonsIntersect()

Int DBG_polygonsIntersect ( directedLine p1,
directedLine p2 
)

Definition at line 270 of file polyDBG.cc.

271{
273 if(DBG_edgeIntersectPoly(p1, p2))
274 return 1;
275 for(temp=p1->getNext(); temp!= p1; temp = temp->getNext())
277 return 1;
278 return 0;
279}
Int DBG_edgeIntersectPoly(directedLine *edge, directedLine *poly)
Definition: polyDBG.cc:257

Referenced by DBG_polygonListIntersect().

◆ DBG_rayIntersectEdge()

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.

322{
323/*
324if( (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 v1
Definition: glext.h:6062
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97

Referenced by DBG_rayIntersectPoly().

◆ DBG_reverse()

void DBG_reverse ( directedLine poly)

Definition at line 435 of file polyDBG.cc.

436{
437 if(poly->getDirection() == INCREASING)
439 else
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}
void putDirection(short dir)
Definition: directedLine.h:79
void putPrev(directedLine *p)
Definition: directedLine.h:80
void putNext(directedLine *p)
Definition: directedLine.h:81
short getDirection()
Definition: directedLine.h:78
@ INCREASING
Definition: directedLine.h:39
@ DECREASING
Definition: directedLine.h:39
#define printf
Definition: freeldr.h:97

Referenced by DBG_check().