Manifold 3.0
Robust geometry
 
Loading...
Searching...
No Matches
MeshGLP< Precision, I > Struct Template Reference

Mesh input/output suitable for pushing directly into graphics libraries. More...

#include <manifold.h>

Public Member Functions

NumVert () const
 Number of property vertices.
 
NumTri () const
 Number of triangles.
 
bool Merge ()
 
la::vec< Precision, 3 > GetVertPos (size_t v) const
 
la::vec< I, 3 > GetTriVerts (size_t t) const
 
la::vec< Precision, 4 > GetTangent (size_t h) const
 

Public Attributes

numProp = 3
 Number of properties per vertex, always >= 3.
 
std::vector< Precision > vertProperties
 
std::vector< I > triVerts
 
std::vector< I > mergeFromVert
 
std::vector< I > mergeToVert
 
std::vector< I > runIndex
 
std::vector< uint32_t > runOriginalID
 
std::vector< Precision > runTransform
 
std::vector< I > faceID
 
std::vector< Precision > halfedgeTangent
 
Precision tolerance = 0
 

Detailed Description

template<typename Precision, typename I = uint32_t>
struct manifold::MeshGLP< Precision, I >

Mesh input/output suitable for pushing directly into graphics libraries.

This may not be manifold since the verts are duplicated along property boundaries that do not match. The additional merge vectors store this missing information, allowing the manifold to be reconstructed. MeshGL is an alias for the standard single-precision version. Use MeshGL64 to output the full double precision that Manifold uses internally.

Member Function Documentation

◆ Merge()

template<typename Precision , typename I = uint32_t>
bool Merge ( )

Updates the mergeFromVert and mergeToVert vectors in order to create a manifold solid. If the MeshGL is already manifold, no change will occur and the function will return false. Otherwise, this will merge verts along open edges within tolerance (the maximum of the MeshGL tolerance and the baseline bounding-box tolerance), keeping any from the existing merge vectors, and return true.

There is no guarantee the result will be manifold - this is a best-effort helper function designed primarily to aid in the case where a manifold multi-material MeshGL was produced, but its merge vectors were lost due to a round-trip through a file format. Constructing a Manifold from the result will report an error status if it is not manifold.

◆ GetVertPos()

template<typename Precision , typename I = uint32_t>
la::vec< Precision, 3 > GetVertPos ( size_t v) const
inline

Returns the x, y, z position of the ith vertex.

Parameters
vvertex index.

◆ GetTriVerts()

template<typename Precision , typename I = uint32_t>
la::vec< I, 3 > GetTriVerts ( size_t t) const
inline

Returns the three vertex indices of the ith triangle.

Parameters
ttriangle index.

◆ GetTangent()

template<typename Precision , typename I = uint32_t>
la::vec< Precision, 4 > GetTangent ( size_t h) const
inline

Returns the x, y, z, w tangent of the ith halfedge.

Parameters
hhalfedge index (3 * triangle_index + [0|1|2]).

Member Data Documentation

◆ vertProperties

template<typename Precision , typename I = uint32_t>
std::vector<Precision> vertProperties

Flat, GL-style interleaved list of all vertex properties: propVal = vertProperties[vert * numProp + propIdx]. The first three properties are always the position x, y, z.

◆ triVerts

template<typename Precision , typename I = uint32_t>
std::vector<I> triVerts

The vertex indices of the three triangle corners in CCW (from the outside) order, for each triangle.

◆ mergeFromVert

template<typename Precision , typename I = uint32_t>
std::vector<I> mergeFromVert

Optional: A list of only the vertex indicies that need to be merged to reconstruct the manifold.

◆ mergeToVert

template<typename Precision , typename I = uint32_t>
std::vector<I> mergeToVert

Optional: The same length as mergeFromVert, and the corresponding value contains the vertex to merge with. It will have an identical position, but the other properties may differ.

◆ runIndex

template<typename Precision , typename I = uint32_t>
std::vector<I> runIndex

Optional: Indicates runs of triangles that correspond to a particular input mesh instance. The runs encompass all of triVerts and are sorted by runOriginalID. Run i begins at triVerts[runIndex[i]] and ends at triVerts[runIndex[i+1]]. All runIndex values are divisible by 3. Returned runIndex will always be 1 longer than runOriginalID, but same length is also allowed as input: triVerts.size() will be automatically appended in this case.

◆ runOriginalID

template<typename Precision , typename I = uint32_t>
std::vector<uint32_t> runOriginalID

Optional: The OriginalID of the mesh this triangle run came from. This ID is ideal for reapplying materials to the output mesh. Multiple runs may have the same ID, e.g. representing different copies of the same input mesh. If you create an input MeshGL that you want to be able to reference as one or more originals, be sure to set unique values from ReserveIDs().

◆ runTransform

template<typename Precision , typename I = uint32_t>
std::vector<Precision> runTransform

Optional: For each run, a 3x4 transform is stored representing how the corresponding original mesh was transformed to create this triangle run. This matrix is stored in column-major order and the length of the overall vector is 12 * runOriginalID.size().

◆ faceID

template<typename Precision , typename I = uint32_t>
std::vector<I> faceID

Optional: Length NumTri, contains the source face ID this triangle comes from. When auto-generated, this ID will be a triangle index into the original mesh. This index/ID is purely for external use (e.g. recreating polygonal faces) and will not affect Manifold's algorithms.

◆ halfedgeTangent

template<typename Precision , typename I = uint32_t>
std::vector<Precision> halfedgeTangent

Optional: The X-Y-Z-W weighted tangent vectors for smooth Refine(). If non-empty, must be exactly four times as long as Mesh.triVerts. Indexed as 4 * (3 * tri + i) + j, i < 3, j < 4, representing the tangent value Mesh.triVerts[tri][i] along the CCW edge. If empty, mesh is faceted.

◆ tolerance

template<typename Precision , typename I = uint32_t>
Precision tolerance = 0

Tolerance for mesh simplification. When creating a Manifold, the tolerance used will be the maximum of this and a baseline tolerance from the size of the bounding box. Any edge shorter than tolerance may be collapsed. Tolerance may be enlarged when floating point error accumulates.