Skip to content

Geometrical objects

Geometrical objects in the implicit lab are stored using the mouette library, which are either:

Volume meshes are not supported for now.

In addition to the capabilities of mouette classes, each geometrical object is assigned a GeometryType attribute:

GeometryType

Bases: Enum

Enumeration of the kinds of geometrical objects handled by the library.

A GeometryType attribute .type is automatically assigned to every geometrical object loaded by the library. It specifies the nature of the object (point cloud, polyline or surface mesh) and the dimension of its ambient space (2D or 3D). Algorithms access this type to determine if it makes sense to apply a given processing to a given type.

Attributes:

Name Type Description
POINT_CLOUD_2D

a set of points in the plane.

POINT_CLOUD_3D

a set of points in space.

POLYLINE_2D

a set of points connected by edges in the plane (typically a closed curve).

POLYLINE_3D

a set of points connected by edges in space.

SURFACE_MESH_2D

a planar surface mesh.

SURFACE_MESH_3D

a surface mesh in space.

dim property

Dimension of the ambient space of the geometry type.

Returns:

Name Type Description
int int

2 for planar geometries, 3 for geometries embedded in space.

of_geometry_data(geom) classmethod

Infers the geometry type of a mesh object from its class and the dimensionality of its vertex coordinates.

Note

A 3D object whose vertices all lie in a plane (for instance with a constant z coordinate) will be converted to a 2D object.

Parameters:

Name Type Description Default
geom Mesh

the geometrical object. Should be a PointCloud, a PolyLine or a SurfaceMesh.

required

Raises:

Type Description
Exception

if the type of the object or its dimensionality is not supported.

Returns:

Name Type Description
GeometryType

the type of the geometrical object.

Geometry utilities

extract_boundary_polyline_from_2D_mesh(geometry)

Converts a SURFACE_MESH_2D into a POLYLINE_2D geometrical object by extracting its boundary polyline.

If the geometry type is not SURFACE_MESH_2D, this function does nothing.

Parameters:

Name Type Description Default
geometry Mesh

the input geometry.

required

Returns:

Name Type Description
geometry Mesh

The extracted boundary polyline if the input geometry type was SURFACE_MESH_2D. Otherwise, returns the unmodified input geometry.

load_geometry(file_path)

Loads a geometrical object from a file on the disk. The created object is a mouette mesh type. See the documentation of mouette for further information.

Note

By convention:
- The geometry object is normalized so that it fits the unit box [-1, 1]^d (where d is its dimension).
- All surface meshes are triangulated at import

Parameters:

Name Type Description Default
file_path str

path to the file. Supported formats are .obj, .mesh, .stl, .xyz and .geogram_ascii

required

Returns:

Type Description

mouette.mesh.Mesh: a geometry object (whose type depend on what's been read from the file). Can be a PointCloud, a Polyline or a SurfaceMesh.

sample_geometry_with_normals(geometry, n_pts)

Samples a geometrical object uniformly.

Parameters:

Name Type Description Default
geometry Mesh

the geometry to sample from

required
n_pts int

number of points to sample

required

Returns:

Type Description

np.ndarray: array of size (n_pts, dim) containing the points

np.ndarray: array of size (n_pts, dim) containing the normals

Raises:

Type Description
Exception

fails if the provided geometry is not a 3D surface mesh or a 2D polyline

sample_unit_disk(n_pts)

Samples n_pts points uniformly inside the disk of center 0 and radius 1

Parameters:

Name Type Description Default
n_pts int

number of points to sample

required

Returns:

Type Description

np.ndarray: array of size (n_pts, 2) containing the sampled points.