Enzo
Loading...
Searching...
No Matches
enzo::geo::Mesh Class Reference

Polygonal mesh primitive with point, vertex, and face attributes. More...

#include <Mesh.h>

Inheritance diagram for enzo::geo::Mesh:
enzo::geo::Primitive

Classes

struct  FaceOffsets
 

Public Member Functions

 Mesh (std::string_view path="/mesh")
 
 Mesh (const Mesh &other)
 
Meshoperator= (const Mesh &rhs)
 
PrimType getType () const override
 
std::shared_ptr< Primitiveclone () const override
 
TransformClass transformType () const override
 
void applyTransform (const Matrix4 &mat, TransformClass transformClass=TransformClass::POINT) override
 
void applyTransform (const Transform &transform, TransformClass transformClass=TransformClass::POINT)
 
bool canMerge () const override
 
void merge (std::shared_ptr< Primitive > other) override
 
bool hasPoints () const override
 
Offset addFace (const std::vector< Offset > &pointOffsets, bool closed=true)
 Adds a single face. Avoid for multiple faces in a loop as a single call to addFaces is much more performant.
 
std::vector< OffsetaddFaces (std::span< const Offset > pointOffsetsFlat, std::span< const Offset > vertexCounts, bool closed=true)
 Adds many faces in a single call.
 
Offset addPoint (const Vector3 &pos)
 
std::vector< OffsetaddPoints (std::span< const Vector3 > positions)
 Adds many points in a single call.
 
std::vector< OffsetduplicatePoints (std::span< const Offset > srcPointOffsets, bool copyAttributes=true)
 Duplicates existing points into new points carrying the same positions.
 
void deleteFaces (const std::vector< Offset > &faceOffsets, bool andPoints=true)
 
void deleteAllFaces (bool andPoints=true)
 Removes every face from the mesh.
 
void deletePoints (const std::vector< Offset > &pointOffsets) override
 
void deletePoints (const std::vector< Offset > &pointOffsets, bool andFaces)
 
void deleteVertices (const std::vector< Offset > &vertOffsets)
 
bool isValidFace (Offset offset) const
 
bool isValidVertex (Offset offset) const
 
bool isValidPoint (Offset offset) const override
 
void defragment () override
 Compacts storage, removing entries marked invalid so offsets are contiguous again.
 
void merge (Mesh &other)
 
HeMesh computeHalfEdgeMesh ()
 
std::unordered_set< Offset >::const_iterator soloPointsBegin () const
 
std::unordered_set< Offset >::const_iterator soloPointsEnd () const
 
void setPointPos (const Offset offset, const Vector3 &pos)
 
std::span< const OffsetgetFaceStartVertices () const
 Contiguous view of each face's starting vertex offset.
 
Vector3 getPosFromVert (Offset vertexOffset) const
 
Vector3 getPointPos (Offset pointOffset) const
 
unsigned int getFaceVertCount (Offset faceOffset) const
 
unsigned int getFacePointCount (Offset faceOffset) const
 
Offset getVertexFace (Offset vertexOffset) const
 
Offset getPointVertex (Offset vertexOffset) const
 
std::span< const intT > getFacePoints (Offset faceOffset) const
 
std::span< const intT > vertexPointSpan () const
 Contiguous view mapping each vertex offset to its point offset.
 
std::span< const Vector3 > pointPosSpan () const
 Contiguous view of every point position.
 
Offset getNumFaces () const
 
Offset getNumVerts () const
 
Offset getNumSoloPoints () const
 
FaceOffsets getFaces () const
 
attr::AttributeHandleBool createVertexGroup (std::string name)
 Creates a vertex group.
 
attr::AttributeHandleBool createFaceGroup (std::string name)
 Creates a face group.
 
void addToVertexGroup (const std::string &name, const std::vector< Offset > &offsets)
 Marks the given offsets as members of the vertex group.
 
void addToFaceGroup (const std::string &name, const std::vector< Offset > &offsets)
 Marks the given offsets as members of the face group.
 
boolT isClosed (Offset faceOffset) const
 
void computeFaceStartVertices () const
 
FaceNormalHandle getFaceNormal (bool precompute=false) const
 Returns a handle for reading per-face normals.
 
VertexNormalHandle getVertexNormal (bool precompute=false) const
 Returns a handle for reading per-vertex normals.
 
- Public Member Functions inherited from enzo::geo::Primitive
 Primitive (std::string_view path="/prim")
 
 Primitive (const Primitive &other)
 
Primitiveoperator= (const Primitive &rhs)
 
void applyTransform (const Transform &transform, TransformClass transformClass)
 
void incrementVersion ()
 
Offset getNumPoints () const
 
virtual PointOffsets getPoints ()
 
attr::AttributeHandle< intT > addIntAttribute (attr::AttributeOwner owner, std::string name, bool intrinsic=false)
 
attr::AttributeHandleBool addBoolAttribute (attr::AttributeOwner owner, std::string name, bool intrinsic=false, bool isPrivate=false)
 
attr::AttributeHandle< Vector3 > addVector3Attribute (attr::AttributeOwner owner, std::string name, bool intrinsic=false)
 
attr::AttributeHandle< Matrix4 > addMatrix4Attribute (attr::AttributeOwner owner, std::string name, bool intrinsic=false)
 
std::shared_ptr< attr::AttributegetAttribByName (attr::AttributeOwner owner, std::string name, bool includeIntrinsics=false)
 
std::shared_ptr< const attr::AttributegetAttribByName (attr::AttributeOwner owner, std::string name, bool includeIntrinsics=false) const
 Const counterpart of getAttribByName.
 
const size_t getNumAttributes (const attr::AttributeOwner owner) const
 
std::weak_ptr< const attr::AttributegetAttributeByIndex (attr::AttributeOwner owner, unsigned int index) const
 
bool attributeExists (attr::AttributeOwner owner, std::string name)
 
attr::AttributeHandleBool createGroup (attr::AttributeOwner owner, std::string name)
 Creates a group on the given owner.
 
void addToGroup (attr::AttributeOwner owner, const std::string &name, const std::vector< Offset > &offsets)
 Marks the given offsets as members of the group.
 
std::shared_ptr< attr::AttributegetGroupByName (attr::AttributeOwner owner, const std::string &name) const
 Looks up a group by name.
 
size_t getNumGroups (attr::AttributeOwner owner) const
 Returns how many groups live on the given owner.
 
std::weak_ptr< const attr::AttributegetGroupByIndex (attr::AttributeOwner owner, unsigned int index) const
 Returns the group at the given index in the owner's group store.
 
attr::AttributeHandleBool createPointGroup (std::string name)
 Creates a point group.
 
attr::AttributeHandleBool createPrimitiveGroup (std::string name)
 Creates a primitive group.
 
void addToPointGroup (const std::string &name, const std::vector< Offset > &offsets)
 Marks the given offsets as members of the point group.
 
void addToPrimitiveGroup (const std::string &name, const std::vector< Offset > &offsets)
 Marks the given offsets as members of the primitive group.
 
String getPath () const
 
void setPath (const String &path)
 

Protected Member Functions

attr::attribVector & getAttributeStore (const attr::AttributeOwner &owner) override
 
const attr::attribVector & getAttributeStore (const attr::AttributeOwner &owner) const override
 
attr::attribVector & getGroupStore (const attr::AttributeOwner &owner) override
 
const attr::attribVector & getGroupStore (const attr::AttributeOwner &owner) const override
 
- Protected Member Functions inherited from enzo::geo::Primitive
attr::attribVector deepCopyAttributes (attr::attribVector source)
 
size_t getElementCount (const attr::AttributeOwner &owner) const
 Returns the number of elements in the given owner's store.
 

Friends

class FaceNormalHandle
 
class VertexNormalHandle
 

Additional Inherited Members

- Protected Attributes inherited from enzo::geo::Primitive
std::string path_ = "/prim"
 
attr::attribVector pointAttributes_
 
attr::attribVector primitiveAttributes_
 
attr::attribVector pointGroups_
 
attr::attribVector primitiveGroups_
 

Detailed Description

Polygonal mesh primitive with point, vertex, and face attributes.

Extends Primitive with mesh-specific topology: points, vertices, faces, and the intrinsic attributes that describe connectivity (vertexCount, closed, point offset, and position P).

Member Function Documentation

◆ addFace()

Offset enzo::geo::Mesh::addFace ( const std::vector< Offset > & pointOffsets,
bool closed = true )

Adds a single face. Avoid for multiple faces in a loop as a single call to addFaces is much more performant.

Returns
Offset of the new face.

◆ addFaces()

std::vector< Offset > enzo::geo::Mesh::addFaces ( std::span< const Offset > pointOffsetsFlat,
std::span< const Offset > vertexCounts,
bool closed = true )

Adds many faces in a single call.

Parameters
pointOffsetsFlatAll point offsets for every face listed one after another.
vertexCountsHow many points each face has. Read in the same order as pointOffsetsFlat.
Returns
Offsets of the newly created faces in the order they were added.

◆ addPoints()

std::vector< Offset > enzo::geo::Mesh::addPoints ( std::span< const Vector3 > positions)

Adds many points in a single call.

Parameters
positionsPosition for each new point, read in order.
Returns
Offsets of the newly created points in the order they were added.

◆ applyTransform()

void enzo::geo::Mesh::applyTransform ( const Matrix4 & mat,
TransformClass transformClass = TransformClass::POINT )
overridevirtual

Implements enzo::geo::Primitive.

◆ canMerge()

bool enzo::geo::Mesh::canMerge ( ) const
inlineoverridevirtual

Reimplemented from enzo::geo::Primitive.

◆ clone()

std::shared_ptr< Primitive > enzo::geo::Mesh::clone ( ) const
inlineoverridevirtual

Implements enzo::geo::Primitive.

◆ createFaceGroup()

attr::AttributeHandleBool enzo::geo::Mesh::createFaceGroup ( std::string name)
inline

Creates a face group.

Returns
Handle to the new group.

◆ createVertexGroup()

attr::AttributeHandleBool enzo::geo::Mesh::createVertexGroup ( std::string name)
inline

Creates a vertex group.

Returns
Handle to the new group.

◆ defragment()

void enzo::geo::Mesh::defragment ( )
overridevirtual

Compacts storage, removing entries marked invalid so offsets are contiguous again.

Reimplemented from enzo::geo::Primitive.

◆ deletePoints()

void enzo::geo::Mesh::deletePoints ( const std::vector< Offset > & pointOffsets)
inlineoverridevirtual

Reimplemented from enzo::geo::Primitive.

◆ duplicatePoints()

std::vector< Offset > enzo::geo::Mesh::duplicatePoints ( std::span< const Offset > srcPointOffsets,
bool copyAttributes = true )

Duplicates existing points into new points carrying the same positions.

Parameters
srcPointOffsetsOffsets of the points to duplicate, read in order.
copyAttributesWhen true, copy every point attribute from each source point. When false, only positions are copied.
Returns
Offsets of the newly created points in the same order as srcPointOffsets.

◆ getAttributeStore() [1/2]

const attr::attribVector & enzo::geo::Mesh::getAttributeStore ( const attr::AttributeOwner & owner) const
overrideprotectedvirtual

Reimplemented from enzo::geo::Primitive.

◆ getAttributeStore() [2/2]

attr::attribVector & enzo::geo::Mesh::getAttributeStore ( const attr::AttributeOwner & owner)
overrideprotectedvirtual

Reimplemented from enzo::geo::Primitive.

◆ getFaceNormal()

geo::FaceNormalHandle enzo::geo::Mesh::getFaceNormal ( bool precompute = false) const

Returns a handle for reading per-face normals.

Normals follow the right hand rule on CCW winding viewed from outside the surface. When the mesh has a face attribute named Normal the handle reads it directly. Otherwise normals are computed via Newell's method.

Parameters
precomputeWhen true and no Normal face attribute is present, every face normal is computed up front so subsequent reads are O(1). Pay this cost when the caller plans to read most faces; skip it for sparse access.
Returns
Handle whose operator[] returns the normal for a face offset.

◆ getFaceStartVertices()

std::span< const Offset > enzo::geo::Mesh::getFaceStartVertices ( ) const

Contiguous view of each face's starting vertex offset.

Returns
Span indexed by face offset. Invalid after a mutation that grows storage.

◆ getGroupStore() [1/2]

const attr::attribVector & enzo::geo::Mesh::getGroupStore ( const attr::AttributeOwner & owner) const
overrideprotectedvirtual

Reimplemented from enzo::geo::Primitive.

◆ getGroupStore() [2/2]

attr::attribVector & enzo::geo::Mesh::getGroupStore ( const attr::AttributeOwner & owner)
overrideprotectedvirtual

Reimplemented from enzo::geo::Primitive.

◆ getType()

PrimType enzo::geo::Mesh::getType ( ) const
inlineoverridevirtual

Implements enzo::geo::Primitive.

◆ getVertexNormal()

geo::VertexNormalHandle enzo::geo::Mesh::getVertexNormal ( bool precompute = false) const

Returns a handle for reading per-vertex normals.

When the mesh has a vertex attribute named Normal the handle reads it directly. Otherwise the handle returns the owning face's normal.

Parameters
precomputeForwarded to the internal FaceNormalHandle when the vertex attribute is absent. Useful when many vertices on a small number of faces are read.
Returns
Handle whose operator[] returns the normal for a vertex offset.

◆ hasPoints()

bool enzo::geo::Mesh::hasPoints ( ) const
inlineoverridevirtual

Reimplemented from enzo::geo::Primitive.

◆ isValidPoint()

bool enzo::geo::Mesh::isValidPoint ( Offset offset) const
overridevirtual

Reimplemented from enzo::geo::Primitive.

◆ merge()

void enzo::geo::Mesh::merge ( std::shared_ptr< Primitive > other)
overridevirtual

Reimplemented from enzo::geo::Primitive.

◆ pointPosSpan()

std::span< const Vector3 > enzo::geo::Mesh::pointPosSpan ( ) const
inline

Contiguous view of every point position.

Returns
Span indexed by point offset. Invalid after a mutation that grows storage.

◆ transformType()

TransformClass enzo::geo::Mesh::transformType ( ) const
inlineoverridevirtual

Implements enzo::geo::Primitive.

◆ vertexPointSpan()

std::span< const intT > enzo::geo::Mesh::vertexPointSpan ( ) const
inline

Contiguous view mapping each vertex offset to its point offset.

Returns
Span indexed by vertex offset. Invalid after a mutation that grows storage.

The documentation for this class was generated from the following files: