ISAAC
0.2.11
Flight software for the ISAAC project, adding functionality to the Astrobee robot, operating inside the International Space Station.
|
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 |
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").
|
inline |
Create a new element type.
name_ | Name of the element type (eg, "vertices") |
count_ | Number of instances of this element. |
|
inline |
Add a new list property for this element type.
T | The type of the property (eg, "double" for a list of doubles) |
propertyName | The name of the property |
data | The data for the property. Outer vector must have the same length as the number of elements. |
|
inline |
Add a new (plain, not list) property for this element type.
T | The type of the property |
propertyName | The name of the property |
data | The data for the property. Must have the same length as the number of elements. |
|
inline |
Helper function which does the hard work to implement type promotion for list data getters. Throws if type conversion fails.
D | The desired output type |
T | The current attempt for the actual type of the property |
prop | The property to get (does not delete nor share pointer) |
|
inline |
Helper function which does the hard work to implement type promotion for data getters. Throws if type conversion fails.
D | The desired output type |
T | The current attempt for the actual type of the property |
prop | The property to get (does not delete nor share pointer) |
|
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.
T | The type of data requested |
propertyName | The name of the property to get. |
|
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.
T | The type of data requested |
propertyName | The name of the property to get. |
|
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.
T | The type of data requested |
propertyName | The name of the property to get. |
|
inline |
Get a vector of a data from a property for this element. Automatically promotes to larger types. Throws if requested data is unavailable.
T | The type of data requested |
propertyName | The name of the property to get. |
|
inline |
A list of the names of all properties.
|
inline |
Low-level method to get a pointer to a property. Users probably don't need to call this.
target | The name of the property to get. |
|
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.
T | The type of data requested |
propertyName | The name of the property to get. |
|
inline |
Check if a property exists.
target | The name of the property to get. |
|
inline |
Check if a property exists with the requested type.
T | The type of the property |
target | The name of the property to get. |
|
inline |
(ASCII writing) Writes out all of the data for every element of this element type to the stream, including all contained properties.
outStream | The stream to write to. |
|
inline |
(binary writing) Writes out all of the data for every element of this element type to the stream, including all contained properties.
outStream | The stream to write to. |
|
inline |
(binary writing) Writes out all of the data for every element of this element type to the stream, including all contained properties.
outStream | The stream to write to. |
|
inline |
Writes out this element's information to the file header.
outStream | The stream to use. |