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::Element Class Reference

An element (more properly an element type) in the .ply object. Tracks the name of the elemnt type (eg, "vertices"), the number of elements of that type (eg, 1244), and any properties associated with that element (eg, "position", "color"). More...

#include <happly.h>

Public Member Functions

 Element (const std::string &name_, size_t count_)
 Create a new element type. More...
 
bool hasProperty (const std::string &target)
 Check if a property exists. More...
 
template<class T >
bool hasPropertyType (const std::string &target)
 Check if a property exists with the requested type. More...
 
std::vector< std::string > getPropertyNames ()
 A list of the names of all properties. More...
 
std::unique_ptr< Property > & getPropertyPtr (const std::string &target)
 Low-level method to get a pointer to a property. Users probably don't need to call this. More...
 
template<class T >
void addProperty (const std::string &propertyName, const std::vector< T > &data)
 Add a new (plain, not list) property for this element type. More...
 
template<class T >
void addListProperty (const std::string &propertyName, const std::vector< std::vector< T >> &data)
 Add a new list property for this element type. More...
 
template<class T >
std::vector< T > getProperty (const std::string &propertyName)
 Get a vector of a data from a property for this element. Automatically promotes to larger types. Throws if requested data is unavailable. More...
 
template<class T >
std::vector< T > getPropertyType (const std::string &propertyName)
 Get a vector of a data from a property for this element. Unlike getProperty(), only returns if the ply record contains a type that matches T exactly. Throws if * requested data is unavailable. More...
 
template<class T >
std::vector< std::vector< T > > getListProperty (const std::string &propertyName)
 Get a vector of lists of data from a property for this element. Automatically promotes to larger types. Throws if requested data is unavailable. More...
 
template<class T >
std::vector< std::vector< T > > getListPropertyType (const std::string &propertyName)
 Get a vector of a data from a property for this element. Unlike getProperty(), only returns if the ply record contains a type that matches T exactly. Throws if * requested data is unavailable. More...
 
template<class T >
std::vector< std::vector< T > > getListPropertyAnySign (const std::string &propertyName)
 Get a vector of lists of data from a property for this element. Automatically promotes to larger types. Unlike getListProperty(), this method will additionally convert between types of different sign (eg, requesting and int32 would get data from a uint32); doing so naively converts between signed and unsigned types. This is typically useful for data representing indices, which might be stored as signed or unsigned numbers. More...
 
void validate ()
 Performs sanity checks on the element, throwing if any fail.
 
void writeHeader (std::ostream &outStream)
 Writes out this element's information to the file header. More...
 
void writeDataASCII (std::ostream &outStream)
 (ASCII writing) Writes out all of the data for every element of this element type to the stream, including all contained properties. More...
 
void writeDataBinary (std::ostream &outStream)
 (binary writing) Writes out all of the data for every element of this element type to the stream, including all contained properties. More...
 
void writeDataBinaryBigEndian (std::ostream &outStream)
 (binary writing) Writes out all of the data for every element of this element type to the stream, including all contained properties. More...
 
template<class D , class T >
std::vector< D > getDataFromPropertyRecursive (Property *prop)
 Helper function which does the hard work to implement type promotion for data getters. Throws if type conversion fails. More...
 
template<class D , class T >
std::vector< std::vector< D > > getDataFromListPropertyRecursive (Property *prop)
 Helper function which does the hard work to implement type promotion for list data getters. Throws if type conversion fails. More...
 

Public Attributes

std::string name
 
size_t count
 
std::vector< std::unique_ptr< Property > > properties
 

Detailed Description

An element (more properly an element type) in the .ply object. Tracks the name of the elemnt type (eg, "vertices"), the number of elements of that type (eg, 1244), and any properties associated with that element (eg, "position", "color").

Constructor & Destructor Documentation

◆ Element()

happly::Element::Element ( const std::string &  name_,
size_t  count_ 
)
inline

Create a new element type.

Parameters
name_Name of the element type (eg, "vertices")
count_Number of instances of this element.

Member Function Documentation

◆ addListProperty()

template<class T >
void happly::Element::addListProperty ( const std::string &  propertyName,
const std::vector< std::vector< T >> &  data 
)
inline

Add a new list property for this element type.

Template Parameters
TThe type of the property (eg, "double" for a list of doubles)
Parameters
propertyNameThe name of the property
dataThe data for the property. Outer vector must have the same length as the number of elements.

◆ addProperty()

template<class T >
void happly::Element::addProperty ( const std::string &  propertyName,
const std::vector< T > &  data 
)
inline

Add a new (plain, not list) property for this element type.

Template Parameters
TThe type of the property
Parameters
propertyNameThe name of the property
dataThe data for the property. Must have the same length as the number of elements.

◆ getDataFromListPropertyRecursive()

template<class D , class T >
std::vector<std::vector<D> > happly::Element::getDataFromListPropertyRecursive ( Property prop)
inline

Helper function which does the hard work to implement type promotion for list data getters. Throws if type conversion fails.

Template Parameters
DThe desired output type
TThe current attempt for the actual type of the property
Parameters
propThe property to get (does not delete nor share pointer)
Returns
The data, with the requested type

◆ getDataFromPropertyRecursive()

template<class D , class T >
std::vector<D> happly::Element::getDataFromPropertyRecursive ( Property prop)
inline

Helper function which does the hard work to implement type promotion for data getters. Throws if type conversion fails.

Template Parameters
DThe desired output type
TThe current attempt for the actual type of the property
Parameters
propThe property to get (does not delete nor share pointer)
Returns
The data, with the requested type

◆ getListProperty()

template<class T >
std::vector<std::vector<T> > happly::Element::getListProperty ( const std::string &  propertyName)
inline

Get a vector of lists of data from a property for this element. Automatically promotes to larger types. Throws if requested data is unavailable.

Template Parameters
TThe type of data requested
Parameters
propertyNameThe name of the property to get.
Returns
The data.

◆ getListPropertyAnySign()

template<class T >
std::vector<std::vector<T> > happly::Element::getListPropertyAnySign ( const std::string &  propertyName)
inline

Get a vector of lists of data from a property for this element. Automatically promotes to larger types. Unlike getListProperty(), this method will additionally convert between types of different sign (eg, requesting and int32 would get data from a uint32); doing so naively converts between signed and unsigned types. This is typically useful for data representing indices, which might be stored as signed or unsigned numbers.

Template Parameters
TThe type of data requested
Parameters
propertyNameThe name of the property to get.
Returns
The data.

◆ getListPropertyType()

template<class T >
std::vector<std::vector<T> > happly::Element::getListPropertyType ( const std::string &  propertyName)
inline

Get a vector of a data from a property for this element. Unlike getProperty(), only returns if the ply record contains a type that matches T exactly. Throws if * requested data is unavailable.

Template Parameters
TThe type of data requested
Parameters
propertyNameThe name of the property to get.
Returns
The data.

◆ getProperty()

template<class T >
std::vector<T> happly::Element::getProperty ( const std::string &  propertyName)
inline

Get a vector of a data from a property for this element. Automatically promotes to larger types. Throws if requested data is unavailable.

Template Parameters
TThe type of data requested
Parameters
propertyNameThe name of the property to get.
Returns
The data.

◆ getPropertyNames()

std::vector<std::string> happly::Element::getPropertyNames ( )
inline

A list of the names of all properties.

Returns
Property names

◆ getPropertyPtr()

std::unique_ptr<Property>& happly::Element::getPropertyPtr ( const std::string &  target)
inline

Low-level method to get a pointer to a property. Users probably don't need to call this.

Parameters
targetThe name of the property to get.
Returns
A (unique_ptr) pointer to the property.

◆ getPropertyType()

template<class T >
std::vector<T> happly::Element::getPropertyType ( const std::string &  propertyName)
inline

Get a vector of a data from a property for this element. Unlike getProperty(), only returns if the ply record contains a type that matches T exactly. Throws if * requested data is unavailable.

Template Parameters
TThe type of data requested
Parameters
propertyNameThe name of the property to get.
Returns
The data.

◆ hasProperty()

bool happly::Element::hasProperty ( const std::string &  target)
inline

Check if a property exists.

Parameters
targetThe name of the property to get.
Returns
Whether the target property exists.

◆ hasPropertyType()

template<class T >
bool happly::Element::hasPropertyType ( const std::string &  target)
inline

Check if a property exists with the requested type.

Template Parameters
TThe type of the property
Parameters
targetThe name of the property to get.
Returns
Whether the target property exists.

◆ writeDataASCII()

void happly::Element::writeDataASCII ( std::ostream &  outStream)
inline

(ASCII writing) Writes out all of the data for every element of this element type to the stream, including all contained properties.

Parameters
outStreamThe stream to write to.

◆ writeDataBinary()

void happly::Element::writeDataBinary ( std::ostream &  outStream)
inline

(binary writing) Writes out all of the data for every element of this element type to the stream, including all contained properties.

Parameters
outStreamThe stream to write to.

◆ writeDataBinaryBigEndian()

void happly::Element::writeDataBinaryBigEndian ( std::ostream &  outStream)
inline

(binary writing) Writes out all of the data for every element of this element type to the stream, including all contained properties.

Parameters
outStreamThe stream to write to.

◆ writeHeader()

void happly::Element::writeHeader ( std::ostream &  outStream)
inline

Writes out this element's information to the file header.

Parameters
outStreamThe stream to use.

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