Mesh

class Mesh

Bases: CommonBaseModel

Represents a 3D mesh, a collection of polygons (typically triangles or quadrilaterals) used to model the surface of a 3D object.

Meshes are fundamental in computer graphics, engineering simulations, and geometric modeling, allowing for the detailed representation of complex 3D shapes. This class facilitates the construction, manipulation, and analysis of mesh geometries, supporting applications in visualization, physical simulation, and more.

polylines

A collection of polylines defining the mesh.

Type:

List[Polyline]

metadata

Additional metadata for the mesh.

Type:

Metadata

Attributes Summary

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Methods Summary

add_polyline(polyline)

Add a new polyline object to the mesh, expanding its geometry.

calculate_volume()

Calculate the volume enclosed by the mesh.

remove_polyline(index)

Remove a polyline from the mesh at the specified index.

validate_polylines(value)

Validate the 'polylines' list to ensure it contains at least one polyline.

Attributes Documentation

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow', 'protected_namespaces': (), 'validate_assignment': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Methods Documentation

add_polyline(polyline)

Add a new polyline object to the mesh, expanding its geometry.

Parameters:

polyline (Polyline) – The new polyline to be added to the mesh.

Return type:

None

calculate_volume()

Calculate the volume enclosed by the mesh.

This method uses the tetrahedron decomposition algorithm to compute the volume enclosed by the mesh geometry.

Returns:

The calculated volume of the mesh.

Return type:

float

remove_polyline(index)

Remove a polyline from the mesh at the specified index.

Parameters:

index (int) – The index of the polyline to be removed.

Raises:

IndexError – If the specified index is out of range.

Return type:

None

classmethod validate_polylines(value)

Validate the ‘polylines’ list to ensure it contains at least one polyline.

Parameters:

value (List[Polyline]) – The list of polylines being validated.

Returns:

The validated list of polylines.

Raises:

ValueError – If the list is empty.

Return type:

List[Polyline]

Methods:

validate_polylines(value)

Validate the 'polylines' list to ensure it contains at least one polyline.

add_polyline(polyline)

Add a new polyline object to the mesh, expanding its geometry.

remove_polyline(index)

Remove a polyline from the mesh at the specified index.

calculate_volume()

Calculate the volume enclosed by the mesh.

Attributes:

__pydantic_setattr_handlers__

__setattr__ handlers.

classmethod validate_polylines(value)

Validate the ‘polylines’ list to ensure it contains at least one polyline.

Parameters:

value (List[Polyline]) – The list of polylines being validated.

Returns:

The validated list of polylines.

Raises:

ValueError – If the list is empty.

Return type:

List[Polyline]

add_polyline(polyline)

Add a new polyline object to the mesh, expanding its geometry.

Parameters:

polyline (Polyline) – The new polyline to be added to the mesh.

Return type:

None

remove_polyline(index)

Remove a polyline from the mesh at the specified index.

Parameters:

index (int) – The index of the polyline to be removed.

Raises:

IndexError – If the specified index is out of range.

Return type:

None

calculate_volume()

Calculate the volume enclosed by the mesh.

This method uses the tetrahedron decomposition algorithm to compute the volume enclosed by the mesh geometry.

Returns:

The calculated volume of the mesh.

Return type:

float

__pydantic_setattr_handlers__: ClassVar[Dict[str, Callable[[BaseModel, str, Any], None]]] = {}

__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__