A triangle mesh class.
More...
#include <Mesh.h>
|
using | Scalar = T |
| Scalar type of the vector space the embedding.
|
|
using | Index = std::ptrdiff_t |
| Index type.
|
|
using | Size = std::size_t |
| Size type.
|
|
using | Label = unsigned int |
| Label type.
|
|
|
| Mesh () noexcept(noexcept(VertexData())&&noexcept(IndexData())&&noexcept(LabelData())&&noexcept(VertexData())) |
| Constructs an empty mesh.
|
|
| Mesh (std::size_t nVertices, std::size_t nTriangles) noexcept(noexcept(VertexData(3 *nVertices, T{0}))&&noexcept(IndexData(3 *nTriangles, Index{0}))&&noexcept(LabelData(nVertices, Label{0}))&&noexcept(NormalData(3 *nVertices, T{0}))) |
| Constructs an uninitialized mesh with the given vertex and triangle count.
|
|
|
std::array< T, 3 > | cartesianRepresentation (BarycentricPoint< T, Index > const &point) const |
| Returns the cartesian coordinate of a point in barycentric coordinates. More...
|
|
template<class InputIterator , class OutputIterator > |
void | cartesianRepresentation (InputIterator begin, InputIterator end, OutputIterator out) const |
| Converts a sequence of barycentric coordinates into caresian coordinates. More...
|
|
std::vector< std::array< T, 3 > > | cartesianRepresentation (std::vector< BarycentricPoint< T, Index >> const &points) const |
| Converts a sequence of barycentric coordinates into caresian coordinates. More...
|
|
template<class PtIter , class AttrIter , class OutputIterator > |
void | barycentricInterpolation (PtIter pointsBegin, PtIter pointsEnd, AttrIter attributesBegin, OutputIterator out, std::size_t attributeDimension=1) const |
| Interpolates per-vertex values for points inside a triangle. More...
|
|
template<class InputIterator , class OutputIterator > |
void | rayIntersections (InputIterator raysBegin, InputIterator raysEnd, OutputIterator intersectionsOut) const |
| Computes the intersection of a set of rays with the mesh. More...
|
|
RayMeshIntersection< T > | rayIntersection (Ray< T > const &ray) const |
| Computes intersection with the given ray and the mesh. More...
|
|
void | updatePerVertexNormals () |
| Re-computes per-vertex normals.
|
|
|
Mesh< T > & | upsample (std::size_t nTimes=1) |
| Upsample the mesh without touching the original vertices. More...
|
|
|
The methods in this section all call a functional with a pointer to raw data as its argument. The pointer only guaranteed to be valid within the call to the given functional.
- Attention
- Do not return the raw data pointer or save it in any other way!
|
template<class F > |
auto | withUnsafeVertexPointer (F &&f) const noexcept(noexcept(f(std::declval< const VertexData >().data()))) |
| Calls the given functional with an unsafe pointer to the raw vertex storage. More...
|
|
template<class F > |
auto | withUnsafeVertexPointer (F &&f) noexcept(noexcept(f(std::declval< VertexData >().data()))) |
|
template<class F > |
auto | withUnsafeIndexPointer (F &&f) const noexcept(noexcept(f(std::declval< const IndexData >().data()))) |
| Calls the given functional with an unsafe pointer to the raw index storage. More...
|
|
template<class F > |
auto | withUnsafeIndexPointer (F &&f) noexcept(noexcept(f(std::declval< IndexData >().data()))) |
|
template<class F > |
auto | withUnsafeLabelPointer (F &&f) const noexcept(noexcept(f(LabelData().data()))) |
| Calls the given functional with an unsafe pointer to the raw label storage. More...
|
|
template<class F > |
auto | withUnsafeLabelPointer (F &&f) noexcept(noexcept(f(LabelData().data()))) |
|
template<class F > |
auto | withUnsafeVertexNormalPointer (F &&f) const noexcept(noexcept(f(std::declval< const NormalData >().data()))) |
| Calls the given functional with an unsafe pointer to the raw per vertex normal storage. More...
|
|
template<class F > |
auto | withUnsafeVertexNormalPointer (F &&f) noexcept(noexcept(f(std::declval< NormalData >().data()))) |
|
template<class T>
class CortidQCT::Mesh< T >
A triangle mesh class.
- Template Parameters
-
T | Scalar type of the vector space of the embedding, must be a floating point type |
template<class T >
template<class PtIter , class AttrIter , class OutputIterator >
template void CortidQCT::Mesh< T >::barycentricInterpolation |
( |
PtIter |
pointsBegin, |
|
|
PtIter |
pointsEnd, |
|
|
AttrIter |
attributesBegin, |
|
|
OutputIterator |
out, |
|
|
std::size_t |
attributeDimension = 1 |
|
) |
| const |
Interpolates per-vertex values for points inside a triangle.
This input of this function are some points on the surfac of the mesh in barycentric representation and a vector of per-vertex attributes/values that are to be interpolated. The per-vertex attributes/values do not have to be scalar, vector values attributes can be used by setting the attributeDimension
paremter. The attributes must be in row major order, i.e. a full attribute vector is stored in consecutively in the underlying container.
- Template Parameters
-
PtIter | InputIterator of BarycentricPoint type |
AttrIter | RandomAccessIterator of scalar type |
OutputIterator | output iterator acceptiong scalar of the same type as AttrIter |
- Parameters
-
[in] | pointsBegin | input iterator pointing to the first barycentric point |
[in] | pointsEnd | input iterator pointing one element past the last barycentric point |
[in] | attributesBegin | random access iterator pointing to the first attribute vector |
[out] | out | output iterator |
[in] | attributeDimension | number of attribute dimensions, defaults to 1 |
- Exceptions
-
std::out_of_range | if a trinagle index is out of range In case of an exception out is only untouched if and only if PtIter conforms to ForwardIterator . If PtIter only conforms to IputIterator , all values up to the one where the exception happened will be written to out . |
Returns the cartesian coordinate of a point in barycentric coordinates.
- Parameters
-
[in] | point | point in barycentric coodinate representation |
- Returns
- vartesian coordinates of the point
- Exceptions
-
std::out_of_range | if the triangle index of the point is invalid. |
template<class T >
template<class InputIterator , class OutputIterator >
void CortidQCT::Mesh< T >::cartesianRepresentation |
( |
InputIterator |
begin, |
|
|
InputIterator |
end, |
|
|
OutputIterator |
out |
|
) |
| const |
Converts a sequence of barycentric coordinates into caresian coordinates.
The implementation uses barycetnricInterpolation. OutputIterator's value_type must be T.
- Parameters
-
[in] | begin | iterator that points to the first cartesian point |
[in] | end | interator that points right after the last point |
[out] | out | output iterator |
- Exceptions
-
std::out_of_range | if a triangle index is out of range |
- See also
- barycentricInterpolation
Converts a sequence of barycentric coordinates into caresian coordinates.
- Parameters
-
[in] | points | std::vector of barycentric points |
- Returns
- a std::vector of cartesian points
- Exceptions
-
std::out_of_range | if a triangle index is out of range |
true iff the mesh is empty
The mesh is empty iff the triangle or the vertex count is zero
template<class T >
Mesh< T > & CortidQCT::Mesh< T >::loadFromFile |
( |
std::string const & |
meshFilename, |
|
|
std::string const & |
labelFilename |
|
) |
| |
Load mesh and labels from ASCII file using format auto detection.
Supported file formats are: obj, off, stl, wrl, ply, mesh, SIMesh. If a .off file with color data (COFF) is given and the labels should be extracted from the color data, use the overload loadFromFile(std::string const &, ColorToLabelMap<Label, double> const &)
.
- Parameters
-
meshFilename | Path to the file to load the mesh from |
labelFilename | Optional path to the file to load the vertex labels from. |
- Returns
- Reference to the loaded mesh
- Exceptions
-
std::invalid_argument | if the mesh or the labels could not be loaded from the given filename |
std::invalid_argument | if the file file format could not be recognized |
Load mesh from ASCII file using format auto detection and extract labels from per-vertex colors.
Supported file formats are: off (COFF), SIMesh. Per-vertex colors are converted to labels using the given colormap. For SIMesh format, the labels are directly read from the file. For other formats use the overload loadFromFile(std::string const &, std::string const &)
- Parameters
-
- Returns
- Reference to the loaded mesh
- Exceptions
-
std::invalid_argument | if the mesh could not be loaded from the given filename |
std::invalid_argument | if the file file format could not be recognized |
template<class T >
template<class InputIterator , class OutputIterator >
template void CortidQCT::Mesh< T >::rayIntersections |
( |
InputIterator |
raysBegin, |
|
|
InputIterator |
raysEnd, |
|
|
OutputIterator |
intersectionsOut |
|
) |
| const |
Computes the intersection of a set of rays with the mesh.
If for any ray no intersection can be found, the corresponding RayMeshIntersection object is left with its default values (its signed distance is infinity).
- Template Parameters
-
InputIterator | Input iterator with value_type of Ray |
OutputIterator | Output iterator with value_type of RayMeshIntersection |
- Parameters
-
raysBegin | Iterator poiting to the first ray |
raysEnd | Iterator pointing one element past the last ray |
intersectionsOut | Output iterator for intersections |
Upsample the mesh without touching the original vertices.
- Parameters
-
nTimes | number of subsample iterations |
- Returns
- Reference to
*this
template<class T>
template<class F >
Calls the given functional with an unsafe pointer to the raw index storage.
Indices are stored contiguously in memory: [i_0, i_1, ...].
- Template Parameters
-
F | Function that accepts a Index const * pointer as the only argument. |
- Exceptions
-
noexcept(conditional) | iff f(Index const *) is noexcept. |
- Returns
- The return value of the functional
template<class T>
template<class F >
Calls the given functional with an unsafe pointer to the raw label storage.
Labels are stored contiguously in memory: [l_0, l_1, ...].
- Template Parameters
-
F | Function that accepts a Label const * pointer as the only argument. |
- Exceptions
-
noexcept(conditional) | iff f(Label const *) is noexcept. |
- Returns
- The return value of the functional
template<class T>
template<class F >
Calls the given functional with an unsafe pointer to the raw per vertex normal storage.
Vertex normals are stored contiguously in memory: [dx_0, dy_0, dz_0, dx_1, dy_1, dz_1, ...].
- Template Parameters
-
F | Function that accepts a Scalar const * pointer as the only argument. |
- Exceptions
-
noexcept(conditional) | iff f(Scalar const *) is noexcept. |
- Returns
- The return value of the functional
template<class T>
template<class F >
Calls the given functional with an unsafe pointer to the raw vertex storage.
Vertices are stored contiguously in memory: [x_0, y_0, z_0, x_1, y_1, z_1, ...].
- Template Parameters
-
F | Function that accepts a Scalar const * pointer as the only argument. |
- Exceptions
-
noexcept(conditional) | iff f(Scalar const *) is noexcept. |
- Returns
- The return value of the functional
template<class T >
void CortidQCT::Mesh< T >::writeToFile |
( |
std::string const & |
meshFilename, |
|
|
std::string const & |
labelFilename |
|
) |
| const |
Writes mesh to ASCII file using format auto detection.
Supported file formats are: obj, off, stl, wrl, ply, mesh, SIMesh. Labels are written rowwise to labelFilename
. For encoding the labels in the color attribute use the overload writeToFile(std::string const &, LabelToColorMap<double, Label> const &)
.
- Parameters
-
meshFilename | path to the file to write the mesh to |
labelFilename | path to the file to write the labels to |
- Exceptions
-
std::invalid_argument | if the mesh or the labels could not be writted to the given file |
std::invalid_argument | if the file file format could not be recognized |
- Note
- Does nothing on empty meshes
Writes mesh to ASCII file using format auto detection and encode labels as colors.
Supported file formats are: off (coff), SIMesh. The labels are encoded in per-vertex colors using the given label to color map. For the 'SIMesh' format the labels are written directly into the mesh file, ignoring the color encoding. For storing the labels in a separate file use the overload writeToFile(std::string const &, std::string const &)
.
- Parameters
-
- Exceptions
-
std::invalid_argument | if the mesh could not be writted to the given file |
std::invalid_argument | if the file file format could not be recognized |
- Note
- Does nothing on empty meshes
The documentation for this class was generated from the following files: