Manifold 1.0
Robust computational geometry
 
Loading...
Searching...
No Matches
MeshGL Struct Reference

#include <manifold.h>

Public Member Functions

uint32_t NumVert () const
 Number of property vertices.
 
uint32_t NumTri () const
 Number of triangles.
 
 MeshGL (const Mesh &mesh)
 Constructs a position-only MeshGL from the input Mesh.
 
bool Merge ()
 

Public Attributes

uint32_t numProp = 3
 Number of properties per vertex, always >= 3.
 
std::vector< floatvertProperties
 
std::vector< uint32_ttriVerts
 
std::vector< uint32_tmergeFromVert
 
std::vector< uint32_tmergeToVert
 
std::vector< uint32_trunIndex
 
std::vector< uint32_trunOriginalID
 
std::vector< floatrunTransform
 
std::vector< uint32_tfaceID
 
std::vector< floathalfedgeTangent
 
float precision = 0
 

Detailed Description

An alternative to Mesh for output suitable for pushing into graphics libraries directly. 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.

Member Function Documentation

◆ Merge()

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 precision (the maximum of the MeshGL precision and the baseline bounding-box precision), keeping any from the existing merge vectors.

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 a Status if it is not manifold.

Member Data Documentation

◆ vertProperties

std::vector<float> 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

std::vector<uint32_t> triVerts

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

◆ mergeFromVert

std::vector<uint32_t> mergeFromVert

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

◆ mergeToVert

std::vector<uint32_t> 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

std::vector<uint32_t> 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

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

std::vector<float> 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

std::vector<uint32_t> faceID

Optional: Length NumTri, contains an ID of the source face this triangle comes from. When auto-generated, this ID will be a triangle index into the original mesh. All neighboring coplanar triangles from that input mesh will refer to a single triangle of that group as the faceID. When supplying faceIDs, ensure that triangles with the same ID are in fact coplanar and have consistent properties (within some tolerance) or the output will be surprising.

◆ halfedgeTangent

std::vector<float> 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.

◆ precision

float precision = 0

The absolute precision of the vertex positions, based on accrued rounding errors. When creating a Manifold, the precision used will be the maximum of this and a baseline precision from the size of the bounding box. Any edge shorter than precision may be collapsed.