HOW TO USE A GENERIC MT

An MT is used for extracting tesselations at variable resolution from it. Such tesselations will then be processed in some way within the application program.

For extracting a tesselations at variable resolution from an MT, we need:

  1. An extractor, chosen among the available ones: static extractor, dynamic extractor, local extractor (class MT_StaticExtractorClass, MT_DynamictractorClass, MT_LocaltractorClass, respectively).
  2. A resolution filter condition and/or a focus condition (subclasses of MT_CondClass).
The first two types of extractors generate a tesselation covering the whole object, where active tiles satisfy the resolution filter. The local extractor generates a tesselation restricted to active tiles, such that all such tiles satisfy the resolution filter.

How to choose the extractor

Static vs. dynamic extractor

The static extractor needs less memory than the dynamic one. It is good for applications which perform few extraction queries, or with query parameters that vary considerably between two consecutive queries.

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.

Local vs. dynamic extractor

The local extractor is recommended for applications in which the focus set is very selective, i.e., active tiles cover a small portion of the spatial object described by the MT.

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.

Guidelines

In order to extract a tesselation from an MT, an application program must perform the following operations:
  1. Create and MT and initialize it (typically, by reading it from a file).
  2. Create an extractor, of the suitable class, for that MT. When creating the extractor, it is possible to enable the generation of tile-to-tile adjacency links in extracted tesselations, if this feature is useful within the application program. By default, adjacency generation is disabled since it is a time-consuming operation.
  3. Create a suitable resolution filter condition and associate it with the extractor by calling function MT_SetFilter.
  4. Create a suitable focus condition and associate it with the extractor by calling function MT_SetFocus.
  5. Call MT_ExtractTesselation.
  6. Call either MT_ExtractedTiles to get the active tiles of the resulting tesselation, or MT_AllExtractedTiles to get all the tiles of the resulting tesselation. The MT_INDEXes of such tiles are returned into an array.
  7. Access the arrays to find the geometry (and, if enabled, the adjacency information) for each extracted tile:
The user program may perform several extraction queries from the same extractor by changing the resolution filter and/or the focus condition between two successive queries.

The (resolution filter or focus) condition associated with an extractor may be changed in two ways:

  1. By replacing it with another condition: create another condition and call MT_SetFilter or MT_SetFocus with such new condition.
  2. By modifying the condition through its access functions (which depend on the specific subclass of MT_CondClass): the extractor contains a direct reference to the condition, thus such modifications are visible within the extractor.

An example

We provide here the template of a program that extracts tesselations form an MT. In the example, a static extractor is used. A program using a dynamic extractor or a local extractor is written in a similar way.

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 */
}