lagrange.subdivision¶
Classes¶
Face-varying interpolation rule |
|
Selection tag for interpolated attributes |
|
Subdivision scheme type |
|
Vertex boundary interpolation rule |
Functions¶
|
Computes sharpness attributes for subdivision based on existing mesh normals. |
|
Evaluates the subdivision surface of a polygonal mesh. |
Module Contents¶
- class lagrange.subdivision.FaceVaryingInterpolation(*args, **kwds)¶
Bases:
enum.EnumFace-varying interpolation rule
- All = 5¶
Linear interpolation everywhere.
- Boundaries = 4¶
Linear interpolation along all boundaries.
- CornersOnly = 1¶
Linear interpolation at corners only.
- CornersPlus1 = 2¶
CornersOnly plus sharpening at junctions of 3+ regions.
- CornersPlus2 = 3¶
CornersPlus1 plus sharpening of darts and concave corners.
- Smooth = 0¶
Smooth interpolation everywhere the mesh is smooth.
- class lagrange.subdivision.InterpolatedAttributesSelection(*args, **kwds)¶
Bases:
enum.EnumSelection tag for interpolated attributes
- All = 0¶
Interpolate all compatible attributes.
- Empty = 1¶
Do not interpolate any attributes.
- Selected = 2¶
Interpolate only selected attributes.
- class lagrange.subdivision.SchemeType(*args, **kwds)¶
Bases:
enum.EnumSubdivision scheme type
- Bilinear = 0¶
Bilinear scheme, useful before applying displacement.
- CatmullClark = 1¶
Catmull-Clark scheme for quad-dominant meshes.
- Loop = 2¶
Loop scheme for triangle meshes.
- class lagrange.subdivision.VertexBoundaryInterpolation(*args, **kwds)¶
Bases:
enum.EnumVertex boundary interpolation rule
- EdgeAndCorner = 2¶
Interpolate boundary edges and corners.
- EdgeOnly = 1¶
Interpolate boundary edges only.
- NoInterpolation = 0¶
Do not interpolate boundary edges.
- lagrange.subdivision.compute_sharpness(mesh, normal_attribute_name=None, feature_angle_threshold=None)¶
Computes sharpness attributes for subdivision based on existing mesh normals.
- Parameters:
mesh (lagrange.core.SurfaceMesh) – The input mesh. Modified in place to add the necessary attributes.
normal_attribute_name (str | None) – If provided, name of the normal attribute to use as indexed normals to define sharp edges. If not provided, the function will attempt to find an existing indexed normal attribute. If no such attribute is found, autosmooth normals will be computed based on the feature_angle_threshold parameter.
feature_angle_threshold (float | None) – Feature angle threshold (in radians) to detect sharp edges when computing autosmooth normals. By default, if no indexed normal attribute is found, no autosmooth normals will be computed.
- Returns:
A tuple containing: - vertex_sharpness_attr: Attribute id to use for vertex sharpness in the subdivide_mesh function. - edge_sharpness_attr: Attribute id to use for edge sharpness in the subdivide_mesh function. - normal_attr: Attribute id of the indexed normal attribute used to compute sharpness information.
- Return type:
tuple[int | None, int | None, int | None]
- lagrange.subdivision.subdivide_mesh(mesh, num_levels=1, scheme=None, adaptive=False, max_edge_length=None, vertex_boundary_interpolation=VertexBoundaryInterpolation.EdgeOnly, face_varying_interpolation=FaceVaryingInterpolation.Smooth, use_limit_surface=False, interpolated_attributes_selection=InterpolatedAttributesSelection.All, interpolated_smooth_attributes=None, interpolated_linear_attributes=None, edge_sharpness_attr=None, vertex_sharpness_attr=None, face_hole_attr=None, output_limit_normals=None, output_limit_tangents=None, output_limit_bitangents=None)¶
Evaluates the subdivision surface of a polygonal mesh.
- Parameters:
mesh (lagrange.core.SurfaceMesh) – The source mesh.
num_levels (int) – The number of levels of subdivision to apply.
scheme (SchemeType | None) – Subdivision scheme. If None, uses Loop for triangle meshes and CatmullClark for quad-dominant meshes.
adaptive (bool) – Whether to use edge-adaptive refinement.
max_edge_length (float | None) – Maximum edge length for adaptive refinement. If None, uses longest edge / num_levels. Ignored when adaptive is False.
vertex_boundary_interpolation (VertexBoundaryInterpolation) – Vertex boundary interpolation rule.
face_varying_interpolation (FaceVaryingInterpolation) – Face-varying interpolation rule.
use_limit_surface (bool) – Interpolate all data to the limit surface.
interpolated_attributes_selection (InterpolatedAttributesSelection) – Whether to interpolate all, none, or selected attributes.
interpolated_smooth_attributes (collections.abc.Sequence[int] | None) – Attribute ids to smoothly interpolate (per-vertex or indexed).
interpolated_linear_attributes (collections.abc.Sequence[int] | None) – Attribute ids to linearly interpolate (per-vertex only).
edge_sharpness_attr (int | None) – Per-edge scalar attribute denoting edge sharpness. Sharpness values must be in [0, 1] (0 means smooth, 1 means sharp).
vertex_sharpness_attr (int | None) – Per-vertex scalar attribute denoting vertex sharpness (e.g. for boundary corners). Sharpness values must be in [0, 1] (0 means smooth, 1 means sharp).
face_hole_attr (int | None) – Per-face integer attribute denoting face holes. A non-zero value means the facet is a hole. If a face is tagged as a hole, the limit surface will not be generated for that face.
output_limit_normals (str | None) – Output name for a newly computed per-vertex attribute containing the normals to the limit surface. Skipped if left empty.
output_limit_tangents (str | None) – Output name for a newly computed per-vertex attribute containing the tangents (first derivatives) to the limit surface. Skipped if left empty.
output_limit_bitangents (str | None) – Output name for a newly computed per-vertex attribute containing the bitangents (second derivative) to the limit surface. Skipped if left empty.
- Returns:
The subdivided mesh.
- Return type: