Home > User Guide > Display and User Input > Faceting
Mesh Managers
The way facets are 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. Applications rarely use everything output by the faceter, anyway. If provided a huge data structure, applications would typically extract what they need and discard the original data structure to save on storage. Saving storage space might 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 was not to store any facet data directly. Instead, ACIS provides mesh managers with simple virtual functions that can output the facet data. Deriving application specific mesh managers permits an application to redefine the functions, or class methods. In doing so, an application has the ability to store the information it requires directly into its own structures. 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 has to be set before faceting.
A mesh manager is simply 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 managers virtual functions are divided into three different protocols. Each protocol represents a group of functions tailored for a commonly used data storage format.
The base MESH_MANAGER class defines numerous virtual member functions stubs that are grouped into 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
- Outputs the polygon vertices as explicit coordinates.
Indexed Protocol- First outputs the list of coordinates of all the vertices in a face mesh, then outputs the polygon vertices as indices referring to items of this list.
Global Indexed Protocol- Is similar to the indexed protocol, but considers the entire body as a single mesh.
The MESH_MANAGER 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.
The general flow of output is:
- The counts.
- The nodes.
- The edges.
- The polygons for each mesh. The polygons are output node by node.
ACIS provides three main mesh managers: INDEXED_MESH_MANAGER, LINKED_MESH_MANAGER, and POLYGON_POINT_MESH_MANAGER.
The INDEXED_MESH_MANAGER is used primarily for rendering. It announces (declares) the nodes by their xyz positions. The nodes are created by the faceter. The nodes are used to create polygons. Each face receives a mesh based on the polygons. The INDEXED_MESH created by this mesh manager places its data in contiguous arrays, thereby minimizing memory fragmentation. It is stored as an array of nodes and a set of polygons defined by numerical indices. In this packed representation, both nodes and polygon are referenced using an index into the array.
The LINKED_MESH_MANAGER provides an interface to the faceters data that improves the speed of faceting. It and the INDEXED_MESH_MANAGER are derived from a base class, SEQUENTIAL_MESH_MANAGER. This was done to provide an easier transition between the two mesh managers. The current interface has methods that allow one to traverse the mesh in a sequential fashion. In the near future, interfaces may be added to the LINKED_MESH to allow one to quickly visit neighboring facets or coedges.
The POLYGON_POINT_MESH_MANAGER is used primarily by the obsolete Faceted Hidden Line Component. It announces its mesh polygon by polygon. The polygons are announced based on the xyz coordinates of their nodes created by the faceter. The POLYGON_POINT_MESH created by this mesh manager places its data in a singly linked, NULL terminated list. The mesh maintains pointers to the first and last polygons as well as the number of polygons in the mesh. The Polygon Point Mesh Manager calculates the node information once and stores it for future use.
Another mesh manager: GLOBAL_INDEX_MESH_MANAGER, declares a single mesh for the entire body instead of a mesh for each face. It has no graphics or permanent storage services. The mesh is written to the standard output.
The mesh manager can be specified when faceting is initialized with the function api_initialize_faceter. Or, after initialization, the mesh manager can be specified with the function api_set_mesh_manager.
Vertex Templates
A vertex template enables applications to request the mesh manager to attach data to the nodes of a mesh, if the mesh manager is designed to handle the request. The data, which is defined with the class VERTEX_TEMPLATE, includes:
- Coordinate data
- Surface normal
- uv parameter
- Partial derivatives and their magnitude
- RGB color
- Transparency
- Texture
- Pointer to user defined data
Indexed (non-global) and coordinate mesh managers create meshes on a face basis. Therefore, they can be designed to attach vertex template data to the nodes. Because global indexed mesh managers share node data between faces, they cannot store face related information such as attached vertex template data.
The VERTEX_TEMPLATE is typically used from a customized mesh manager. The template defines the information of importance from a mesh node. The template itself is stored in the save file, but not the resulting VERTEX_TEMPLATE instances for each node of the mesh. In other words, if a template is defined, then when the mesh is generated, a template for each node is filled out with information. When the mesh itself goes away, either because the owning entity was deleted or because the application was terminated, the individual templates go away. If the entity is saved to the save file, its refinements and master vertex template are saved as well. The mesh and the information in each individual vertex template are recreated from the entity, refinements, and master template when restored from the save file.
Related topics:
Refinements
The Faceting Algorithm
Step-by-Step Faceting
Discarding or Keeping Facet Data
Faceting Functions and Classes
Faceting Using Scheme[Top]
© 1989-2007 Spatial Corp., a Dassault Systèmes company. All rights reserved.