ReactOS 0.4.15-dev-5666-gc548b97
directedLine Class Reference

#include <directedLine.h>

Collaboration diagram for directedLine:

Public Member Functions

 directedLine (short dir, sampledLine *sl)
 
 directedLine ()
 
 ~directedLine ()
 
void init (short dir, sampledLine *sl)
 
Realhead ()
 
Realtail ()
 
RealgetVertex (Int i)
 
Int get_npoints ()
 
directedLinegetPrev ()
 
directedLinegetNext ()
 
directedLinegetNextPolygon ()
 
sampledLinegetSampledLine ()
 
short getDirection ()
 
void putDirection (short dir)
 
void putPrev (directedLine *p)
 
void putNext (directedLine *p)
 
void insert (directedLine *nl)
 
void deletePolygonList ()
 
void deleteSinglePolygon ()
 
void deleteSinglePolygonWithSline ()
 
void deletePolygonListWithSline ()
 
void deleteSingleLine (directedLine *dline)
 
directedLinedeleteDegenerateLines ()
 
directedLinedeleteDegenerateLinesAllPolygons ()
 
directedLinecutIntersectionAllPoly (int &cutOccur)
 
short isPolygon ()
 
Int compInY (directedLine *nl)
 
Int compInX (directedLine *nl)
 
directedLine ** sortAllPolygons ()
 
Int numEdges ()
 
Int numEdgesAllPolygons ()
 
Int numPolygons ()
 
short isConnected ()
 
Real polyArea ()
 
void printSingle ()
 
void printList ()
 
void printAllPolygons ()
 
void writeAllPolygons (char *filename)
 
directedLineinsertPolygon (directedLine *newpolygon)
 
directedLinecutoffPolygon (directedLine *p)
 
Int toArraySinglePolygon (directedLine **array, Int index)
 
directedLine ** toArrayAllPolygons (Int &total_num_edges)
 
void connectDiagonal (directedLine *v1, directedLine *v2, directedLine **ret_p1, directedLine **ret_p2, sampledLine **generatedLine, directedLine *list)
 
void connectDiagonal_2slines (directedLine *v1, directedLine *v2, directedLine **ret_p1, directedLine **ret_p2, directedLine *list)
 
Int samePolygon (directedLine *v1, directedLine *v2)
 
void setRootBit ()
 
void resetRootBit ()
 
directedLinefindRoot ()
 
void rootLinkSet (directedLine *r)
 
directedLinerootLinkFindRoot ()
 
directedLinedeleteChain (directedLine *begin, directedLine *end)
 

Private Attributes

short direction
 
sampledLinesline
 
directedLinenext
 
directedLineprev
 
directedLinenextPolygon
 
Int rootBit
 
directedLinerootLink
 

Detailed Description

Definition at line 41 of file directedLine.h.

Constructor & Destructor Documentation

◆ directedLine() [1/2]

directedLine::directedLine ( short  dir,
sampledLine sl 
)

Definition at line 285 of file directedLine.cc.

286{
287 direction = dir;
288 sline = sl;
289 next = this;
290 prev = this;
292// prevPolygon = NULL;
293 rootBit = 0;/*important to initilzae to 0 meaning not root yet*/
294
295 rootLink = NULL;
296
297}
unsigned int dir
Definition: maze.c:112
short direction
Definition: directedLine.h:42
directedLine * prev
Definition: directedLine.h:45
sampledLine * sline
Definition: directedLine.h:43
directedLine * nextPolygon
Definition: directedLine.h:50
directedLine * next
Definition: directedLine.h:44
directedLine * rootLink
Definition: directedLine.h:58
#define NULL
Definition: types.h:112

◆ directedLine() [2/2]

directedLine::directedLine ( )

Definition at line 305 of file directedLine.cc.

306{
307 next = this;
308 prev = this;
310 rootBit = 0;/*important to initilzae to 0 meaning not root yet*/
311 rootLink = NULL;
313 sline = NULL;
314}
@ INCREASING
Definition: directedLine.h:39

Referenced by connectDiagonal(), connectDiagonal_2slines(), and deleteChain().

◆ ~directedLine()

directedLine::~directedLine ( )

Definition at line 316 of file directedLine.cc.

317{
318}

Member Function Documentation

◆ compInX()

Int directedLine::compInX ( directedLine nl)

Definition at line 438 of file directedLine.cc.

439{
440 if(head()[0] < nl->head()[0]) return -1;
441 if(head()[0] == nl->head()[0] && head()[1] < nl->head()[1]) return -1;
442 return 1;
443}
Real * head()

◆ compInY()

Int directedLine::compInY ( directedLine nl)

Definition at line 423 of file directedLine.cc.

424{
425 if(head()[1] < nl->head()[1]) return -1;
426 if(head()[1] == nl->head()[1] && head()[0] < nl->head()[0]) return -1;
427 return 1;
428}

Referenced by monoChain::monoChain().

◆ connectDiagonal()

void directedLine::connectDiagonal ( directedLine v1,
directedLine v2,
directedLine **  ret_p1,
directedLine **  ret_p2,
sampledLine **  generatedLine,
directedLine list 
)

Definition at line 632 of file directedLine.cc.

637{
638 sampledLine *nsline = new sampledLine(2);
639
640
641
642 nsline->setPoint(0, v1->head());
643 nsline->setPoint(1, v2->head());
644
645
646
647 /*the increasing line is from v1 head to v2 head*/
648 directedLine* newLineInc = new directedLine(INCREASING, nsline);
649
650
651
652 directedLine* newLineDec = new directedLine(DECREASING, nsline);
653
654
655 directedLine* v1Prev = v1->prev;
656 directedLine* v2Prev = v2->prev;
657
658 v1 ->prev = newLineDec;
659 v2Prev ->next = newLineDec;
660 newLineDec->next = v1;
661 newLineDec->prev = v2Prev;
662
663 v2 ->prev = newLineInc;
664 v1Prev ->next = newLineInc;
665 newLineInc->next = v2;
666 newLineInc->prev = v1Prev;
667
668 *ret_p1 = newLineDec;
669 *ret_p2 = newLineInc;
670 *generatedLine = nsline;
671}
void setPoint(Int i, Real p[2])
Definition: sampledLine.cc:45
@ DECREASING
Definition: directedLine.h:39
GLfloat GLfloat v1
Definition: glext.h:6062
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063

◆ connectDiagonal_2slines()

void directedLine::connectDiagonal_2slines ( directedLine v1,
directedLine v2,
directedLine **  ret_p1,
directedLine **  ret_p2,
directedLine list 
)

Definition at line 675 of file directedLine.cc.

679{
680 sampledLine *nsline = new sampledLine(2);
681 sampledLine *nsline2 = new sampledLine(2);
682
683 nsline->setPoint(0, v1->head());
684 nsline->setPoint(1, v2->head());
685 nsline2->setPoint(0, v1->head());
686 nsline2->setPoint(1, v2->head());
687
688 /*the increasing line is from v1 head to v2 head*/
689 directedLine* newLineInc = new directedLine(INCREASING, nsline);
690
691 directedLine* newLineDec = new directedLine(DECREASING, nsline2);
692
693 directedLine* v1Prev = v1->prev;
694 directedLine* v2Prev = v2->prev;
695
696 v1 ->prev = newLineDec;
697 v2Prev ->next = newLineDec;
698 newLineDec->next = v1;
699 newLineDec->prev = v2Prev;
700
701 v2 ->prev = newLineInc;
702 v1Prev ->next = newLineInc;
703 newLineInc->next = v2;
704 newLineInc->prev = v1Prev;
705
706 *ret_p1 = newLineDec;
707 *ret_p2 = newLineInc;
708
709}

Referenced by monoPolyPart(), monoTriangulationOpt(), monoTriangulationRecGenOpt(), and sampleMonoPoly().

◆ cutIntersectionAllPoly()

directedLine * directedLine::cutIntersectionAllPoly ( int cutOccur)

Definition at line 208 of file directedLine.cc.

209{
211 directedLine *tempNext = NULL;
213 directedLine* retEnd = NULL;
214 cutOccur = 0;
215 for(temp=this; temp != NULL; temp = tempNext)
216 {
217 int eachCutOccur=0;
218 tempNext = temp->nextPolygon;
219 temp->nextPolygon = NULL;
220 if(ret == NULL)
221 {
222
223 ret = retEnd = DBG_cutIntersectionPoly(temp, eachCutOccur);
224 if(eachCutOccur)
225 cutOccur = 1;
226 }
227 else
228 {
229
230 retEnd->nextPolygon = DBG_cutIntersectionPoly(temp, eachCutOccur);
231 retEnd = retEnd->nextPolygon;
232 if(eachCutOccur)
233 cutOccur = 1;
234 }
235 }
236 return ret;
237}
directedLine * DBG_cutIntersectionPoly(directedLine *polygon, int &cutOccur)
Definition: polyDBG.cc:549
static calc_node_t temp
Definition: rpn_ieee.c:38
int ret

◆ cutoffPolygon()

directedLine * directedLine::cutoffPolygon ( directedLine p)

Definition at line 514 of file directedLine.cc.

515{
517 directedLine* prev_polygon = NULL;
518 if(p == NULL) return this;
519
520 for(temp=this; temp != p; temp = temp->nextPolygon)
521 {
522 if(temp == NULL)
523 {
524 fprintf(stderr, "in cutoffPolygon, not found\n");
525 exit(1);
526 }
527 prev_polygon = temp;
528 }
529
530/* prev_polygon = p->prevPolygon;*/
531
532 p->resetRootBit();
533 if(prev_polygon == NULL) /*this is the one to cutoff*/
534 return nextPolygon;
535 else {
536 prev_polygon->nextPolygon = p->nextPolygon;
537 return this;
538 }
539}
GLfloat GLfloat p
Definition: glext.h:8902
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define exit(n)
Definition: config.h:202

Referenced by MC_partitionY(), and partitionY().

◆ deleteChain()

directedLine * directedLine::deleteChain ( directedLine begin,
directedLine end 
)

Definition at line 53 of file directedLine.cc.

54{
55 if(begin->head()[0] == end->tail()[0] &&
56 begin->head()[1] == end->tail()[1]
57 )
58 {
59 directedLine *ret = begin->prev;
60 begin->prev->next = end->next;
61 end->next->prev = begin->prev;
62 delete begin->sline;
63 delete end->sline;
64 delete begin;
65 delete end;
66
67 return ret;
68 }
69
70 directedLine* newLine;
71 sampledLine* sline = new sampledLine(begin->head(), end->tail());
72 newLine = new directedLine(INCREASING, sline);
73 directedLine *p = begin->prev;
75 p->next = newLine;
76 n->prev = newLine;
77 newLine->prev = p;
78 newLine->next = n;
79
80 delete begin->sline;
81 delete end->sline;
82 delete begin;
83 delete end;
84 return newLine;
85}
GLuint GLuint end
Definition: gl.h:1545
GLdouble n
Definition: glext.h:7729
static clock_t begin
Definition: xmllint.c:458

◆ deleteDegenerateLines()

directedLine * directedLine::deleteDegenerateLines ( )

Definition at line 124 of file directedLine.cc.

125{
126 //if there is only one edge or two edges, don't do anything
127 if(this->next == this)
128 return this;
129 if(this->next == this->prev)
130 return this;
131
132 //find a nondegenerate line
135 if(! myequal(head(), tail()))
136 /*
137 if(head()[0] != tail()[0] ||
138 head()[1] != tail()[1])
139 */
140 first = this;
141 else
142 {
143 for(temp = this->next; temp != this; temp = temp->next)
144 {
145 /*
146 if(temp->head()[0] != temp->tail()[0] ||
147 temp->head()[1] != temp->tail()[1])
148 */
149 if(! myequal(temp->head(), temp->tail()))
150 {
151 first = temp;
152 break;
153 }
154
155 }
156 }
157
158 //if there are no non-degenerate lines, then we simply return NULL.
159 if(first == NULL)
160 {
162 return NULL;
163 }
164
165 directedLine* tempNext = NULL;
166 for(temp =first->next; temp != first; temp = tempNext)
167 {
168 tempNext = temp->getNext();
169/*
170 if(temp->head()[0] == temp->tail()[0] &&
171 temp->head()[1] == temp->tail()[1])
172*/
173
174 if(myequal(temp->head(), temp->tail()))
176 }
177 return first;
178}
void deleteSingleLine(directedLine *dline)
Definition: directedLine.cc:88
void deleteSinglePolygonWithSline()
Real * tail()
static Int myequal(Real a[2], Real b[2])
const GLint * first
Definition: glext.h:5794

◆ deleteDegenerateLinesAllPolygons()

directedLine * directedLine::deleteDegenerateLinesAllPolygons ( )

Definition at line 180 of file directedLine.cc.

181{
183 directedLine *tempNext = NULL;
185 directedLine* retEnd = NULL;
186 for(temp=this; temp != NULL; temp = tempNext)
187 {
188 tempNext = temp->nextPolygon;
189 temp->nextPolygon = NULL;
190 if(ret == NULL)
191 {
192 ret = retEnd = temp->deleteDegenerateLines();
193
194 }
195 else
196 {
197 directedLine *newPolygon = temp->deleteDegenerateLines();
198 if(newPolygon != NULL)
199 {
200 retEnd->nextPolygon = temp->deleteDegenerateLines();
201 retEnd = retEnd->nextPolygon;
202 }
203 }
204 }
205 return ret;
206}

Referenced by Subdivider::drawSurfaces().

◆ deletePolygonList()

void directedLine::deletePolygonList ( )

Definition at line 273 of file directedLine.cc.

274{
275 directedLine *temp, *tempNext;
276 for(temp=this; temp != NULL; temp=tempNext)
277 {
278 tempNext = temp->nextPolygon;
279 temp->deleteSinglePolygon();
280 }
281}

◆ deletePolygonListWithSline()

void directedLine::deletePolygonListWithSline ( )

Definition at line 252 of file directedLine.cc.

253{
254 directedLine *temp, *tempNext;
255 for(temp=this; temp != NULL; temp=tempNext)
256 {
257 tempNext = temp->nextPolygon;
258 temp->deleteSinglePolygonWithSline();
259 }
260}

◆ deleteSingleLine()

void directedLine::deleteSingleLine ( directedLine dline)

Definition at line 88 of file directedLine.cc.

89{
90 //make sure that dline->prev->tail is the same as
91 //dline->next->head. This is for numerical erros.
92 //for example, if we delete a line which is almost degeneate
93 //within (epsilon), then we want to make that the polygon after deletion
94 //is still a valid polygon
95
96 dline->next->head()[0] = dline->prev->tail()[0];
97 dline->next->head()[1] = dline->prev->tail()[1];
98
99 dline->prev->next = dline->next;
100 dline->next->prev = dline->prev;
101
102 delete dline;
103
104}

Referenced by deleteDegenerateLines().

◆ deleteSinglePolygon()

void directedLine::deleteSinglePolygon ( )

Definition at line 262 of file directedLine.cc.

263{
264 directedLine *temp, *tempNext;
265 prev->next = NULL;
266 for(temp=this; temp != NULL; temp = tempNext)
267 {
268 tempNext = temp->next;
269 delete temp;
270 }
271}

◆ deleteSinglePolygonWithSline()

void directedLine::deleteSinglePolygonWithSline ( )

Definition at line 240 of file directedLine.cc.

241{
242 directedLine *temp, *tempNext;
243 prev->next = NULL;
244 for(temp=this; temp != NULL; temp = tempNext)
245 {
246 tempNext = temp->next;
247 delete temp->sline;
248 delete temp;
249 }
250}

Referenced by deleteDegenerateLines(), monoTriangulationOpt(), monoTriangulationRecGenOpt(), sampleLeftOneGridStep(), sampleMonoPoly(), sampleRightOneGridStep(), and Slicer::slice_new().

◆ findRoot()

directedLine * directedLine::findRoot ( )

Definition at line 722 of file directedLine.cc.

723{
724 if(rootBit) return this;
726 for(temp = next; temp != this; temp = temp->next)
727 if(temp -> rootBit ) return temp;
728 return NULL; /*should not happen*/
729}

Referenced by MC_partitionY(), and partitionY().

◆ get_npoints()

◆ getDirection()

short directedLine::getDirection ( )
inline

Definition at line 78 of file directedLine.h.

78{return direction;}

Referenced by DBG_reverse().

◆ getNext()

◆ getNextPolygon()

directedLine * directedLine::getNextPolygon ( )
inline

Definition at line 75 of file directedLine.h.

75{return nextPolygon;}

Referenced by DBG_collectSampledLinesAllPoly(), and DBG_polygonListIntersect().

◆ getPrev()

◆ getSampledLine()

sampledLine * directedLine::getSampledLine ( )
inline

Definition at line 76 of file directedLine.h.

76{return sline;}

Referenced by DBG_collectSampledLinesPoly().

◆ getVertex()

Real * directedLine::getVertex ( Int  i)

Definition at line 326 of file directedLine.cc.

327{
328 return (direction==INCREASING)? (sline->get_points())[i] : (sline->get_points())[sline->get_npoints() - 1 -i];
329}
Real2 * get_points()
Definition: sampledLine.h:57
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

Referenced by monoTriangulation(), monoTriangulationFun(), monoTriangulationRec(), polygonConvert(), sampleMonoPoly(), toVertexArrays(), triangulateConvexPolyHoriz(), and triangulateConvexPolyVertical().

◆ head()

◆ init()

void directedLine::init ( short  dir,
sampledLine sl 
)

Definition at line 299 of file directedLine.cc.

300{
301 direction = dir;
302 sline = sl;
303}

◆ insert()

void directedLine::insert ( directedLine nl)

Definition at line 337 of file directedLine.cc.

338{
339 nl->next = this;
340 nl->prev = prev;
341 prev->next = nl;
342 prev = nl;
343 nl->rootLink = this; /*assuming that 'this' is the root!!!*/
344}

Referenced by monoTriangulationRecGenOpt(), readAllPolygons(), sampleLeftOneGridStep(), and sampleRightOneGridStep().

◆ insertPolygon()

directedLine * directedLine::insertPolygon ( directedLine newpolygon)

Definition at line 501 of file directedLine.cc.

502{
503 /*this polygon is a root*/
504 setRootBit();
505 if(oldList == NULL) return this;
506 nextPolygon = oldList;
507/* oldList->prevPolygon = this;*/
508 return this;
509}
void setRootBit()
Definition: directedLine.h:151

Referenced by MC_partitionY(), monoPolyPart(), partitionY(), and readAllPolygons().

◆ isConnected()

short directedLine::isConnected ( )

Definition at line 391 of file directedLine.cc.

392{
393 if( (head()[0] == prev->tail()[0]) && (head()[1] == prev->tail()[1]))
394 return 1;
395 else
396 return 0;
397}

Referenced by isPolygon().

◆ isPolygon()

short directedLine::isPolygon ( )

Definition at line 371 of file directedLine.cc.

372{
374
375 /*a polygon contains at least 3 edges*/
376 if(numEdges() <=2) return 0;
377
378 /*check this edge*/
379 if(! isConnected()) return 0;
380
381 /*check all other edges*/
382 for(temp=next; temp != this; temp = temp->next){
383 if(!isConnected()) return 0;
384 }
385 return 1;
386}
short isConnected()

◆ numEdges()

Int directedLine::numEdges ( )

Definition at line 346 of file directedLine.cc.

347{
348 Int ret=0;
350 if(next == this) return 1;
351
352 ret = 1;
353 for(temp = next; temp != this; temp = temp->next)
354 ret++;
355 return ret;
356}
int Int
Definition: definitions.h:37

Referenced by isPolygon(), monoTriangulationOpt(), monoTriangulationRecGenOpt(), and sampleMonoPoly().

◆ numEdgesAllPolygons()

Int directedLine::numEdgesAllPolygons ( )

Definition at line 358 of file directedLine.cc.

359{
360 Int ret=0;
362 for(temp=this; temp!= NULL; temp=temp->nextPolygon)
363 {
364 ret += temp->numEdges();
365 }
366 return ret;
367}

Referenced by toArrayAllPolygons().

◆ numPolygons()

Int directedLine::numPolygons ( )

Definition at line 541 of file directedLine.cc.

542{
543 if(nextPolygon == NULL) return 1;
544 else return 1+nextPolygon->numPolygons();
545}

Referenced by numPolygons(), and writeAllPolygons().

◆ polyArea()

Real directedLine::polyArea ( )

Definition at line 585 of file directedLine.cc.

586{
588 Real ret=0.0;
589 Real x1,y1,x2,y2;
590 x1 = this->head()[0];
591 y1 = this->head()[1];
592 x2 = this->next->head()[0];
593 y2 = this->next->head()[1];
594 ret = -(x2*y1-x1*y2);
595 for(temp=this->next; temp!=this; temp = temp->next)
596 {
597 x1 = temp->head()[0];
598 y1 = temp->head()[1];
599 x2 = temp->next->head()[0];
600 y2 = temp->next->head()[1];
601 ret += -( x2*y1-x1*y2);
602 }
603 return Real(0.5)*ret;
604}
float Real
Definition: definitions.h:36
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3710
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG y1
Definition: winddi.h:3709
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3708
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG _In_ LONG y2
Definition: winddi.h:3711

Referenced by DBG_isCounterclockwise().

◆ printAllPolygons()

void directedLine::printAllPolygons ( )

Definition at line 490 of file directedLine.cc.

491{
493 for(temp = this; temp!=NULL; temp = temp->nextPolygon)
494 {
495 printf("polygon:\n");
496 temp->printList();
497 }
498}
#define printf
Definition: freeldr.h:94

◆ printList()

void directedLine::printList ( )

Definition at line 481 of file directedLine.cc.

482{
484 printSingle();
485 for(temp = next; temp!=this; temp=temp->next)
486 temp->printSingle();
487}
void printSingle()

◆ printSingle()

void directedLine::printSingle ( )

Definition at line 470 of file directedLine.cc.

471{
472 if(direction == INCREASING)
473 printf("direction is INCREASING\n");
474 else
475 printf("direction is DECREASING\n");
476 printf("head=%f,%f)\n", head()[0], head()[1]);
477 sline->print();
478}
void print()
Definition: sampledLine.cc:129

Referenced by printList(), and sweepY().

◆ putDirection()

void directedLine::putDirection ( short  dir)
inline

Definition at line 79 of file directedLine.h.

79{direction = dir;}

Referenced by DBG_reverse().

◆ putNext()

void directedLine::putNext ( directedLine p)
inline

Definition at line 81 of file directedLine.h.

81{next = p;}

Referenced by DBG_reverse().

◆ putPrev()

void directedLine::putPrev ( directedLine p)
inline

Definition at line 80 of file directedLine.h.

80{prev = p;}

Referenced by DBG_reverse().

◆ resetRootBit()

void directedLine::resetRootBit ( )
inline

Definition at line 152 of file directedLine.h.

152{rootBit = 0;}

◆ rootLinkFindRoot()

directedLine * directedLine::rootLinkFindRoot ( )

Definition at line 731 of file directedLine.cc.

732{
733 directedLine* tempRoot;
734 directedLine* tempLink;
735 tempRoot = this;
736 tempLink = rootLink;
737 while(tempLink != NULL){
738 tempRoot = tempLink;
739 tempLink = tempRoot->rootLink;
740 }
741 return tempRoot;
742}

Referenced by MC_partitionY(), and partitionY().

◆ rootLinkSet()

void directedLine::rootLinkSet ( directedLine r)
inline

Definition at line 155 of file directedLine.h.

155{rootLink = r;}
GLdouble GLdouble GLdouble r
Definition: gl.h:2055

Referenced by MC_partitionY(), partitionY(), and readAllPolygons().

◆ samePolygon()

Int directedLine::samePolygon ( directedLine v1,
directedLine v2 
)

Definition at line 711 of file directedLine.cc.

712{
713 if(v1 == v2) return 1;
715 for(temp = v1->next; temp != v1; temp = temp->next)
716 {
717 if(temp == v2) return 1;
718 }
719 return 0;
720}

Referenced by MC_partitionY(), and partitionY().

◆ setRootBit()

void directedLine::setRootBit ( )
inline

Definition at line 151 of file directedLine.h.

151{rootBit = 1;}

Referenced by insertPolygon().

◆ sortAllPolygons()

directedLine ** directedLine::sortAllPolygons ( )

Definition at line 461 of file directedLine.cc.

462{
463 Int total_num_edges = 0;
464 directedLine** array = toArrayAllPolygons(total_num_edges);
465 quicksort( (void**)array, 0, total_num_edges-1, (Int (*)(void *, void *)) compInY2);
466
467 return array;
468}
directedLine ** toArrayAllPolygons(Int &total_num_edges)
static Int compInY2(directedLine *v1, directedLine *v2)
void quicksort(void *v[], int left, int right, int(*comp)(void *, void *))
Definition: quicksort.cc:62

◆ tail()

◆ toArrayAllPolygons()

directedLine ** directedLine::toArrayAllPolygons ( Int total_num_edges)

Definition at line 567 of file directedLine.cc.

568{
569 total_num_edges=numEdgesAllPolygons();
570 directedLine** ret = (directedLine**) malloc(sizeof(directedLine*) * total_num_edges);
571 assert(ret);
572
574 Int index = 0;
575 for(temp=this; temp != NULL; temp=temp->nextPolygon) {
576 index = temp->toArraySinglePolygon(ret, index);
577 }
578 return ret;
579}
Int numEdgesAllPolygons()
#define malloc
Definition: debug_ros.c:4
#define assert(x)
Definition: debug.h:53
GLuint index
Definition: glext.h:6031

Referenced by DBGfindDiagonals(), partitionY(), and sortAllPolygons().

◆ toArraySinglePolygon()

Int directedLine::toArraySinglePolygon ( directedLine **  array,
Int  index 
)

Definition at line 552 of file directedLine.cc.

553{
555 array[index++] = this;
556 for(temp = next; temp != this; temp = temp->next)
557 {
558 array[index++] = temp;
559 }
560 return index;
561}
#define index(s, c)
Definition: various.h:29

◆ writeAllPolygons()

void directedLine::writeAllPolygons ( char filename)

Definition at line 756 of file directedLine.cc.

757{
758 FILE* fp = fopen(filename, "w");
759 assert(fp);
760 Int nPolygons = numPolygons();
762 fprintf(fp, "%i\n", nPolygons);
763 for(root = this; root != NULL; root = root->nextPolygon)
764 {
766 Int npoints=0;
767 npoints = root->get_npoints()-1;
768 for(temp = root->next; temp != root; temp=temp->next)
769 npoints += temp->get_npoints()-1;
770 fprintf(fp, "%i\n", npoints/*root->numEdges()*/);
771
772
773 for(Int i=0; i<root->get_npoints()-1; i++){
774 fprintf(fp, "%f ", root->getVertex(i)[0]);
775 fprintf(fp, "%f ", root->getVertex(i)[1]);
776 }
777
778 for(temp=root->next; temp != root; temp = temp->next)
779 {
780 for(Int i=0; i<temp->get_npoints()-1; i++){
781
782 fprintf(fp, "%f ", temp->getVertex(i)[0]);
783 fprintf(fp, "%f ", temp->getVertex(i)[1]);
784 }
785 fprintf(fp,"\n");
786 }
787 fprintf(fp, "\n");
788 }
789 fclose(fp);
790}
struct _root root
_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)
const char * filename
Definition: ioapi.h:137

Member Data Documentation

◆ direction

short directedLine::direction
private

◆ next

◆ nextPolygon

◆ prev

◆ rootBit

Int directedLine::rootBit
private

Definition at line 55 of file directedLine.h.

Referenced by directedLine(), findRoot(), resetRootBit(), and setRootBit().

◆ rootLink

directedLine* directedLine::rootLink
private

Definition at line 58 of file directedLine.h.

Referenced by directedLine(), insert(), rootLinkFindRoot(), and rootLinkSet().

◆ sline

sampledLine* directedLine::sline
private

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