Files
UnrealEngineUWP/Engine/Plugins/Runtime/GeometryProcessing/Source/DynamicMesh/Private/Selections/MeshEdgeSelection.cpp
michael balzer b8a1c9b6cf GeometryCore: Remove ExplicitUseGeometryMathTypes.h
#ROBOMERGE-AUTHOR: michael.balzer
#ROBOMERGE-SOURCE: CL 18227685 in //UE5/Release-5.0/... via CL 18229350
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469)
#ROBOMERGE[STARSHIP]: UE5-Main

[CL 18231457 by michael balzer in ue5-release-engine-test branch]
2021-11-17 19:02:44 -05:00

68 lines
1.7 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Selections/MeshEdgeSelection.h"
#include "DynamicMesh/DynamicMesh3.h"
#include "Containers/Set.h"
#include "Selections/MeshFaceSelection.h"
#include "Selections/MeshVertexSelection.h"
using namespace UE::Geometry;
// 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]);
}
}
}
}