scenepic 1.1.0
3D Visualization Made Easy
Public Member Functions | Static Public Member Functions | List of all members
scenepic::LoopSubdivisionStencil Class Reference

This class enables efficient Loop subdivision of triangle meshes. More...

#include <loop_subdivision_stencil.h>

Public Member Functions

 LoopSubdivisionStencil (TriangleBuffer triangles, SparseMatrix subdiv)
 Constructor. More...
 
const ConstTriangleBufferRef triangles () const
 Returns the triangles of the subdivided mesh. More...
 
VertexBuffer apply (const ConstVertexBufferRef vertices) const
 Applies the stencil to a vertex buffer. More...
 
std::size_t vertex_count () const
 The number of vertices in the subdivided mesh. More...
 
std::size_t triangle_count () const
 The number of triangles in the subdivided mesh. More...
 

Static Public Member Functions

static LoopSubdivisionStencil create (const ConstTriangleBufferRef triangles, int steps=1, bool project_to_limit=false)
 Creates a new stencil by subdividing the provided triangles. More...
 

Detailed Description

This class enables efficient Loop subdivision of triangle meshes.

The subdivision stencil specifies what linear combinations of existing vertices are needed, and stencils can be reused across meshes with different vertex positions but identical triangle topologies. Thus, the constructor only takes the triangles, and caches the stencil. The stencil can be applied to a set of vertices using the apply() method.

Constructor & Destructor Documentation

◆ LoopSubdivisionStencil()

scenepic::LoopSubdivisionStencil::LoopSubdivisionStencil ( TriangleBuffer  triangles,
SparseMatrix  subdiv 
)

Constructor.

Parameters
trianglesthe triangles of the subdivided mesh
subdivthe subdivision matrix of size (num_new_verts, num_old_verts) that maps old vertices to new ones

Member Function Documentation

◆ apply()

VertexBuffer scenepic::LoopSubdivisionStencil::apply ( const ConstVertexBufferRef  vertices) const

Applies the stencil to a vertex buffer.

Parameters
verticesthe vertices to map.
Returns
new vertices constructed from the old ones using the stencil

◆ create()

static LoopSubdivisionStencil scenepic::LoopSubdivisionStencil::create ( const ConstTriangleBufferRef  triangles,
int  steps = 1,
bool  project_to_limit = false 
)
static

Creates a new stencil by subdividing the provided triangles.

Parameters
trianglesthe initial triangle indices
stepsspecifies how many steps of subdivision to apply. Defaults to 1.
project_to_limitspecifies whether the vertices should be projected onto the limit surface in the final step of subdivision. Defaults to false.
Returns
a stencil object

◆ triangle_count()

std::size_t scenepic::LoopSubdivisionStencil::triangle_count ( ) const

The number of triangles in the subdivided mesh.

◆ triangles()

const ConstTriangleBufferRef scenepic::LoopSubdivisionStencil::triangles ( ) const

Returns the triangles of the subdivided mesh.

◆ vertex_count()

std::size_t scenepic::LoopSubdivisionStencil::vertex_count ( ) const

The number of vertices in the subdivided mesh.


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