2019-12-27 09:26:59 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2019-09-10 11:35:20 -04:00
|
|
|
|
|
|
|
|
#include "Selections/MeshEdgeSelection.h"
|
|
|
|
|
|
2021-06-13 00:36:02 -04:00
|
|
|
#include "DynamicMesh/DynamicMesh3.h"
|
2019-09-10 11:35:20 -04:00
|
|
|
#include "Containers/Set.h"
|
|
|
|
|
#include "Selections/MeshFaceSelection.h"
|
|
|
|
|
#include "Selections/MeshVertexSelection.h"
|
|
|
|
|
|
2021-03-09 19:33:56 -04:00
|
|
|
using namespace UE::Geometry;
|
2019-09-10 11:35:20 -04:00
|
|
|
|
|
|
|
|
// convert vertex selection to edge selection. Require at least minCount verts of edge to be selected
|
|
|
|
|
FMeshEdgeSelection::FMeshEdgeSelection(const FDynamicMesh3* mesh, const FMeshVertexSelection& convertV, int minCount) : Mesh(mesh)
|
|
|
|
|
{
|
|
|
|
|
for (int eid : Mesh->EdgeIndicesItr())
|
|
|
|
|
{
|
|
|
|
|
FIndex2i ev = Mesh->GetEdgeV(eid);
|
|
|
|
|
int n = (convertV.IsSelected(ev.A) ? 1 : 0) +
|
|
|
|
|
(convertV.IsSelected(ev.B) ? 1 : 0);
|
|
|
|
|
if (n >= minCount)
|
|
|
|
|
{
|
|
|
|
|
add(eid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// convert face selection to edge selection. Require at least minCount tris of edge to be selected
|
|
|
|
|
FMeshEdgeSelection::FMeshEdgeSelection(const FDynamicMesh3* mesh, const FMeshFaceSelection& convertT, int minCount) : Mesh(mesh)
|
|
|
|
|
{
|
|
|
|
|
minCount = FMathd::Clamp(minCount, 1, 2);
|
|
|
|
|
|
|
|
|
|
if (minCount == 1)
|
|
|
|
|
{
|
|
|
|
|
for (int tid : convertT)
|
|
|
|
|
{
|
|
|
|
|
FIndex3i te = Mesh->GetTriEdges(tid);
|
|
|
|
|
add(te.A); add(te.B); add(te.C);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (int eid : Mesh->EdgeIndicesItr())
|
|
|
|
|
{
|
|
|
|
|
FIndex2i et = Mesh->GetEdgeT(eid);
|
|
|
|
|
if (convertT.IsSelected(et.A) && convertT.IsSelected(et.B))
|
|
|
|
|
{
|
|
|
|
|
add(eid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FMeshEdgeSelection::SelectBoundaryTriEdges(const FMeshFaceSelection& Triangles)
|
|
|
|
|
{
|
|
|
|
|
for (int tid : Triangles)
|
|
|
|
|
{
|
|
|
|
|
FIndex3i te = Mesh->GetTriEdges(tid);
|
|
|
|
|
for ( int j = 0; j < 3; ++j )
|
|
|
|
|
{
|
|
|
|
|
FIndex2i et = Mesh->GetEdgeT(te[j]);
|
|
|
|
|
int other_tid = (et.A == tid) ? et.B : et.A;
|
|
|
|
|
if (Triangles.IsSelected(other_tid) == false)
|
|
|
|
|
{
|
|
|
|
|
add(te[j]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|