iRoCS Toolbox  1.1.0
Public Types | Public Member Functions
atb::SurfaceGeometry Class Reference

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"

Collaboration diagram for atb::SurfaceGeometry:

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...
 
SurfaceGeometryoperator= (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...
 

Detailed Description

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.

Member Typedef Documentation

◆ VertexT

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.

◆ NormalT

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.

◆ IndexT

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.

Constructor & Destructor Documentation

◆ SurfaceGeometry() [1/2]

atb::SurfaceGeometry::SurfaceGeometry ( )

Default Constructor.

Creates a new empty SurfaceGeometry object.

◆ SurfaceGeometry() [2/2]

atb::SurfaceGeometry::SurfaceGeometry ( SurfaceGeometry const &  geometry)

Copy Constructor.

Creates a new copy of the given SurfaceGeometry object.

Parameters
geometryThe Surface geometry to copy

◆ ~SurfaceGeometry()

atb::SurfaceGeometry::~SurfaceGeometry ( )

Destructor.

Member Function Documentation

◆ operator=()

SurfaceGeometry& atb::SurfaceGeometry::operator= ( SurfaceGeometry const &  geometry)

Copy assignment operator.

Sets the data of this SurfaceGeometry object to the right-hand-side SurfaceGeometry.

Parameters
geometryThe Surface geometry to copy
Returns
A reference to this SurfaceGeometry object for operator chaining

◆ vertices() [1/2]

std::vector<VertexT> const& atb::SurfaceGeometry::vertices ( ) const

Get a read only reference onto the Vertex vector of this SurfaceGeometry object.

Returns
A reference to the Vertex vector of this SurfaceGeometry object

◆ vertices() [2/2]

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.

Returns
A reference to the Vertex vector of this SurfaceGeometry object

◆ normals() [1/2]

std::vector<NormalT> const& atb::SurfaceGeometry::normals ( ) const

Get a read only reference onto the Normal vector of this SurfaceGeometry object.

Returns
A reference to the Normal vector of this SurfaceGeometry object

◆ normals() [2/2]

std::vector<NormalT>& atb::SurfaceGeometry::normals ( )

Get a random-access reference onto the Normal vector of this SurfaceGeometry object.

Returns
A reference to the Normal vector of this SurfaceGeometry object

◆ indices() [1/2]

std::vector<IndexT> const& atb::SurfaceGeometry::indices ( ) const

Get a read only reference onto the Index vector of this SurfaceGeometry object.

Returns
A reference to the Index vector of this SurfaceGeometry object

◆ indices() [2/2]

std::vector<IndexT>& atb::SurfaceGeometry::indices ( )

Get a random-access reference onto the Index vector of this SurfaceGeometry object.

Returns
A reference to the Index vector of this SurfaceGeometry object

◆ computeDefaultNormals()

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.

◆ renderSTL()

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.

Parameters
osThe stream to write the triangles to
writeASCIIIf 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

◆ planeIntersection() [1/2]

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.

Parameters
planeNormalThe plane normal. The normal is assumed to be normalized to unit length, if it is not the behaviour is undefined.
planeOffsetThe plane offset from the coordinate origin
linesThe resulting endpoints of all polygon segments.

◆ planeIntersection() [2/2]

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.

Parameters
directionThe orthogonal dimension to the plane
planeOffsetThe plane offset from the coordinate origin
linesThe resulting endpoints of all polygon segments.

◆ boundingBoxLowerBoundUm()

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.

Returns
The lower bound of the bounding box enclosing this SurfaceGeometry

◆ boundingBoxUpperBoundUm()

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.

Returns
The upper bound of the bounding box enclosing this SurfaceGeometry

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