![]() |
Creating PSM Data From Foreign Facet Data |
<<< Converting Between Facet and Classic Geometry | Chapters | Checking and Repairing Mesh Data >>> |
Parasolid provides the function PK_MESH_create_from_facets to allow you to import foreign facet data and create meshes using the PSM mesh format. These meshes can then be stored in
.xmm
files alongside the
.xmt
files used to store the model data, or embedded in the XT data itself. PK_MESH_create_from_facets also enables you to choose whether to create facets of newly created meshes immediately, or delay their creation until they are required by a Parasolid operation.
When a mesh is created from foreign data an application should ensure the result is of good quality; see Chapter 86, “Checking and Repairing Mesh Data”, for more information.
This chapter covers the creation of facet bodies from foreign mesh data. For information on creating facet bodies from classic bodies see Chapter 84, “Converting Between Facet and Classic Geometry”.
PK_MESH_create_from_facets receives the following arguments:
A user-defined callback function.See Section 85.4, “Using the facet reader”, for more information. |
|
These are described in more detail in Section 85.3, “Option structure” |
It creates and returns a mesh using the data from the received arguments.
This function takes the following options:
Estimate of the total number of vertices returned by all calls to |
|
Estimate of the total number of facets returned by all calls to
If a mesh has a large number of facets, |
|
Function to free data blocks returned by |
|
Whether the
The facets are required by a Parasolid operation when:
Default: PK_MESH_create_now_c |
|
The bounding box of the mesh when
If a mesh is to be created at a later time and a Parasolid operation requires the box of the mesh, the mesh will not be created and the supplied
When a mesh has been created the |
|
Whether the |
This section describes how the callback function,
facet_reader
, is used to create PSM meshes from facet data. The
facet_reader
takes a block of user supplied
context
information and returns a block of mesh data and a return status. The block of mesh data can be one of four types; index, strip, fan, and vector or a mix of these types. See Section 85.4.1, “Facet types” for more information.The return status indicates the state of the operation. The
facet_reader
is called repeatedly by PK_MESH_create_from_facets until it returns the status PK_MESH_cb_status_stop_c.
This section describes the four types of data blocks (index, strip, fan, and vector) that can be returned by each call to
facet_reader
.
For examples of this functionality using each of the four data block types, see the code examples in the
C++\Code Examples\Facet Examples\Mesh Creation
folder, located in
example_applications
in your Parasolid installation folder.
This structure contains the data for a facet index block of mesh data. The
facet_indices
array contains a single list of the
vertex_positions
indices which define the vertices of facets of the mesh. This array must have a length that is a multiple of 3.
The following pseudo-code example shows the data input when using PK_MESH_facet_type_index_t to transmit a block of facet index data.
Figure 85-1 illustrates this pseudo-code example. In the illustration,
fX represents values in
facet_indices
and
vX represents values in
vertex_positions
.
is_relative_index:PK_LOGICAL_true n_vertex_positions = 7 vertex_positions = {v0,v1,v2,v3,v4,v5,v6} vertex_normals = null n_facet_indices = 18 facet_indices = {0,1,2,1,3,2,1,4,3,0,5,1,5,6,1,6,4,1} status = PK_MESH_cb_status_stop_c |
Figure 85-1 Example of an index mesh
This mesh describes a set of connected triangles that share vertices. The data is a collection of facets described by
strip_indices
.
The following pseudo-code example shows the data input when using PK_MESH_facet_strip_t to transmit a block of facet triangle strip data.
Figure 85-2 illustrates this pseudo-code example. In the illustration,
vX represents values in
vertex_positions
and the arrows represent the direction of
strip_indices
. The triangle strip returned in call zero is coloured blue and the triangle strip returned in call one is coloured red.
<--Call zero returns--> is_relative_index:PK_LOGICAL_true n_vertex_positions = 7 vertex_positions = {v0,v1,v2,v3,v4,v5,v6} vertex_normals = null n_strip_indices = 5 strip_indices = {0,2,1,3,4} status = PK_MESH_cb_status_continue_c <--Call one returns--> is_relative_index:PK_LOGICAL_false n_vertex_positions = 0 vertex_positions = null vertex_normals = null n_strip_indices = 5 strip_indices = {4,6,1,5,0} status = PK_MESH_cb_status_stop_c |
Figure 85-2 Example of a triangle strip mesh
This mesh describes a set of connected triangles that share one central vertex. The data is a sequence of facets described by
fan_indices
.
The following pseudo-code example shows the data input when using PK_MESH_facet_fan_t to transmit a block of facet fan data.
Figure 85-3 illustrates this pseudo-code example. In the illustration
vX represents values in
vertex_positions
and the arrows represent the direction of
fan_indices
.
is_relative_index:PK_LOGICAL_true n_vertex_positions =7 vertex_positions = {v0,v1,v2,v3,v4,v5,v6} vertex_normals = null n_fan_indices = 8 fan_indices = {1,4,3,2,0,5,6,4} status = PK_MESH_cb_status_stop_c |
Figure 85-3 Example of a fan mesh
This structure contains the data for an independent facet block of mesh data. It describes each facet as a triple of vertex positions.
The following pseudo-code example shows the data input when using PK_MESH_facet_vector_t to transmit a block of independent facet data.
Figure 85-4 illustrates this pseudo-code example. In the illustration,
fX represents values in
n_vertex_positions
and
vX represents values in
vertex_positions
.
n_vertex_positions = 18 vertex_positions = {v0,v1,v2,v1,v3,v2,v1,v4,v3,v0,v5,v1,v1,v5,v6,v4,v1,v6} vertex_normals = null status = PK_MESH_cb_status_stop_c |
Figure 85-4 Example of a vector mesh
The following pseudo-code example shows the data returned to read a mixture of data blocks from different calls to
facet_reader
.
Figure 85-5 illustrates this pseudo-code example.
<--Call zero returns--> facet_type: PK_MESH_facet_type_strip_c is_relative_index:PK_LOGICAL_true n_vertex_positions = 5 vertex_positions = {v0,v1,v2,v3,v4} vertex_normals = null n_strip_indices = 5 strip_indices = {0,2,1,3,4} status = PK_MESH_cb_status_continue_c <--Call one returns--> facet_type: PK_MESH_facet_type_vector_c n_vertex_positions = 9 vertex_positions = {v1,v5,v6,v4,v1,v6,v0,v5,v1} vertex_normals = null status = PK_MESH_cb_status_stop_c |
Figure 85-5 Example of a mixed mesh
<<< Converting Between Facet and Classic Geometry | Chapters | Checking and Repairing Mesh Data >>> |