Mesh Managers

From DocR23

Jump to: navigation, search
Showdoc.png



Mesh Managers control how the mesh is streamed to applications. For most uses the default mesh manager, INDEXED_MESH_MANAGER, is a good choice. If more customized mesh formats are desired, the application may choose another mesh manager. This involves either choosing one of the mesh managers provided by ACIS (refer to the section ACIS Mesh Managers), or deriving a custom mesh manager from the MESH_MANAGER class (refer to the section Derived Mesh Managers). Making the right choice of a mesh manager ensures that:

  • Only the needed information is stored, and in a format suited to the application;
  • The right balance between performance and efficient memory use is struck; and
  • Other support required by the application will be provided.

Contents

Derived Mesh Managers

The way in which facets should be stored always depends on the particular application. A data format designed to meet the needs of all end-user applications would make the data-storage requirements for faceting huge, if not unmanageable. Furthermore, applications rarely need all the data generated by the Faceter. If provided with a huge data structure, most applications would extract what they needed and discard the original data structure to save on storage. Saving storage space could come at the expense of computation, because downstream operations might need the original data structure and would be forced to regenerate (refacet) the model.

The solution used by ACIS is not to store any facet data directly. Instead, ACIS provides mesh managers with virtual functions that can output the facet data. Enabling application-specific mesh managers to be derived permits an application to redefine the functions, or class methods. In doing so, the application has the ability to store precisely the information it requires directly into its own data structures. In addition, an application can have multiple mesh managers that generate facet data for various purposes. For example, one mesh manager may be used for display and another for generating stereolithography files. The correct mesh manager must be set before faceting.

A mesh manager is a C++ class that is derived from the base class MESH_MANAGER. (For a complete list of MESH_MANAGER methods, refer to the documentation of the MESH_MANAGER class.) The mesh manager's virtual functions are divided into three different protocols. Each protocol represents a group of functions tailored to a commonly used data-storage format. The base MESH_MANAGER class defines numerous virtual member-function stubs that are grouped into these protocols. Derived classes can redefine these functions to switch on the desired protocol. When the Faceter has computed a set of facets, it outputs them according to the protocol specified:

Coordinate Protocol A face mesh is announced polygon-by-polygon. Polygons are output using explicit coordinates. Coordinates are repeated for adjacent polygons.
Indexed Protocol A face mesh is represented by a set of nodes and a set of polygons that reference the nodes. The coordinates of all the nodes in a face mesh is output first, then the polygons, referring to the indices of the node list.
Global-Indexed Protocol Is similar to the indexed protocol; however, it creates a single mesh for an entire body.

The MESH_MANAGER class has a virtual method announce_polygon_model_face to announce the model face from which the polygons are made. Being a virtual function, it works with all mesh managers. The method announces the face once before the polygons are announced. All mesh managers evaluate the coordinates on a node only once, regardless of the number of polygon edges that share that node.

For Indexed and Global-Indexed mesh managers, the general flow of output for each mesh is:

  • The counts,
  • The nodes, and
  • The polygons (the polygons are output node-by-node).

For Coordinate Protocol mesh managers, the general flow of output is simply:

  • The counts, and
  • The polygons (the polygons are output using explicit coordinates).

Since ACIS R21 Coordinate Protocol and Indexed Protocol mesh managers may announce the mesh for a face more than once during a single faceting operation. For more information, refer to Faceting One Face May Re-Facet Adjacent Faces.

For many applications the predefined ACIS Mesh Managers will be sufficient; however, some applications will require a customized mesh manager.

ACIS Mesh Managers

ACIS currently provides seven mesh managers for use by applications. These exemplify the three protocols discussed above.

Coordinate Protocol POLYGON_POINT_MESH_MANAGER and PPM_ON_FACE_MESH_MANAGER.
Indexed Protocol LINKED_MESH_MANAGER, INDEXED_MESH_MANAGER, and SIMPLE_INDEXED_MESH_MANAGER.
Global-Indexed Protocol GLOBAL_MESH_MANAGER and STL_MESH_MANAGER.

Note: In addition to these mesh managers, there is a PE_MESH_MANAGER that is intended for use only by the Interactive Hidden Line Component.


Coordinate Protocol

The POLYGON_POINT_MESH_MANAGER class was used by the obsolete Faceted Hidden Line Component. The PPM_ON_FACE_MESH_MANAGER class, which is derived from POLYGON_POINT_MESH_MANAGER, has one additional overloaded member function to attach the mesh to the owning face. These mesh managers produce the simplest mesh format. They maintain one mesh per face and announce the mesh polygon-by-polygon. The polygons are announced using the xyz coordinates of their nodes. The POLYGON_POINT_MESH created by these mesh managers places its data in a singly-linked, NULL-terminated list. Coordinates are repeated for adjoining facets, which consumes additional memory, but avoids indirect references. The mesh maintains pointers to the first and last polygons as well as the number of polygons in the mesh.

Indexed Protocol

Similar to Coordinate Protocol mesh managers, Indexed Protocol mesh managers produce a separate mesh for each face; however, with Indexed Protocol mesh managers, meshes are announced as a set of nodes and a set of polygons that reference the nodes.

The INDEXED_MESH_MANAGER is used primarily for rendering. It announces (declares) the nodes by their xyz positions. The nodes are first created by the Faceter, then are used to create polygons, and each face receives a mesh based on these polygons. The INDEXED_MESH created by this mesh manager maintains its data in contiguous arrays, thereby minimizing memory fragmentation. It is stored as an array of nodes and a set of polygons defined by the numerical indices of the nodes. In this packed representation, both nodes and polygon are referenced using an index into the array. This is the default ACIS mesh manager, but it is often overridden.

The LINKED_MESH_MANAGER provides access to the facet data using a similar format and provides similar performance, but has a slightly larger memory footprint. It creates a LINKED_MESH, which is derived from a base class, SEQUENTIAL_MESH. The INDEXED_MESH is also derived from the same base class. This mechanism provides an easy transition between the two derived mesh managers. The interface has methods that allow one to traverse either mesh in a sequential fashion. For more information on how to traverse the INDEXED_MESH and LINKED_MESH data structures, refer to Traversing Facet Polygons and Traversing Facet Vertices and Polygons.

As its name suggests the SIMPLE_INDEXED_MESH_MANAGER class, while offering an indexed protocol, does so at the cost of reduced functionality. The SAMPLE_INDEXED_MESH_MANAGER and SAMPLE_INDEXED_MESH classes presented in Creating a Mesh Manager Class are nearly identical to the SIMPLE_INDEXED_MESH_MANAGER and SIMPLE_INDEXED_MESH classes.

Global-Indexed Protocol

The primary distinction of this protocol is in maintaining a single mesh for an entire body, rather than one for each face. Because of this, nodes are not repeated along edges that bound multiple faces. (With Coordinate or Indexed Protocols, nodes are repeated along edges that bound multiple faces. That is, the mesh for each face contains nodes that lie on its bounding edges.) The memory footprint when using the Global-Indexed Protocol is larger than the memory footprint when using either the Coordinate or Indexed Protocols, because the Faceter generates the mesh for the entire body before announcing the nodes and polygons. (With the other two protocols meshing occurs on a face-by-face basis, nodes and polygons are announced on a face-by-face basis, and working memory can be released after the mesh for each face is announced.) Because the Faceter generates the mesh for the entire body before announcing the nodes and polygons, the mesh for a face will never be announced twice. If a face needs to be refaceted as a result of faceting an adjacent face, this will be done before the mesh is announced.

The ACIS GLOBAL_MESH_MANAGER class has no graphics or permanent storage services. The facet data is simply written to the standard output. The same is true of the STL_MESH_MANAGER class, which writes facet data to an STL (stereolithography-formatted) file. An example of an implementation of a Global-Indexed mesh manager is presented in Creating a Mesh Manager Class. Although the predefined GLOBAL_MESH_MANAGER and the above mentioned example do not create and attach a MESH to the faceted body, there is nothing inherent in this protocol that would prohibit an application-derived mesh manager from doing so.

C++ Interface

Mesh manager objects handle the saving and restoring of facet data. If facet information is to be saved by an application, the application must provide a derived class to handle the details.

The mesh manager is set using api_set_mesh_manager, and queried using api_get_mesh_manager.

C++ APIs Description
api_get_mesh_manager Get the mesh manager in use for Faceter operations.
api_set_mesh_manager Set the mesh manager to be used for subsequent Faceter operations.

The following code snippet illustrates the use of api_get_mesh_manager and api_set_mesh_manager with api_facet_entity to facet a list of entities.

void facet_ents( ENTITY_LIST ents )
{
    EXCEPTION_BEGIN
	SAMPLE_INDEXED_MESH_MANAGER * MyMeshManager = NULL;
	MESH_MANAGER * oldMM;
    EXCEPTION_TRY
	// Get the previous mesh manager.
	outcome res = api_get_mesh_manager( oldMM );
 
	// Tell the Faceter to use our SAMPLE_INDEXED_MESH_MANAGER.
	MyMeshManager = ACIS_NEW SAMPLE_INDEXED_MESH_MANAGER();
	res = api_set_mesh_manager( MyMeshManager );
	check_outcome( res );
 
	// Facet all entities in the model.
	ENTITY *ent;
	for ( ents.init(); ent = ents.next(); ) {
	    res = api_facet_entity( ent );
	    check_outcome( res );
	}
 
    EXCEPTION_CATCH_TRUE
	// Delete our mesh manager and restore the old mesh manager.
	if ( MyMeshManager ) {
	    ACIS_DELETE MyMeshManager;
	    MyMeshManager = NULL;
	}
	api_set_mesh_manager( oldMM );
    EXCEPTION_END
}

See Also

Personal tools