Creating PSM Data From Foreign Facet Data   

<<< Converting Between Facet and Classic Geometry Chapters Checking and Repairing Mesh Data >>>

Contents

[back to top]


85.1 Introduction

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”.

[back to top]


85.2 Received and returned arguments

PK_MESH_create_from_facets receives the following arguments:

 

Option

Description

facet_reader

A user-defined callback function.See Section 85.4, “Using the facet reader”, for more information.

context

A pointer to the user supplied data input to facet_reader

options

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.

[back to top]


85.3 Option structure

This function takes the following options:

 

Option

Description

vertices_estimate

Estimate of the total number of vertices returned by all calls to facet_reader . If a mesh has a large number of vertices, vertices_estimate can improve efficiency by limiting the number of times the data is copied.

Default: 0

facet_estimate

Estimate of the total number of facets returned by all calls to facet_reader .

If a mesh has a large number of facets, facet_estimate can improve efficiency by limiting the number of times the data is copied.

Default: 0

facet_free

Function to free data blocks returned by facet_reader . These blocks can be one of four types; index, strip, fan and vector. See Section 85.4.1, “Facet types”, for more informations.

Default: NULL

create

Whether the facet_reader callback function is called either:

  • Immediately, to create facets of a mesh (PK_MESH_create_now_c) or
  • At a later time, when the facets are required by a Parasolid operation (PK_MESH_create_later_c). If a mesh is created at a later time, a bounding box should be supplied.

The facets are required by a Parasolid operation when:

Default: PK_MESH_create_now_c

have_box

Whether box is supplied.

Default: PK_LOGICAL_false

box

The bounding box of the mesh when have_box is PK_LOGICAL_true.

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 box will be used.

When a mesh has been created the box will be compared with the calculated box of the mesh. If Parasolid finds that the box is not a bounding box of the mesh an error will be raised.

thread_safe

Whether the facet_reader callback and the facet_free callback (if supplied) are thread safe.

Default: PK_LOGICAL_false

[back to top]


85.4 Using the facet reader

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.

85.4.1 Facet types

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.

85.4.1.1 Index mesh

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

85.4.1.2 Strip 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

85.4.1.3 Fan 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

85.4.1.4 Vector 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

85.4.1.5 Mixed mesh example

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

 

[back to top]

<<< Converting Between Facet and Classic Geometry Chapters Checking and Repairing Mesh Data >>>