For extracting a tesselations at variable resolution from an MT, we need:
The dynamic extractor is more efficient for applications in which the query parameters vary gradually between two consecutive queries. In this case, it is faster to modify the solution of the previous query into the solution of the next query, than recomputing it by scratch.
In application that are interested in processing just active tiles, the dynamic extractor has the disadvantage of generating a tesselation covering the whole object. On the other hand, the local extractor works with a static approach. Thus, in applications in which the focus set is not very selective, and query parameters change gradually from query to query, the dynamic extractor may still be faster than the local one.
The (resolution filter or focus) condition associated with an extractor may be changed in two ways:
We assume that header files myfilter.h and myfocus.h define the resolution filter condition and the focus condition needed by the application, as two subclasses of MT_CondClass named MyFilterCondClass and MyFocusCondClass, respectively. Names MyFilterCond and MyFocusCond denote the pointer types to such classes.
#include "mt_extra.h"
#include "myfilter.h"
#include "myfocus.h"
....
MT_MultiTesselation mt; /* the MT to be used */
MT_StaticExtractor ex /* the extractor */
MyFilterCond flt; /* the resolution filter condition */
MyFocusCond fcs; /* the focus condition */
MT_INDEX * active_tiles; /* array for active extracted tiles */
MT_INDEX * other_tiles; /* array for non-active extracted tiles */
MT_INXED active_num; /* number of active extracted tiles */
MT_INXED other_num; /* number of non-active extracted tiles */
/* create mt as a 2-dimensional MT (tiles=triangles) in 3D */
mt = new MT_MultiTesselationClass(3,2);
/* read the MT from some file */
mt->MT_Read(...);
/* create the resolution filter and the focus condition */
flt = new MyFilterCondClass(... parameters ...);
fcs = new MyFocusCondClass(... parameters ...);
/* create the extractor and set the extraction conditions */
ex = new MT_StaticExtractorClass(mt);
/* associate the conditions with the extractor */
ex->MT_SetFilter(flt);
ex->MT_SetFocus(fcs);
/* main loop */
while (... we want to continue ...)
{
/* extract a tesselation */
ex->MT_ExtractTesselation();
/* do something with the extracted tesselation; here,
we print the extracted triangles */
/* get all extracted tiles */
ex->MT_AttExtractedTiles(&active_tiles, &active_num,
&other_tiles, &other_num);
/* print active tiles */
for (i=0; i < active_num; i++)
{
printf("Active tile %d: ", i);
for (j=0; j < 3; j++)
{
printf("(%f %f %f) ",
mt->MT_vertexX(mt->MT_TileVertex(active_tiles[i],j)),
mt->MT_vertexY(mt->MT_TileVertex(active_tiles[i],j)),
mt->MT_vertexZ(mt->MT_TileVertex(active_tiles[i],j)));
}
printf("\n");
}
/* print non-active tiles */
... same as before, using counter other_num and array other_tiles ...
/* prepare for next extraction, if desired */
if (... we want to perform another extraction ...)
{
... change flt and/or fcs by using their access functions
defined in files myfilter.h and myfocus.h ...
}
else break; /* we do not want to continue */
}