ReactOS  0.4.11-dev-765-g5e024bf
monoTriangulationBackend.cc File Reference
#include "monoTriangulation.h"
#include "polyUtil.h"
#include "backend.h"
Include dependency graph for monoTriangulationBackend.cc:

Go to the source code of this file.

Functions

void monoTriangulationRec (Real *topVertex, Real *botVertex, vertexArray *inc_chain, Int inc_current, vertexArray *dec_chain, Int dec_current, Backend *backend)
 
void monoTriangulationFunBackend (Arc_ptr loop, Int(*compFun)(Real *, Real *), Backend *backend)
 
void monoTriangulationRecFunBackend (Real *topVertex, Real *botVertex, vertexArray *inc_chain, Int inc_current, vertexArray *dec_chain, Int dec_current, Int(*compFun)(Real *, Real *), Backend *backend)
 

Function Documentation

void monoTriangulationFunBackend ( Arc_ptr  loop,
Int(*)(Real *, Real *)  compFun,
Backend backend 
)

Definition at line 253 of file monoTriangulationBackend.cc.

Referenced by Slicer::slice_new().

254 {
255  Int i;
256  /*find the top vertex, bottom vertex, inccreasing chain, and decreasing chain,
257  *then call monoTriangulationRec
258  */
259  Arc_ptr tempV;
260  Arc_ptr topV;
261  Arc_ptr botV;
262  topV = botV = loop;
263  for(tempV = loop->next; tempV != loop; tempV = tempV->next)
264  {
265  if(compFun(topV->tail(), tempV->tail())<0) {
266  topV = tempV;
267  }
268  if(compFun(botV->tail(), tempV->tail())>0) {
269  botV = tempV;
270  }
271  }
272 
273  /*creat increase and decrease chains*/
274  vertexArray inc_chain(20); /*this is a dynamic array*/
275  for(i=1; i<=topV->pwlArc->npts-2; i++) { /*the first vertex is the top vertex which doesn't belong to inc_chain*/
276  inc_chain.appendVertex(topV->pwlArc->pts[i].param);
277  }
278  for(tempV = topV->next; tempV != botV; tempV = tempV->next)
279  {
280  for(i=0; i<=tempV->pwlArc->npts-2; i++){
281  inc_chain.appendVertex(tempV->pwlArc->pts[i].param);
282  }
283  }
284 
285  vertexArray dec_chain(20);
286  for(tempV = topV->prev; tempV != botV; tempV = tempV->prev)
287  {
288  for(i=tempV->pwlArc->npts-2; i>=0; i--){
289  dec_chain.appendVertex(tempV->pwlArc->pts[i].param);
290  }
291  }
292  for(i=botV->pwlArc->npts-2; i>=1; i--){
293  dec_chain.appendVertex(tempV->pwlArc->pts[i].param);
294  }
295 
296  monoTriangulationRecFunBackend(topV->tail(), botV->tail(), &inc_chain, 0, &dec_chain, 0, compFun, backend);
297 
298 }
VARIANT loop
void monoTriangulationRecFunBackend(Real *topVertex, Real *botVertex, vertexArray *inc_chain, Int inc_current, vertexArray *dec_chain, Int dec_current, Int(*compFun)(Real *, Real *), Backend *backend)
GLenum GLclampf GLint i
Definition: glfuncs.h:14
class Arc * Arc_ptr
Definition: arc.h:50
int Int
Definition: definitions.h:37
void monoTriangulationRec ( Real topVertex,
Real botVertex,
vertexArray inc_chain,
Int  inc_current,
vertexArray dec_chain,
Int  dec_current,
Backend backend 
)

Definition at line 159 of file monoTriangulationBackend.cc.

Referenced by monoTriangulationLoop(), monoTriangulationRec(), and sampleMonoPolyRec().

163 {
164  assert( inc_chain != NULL && dec_chain != NULL);
165  assert( ! (inc_current>=inc_chain->getNumElements() &&
166  dec_current>=dec_chain->getNumElements()));
167  Int inc_nVertices;
168  Int dec_nVertices;
169  Real** inc_array ;
170  Real** dec_array ;
171  Int i;
172  assert( ! ( (inc_chain==NULL) && (dec_chain==NULL)));
173 
174  if(inc_current>=inc_chain->getNumElements()) /*no more vertices on inc_chain*/
175  {
176 
177  dec_array = dec_chain->getArray();
178  dec_nVertices = dec_chain->getNumElements();
179  reflexChain rChain(20,0);
180  /*put the top vertex into the reflex chain*/
181  rChain.processNewVertex(topVertex, backend);
182  /*process all the vertices on the dec_chain*/
183  for(i=dec_current; i<dec_nVertices; i++){
184  rChain.processNewVertex(dec_array[i], backend);
185  }
186  /*process the bottom vertex*/
187  rChain.processNewVertex(botVertex, backend);
188 
189  }
190  else if(dec_current>= dec_chain->getNumElements()) /*no more vertices on dec_chain*/
191  {
192  inc_array = inc_chain->getArray();
193  inc_nVertices= inc_chain->getNumElements();
194  reflexChain rChain(20,1);
195  /*put the top vertex into the reflex chain*/
196  rChain.processNewVertex(topVertex, backend);
197  /*process all the vertices on the inc_chain*/
198  for(i=inc_current; i<inc_nVertices; i++){
199  rChain.processNewVertex(inc_array[i], backend);
200  }
201  /*process the bottom vertex*/
202  rChain.processNewVertex(botVertex, backend);
203  }
204  else /*neither chain is empty*/
205  {
206  inc_array = inc_chain -> getArray();
207  dec_array = dec_chain -> getArray();
208  inc_nVertices= inc_chain->getNumElements();
209  dec_nVertices= dec_chain->getNumElements();
210  /*if top of inc_chain is 'lower' than top of dec_chain, process all the
211  *vertices on the dec_chain which are higher than top of inc_chain
212  */
213  if(compV2InY(inc_array[inc_current], dec_array[dec_current]) <= 0)
214  {
215 
216  reflexChain rChain(20, 0);
217  rChain.processNewVertex(topVertex, backend);
218  for(i=dec_current; i<dec_nVertices; i++)
219  {
220  if(compV2InY(inc_array[inc_current], dec_array[i]) <= 0)
221  rChain.processNewVertex(dec_array[i], backend);
222  else
223  break;
224  }
225  rChain.outputFan(inc_array[inc_current], backend);
226  monoTriangulationRec(dec_array[i-1], botVertex,
227  inc_chain, inc_current,
228  dec_chain, i,
229  backend);
230  }
231  else /*compV2InY(inc_array[inc_current], dec_array[dec_current]) > 0*/
232  {
233 
234  reflexChain rChain(20, 1);
235  rChain.processNewVertex(topVertex, backend);
236  for(i=inc_current; i<inc_nVertices; i++)
237  {
238  if(compV2InY(inc_array[i], dec_array[dec_current]) >0)
239  rChain.processNewVertex(inc_array[i], backend);
240  else
241  break;
242  }
243  rChain.outputFan(dec_array[dec_current], backend);
244  monoTriangulationRec(inc_array[i-1], botVertex,
245  inc_chain, i,
246  dec_chain, dec_current,
247  backend);
248  }
249  }/*end case neither is empty*/
250 }
Real ** getArray()
#define assert(x)
Definition: debug.h:53
Int compV2InY(Real A[2], Real B[2])
GLenum GLclampf GLint i
Definition: glfuncs.h:14
smooth NULL
Definition: ftsmooth.c:416
void monoTriangulationRec(Real *topVertex, Real *botVertex, vertexArray *inc_chain, Int inc_current, vertexArray *dec_chain, Int dec_current, Backend *backend)
float Real
Definition: definitions.h:36
int Int
Definition: definitions.h:37
void monoTriangulationRecFunBackend ( Real topVertex,
Real botVertex,
vertexArray inc_chain,
Int  inc_current,
vertexArray dec_chain,
Int  dec_current,
Int(*)(Real *, Real *)  compFun,
Backend backend 
)

Definition at line 303 of file monoTriangulationBackend.cc.

Referenced by monoTriangulationFunBackend(), and monoTriangulationRecFunBackend().

308 {
309  assert( inc_chain != NULL && dec_chain != NULL);
310  assert( ! (inc_current>=inc_chain->getNumElements() &&
311  dec_current>=dec_chain->getNumElements()));
312  Int inc_nVertices;
313  Int dec_nVertices;
314  Real** inc_array ;
315  Real** dec_array ;
316  Int i;
317  assert( ! ( (inc_chain==NULL) && (dec_chain==NULL)));
318 
319  if(inc_current>=inc_chain->getNumElements()) /*no more vertices on inc_chain*/
320  {
321 
322  dec_array = dec_chain->getArray();
323  dec_nVertices = dec_chain->getNumElements();
324  reflexChain rChain(20,0);
325  /*put the top vertex into the reflex chain*/
326  rChain.processNewVertex(topVertex, backend);
327  /*process all the vertices on the dec_chain*/
328  for(i=dec_current; i<dec_nVertices; i++){
329  rChain.processNewVertex(dec_array[i], backend);
330  }
331  /*process the bottom vertex*/
332  rChain.processNewVertex(botVertex, backend);
333 
334  }
335  else if(dec_current>= dec_chain->getNumElements()) /*no more vertices on dec_chain*/
336  {
337  inc_array = inc_chain->getArray();
338  inc_nVertices= inc_chain->getNumElements();
339  reflexChain rChain(20,1);
340  /*put the top vertex into the reflex chain*/
341  rChain.processNewVertex(topVertex, backend);
342  /*process all the vertices on the inc_chain*/
343  for(i=inc_current; i<inc_nVertices; i++){
344  rChain.processNewVertex(inc_array[i], backend);
345  }
346  /*process the bottom vertex*/
347  rChain.processNewVertex(botVertex, backend);
348  }
349  else /*neither chain is empty*/
350  {
351  inc_array = inc_chain -> getArray();
352  dec_array = dec_chain -> getArray();
353  inc_nVertices= inc_chain->getNumElements();
354  dec_nVertices= dec_chain->getNumElements();
355  /*if top of inc_chain is 'lower' than top of dec_chain, process all the
356  *vertices on the dec_chain which are higher than top of inc_chain
357  */
358  if(compFun(inc_array[inc_current], dec_array[dec_current]) <= 0)
359  {
360 
361  reflexChain rChain(20, 0);
362  rChain.processNewVertex(topVertex, backend);
363  for(i=dec_current; i<dec_nVertices; i++)
364  {
365  if(compFun(inc_array[inc_current], dec_array[i]) <= 0)
366  rChain.processNewVertex(dec_array[i], backend);
367  else
368  break;
369  }
370  rChain.outputFan(inc_array[inc_current], backend);
371  monoTriangulationRecFunBackend(dec_array[i-1], botVertex,
372  inc_chain, inc_current,
373  dec_chain, i,
374  compFun,
375  backend);
376  }
377  else /*compFun(inc_array[inc_current], dec_array[dec_current]) > 0*/
378  {
379 
380  reflexChain rChain(20, 1);
381  rChain.processNewVertex(topVertex, backend);
382  for(i=inc_current; i<inc_nVertices; i++)
383  {
384  if(compFun(inc_array[i], dec_array[dec_current]) >0)
385  rChain.processNewVertex(inc_array[i], backend);
386  else
387  break;
388  }
389  rChain.outputFan(dec_array[dec_current], backend);
390  monoTriangulationRecFunBackend(inc_array[i-1], botVertex,
391  inc_chain, i,
392  dec_chain, dec_current,
393  compFun,
394  backend);
395  }
396  }/*end case neither is empty*/
397 }
Real ** getArray()
#define assert(x)
Definition: debug.h:53
void monoTriangulationRecFunBackend(Real *topVertex, Real *botVertex, vertexArray *inc_chain, Int inc_current, vertexArray *dec_chain, Int dec_current, Int(*compFun)(Real *, Real *), Backend *backend)
GLenum GLclampf GLint i
Definition: glfuncs.h:14
smooth NULL
Definition: ftsmooth.c:416
float Real
Definition: definitions.h:36
int Int
Definition: definitions.h:37