scripts
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using TriangleNet.Data;
|
||||
using TriangleNet.Geometry;
|
||||
using TriangleNet.Tools;
|
||||
|
||||
namespace TriangleNet.Smoothing
|
||||
{
|
||||
// Token: 0x0200001E RID: 30
|
||||
public class SimpleSmoother : ISmoother
|
||||
{
|
||||
// Token: 0x06000109 RID: 265 RVA: 0x00015047 File Offset: 0x00013247
|
||||
public SimpleSmoother(Mesh mesh)
|
||||
{
|
||||
this.mesh = mesh;
|
||||
}
|
||||
|
||||
// Token: 0x0600010A RID: 266 RVA: 0x00015058 File Offset: 0x00013258
|
||||
public void Smooth()
|
||||
{
|
||||
this.mesh.behavior.Quality = false;
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
this.Step();
|
||||
this.mesh.Triangulate(this.Rebuild());
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600010B RID: 267 RVA: 0x0001509C File Offset: 0x0001329C
|
||||
private void Step()
|
||||
{
|
||||
foreach (VoronoiRegion voronoiRegion in new BoundedVoronoi(this.mesh, false).Regions)
|
||||
{
|
||||
int num = 0;
|
||||
double num3;
|
||||
double num2 = (num3 = 0.0);
|
||||
foreach (Point point in voronoiRegion.Vertices)
|
||||
{
|
||||
num++;
|
||||
num3 += point.x;
|
||||
num2 += point.y;
|
||||
}
|
||||
voronoiRegion.Generator.x = num3 / (double)num;
|
||||
voronoiRegion.Generator.y = num2 / (double)num;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600010C RID: 268 RVA: 0x00015174 File Offset: 0x00013374
|
||||
private InputGeometry Rebuild()
|
||||
{
|
||||
InputGeometry inputGeometry = new InputGeometry(this.mesh.vertices.Count);
|
||||
foreach (Vertex vertex in this.mesh.vertices.Values)
|
||||
{
|
||||
inputGeometry.AddPoint(vertex.x, vertex.y, vertex.mark);
|
||||
}
|
||||
foreach (Segment segment in this.mesh.subsegs.Values)
|
||||
{
|
||||
inputGeometry.AddSegment(segment.P0, segment.P1, segment.Boundary);
|
||||
}
|
||||
foreach (Point point in this.mesh.holes)
|
||||
{
|
||||
inputGeometry.AddHole(point.x, point.y);
|
||||
}
|
||||
foreach (RegionPointer regionPointer in this.mesh.regions)
|
||||
{
|
||||
inputGeometry.AddRegion(regionPointer.point.x, regionPointer.point.y, regionPointer.id);
|
||||
}
|
||||
return inputGeometry;
|
||||
}
|
||||
|
||||
// Token: 0x040000D4 RID: 212
|
||||
private Mesh mesh;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user