ReactOS  0.4.15-dev-2965-g9a42267
monoPolyPart.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Functions

directedLinemonoPolyPart (directedLine *polygon)

## ◆ monoPolyPart()

 directedLine* monoPolyPart ( directedLine * polygon )

Definition at line 80 of file monoPolyPart.cc.

81 {
82  //handle special cases:
83  if(polygon == NULL)
84  return NULL;
85  if(polygon->getPrev() == polygon)
86  return polygon;
87  if(polygon->getPrev() == polygon->getNext())
88  return polygon;
89  if(polygon->getPrev()->getPrev() == polygon->getNext())
90  return polygon;
91
92  //find the top and bottom vertexes
93  directedLine *tempV, *topV, *botV;
94  topV = botV = polygon;
95  for(tempV = polygon->getNext(); tempV != polygon; tempV = tempV->getNext())
96  {
98  topV = tempV;
99  }
101  botV = tempV;
102  }
103  }
104
105  //initilization
106  directedLine *A, *B, *C, *D, *G, *H;
107  //find A:the first u_maximal vertex on the left chain
108  //and C: the left most vertex between top and A
109  A = NULL;
110  C = topV;
111  for(tempV=topV->getNext(); tempV != botV; tempV = tempV->getNext())
112  {
114  C = tempV;
115
116  if(is_u_maximal(tempV))
117  {
118  A = tempV;
119  break;
120  }
121  }
122  if(A == NULL)
123  {
124  A = botV;
126  C = A;
127  }
128
129  //find B: the first u_minimal vertex on the right chain
130  //and D: the right most vertex between top and B
131  B = NULL;
132  D = topV;
133  for(tempV=topV->getPrev(); tempV != botV; tempV = tempV->getPrev())
134  {
136  D = tempV;
137  if(is_u_minimal(tempV))
138  {
139  B = tempV;
140  break;
141  }
142  }
143  if(B == NULL)
144  {
145  B = botV;
147  D = B;
148  }
149
150  //error checking XXX
152  return polygon;
153
154  //find G on the left chain that is right above B
156  G = tempV->getPrev();
157  //find H on the right chain that is right above A
159  H = tempV->getNext();
160
161  //Main Loop
162  directedLine* ret = NULL;
163  directedLine* currentPolygon = polygon;
164  while(1)
165  {
166  //if both B and D are equal to botV, then this polygon is already
167  //u-monotone
168  if(A == botV && B == botV)
169  {
170  ret = currentPolygon->insertPolygon(ret);
171  return ret;
172  }
173  else //not u-monotone
174  {
175  directedLine *ret_p1, *ret_p2;
177  {
178  directedLine* E = NULL;
179  for(tempV = C; tempV != D; tempV = tempV->getPrev())
180  {
182  {
183  E = tempV;
184  break;
185  }
186  }
187
188  if(E == NULL)
189  E = D;
191  E = H;
192  //connect AE and output polygon ECA
193  polygon->connectDiagonal_2slines(A, E,
194  &ret_p1,
195  &ret_p2,
196  NULL);
197  ret = ret_p2->insertPolygon(ret);
198  currentPolygon = ret_p1;
199
200  if(E == D)
201  D = ret_p1;
202  if(E == H)
203  H = ret_p1;
205  G = A;
206  //update A to be the next u-maxiaml vertex on left chain
207  //and C the leftmost vertex between the old A and the new A
208  C = A;
209  for(tempV = A->getNext(); tempV != botV; tempV = tempV->getNext())
210  {
211
213  C = tempV;
214  if(is_u_maximal(tempV))
215  {
216  A = tempV;
217  break;
218  }
219  }
220
221  if(tempV == botV)
222  {
223  A = botV;
225  C = botV;
226  }
227  //update H
228
229  if(A == botV)
230  H = botV;
231  else
232  {
234  H = tempV->getNext();
235  }
236
237  }
238  else //A is below B
239  {
240
241  directedLine* F = NULL;
242  for(tempV = D; tempV != C; tempV = tempV->getNext())
243  {
245  {
246  F = tempV;
247  break;
248  }
249  }
250  if(F == NULL)
251  F = C;
253  F = G;
254
255  //connect FB
256  polygon->connectDiagonal_2slines(F, B,
257  &ret_p1,
258  &ret_p2,
259  NULL);
260  ret = ret_p2->insertPolygon(ret);
261  currentPolygon = ret_p1;
262  B = ret_p1;
264  H = ret_p1;
265
266  //update B to be the next u-minimal vertex on right chain
267  //and D the rightmost vertex between the old B and the new B
268  D = B;
269  for(tempV = B->getPrev(); tempV != botV; tempV = tempV->getPrev())
270  {
272  D = tempV;
273  if(is_u_minimal(tempV))
274  {
275  B = tempV;
276  break;
277  }
278  }
279  if(tempV == botV)
280  {
281  B = botV;
283  D = botV;
284  }
285  //update G
286  if(B == botV)
287  G = botV;
288  else
289  {
291  G = tempV->getPrev();
292  }
293  } //end of A is below B
294  } //end not u-monotone
295  } //end of main loop
296 }
Definition: ehthrow.cxx:53
void connectDiagonal_2slines(directedLine *v1, directedLine *v2, directedLine **ret_p1, directedLine **ret_p2, directedLine *list)
static Int is_u_maximal(directedLine *v)
Definition: monoPolyPart.cc:56
ULONG G
Definition: xcpt4u.c:549
Definition: terminate.cpp:23
Definition: ehthrow.cxx:92
directedLine * getPrev()
Definition: directedLine.h:73
Int compV2InY(Real A[2], Real B[2])
#define A(row, col)
directedLine * insertPolygon(directedLine *newpolygon)
directedLine * getNext()
Definition: directedLine.h:74
static Int is_u_minimal(directedLine *v)
Definition: monoPolyPart.cc:68
#define D(d)
Definition: builtin.c:4557
int ret
static const WCHAR E[]
Definition: oid.c:1253
#define B(row, col)
#define NULL
Definition: types.h:112
#define C(c)
Definition: builtin.c:4556
#define H
#define F(x, y, z)
Definition: md5.c:51

Referenced by monoTriangulationRecGenOpt().