Checking and Repairing Mesh Data   

<<< Creating PSM Data From Foreign Facet Data Chapters Filling Holes In Facet Bodies >>>

Contents

[back to top]


86.1 Introduction

You can use the standard checking APIs (PK_BODY_check, PK_GEOM_check, etc.) to find invalidities in a mesh.

In addition, Parasolid provides APIs to find and fix defects in a mesh. Defects include invalidities and additionally other sub-optimal properties of a mesh whose removal may be desirable.

When creating a Parasolid mesh from foreign facet data, you should ensure that the resulting mesh is of good quality by attempting repair on any defects that may exist.

 

Note: It is recommended that any defects present on a mesh are removed prior to adding topology.

This chapter explains how you can use Parasolid functionality to manage defects and invalidities in mesh data.

[back to top]


86.2 Finding and fixing defects in meshes

Parasolid provides two functions to let you look for defects on a mesh, and to attempt to fix defects found, as follows:

 

Function

Description

PK_MESH_find_defects

Examine a mesh for defects and return a structure that contains details of any defects found.

PK_MESH_fix_defects

Examine a mesh for defects, as in PK_MESH_find_defects, and attempt to fix those defects. Return the new meshes created as a result of the repair operation, together with details of any defects still existing in the mesh.

 

Note: PK_MESH_find_defects and PK_MESH_fix_defects work on orphan meshes. To repair meshes that are attached to faces you can use PK_FACE_fix_mesh_defects. For more information on this function, see Section 86.3, “Repairing meshes attached to faces”.

PK_MESH_find_defects returns the number of defects found, together with a PK_MESH_defect_details_t structure that provides details about the types of defects found, the entities affected and position and parameter information.

PK_MESH_fix_defects returns an array of new, repaired meshes, together with an array of PK_MESH_defect_details_t structures (one for each mesh returned), providing details about any defects that remain in that mesh.

These two functions can identify and attempt to fix a diverse range of mesh defects. Examples and a description of each mesh defect type are provided in the following table.

 

Defect type

Description

 

PK_MESH_defect_disjoint_c

The mesh has disjoint components.

 

PK_MESH_defect_foldover_c

Folds occur when the smaller of the two angles between two mfin-adjacent mfacets is less than or equal to the value in radians specified in max_foldover_angle . A foldover is a chain of one or more folds that bound a region of facets whose normals are opposed to those of their neighbours and are within tolerance of the neighbouring facets. The detection of foldovers is carried out either to:

  • session linear precision (default),
  • a linear precision specified using the have_tolerance and tolerance options, or
  • a tolerance specified using the have_height_tolerance and height_tolerance options in the defect_tolerances sub-structure.

 

PK_MESH_defect_flat_mfacet_c

An mfacet of zero area through having a perpendicular height smaller than either:

  • session linear precision (default),
  • a linear precision specified using the have_tolerance and tolerance options, or
  • a tolerance specified using the have_degen_tolerance and degen_tolerance options in the defect_tolerances sub-structure.

 

PK_MESH_defect_degen_mfacet_c

An mfacet with at least one mfin shorter than either:

  • session linear precision (default),
  • a linear precision specified using the have_tolerance and tolerance options, or
  • a tolerance specified using the have_degen_tolerance and degen_tolerance options in the defect_tolerances sub-structure.

A degenerate mfacet is also flat by definition.

 

PK_MESH_defect_slit_c

The mesh contains laminar mfins that the occupy the same position. The detection of coincident laminar mfins is carried out either:

  • to session linear precision (default),
  • to a linear precision specified using the have_tolerance and tolerance options, or
  • to a tolerance specified using the have_slit_tolerance and slit_tolerance options in the defect_tolerances sub-structure.

 

PK_MESH_defect_self_int_c

The mesh contains intersecting mfacets.

 

PK_MESH_defect_non_manifold_c

The mesh is non-manifold.

 

PK_MESH_defect_mvertex_normal_c

The mesh has an mvertex with an incorrect normal direction.

Corrupted mesh

PK_MESH_defect_corrupt_c

The mesh’s data structure is corrupt.

See PK_MESH_find_defects_o_t and PK_MESH_fix_defects_o_t for more detail about individual options.

 

Note: PK_MESH_fix_defects will have no effect on corrupt meshes or mvertices with bad mvertex normals.

If a mesh component containing slit defects (interior laminar mfins) is used to create a facet body, the resulting body will have non-boundary edges sat within faces, which are formed along the laminar mfins. These edges may be avoided if the mesh is repaired prior to creating bodies.

An mvertex has a bad normal when the normal at the mvertex points towards the mesh and not away from it as shown in Figure 86-1. In cases where an mvertex has multiple normals, the mesh is deemed to have a bad normal when at least one of the normals at the mvertex points into the mesh.

 

Figure 86-1 Examples of good and bad normals at an mvertex of a mesh (shown in cross-section)

Bad mvertex normals on a mesh can be addressed by discarding the existing mvertex normals and allowing Parasolid to assign new ones dynamically. This can be achieved using PK_MESH_store_normals, ensuring that the replace option is set to PK_MESH_replace_normal_mtopol_c, and the mvertices with bad normals are supplied in the mtopols array. See Chapter 88.3.2, “Managing mvertex normals”, for more information.

 

Note: PK_MESH_fix_defects may introduce new defects into the fixed meshes returned.

[back to top]


86.3 Repairing meshes attached to faces

You can perform a limited range of repairs on meshes that are attached to faces using PK_FACE_fix_mesh_defects. The returned tracking records contain the original faces, the mesh attached to each face, and the repaired mesh for all faces whose meshes were edited.

The amount of modification that Parasolid can make when fixing mesh defects can be controlled by the following options:

 

Option

Description

have_max_deviation

Whether a max_deviation value is provided.

max_deviation

This value is the largest distance that the repaired mesh will be deformed from the original.

Setting a max_deviation will allow Parasolid to carry out a greater level of repair, where possible, by altering the shape of the mesh, such that any point on the new mesh won’t be more than max_deviation distance away from the original mesh. The requirements of your application should therefore be taken into consideration when setting a max_deviation , to ensure that resulting changes to the shape of the mesh would be suitable for your application. Typically, if you specify a modelling tolerance in other operations, you should use the same value here.

See the API documentation for PK_FACE_fix_mesh_defects for more information.

[back to top]


86.4 Checking meshes

In addition to finding and fixing mesh defects, you can check for invalidity in mesh data using the standard checking APIs.

You can use PK_BODY_check and PK_FACE_check to check meshes using the mesh option, which can be set as follows:

 

Value

Description

PK_check_mesh_no_c

Do not perform mesh invalidity checks.

PK_check_mesh_basic_c

Perform basic mesh invalidity checks, as follows:

  • A mesh cannot be non-manifold.
  • A mesh cannot have an mfacet with a zero length mfin (degenerate mfacet).
  • A mesh cannot have an mfacet of zero area (flat mfacet).
  • A mesh cannot have an mvertex normal that is opposed to all adjacent mfacet normals.
  • A mesh that is attached to a face must not be disjoint.
  • A mesh that is attached to a face must have all its boundary mfins along each edge of that face matched to the segments of any polyline attached to the edge.

PK_check_mesh_yes_c

Perform the same checks as PK_check_mesh_basic_c, and also check for the following:

  • A mesh cannot have slits (laminar mfins that occupy the same position).
  • A mesh cannot self-intersect.

This is the default.

PK_GEOM_check can check meshes without specifying any additional options. Instead, it uses the geom option to determine how to examine the given geometry, whether it is classic B-rep or facet geometry.

PK_FACE_check_pair can also be used to check for face-face clashes between pairs of faces that have facet geometry attached.

Please see Chapter 30, “Checking”, for more information on those APIs.

[back to top]

<<< Creating PSM Data From Foreign Facet Data Chapters Filling Holes In Facet Bodies >>>