Volume Cartographer 2.27.0
Protected Member Functions | Protected Attributes | List of all members
volcart::shapes::ShapePrimitive Class Reference

Base class for shape generators. More...

#include <vc/core/shapes/ShapePrimitive.hpp>

Inheritance diagram for volcart::shapes::ShapePrimitive:
[legend]

Public Member Functions

ITKMesh::Pointer itkMesh ()
 Return the shape as an ITKMesh.
 
vtkSmartPointer< vtkPolyData > vtkMesh ()
 Return the shape as a vtkPolyData.
 
PointSet< cv::Vec3d > unorderedPoints ()
 Return the vertices as a PointSet. More...
 
PointSet< cv::Vec6d > unorderedPointNormal ()
 Return the vertices and vertex normals as a PointSet. More...
 
std::vector< SimpleMesh::VertexgetPoints () const
 Return the vertices as a list of SimpleMesh::Vertex. More...
 
std::vector< SimpleMesh::CellgetCells () const
 Return the faces as a list of volcart::Cell. More...
 
OrderedPointSet< cv::Vec3d > orderedPoints ()
 Return the vertices as an OrderedPointSet. More...
 
OrderedPointSet< cv::Vec6d > orderedPointNormal ()
 Return the vertices and vertex normals as an OrderedPointSet. More...
 
bool isOrdered () const
 Return if the shape generator created ordered vertices. More...
 
std::size_t orderedWidth () const
 Return the width of the ordered vertex set. More...
 
std::size_t orderedHeight () const
 Return the height of the ordered vertex set. More...
 

Protected Member Functions

 ShapePrimitive ()
 
void addVertex_ (double x, double y, double z)
 Add a new vertex to the shape.
 
void addCell_ (int v1, int v2, int v3)
 Add a new triangular face to the mesh from vertex IDs. More...
 
void updateNormal_ (int vertID, double nx, double ny, double nz)
 Update the normal of a vertex with a new normal component. More...
 

Protected Attributes

std::vector< SimpleMesh::Vertexpoints_
 
std::vector< SimpleMesh::Cellcells_
 
bool ordered_ {false}
 
std::size_t orderedWidth_ {0}
 
std::size_t orderedHeight_ {0}
 

Detailed Description

Base class for shape generators.

Author
Seth Parker
Date
9/18/15

This class provides a common interface for interacting with the various shape generators (Cube, Plane, etc.) provided by the Core library. Shape generators are meant to be used for unit and regression testing.

This class internally keeps a simple list of vertices and triangular faces and provides adaptor functions to convert these lists into higher level data structures (ITK/VTK meshes, PointSets, etc.). A new ShapePrimitive object will have no vertices or faces.

Definition at line 41 of file ShapePrimitive.hpp.

Constructor & Destructor Documentation

◆ ShapePrimitive()

volcart::shapes::ShapePrimitive::ShapePrimitive ( )
protected

Default constructor

Member Function Documentation

◆ addCell_()

void volcart::shapes::ShapePrimitive::addCell_ ( int  v1,
int  v2,
int  v3 
)
protected

Add a new triangular face to the mesh from vertex IDs.

Automatically calls updateNormal_ as needed

◆ getCells()

std::vector< SimpleMesh::Cell > volcart::shapes::ShapePrimitive::getCells ( ) const
inline

Return the faces as a list of volcart::Cell.

Definition at line 71 of file ShapePrimitive.hpp.

◆ getPoints()

std::vector< SimpleMesh::Vertex > volcart::shapes::ShapePrimitive::getPoints ( ) const
inline

Return the vertices as a list of SimpleMesh::Vertex.

Definition at line 68 of file ShapePrimitive.hpp.

◆ isOrdered()

bool volcart::shapes::ShapePrimitive::isOrdered ( ) const
inline

Return if the shape generator created ordered vertices.

Definition at line 92 of file ShapePrimitive.hpp.

◆ orderedHeight()

std::size_t volcart::shapes::ShapePrimitive::orderedHeight ( ) const
inline

Return the height of the ordered vertex set.

Definition at line 98 of file ShapePrimitive.hpp.

◆ orderedPointNormal()

OrderedPointSet< cv::Vec6d > volcart::shapes::ShapePrimitive::orderedPointNormal ( )

Return the vertices and vertex normals as an OrderedPointSet.

Throws a std::runtime_error if shape does not generate ordered vertices

Element order is: {x, y, z, nx, ny, nz}

◆ orderedPoints()

OrderedPointSet< cv::Vec3d > volcart::shapes::ShapePrimitive::orderedPoints ( )

Return the vertices as an OrderedPointSet.

Throws a std::runtime_error if shape does not generate ordered points

Element order is: {x, y, z}

◆ orderedWidth()

std::size_t volcart::shapes::ShapePrimitive::orderedWidth ( ) const
inline

Return the width of the ordered vertex set.

Definition at line 95 of file ShapePrimitive.hpp.

◆ unorderedPointNormal()

PointSet< cv::Vec6d > volcart::shapes::ShapePrimitive::unorderedPointNormal ( )

Return the vertices and vertex normals as a PointSet.

Element order is: {x, y, z, nx, ny, nz}

◆ unorderedPoints()

PointSet< cv::Vec3d > volcart::shapes::ShapePrimitive::unorderedPoints ( )

Return the vertices as a PointSet.

Element order is: {x, y, z}

◆ updateNormal_()

void volcart::shapes::ShapePrimitive::updateNormal_ ( int  vertID,
double  nx,
double  ny,
double  nz 
)
protected

Update the normal of a vertex with a new normal component.

The stored vertex normal is an average of the normals of a vertex's adjacent faces. This function reaverages the normal with the vector defined by {nx, ny, nz}.

Member Data Documentation

◆ cells_

std::vector<SimpleMesh::Cell> volcart::shapes::ShapePrimitive::cells_
protected

Face storage

Definition at line 108 of file ShapePrimitive.hpp.

◆ ordered_

bool volcart::shapes::ShapePrimitive::ordered_ {false}
protected

Is the generated vertex set ordered?

Definition at line 129 of file ShapePrimitive.hpp.

◆ orderedHeight_

std::size_t volcart::shapes::ShapePrimitive::orderedHeight_ {0}
protected

Height of the ordered vertex set

Definition at line 133 of file ShapePrimitive.hpp.

◆ orderedWidth_

std::size_t volcart::shapes::ShapePrimitive::orderedWidth_ {0}
protected

Width of the ordered vertex set

Definition at line 131 of file ShapePrimitive.hpp.

◆ points_

std::vector<SimpleMesh::Vertex> volcart::shapes::ShapePrimitive::points_
protected

Vertex storage

Definition at line 106 of file ShapePrimitive.hpp.


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