lagrange.core¶
Module Contents¶
Classes¶
Attribute data associated with mesh elements (vertices, facets, corners, edges). |
|
Policy for remapping invalid values when casting to a different value type |
|
Policy for copying attribute that is a view of an external buffer |
|
Attribute creation policy |
|
Policy for deleting attributes with reserved names |
|
Attribute element type |
|
Policy for exporting attribute that is a view of an external buffer |
|
Attribute growth policy (for external buffers) |
|
Attribute shrink policy (for external buffers) |
|
Attribute usage type |
|
Policy for attempting to write to read-only external buffer |
|
Centroid weighting type. |
|
Mesh connectivity type |
|
Distortion metric. |
|
Options for computing facet area. |
|
Facet centroid options. |
|
Facet normal computation options. |
|
Indexed attribute data structure. |
|
Mapping policy for handling collisions. |
|
Options for computing mesh area. |
|
Mesh centroid options. |
|
Metadata dict of the mesh |
|
Normal computation options. |
|
Normal weighting type. |
|
Options for remapping vertices. |
|
Surface mesh data structure |
|
Tangent bitangent options |
|
Tangent bitangent result |
|
Options for computing vertex normals |
|
Vertex valence options |
Functions¶
|
Cast an attribute to a new dtype. |
|
Close small holes in a mesh. |
|
Combine a list of meshes into a single mesh. |
|
Compute connected components. |
|
Compute dihedral angles for each edge. |
|
Compute Dijkstra distance from a seed facet. |
|
Compute edge lengths. |
|
Compute the Euler characteristic. |
Compute facet area (Pythonic API). |
|
Compute facet centroid (Pythonic API). |
|
|
Compute facet circumcenter (Pythonic API). |
Compute facet normal (Pythonic API). |
|
|
Compute facet vector area (Pythonic API). |
|
Compute greedy coloring of mesh elements. |
Compute mesh area (Pythonic API). |
|
Compute mesh centroid (Pythonic API). |
|
|
Compute the covariance matrix of a mesh w.r.t. a center (Pythonic API). |
Compute indexed normal attribute (Pythonic API). |
|
|
Compute principal components of a point cloud. |
|
Compute seam edges for a given indexed attribute. |
Compute tangent and bitangent vector attributes (Pythonic API). |
|
|
Compute UV charts. |
|
Compute UV distortion. |
Compute vertex normal (Pythonic API). |
|
Compute vertex valence); |
|
|
Detect degenerate facets in a mesh. |
|
Extract boundary edges from a mesh. |
|
Extract boundary loops from a mesh. |
|
Extract the isoline of an implicit function defined on the mesh vertices/corners. |
|
Extract a submesh based on the selected facets. |
|
Filters the attributes of mesh according to user specifications. |
|
Check if the mesh is closed. |
|
Check if the mesh is edge manifold. |
|
Check if the mesh is manifold. |
|
Check if the mesh is oriented. |
|
Check if the mesh is vertex manifold. |
Map an attribute to a new element type. |
|
Map an attribute to a new element type in place. |
|
|
Normalize a mesh to fit into a unit box centered at the origin. |
|
Normalize a mesh to fit into a unit box centered at the origin. |
|
Normalize a mesh to fit into a unit box centered at the origin. |
|
Normalize a list of meshes to fit into a unit box centered at the origin. |
|
Normalize a mesh to fit into a unit box centered at the origin. |
|
Normalize a mesh to fit into a unit box centered at the origin. |
|
Orient mesh facets to ensure positive or negative signed volume. |
|
Reorder facets of a mesh in place based on a permutation. |
|
Reorder vertices of a mesh in place based on a permutation. |
Remap vertices of a mesh in place based on a permutation (Pythonic API). |
|
|
Remove degenerate facets from a mesh. |
|
Remove duplicate facets from a mesh. |
|
Remove duplicate vertices from a mesh. |
|
Remove isolated vertices from a mesh. |
|
Remove facets with unsigned facets area <= null_area_threhsold. |
|
Remove short edges from a mesh. |
Remove topologically degenerate facets such as (0,1,1). |
|
|
Reorder a mesh in place. |
|
Rescale UV charts to match their 3D aspect ratios. |
|
Resolve both vertex and edge nonmanifoldness in a mesh. |
Resolve vertex non-manifoldness in a mesh. |
|
|
Select facets by normal similarity (Pythonic API). |
|
Select facets in a frustum (Pythonic API). |
|
Extract a set of submeshes based on connected components. |
|
Extract a set of submeshes based on facet groups. |
|
Split mesh facets based on a material attribute. |
|
Split edges longer than max_edge_length. |
|
Thicken a mesh by offsetting it, and close the shape into a thick 3D solid. |
|
Apply affine transformation to a mesh. |
|
Triangulate polygonal facets of the mesh. |
|
Trim a triangle mesh by an isoline. |
Unify the index buffer for selected attributes. |
|
|
Extract a UV mesh reference from a 3D mesh. |
|
Extract a UV mesh view from a 3D mesh. |
|
Weld indexed attribute. |
Attributes¶
- class lagrange.core.Attribute¶
Attribute data associated with mesh elements (vertices, facets, corners, edges).
- property cast_policy: AttributeCastPolicy¶
Policy for casting the attribute to different types.
- Return type:
- property copy_policy: AttributeCopyPolicy¶
Policy for copying the attribute.
- Return type:
- property data: numpy.typing.NDArray¶
Raw data as a numpy array.
- Return type:
numpy.typing.NDArray
- property default_value: object¶
Default value for new elements.
- Return type:
object
- property dtype: type | None¶
NumPy dtype of the attribute values.
- Return type:
type | None
- property element_type: AttributeElement¶
Element type (Vertex, Facet, Corner, Edge, Value).
- Return type:
- property external: bool¶
Check if the attribute wraps external data.
- Return type:
bool
- property growth_policy: AttributeGrowthPolicy¶
Policy for growing the attribute when elements are added.
- Return type:
- property num_channels: int¶
Number of channels per element.
- Return type:
int
- property num_elements: int¶
Number of elements in the attribute.
- Return type:
int
- property readonly: bool¶
Check if the attribute is read-only.
- Return type:
bool
- property shrink_policy: AttributeShrinkPolicy¶
Policy for shrinking the attribute when elements are removed.
- Return type:
- property usage: AttributeUsage¶
Usage type (Position, Normal, UV, Color, etc.).
- Return type:
- property write_policy: AttributeWritePolicy¶
Policy for write operations on the attribute.
- Return type:
- clear()¶
Remove all elements from the attribute.
- Return type:
None
- create_internal_copy()¶
Create an internal copy if the attribute wraps external data.
- Return type:
None
- empty()¶
Check if the attribute has no elements.
- Return type:
bool
- insert_elements(num_elements: int) None¶
- insert_elements(tensor: object) None
Insert new elements to the attribute.
- Parameters:
tensor – A tensor with shape (num_elements, num_channels) or (num_elements,).
- reserve_entries(num_entries)¶
Reserve enough memory for num_entries entries.
- Parameters:
num_entries (int) – Number of entries to reserve. It does not need to be a multiple of num_channels.
- Return type:
None
- class lagrange.core.AttributeCastPolicy(*args, **kwds)¶
Bases:
enum.EnumPolicy for remapping invalid values when casting to a different value type
- DoNotRemapInvalid = 2¶
Do not remap invalid values. They are simply static_cast<> to the target type
- RemapInvalidAlways = 1¶
Always remap invalid values from source type to target type, regardless of AttributeUsage
- RemapInvalidIndices = 0¶
Map invalid values only if the AttributeUsage represents indices
- class lagrange.core.AttributeCopyPolicy(*args, **kwds)¶
Bases:
enum.EnumPolicy for copying attribute that is a view of an external buffer
- CopyIfExternal = 0¶
Copy attribute to internal buffer
- ErrorIfExternal = 2¶
Error if external buffer is used
- KeepExternalPtr = 1¶
Keep external buffer pointer
- class lagrange.core.AttributeCreatePolicy(*args, **kwds)¶
Bases:
enum.EnumAttribute creation policy
- ErrorIfReserved = 0¶
Default policy, error if attribute name is reserved
- Force = 1¶
Force create attribute even if name is reserved
- class lagrange.core.AttributeDeletePolicy(*args, **kwds)¶
Bases:
enum.EnumPolicy for deleting attributes with reserved names
- ErrorIfReserved = 0¶
Disallow deletion (default)
- Force = 1¶
Force delete attribute
- class lagrange.core.AttributeElement¶
Bases:
enum.IntEnumAttribute element type
- Corner = 8¶
Per-corner attribute
- Edge = 4¶
Per-edge attribute
- Facet = 2¶
Per-facet attribute
- Indexed = 32¶
Indexed attribute
- Value = 16¶
Value attribute not attached to any mesh elements
- Vertex = 1¶
Per-vertex attribute
- class lagrange.core.AttributeExportPolicy(*args, **kwds)¶
Bases:
enum.EnumPolicy for exporting attribute that is a view of an external buffer
- CopyIfExternal = 0¶
Copy attribute to internal buffer
- CopyIfUnmanaged = 1¶
Copy attribute to internal buffer if the external buffer is unmanaged (i.e. not reference counted)
- ErrorIfExternal = 3¶
Error if external buffer is used
- KeepExternalPtr = 2¶
Keep external buffer pointer
- class lagrange.core.AttributeGrowthPolicy(*args, **kwds)¶
Bases:
enum.EnumAttribute growth policy (for external buffers)
- AllowWithinCapacity = 1¶
Allow growth as long as it is within the capacity of the external buffer
- ErrorIfExtenal = 0¶
Disallow growth if external buffer is used (default)
- SilentCopy = 3¶
Silently copy attribute to internal buffer when growth exceeds external buffer capacity
- WarnAndCopy = 2¶
Warn and copy attribute to internal buffer when growth exceeds external buffer capacity
- class lagrange.core.AttributeShrinkPolicy(*args, **kwds)¶
Bases:
enum.EnumAttribute shrink policy (for external buffers)
- ErrorIfExternal = 0¶
Disallow shrink if external buffer is used (default)
- IgnoreIfExternal = 1¶
Ignore shrink if external buffer is used
- SilentCopy = 3¶
Silently copy attribute to internal buffer when shrinking below external buffer capacity
- WarnAndCopy = 2¶
Warn and copy attribute to internal buffer when shrinking below external buffer capacity
- class lagrange.core.AttributeUsage(*args, **kwds)¶
Bases:
enum.EnumAttribute usage type
- Bitangent = 32¶
Bitangent attribute must have exactly dim channels
- Color = 64¶
Color attribute may have 1, 2, 3 or 4 channels
- CornerIndex = 1024¶
Single channel integer attribute indexing mesh corners
- EdgeIndex = 2048¶
Single channel integer attribute indexing mesh edges
- FacetIndex = 512¶
Single channel integer attribute indexing mesh facets
- Normal = 8¶
Normal attribute must have exactly dim channels
- Position = 4¶
Position attribute must have exactly dim channels
- Scalar = 2¶
Scalar attribute that has exactly 1 channel
- Tangent = 16¶
Tangent attribute must have exactly dim channels
- UV = 128¶
UV attribute has exactly 2 channels
- Vector = 1¶
Vector attribute that may have any number of channels
- VertexIndex = 256¶
Single channel integer attribute indexing mesh vertices
- class lagrange.core.AttributeWritePolicy(*args, **kwds)¶
Bases:
enum.EnumPolicy for attempting to write to read-only external buffer
- ErrorIfReadOnly = 0¶
Disallow writing to read-only external buffer (default)
- SilentCopy = 2¶
Silently copy attribute to internal buffer when writing to read-only external buffer
- WarnAndCopy = 1¶
Warn and copy attribute to internal buffer when writing to read-only external buffer
- class lagrange.core.CentroidWeightingType(*args, **kwds)¶
Bases:
enum.EnumCentroid weighting type.
- Area = 1¶
Area weighting.
- Uniform = 0¶
Uniform weighting.
- class lagrange.core.ConnectivityType(*args, **kwds)¶
Bases:
enum.EnumMesh connectivity type
- Edge = 1¶
Two facets are connected if they share an edge
- Vertex = 0¶
Two facets are connected if they share a vertex
- class lagrange.core.DistortionMetric(*args, **kwds)¶
Bases:
enum.EnumDistortion metric.
- AreaRatio = 3¶
Area ratio
- Dirichlet = 0¶
Dirichlet energy
- InverseDirichlet = 1¶
Inverse Dirichlet energy
- MIPS = 4¶
Most isotropic parameterization energy
- SymmetricDirichlet = 2¶
Symmetric Dirichlet energy
- class lagrange.core.FacetAreaOptions¶
Options for computing facet area.
- property output_attribute_name: str¶
The name of the output attribute.
- Return type:
str
- class lagrange.core.FacetCentroidOptions¶
Facet centroid options.
- property output_attribute_name: str¶
The name of the output attribute.
- Return type:
str
- class lagrange.core.FacetNormalOptions¶
Facet normal computation options.
- property output_attribute_name: str¶
@facet_normal
- Type:
Output attribute name. Default
- Return type:
str
- class lagrange.core.IndexedAttribute¶
Indexed attribute data structure.
An indexed attribute stores values and indices separately, allowing for efficient storage when multiple elements share the same values. This is commonly used for UV coordinates, normals, or colors where the same value may be referenced by multiple vertices, corners, or facets.
- property element_type: AttributeElement¶
Element type (i.e. Indexed).
- Return type:
- property indices: Attribute¶
The indices array of the indexed attribute.
- Returns:
Attribute containing the indices that reference into the values array
- Return type:
- property num_channels: int¶
Number of channels per element.
- Return type:
int
- property usage: AttributeUsage¶
Usage type (Position, Normal, UV, Color, etc.).
- Return type:
- class lagrange.core.MappingPolicy(*args, **kwds)¶
Bases:
enum.EnumMapping policy for handling collisions.
- Average = 0¶
Compute the average of the collided values.
- Error = 2¶
Throw an error when collision happens.
- KeepFirst = 1¶
Keep the first collided value.
- class lagrange.core.MeshAreaOptions¶
Options for computing mesh area.
- property input_attribute_name: str¶
The name of the pre-computed facet area attribute, default is @facet_area.
- Return type:
str
- property use_signed_area: bool¶
Whether to use signed area.
- Return type:
bool
- class lagrange.core.MeshCentroidOptions¶
Mesh centroid options.
- property facet_area_attribute_name: str¶
The name of the pre-computed facet area attribute if available.
- Return type:
str
- property facet_centroid_attribute_name: str¶
The name of the pre-computed facet centroid attribute if available.
- Return type:
str
- property weighting_type: CentroidWeightingType¶
The weighting type.
- Return type:
- class lagrange.core.MetaData¶
Metadata dict of the mesh
- __delitem__(arg, /)¶
- Parameters:
arg (str)
- Return type:
None
- __getitem__(arg, /)¶
- Parameters:
arg (str)
- Return type:
str
- __len__()¶
- Return type:
int
- __repr__()¶
Return repr(self).
- Return type:
str
- __setitem__(arg0, arg1, /)¶
- Parameters:
arg0 (str)
arg1 (str)
- Return type:
None
- class lagrange.core.NormalOptions¶
Normal computation options.
- property distance_tolerance: float¶
Distance tolerance for degenerate edge check. (Only used to bypass degenerate edge in polygon facets.)
- Return type:
float
- property facet_normal_attribute_name: str¶
Facet normal attribute name to use. Default is @facet_normal.
- Return type:
str
- property keep_facet_normals: bool¶
Whether to keep the computed facet normal attribute. Default is false.
- Return type:
bool
- property output_attribute_name: str¶
@normal
- Type:
Output attribute name. Default
- Return type:
str
- property recompute_facet_normals: bool¶
Whether to recompute facet normals. Default is false.
- Return type:
bool
- property weight_type: NormalWeightingType¶
Weighting type for normal computation. Default is Angle.
- Return type:
- class lagrange.core.NormalWeightingType(*args, **kwds)¶
Bases:
enum.EnumNormal weighting type.
- Angle = 2¶
Weight by corner angle
- CornerTriangleArea = 1¶
Weight by corner triangle area
- Uniform = 0¶
Uniform weighting
- class lagrange.core.RemapVerticesOptions¶
Options for remapping vertices.
- property collision_policy_float: MappingPolicy¶
The collision policy for float attributes.
- Return type:
- property collision_policy_integral: MappingPolicy¶
The collision policy for integral attributes.
- Return type:
- class lagrange.core.SurfaceMesh(dimension=3)¶
Surface mesh data structure
- Parameters:
dimension (int)
- property attr_id_corner_to_edge: int¶
- Return type:
int
- property attr_id_corner_to_facet: int¶
- Return type:
int
- property attr_id_corner_to_vertex: int¶
- Return type:
int
- property attr_id_edge_to_first_corner: int¶
- Return type:
int
- property attr_id_facet_to_first_corner: int¶
- Return type:
int
- property attr_id_next_corner_around_edge: int¶
- Return type:
int
- property attr_id_next_corner_around_vertex: int¶
- Return type:
int
- property attr_id_vertex_to_first_corner: int¶
- Return type:
int
- property attr_id_vertex_to_position: int¶
- Return type:
int
- property dimension: int¶
- Return type:
int
- property edges: Annotated[numpy.typing.NDArray[numpy.uint32], dict(shape=None, 2, order='C', device='cpu')]¶
Edges of the mesh.
- Return type:
Annotated[numpy.typing.NDArray[numpy.uint32], dict(shape=(None, 2), order=’C’, device=’cpu’)]
- property facets: Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')]¶
Facets of the mesh.
- Return type:
Annotated[numpy.typing.NDArray[numpy.uint32], dict(order=’C’, device=’cpu’)]
- property has_edges: bool¶
- Return type:
bool
- property is_hybrid: bool¶
- Return type:
bool
- property is_quad_mesh: bool¶
- Return type:
bool
- property is_regular: bool¶
- Return type:
bool
- property is_triangle_mesh: bool¶
- Return type:
bool
- property num_corners: int¶
- Return type:
int
- property num_edges: int¶
- Return type:
int
- property num_facets: int¶
- Return type:
int
- property num_vertices: int¶
- Return type:
int
- property vertex_per_facet: int¶
- Return type:
int
- property vertices: Annotated[numpy.typing.NDArray[numpy.float64], dict(order='C', device='cpu')]¶
Vertices of the mesh.
- Return type:
Annotated[numpy.typing.NDArray[numpy.float64], dict(order=’C’, device=’cpu’)]
- attr_name_corner_to_edge: str = Ellipsis¶
The name of the attribute that stores the corner to edge mapping.
- attr_name_corner_to_facet: str = Ellipsis¶
The name of the attribute that stores the corner to facet mapping.
- attr_name_corner_to_vertex: str = Ellipsis¶
The name of the attribute that stores the corner to vertex mapping.
- attr_name_edge_to_first_corner: str = Ellipsis¶
The name of the attribute that stores the edge to first corner mapping.
- attr_name_facet_to_first_corner: str = Ellipsis¶
The name of the attribute that stores the facet to first corner mapping.
- attr_name_next_corner_around_edge: str = Ellipsis¶
The name of the attribute that stores the next corner around edge mapping.
- attr_name_next_corner_around_vertex: str = Ellipsis¶
The name of the attribute that stores the next corner around vertex mapping.
- attr_name_vertex_to_first_corner: str = Ellipsis¶
The name of the attribute that stores the vertex to first corner mapping.
- attr_name_vertex_to_position: str = Ellipsis¶
The name of the attribute that stores the vertex positions.
- __attribute_ref_count__(id)¶
Get the reference count of an attribute (for debugging purposes).
- Parameters:
id (int) – attribute ID
- Returns:
reference count of the attribute
- Return type:
int
- __copy__()¶
Create a shallow copy of this mesh.
- Return type:
- __deepcopy__(memo=None)¶
Create a deep copy of this mesh.
- Parameters:
memo (dict | None)
- Return type:
- add_hybrid(sizes, indices)¶
Add hybrid facets (polygons with varying number of vertices) to the mesh.
- Parameters:
sizes (Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')]) – 1D tensor specifying the number of vertices for each facet
indices (Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')]) – 1D tensor of vertex indices for all facets concatenated together
- Return type:
None
- add_polygon(vertices)¶
Add a polygon to the mesh.
- Parameters:
vertices (Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')]) – 1D tensor of vertex indices defining the polygon
- Returns:
facet index of the added polygon
- Return type:
None
- add_polygons(polygons)¶
Add multiple regular polygons to the mesh.
- Parameters:
polygons (Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')]) – N x K tensor of vertex indices, where N is the number of polygons and K is the number of vertices per polygon
- Return type:
None
- add_quad(v0, v1, v2, v3)¶
Add a quad to the mesh.
- Parameters:
v0 (int) – first vertex index
v1 (int) – second vertex index
v2 (int) – third vertex index
v3 (int) – fourth vertex index
- Returns:
facet index of the added quad
- Return type:
None
- add_quads(quads)¶
Add multiple quads to the mesh.
- Parameters:
quads (Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')]) – N x 4 tensor of vertex indices, where N is the number of quads
- Return type:
None
- add_triangle(v0, v1, v2)¶
Add a triangle to the mesh.
- Parameters:
v0 (int) – first vertex index
v1 (int) – second vertex index
v2 (int) – third vertex index
- Returns:
facet index of the added triangle
- Return type:
None
- add_triangles(triangles)¶
Add multiple triangles to the mesh.
- Parameters:
triangles (Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')]) – N x 3 tensor of vertex indices, where N is the number of triangles
- Return type:
None
- add_vertex(vertex: Annotated[numpy.typing.NDArray[numpy.float64], dict(order='C', device='cpu')]) None¶
- add_vertex(vertex: list) None
Add a vertex to the mesh.
- Parameters:
vertex – vertex coordinates as a list
- add_vertices(vertices)¶
Add multiple vertices to the mesh.
- Parameters:
vertices (Annotated[numpy.typing.NDArray[numpy.float64], dict(order='C', device='cpu')]) – N x D tensor of vertex coordinates, where N is the number of vertices and D is the dimension
- Return type:
None
- static attr_name_is_reserved(name)¶
Check if an attribute name is reserved.
- Parameters:
name (str) – attribute name to check
- Returns:
True if the name is reserved, False otherwise
- Return type:
bool
- attribute(id: int, sharing: bool = True) Attribute¶
- attribute(name: str, sharing: bool = True) Attribute
Get an attribute by name.
- Parameters:
name – Name of the attribute.
sharing – Whether to allow sharing the attribute with other meshes.
- Returns:
The attribute.
- clear_edges()¶
Clear all edge connectivity information.
- Return type:
None
- clear_facets()¶
Remove all facets from the mesh.
- Return type:
None
- clear_vertices()¶
Remove all vertices from the mesh.
- Return type:
None
- clone(strip=False)¶
Create a deep copy of this mesh.
- Parameters:
strip (bool) – If True, strip the mesh of all attributes except for the reserved attributes.
- Return type:
- compress_if_regular()¶
Compress the mesh representation if it is regular (all facets have the same number of vertices).
- Returns:
True if the mesh was compressed, False otherwise
- Return type:
None
- count_num_corners_around_edge(edge_id)¶
Count the number of corners around an edge.
- Parameters:
edge_id (int) – edge index
- Returns:
number of corners around the edge
- Return type:
int
- count_num_corners_around_vertex(vertex_id)¶
Count the number of corners around a vertex.
- Parameters:
vertex_id (int) – vertex index
- Returns:
number of corners around the vertex
- Return type:
int
- create_attribute(name, element=None, usage=None, initial_values=None, initial_indices=None, num_channels=None, dtype=None)¶
Create an attribute.
- Parameters:
name (str) – Name of the attribute.
element (Union[AttributeElement, Literal[Vertex, Facet, Edge, Corner, Value, Indexed], None]) – Element type of the attribute. If None, derive from the shape of initial values.
usage (Union[AttributeUsage, Literal[Vector, Scalar, Position, Normal, Tangent, Bitangent, Color, UV, VertexIndex, FacetIndex, CornerIndex, EdgeIndex], None]) – Usage type of the attribute. If None, derive from the shape of initial values or the number of channels.
initial_values (Union[numpy.typing.NDArray, List[float], None]) – Initial values of the attribute.
initial_indices (Union[numpy.typing.NDArray, List[int], None]) – Initial indices of the attribute (Indexed attribute only).
num_channels (Optional[int]) – Number of channels of the attribute.
dtype (Optional[numpy.typing.DTypeLike]) – Data type of the attribute.
- Returns:
The id of the created attribute.
- Return type:
int
Note
If element is None, it will be derived based on the cardinality of the mesh elements. If there is an ambiguity, an exception will be raised. In addition, explicit element specification is required for value attributes.
Note
If usage is None, it will be derived based on the shape of initial_values or num_channels if specified.
- create_attribute_from(name, source_mesh, source_name='')¶
Shallow copy an attribute from another mesh.
- Parameters:
name (str) – Name of the attribute.
source_mesh (SurfaceMesh) – Source mesh.
source_name (str) – Name of the attribute in the source mesh. If empty, use the same name as name.
- Returns:
The id of the created attribute.
- Return type:
int
- delete_attribute(name: str, policy: AttributeDeletePolicy) None¶
- delete_attribute(name: str) None
- delete_attribute(id: int) None
Delete an attribute by id.
- Parameters:
id – Id of the attribute.
- duplicate_attribute(old_name, new_name)¶
Duplicate an attribute with a new name.
- Parameters:
old_name (str) – name of the attribute to duplicate
new_name (str) – name for the new attribute
- Returns:
attribute ID of the duplicated attribute
- Return type:
int
- find_edge_from_vertices(vertex1_id, vertex2_id)¶
Find the edge connecting two vertices.
- Parameters:
vertex1_id (int) – first vertex index
vertex2_id (int) – second vertex index
- Returns:
edge index, or invalid_index if no such edge exists
- Return type:
int
- get_attribute_id(name)¶
Get the attribute ID by name.
- Parameters:
name (str) – attribute name
- Returns:
attribute ID
- Return type:
int
- get_attribute_name(id)¶
Get the attribute name by ID.
- Parameters:
id (int) – attribute ID
- Returns:
attribute name
- Return type:
str
- get_clockwise_corner_around_vertex(corner)¶
Get the clockwise corner around the vertex associated with the input corner.
Note
If the vertex is a non-manifold vertex, only one “umbrella” (a set of connected corners based on edge-connectivity) will be visited.
If the traversal reaches a boundary or a non-manifold edge, the next adjacent corner is not well defined. It will return invalid_index in this case.
- Parameters:
corner (int) – The input corner index.
- Returns:
The clockwise corner index or invalid_index if none exists.
- Return type:
int
- get_corner_edge(corner_id)¶
Get the edge index associated with a corner.
- Parameters:
corner_id (int) – corner index
- Returns:
edge index
- Return type:
int
- get_corner_facet(corner_id)¶
Get the facet index associated with a corner.
- Parameters:
corner_id (int) – corner index
- Returns:
facet index
- Return type:
int
- get_corner_vertex(corner_id)¶
Get the vertex index associated with a corner.
- Parameters:
corner_id (int) – corner index
- Returns:
vertex index
- Return type:
int
- get_counterclockwise_corner_around_vertex(corner)¶
Get the counterclockwise corner around the vertex associated with the input corner.
Note
If the vertex is a non-manifold vertex, only one “umbrella” (a set of connected corners based on edge-connectivity) will be visited.
If the traversal reaches a boundary or a non-manifold edge, the next adjacent corner is not well defined. It will return invalid_index in this case.
- Parameters:
corner (int) – The input corner index.
- Returns:
The counterclockwise corner index or invalid_index if none exists.
- Return type:
int
- get_edge(facet_id, lv)¶
Get the edge index associated with a local vertex of a facet.
- Parameters:
facet_id (int) – facet index
lv (int) – local vertex index of the facet
- Returns:
edge index
- Return type:
int
- get_edge_vertices(edge_id)¶
Get the two vertex indices of an edge.
- Parameters:
edge_id (int) – edge index
- Returns:
tuple of (vertex1_id, vertex2_id)
- Return type:
list[int]
- get_facet_corner_begin(facet_id)¶
Get the first corner index of a facet.
- Parameters:
facet_id (int) – facet index
- Returns:
first corner index of the facet
- Return type:
int
- get_facet_corner_end(facet_id)¶
Get the end corner index of a facet (one past the last corner).
- Parameters:
facet_id (int) – facet index
- Returns:
end corner index of the facet
- Return type:
int
- get_facet_size(facet_id)¶
Get the number of vertices in a facet.
- Parameters:
facet_id (int) – facet index
- Returns:
number of vertices in the facet
- Return type:
int
- get_facet_vertex(facet_id, local_vertex_id)¶
Get a vertex index from a facet.
- Parameters:
facet_id (int) – facet index
local_vertex_id (int) – local vertex index within the facet (0 to facet_size-1)
- Returns:
global vertex index
- Return type:
int
- get_facet_vertices(facet_id)¶
Get all vertex indices of a facet.
- Parameters:
facet_id (int) – facet index
- Returns:
vertex indices as a tensor
- Return type:
Annotated[numpy.typing.NDArray[numpy.uint32], dict(order=’C’, device=’cpu’)]
- get_first_corner_around_edge(edge_id)¶
Get the first corner around an edge.
- Parameters:
edge_id (int) – edge index
- Returns:
first corner index around the edge
- Return type:
int
- get_first_corner_around_vertex(vertex_id)¶
Get the first corner around a vertex.
- Parameters:
vertex_id (int) – vertex index
- Returns:
first corner index around the vertex
- Return type:
int
- get_matching_attribute_id(element=None, usage=None, num_channels=0)¶
Get one matching attribute id with the desired element type, usage and number of channels.
- Parameters:
element (AttributeElement | None) – The target element type. None matches all element types.
usage (AttributeUsage | None) – The target usage type. None matches all usage types.
num_channels (int) – The target number of channels. 0 matches arbitrary number of channels.
- Returns:
An attribute id matching the target element, usage and number of channels, if found. None otherwise.
- Return type:
int | None
- get_matching_attribute_ids(element=None, usage=None, num_channels=0)¶
Get all matching attribute ids with the desired element type, usage and number of channels.
- Parameters:
element (AttributeElement | None) – The target element type. None matches all element types.
usage (AttributeUsage | None) – The target usage type. None matches all usage types.
num_channels (int) – The target number of channels. 0 matches arbitrary number of channels.
- Returns:
A list of attribute ids matching the target element, usage and number of channels.
- Return type:
list[int]
- get_next_corner_around_edge(corner_id)¶
Get the next corner around the same edge.
- Parameters:
corner_id (int) – current corner index
- Returns:
next corner index around the same edge
- Return type:
int
- get_next_corner_around_vertex(corner_id)¶
Get the next corner around the same vertex.
- Parameters:
corner_id (int) – current corner index
- Returns:
next corner index around the same vertex
- Return type:
int
- get_one_corner_around_edge(edge_id)¶
Get one corner around an edge.
- Parameters:
edge_id (int) – edge index
- Returns:
corner index around the edge
- Return type:
int
- get_one_corner_around_vertex(vertex_id)¶
Get one corner around a vertex.
- Parameters:
vertex_id (int) – vertex index
- Returns:
corner index around the vertex
- Return type:
int
- get_one_facet_around_edge(edge_id)¶
Get one facet adjacent to an edge.
- Parameters:
edge_id (int) – edge index
- Returns:
facet index adjacent to the edge
- Return type:
int
- get_position(vertex_id)¶
Get the position of a vertex.
- Parameters:
vertex_id (int) – vertex index
- Returns:
position coordinates as a tensor
- Return type:
Annotated[numpy.typing.NDArray[numpy.float64], dict(order=’C’, device=’cpu’)]
- has_attribute(name)¶
Check if an attribute exists.
- Parameters:
name (str) – attribute name
- Returns:
True if the attribute exists, False otherwise
- Return type:
bool
- indexed_attribute(id: int, sharing: bool = True) IndexedAttribute¶
- indexed_attribute(name: str, sharing: bool = True) IndexedAttribute
Get an indexed attribute by name.
- Parameters:
name – Name of the attribute.
sharing – Whether to allow sharing the attribute with other meshes.
- Returns:
The indexed attribute.
- initialize_edges(edges=None)¶
Initialize the edges.
The edges tensor provides a predefined ordering of the edges. If not provided, the edges are initialized in an arbitrary order.
- Parameters:
edges (Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')] | None) – M x 2 tensor of predefined edge vertex indices, where M is the number of edges.
- Return type:
None
- is_attribute_indexed(id: int) bool¶
- is_attribute_indexed(name: str) bool
Check if an attribute is indexed.
- Parameters:
name – attribute name
- Returns:
True if the attribute is indexed, False otherwise
- is_boundary_edge(edge_id)¶
Check if an edge is on the boundary.
- Parameters:
edge_id (int) – edge index
- Returns:
True if the edge is on the boundary, False otherwise
- Return type:
bool
- ref_facet_vertices(facet_id)¶
Get a mutable reference to all vertex indices of a facet.
- Parameters:
facet_id (int) – facet index
- Returns:
mutable vertex indices as a tensor
- Return type:
Annotated[numpy.typing.NDArray[numpy.uint32], dict(order=’C’, device=’cpu’)]
- ref_position(vertex_id)¶
Get a mutable reference to the position of a vertex.
- Parameters:
vertex_id (int) – vertex index
- Returns:
mutable position coordinates as a tensor
- Return type:
Annotated[numpy.typing.NDArray[numpy.float64], dict(order=’C’, device=’cpu’)]
- remove_facets(facets: Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')]) None¶
- remove_facets(facets: list) None
Remove selected facets from the mesh.
- Parameters:
facets – list of facet indices to remove
- remove_vertices(vertices: Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')]) None¶
- remove_vertices(vertices: list) None
Remove selected vertices from the mesh.
- Parameters:
vertices – list of vertex indices to remove
- rename_attribute(old_name, new_name)¶
Rename an attribute.
- Parameters:
old_name (str) – current name of the attribute
new_name (str) – new name for the attribute
- Return type:
None
- shrink_to_fit()¶
Shrink the internal storage to fit the current mesh size.
- Return type:
None
- wrap_as_attribute(name, element, usage, values)¶
Wrap an existing numpy array as an attribute.
- Parameters:
name (str) – Name of the attribute.
element (AttributeElement) – Element type of the attribute.
usage (AttributeUsage) – Usage type of the attribute.
values (Annotated[numpy.typing.NDArray, dict(order='C', device='cpu')]) – Values of the attribute.
- Returns:
The id of the created attribute.
- Return type:
int
- wrap_as_facets(tensor: Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')], num_facets: int, vertex_per_facet: int) int¶
- wrap_as_facets(offsets: Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')], num_facets: int, facets: Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')], num_corners: int) int
Wrap a tensor as a list of hybrid facets.
- Parameters:
offsets – The offset indices into the facets array.
num_facets – Number of facets.
facets – The indices of the vertices of the facets.
num_corners – Number of corners.
- Returns:
The id of the wrapped facet attribute.
- wrap_as_indexed_attribute(name, usage, values, indices)¶
Wrap an existing numpy array as an indexed attribute.
- Parameters:
name (str) – Name of the attribute.
usage (AttributeUsage) – Usage type of the attribute.
values (Annotated[numpy.typing.NDArray, dict(order='C', device='cpu')]) – Values of the attribute.
indices (Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')]) – Indices of the attribute.
- Returns:
The id of the created attribute.
- Return type:
int
- wrap_as_vertices(tensor, num_vertices)¶
Wrap a tensor as vertices.
- Parameters:
tensor (Annotated[numpy.typing.NDArray[numpy.float64], dict(order='C', device='cpu')]) – The tensor to wrap.
num_vertices (int) – Number of vertices.
- Returns:
The id of the wrapped vertices attribute.
- Return type:
int
- class lagrange.core.TangentBitangentOptions¶
Tangent bitangent options
- property bitangent_attribute_name: str¶
The name of the output bitangent attribute, default is @bitangent
- Return type:
str
- property keep_existing_tangent: bool¶
Whether to recompute tangent if the tangent attribute (specified by tangent_attribute_name) already exists. If true, bitangent is computed by normalizing cross(normal, tangent) and param orthogonalize_bitangent must be true.
- Return type:
bool
- property normal_attribute_name: str¶
The name of the normal attribute
- Return type:
str
- property orthogonalize_bitangent: bool¶
Whether to compute the bitangent as cross(normal, tangent). If false, the bitangent is computed as the derivative of v-coordinate
- Return type:
bool
- property output_element_type: AttributeElement¶
The output element type
- Return type:
- property pad_with_sign: bool¶
Whether to pad the output tangent/bitangent with sign
- Return type:
bool
- property tangent_attribute_name: str¶
The name of the output tangent attribute, default is @tangent
- Return type:
str
- property uv_attribute_name: str¶
The name of the uv attribute
- Return type:
str
- class lagrange.core.TangentBitangentResult¶
Tangent bitangent result
- property bitangent_id: int¶
The output bitangent attribute id
- Return type:
int
- property tangent_id: int¶
The output tangent attribute id
- Return type:
int
- class lagrange.core.VertexNormalOptions¶
Options for computing vertex normals
- property distance_tolerance: float¶
Distance tolerance for degenerate edge check in polygon facets.
- Return type:
float
- property keep_weighted_corner_normals: bool¶
false).
- Type:
Whether to keep the weighted corner normal attribute (default
- Return type:
bool
- property output_attribute_name: str¶
Output attribute name. Default is @vertex_normal.
- Return type:
str
- property recompute_weighted_corner_normals: bool¶
false).
- Type:
Whether to recompute weighted corner normals (default
- Return type:
bool
- property weight_type: NormalWeightingType¶
Weighting type for normal computation. Default is Angle.
- Return type:
- property weighted_corner_normal_attribute_name: str¶
@weighted_corner_normal).
If attribute exists, the precomputed weighted corner normal will be used.
- Type:
Precomputed weighted corner normals attribute name (default
- Return type:
str
- class lagrange.core.VertexValenceOptions¶
Vertex valence options
- property induced_by_attribute: str¶
Optional per-edge attribute used as indicator function to restrict the graph used for vertex valence computation
- Return type:
str
- property output_attribute_name: str¶
The name of the output attribute
- Return type:
str
- lagrange.core.cast_attribute(mesh, input_attribute, dtype, output_attribute_name=None)¶
Cast an attribute to a new dtype.
- Parameters:
mesh (SurfaceMesh) – The input mesh.
input_attribute (int | str) – The input attribute id or name.
dtype (type) – The new dtype.
output_attribute_name (str | None) – The output attribute name. If none, cast will replace the input attribute.
- Returns:
The id of the new attribute.
- Return type:
int
- lagrange.core.close_small_holes(mesh, max_hole_size=16, triangulate_holes=True)¶
Close small holes in a mesh.
- Parameters:
mesh (SurfaceMesh) – Input mesh (modified in place).
max_hole_size (int) – Maximum number of vertices on a hole to be closed.
triangulate_holes (bool) – Whether to triangulate holes (if false, fill with polygons).
- Return type:
None
- lagrange.core.combine_meshes(meshes, preserve_attributes=True)¶
Combine a list of meshes into a single mesh.
- Parameters:
meshes (collections.abc.Sequence[SurfaceMesh]) – Input meshes.
preserve_attributes (bool) – Whether to preserve attributes.
- Returns:
The combined mesh.
- Return type:
- lagrange.core.compute_components(mesh, output_attribute_name=None, connectivity_type=None, blocker_elements=None)¶
Compute connected components.
This method will create a per-facet component id attribute named by the output_attribute_name argument. Each component id is in [0, num_components-1] range.
- Parameters:
mesh (SurfaceMesh) – The input mesh.
output_attribute_name (str | None) – The name of the output attribute.
connectivity_type (ConnectivityType | None) – The connectivity type. Either “Vertex” or “Edge”.
blocker_elements (list | None) – The list of blocker element indices. If connectivity_type is Edge, facets adjacent to a blocker edge are not considered as connected through this edge. If connectivity_type is Vertex, facets sharing a blocker vertex are not considered as connected through this vertex.
- Returns:
The total number of components.
- Return type:
int
- lagrange.core.compute_dihedral_angles(mesh, output_attribute_name=None, facet_normal_attribute_name=None, recompute_facet_normals=None, keep_facet_normals=None)¶
Compute dihedral angles for each edge.
The dihedral angle of an edge is defined as the angle between the __normals__ of two facets adjacent to the edge. The dihedral angle is always in the range [0, pi] for manifold edges. For boundary edges, the dihedral angle defaults to 0. For non-manifold edges, the dihedral angle is not well-defined and will be set to the special value 2 * π.
- Parameters:
mesh (SurfaceMesh) – The source mesh.
output_attribute_name (str | None) – The optional edge attribute name to store the dihedral angles.
facet_normal_attribute_name (str | None) – The optional attribute name to store the facet normals.
recompute_facet_normals (bool | None) – Whether to recompute facet normals.
keep_facet_normals (bool | None) – Whether to keep newly computed facet normals. It has no effect on pre-existing facet normals.
- Returns:
The edge attribute id of dihedral angles.
- Return type:
int
- lagrange.core.compute_dijkstra_distance(mesh, seed_facet, barycentric_coords, radius=None, output_attribute_name='@dijkstra_distance', output_involved_vertices=False)¶
Compute Dijkstra distance from a seed facet.
- Parameters:
mesh (SurfaceMesh) – The source mesh.
seed_facet (int) – The seed facet index.
barycentric_coords (list) – The barycentric coordinates of the seed facet.
radius (float | None) – The maximum radius of the dijkstra distance.
output_attribute_name (str) – The output attribute name to store the dijkstra distance.
output_involved_vertices (bool) – Whether to output the list of involved vertices.
- Return type:
list[int] | None
- lagrange.core.compute_edge_lengths(mesh, output_attribute_name=None)¶
Compute edge lengths.
- Parameters:
mesh (SurfaceMesh) – The source mesh.
output_attribute_name (str | None) – The optional edge attribute name to store the edge lengths.
- Returns:
The edge attribute id of edge lengths.
- Return type:
int
- lagrange.core.compute_euler(mesh)¶
Compute the Euler characteristic.
- Parameters:
mesh (SurfaceMesh) – The source mesh.
- Returns:
The Euler characteristic.
- Return type:
int
- lagrange.core.compute_facet_area(mesh: SurfaceMesh, options: FacetAreaOptions = ...) int¶
- lagrange.core.compute_facet_area(mesh: SurfaceMesh, output_attribute_name: str | None = None) int
Compute facet area (Pythonic API).
- Parameters:
mesh – The input mesh.
output_attribute_name – The name of the output attribute.
- Returns:
The id of the new attribute.
- lagrange.core.compute_facet_centroid(mesh: SurfaceMesh, options: FacetCentroidOptions = ...) int¶
- lagrange.core.compute_facet_centroid(mesh: SurfaceMesh, output_attribute_name: str | None = None) int
Compute facet centroid (Pythonic API).
- Parameters:
mesh – Input mesh.
output_attribute_name – Output attribute name.
- Returns:
Attribute ID.
- lagrange.core.compute_facet_circumcenter(mesh, output_attribute_name=None)¶
Compute facet circumcenter (Pythonic API).
- Parameters:
mesh (SurfaceMesh) – The input mesh.
output_attribute_name (str | None) – The name of the output attribute.
- Returns:
The id of the new attribute.
- Return type:
int
- lagrange.core.compute_facet_normal(mesh: SurfaceMesh, options: FacetNormalOptions = ...) int¶
- lagrange.core.compute_facet_normal(mesh: SurfaceMesh, output_attribute_name: str | None = None) int
Compute facet normal (Pythonic API).
- Parameters:
mesh – Input mesh.
output_attribute_name – Output attribute name.
- Returns:
Facet normal attribute id.
- lagrange.core.compute_facet_vector_area(mesh, output_attribute_name=None)¶
Compute facet vector area (Pythonic API).
Vector area is defined as the area multiplied by the facet normal. For triangular facets, it is equivalent to half of the cross product of two edges. For non-planar polygonal facets, the vector area offers a robust way to compute the area and normal. The magnitude of the vector area is the largest area of any orthogonal projection of the facet. The direction of the vector area is the normal direction that maximizes the projected area [1, 2].
[1] Sullivan, John M. “Curvatures of smooth and discrete surfaces.” Discrete differential geometry. Basel: Birkhäuser Basel, 2008. 175-188.
[2] Alexa, Marc, and Max Wardetzky. “Discrete Laplacians on general polygonal meshes.” ACM SIGGRAPH 2011 papers. 2011. 1-10.
- Parameters:
mesh (SurfaceMesh) – The input mesh.
output_attribute_name (str | None) – The name of the output attribute.
- Returns:
The id of the new attribute.
- Return type:
int
- lagrange.core.compute_greedy_coloring(mesh, element_type=AttributeElement.Facet, num_color_used=8, output_attribute_name=None)¶
Compute greedy coloring of mesh elements.
- Parameters:
mesh (SurfaceMesh) – Input mesh.
element_type (AttributeElement) – Element type to be colored. Can be either Vertex or Facet.
num_color_used (int) – Minimum number of colors to use. The algorithm will cycle through them but may use more.
output_attribute_name (str | None) – Output attribute name.
- Returns:
Color attribute id.
- Return type:
int
- lagrange.core.compute_mesh_area(mesh: SurfaceMesh, options: MeshAreaOptions = ...) float¶
- lagrange.core.compute_mesh_area(mesh: SurfaceMesh, input_attribute_name: str | None = None, use_signed_area: bool | None = None) float
Compute mesh area (Pythonic API).
- Parameters:
mesh – The input mesh.
input_attribute_name – The name of the pre-computed facet area attribute.
use_signed_area – Whether to use signed area.
- Returns:
The mesh area.
- lagrange.core.compute_mesh_centroid(mesh: SurfaceMesh, options: MeshCentroidOptions = ...) list[float]¶
- lagrange.core.compute_mesh_centroid(mesh: SurfaceMesh, weighting_type: CentroidWeightingType | None = None, facet_centroid_attribute_name: str | None = None, facet_area_attribute_name: str | None = None) list[float]
Compute mesh centroid (Pythonic API).
- Parameters:
mesh – Input mesh.
weighting_type – Weighting type (default: Area).
facet_centroid_attribute_name – Pre-computed facet centroid attribute name.
facet_area_attribute_name – Pre-computed facet area attribute name.
- Returns:
Mesh centroid coordinates.
- lagrange.core.compute_mesh_covariance(mesh, center, active_facets_attribute_name=None)¶
Compute the covariance matrix of a mesh w.r.t. a center (Pythonic API).
- Parameters:
mesh (SurfaceMesh) – Input mesh.
center (collections.abc.Sequence[float]) – The center of the covariance computation.
active_facets_attribute_name (str | None) – (optional) Attribute name of whether a facet should be considered in the computation.
- Returns:
The 3 by 3 covariance matrix, which should be symmetric.
- Return type:
list[list[float]]
- lagrange.core.compute_normal(mesh: SurfaceMesh, feature_angle_threshold: float = 0.7853981633974483, cone_vertices: object | None = None, options: NormalOptions | None = None) int¶
- lagrange.core.compute_normal(mesh: SurfaceMesh, feature_angle_threshold: float = 0.7853981633974483, cone_vertices: object | None = None, output_attribute_name: str | None = None, weight_type: NormalWeightingType | None = None, facet_normal_attribute_name: str | None = None, recompute_facet_normals: bool | None = None, keep_facet_normals: bool | None = None, distance_tolerance: float | None = None) int
Compute indexed normal attribute (Pythonic API).
- Parameters:
mesh – input mesh
feature_angle_threshold – feature angle threshold
cone_vertices – cone vertices
output_attribute_name – output normal attribute name
weight_type – normal weighting type
facet_normal_attribute_name – facet normal attribute name
recompute_facet_normals – whether to recompute facet normals
keep_facet_normals – whether to keep the computed facet normal attribute
distance_tolerance – distance tolerance for degenerate edge check (only used to bypass degenerate edges in polygon facets)
- Returns:
the id of the indexed normal attribute.
- lagrange.core.compute_pointcloud_pca(points, shift_centroid=False, normalize=False)¶
Compute principal components of a point cloud.
- Parameters:
points (Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=(None, 3), order='C', device='cpu', writable=False)]) – Input points.
shift_centroid (bool) – When true: covariance = (P-centroid)^T (P-centroid), when false: covariance = (P)^T (P).
normalize (bool) – Should we divide the result by number of points?
- Returns:
tuple of (center, eigenvectors, eigenvalues).
- Return type:
tuple[list[float], list[list[float]], list[float]]
- lagrange.core.compute_seam_edges(mesh, indexed_attribute_id, output_attribute_name=None)¶
Compute seam edges for a given indexed attribute.
- Parameters:
mesh (SurfaceMesh) – Input mesh.
indexed_attribute_id (int) – Input indexed attribute id.
output_attribute_name (str | None) – Output attribute name.
- Returns:
Attribute id for the output per-edge seam attribute (1 is a seam, 0 is not).
- Return type:
int
- lagrange.core.compute_tangent_bitangent(mesh: SurfaceMesh, options: TangentBitangentOptions = ...) TangentBitangentResult¶
- lagrange.core.compute_tangent_bitangent(mesh: SurfaceMesh, tangent_attribute_name: str | None = None, bitangent_attribute_name: str | None = None, uv_attribute_name: str | None = None, normal_attribute_name: str | None = None, output_attribute_type: AttributeElement | None = None, pad_with_sign: bool | None = None, orthogonalize_bitangent: bool | None = None, keep_existing_tangent: bool | None = None) tuple[int, int]
Compute tangent and bitangent vector attributes (Pythonic API).
- Parameters:
mesh – The input mesh.
tangent_attribute_name – The name of the output tangent attribute.
bitangent_attribute_name – The name of the output bitangent attribute.
uv_attribute_name – The name of the uv attribute.
normal_attribute_name – The name of the normal attribute.
output_attribute_type – The output element type.
pad_with_sign – Whether to pad the output tangent/bitangent with sign.
orthogonalize_bitangent – Whether to compute the bitangent as sign * cross(normal, tangent).
keep_existing_tangent – Whether to recompute tangent if the tangent attribute (specified by tangent_attribute_name) already exists. If true, bitangent is computed by normalizing cross(normal, tangent) and param orthogonalize_bitangent must be true.
- Returns:
The tangent and bitangent attribute ids
- lagrange.core.compute_uv_charts(mesh, uv_attribute_name='', output_attribute_name='@chart_id', connectivity_type='Edge')¶
Compute UV charts.
@param mesh: Input mesh. @param uv_attribute_name: Name of the UV attribute. @param output_attribute_name: Name of the output attribute to store the chart ids. @param connectivity_type: Type of connectivity to use for chart computation. Can be “Vertex” or “Edge”.
@returns: A list of chart ids for each vertex.
- Parameters:
mesh (SurfaceMesh)
uv_attribute_name (str)
output_attribute_name (str)
connectivity_type (str)
- Return type:
int
- lagrange.core.compute_uv_distortion(mesh, uv_attribute_name='@uv', output_attribute_name='@uv_measure', metric=DistortionMetric.MIPS)¶
Compute UV distortion.
- Parameters:
mesh (SurfaceMesh) – Input mesh.
uv_attribute_name (str) – UV attribute name (default: “@uv”).
output_attribute_name (str) – Output attribute name (default: “@uv_measure”).
metric (DistortionMetric) – Distortion metric (default: MIPS).
- Returns:
Facet attribute ID for distortion.
- Return type:
int
- lagrange.core.compute_vertex_normal(mesh: SurfaceMesh, options: VertexNormalOptions = ...) int¶
- lagrange.core.compute_vertex_normal(mesh: SurfaceMesh, output_attribute_name: str | None = None, weight_type: NormalWeightingType | None = None, weighted_corner_normal_attribute_name: str | None = None, recompute_weighted_corner_normals: bool | None = None, keep_weighted_corner_normals: bool | None = None, distance_tolerance: float | None = None) int
Compute vertex normal (Pythonic API).
- Parameters:
mesh – Input mesh.
output_attribute_name – Output attribute name.
weight_type – Weighting type for normal computation.
weighted_corner_normal_attribute_name – Precomputed weighted corner normals attribute name.
recompute_weighted_corner_normals – Whether to recompute weighted corner normals.
keep_weighted_corner_normals – Whether to keep the weighted corner normal attribute.
distance_tolerance – Distance tolerance for degenerate edge check. (Only used to bypass degenerate edge in polygon facets.)
- Returns:
Vertex normal attribute id.
- lagrange.core.compute_vertex_valence(mesh: SurfaceMesh, options: VertexValenceOptions = ...) int¶
- lagrange.core.compute_vertex_valence(mesh: SurfaceMesh, output_attribute_name: str | None = None, induced_by_attribute: str | None = None) int
Compute vertex valence);
- Parameters:
mesh – The input mesh.
output_attribute_name – The name of the output attribute.
induced_by_attribute – Optional per-edge attribute used as indicator function to restrict the graph used for vertex valence computation.
- Returns:
The vertex valence attribute id
- lagrange.core.detect_degenerate_facets(mesh)¶
Detect degenerate facets in a mesh.
Note
Only exactly degenerate facets are detected.
- Parameters:
mesh (SurfaceMesh) – Input mesh.
- Returns:
List of degenerate facet indices.
- Return type:
list[int]
- lagrange.core.extract_boundary_edges(mesh)¶
Extract boundary edges from a mesh.
- Parameters:
mesh (SurfaceMesh) – Input mesh.
- Returns:
A list of boundary edge indices.
- Return type:
list[int]
- lagrange.core.extract_boundary_loops(mesh)¶
Extract boundary loops from a mesh.
- Parameters:
mesh (SurfaceMesh) – Input mesh.
- Returns:
A list of boundary loops, each represented as a list of vertex indices.
- Return type:
list[list[int]]
- lagrange.core.extract_isoline(mesh, attribute, isovalue=0.0)¶
Extract the isoline of an implicit function defined on the mesh vertices/corners.
The input mesh must be a triangle mesh.
- Parameters:
mesh (SurfaceMesh) – Input triangle mesh to extract the isoline from.
attribute (int | str) – Attribute id or name of the scalar field to use. Can be a vertex or indexed attribute.
isovalue (float) – Isovalue to extract.
- Returns:
A mesh whose facets is a collection of size 2 elements representing the extracted isoline.
- Return type:
- lagrange.core.extract_submesh(mesh, selected_facets, source_vertex_attr_name='', source_facet_attr_name='', map_attributes=False)¶
Extract a submesh based on the selected facets.
- Parameters:
mesh (SurfaceMesh) – The source mesh.
selected_facets (Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')]) – A listed of facet ids to extract.
source_vertex_attr_name (str) – The optional attribute name to track source vertices.
source_facet_attr_name (str) – The optional attribute name to track source facets.
map_attributes (bool) – Map attributes from the source to target meshes.
- Returns:
A mesh that contains only the selected facets.
- Return type:
- lagrange.core.filter_attributes(mesh, included_attributes=None, excluded_attributes=None, included_usages=None, included_element_types=None)¶
Filters the attributes of mesh according to user specifications.
- Parameters:
mesh (SurfaceMesh) – Input mesh.
included_attributes (collections.abc.Sequence[int | str] | None) – List of attribute names or ids to include. By default, all attributes are included.
excluded_attributes (collections.abc.Sequence[int | str] | None) – List of attribute names or ids to exclude. By default, no attribute is excluded.
included_usages (collections.abc.Set[AttributeUsage] | None) – List of attribute usages to include. By default, all usages are included.
included_element_types (collections.abc.Set[AttributeElement] | None) – List of attribute element types to include. By default, all element types are included.
- Return type:
- lagrange.core.is_closed(mesh)¶
Check if the mesh is closed.
A mesh is considered closed if it has no boundary edges.
- Parameters:
mesh (SurfaceMesh) – The source mesh.
- Returns:
Whether the mesh is closed.
- Return type:
bool
- lagrange.core.is_edge_manifold(mesh)¶
Check if the mesh is edge manifold.
- Parameters:
mesh (SurfaceMesh) – The source mesh.
- Returns:
Whether the mesh is edge manifold.
- Return type:
bool
- lagrange.core.is_manifold(mesh)¶
Check if the mesh is manifold.
A mesh considered as manifold if it is both vertex and edge manifold.
- Parameters:
mesh (SurfaceMesh) – The source mesh.
- Returns:
Whether the mesh is manifold.
- Return type:
bool
- lagrange.core.is_oriented(mesh)¶
Check if the mesh is oriented.
- Parameters:
mesh (SurfaceMesh) – The source mesh.
- Returns:
Whether the mesh is oriented.
- Return type:
bool
- lagrange.core.is_vertex_manifold(mesh)¶
Check if the mesh is vertex manifold.
- Parameters:
mesh (SurfaceMesh) – The source mesh.
- Returns:
Whether the mesh is vertex manifold.
- Return type:
bool
- lagrange.core.map_attribute(mesh: SurfaceMesh, old_attribute_id: int, new_attribute_name: str, new_element: AttributeElement) int¶
- lagrange.core.map_attribute(mesh: SurfaceMesh, old_attribute_name: str, new_attribute_name: str, new_element: AttributeElement) int
Map an attribute to a new element type.
- Parameters:
mesh – The input mesh.
old_attribute_name – The name of the input attribute.
new_attribute_name – The name of the new attribute.
new_element – The new element type.
- Returns:
The id of the new attribute.
- lagrange.core.map_attribute_in_place(mesh: SurfaceMesh, id: int, new_element: AttributeElement) int¶
- lagrange.core.map_attribute_in_place(mesh: SurfaceMesh, name: str, new_element: AttributeElement) int
Map an attribute to a new element type in place.
- Parameters:
mesh – The input mesh.
name – The name of the input attribute.
new_element – The new element type.
- Returns:
The id of the new attribute.
- lagrange.core.normalize_mesh(mesh, normalize_normals=True, normalize_tangents_bitangents=True)¶
Normalize a mesh to fit into a unit box centered at the origin.
- Parameters:
mesh (SurfaceMesh) – Input mesh.
normalize_normals (bool) – Whether to normalize normals.
normalize_tangents_bitangents (bool) – Whether to normalize tangents and bitangents.
- Return type:
None
- lagrange.core.normalize_mesh_with_transform(mesh, normalize_normals=True, normalize_tangents_bitangents=True)¶
Normalize a mesh to fit into a unit box centered at the origin.
- Parameters:
mesh (SurfaceMesh) – Input mesh.
normalize_normals (bool) – Whether to normalize normals.
normalize_tangents_bitangents (bool) – Whether to normalize tangents and bitangents.
- Return type:
Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=(4, 4), order=’F’)]
:return Inverse transform, can be used to undo the normalization process.
- lagrange.core.normalize_mesh_with_transform_2d(mesh, normalize_normals=True, normalize_tangents_bitangents=True)¶
Normalize a mesh to fit into a unit box centered at the origin.
- Parameters:
mesh (SurfaceMesh) – Input mesh.
normalize_normals (bool) – Whether to normalize normals.
normalize_tangents_bitangents (bool) – Whether to normalize tangents and bitangents.
- Return type:
Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=(3, 3), order=’F’)]
:return Inverse transform, can be used to undo the normalization process.
- lagrange.core.normalize_meshes(meshes, normalize_normals=True, normalize_tangents_bitangents=True)¶
Normalize a list of meshes to fit into a unit box centered at the origin.
- Parameters:
meshes (collections.abc.Sequence[SurfaceMesh]) – Input meshes.
normalize_normals (bool) – Whether to normalize normals.
normalize_tangents_bitangents (bool) – Whether to normalize tangents and bitangents.
- Return type:
None
- lagrange.core.normalize_meshes_with_transform(meshes, normalize_normals=True, normalize_tangents_bitangents=True)¶
Normalize a mesh to fit into a unit box centered at the origin.
- Parameters:
meshes (collections.abc.Sequence[SurfaceMesh]) – Input meshes.
normalize_normals (bool) – Whether to normalize normals.
normalize_tangents_bitangents (bool) – Whether to normalize tangents and bitangents.
- Return type:
Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=(4, 4), order=’F’)]
:return Inverse transform, can be used to undo the normalization process.
- lagrange.core.normalize_meshes_with_transform_2d(meshes, normalize_normals=True, normalize_tangents_bitangents=True)¶
Normalize a mesh to fit into a unit box centered at the origin.
- Parameters:
meshes (collections.abc.Sequence[SurfaceMesh]) – Input meshes.
normalize_normals (bool) – Whether to normalize normals.
normalize_tangents_bitangents (bool) – Whether to normalize tangents and bitangents.
- Return type:
Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=(3, 3), order=’F’)]
:return Inverse transform, can be used to undo the normalization process.
- lagrange.core.orient_outward(mesh, positive=True)¶
Orient mesh facets to ensure positive or negative signed volume.
- Parameters:
mesh (SurfaceMesh) – Input mesh.
positive (bool) – Whether to orient volumes positively or negatively.
- Return type:
None
- lagrange.core.permute_facets(mesh, new_to_old)¶
Reorder facets of a mesh in place based on a permutation.
- Parameters:
mesh (SurfaceMesh) – input mesh
new_to_old (Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')]) – permutation vector for facets
- Return type:
None
- lagrange.core.permute_vertices(mesh, new_to_old)¶
Reorder vertices of a mesh in place based on a permutation.
- Parameters:
mesh (SurfaceMesh) – input mesh
new_to_old (Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')]) – permutation vector for vertices
- Return type:
None
- lagrange.core.remap_vertices(mesh: SurfaceMesh, old_to_new: Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')], options: RemapVerticesOptions = ...) None¶
- lagrange.core.remap_vertices(mesh: SurfaceMesh, old_to_new: Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')], collision_policy_float: MappingPolicy | None = None, collision_policy_integral: MappingPolicy | None = None) None
Remap vertices of a mesh in place based on a permutation (Pythonic API).
- Parameters:
mesh – input mesh
old_to_new – permutation vector for vertices
collision_policy_float – The collision policy for float attributes.
collision_policy_integral – The collision policy for integral attributes.
- lagrange.core.remove_degenerate_facets(mesh)¶
Remove degenerate facets from a mesh.
Note
Assumes triangular mesh. Use triangulate_polygonal_facets for non-triangular meshes. Adjacent non-degenerate facets may be re-triangulated during removal.
- Parameters:
mesh (SurfaceMesh) – Input mesh (modified in place).
- Return type:
None
- lagrange.core.remove_duplicate_facets(mesh, consider_orientation=False)¶
Remove duplicate facets from a mesh.
Facets with different orientations (e.g. (0,1,2) and (2,1,0)) are considered duplicates. If both orientations have equal counts, all are removed. If one orientation has more duplicates, all but one of the majority orientation are kept.
- Parameters:
mesh (SurfaceMesh) – Input mesh (modified in place).
consider_orientation (bool) – Whether to consider orientation when detecting duplicates.
- Return type:
None
- lagrange.core.remove_duplicate_vertices(mesh, extra_attributes=None, boundary_only=False)¶
Remove duplicate vertices from a mesh.
- Parameters:
mesh (SurfaceMesh) – Input mesh (modified in place).
extra_attributes (collections.abc.Sequence[int] | None) – Additional attributes to consider when detecting duplicates.
boundary_only (bool) – Only remove duplicate vertices on the boundary.
- Return type:
None
- lagrange.core.remove_isolated_vertices(mesh)¶
Remove isolated vertices from a mesh.
Note
A vertex is considered isolated if it is not referenced by any facet.
- Parameters:
mesh (SurfaceMesh) – Input mesh (modified in place).
- Return type:
None
- lagrange.core.remove_null_area_facets(mesh, null_area_threshold=0, remove_isolated_vertices=False)¶
Remove facets with unsigned facets area <= null_area_threhsold.
- Parameters:
mesh (SurfaceMesh) – Input mesh (modified in place).
null_area_threshold (float) – Area threshold below which facets are considered null.
remove_isolated_vertices (bool) – Whether to remove isolated vertices after removing null area facets.
- Return type:
None
- lagrange.core.remove_short_edges(mesh, threshold=0)¶
Remove short edges from a mesh.
- Parameters:
mesh (SurfaceMesh) – Input mesh (modified in place).
threshold (float) – Minimum edge length below which edges are considered short.
- Return type:
None
- lagrange.core.remove_topologically_degenerate_facets(mesh)¶
Remove topologically degenerate facets such as (0,1,1).
For polygons, topological degeneracy means the polygon has at most two unique vertices. E.g. quad (0,0,1,1) is degenerate, while (1,1,2,3) is not.
- Parameters:
mesh (SurfaceMesh) – Input mesh (modified in place).
- Return type:
None
- lagrange.core.reorder_mesh(mesh, method)¶
Reorder a mesh in place.
- Parameters:
mesh (SurfaceMesh) – input mesh
method (Literal[Lexicographic, Morton, Hilbert, None]) – reordering method, options are ‘Lexicographic’, ‘Morton’, ‘Hilbert’, ‘None’ (default is ‘Morton’).
- Return type:
None
- lagrange.core.rescale_uv_charts(mesh, uv_attribute_name='', chart_id_attribute_name='', uv_area_threshold=1e-06)¶
Rescale UV charts to match their 3D aspect ratios.
- Parameters:
mesh (SurfaceMesh) – Input mesh (modified in place).
uv_attribute_name (str) – UV attribute name for rescaling. If empty, uses first UV attribute found.
chart_id_attribute_name (str) – Patch ID attribute name. If empty, computes patches from UV chart connectivity.
uv_area_threshold (float) – UV area threshold. Triangles below this threshold don’t contribute to scale computation.
- Return type:
None
- lagrange.core.resolve_nonmanifoldness(mesh)¶
Resolve both vertex and edge nonmanifoldness in a mesh.
- Parameters:
mesh (SurfaceMesh) – Input mesh (modified in place).
- Return type:
None
- lagrange.core.resolve_vertex_nonmanifoldness(mesh)¶
Resolve vertex non-manifoldness in a mesh.
- Parameters:
mesh (SurfaceMesh) – Input mesh (modified in place).
- Raises:
RuntimeError – If the input mesh is not edge-manifold.
- Return type:
None
- lagrange.core.select_facets_by_normal_similarity(mesh, seed_facet_id, flood_error_limit=None, flood_second_to_first_order_limit_ratio=None, facet_normal_attribute_name=None, is_facet_selectable_attribute_name=None, output_attribute_name=None, search_type=None, num_smooth_iterations=None)¶
Select facets by normal similarity (Pythonic API).
- Parameters:
mesh (SurfaceMesh) – Input mesh.
seed_facet_id (int) – Index of the seed facet.
flood_error_limit (float | None) – Tolerance for normals of the seed and the selected facets. Higher limit leads to larger selected region.
flood_second_to_first_order_limit_ratio (float | None) – Ratio of the flood_error_limit and the tolerance for normals of neighboring selected facets. Higher ratio leads to more curvature in selected region.
facet_normal_attribute_name (str | None) – Attribute name of the facets normal. If the mesh doesn’t have this attribute, it will call compute_facet_normal to compute it.
is_facet_selectable_attribute_name (str | None) – If provided, this function will look for this attribute to determine if a facet is selectable.
output_attribute_name (str | None) – Attribute name of whether a facet is selected.
search_type (Literal[BFS, DFS] | None) – Use ‘BFS’ for breadth-first search or ‘DFS’ for depth-first search.
num_smooth_iterations (int | None) – Number of iterations to smooth the boundary of the selected region.
- Returns:
Id of the attribute on whether a facet is selected.
- Return type:
int
- lagrange.core.select_facets_in_frustum(mesh, frustum_plane_points, frustum_plane_normals, greedy=None, output_attribute_name=None)¶
Select facets in a frustum (Pythonic API).
- Parameters:
mesh (SurfaceMesh) – Input mesh.
frustum_plane_points (collections.abc.Sequence[collections.abc.Sequence[float]]) – Four points on each of the frustum planes.
frustum_plane_normals (collections.abc.Sequence[collections.abc.Sequence[float]]) – Four normals of each of the frustum planes.
greedy (bool | None) – If true, the function returns as soon as the first facet is found.
output_attribute_name (str | None) – Attribute name of whether a facet is selected.
- Returns:
Whether any facets got selected.
- Return type:
bool
- lagrange.core.separate_by_components(mesh, source_vertex_attr_name='', source_facet_attr_name='', map_attributes=False, connectivity_type=ConnectivityType.Edge)¶
Extract a set of submeshes based on connected components.
- Parameters:
mesh (SurfaceMesh) – The source mesh.
source_vertex_attr_name (str) – The optional attribute name to track source vertices.
source_facet_attr_name (str) – The optional attribute name to track source facets.
map_attributes (bool) – Map attributes from the source to target meshes.
connectivity_type (ConnectivityType) – The connectivity used for component computation.
- Returns:
A list of meshes, one for each connected component.
- Return type:
list[SurfaceMesh]
- lagrange.core.separate_by_facet_groups(mesh, facet_group_indices, source_vertex_attr_name='', source_facet_attr_name='', map_attributes=False)¶
Extract a set of submeshes based on facet groups.
- Parameters:
mesh (SurfaceMesh) – The source mesh.
facet_group_indices (Annotated[numpy.typing.NDArray[numpy.uint32], dict(order='C', device='cpu')]) – The group index for each facet. Each group index must be in the range of [0, max(facet_group_indices)]
source_vertex_attr_name (str) – The optional attribute name to track source vertices.
source_facet_attr_name (str) – The optional attribute name to track source facets.
map_attributes (bool)
- Returns:
A list of meshes, one for each facet group.
- Return type:
list[SurfaceMesh]
- lagrange.core.split_facets_by_material(mesh, material_attribute_name)¶
Split mesh facets based on a material attribute.
@param mesh: Input mesh on which material segmentation will be applied in place. @param material_attribute_name: Name of the material attribute to use for inserting boundaries.
@note The material attribute should be n by k vertex attribute, where n is the number of vertices, and k is the number of materials. The value at row i and column j indicates the probability of vertex i belonging to material j. The function will insert boundaries between different materials based on the material attribute.
- Parameters:
mesh (SurfaceMesh)
material_attribute_name (str)
- Return type:
None
- lagrange.core.split_long_edges(mesh, max_edge_length=0.10000000149011612, recursive=True, active_region_attribute=None, edge_length_attribute=None)¶
Split edges longer than max_edge_length.
- Parameters:
mesh (SurfaceMesh) – Input mesh (modified in place).
max_edge_length (float) – Maximum edge length threshold.
recursive (bool) – If true, apply recursively until no edge exceeds threshold.
active_region_attribute (str | None) – Facet attribute name for active region (uint8_t type). If None, all edges are considered.
edge_length_attribute (str | None) – Edge length attribute name. If None, edge lengths are computed.
- Return type:
None
- lagrange.core.thicken_and_close_mesh(mesh, offset_amount=None, direction=None, mirror_ratio=None, num_segments=None, indexed_attributes=None)¶
Thicken a mesh by offsetting it, and close the shape into a thick 3D solid.
- Parameters:
mesh (SurfaceMesh) – Input mesh.
direction (collections.abc.Sequence[float] | str | None) – Direction of the offset. Can be an attribute name or a fixed 3D vector.
offset_amount (float | None) – Amount of offset.
mirror_ratio (float | None) – Ratio of the offset amount to mirror the mesh.
num_segments (int | None) – Number of segments to use for the thickening.
indexed_attributes (collections.abc.Sequence[str] | None) – List of indexed attributes to copy to the new mesh.
- Returns:
The thickened and closed mesh.
- Return type:
- lagrange.core.transform_mesh(mesh, affine_transform, normalize_normals=True, normalize_tangents_bitangents=True, in_place=True)¶
Apply affine transformation to a mesh.
- Parameters:
mesh (SurfaceMesh) – Input mesh.
affine_transform (Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=(4, 4), order='F')]) – Affine transformation matrix.
normalize_normals (bool) – Whether to normalize normals.
normalize_tangents_bitangents (bool) – Whether to normalize tangents and bitangents.
in_place (bool) – Whether to apply transformation in place.
- Returns:
Transformed mesh if in_place is False.
- Return type:
SurfaceMesh | None
- lagrange.core.triangulate_polygonal_facets(mesh, scheme='earcut')¶
Triangulate polygonal facets of the mesh.
- Parameters:
mesh (SurfaceMesh) – The input mesh to be triangulated in place.
scheme (str) – The triangulation scheme (options are ‘earcut’ and ‘centroid_fan’)
- Return type:
None
- lagrange.core.trim_by_isoline(mesh, attribute, isovalue=0.0, keep_below=True)¶
Trim a triangle mesh by an isoline.
- Parameters:
mesh (SurfaceMesh) – Input triangle mesh.
attribute (int | str) – Attribute ID or name of scalar field (vertex or indexed).
isovalue (float) – Isovalue to trim with.
keep_below (bool) – Whether to keep the part below the isoline.
- Returns:
Trimmed mesh.
- Return type:
- lagrange.core.unify_index_buffer(mesh: SurfaceMesh) SurfaceMesh¶
- lagrange.core.unify_index_buffer(mesh: SurfaceMesh, attribute_ids: collections.abc.Sequence[int]) SurfaceMesh
- lagrange.core.unify_index_buffer(mesh: SurfaceMesh, attribute_names: collections.abc.Sequence[str]) SurfaceMesh
Unify the index buffer for selected attributes.
- Parameters:
mesh – Input mesh.
attribute_names – Attribute names to unify.
- Returns:
Unified mesh.
- lagrange.core.uv_mesh_ref(mesh, uv_attribute_name='')¶
Extract a UV mesh reference from a 3D mesh.
- Parameters:
mesh (SurfaceMesh) – Input mesh.
uv_attribute_name (str) – Name of the (indexed or vertex) UV attribute.
- Returns:
A new mesh representing the UV mesh.
- Return type:
- lagrange.core.uv_mesh_view(mesh, uv_attribute_name='')¶
Extract a UV mesh view from a 3D mesh.
- Parameters:
mesh (SurfaceMesh) – Input mesh.
uv_attribute_name (str) – Name of the (indexed or vertex) UV attribute.
- Returns:
A new mesh representing the UV mesh.
- Return type:
- lagrange.core.weld_indexed_attribute(mesh, attribute_id, epsilon_rel=None, epsilon_abs=None, angle_abs=None, exclude_vertices=None)¶
Weld indexed attribute.
- Parameters:
mesh (SurfaceMesh) – The source mesh to be updated in place.
attribute_id (int) – The indexed attribute id to weld.
epsilon_rel (float | None) – The relative tolerance for welding.
epsilon_abs (float | None) – The absolute tolerance for welding.
angle_abs (float | None) – The absolute angle tolerance for welding.
exclude_vertices (collections.abc.Sequence[int] | None) – Optional list of vertex indices to exclude from welding.
- Return type:
None
- lagrange.core.invalid_index: int = 4294967295¶
- lagrange.core.invalid_scalar: float¶