Module |
|
Header |
/Engine/Plugins/Experimental/GeometryProcessing/Source/DynamicMesh/Public/DynamicMesh3.h |
Include |
#include "DynamicMesh3.h" |
class FDynamicMesh3
FDynamicMesh3 is a dynamic triangle mesh class. The mesh has has connectivity, is an indexed mesh, and allows for gaps in the index space.
internally, all data is stored in POD-type buffers, except for the vertex->edge links, which are stored as List<int>'s. The arrays of POD data are stored in TDynamicVector's, so they grow in chunks, which is relatively efficient. The actual blocks are arrays, so they can be efficiently mem-copied into larger buffers if necessary.
Reference counts for verts/tris/edges are stored as separate FRefCountVector instances.
Vertices are stored as doubles, although this should be easily changed if necessary, as the internal data structure is not exposed
Per-vertex Vertex Normals, Colors, and UVs are optional and stored as floats.
For each vertex, VertexEdgeLists[i] is the unordered list of connected edges. The elements of the list are indices into the edges list. This list is unsorted but can be traversed in-order (ie cw/ccw) at some additional cost.
Triangles are stored as 3 ints, with optionally a per-triangle integer group id.
The edges of a triangle are similarly stored as 3 ints, in triangle_edes. If the triangle is [v1,v2,v3], then the triangle edges [e1,e2,e3] are e1=edge(v1,v2), e2=edge(v2,v3), e3=edge(v3,v1), where the e# are indexes into edges.
Edges are stored as tuples of 4 ints. If the edge is between v1 and v2, with neighbour tris t1 and t2, then the edge is [min(v1,v2), max(v1,v2), t1, t2]. For a boundary edge, t2 is InvalidID. t1 is never InvalidID.
Most of the class assumes that the mesh is manifold. Many functions will work if the topology is non-manifold, but behavior of operators like Split/Flip/Collapse edge is untested.
The function CheckValidity() does extensive sanity checking on the mesh data structure. Use this to test your code, both for mesh construction and editing!!
TODO:
Many of the iterators depend on lambda functions, can we replace these with calls to internal/static functions that do the same thing?
efficient TriTrianglesItr() implementation?
additional Topology timestamp?
CompactInPlace() does not compact VertexEdgeLists ? TDynamicVector w/ 'stride' option, so that we can guarantee that tuples are in single block. The can have custom accessor that looks up entire tuple
Name | Description | ||
---|---|---|---|
|
TUniquePtr< FDy... |
AttributeSet |
|
|
bIsClosedCached |
Cached value of IsClosed() |
|
|
CachedBoundingBox |
Cached vertex bounding box (includes unreferenced vertices) |
|
|
int |
CachedBoundingBoxTimestamp |
Timestamp for CachedBoundingBox, if less than current timestamp, cache is invalid |
|
int |
CachedIsClosedTimestamp |
Timestamp for bIsClosedCached, if less than current timestamp, cache is invalid |
|
EdgeRefCounts |
Reference counts of edge indices. |
|
|
TDynamicVector<... |
Edges |
List of edge elements. |
|
int |
GroupIDCounter |
Upper bound on the triangle group IDs used in the mesh (may be larger than the actual maximum if triangles have been deleted) |
|
int |
ShapeTimestamp |
The shape timestamp is incremented any time a function that modifies the mesh shape or topology is called |
|
int |
Timestamp |
The mesh timestamp is incremented any time a function that modifies the mesh is called |
|
int |
TopologyTimestamp |
The topology timestamp is incremented any time a function that modifies the mesh topology is called |
|
TDynamicVector<... |
TriangleEdges |
List of triangle edge triplets [Edge0 Edge1 Edge2] |
|
TriangleGroups |
(optional) List of per-triangle group identifiers |
|
|
TriangleRefCounts |
Reference counts of triangle indices. |
|
|
TDynamicVector<... |
Triangles |
List of triangle vertex-index triplets [Vert0 Vert1 Vert2] |
|
VertexColors |
(optional) List of per-vertex colors |
|
|
VertexEdgeLists |
List of per-vertex edge one-rings |
|
|
VertexNormals |
(optional) List of per-vertex normals |
|
|
VertexRefCounts |
Reference counts of vertex indices. |
|
|
VertexUVs |
(optional) List of per-vertex uv's |
|
|
TDynamicVector<... |
Vertices |
List of vertex positions |
Name | Description | |
---|---|---|
|
FDynamicMesh3() |
Default constructor |
|
FDynamicMesh3 ( |
Copy/Move construction |
|
FDynamicMesh3 ( |
|
|
FDynamicMesh3 ( |
Default constructor |
|
FDynamicMesh3 ( |
Construction from Mesh Generator |
|
FDynamicMesh3 |
Construct an empty mesh with specified attributes |
Name | Description | |
---|---|---|
|
~FDynamicMesh3() |
Destructor |
Name | Description | ||
---|---|---|---|
|
int |
AddEdgeInternal ( |
|
|
AddTriangleEdge ( |
||
|
int |
AddTriangleInternal ( |
|
|
AllocateEdgesList ( |
||
|
int |
AllocateTriangleGroup() |
|
|
int |
AppendTriangle ( |
|
|
int |
AppendTriangle ( |
|
|
int |
AppendVertex ( |
Append vertex at position, returns vid |
|
int |
AppendVertex ( |
Copy vertex SourceVertexID from existing SourceMesh, returns new vertex id |
|
int |
AppendVertex ( |
Mesh ConstructionAppend vertex at position and other fields, returns vid |
|
FDynamicMesh... |
Attributes() |
|
|
const FDynam... |
Attributes() |
|
|
BeginUnsafeTrianglesInsert() |
Call this before a set of unsafe InsertTriangle() calls |
|
|
BeginUnsafeVerticesInsert() |
Support for inserting vertex and triangle at specific IDs. |
|
|
FRefCountVec... |
BoundaryEdgeIndicesItr() |
|
|
double |
CalculateWindingNumber ( |
Compute mesh winding number, from Jacobson et. |
|
CheckValidity ( |
Checks that the mesh is well-formed, ie all internal data structures are consistent |
|
|
Clear() |
Discard all data |
|
|
CollapseEdge ( |
Collapse the edge between the two vertices, if topologically possible. |
|
|
CollapseEdge ( |
||
|
CompactCopy ( |
Copy input mesh while compacting, i.e. removing unused vertices/triangles/edges |
|
|
CompactInPlace ( |
Mesh Edit operations Compact mesh in-place, by moving vertices around and rewriting indices. |
|
|
double |
CompactMetric() |
Returns measure of compactness in range [0,1], where 1 is fully compacted |
|
Copy ( |
Set internal data structures to be a copy of input mesh using the specified attributes |
|
|
Copy ( |
Initialize mesh from the output of a MeshShapeGenerator (assumes Generate() was already called) |
|
|
DiscardAttributes() |
||
|
DiscardTriangleGroups() |
||
|
DiscardVertexColors() |
||
|
DiscardVertexNormals() |
||
|
DiscardVertexUVs() |
||
|
int |
EdgeCount() |
|
|
EdgeHasTriangle ( |
||
|
EdgeHasVertex ( |
||
|
edge_iterato... |
EdgeIndicesItr() |
|
|
value_iterat... |
EdgesItr() |
Enumerate edges. |
|
EnableAttributes() |
||
|
EnableTriangleGroups ( |
||
|
EnableVertexColors ( |
||
|
EnableVertexNormals ( |
Vertex and Triangle attribute arrays |
|
|
EnableVertexUVs ( |
||
|
EndUnsafeTrianglesInsert() |
Call after a set of unsafe InsertTriangle() calls to rebuild free list |
|
|
EndUnsafeVerticesInsert() |
Call after a set of unsafe InsertVertex() calls to rebuild free list |
|
|
int |
FindEdge ( |
Find id of edge connecting A and B |
|
int |
FindEdgeFromTri ( |
Find edgeid for edge [a,b] from triangle that contains the edge. |
|
int |
FindEdgeFromTriPair ( |
Find edgeid for edge connecting two triangles |
|
int |
FindTriangle ( |
Find triangle made up of any permutation of vertices [a,b,c] |
|
int |
FindTriangleEdge ( |
Returns edge ID |
|
FlipEdge ( |
Calls FlipEdge() on the edge between two vertices, if it exists |
|
|
FlipEdge ( |
Flip/Rotate an edge of the mesh. |
|
|
GetAllVertexGroups ( |
Returns all group IDs at vertex |
|
|
int |
GetAllVtxBoundaryEdges ( |
Find edge ids of boundary edges connected to vertex. |
|
FAxisAligned... |
GetBounds() |
Geometric queriesReturns bounding box of all mesh vertices (including unreferenced vertices) |
|
FAxisAligned... |
GetCachedBounds() |
Returns GetBounds() and saves result, cache is invalidated and recomputed if topology has changed since last call |
|
GetCachedIsClosed() |
||
|
const TDynam... |
GetColorsBuffer() |
|
|
int |
GetComponentsFlags() |
|
|
GetEdge ( |
Get the vertices and triangles of an edge, returned as [v0,v1,t0,t1], where t1 may be InvalidID |
|
|
GetEdgeNormal ( |
Returns average normal of connected face normals |
|
|
GetEdgeOpposingV ( |
If edge has vertices [a,b], and is connected two triangles [a,b,c] and [a,b,d], this returns [c,d], or [c,InvalidID] for a boundary edge |
|
|
GetEdgePoint ( |
Get point along edge, t clamped to range [0,1] |
|
|
const TDynam... |
GetEdgesBuffer() |
|
|
const FRefCo... |
GetEdgesRefCounts() |
|
|
GetEdgeT ( |
Get the triangle pair for an edge. The second triangle may be InvalidID |
|
|
GetEdgeV ( |
Get the vertex pair for an edge |
|
|
GetEdgeV |
Get the vertex positions of an edge |
|
|
int |
GetMaxVtxEdgeCount() |
|
|
const TDynam... |
GetNormalsBuffer() |
|
|
GetOrderedOneRingEdgeTris ( |
Utility function that returns one or two triangles of edge, used to enumerate vertex one-ring triangles The logic is a bit tricky to follow without drawing it out on paper, but this will only return each triangle once, for the 'outgoing' edge from the vertex, and each triangle only has one such edge at any vertex (including boundary triangles) |
|
|
GetOrientedBoundaryEdgeV ( |
Return edge vertex indices, but oriented based on attached triangle (rather than min-sorted) |
|
|
int |
GetOtherEdgeTriangle ( |
|
|
int |
GetOtherEdgeVertex ( |
|
|
int |
GetShapeTimestamp() |
ShapeTimestamp is incremented any time any vertex position is changed or the mesh topology is modified |
|
int |
GetTimestamp() |
Timestamp is incremented any time any change is made to the mesh |
|
int |
GetTopologyTimestamp() |
TopologyTimestamp is incremented any time any vertex position is changed or the mesh topology is modified |
|
GetTriangle ( |
Get triangle vertices |
|
|
int |
GetTriangleGroup ( |
|
|
const TDynam... |
GetTriangleGroupsBuffer() |
|
|
const TDynam... |
GetTrianglesBuffer() |
|
|
const FRefCo... |
GetTrianglesRefCounts() |
|
|
double |
GetTriArea ( |
Calculate area triangle |
|
GetTriBaryNormal ( |
Interpolate vertex normals of triangle using barycentric coordinates |
|
|
GetTriBaryPoint ( |
Interpolate vertex positions of triangle using barycentric coordinates |
|
|
GetTriBaryPoint ( |
Compute interpolated vertex attributes at point of triangle |
|
|
FAxisAligned... |
GetTriBounds ( |
Construct bounding box of triangle as efficiently as possible |
|
GetTriCentroid ( |
Compute centroid of triangle |
|
|
int |
GetTriEdge ( |
Get one of the edges of a triangle |
|
GetTriEdges ( |
Get triangle edges |
|
|
GetTriFrame ( |
Construct stable frame at triangle centroid, where frame.Z is face normal, and frame.X is aligned with edge nEdge of triangle. |
|
|
GetTriInfo |
Compute triangle normal, area, and centroid all at once. |
|
|
double |
GetTriInternalAngleR ( |
Compute internal angle at vertex i of triangle (where i is 0,1,2); |
|
GetTriInternalAnglesR ( |
Compute internal angles at all vertices of triangle |
|
|
GetTriNeighbourTris ( |
Find the neighbour triangles of a triangle (any of them might be InvalidID) |
|
|
GetTriNormal ( |
Calculate face normal of triangle |
|
|
double |
GetTriSolidAngle ( |
Compute solid angle of oriented triangle tID relative to point p - see WindingNumber() |
|
GetTriVertex ( |
Get the position of one of the vertices of a triangle |
|
|
GetTriVertices |
Get the three vertex positions of a triangle |
|
|
const TDynam... |
GetUVBuffer() |
|
|
GetVertex ( |
Vertex/Tri/Edge accessors |
|
|
GetVertex |
Get extended vertex information |
|
|
GetVertexColor ( |
||
|
const FSmall... |
GetVertexEdges() |
|
|
GetVertexEdgesList ( |
||
|
GetVertexFrame ( |
Compute a normal/tangent frame at vertex that is "stable" as long as the mesh topology doesn't change, meaning that one axis of the frame will be computed from projection of outgoing edge. |
|
|
GetVertexGroups ( |
Returns up to 4 group IDs at vertex. Returns false if > 4 encountered |
|
|
FVertexInfo |
GetVertexInfo ( |
Get all vertex information available |
|
GetVertexNormal ( |
||
|
GetVertexOneRingTriangles ( |
Adds triangles touching VertexID to the TrianglesOut list |
|
|
GetVertexUV ( |
||
|
const TDynam... |
GetVerticesBuffer() |
Direct buffer access |
|
const FRefCo... |
GetVerticesRefCounts() |
|
|
int |
GetVtxBoundaryEdges ( |
Returns count of boundary edges at vertex, and the first two boundary edges if found. |
|
GetVtxContiguousTriangles |
Get triangles connected to vertex in contiguous order, with multiple groups if vertex is a bowtie. |
|
|
int |
GetVtxEdgeCount ( |
|
|
GetVtxNbrhood ( |
Given an edge and vertex on that edge, returns other vertex of edge, the two opposing verts, and the two connected triangles (OppVert2Out and Tri2Out are be InvalidID for boundary edge) |
|
|
GetVtxOneRingCentroid ( |
Fastest possible one-ring centroid. |
|
|
int |
GetVtxTriangleCount ( |
Return # of triangles attached to vID, or -1 if invalid vertex if bBruteForce = true, explicitly checks, which creates a list and is expensive default is false, uses orientation, no memory allocation |
|
GetVtxTriangles |
Get triangle one-ring at vertex. |
|
|
HasAttributes() |
||
|
HasTriangleGroups() |
||
|
HasVertexColors() |
||
|
HasVertexNormals() |
||
|
HasVertexUVs() |
||
|
InsertTriangle |
Insert triangle at given index, assuming it is unused. |
|
|
InsertVertex ( |
Insert vertex at given index, assuming it is unused. |
|
|
IsBoundaryEdge ( |
Topological queriesReturns true if edge is on the mesh boundary, ie only connected to one triangle |
|
|
IsBoundaryTriangle ( |
Returns true if any edge of triangle is a boundary edge |
|
|
IsBoundaryVertex ( |
Returns true if the vertex is part of any boundary edges |
|
|
IsBowtieVertex ( |
Returns true if vID is a "bowtie" vertex, ie multiple disjoint triangle sets in one-ring |
|
|
IsClosed() |
||
|
IsCompact() |
Returns true if vertices, edges, and triangles are all dense (Count == MaxID) |
|
|
IsCompactT() |
||
|
IsCompactV() |
||
|
IsEdge ( |
||
|
IsGroupBoundaryEdge ( |
Returns true if the two triangles connected to edge have different group IDs |
|
|
IsGroupBoundaryVertex ( |
Returns true if vertex has more than one tri group in its tri nbrhood |
|
|
IsGroupJunctionVertex ( |
Returns true if more than two group boundary edges meet at vertex (ie 3+ groups meet at this vertex) |
|
|
IsReferencedVertex ( |
||
|
IsSameMesh |
Check if another mesh is the same as this mesh. |
|
|
IsTriangle ( |
||
|
IsVertex ( |
||
|
int |
MaxEdgeID() |
|
|
int |
MaxGroupID() |
|
|
int |
MaxTriangleID() |
|
|
int |
MaxVertexID() |
|
|
MergeEdges ( |
Given two edges of the mesh, weld both their vertices, so that one edge is removed. |
|
|
MeshInfoString() |
Debug utility functions Returns a debug string that contains mesh statistics and other information |
|
|
PokeTriangle ( |
Insert a new vertex inside a triangle, ie do a 1 to 3 triangle split |
|
|
PokeTriangle ( |
Call PokeTriangle at the centroid of the triangle |
|
|
RemoveTriangle |
Remove a triangle from the mesh. |
|
|
RemoveVertex |
Remove vertex vID, and all connected triangles if bRemoveAllTriangles = true Returns Failed_VertexStillReferenced if vertex is still referenced by triangles. |
|
|
int |
ReplaceEdgeTriangle ( |
|
|
int |
ReplaceEdgeVertex ( |
|
|
int |
ReplaceTriangleEdge ( |
|
|
int |
ReplaceTriangleVertex ( |
|
|
ReverseOrientation ( |
Reverse the ccw/cw orientation of all triangles in the mesh, and optionally flip the vertex normals if they exist |
|
|
ReverseTriOrientation ( |
Reverse the ccw/cw orientation of a triangle |
|
|
ReverseTriOrientationInternal ( |
||
|
SetEdgeTrianglesInternal ( |
||
|
SetEdgeVerticesInternal ( |
||
|
SetTriangle |
Rewrite the triangle to reference the new tuple of vertices. |
|
|
SetTriangleEdgesInternal ( |
||
|
SetTriangleGroup ( |
||
|
SetTriangleInternal ( |
Internal functions |
|
|
SetVertex ( |
Set vertex position |
|
|
SetVertexColor ( |
||
|
SetVertexNormal ( |
||
|
SetVertexUV ( |
||
|
SplitEdge ( |
Split an edge of the mesh by inserting a vertex. |
|
|
SplitEdge ( |
Splits the edge between two vertices at the midpoint, if this edge exists |
|
|
SplitVertex ( |
Clones the given vertex and updates any provided triangles to use the new vertex if/where they used the old one. |
|
|
SplitVertexWouldLeaveIsolated ( |
Tests whether splitting the given vertex with the given triangles would leave no triangles attached to the original vertex (creating an isolated vertex) |
|
|
int |
TriangleCount() |
|
|
TriangleHasVertex ( |
||
|
triangle_ite... |
TriangleIndicesItr() |
|
|
value_iterat... |
TrianglesItr() |
Enumerate all triangles in the mesh |
|
TriHasNeighbourTri ( |
||
|
TriHasSequentialVertices ( |
||
|
UpdateTimeStamp |
||
|
int |
VertexCount() |
|
|
vertex_itera... |
VertexIndicesItr() |
|
|
value_iterat... |
VerticesItr() |
Enumerate positions of all vertices in mesh |
|
FSmallListSe... |
VtxEdgesItr ( |
|
|
vtx_triangle... |
VtxTrianglesItr ( |
|
|
FSmallListSe... |
VtxVerticesItr ( |
Name | Description | ||
---|---|---|---|
|
const FDynam... |
operator= ( |
|
|
const FDynam... |
operator= ( |
Copy and move assignment |
Name |
Description |
|
---|---|---|
|
FValidityOptions |
Options for what the validity check will permit |
Name |
Description |
---|---|
edge_iterator |
|
FEdgeCollapseInfo |
|
FEdgeFlipInfo |
|
FEdgeSplitInfo |
|
FMergeEdgesInfo |
|
FPokeTriangleInfo |
|
FVertexSplitInfo |
|
triangle_iterator |
|
value_iteration |
|
vertex_iterator |
Simplify names for iterations |
vtx_triangles_enumerable |
Name |
Description |
---|---|
DuplicateTriangleID |
DuplicateTriangleID is returned by AppendTriangle() to indicate that the added triangle already exists in the mesh, and was ignored because we do not support duplicate triangles |
InvalidEdge |
|
InvalidGroupID |
InvalidGroupID indicates that a group ID is invalid |
InvalidID |
InvalidID indicates that a vertex/edge/triangle ID is invalid |
InvalidTriangle |
|
InvalidVertex |
|
NonManifoldID |
NonManifoldID is returned by AppendTriangle() to indicate that the added triangle would result in nonmanifold geometry and hence was ignored |