This commit is contained in:
niko
2026-06-04 11:42:34 +02:00
parent f39ba70a9f
commit e720b98cd1
7488 changed files with 2493818 additions and 0 deletions
+138
View File
@@ -0,0 +1,138 @@
using System;
using TriangleNet.Data;
using TriangleNet.Log;
namespace TriangleNet
{
// Token: 0x02000005 RID: 5
public static class MeshValidator
{
// Token: 0x06000038 RID: 56 RVA: 0x000038D0 File Offset: 0x00001AD0
public static bool IsConsistent(Mesh mesh)
{
Otri otri = default(Otri);
Otri otri2 = default(Otri);
Otri otri3 = default(Otri);
ILog<SimpleLogItem> instance = SimpleLog.Instance;
bool noExact = Behavior.NoExact;
Behavior.NoExact = false;
int num = 0;
foreach (Triangle triangle in mesh.triangles.Values)
{
otri.triangle = triangle;
otri.orient = 0;
while (otri.orient < 3)
{
Vertex vertex = otri.Org();
Vertex vertex2 = otri.Dest();
if (otri.orient == 0)
{
Vertex vertex3 = otri.Apex();
if (Primitives.CounterClockwise(vertex, vertex2, vertex3) <= 0.0)
{
if (Behavior.Verbose)
{
instance.Warning("Triangle is flat or inverted.", "Quality.CheckMesh()");
}
num++;
}
}
otri.Sym(ref otri2);
if (otri2.triangle != Mesh.dummytri)
{
otri2.Sym(ref otri3);
if (otri.triangle != otri3.triangle || otri.orient != otri3.orient)
{
if (otri.triangle == otri3.triangle && Behavior.Verbose)
{
instance.Warning("Asymmetric triangle-triangle bond: (Right triangle, wrong orientation)", "Quality.CheckMesh()");
}
num++;
}
Vertex vertex4 = otri2.Org();
Vertex vertex5 = otri2.Dest();
if (vertex != vertex5 || vertex2 != vertex4)
{
if (Behavior.Verbose)
{
instance.Warning("Mismatched edge coordinates between two triangles.", "Quality.CheckMesh()");
}
num++;
}
}
otri.orient++;
}
}
mesh.MakeVertexMap();
foreach (Vertex vertex6 in mesh.vertices.Values)
{
if (vertex6.tri.triangle == null && Behavior.Verbose)
{
instance.Warning("Vertex (ID " + vertex6.id + ") not connected to mesh (duplicate input vertex?)", "Quality.CheckMesh()");
}
}
Behavior.NoExact = noExact;
return num == 0;
}
// Token: 0x06000039 RID: 57 RVA: 0x00003B34 File Offset: 0x00001D34
public static bool IsDelaunay(Mesh mesh)
{
return MeshValidator.IsDelaunay(mesh, false);
}
// Token: 0x0600003A RID: 58 RVA: 0x00003B3D File Offset: 0x00001D3D
public static bool IsConstrainedDelaunay(Mesh mesh)
{
return MeshValidator.IsDelaunay(mesh, true);
}
// Token: 0x0600003B RID: 59 RVA: 0x00003B48 File Offset: 0x00001D48
private static bool IsDelaunay(Mesh mesh, bool constrained)
{
Otri otri = default(Otri);
Otri otri2 = default(Otri);
Osub osub = default(Osub);
ILog<SimpleLogItem> instance = SimpleLog.Instance;
bool noExact = Behavior.NoExact;
Behavior.NoExact = false;
int num = 0;
Vertex infvertex = mesh.infvertex1;
Vertex infvertex2 = mesh.infvertex2;
Vertex infvertex3 = mesh.infvertex3;
foreach (Triangle triangle in mesh.triangles.Values)
{
otri.triangle = triangle;
otri.orient = 0;
while (otri.orient < 3)
{
Vertex vertex = otri.Org();
Vertex vertex2 = otri.Dest();
Vertex vertex3 = otri.Apex();
otri.Sym(ref otri2);
Vertex vertex4 = otri2.Apex();
bool flag = otri.triangle.id < otri2.triangle.id && !Otri.IsDead(otri2.triangle) && otri2.triangle != Mesh.dummytri && vertex != infvertex && vertex != infvertex2 && vertex != infvertex3 && vertex2 != infvertex && vertex2 != infvertex2 && vertex2 != infvertex3 && vertex3 != infvertex && vertex3 != infvertex2 && vertex3 != infvertex3 && vertex4 != infvertex && vertex4 != infvertex2 && vertex4 != infvertex3;
if (constrained && mesh.checksegments && flag)
{
otri.SegPivot(ref osub);
if (osub.seg != Mesh.dummysub)
{
flag = false;
}
}
if (flag && Primitives.NonRegular(vertex, vertex2, vertex3, vertex4) > 0.0)
{
if (Behavior.Verbose)
{
instance.Warning(string.Format("Non-regular pair of triangles found (IDs {0}/{1}).", otri.triangle.id, otri2.triangle.id), "Quality.CheckDelaunay()");
}
num++;
}
otri.orient++;
}
}
Behavior.NoExact = noExact;
return num == 0;
}
}
}