Files
tyson brochu 03b4b2b9b2 New MeshPaths class. Given a set of edges on a mesh, finds the topology of simply connected edges and collects them into Spans.
#rb jimmy.andrews
#preflight 62a0c573232daff7b3efe3db

[CL 20557829 by tyson brochu in ue5-main branch]
2022-06-08 12:04:16 -04:00

54 lines
1.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "DynamicMesh/DynamicMesh3.h"
#include "EdgeSpan.h"
namespace UE
{
namespace Geometry
{
/**
* Given a mesh and a set of edges, walk connected edges to form a set of paths.
* We do not distinguish betweens spans and loops -- if the input set of edges forms a loop, it will create an FEdgeSpan with those edges.
* If the input edges do not form loops, then paths will begin/end at vertices incident on 1 or >2 of the given edges (e.g. "dead ends" or "intersections" of paths.)
*/
class DYNAMICMESH_API FMeshPaths
{
public:
FMeshPaths(const FDynamicMesh3* Mesh, const TSet<int>& Edges ) :
Mesh(Mesh),
Edges(Edges)
{}
// Inputs
const FDynamicMesh3* Mesh = nullptr;
const TSet<int> Edges;
// Outputs
TArray<FEdgeSpan> Spans;
// Find connected simple paths made up of edges in the input Edges structure
bool Compute();
private:
TSet<int> UnvisitedEdges;
// Helper for the Compute function
/*
* Find an edge adjacent to CurrentEdge which is in both the Edges and UnvisitedEdges set.
* Consider only edges incident on CrossedVertex, which is the vertex belonging to CurrentEdge that is not FromVertex.
* Do not consider an adjacent edge if CrossedVertex is incident on more than 2 input Edges (i.e. we've hit a corner).
*/
int GetNextEdge(int CurrentEdge, int FromVertex, int& CrossedVertex) const;
};
} // end namespace UE::Geometry
} // end namespace UE