52#define max(a,b) ((a>b)? a:b)
55#define min(a,b) ((a>b)? b:a)
63static void drawDiagonals(
Int num_diagonals,
directedLine** diagonal_vertices)
66 for(
i=0;
i<num_diagonals;
i++)
148 tempNext =
temp->next;
158 tempNext =
temp->nextPolygon;
191 if(
next ==
this)
return 1;
203 ret +=
temp->numChainsSingleLoop();
215 if(
temp->head()[1] >
y)
224 if(
temp->head()[1] >
y)
250 firstCusp = prevCusp;
312 Real e1_Ymax, e1_Ymin, e2_Ymax, e2_Ymin;
333 if(head1[1]>tail1[1]) {
342 if(head2[1]>tail2[1]) {
357 Real Ymax =
min(e1_Ymax, e2_Ymax);
358 Real Ymin =
max(e1_Ymin, e2_Ymin);
360 Real y = 0.5*(Ymax + Ymin);
372 if(
x1<=
x2)
return -1;
403 if(
temp->head()[1] >
y)
413 if(
temp->head()[1] >
y)
438 temp->printOneChain();
447 temp->printChainLoop();
463 for(
i=0;
i<nVertices;
i++)
489 if(leftEdge ==
NULL || rightEdge ==
NULL)
534 if(leftEdge ==
NULL || rightEdge ==
NULL)
574 for(
i=0;
i<total_num_edges;
i++)
575 sortedVertices[
i]->resetCurrent();
577 for(
i=0;
i<total_num_edges;
i++)
585 diagonal_vertices[
k++] = vert;
596 for(
j=
i+1;
j<total_num_edges;
j++)
598 if(sortedVertices[
j]->getHead()->head()[1] > minVert->
head()[1])
609 diagonal_vertices[
k++] = sortedVertices[
j]->
getHead();
611 diagonal_vertices[
k++] = minVert;
616 diagonal_vertices[
k++] = vert;
625 for(
j=
i-1;
j>=0;
j--)
627 if(sortedVertices[
j]->getHead()->head()[1] < maxVert->
head()[1])
636 diagonal_vertices[
k++] = sortedVertices[
j]->
getHead();
638 diagonal_vertices[
k++] = maxVert;
650 Int total_num_chains = 0;
654 if(total_num_chains<=2)
658 *retSampledLines =
NULL;
674 *retSampledLines =
NULL;
683 assert(diagonal_vertices);
707 for(
i=0;
i<num_diagonals;
i++)
708 removedDiagonals[
i] = 0;
712 for(
i=0,
k=0;
i<num_diagonals;
i++,
k+=2)
737 removedDiagonals[
i] = 1;
742 v1->connectDiagonal(
v1,
v2, &ret_p1, &ret_p2, &generatedLine, ret_polygons);
746 newSampledLines = generatedLine->
insert(newSampledLines);
776 for(ii=0, kk=0; ii<num_diagonals; ii++, kk+=2)
777 if( removedDiagonals[ii]==0)
785 v1->head(),
v1->tail(), d2->
head()))
798 v2->head(),
v2->tail(), d2->
head()))
812 v1->head(),
v1->tail(), d1->
head()))
824 v2->head(),
v2->tail(), d1->
head()))
844 for(
i=0,
k=0;
i<num_diagonals;
i++,
k += 2)
845 if(removedDiagonals[
i] == 0)
874 v1->connectDiagonal(
v1,
v2, &ret_p1, &ret_p2, &generatedLine, ret_polygons);
875 newSampledLines = generatedLine->
insert(newSampledLines);
885 for(
Int j=
i+1;
j<num_diagonals;
j++)
887 if(removedDiagonals[
j] ==0)
892 if(temp1==
v1 || temp1==
v2 || temp2==
v1 || temp2==
v2)
929 free(diagonal_vertices);
930 free(removedDiagonals);
932 *retSampledLines = newSampledLines;
struct outqueuenode * head
directedLine * cutoffPolygon(directedLine *p)
void rootLinkSet(directedLine *r)
directedLine * insertPolygon(directedLine *newpolygon)
directedLine * findRoot()
directedLine * rootLinkFindRoot()
Int samePolygon(directedLine *v1, directedLine *v2)
Int compInY(directedLine *nl)
Real chainIntersectHoriz(Real y)
directedLine * find(Real y)
monoChain ** toArrayAllLoops(Int &num_chains)
monoChain(directedLine *cHead, directedLine *cTail)
Int toArraySingleLoop(monoChain **array, Int index)
void insert(monoChain *nc)
Int numChainsSingleLoop()
void setNextPolygon(monoChain *np)
sampledLine * insert(sampledLine *nline)
Int compV2InY(Real A[2], Real B[2])
GLint GLint GLint GLint GLint GLint y
GLAPI void GLAPIENTRY glBegin(GLenum mode)
GLAPI void GLAPIENTRY glEnd(void)
GLAPI void GLAPIENTRY glVertex2fv(const GLfloat *v)
GLfloat GLfloat GLfloat v2
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 const GLfloat const GLdouble const GLfloat GLint GLint GLint j
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
monoChain * directedLineLoopListToMonoChainLoopList(directedLine *list)
Int isCusp(directedLine *v)
Int MC_sweepY(Int nVertices, monoChain **sortedVertices, sweepRange **ret_ranges)
static Int compEdges(directedLine *e1, directedLine *e2)
Int deleteRepeatDiagonals(Int num_diagonals, directedLine **diagonal_vertices, directedLine **new_vertices)
Real intersectHoriz(Real x1, Real y1, Real x2, Real y2, Real y)
directedLine * MC_partitionY(directedLine *polygons, sampledLine **retSampledLines)
void MC_findDiagonals(Int total_num_edges, monoChain **sortedVertices, sweepRange **ranges, Int &num_diagonals, directedLine **diagonal_vertices)
monoChain * directedLineLoopToMonoChainLoop(directedLine *loop)
Int compChains(monoChain *mc1, monoChain *mc2)
static int compChainHeadInY(monoChain *mc1, monoChain *mc2)
sweepRange * sweepRangeMake(directedLine *left, Int leftType, directedLine *right, Int rightType)
Int cuspType(directedLine *v)
Int isBelow(directedLine *v, directedLine *e)
Int sweepRangeEqual(sweepRange *src1, sweepRange *src2)
Int isAbove(directedLine *v, directedLine *e)
Int pointLeft2Lines(Real A[2], Real B[2], Real C[2], Real P[2])
void quicksort(void *v[], int left, int right, int(*comp)(void *, void *))
void TreeNodeDeleteSingleNode(treeNode *node)
treeNode * TreeNodePredecessor(treeNode *node)
treeNode * TreeNodeFind(treeNode *tree, void *key, int(*compkey)(void *, void *))
treeNode * TreeNodeMake(void *key)
treeNode * TreeNodeSuccessor(treeNode *node)
treeNode * TreeNodeInsert(treeNode *root, treeNode *newnode, int(*compkey)(void *, void *))
void TreeNodeDeleteWholeTree(treeNode *node)
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG y1
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG _In_ LONG y2