iRoCS Toolbox
1.1.0
|
The SurfaceGeometry struct provides data structures required for the storage of triangulated surface data for direct OpenGL rendering or export to STL files. More...
#include "libArrayToolbox/SurfaceGeometry.hh"
Public Types | |
typedef unsigned int | IndexT |
IndexT is the type used to store the triangle corner indices in the vertex Array. More... | |
typedef blitz::TinyVector< float, 3 > | NormalT |
NormalT is the type used to store a 3D vertex normal. More... | |
typedef blitz::TinyVector< float, 3 > | VertexT |
VertexT is the type used to store a 3D vertex position. More... | |
Public Member Functions | |
SurfaceGeometry () | |
Default Constructor. More... | |
SurfaceGeometry (SurfaceGeometry const &geometry) | |
Copy Constructor. More... | |
~SurfaceGeometry () | |
Destructor. More... | |
blitz::TinyVector< double, 3 > const & | boundingBoxLowerBoundUm () const |
Get the tight, axis-aligned lower bound of the bounding box for this surface geometry. More... | |
blitz::TinyVector< double, 3 > const & | boundingBoxUpperBoundUm () const |
Get the tight, axis-aligned upper bound of the bounding box for this surface geometry. More... | |
void | computeDefaultNormals () |
Computes the surface normals from the provided vertices and indices. More... | |
std::vector< IndexT > const & | indices () const |
Get a read only reference onto the Index vector of this SurfaceGeometry object. More... | |
std::vector< IndexT > & | indices () |
Get a random-access reference onto the Index vector of this SurfaceGeometry object. More... | |
std::vector< NormalT > const & | normals () const |
Get a read only reference onto the Normal vector of this SurfaceGeometry object. More... | |
std::vector< NormalT > & | normals () |
Get a random-access reference onto the Normal vector of this SurfaceGeometry object. More... | |
SurfaceGeometry & | operator= (SurfaceGeometry const &geometry) |
Copy assignment operator. More... | |
void | planeIntersection (blitz::TinyVector< float, 3 > const &planeNormal, float planeOffset, std::vector< blitz::TinyVector< blitz::TinyVector< float, 2 >, 2 > > &lines) const |
Intersect the SurfaceGeometryObject with the plane defined by the given parameters and return the resulting set of 2D line end points forming the intersection polygon. More... | |
void | planeIntersection (int direction, float planeOffset, std::vector< blitz::TinyVector< blitz::TinyVector< float, 2 >, 2 > > &lines) const |
Intersect the SurfaceGeometryObject with the plane defined by the given parameters and return the resulting set of 2D line end points forming the intersection polygon. More... | |
void | renderSTL (std::ostream &os, bool writeASCII=true) const |
Appends the set of triangle primitives described by this SurfaceGeometry as STL facets to the given output stream. More... | |
std::vector< VertexT > const & | vertices () const |
Get a read only reference onto the Vertex vector of this SurfaceGeometry object. More... | |
std::vector< VertexT > & | vertices () |
Get a random-access reference onto the Vertex vector of this SurfaceGeometry object. More... | |
The SurfaceGeometry struct provides data structures required for the storage of triangulated surface data for direct OpenGL rendering or export to STL files.
Definition at line 52 of file SurfaceGeometry.hh.
typedef blitz::TinyVector<float,3> atb::SurfaceGeometry::VertexT |
VertexT is the type used to store a 3D vertex position.
Definition at line 62 of file SurfaceGeometry.hh.
typedef blitz::TinyVector<float,3> atb::SurfaceGeometry::NormalT |
NormalT is the type used to store a 3D vertex normal.
Definition at line 69 of file SurfaceGeometry.hh.
typedef unsigned int atb::SurfaceGeometry::IndexT |
IndexT is the type used to store the triangle corner indices in the vertex Array.
Definition at line 77 of file SurfaceGeometry.hh.
atb::SurfaceGeometry::SurfaceGeometry | ( | ) |
Default Constructor.
Creates a new empty SurfaceGeometry object.
atb::SurfaceGeometry::SurfaceGeometry | ( | SurfaceGeometry const & | geometry | ) |
Copy Constructor.
Creates a new copy of the given SurfaceGeometry object.
geometry | The Surface geometry to copy |
atb::SurfaceGeometry::~SurfaceGeometry | ( | ) |
Destructor.
SurfaceGeometry& atb::SurfaceGeometry::operator= | ( | SurfaceGeometry const & | geometry | ) |
Copy assignment operator.
Sets the data of this SurfaceGeometry object to the right-hand-side SurfaceGeometry.
geometry | The Surface geometry to copy |
std::vector<VertexT> const& atb::SurfaceGeometry::vertices | ( | ) | const |
Get a read only reference onto the Vertex vector of this SurfaceGeometry object.
std::vector<VertexT>& atb::SurfaceGeometry::vertices | ( | ) |
Get a random-access reference onto the Vertex vector of this SurfaceGeometry object.
When requesting a read-write reference to the vertices, the bounding will be recomputed when requested the next time. When editing a stored reference, the bounding box will be only recomputed at first bounding box request, try to avoid keeping references to the vertex vector, or request a new reference if you want to force a bounding box update.
std::vector<NormalT> const& atb::SurfaceGeometry::normals | ( | ) | const |
Get a read only reference onto the Normal vector of this SurfaceGeometry object.
std::vector<NormalT>& atb::SurfaceGeometry::normals | ( | ) |
Get a random-access reference onto the Normal vector of this SurfaceGeometry object.
std::vector<IndexT> const& atb::SurfaceGeometry::indices | ( | ) | const |
Get a read only reference onto the Index vector of this SurfaceGeometry object.
std::vector<IndexT>& atb::SurfaceGeometry::indices | ( | ) |
Get a random-access reference onto the Index vector of this SurfaceGeometry object.
void atb::SurfaceGeometry::computeDefaultNormals | ( | ) |
Computes the surface normals from the provided vertices and indices.
For each vertex the normals of all adjacent triangles are computed using the cross product of its edges and averaged giving the normal for that vertex.
void atb::SurfaceGeometry::renderSTL | ( | std::ostream & | os, |
bool | writeASCII = true |
||
) | const |
Appends the set of triangle primitives described by this SurfaceGeometry as STL facets to the given output stream.
The header and footer of the STL file must be pre- and appended by the user. For the ASCII case this means the stream must start with 'solid <name>' and end with 'endsolid <name>'. It is not possible to put multiple solids into the same file, therefore write the header, then all objects and finally the footer. For the binary file format it is slightly different, the files start with an arbitrary 80 Byte header which is by default ignored, Bytes 80 - 84 are the number of all triangles in the file as unsigned int. The binary file needs no footer.
os | The stream to write the triangles to |
writeASCII | If writeASCII is true the triangles will be written in user readable ASCII format, otherwise it will be written in binary format. In binary format only the raw vertex positions and normals are stored. The header has to be already written to the stream beforehand |
void atb::SurfaceGeometry::planeIntersection | ( | blitz::TinyVector< float, 3 > const & | planeNormal, |
float | planeOffset, | ||
std::vector< blitz::TinyVector< blitz::TinyVector< float, 2 >, 2 > > & | lines | ||
) | const |
Intersect the SurfaceGeometryObject with the plane defined by the given parameters and return the resulting set of 2D line end points forming the intersection polygon.
planeNormal | The plane normal. The normal is assumed to be normalized to unit length, if it is not the behaviour is undefined. |
planeOffset | The plane offset from the coordinate origin |
lines | The resulting endpoints of all polygon segments. |
void atb::SurfaceGeometry::planeIntersection | ( | int | direction, |
float | planeOffset, | ||
std::vector< blitz::TinyVector< blitz::TinyVector< float, 2 >, 2 > > & | lines | ||
) | const |
Intersect the SurfaceGeometryObject with the plane defined by the given parameters and return the resulting set of 2D line end points forming the intersection polygon.
This implementation is a special case of the method above for axis aligned planes.
direction | The orthogonal dimension to the plane |
planeOffset | The plane offset from the coordinate origin |
lines | The resulting endpoints of all polygon segments. |
blitz::TinyVector<double,3> const& atb::SurfaceGeometry::boundingBoxLowerBoundUm | ( | ) | const |
Get the tight, axis-aligned lower bound of the bounding box for this surface geometry.
Lower and upper bound will be recomputed if a random-access reference to the vertex vector of this SurfaceGeometry was requested since the last call to boundingBoxLowerBoundUm() or boundingBoxUpperBoundUm(). If the user stores a persistent reference for editing the automatic update fails.
blitz::TinyVector<double,3> const& atb::SurfaceGeometry::boundingBoxUpperBoundUm | ( | ) | const |
Get the tight, axis-aligned upper bound of the bounding box for this surface geometry.
Lower and upper bound will be recomputed if a random-access reference to the vertex vector of this SurfaceGeometry was requested since the last call to boundingBoxLowerBoundUm() or boundingBoxUpperBoundUm(). If the user stores a persistent reference for editing the automatic update fails.