ISAAC  0.2.11
Flight software for the ISAAC project, adding functionality to the Astrobee robot, operating inside the International Space Station.
All Classes Functions Variables Pages
happly::PLYData Class Reference

Primary class; represents a set of data in the .ply format. More...

#include <happly.h>

Public Member Functions

 PLYData ()
 Create an empty PLYData object.
 
 PLYData (const std::string &filename, bool verbose=false)
 Initialize a PLYData by reading from a file. Throws if any failures occur. More...
 
 PLYData (std::istream &inStream, bool verbose=false)
 Initialize a PLYData by reading from a stringstream. Throws if any failures occur. More...
 
void validate ()
 Perform sanity checks on the file, throwing if any fail.
 
void write (const std::string &filename, DataFormat format=DataFormat::ASCII)
 Write this data to a .ply file. More...
 
void write (std::ostream &outStream, DataFormat format=DataFormat::ASCII)
 Write this data to an output stream. More...
 
ElementgetElement (const std::string &target)
 Get an element type by name ("vertices") More...
 
bool hasElement (const std::string &target)
 Check if an element type exists. More...
 
std::vector< std::string > getElementNames ()
 A list of the names of all elements. More...
 
void addElement (const std::string &name, size_t count)
 Add a new element type to the object. More...
 
std::vector< std::array< double, 3 > > getVertexPositions (const std::string &vertexElementName="vertex")
 Common-case helper get mesh vertex positions. More...
 
std::vector< std::array< unsigned char, 3 > > getVertexColors (const std::string &vertexElementName="vertex")
 Common-case helper get mesh vertex colors. More...
 
template<typename T = size_t>
std::vector< std::vector< T > > getFaceIndices ()
 Common-case helper to get face indices for a mesh. If not template type is given, size_t is used. Naively converts to requested signedness, which may lead to unexpected values if an unsigned type is used and file contains negative values. More...
 
void addVertexPositions (std::vector< std::array< double, 3 >> &vertexPositions)
 Common-case helper set mesh vertex positons. Creates vertex element, if necessary. More...
 
void addVertexColors (std::vector< std::array< unsigned char, 3 >> &colors)
 Common-case helper set mesh vertex colors. Creates a vertex element, if necessary. More...
 
void addVertexColors (std::vector< std::array< double, 3 >> &colors)
 Common-case helper set mesh vertex colors. Creates a vertex element, if necessary. More...
 
template<typename T >
void addFaceIndices (std::vector< std::vector< T >> &indices)
 Common-case helper to set face indices. Creates a face element if needed. The input type will be casted to a 32 bit integer of the same signedness. More...
 

Public Attributes

std::vector< std::string > comments
 Comments for the file. When writing, each entry will be written as a sequential comment line.
 
std::vector< std::string > objInfoComments
 obj_info comments for the file. When writing, each entry will be written as a sequential comment line.
 

Detailed Description

Primary class; represents a set of data in the .ply format.

Constructor & Destructor Documentation

◆ PLYData() [1/2]

happly::PLYData::PLYData ( const std::string &  filename,
bool  verbose = false 
)
inline

Initialize a PLYData by reading from a file. Throws if any failures occur.

Parameters
filenameThe file to read from.
verboseIf true, print useful info about the file to stdout

◆ PLYData() [2/2]

happly::PLYData::PLYData ( std::istream &  inStream,
bool  verbose = false 
)
inline

Initialize a PLYData by reading from a stringstream. Throws if any failures occur.

Parameters
inStreamThe stringstream to read from.
verboseIf true, print useful info about the file to stdout

Member Function Documentation

◆ addElement()

void happly::PLYData::addElement ( const std::string &  name,
size_t  count 
)
inline

Add a new element type to the object.

Parameters
nameThe name of the new element type ("vertices").
countThe number of elements of this type.

◆ addFaceIndices()

template<typename T >
void happly::PLYData::addFaceIndices ( std::vector< std::vector< T >> &  indices)
inline

Common-case helper to set face indices. Creates a face element if needed. The input type will be casted to a 32 bit integer of the same signedness.

Parameters
indicesThe indices into the vertex list around each face.

◆ addVertexColors() [1/2]

void happly::PLYData::addVertexColors ( std::vector< std::array< double, 3 >> &  colors)
inline

Common-case helper set mesh vertex colors. Creates a vertex element, if necessary.

Parameters
colorsA vector of vertex colors as floating point [0,1] values. Internally converted to [0,255] chars.

◆ addVertexColors() [2/2]

void happly::PLYData::addVertexColors ( std::vector< std::array< unsigned char, 3 >> &  colors)
inline

Common-case helper set mesh vertex colors. Creates a vertex element, if necessary.

Parameters
colorsA vector of vertex colors (unsigned chars [0,255]).

◆ addVertexPositions()

void happly::PLYData::addVertexPositions ( std::vector< std::array< double, 3 >> &  vertexPositions)
inline

Common-case helper set mesh vertex positons. Creates vertex element, if necessary.

Parameters
vertexPositionsA vector of vertex positions

◆ getElement()

Element& happly::PLYData::getElement ( const std::string &  target)
inline

Get an element type by name ("vertices")

Parameters
targetThe name of the element type to get
Returns
A reference to the element type.

◆ getElementNames()

std::vector<std::string> happly::PLYData::getElementNames ( )
inline

A list of the names of all elements.

Returns
Element names

◆ getFaceIndices()

template<typename T = size_t>
std::vector<std::vector<T> > happly::PLYData::getFaceIndices ( )
inline

Common-case helper to get face indices for a mesh. If not template type is given, size_t is used. Naively converts to requested signedness, which may lead to unexpected values if an unsigned type is used and file contains negative values.

Returns
The indices into the vertex elements for each face. Usually 0-based, though there are no formal rules.

◆ getVertexColors()

std::vector<std::array<unsigned char, 3> > happly::PLYData::getVertexColors ( const std::string &  vertexElementName = "vertex")
inline

Common-case helper get mesh vertex colors.

Parameters
vertexElementNameThe element name to use (default: "vertex")
Returns
A vector of vertex colors (unsigned chars [0,255]).

◆ getVertexPositions()

std::vector<std::array<double, 3> > happly::PLYData::getVertexPositions ( const std::string &  vertexElementName = "vertex")
inline

Common-case helper get mesh vertex positions.

Parameters
vertexElementNameThe element name to use (default: "vertex")
Returns
A vector of vertex positions.

◆ hasElement()

bool happly::PLYData::hasElement ( const std::string &  target)
inline

Check if an element type exists.

Parameters
targetThe name to check for.
Returns
True if exists.

◆ write() [1/2]

void happly::PLYData::write ( const std::string &  filename,
DataFormat  format = DataFormat::ASCII 
)
inline

Write this data to a .ply file.

Parameters
filenameThe file to write to.
formatThe format to use (binary or ascii?)

◆ write() [2/2]

void happly::PLYData::write ( std::ostream &  outStream,
DataFormat  format = DataFormat::ASCII 
)
inline

Write this data to an output stream.

Parameters
outStreamThe output stream to write to.
formatThe format to use (binary or ascii?)

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