2 ** License Applicability. Except to the extent portions of this file are
3 ** made subject to an alternative license as permitted in the SGI Free
4 ** Software License B, Version 1.1 (the "License"), the contents of this
5 ** file are subject only to the provisions of the License. You may not use
6 ** this file except in compliance with the License. You may obtain a copy
7 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
8 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
10 ** http://oss.sgi.com/projects/FreeB
12 ** Note that, as provided in the License, the Software is distributed on an
13 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
14 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
15 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
16 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
18 ** Original Code. The Original Code is: OpenGL Sample Implementation,
19 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
20 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
21 ** Copyright in any portions created by third parties is as indicated
22 ** elsewhere herein. All Rights Reserved.
24 ** Additional Notice Provisions: The application programming interfaces
25 ** established by SGI in conjunction with the Original Code are The
26 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
27 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
28 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
29 ** Window System(R) (Version 1.3), released October 19, 1998. This software
30 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
31 ** published by SGI, but has not been independently verified as being
32 ** compliant with the OpenGL(R) version 1.2.1 Specification.
34 ** $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
37 ** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/nurbtess/directedLine.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
40 #ifndef _DIRECTEDLINE_H
41 #define _DIRECTEDLINE_H
43 #include "definitions.h"
44 #include "sampledLine.h"
46 enum {INCREASING
, DECREASING
};
49 short direction
; /*INCREASING or DECREASING*/
51 directedLine
* next
; /*double linked list*/
52 directedLine
* prev
; /*double linked list*/
54 /*in case we need a list of polygons each
55 *consisting of a double linked list
57 directedLine
* nextPolygon
;
59 /*optimization make cutoff polygon faster*/
60 /* directedLine* prevPolygon;*/
62 Int rootBit
; /*1 if this is a root of the polygon, set by setRootBit*/
63 /*and reset by resetRootBit()*/
65 directedLine
* rootLink
; /*fast root-finding*/
70 directedLine(short dir
, sampledLine
* sl
);
74 void init(short dir
, sampledLine
* sl
);
76 Real
* head(); /*points[0] if INCREASING, points[n-1] otherwise*/
77 Real
* tail(); /*points[n-1] if INCREASING, points[0] otherwise*/
78 Real
* getVertex(Int i
); /*points[i] if INCREASING, points[n-1-i] otherwise*/
79 Int
get_npoints() {return sline
->get_npoints();}
80 directedLine
* getPrev() {return prev
;}
81 directedLine
* getNext() {return next
;}
82 directedLine
* getNextPolygon() {return nextPolygon
;}
83 sampledLine
* getSampledLine() {return sline
;}
85 short getDirection(){return direction
;}
86 void putDirection(short dir
) {direction
= dir
;}
87 void putPrev(directedLine
*p
) {prev
= p
;}
88 void putNext(directedLine
*p
) {next
= p
;}
90 /*insert a new line between prev and this*/
91 void insert(directedLine
* nl
);
93 /*delete all the polygons following the link: nextPolygon.
94 *notice that sampledLine is not deleted. The caller is
97 void deletePolygonList();
98 void deleteSinglePolygon();
100 void deleteSinglePolygonWithSline(); //also delete sanmpled line
101 void deletePolygonListWithSline(); //also delete sanmpled line
103 void deleteSingleLine(directedLine
* dline
);
104 directedLine
* deleteDegenerateLines();
105 directedLine
* deleteDegenerateLinesAllPolygons();
106 directedLine
* cutIntersectionAllPoly(int& cutOccur
);
108 /*check to see if the list forms a closed polygon
113 Int
compInY(directedLine
* nl
);
114 Int
compInX(directedLine
* nl
);
116 /*return an array of pointers.
119 directedLine
** sortAllPolygons();
122 Int
numEdgesAllPolygons();
125 /*check if the head of this edge is connected to
126 *the tail of the prev
134 void printAllPolygons();
135 void writeAllPolygons(char* filename
);
138 /*insert a polygon: using nextPolygon*/
139 directedLine
* insertPolygon(directedLine
* newpolygon
);
140 directedLine
* cutoffPolygon(directedLine
*p
);
142 Int
toArraySinglePolygon(directedLine
** array
, Int index
);
143 directedLine
** toArrayAllPolygons(Int
& total_num_edges
);
145 void connectDiagonal(directedLine
* v1
, directedLine
* v2
,
146 directedLine
** ret_p1
,
147 directedLine
** ret_p2
,
148 sampledLine
** generatedLine
, directedLine
* list
);
150 /*generate two slines
152 void connectDiagonal_2slines(directedLine
* v1
, directedLine
* v2
,
153 directedLine
** ret_p1
,
154 directedLine
** ret_p2
,
157 Int
samePolygon(directedLine
* v1
, directedLine
* v2
);
158 void setRootBit() {rootBit
= 1;}
159 void resetRootBit() {rootBit
= 0;}
160 directedLine
* findRoot();
162 void rootLinkSet(directedLine
* r
) {rootLink
= r
;}
163 directedLine
* rootLinkFindRoot();
165 //the chain from begin to end is deleted (the space is deallocated)
166 //and a new edge(which connectes the head of begin and the tail of end)
167 // is inserted. The new polygon is returned.
168 //notice that "this" is arbitrary
169 directedLine
* deleteChain(directedLine
* begin
, directedLine
* end
);
172 directedLine
* readAllPolygons(char* filename
);
174 extern Int
compV2InY(Real A
[2], Real B
[2]);
175 extern Int
compV2InX(Real A
[2], Real B
[2]);