ug4
stl_reader::StlMesh< TNumber, TIndex > Class Template Reference

convenience mesh class which makes accessing the stl data more easy More...

#include <stl_reader.h>

Public Member Functions

size_t num_solids () const
 returns the number of solids of the mesh More...
 
size_t num_tris () const
 returns the number of triangles in the mesh More...
 
size_t num_vrts () const
 returns the number of vertices in the mesh More...
 
const TNumber * raw_coords () const
 returns a pointer to the coordinate array, containing num_vrts()*3 entries. More...
 
const TNumber * raw_normals () const
 returns a pointer to the normal array, containing num_tris()*3 entries. More...
 
const TIndex * raw_solids () const
 returns a pointer to the solids array, containing num_solids()+1 entries. More...
 
const TIndex * raw_tris () const
 returns a pointer to the triangle array, containing num_tris()*3 entries. More...
 
bool read_file (const char *filename)
 fills the mesh with the contents of the specified stl-file More...
 
TIndex solid_tris_begin (const size_t si) const
 returns the index of the first triangle in the given solid More...
 
TIndex solid_tris_end (const size_t si) const
 returns the index of the triangle behind the last triangle in the given solid More...
 
 StlMesh ()
 initializes an empty mesh More...
 
 StlMesh (const char *filename)
 initializes the mesh from the stl-file specified through filename More...
 
const TNumber * tri_corner_coords (const size_t ti, const size_t ci) const
 returns an array of 3 floating point values, one for each coordinate of the specified corner of the specified tri. More...
 
const TIndex tri_corner_ind (const size_t ti, const size_t ci) const
 returns the index of the corner with index 0<=ci<3 of triangle ti More...
 
const TIndex * tri_corner_inds (const size_t ti) const
 returns an array of 3 indices, one for each corner vertex of the triangle More...
 
const TNumber * tri_normal (const size_t ti) const
 returns an array of 3 floating point values defining the normal of a tri More...
 
const TNumber * vrt_coords (const size_t vi) const
 returns an array of 3 floating point values, one for each coordinate of the vertex More...
 

Private Attributes

std::vector< TNumber > coords
 
std::vector< TNumber > normals
 
std::vector< TIndex > solids
 
std::vector< TIndex > tris
 

Detailed Description

template<class TNumber = float, class TIndex = unsigned int>
class stl_reader::StlMesh< TNumber, TIndex >

convenience mesh class which makes accessing the stl data more easy

Constructor & Destructor Documentation

◆ StlMesh() [1/2]

template<class TNumber = float, class TIndex = unsigned int>
stl_reader::StlMesh< TNumber, TIndex >::StlMesh ( )
inline

initializes an empty mesh

References stl_reader::StlMesh< TNumber, TIndex >::solids.

◆ StlMesh() [2/2]

template<class TNumber = float, class TIndex = unsigned int>
stl_reader::StlMesh< TNumber, TIndex >::StlMesh ( const char *  filename)
inline

initializes the mesh from the stl-file specified through filename

References stl_reader::StlMesh< TNumber, TIndex >::read_file().

Member Function Documentation

◆ num_solids()

template<class TNumber = float, class TIndex = unsigned int>
size_t stl_reader::StlMesh< TNumber, TIndex >::num_solids ( ) const
inline

returns the number of solids of the mesh

solids can be seen as a partitioning of the triangles of a mesh. By iterating consecutively from the index of the first triangle of a solid si (using solid_tris_begin(si)) to the index of the last triangle of a solid (using solid_tris_end(...)-1), one visits all triangles of the solid si.

References stl_reader::StlMesh< TNumber, TIndex >::solids.

◆ num_tris()

template<class TNumber = float, class TIndex = unsigned int>
size_t stl_reader::StlMesh< TNumber, TIndex >::num_tris ( ) const
inline

returns the number of triangles in the mesh

References stl_reader::StlMesh< TNumber, TIndex >::tris.

◆ num_vrts()

template<class TNumber = float, class TIndex = unsigned int>
size_t stl_reader::StlMesh< TNumber, TIndex >::num_vrts ( ) const
inline

returns the number of vertices in the mesh

References stl_reader::StlMesh< TNumber, TIndex >::coords.

◆ raw_coords()

template<class TNumber = float, class TIndex = unsigned int>
const TNumber* stl_reader::StlMesh< TNumber, TIndex >::raw_coords ( ) const
inline

returns a pointer to the coordinate array, containing num_vrts()*3 entries.

Storage layout: x0,y0,z0,x1,y1,z1,...

Returns
pointer to a contiguous array of numbers, or NULL if no coords exist.

References stl_reader::StlMesh< TNumber, TIndex >::coords.

◆ raw_normals()

template<class TNumber = float, class TIndex = unsigned int>
const TNumber* stl_reader::StlMesh< TNumber, TIndex >::raw_normals ( ) const
inline

returns a pointer to the normal array, containing num_tris()*3 entries.

Storage layout: nx0,ny0,nz0,nx1,ny1,nz1,...

Returns
pointer to a contiguous array of numbers, or NULL if no normals exist.

References stl_reader::StlMesh< TNumber, TIndex >::normals.

◆ raw_solids()

template<class TNumber = float, class TIndex = unsigned int>
const TIndex* stl_reader::StlMesh< TNumber, TIndex >::raw_solids ( ) const
inline

returns a pointer to the solids array, containing num_solids()+1 entries.

Storage layout: s0begin, s0end/s1begin, s1end/s2begin, ..., sNend

Returns
pointer to a contiguous array of indices, or NULL if no solids exist.

References stl_reader::StlMesh< TNumber, TIndex >::solids.

◆ raw_tris()

template<class TNumber = float, class TIndex = unsigned int>
const TIndex* stl_reader::StlMesh< TNumber, TIndex >::raw_tris ( ) const
inline

returns a pointer to the triangle array, containing num_tris()*3 entries.

Storage layout: t0c0,t0c1,t0c2,t1c0,t1c1,t1c2,...

Returns
pointer to a contiguous array of indices, or NULL if no tris exist.

References stl_reader::StlMesh< TNumber, TIndex >::tris.

◆ read_file()

template<class TNumber = float, class TIndex = unsigned int>
bool stl_reader::StlMesh< TNumber, TIndex >::read_file ( const char *  filename)
inline

◆ solid_tris_begin()

template<class TNumber = float, class TIndex = unsigned int>
TIndex stl_reader::StlMesh< TNumber, TIndex >::solid_tris_begin ( const size_t  si) const
inline

returns the index of the first triangle in the given solid

References stl_reader::StlMesh< TNumber, TIndex >::solids.

◆ solid_tris_end()

template<class TNumber = float, class TIndex = unsigned int>
TIndex stl_reader::StlMesh< TNumber, TIndex >::solid_tris_end ( const size_t  si) const
inline

returns the index of the triangle behind the last triangle in the given solid

References stl_reader::StlMesh< TNumber, TIndex >::solids.

◆ tri_corner_coords()

template<class TNumber = float, class TIndex = unsigned int>
const TNumber* stl_reader::StlMesh< TNumber, TIndex >::tri_corner_coords ( const size_t  ti,
const size_t  ci 
) const
inline

returns an array of 3 floating point values, one for each coordinate of the specified corner of the specified tri.

Note
same result as calling on a StlMesh mesh:
mesh.vrt_coords (mesh.tri_corner_ind (itri, icorner))

References stl_reader::StlMesh< TNumber, TIndex >::coords, and stl_reader::StlMesh< TNumber, TIndex >::tri_corner_ind().

◆ tri_corner_ind()

template<class TNumber = float, class TIndex = unsigned int>
const TIndex stl_reader::StlMesh< TNumber, TIndex >::tri_corner_ind ( const size_t  ti,
const size_t  ci 
) const
inline

returns the index of the corner with index 0<=ci<3 of triangle ti

References stl_reader::StlMesh< TNumber, TIndex >::tris.

Referenced by stl_reader::StlMesh< TNumber, TIndex >::tri_corner_coords().

◆ tri_corner_inds()

template<class TNumber = float, class TIndex = unsigned int>
const TIndex* stl_reader::StlMesh< TNumber, TIndex >::tri_corner_inds ( const size_t  ti) const
inline

returns an array of 3 indices, one for each corner vertex of the triangle

References stl_reader::StlMesh< TNumber, TIndex >::tris.

◆ tri_normal()

template<class TNumber = float, class TIndex = unsigned int>
const TNumber* stl_reader::StlMesh< TNumber, TIndex >::tri_normal ( const size_t  ti) const
inline

returns an array of 3 floating point values defining the normal of a tri

References stl_reader::StlMesh< TNumber, TIndex >::normals.

◆ vrt_coords()

template<class TNumber = float, class TIndex = unsigned int>
const TNumber* stl_reader::StlMesh< TNumber, TIndex >::vrt_coords ( const size_t  vi) const
inline

returns an array of 3 floating point values, one for each coordinate of the vertex

References stl_reader::StlMesh< TNumber, TIndex >::coords.

Member Data Documentation

◆ coords

◆ normals

template<class TNumber = float, class TIndex = unsigned int>
std::vector<TNumber> stl_reader::StlMesh< TNumber, TIndex >::normals
private

◆ solids

◆ tris


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