meshmagick.mesh_clipper module

This module holds a tools to clip meshes against a plane

class meshmagick.mesh_clipper.MeshClipper(source_mesh, plane=<meshmagick.mesh.Plane object>, vicinity_tol=0.001, assert_closed_boundaries=False, verbose=False)[source]

Bases: object

A class to perform mesh clipping operations.

Parameters
  • source_mesh (Mesh) – The mesh to be clipped.

  • plane (Plane, optional) – The clipping plane. By default, the plane is the Oxy plane.

  • vicinity_tol (float, optional) – The absolute tolerance to consider en vertex is on the plane. Default is 1e-3.

  • assert_closed_boundaries (bool, optional) – False by default. When True, the mesh clipper will raise an exception if intersections with the clipping plane are not closed. It may be caused by a non-watertight mesh.

  • verbose (bool, optional) – False by default. If True, some messages on operations that are handled are printed.

property assert_closed_boundaries

Do we assert the boundaries have to be closed

assert_closed_boundaries_off()[source]

Switches OFF the flag for closed boundary assertion while clipping.

assert_closed_boundaries_on()[source]

Switches ON the flag for closed boundary assertion while clipping.

property clipped_crown_mesh

A new mesh that is obtained by clipping the crown_mesh.

Returns

Return type

Mesh

property clipped_mesh

The resulting clipped mesh

property closed_polygons

Returns the list of closed boundary polygons obtained after clipping.

This is a list of lists. The enclosed lists are ordered IDs list that form a closed polygon, described in the counter-clockwise order with respect to the mesh (oriented following the clipping plane’s normal).

Returns

Return type

list

Warning

  • The first vertex is repeated at the end of the list. By definition, these polygons are lying on the clipping plane.

  • Vertices IDs are corresponding to the IDs of the clipped_crown_mesh, not those of the clipped_mesh.

property closed_polygons_vertices

Returns the list of closed boundary polygons obtained after clipping.

This is a list of lists. The enclosed lists are ordered vertices coordinates of the closed polygons. By definition, these polygons are lying on the clipping plane.

Returns

Return type

list

property crown_mesh

A new mesh only having the faces that cut the plane

Returns

Return type

Mesh

property lower_mesh

A new mesh composed of the faces that entirely lie under the clipping plane.

Returns

Return type

Mesh

property nb_closed_polygons

The number of closed polygons obtained after clipping

Returns

Return type

int

property nb_open_lines

The number of open lines obtained after clipping.

Returns

Return type

int

property open_lines

Returns a list of open boundary lines obtained after clipping.

This is a list of lists. The enclosed lists are ordered vertices IDs.

Returns

Return type

list

Warning

  • The vertices IDs correspond to the IDs of clipped_crown_mesh, not clipped_mesh.

property open_lines_vertices

Returns a list of open boundary lines obtained after clipping.

This is a list of lists. The enclosed lists are ordered vertices IDs.

Returns

Return type

list

property plane

The clipping plane

property source_mesh

The mesh we work with

property upper_mesh

A new mesh only having the faces lying entirely up the plane

Returns

Return type

Mesh

property verbose

Get the current verbosity

verbose_off()[source]

Switches OFF the verbosity of the clipper.

verbose_on()[source]

Switches ON the verbosity of the clipper.

property vicinity_tol

Vicinity tolerance.

It tells if a point is close enough to the plane to consider it lies on the plane