Lagrange
lagrange::internal Namespace Reference

nullptr_t, size_t, ptrdiff_t basic_ostream bad_weak_ptr extent, remove_extent, is_array, is_void, common_type move, forward, swap More...

Classes

struct  BucketSortOffset
 Bucket sort offset infos. More...
 
struct  BucketSortResult
 Bucket sort result object. More...
 
class  control_block
 NOT implemented: custom allocator support. More...
 
class  control_block_base
 
class  default_delete
 
class  default_delete< T[]>
 
struct  InverseMapping
 A simple struct representing the inverse of a 1-to-many mapping. More...
 
struct  MapAttributesOptions
 Attribute mapping options. More...
 
class  ptr
 
class  shared_ptr
 NOT implemented: custom allocator support. More...
 
class  shared_ptr_access
 
class  shared_ptr_access< T, false, true >
 
class  shared_ptr_access< T, true, false >
 
struct  SkinningExtractNResult
 
struct  UnorientedEdge
 
class  weak_ptr
 

Enumerations

enum class  ResetToDefault { Yes , No }
 

Functions

LA_CORE_API std::string_view to_string (AttributeElement element)
 Returns a string representation of an attribute element type. More...
 
LA_CORE_API std::string to_string (BitField< AttributeElement > element)
 Returns a string representation of an attribute element type. More...
 
LA_CORE_API std::string_view to_string (AttributeUsage usage)
 Returns a string representation of an attribute usage. More...
 
template<typename ValueType >
std::string_view value_type_name (const lagrange::Attribute< ValueType > &attr)
 Returns a string representation of the attribute value type. More...
 
template<typename ValueType >
std::string_view value_type_name ()
 Returns a string representation of the attribute value type. More...
 
template<typename DerivedF , typename DerivedFF , typename DerivedC >
void bfs_orient (const Eigen::MatrixBase< DerivedF > &F, Eigen::PlainObjectBase< DerivedFF > &FF, Eigen::PlainObjectBase< DerivedC > &C)
 
template<typename Scalar , typename Index >
void dijkstra (SurfaceMesh< Scalar, Index > &mesh, span< const Index > seed_vertices, span< const Scalar > seed_vertex_dist, Scalar radius, const function_ref< Scalar(Index, Index)> &dist, const function_ref< bool(Index, Scalar)> &process)
 Traverse the mesh based on Dijkstra's algorithm with customized distance metric and process functions. More...
 
template<typename DerivedV , typename DerivedF , typename DeriveddblA >
void doublearea (const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedF > &F, Eigen::PlainObjectBase< DeriveddblA > &dblA)
 
template<typename Index , typename Func >
std::vector< Index > fast_edge_sort (Index num_edges, Index num_vertices, Func get_edge, span< Index > vertex_to_first_edge={})
 Sort an array of edges using a parallel bucket sort. More...
 
template<typename ExpectedValueType , typename Scalar , typename Index >
AttributeId find_matching_attribute (const SurfaceMesh< Scalar, Index > &mesh, std::string_view name, BitField< AttributeElement > expected_element, AttributeUsage expected_usage, size_t expected_channels)
 Find an attribute with a given name, ensuring the usage and element type match an expected target. More...
 
template<typename ExpectedValueType , typename Scalar , typename Index >
AttributeId find_matching_attribute (const SurfaceMesh< Scalar, Index > &mesh, span< const AttributeId > selected_ids, BitField< AttributeElement > expected_element, AttributeUsage expected_usage, size_t expected_channels)
 Find an attribute from a selected set of ids, ensuring the usage and element type match an expected target. More...
 
template<typename ExpectedValueType , typename Scalar , typename Index >
AttributeId find_attribute (const SurfaceMesh< Scalar, Index > &mesh, std::string_view name, BitField< AttributeElement > expected_element, AttributeUsage expected_usage, size_t expected_channels)
 Find an attribute with a given name, ensuring the usage and element type match an expected target. More...
 
template<typename ExpectedValueType , typename Scalar , typename Index >
AttributeId find_or_create_attribute (SurfaceMesh< Scalar, Index > &mesh, std::string_view name, AttributeElement expected_element, AttributeUsage expected_usage, size_t expected_channels, ResetToDefault reset_tag)
 Either retrieve or create an attribute with a prescribed name, element type and usage. More...
 
template<typename DerivedV , typename DerivedF , typename DerivedK >
void internal_angles (const Eigen::MatrixBase< DerivedV > &vertices, const Eigen::MatrixBase< DerivedF > &facets, Eigen::PlainObjectBase< DerivedK > &angles)
 Compute internal angles for a triangle mesh. More...
 
template<typename Index , typename Function >
InverseMapping< Index > invert_mapping (Index num_source_elements, Function old_to_new, Index num_target_elements=invalid< Index >())
 Compute the target-to-source (i.e. More...
 
template<typename Index >
InverseMapping< Index > invert_mapping (span< const Index > old_to_new, Index num_target_elements=invalid< Index >())
 Compute the target-to-source (i.e. More...
 
template<AttributeElement element, typename Scalar , typename Index >
void map_attributes (const SurfaceMesh< Scalar, Index > &source_mesh, SurfaceMesh< Scalar, Index > &target_mesh, span< const Index > mapping_data, span< const Index > mapping_offsets={}, const MapAttributesOptions &options={})
 Map attributes from the source mesh to the target mesh. More...
 
template<typename DerivedF , typename DerivedC , typename AScalar >
void orientable_patches (const Eigen::MatrixBase< DerivedF > &F, Eigen::PlainObjectBase< DerivedC > &C, Eigen::SparseMatrix< AScalar > &A)
 
template<typename DerivedF , typename DerivedC >
void orientable_patches (const Eigen::MatrixBase< DerivedF > &F, Eigen::PlainObjectBase< DerivedC > &C)
 
template<typename T , typename... Args>
shared_ptr< T > make_shared (Args &&... args)
 Creates a shared_ptr that manages a new object.
 
template<typename T , typename A , typename... Args>
shared_ptr< T > allocate_shared (const A &a, Args &&... args)=delete
 
template<typename T , typename U >
bool operator== (const shared_ptr< T > &sp1, const shared_ptr< U > &sp2)
 Operator == overloading.
 
template<typename T >
bool operator== (const shared_ptr< T > &sp, std::nullptr_t) noexcept
 
template<typename T >
bool operator== (std::nullptr_t, const shared_ptr< T > &sp) noexcept
 
template<typename T , typename U >
bool operator!= (const shared_ptr< T > &sp1, const shared_ptr< U > &sp2)
 Operator != overloading.
 
template<typename T >
bool operator!= (const shared_ptr< T > &sp, std::nullptr_t) noexcept
 
template<typename T >
bool operator!= (std::nullptr_t, const shared_ptr< T > &sp) noexcept
 
template<typename T >
void swap (shared_ptr< T > &sp1, shared_ptr< T > &sp2)
 Swaps with another shared_ptr.
 
template<typename T , typename U >
shared_ptr< T > static_pointer_cast (const shared_ptr< U > &sp) noexcept
 
template<typename T , typename U >
shared_ptr< T > const_pointer_cast (const shared_ptr< U > &sp) noexcept
 
template<typename T , typename U >
shared_ptr< T > dynamic_pointer_cast (const shared_ptr< U > &sp) noexcept
 
template<typename T , typename U >
shared_ptr< T > reinterpret_pointer_cast (const shared_ptr< U > &sp) noexcept
 
template<class E , class T , class Y >
std::basic_ostream< E, T > & operator<< (std::basic_ostream< E, T > &os, const shared_ptr< Y > &sp)
 
template<typename Scalar , typename Index >
void skinning_deform (SurfaceMesh< Scalar, Index > &mesh, const lagrange::Attribute< Scalar > &original_vertices, const std::vector< Eigen::Transform< Scalar, 3, Eigen::TransformTraits::Affine > > &transforms, const Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > &weights, const Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > &weight_complement={})
 Performs linear blend skinning deformation on a mesh. More...
 
template<typename Scalar , typename Index >
void skinning_deform (SurfaceMesh< Scalar, Index > &mesh, const Attribute< Scalar > &original_vertices, const std::vector< Eigen::Transform< Scalar, 3, Eigen::TransformTraits::Affine > > &transforms)
 Performs linear blend skinning on a mesh, using weights information from the mesh attributes. More...
 
template<typename Scalar , typename Index >
SkinningExtractNResult< Scalar, Index > skinning_extract_n (const Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > &weights, int n, const Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > &weight_complement=Eigen::Matrix< Scalar, Eigen::Dynamic, 1 >())
 From a weight matrix |V| x |H|, constructs a weight matrix |V| x n, where n is an arbitrary contraint (typically 4 or 8). More...
 
template<typename Scalar , typename Index , typename WeightScalar = Scalar>
lagrange::AttributeId weights_to_mesh_attribute (SurfaceMesh< Scalar, Index > &mesh, const Eigen::Matrix< WeightScalar, Eigen::Dynamic, Eigen::Dynamic > &weights)
 Imports the weights matrix as weight attributes of the mesh. More...
 
template<typename Scalar , typename Index , typename WeightScalar = Scalar, typename WeightIndex = Index>
std::pair< lagrange::AttributeId, lagrange::AttributeIdweights_to_indexed_mesh_attribute (SurfaceMesh< Scalar, Index > &mesh, const Eigen::Matrix< WeightScalar, Eigen::Dynamic, Eigen::Dynamic > &weights, int n)
 Imports the weights matrix as indexed weight attributes of the mesh. More...
 
template<typename DerivedX , typename DerivedIX >
void sortrows (const Eigen::DenseBase< DerivedX > &X, const bool ascending, Eigen::PlainObjectBase< DerivedX > &Y, Eigen::PlainObjectBase< DerivedIX > &IX)
 
template<typename DerivedX >
void sortrows (const Eigen::DenseBase< DerivedX > &X, const bool ascending, Eigen::PlainObjectBase< DerivedX > &Y)
 
template<typename Scalar >
std::string_view string_from_scalar ()
 Returns a human-readable string from any supported attribute value type. More...
 
template<typename DerivedA , typename DerivedC , typename DerivedIA , typename DerivedIC >
void unique_rows (const Eigen::DenseBase< DerivedA > &A, Eigen::PlainObjectBase< DerivedC > &C, Eigen::PlainObjectBase< DerivedIA > &IA, Eigen::PlainObjectBase< DerivedIC > &IC)
 
template<typename DerivedA , typename DerivedC , typename Derivedcounts >
void vertex_components (const Eigen::SparseCompressedBase< DerivedA > &A, Eigen::PlainObjectBase< DerivedC > &C, Eigen::PlainObjectBase< Derivedcounts > &counts)
 
template<typename DerivedA , typename DerivedC >
void vertex_components (const Eigen::SparseCompressedBase< DerivedA > &A, Eigen::PlainObjectBase< DerivedC > &C)
 
template<typename Func , typename Scalar , typename Index >
void visit_attribute_read (const SurfaceMesh< Scalar, Index > &mesh, AttributeId id, Func &&func)
 Apply a function to a read-only mesh attribute. More...
 
template<typename Func , typename Scalar , typename Index >
void visit_attribute_write (SurfaceMesh< Scalar, Index > &mesh, AttributeId id, Func &&func)
 Apply a function to a writeable mesh attribute. More...
 
template<typename T >
void swap (weak_ptr< T > &wp1, weak_ptr< T > &wp2)
 Swaps with another weak_ptr.
 
template<typename MeshType >
auto compute_triangle_areas (const MeshType &mesh) -> AttributeArrayOf< MeshType >
 Calculates the triangle areas. More...
 
template<typename MeshType >
auto compute_quad_areas (const MeshType &mesh) -> AttributeArrayOf< MeshType >
 Calculates the quad areas. More...
 
bool point_on_segment_2d (Eigen::Vector2d p, Eigen::Vector2d a, Eigen::Vector2d b)
 
bool point_on_segment_3d (Eigen::Vector3d p, Eigen::Vector3d a, Eigen::Vector3d b)
 
template<typename Index >
BucketSortResult< Index > bucket_sort (DisjointSets< Index > &unified_indices, span< Index > element_representative)
 Performs a bucket sort over a range of elements. More...
 
template<typename Index , typename Function >
BucketSortOffset< Index > bucket_sort (std::vector< Index > &elements, Index num_buckets, Function get_representative)
 Perform a bucket sort over a range of elements in place. More...
 
template<typename Scalar , typename Index >
Eigen::Matrix< Scalar, 3, 1 > compute_weighted_corner_normal (SurfaceMesh< Scalar, Index > &mesh, Index ci, NormalWeightingType weighting=NormalWeightingType::CornerTriangleArea)
 Compute weighted corner normal based on the weighting type. More...
 
template<typename Scalar , typename Index >
auto recompute_facet_normal_if_needed (SurfaceMesh< Scalar, Index > &mesh, std::string_view facet_normal_attribute_name, bool recompute_facet_normals)
 Compute facet normal attribute if necessary or as requested. More...
 

Detailed Description

nullptr_t, size_t, ptrdiff_t basic_ostream bad_weak_ptr extent, remove_extent, is_array, is_void, common_type move, forward, swap

This file contains commonly used functions related to skinning deformation on a mesh.

skinning_deform deforms a mesh with weights.

skinning_extract_n takes a weight matrix |V| x |H| and outputs indexed weights, up to n per vertex.

weights_to_mesh_attribute and weights_to_indexed_mesh_attribute save a weights matrix as attributes.

Function Documentation

◆ to_string() [1/3]

std::string_view to_string ( AttributeElement  element)

Returns a string representation of an attribute element type.

Parameters
[in]elementAttribute element type.
Returns
String representation.

◆ to_string() [2/3]

std::string to_string ( BitField< AttributeElement element)

Returns a string representation of an attribute element type.

Parameters
[in]elementAttribute element type.
Returns
String representation.

◆ to_string() [3/3]

std::string_view to_string ( AttributeUsage  usage)

Returns a string representation of an attribute usage.

Parameters
[in]usageAttribute usage.
Returns
String representation.

◆ value_type_name() [1/2]

std::string_view value_type_name ( const lagrange::Attribute< ValueType > &  attr)

Returns a string representation of the attribute value type.

Parameters
[in]attrInput attribute.
Template Parameters
ValueTypeAttribute value type.
Returns
String representation.

◆ value_type_name() [2/2]

std::string_view value_type_name ( )

Returns a string representation of the attribute value type.

Template Parameters
ValueTypeAttribute value type.
Returns
String representation.

◆ dijkstra()

void dijkstra ( SurfaceMesh< Scalar, Index > &  mesh,
span< const Index >  seed_vertices,
span< const Scalar >  seed_vertex_dist,
Scalar  radius,
const function_ref< Scalar(Index, Index)> &  dist,
const function_ref< bool(Index, Scalar)> &  process 
)

Traverse the mesh based on Dijkstra's algorithm with customized distance metric and process functions.

Template Parameters
ScalarMesh scalar type
IndexMesh index type
Parameters
meshThe input mesh.
seed_verticesSeed vertices.
seed_vertex_distInitial distance to the seed vertices.
radiusThe radius of the search. Radius <= 0 denotes the search is over the entire mesh.
distThe distance metric. e.g. d = dist(v0, v1)
processCall back function to process each new vertex reached. Its return type indicates whether the search is done. e.g. done = process(vid, v_dist)

◆ fast_edge_sort()

std::vector< Index > fast_edge_sort ( Index  num_edges,
Index  num_vertices,
Func  get_edge,
span< Index >  vertex_to_first_edge = {} 
)

Sort an array of edges using a parallel bucket sort.

Todo:
Maybe we can implement a local cache system for SurfaceMesh<> to reuse tmp buffers. Maybe this would make the add_vertex/add_facet functions efficient enough that we do not need to allocate them all at once in our triangulate_polygonal_facets function.
Parameters
[in]num_edgesNumber of edges to sort.
[in]num_verticesNumber of vertices in the mesh.
[in]get_edgeCallback to retrieve the n-th edge endpoints. Must be safe to call from multiple threads.
[in]vertex_to_first_edgeOptional buffer of size num_vertices + 1 to avoid internal allocations on repeated uses.
Template Parameters
IndexEdge index type.
FuncCallback function to retrieve edge endpoints.
Returns
A vector of sorted edge indices. Edges with repeated endpoints will be continuous in the sorted array.

◆ find_matching_attribute() [1/2]

AttributeId find_matching_attribute ( const SurfaceMesh< Scalar, Index > &  mesh,
std::string_view  name,
BitField< AttributeElement expected_element,
AttributeUsage  expected_usage,
size_t  expected_channels 
)

Find an attribute with a given name, ensuring the usage and element type match an expected target.

If the provided name is empty, the first attribute with matching properties is returned. If no such attribute is found, invalid_attribute_id() is returned instead.

Parameters
meshMesh where to look for attributes.
[in]nameOptional name of the attribute to find. If empty, the first matching attribute id will be returned.
[in]expected_elementExpected element type.
[in]expected_usageExpected attribute usage.
[in]expected_channelsExpected number of channels. If 0, then the check is skipped.
Template Parameters
ExpectedValueTypeExpected attribute value type.
ScalarMesh scalar type.
IndexMesh index type.
Returns
Attribute id of the first matching attribute.

◆ find_matching_attribute() [2/2]

AttributeId find_matching_attribute ( const SurfaceMesh< Scalar, Index > &  mesh,
span< const AttributeId selected_ids,
BitField< AttributeElement expected_element,
AttributeUsage  expected_usage,
size_t  expected_channels 
)

Find an attribute from a selected set of ids, ensuring the usage and element type match an expected target.

If the provided selected_ids is empty, it will search all attributes. Otherwise, only attributes corresponding to selected_ids are searched. The first attribute with matching properties is returned. If no such attribute is found, invalid_attribute_id() is returned instead.

Parameters
meshMesh where to look for attributes.
[in]selected_idsSelected attribute ids.
[in]expected_elementExpected element type.
[in]expected_usageExpected attribute usage.
[in]expected_channelsExpected number of channels. If 0, then the check is skipped.
Template Parameters
ExpectedValueTypeExpected attribute value type.
ScalarMesh scalar type.
IndexMesh index type.
Returns
Attribute id of the first matching attribute.

◆ find_attribute()

AttributeId find_attribute ( const SurfaceMesh< Scalar, Index > &  mesh,
std::string_view  name,
BitField< AttributeElement expected_element,
AttributeUsage  expected_usage,
size_t  expected_channels 
)

Find an attribute with a given name, ensuring the usage and element type match an expected target.

This function does not allow empty names to be provided.

Parameters
meshMesh where to look for attributes.
[in]nameName of the attribute to find.
[in]expected_elementExpected element type.
[in]expected_usageExpected attribute usage.
[in]expected_channelsExpected number of channels. If 0, then the check is skipped.
Template Parameters
ExpectedValueTypeExpected attribute value type.
ScalarMesh scalar type.
IndexMesh index type.
Returns
Attribute id of the first matching attribute.

◆ find_or_create_attribute()

AttributeId find_or_create_attribute ( SurfaceMesh< Scalar, Index > &  mesh,
std::string_view  name,
AttributeElement  expected_element,
AttributeUsage  expected_usage,
size_t  expected_channels,
ResetToDefault  reset_tag 
)

Either retrieve or create an attribute with a prescribed name, element type and usage.

When retrieving an existing attribute, this function performs additional sanity checks, such as ensuring that the attribute usage is correctly set, that the number of channels is correct, etc.

Parameters
meshMesh whose attribute to retrieve.
[in]nameName of the attribute to retrieve.
[in]expected_elementExpected element type.
[in]expected_usageExpected attribute usage.
[in]expected_channelsExpected number of channels. If 0, then the check is skipped.
[in]reset_tagWhether to reset attribute values to default (if attribute is not created).
Template Parameters
ExpectedValueTypeExpected attribute value type.
ScalarMesh scalar type.
IndexMesh index type.
Returns
Attribute id for the retrieved attribute.

◆ internal_angles()

void internal_angles ( const Eigen::MatrixBase< DerivedV > &  vertices,
const Eigen::MatrixBase< DerivedF > &  facets,
Eigen::PlainObjectBase< DerivedK > &  angles 
)

Compute internal angles for a triangle mesh.

Parameters
[in]vertices#vertices by dim Eigen matrix of mesh vertex nD positions.
[in]facets#facets by 3 eigen Matrix of face (triangle) indices,
[out]angles#facets by 3 eigen Matrix of internal angles for triangles, columns correspond to edges [1,2],[2,0],[0,1].
Template Parameters
DerivedVVertices matrix type.
DerivedFFacets matrix type.
DerivedKAngles matrix type.

◆ invert_mapping() [1/2]

InverseMapping< Index > invert_mapping ( Index  num_source_elements,
Function  old_to_new,
Index  num_target_elements = invalid<Index>() 
)

Compute the target-to-source (i.e.

backward) mapping from an input source-to-target (i.e. forward) mapping.

Note
The input source-to-target mapping may be a 1-to-many mapping, where multiple source elements may be mapped to a single target element. If a target element is set to invalid<Index>(), no backward mapping will be created for that target element.
Parameters
[in]num_source_elementsThe number of source elements.
[in]old_to_newSource-to-target mapping function.
[in]num_target_elementsThe total number of target elements. If set to invalid<Index>(), it is automatically calculated from the forward mapping.
Template Parameters
IndexThe index type.
FunctionMapping function type.
Returns
A struct representing the target-to-source mapping.

◆ invert_mapping() [2/2]

InverseMapping< Index > invert_mapping ( span< const Index >  old_to_new,
Index  num_target_elements = invalid<Index>() 
)

Compute the target-to-source (i.e.

backward) mapping from an input source-to-target (i.e. forward) mapping.

Note
The input source-to-target mapping may be a 1-to-many mapping, where multiple source elements may be mapped to a single target element. If a target element is set to invalid<Index>(), no backward mapping will be created for that target element.
Parameters
[in]old_to_newSource-to-target mapping.
[in]num_target_elementsThe total number of target elements. If set to invalid<Index>(), it is automatically calculated from the forward mapping.
Template Parameters
IndexThe index type.
Returns
A struct representing the target-to-source mapping.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ map_attributes()

void map_attributes ( const SurfaceMesh< Scalar, Index > &  source_mesh,
SurfaceMesh< Scalar, Index > &  target_mesh,
span< const Index >  mapping_data,
span< const Index >  mapping_offsets = {},
const MapAttributesOptions options = {} 
)

Map attributes from the source mesh to the target mesh.

This is the most general version that supports many-to-many mapping. Collision policy settings in options define the behavior when multiple source vertices are mapped to the same target vertex.

Template Parameters
ScalarThe scalar type.
IndexThe index type.
Parameters
source_meshThe source mesh.
target_meshThe target mesh.
mapping_dataA flat array of source element indices.
mapping_offsetsThe offset index array into the mapping_data. Source element with index listed from mapping_data[mapping_offset[i]] to mapping_data[mapping_offset[i+1]] are mapped to target element i. If empty, source element with index mapping_data[i] is mapped to target element i.
optionsOption settings.
See also
MapAttributesOptions.

◆ skinning_deform() [1/2]

void skinning_deform ( SurfaceMesh< Scalar, Index > &  mesh,
const lagrange::Attribute< Scalar > &  original_vertices,
const std::vector< Eigen::Transform< Scalar, 3, Eigen::TransformTraits::Affine > > &  transforms,
const Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > &  weights,
const Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > &  weight_complement = {} 
)

Performs linear blend skinning deformation on a mesh.

Parameters
[in,out]meshvertices of this mesh will be modified
[in]original_verticesoriginal positions of vertices
[in]transformsvector of eigen affine transforms, describe the global movement of each handle/joint
[in]weights|V| x |handle| weight matrix
[in]weight_complementoptional, acts as weights for an extra handle that does not move.

◆ skinning_deform() [2/2]

void skinning_deform ( SurfaceMesh< Scalar, Index > &  mesh,
const Attribute< Scalar > &  original_vertices,
const std::vector< Eigen::Transform< Scalar, 3, Eigen::TransformTraits::Affine > > &  transforms 
)

Performs linear blend skinning on a mesh, using weights information from the mesh attributes.

Parameters
[in,out]meshvertices of this mesh will be modified
[in]original_verticesoriginal positions of vertices
[in]transformsvector of eigen affine transforms, describe the global movement of each handle/joint

◆ skinning_extract_n()

SkinningExtractNResult< Scalar, Index > skinning_extract_n ( const Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > &  weights,
int  n,
const Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > &  weight_complement = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>() 
)

From a weight matrix |V| x |H|, constructs a weight matrix |V| x n, where n is an arbitrary contraint (typically 4 or 8).

Parameters
[in]weights|V| x |handle| weight matrix
[in]nmax number of weights for each vertex
[in]weight_complementoptional, acts as weights for an extra handle that does not move.
Returns
|V| x n weights and |V| x n indices (see struct above).

◆ weights_to_mesh_attribute()

lagrange::AttributeId weights_to_mesh_attribute ( SurfaceMesh< Scalar, Index > &  mesh,
const Eigen::Matrix< WeightScalar, Eigen::Dynamic, Eigen::Dynamic > &  weights 
)

Imports the weights matrix as weight attributes of the mesh.

Parameters
[in,out]meshMesh to modify
[in]weightsweights matrix
Returns
new weights attribute id

◆ weights_to_indexed_mesh_attribute()

std::pair< lagrange::AttributeId, lagrange::AttributeId > weights_to_indexed_mesh_attribute ( SurfaceMesh< Scalar, Index > &  mesh,
const Eigen::Matrix< WeightScalar, Eigen::Dynamic, Eigen::Dynamic > &  weights,
int  n 
)

Imports the weights matrix as indexed weight attributes of the mesh.

Parameters
[in,out]meshMesh to modify
[in]weightsWeights matrix
[in]nmax weights per vertex
Returns
pair of new attribute ids: index and weight

◆ string_from_scalar()

std::string_view string_from_scalar ( )

Returns a human-readable string from any supported attribute value type.

Template Parameters
ScalarCan be any supported attribute value type.
Returns
A human-readable string view of the type name.

◆ visit_attribute_read()

void visit_attribute_read ( const SurfaceMesh< Scalar, Index > &  mesh,
AttributeId  id,
Func &&  func 
)

Apply a function to a read-only mesh attribute.

Parameters
[in]meshInput mesh.
[in]idAttribute id to apply the function to.
funcFunction to apply.
Template Parameters
FuncFunction type.
ScalarMesh scalar type.
IndexMesh index type.
Note
To make this a public API function, we probably need (1) a name vs id variant, and (2) maybe a variant for indexed vs non-indexed to avoid having to constexpr our way through all possibilities. Or maybe we just make the function take an AttributeBase & as input?

◆ visit_attribute_write()

void visit_attribute_write ( SurfaceMesh< Scalar, Index > &  mesh,
AttributeId  id,
Func &&  func 
)

Apply a function to a writeable mesh attribute.

Parameters
[in]meshInput mesh.
[in]idAttribute id to apply the function to.
funcFunction to apply.
Template Parameters
FuncFunction type.
ScalarMesh scalar type.
IndexMesh index type.
Note
To make this a public API function, we probably need (1) a name vs id variant, and (2) maybe a variant for indexed vs non-indexed to avoid having to constexpr our way through all possibilities. Or maybe we just make the function take an AttributeBase & as input?

◆ compute_triangle_areas()

auto compute_triangle_areas ( const MeshType mesh) -> AttributeArrayOf<MeshType>

Calculates the triangle areas.

Parameters
[in]meshInput triangle mesh.
Template Parameters
MeshTypeMesh type.
Returns
#F x 1 array of triangle areas.

◆ compute_quad_areas()

auto compute_quad_areas ( const MeshType mesh) -> AttributeArrayOf<MeshType>

Calculates the quad areas.

Parameters
[in]meshInput quad mesh.
Template Parameters
MeshTypeMesh type.
Returns
#F x 1 array of quad areas.

◆ bucket_sort() [1/2]

BucketSortResult< Index > bucket_sort ( DisjointSets< Index > &  unified_indices,
span< Index >  element_representative 
)

Performs a bucket sort over a range of elements.

Parameters
[in,out]unified_indicesDisjoint sets covering the range of elements to sort. Due to path compression in the disjoint sets' find() method, this argument is not const.
[out]element_representativeOutput buffer storing the representative index for each element in the range. Typically this will be the index buffer of a target indexed attribute.
Template Parameters
IndexIndex type to sort.
Returns
Bucket sort result containing a list of sorted element indices and an offset for each representative element.

◆ bucket_sort() [2/2]

BucketSortOffset< Index > bucket_sort ( std::vector< Index > &  elements,
Index  num_buckets,
Function  get_representative 
)

Perform a bucket sort over a range of elements in place.

Parameters
[in,out]elementsElements to sort.
[in]num_bucketsNumber of buckets (max element in the range + 1).
[in]get_representativeFunction to get the representative bucket for a given element.
Template Parameters
IndexIndex type.
FunctionCallback function type.
Returns
Info about the sorted buckets.

◆ compute_weighted_corner_normal()

Eigen::Matrix< Scalar, 3, 1 > compute_weighted_corner_normal ( SurfaceMesh< Scalar, Index > &  mesh,
Index  ci,
NormalWeightingType  weighting = NormalWeightingType::CornerTriangleArea 
)

Compute weighted corner normal based on the weighting type.

Parameters
[in]meshThe input mesh.
[in]ciThe target corner index.
[in]weightingThe weighting type.
Returns
the weighted normal vector corresponding to the target corner.

◆ recompute_facet_normal_if_needed()

auto recompute_facet_normal_if_needed ( SurfaceMesh< Scalar, Index > &  mesh,
std::string_view  facet_normal_attribute_name,
bool  recompute_facet_normals 
)

Compute facet normal attribute if necessary or as requested.

Template Parameters
ScalarMesh scalar type
IndexMesh index type
Parameters
meshThe input mesh.
facet_normal_attribute_nameThe facet normal attribute name.
recompute_facet_normalsWhether to recompute facet normals if one already exists.
Returns
A pair of the facet normal attribute id and a boolean indicating whether the facet