Lagrange

Manipulating mesh attributes. More...

Classes

class  AttributeBase
 Base handle for attributes. More...
 
class  Attribute< ValueType_ >
 Derived attribute class that stores the actual information. More...
 
class  IndexedAttribute< ValueType_, Index_ >
 Derived attribute class that stores the actual information. More...
 

Macros

#define LA_ATTRIBUTE_X(mode, data)
 X Macro arguments for the Attribute<> class. More...
 
#define LA_ATTRIBUTE_INDEX_X(mode, data)
 X Macro arguments for the Attribute<> class. More...
 
#define LA_ATTRIBUTE_SCALAR_X(mode, data)
 X Macro arguments for the Attribute<> class. More...
 
#define LA_X_attribute_make_value_type(_, ValueType)
 

Typedefs

using AttributeId = uint32_t
 Identified to be used to access an attribute. More...
 

Enumerations

enum  AttributeElement : int {
  Vertex = (1 << 0) , Facet = (1 << 1) , Edge = (1 << 2) , Corner = (1 << 3) ,
  Value = (1 << 4) , Indexed = (1 << 5)
}
 Type of element to which the attribute is attached. More...
 
enum class  AttributeUsage : uint16_t {
  Vector = (1 << 0) , Scalar = (1 << 1) , Position = (1 << 2) , Normal = (1 << 3) ,
  Tangent = (1 << 4) , Bitangent = (1 << 5) , Color = (1 << 6) , UV = (1 << 7) ,
  VertexIndex = (1 << 8) , FacetIndex = (1 << 9) , CornerIndex = (1 << 10) , EdgeIndex = (1 << 11) ,
  String = (1 << 12)
}
 Usage tag indicating how the attribute should behave under mesh transformations. More...
 
enum class  AttributeCreatePolicy { ErrorIfReserved , Force }
 Policy for attribute creation with reserved attribute names. More...
 
enum class  AttributeGrowthPolicy { ErrorIfExternal , AllowWithinCapacity , WarnAndCopy , SilentCopy }
 Policy for growing external attribute buffers. More...
 
enum class  AttributeShrinkPolicy { ErrorIfExternal , IgnoreIfExternal , WarnAndCopy , SilentCopy }
 Policy for shrinking external attribute buffers. More...
 
enum class  AttributeWritePolicy { ErrorIfReadOnly , WarnAndCopy , SilentCopy }
 Policy for attempting to write to read-only external buffers. More...
 
enum class  AttributeExportPolicy { CopyIfExternal , CopyIfUnmanaged , KeepExternalPtr , ErrorIfExternal }
 Policy for exporting attributes that are views onto external buffers. More...
 
enum class  AttributeCopyPolicy { CopyIfExternal , KeepExternalPtr , ErrorIfExternal }
 Policy for copying attribute that are views onto external buffers. More...
 
enum class  AttributeDeletePolicy { ErrorIfReserved , Force }
 Policy for attribute deletion of reserved attribute names. More...
 
enum class  AttributeValueType : uint8_t { LA_X_attribute_value_type_enum }
 Enum describing at runtime the value type of an attribute. More...
 

Functions

constexpr AttributeId invalid_attribute_id ()
 Invalid attribute id.
 
template<typename ValueType >
constexpr AttributeValueType make_attribute_value_type ()
 Creates an enum describing an attribute value type. More...
 

Detailed Description

Manipulating mesh attributes.

Please read our user guide for an introduction.

Macro Definition Documentation

◆ LA_ATTRIBUTE_X

#define LA_ATTRIBUTE_X (   mode,
  data 
)

#include <lagrange/AttributeTypes.h>

Value:
LA_X_##mode(data, int8_t) \
LA_X_##mode(data, int16_t) \
LA_X_##mode(data, int32_t) \
LA_X_##mode(data, int64_t) \
LA_X_##mode(data, uint8_t) \
LA_X_##mode(data, uint16_t) \
LA_X_##mode(data, uint32_t) \
LA_X_##mode(data, uint64_t) \
LA_X_##mode(data, float) \
LA_X_##mode(data, double)

X Macro arguments for the Attribute<> class.

Since other modules might need to explicitly instantiate their own functions, this file is a public header.

Use in a .cpp as follows:

#include <lagrange/AttributeTypes.h>
#define LA_X_foo(_, ValueType) template void my_function(const Attribute<ValueType> &);
#define LA_ATTRIBUTE_X(mode, data)
X Macro arguments for the Attribute<> class.
Definition: AttributeTypes.h:48

The optional data argument can forwarded to other macros, in order to implement cartesian products when instantiating nested types.

Parameters
modeSuffix to apply to the LA_X_* macro.
dataData to be passed around as the first argument of the X macro.
Returns
Expansion of LA_X_##mode() for each type to be instantiated.

◆ LA_ATTRIBUTE_INDEX_X

#define LA_ATTRIBUTE_INDEX_X (   mode,
  data 
)

#include <lagrange/AttributeTypes.h>

Value:
LA_X_##mode(data, int8_t) \
LA_X_##mode(data, int16_t) \
LA_X_##mode(data, int32_t) \
LA_X_##mode(data, int64_t) \
LA_X_##mode(data, uint8_t) \
LA_X_##mode(data, uint16_t) \
LA_X_##mode(data, uint32_t) \
LA_X_##mode(data, uint64_t)

X Macro arguments for the Attribute<> class.

Usage is similar to LA_ATTRIBUTE_X, but it will only iterate over integral value types.

Use in a .cpp as follows:

#include <lagrange/AttributeTypes.h>
#define LA_X_foo(_, IndexType) template void my_function(const Attribute<IndexType> &);
#define LA_ATTRIBUTE_INDEX_X(mode, data)
X Macro arguments for the Attribute<> class.
Definition: AttributeTypes.h:80

The optional data argument can forwarded to other macros, in order to implement cartesian products when instantiating nested types.

Parameters
modeSuffix to apply to the LA_X_* macro.
dataData to be passed around as the first argument of the X macro.
Returns
Expansion of LA_X_##mode() for each type to be instantiated.

◆ LA_ATTRIBUTE_SCALAR_X

#define LA_ATTRIBUTE_SCALAR_X (   mode,
  data 
)

#include <lagrange/AttributeTypes.h>

Value:
LA_X_##mode(data, float) \
LA_X_##mode(data, double)

X Macro arguments for the Attribute<> class.

Usage is similar to LA_ATTRIBUTE_X, but it will only iterate over floating points value types.

Use in a .cpp as follows:

#include <lagrange/AttributeTypes.h>
#define LA_X_foo(_, IndexType) template void my_function(const Attribute<IndexType> &);
#define LA_ATTRIBUTE_SCALAR_X(mode, data)
X Macro arguments for the Attribute<> class.
Definition: AttributeTypes.h:110

The optional data argument can forwarded to other macros, in order to implement cartesian products when instantiating nested types.

Parameters
modeSuffix to apply to the LA_X_* macro.
dataData to be passed around as the first argument of the X macro.
Returns
Expansion of LA_X_##mode() for each type to be instantiated.

◆ LA_X_attribute_make_value_type

#define LA_X_attribute_make_value_type (   _,
  ValueType 
)

#include <lagrange/AttributeValueType.h>

Value:
template <> \
constexpr AttributeValueType make_attribute_value_type<ValueType>() \
{ \
return AttributeValueType::e_##ValueType; \
}
AttributeValueType
Enum describing at runtime the value type of an attribute.
Definition: AttributeValueType.h:25

Typedef Documentation

◆ AttributeId

using AttributeId = uint32_t

#include <lagrange/AttributeFwd.h>

Identified to be used to access an attribute.

Attribute names are mapped to a unique identified when created. These unique identifiers can be used to more efficiently access the data (rather than rehashing the string every time).

Enumeration Type Documentation

◆ AttributeElement

enum AttributeElement : int

#include <lagrange/AttributeFwd.h>

Type of element to which the attribute is attached.

Enumerator
Vertex 

Per-vertex mesh attributes.

Facet 

Per-facet mesh attributes.

Edge 

Per-edge mesh attributes.

Corner 

Per-corner mesh attributes.

Value 

Values that are not attached to a specific element.

Used by indexed attributes to store value buffers. It is the responsibility of the user to resize each value attribute as needed.

Indexed 

Indexed mesh attributes.

◆ AttributeUsage

enum class AttributeUsage : uint16_t
strong

#include <lagrange/AttributeFwd.h>

Usage tag indicating how the attribute should behave under mesh transformations.

This tag mostly serves as a hint, and does not impact how the attribute is stored/loaded.

Todo:
Add skinning weights + others?
Enumerator
Vector 

Mesh attribute can have any number of channels (including 1 channel).

Scalar 

Mesh attribute must have exactly 1 channel.

Position 

Mesh attribute must have exactly dim channels.

Normal 

Mesh attribute can have dim or dim + 1 channels.

Tangent 

Mesh attribute can have dim or dim + 1 channels.

Bitangent 

Mesh attribute can have dim or dim + 1 channels.

Color 

Mesh attribute can have 1, 2, 3 or 4 channels.

UV 

Mesh attribute must have exactly 2 channels.

VertexIndex 

Single channel integer attribute indexing a mesh vertex.

FacetIndex 

Single channel integer attribute indexing a mesh facet.

CornerIndex 

Single channel integer attribute indexing a mesh corner.

EdgeIndex 

Single channel integer attribute indexing a mesh edge.

String 

Mesh attribute is a metadata string (stored as a uint8_t buffer).

◆ AttributeCreatePolicy

enum class AttributeCreatePolicy
strong

#include <lagrange/AttributeFwd.h>

Policy for attribute creation with reserved attribute names.

By default, attribute names starting with "$" are reserved for internal use. Creating a reserved attribute name requires an explicit policy flag to be passed to the appropriate function.

Enumerator
ErrorIfReserved 

Default deletion policy, throw an exception if attribute name is reserved.

Force 

Force creation of reserved attribute names.

◆ AttributeGrowthPolicy

enum class AttributeGrowthPolicy
strong

#include <lagrange/AttributeFwd.h>

Policy for growing external attribute buffers.

If we need to add elements to an external attribute buffer, and we have reached the capacity of the provided span, we can either throw an exception (default behavior), or warn and create an internal copy of the buffer data.

Enumerator
ErrorIfExternal 

Throws an exception when trying to grow an external buffer (even if the new size is.

still within the buffer capacity).

AllowWithinCapacity 

Allow attribute growth as long as it remains within the capacity of the external.

buffer. Will throw an error if a reallocation is needed.

WarnAndCopy 

Logs a warning and copy the buffer data if it grows beyond the buffer capacity.

SilentCopy 

Silently copy the buffer data if it grows beyond the buffer capacity.

◆ AttributeShrinkPolicy

enum class AttributeShrinkPolicy
strong

#include <lagrange/AttributeFwd.h>

Policy for shrinking external attribute buffers.

This policy controls what happens when calling shrink_to_fit() to save memory. Shrinkage can happen either when mesh elements have been removed by another operation, or if the attribute has been created with additional capacity.

Enumerator
ErrorIfExternal 

Throws an exception when trying to shrink an external buffer (even if the new size is.

still within the buffer capacity). This is the default policy.

IgnoreIfExternal 

Ignore external buffers when trying to shrink an attribute.

WarnAndCopy 

Logs a warning and creates an internal copy of the buffer data when shrinking below capacity.

SilentCopy 

Silently copy the buffer data when shrinking below capacity.

◆ AttributeWritePolicy

enum class AttributeWritePolicy
strong

#include <lagrange/AttributeFwd.h>

Policy for attempting to write to read-only external buffers.

By default any write operation on a read-only external buffer will throw an exception. Alternatively, we can issue a warning a perform a copy of the buffer data.

Enumerator
ErrorIfReadOnly 

Throws an exception when trying to write to a read-only buffer.

WarnAndCopy 

Logs a warning and copy the buffer data.

SilentCopy 

Silently copy the buffer data.

◆ AttributeExportPolicy

enum class AttributeExportPolicy
strong

#include <lagrange/AttributeFwd.h>

Policy for exporting attributes that are views onto external buffers.

By default, a copy is created, meaning we can use the resulting pointer to manage the lifetime of the allocated data.

Enumerator
CopyIfExternal 

Copy the buffer during export if the attribute points to an external buffer.

CopyIfUnmanaged 

Copy the buffer during export if the attribute points to an unmanaged external buffer.

KeepExternalPtr 

Keep the raw pointer to the external buffer data. Use with caution.

ErrorIfExternal 

Throw an exception if the attribute points to an external buffer.

◆ AttributeCopyPolicy

enum class AttributeCopyPolicy
strong

#include <lagrange/AttributeFwd.h>

Policy for copying attribute that are views onto external buffers.

By default, a copy is created, meaning we can use the copied attribute to manage the lifetime of the allocated data.

Enumerator
CopyIfExternal 

Copy the buffer during copy if the attribute points to an external buffer.

KeepExternalPtr 

Keep the raw pointer to the external buffer data. Use with caution.

ErrorIfExternal 

Throw an exception if the attribute points to an external buffer.

◆ AttributeDeletePolicy

enum class AttributeDeletePolicy
strong

#include <lagrange/AttributeFwd.h>

Policy for attribute deletion of reserved attribute names.

By default, attribute names starting with "$" are reserved for internal use. Deleting a reserved attribute name requires an explicit policy flag to be passed to the appropriate function.

Enumerator
ErrorIfReserved 

Default deletion policy, throw an exception if attribute name is reserved.

Force 

Force deletion of reserved attribute names.

◆ AttributeValueType

enum class AttributeValueType : uint8_t
strong

#include <lagrange/AttributeValueType.h>

Enum describing at runtime the value type of an attribute.

This can be accessed from the base attribute class and enables safe downcasting without global RTTI.

Function Documentation

◆ make_attribute_value_type()

constexpr AttributeValueType make_attribute_value_type ( )
constexpr

#include <lagrange/AttributeValueType.h>

Creates an enum describing an attribute value type.

Template Parameters
ValueTypeValue type of the attribute to convert to enum.
Returns
Enum describing the input value type.