General Attribute class. More...
Inherits DD::Image::RefCountedObject.
Public Member Functions | |
Attribute (const Attribute &src) | |
Attribute (const char *name, AttribType type, size_t size=0) | |
bool | valid () const |
bool | invalid () const |
Attribute & | operator= (const Attribute &) |
void | copy (int dest, const Attribute &, int b_start) |
void | copy (int dest, const Attribute &, int b_start, int b_end) |
bool | append (const Attribute &, int b_start) |
bool | append (const Attribute &, int b_start, int b_end) |
const char * | name () const |
AttribType | type () const |
unsigned | size () const |
unsigned | capacity () const |
void | add (unsigned n=1) |
void | reserve (unsigned size) |
void | resize (size_t size) |
void | clear () |
void * | array (unsigned n=0) const |
size_t | bytes () const |
unsigned | data_elements () const |
unsigned | floats () const |
float & | flt (const size_t n=0) const |
Vector2 & | vector2 (const size_t n=0) const |
Vector3 & | vector3 (const size_t n=0) const |
Vector4 & | vector4 (const size_t n=0) const |
Vector3 & | normal (const size_t n=0) const |
Matrix3 & | matrix3 (const size_t n=0) const |
Matrix4 & | matrix4 (const size_t n=0) const |
int & | integer (const size_t n=0) const |
char *& | string (const size_t n=0) const |
std::string & | stdstring (const size_t n=0) const |
void *& | pointer (const size_t n=0) const |
void | print_info () const |
void | print_value (const size_t n) const |
Public Member Functions inherited from DD::Image::RefCountedObject | |
void | ref () |
increment the reference count | |
void | unref () |
decrement the reference count. delete object if this becomes zero. | |
int | refcount () const |
get the reference counter | |
Static Public Member Functions | |
static const char * | type_string (int i) |
Public Attributes | |
const char * | name_ |
Name of attribute. | |
AttribType | type_ |
Data type. | |
union { | |
std::vector< float, STL3DAllocator< float > > * float_list | |
std::vector< Vector2, STL3DAllocator< Vector2 > > * vector2_list | |
std::vector< Vector3, STL3DAllocator< Vector3 > > * vector3_list | |
std::vector< Vector4, STL3DAllocator< Vector4 > > * vector4_list | |
std::vector< Matrix3, STL3DAllocator< Matrix3 > > * matrix3_list | |
std::vector< Matrix4, STL3DAllocator< Matrix4 > > * matrix4_list | |
std::vector< int, STL3DAllocator< int > > * int_list | |
std::vector< char *, STL3DAllocator< char * > > * string_list | |
std::vector< std::string, STL3DAllocator< std::string > > * std_string_list | |
std::vector< void *, STL3DAllocator< void * > > * pointer_list | |
void * data | |
}; | |
Static Public Attributes | |
static const char * | attribute_types [] |
Friends | |
class | GeoInfo |
class | GeoOp |
General Attribute class.
|
inline |
Copy constructor.
Attribute::Attribute | ( | const char * | name, |
AttribType | type, | ||
size_t | size = 0 |
||
) |
Basic constructor requires a name and type. Size is defaulted to 0.
References DD::Image::FLOAT_ATTRIB, DD::Image::INT_ATTRIB, DD::Image::MATRIX3_ATTRIB, DD::Image::MATRIX4_ATTRIB, DD::Image::NORMAL_ATTRIB, DD::Image::POINTER_ATTRIB, DD::Image::STD_STRING_ATTRIB, DD::Image::STRING_ATTRIB, DD::Image::VECTOR2_ATTRIB, DD::Image::VECTOR3_ATTRIB, and DD::Image::VECTOR4_ATTRIB.
Assignment operator. Empty then copy all data from 'b' into this.
References DD::Image::FLOAT_ATTRIB, DD::Image::INT_ATTRIB, DD::Image::MATRIX3_ATTRIB, DD::Image::MATRIX4_ATTRIB, name_, DD::Image::NORMAL_ATTRIB, DD::Image::POINTER_ATTRIB, DD::Image::STD_STRING_ATTRIB, DD::Image::STRING_ATTRIB, type_, DD::Image::VECTOR2_ATTRIB, DD::Image::VECTOR3_ATTRIB, and DD::Image::VECTOR4_ATTRIB.
void Attribute::copy | ( | int | dest, |
const Attribute & | b, | ||
int | b_start | ||
) |
Destructively copy a single item from 'b_start' to 'dest'.
void Attribute::copy | ( | int | dest, |
const Attribute & | b, | ||
int | b_start, | ||
int | b_end | ||
) |
Destructively copy a range of items from 'b' to a range beginning at 'dest'.
References DD::Image::FLOAT_ATTRIB, DD::Image::INT_ATTRIB, DD::Image::MATRIX3_ATTRIB, DD::Image::MATRIX4_ATTRIB, DD::Image::NORMAL_ATTRIB, DD::Image::POINTER_ATTRIB, size(), DD::Image::STD_STRING_ATTRIB, DD::Image::STRING_ATTRIB, type_, DD::Image::VECTOR2_ATTRIB, DD::Image::VECTOR3_ATTRIB, and DD::Image::VECTOR4_ATTRIB.
bool Attribute::append | ( | const Attribute & | b, |
int | b_start | ||
) |
Appends data elements from a same type Attribute onto the end of this one. Fails if both types are not the same.
bool Attribute::append | ( | const Attribute & | b, |
int | b_start, | ||
int | b_end | ||
) |
unsigned Attribute::size | ( | ) | const |
Number of data elements in list.
References DD::Image::FLOAT_ATTRIB, DD::Image::INT_ATTRIB, DD::Image::INVALID_ATTRIB, DD::Image::MATRIX3_ATTRIB, DD::Image::MATRIX4_ATTRIB, DD::Image::NORMAL_ATTRIB, DD::Image::POINTER_ATTRIB, DD::Image::STD_STRING_ATTRIB, DD::Image::STRING_ATTRIB, DD::Image::VECTOR2_ATTRIB, DD::Image::VECTOR3_ATTRIB, and DD::Image::VECTOR4_ATTRIB.
Referenced by DD::Image::GeometryList::add_primitive(), append(), copy(), and DD::Image::GeoOp::evaluate_transform().
void Attribute::add | ( | unsigned | n = 1 | ) |
Add 'n' elements to end of list.
Referenced by DD::Image::GeometryList::add_primitive().
void Attribute::reserve | ( | unsigned | size | ) |
Reserve memory in list for 'n' elements. If you already know the maximum size of the attribute, this can save a lot of overhead if you call this before adding single elements.
References DD::Image::FLOAT_ATTRIB, DD::Image::INT_ATTRIB, DD::Image::INVALID_ATTRIB, DD::Image::MATRIX3_ATTRIB, DD::Image::MATRIX4_ATTRIB, DD::Image::NORMAL_ATTRIB, DD::Image::POINTER_ATTRIB, DD::Image::STD_STRING_ATTRIB, DD::Image::STRING_ATTRIB, DD::Image::VECTOR2_ATTRIB, DD::Image::VECTOR3_ATTRIB, and DD::Image::VECTOR4_ATTRIB.
void Attribute::resize | ( | size_t | size | ) |
Expand or contract element list size to 'n' elements.
References DD::Image::FLOAT_ATTRIB, DD::Image::INT_ATTRIB, DD::Image::INVALID_ATTRIB, DD::Image::MATRIX3_ATTRIB, DD::Image::MATRIX4_ATTRIB, DD::Image::NORMAL_ATTRIB, DD::Image::POINTER_ATTRIB, DD::Image::STD_STRING_ATTRIB, DD::Image::STRING_ATTRIB, DD::Image::VECTOR2_ATTRIB, DD::Image::VECTOR3_ATTRIB, and DD::Image::VECTOR4_ATTRIB.
Referenced by DD::Image::Mesh::create_point_normals(), and DD::Image::Mesh::create_point_uvs().
void Attribute::clear | ( | ) |
Clear the attribute data, leave the data list structure intact.
References DD::Image::FLOAT_ATTRIB, DD::Image::INT_ATTRIB, DD::Image::INVALID_ATTRIB, DD::Image::MATRIX3_ATTRIB, DD::Image::MATRIX4_ATTRIB, DD::Image::NORMAL_ATTRIB, DD::Image::POINTER_ATTRIB, DD::Image::STD_STRING_ATTRIB, DD::Image::STRING_ATTRIB, DD::Image::VECTOR2_ATTRIB, DD::Image::VECTOR3_ATTRIB, and DD::Image::VECTOR4_ATTRIB.
Referenced by DD::Image::ReadGeo::create_geometry().
void * Attribute::array | ( | unsigned | n = 0 | ) | const |
Return a void pointer to data element 'n'.
References DD::Image::FLOAT_ATTRIB, DD::Image::INT_ATTRIB, DD::Image::INVALID_ATTRIB, DD::Image::MATRIX3_ATTRIB, DD::Image::MATRIX4_ATTRIB, DD::Image::NORMAL_ATTRIB, DD::Image::POINTER_ATTRIB, DD::Image::STD_STRING_ATTRIB, DD::Image::STRING_ATTRIB, DD::Image::VECTOR2_ATTRIB, DD::Image::VECTOR3_ATTRIB, and DD::Image::VECTOR4_ATTRIB.
Referenced by append(), and DD::Image::GeoOp::evaluate_transform().
size_t Attribute::bytes | ( | ) | const |
Size of a single data element in bytes.
References DD::Image::FLOAT_ATTRIB, DD::Image::INT_ATTRIB, DD::Image::INVALID_ATTRIB, DD::Image::MATRIX3_ATTRIB, DD::Image::MATRIX4_ATTRIB, DD::Image::NORMAL_ATTRIB, DD::Image::POINTER_ATTRIB, DD::Image::STD_STRING_ATTRIB, DD::Image::STRING_ATTRIB, DD::Image::VECTOR2_ATTRIB, DD::Image::VECTOR3_ATTRIB, and DD::Image::VECTOR4_ATTRIB.
unsigned Attribute::data_elements | ( | ) | const |
Number of elements in data type.
References DD::Image::FLOAT_ATTRIB, DD::Image::INT_ATTRIB, DD::Image::INVALID_ATTRIB, DD::Image::MATRIX3_ATTRIB, DD::Image::MATRIX4_ATTRIB, DD::Image::NORMAL_ATTRIB, DD::Image::POINTER_ATTRIB, DD::Image::STD_STRING_ATTRIB, DD::Image::STRING_ATTRIB, DD::Image::VECTOR2_ATTRIB, DD::Image::VECTOR3_ATTRIB, and DD::Image::VECTOR4_ATTRIB.
unsigned Attribute::floats | ( | ) | const |
Number of floats for this data attribute type.
References DD::Image::FLOAT_ATTRIB, DD::Image::INT_ATTRIB, DD::Image::INVALID_ATTRIB, DD::Image::MATRIX3_ATTRIB, DD::Image::MATRIX4_ATTRIB, DD::Image::NORMAL_ATTRIB, DD::Image::POINTER_ATTRIB, DD::Image::STD_STRING_ATTRIB, DD::Image::STRING_ATTRIB, DD::Image::VECTOR2_ATTRIB, DD::Image::VECTOR3_ATTRIB, and DD::Image::VECTOR4_ATTRIB.
void Attribute::print_info | ( | ) | const |
Print type information about this attribute.
References DD::Image::FLOAT_ATTRIB, DD::Image::INT_ATTRIB, DD::Image::INVALID_ATTRIB, DD::Image::MATRIX3_ATTRIB, DD::Image::MATRIX4_ATTRIB, DD::Image::NORMAL_ATTRIB, DD::Image::POINTER_ATTRIB, DD::Image::STD_STRING_ATTRIB, DD::Image::STRING_ATTRIB, DD::Image::VECTOR2_ATTRIB, DD::Image::VECTOR3_ATTRIB, and DD::Image::VECTOR4_ATTRIB.
void Attribute::print_value | ( | const size_t | n | ) | const |
Print a nicely formatted value for element 'n'.
References DD::Image::FLOAT_ATTRIB, DD::Image::INT_ATTRIB, DD::Image::MATRIX3_ATTRIB, DD::Image::MATRIX4_ATTRIB, DD::Image::POINTER_ATTRIB, DD::Image::STD_STRING_ATTRIB, DD::Image::STRING_ATTRIB, DD::Image::VECTOR2_ATTRIB, DD::Image::VECTOR3_ATTRIB, and DD::Image::VECTOR4_ATTRIB.
©2021 The Foundry Visionmongers, Ltd. All Rights Reserved. |