reshuffling of dlls
[reactos.git] / reactos / dll / glu32 / libnurbs / nurbtess / directedLine.h
1 /*
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:
9 **
10 ** http://oss.sgi.com/projects/FreeB
11 **
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.
17 **
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.
23 **
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.
33 **
34 ** $Date$ $Revision: 1.1 $
35 */
36 /*
37 ** $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/lib/glu32/libnurbs/nurbtess/directedLine.h,v 1.1 2004/02/02 16:39:13 navaraf Exp $
38 */
39
40 #ifndef _DIRECTEDLINE_H
41 #define _DIRECTEDLINE_H
42
43 #include "definitions.h"
44 #include "sampledLine.h"
45
46 enum {INCREASING, DECREASING};
47
48 class directedLine {
49 short direction; /*INCREASING or DECREASING*/
50 sampledLine* sline;
51 directedLine* next; /*double linked list*/
52 directedLine* prev; /*double linked list*/
53
54 /*in case we need a list of polygons each
55 *consisting of a double linked list
56 */
57 directedLine* nextPolygon;
58
59 /*optimization make cutoff polygon faster*/
60 /* directedLine* prevPolygon;*/
61
62 Int rootBit; /*1 if this is a root of the polygon, set by setRootBit*/
63 /*and reset by resetRootBit()*/
64
65 directedLine* rootLink; /*fast root-finding*/
66
67
68
69 public:
70 directedLine(short dir, sampledLine* sl);
71 directedLine();
72 ~directedLine();
73
74 void init(short dir, sampledLine* sl);
75
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;}
84
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;}
89
90 /*insert a new line between prev and this*/
91 void insert(directedLine* nl);
92
93 /*delete all the polygons following the link: nextPolygon.
94 *notice that sampledLine is not deleted. The caller is
95 *responsible for that
96 */
97 void deletePolygonList();
98 void deleteSinglePolygon();
99
100 void deleteSinglePolygonWithSline(); //also delete sanmpled line
101 void deletePolygonListWithSline(); //also delete sanmpled line
102
103 void deleteSingleLine(directedLine* dline);
104 directedLine* deleteDegenerateLines();
105 directedLine* deleteDegenerateLinesAllPolygons();
106 directedLine* cutIntersectionAllPoly(int& cutOccur);
107
108 /*check to see if the list forms a closed polygon
109 *return 1 if yes
110 */
111 short isPolygon();
112
113 Int compInY(directedLine* nl);
114 Int compInX(directedLine* nl);
115
116 /*return an array of pointers.
117 *the
118 */
119 directedLine** sortAllPolygons();
120
121 Int numEdges();
122 Int numEdgesAllPolygons();
123 Int numPolygons();
124
125 /*check if the head of this edge is connected to
126 *the tail of the prev
127 */
128 short isConnected();
129
130 Real polyArea();
131
132 void printSingle();
133 void printList();
134 void printAllPolygons();
135 void writeAllPolygons(char* filename);
136
137
138 /*insert a polygon: using nextPolygon*/
139 directedLine* insertPolygon(directedLine* newpolygon);
140 directedLine* cutoffPolygon(directedLine *p);
141
142 Int toArraySinglePolygon(directedLine** array, Int index);
143 directedLine** toArrayAllPolygons(Int& total_num_edges);
144
145 void connectDiagonal(directedLine* v1, directedLine* v2,
146 directedLine** ret_p1,
147 directedLine** ret_p2,
148 sampledLine** generatedLine, directedLine* list);
149
150 /*generate two slines
151 */
152 void connectDiagonal_2slines(directedLine* v1, directedLine* v2,
153 directedLine** ret_p1,
154 directedLine** ret_p2,
155 directedLine* list);
156
157 Int samePolygon(directedLine* v1, directedLine* v2);
158 void setRootBit() {rootBit = 1;}
159 void resetRootBit() {rootBit = 0;}
160 directedLine* findRoot();
161
162 void rootLinkSet(directedLine* r) {rootLink = r;}
163 directedLine* rootLinkFindRoot();
164
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);
170 };
171
172 directedLine* readAllPolygons(char* filename);
173
174 extern Int compV2InY(Real A[2], Real B[2]);
175 extern Int compV2InX(Real A[2], Real B[2]);
176
177 #endif
178