ReactOS  0.4.14-dev-55-g2da92ac
directedLine.h
Go to the documentation of this file.
1 /*
2  * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3  * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice including the dates of first publication and
13  * either this permission notice or a reference to
14  * http://oss.sgi.com/projects/FreeB/
15  * shall be included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20  * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22  * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23  * SOFTWARE.
24  *
25  * Except as contained in this notice, the name of Silicon Graphics, Inc.
26  * shall not be used in advertising or otherwise to promote the sale, use or
27  * other dealings in this Software without prior written authorization from
28  * Silicon Graphics, Inc.
29  */
30 /*
31 */
32 
33 #ifndef _DIRECTEDLINE_H
34 #define _DIRECTEDLINE_H
35 
36 //#include "definitions.h"
37 #include "sampledLine.h"
38 
40 
41 class directedLine {
42  short direction; /*INCREASING or DECREASING*/
44  directedLine* next; /*double linked list*/
45  directedLine* prev; /*double linked list*/
46 
47  /*in case we need a list of polygons each
48  *consisting of a double linked list
49  */
51 
52  /*optimization make cutoff polygon faster*/
53 /* directedLine* prevPolygon;*/
54 
55  Int rootBit; /*1 if this is a root of the polygon, set by setRootBit*/
56  /*and reset by resetRootBit()*/
57 
58  directedLine* rootLink; /*fast root-finding*/
59 
60 
61 
62 public:
63  directedLine(short dir, sampledLine* sl);
64  directedLine();
65  ~directedLine();
66 
67  void init(short dir, sampledLine* sl);
68 
69  Real* head(); /*points[0] if INCREASING, points[n-1] otherwise*/
70  Real* tail(); /*points[n-1] if INCREASING, points[0] otherwise*/
71  Real* getVertex(Int i); /*points[i] if INCREASING, points[n-1-i] otherwise*/
73  directedLine* getPrev() {return prev;}
74  directedLine* getNext() {return next;}
77 
78  short getDirection(){return direction;}
79  void putDirection(short dir) {direction = dir;}
80  void putPrev(directedLine *p) {prev = p;}
81  void putNext(directedLine *p) {next = p;}
82 
83  /*insert a new line between prev and this*/
84  void insert(directedLine* nl);
85 
86  /*delete all the polygons following the link: nextPolygon.
87  *notice that sampledLine is not deleted. The caller is
88  *responsible for that
89  */
90  void deletePolygonList();
91  void deleteSinglePolygon();
92 
93  void deleteSinglePolygonWithSline(); //also delete sanmpled line
94  void deletePolygonListWithSline(); //also delete sanmpled line
95 
96  void deleteSingleLine(directedLine* dline);
99  directedLine* cutIntersectionAllPoly(int& cutOccur);
100 
101  /*check to see if the list forms a closed polygon
102  *return 1 if yes
103  */
104  short isPolygon();
105 
106  Int compInY(directedLine* nl);
107  Int compInX(directedLine* nl);
108 
109  /*return an array of pointers.
110  *the
111  */
113 
114  Int numEdges();
116  Int numPolygons();
117 
118  /*check if the head of this edge is connected to
119  *the tail of the prev
120  */
121  short isConnected();
122 
123  Real polyArea();
124 
125  void printSingle();
126  void printList();
127  void printAllPolygons();
128  void writeAllPolygons(char* filename);
129 
130 
131  /*insert a polygon: using nextPolygon*/
134 
136  directedLine** toArrayAllPolygons(Int& total_num_edges);
137 
139  directedLine** ret_p1,
140  directedLine** ret_p2,
141  sampledLine** generatedLine, directedLine* list);
142 
143  /*generate two slines
144  */
146  directedLine** ret_p1,
147  directedLine** ret_p2,
148  directedLine* list);
149 
151  void setRootBit() {rootBit = 1;}
152  void resetRootBit() {rootBit = 0;}
154 
157 
158  //the chain from begin to end is deleted (the space is deallocated)
159  //and a new edge(which connectes the head of begin and the tail of end)
160  // is inserted. The new polygon is returned.
161  //notice that "this" is arbitrary
163 };
164 
166 
167 extern Int compV2InY(Real A[2], Real B[2]);
168 extern Int compV2InX(Real A[2], Real B[2]);
169 
170 #endif
171 
void connectDiagonal(directedLine *v1, directedLine *v2, directedLine **ret_p1, directedLine **ret_p2, sampledLine **generatedLine, directedLine *list)
void rootLinkSet(directedLine *r)
Definition: directedLine.h:155
directedLine * next
Definition: directedLine.h:44
void connectDiagonal_2slines(directedLine *v1, directedLine *v2, directedLine **ret_p1, directedLine **ret_p2, directedLine *list)
Real * head()
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
void deletePolygonList()
Int toArraySinglePolygon(directedLine **array, Int index)
directedLine * deleteDegenerateLinesAllPolygons()
GLuint GLuint end
Definition: gl.h:1545
const char * filename
Definition: ioapi.h:135
Int compV2InY(Real A[2], Real B[2])
Int samePolygon(directedLine *v1, directedLine *v2)
void deleteSinglePolygonWithSline()
void writeAllPolygons(char *filename)
sampledLine * sline
Definition: directedLine.h:43
directedLine * getPrev()
Definition: directedLine.h:73
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
short getDirection()
Definition: directedLine.h:78
directedLine * insertPolygon(directedLine *newpolygon)
directedLine * getNext()
Definition: directedLine.h:74
directedLine ** sortAllPolygons()
Real * getVertex(Int i)
Int compInY(directedLine *nl)
GLuint index
Definition: glext.h:6031
unsigned int dir
Definition: maze.c:112
directedLine * deleteChain(directedLine *begin, directedLine *end)
Definition: directedLine.cc:53
static clock_t begin
Definition: xmllint.c:466
short isPolygon()
directedLine * rootLinkFindRoot()
Int compInX(directedLine *nl)
directedLine * readAllPolygons(char *filename)
void printAllPolygons()
directedLine ** toArrayAllPolygons(Int &total_num_edges)
directedLine * rootLink
Definition: directedLine.h:58
void putDirection(short dir)
Definition: directedLine.h:79
Definition: ttei1.cpp:12
directedLine * deleteDegenerateLines()
Int numEdgesAllPolygons()
Definition: _list.h:228
directedLine * cutIntersectionAllPoly(int &cutOccur)
sampledLine * getSampledLine()
Definition: directedLine.h:76
Real * tail()
void deletePolygonListWithSline()
void putNext(directedLine *p)
Definition: directedLine.h:81
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
void init(short dir, sampledLine *sl)
short isConnected()
directedLine * nextPolygon
Definition: directedLine.h:50
#define B(row, col)
void setRootBit()
Definition: directedLine.h:151
float Real
Definition: definitions.h:36
void printSingle()
Int get_npoints()
Definition: directedLine.h:72
void resetRootBit()
Definition: directedLine.h:152
Int compV2InX(Real A[2], Real B[2])
void deleteSingleLine(directedLine *dline)
Definition: directedLine.cc:88
directedLine * cutoffPolygon(directedLine *p)
directedLine * prev
Definition: directedLine.h:45
Int get_npoints()
Definition: sampledLine.h:56
GLfloat GLfloat p
Definition: glext.h:8902
short direction
Definition: directedLine.h:42
directedLine * findRoot()
void printList()
GLfloat GLfloat v1
Definition: glext.h:6062
directedLine * getNextPolygon()
Definition: directedLine.h:75
void insert(directedLine *nl)
int Int
Definition: definitions.h:37
void putPrev(directedLine *p)
Definition: directedLine.h:80
void deleteSinglePolygon()