コード例 #1
0
    public void EstimateNormals()
    {
        var pointHashSet = new PointHashSet(2.0f, this.Points);

        this.Normals = new Vector3[this.Points.Length];

        const float neighbourRange = 2.0f;
        const int   neighbourCount = 6;

        for (int i = 0; i < this.Points.Length; i++)
        {
            var point      = this.Points[i];
            var neighbours = pointHashSet.GetPointsInRange(point, neighbourRange, true)
                             .OrderBy(p => (point - p).magnitude)
                             .SkipWhile(p => p == point)
                             .Take(neighbourCount)
                             .ToArray();

            this.Normals[i] = this.getPlaneNormal(neighbours).normalized;

            if (this.Normals[i].y < 0)
            {
                this.Normals[i] = this.Normals[i] * -1.0f;
            }
        }
    }
コード例 #2
0
    private static void fix(string filename, string heightmapFile)
    {
        Console.WriteLine("Reading input file...");
        var points = XYZFile.Read(filename);

        PointcloudTool.createPatches(points, filename);

        Console.WriteLine("Creating heightmap...");
        var pointHashSet = new PointHashSet(1d, points);

        XYZFile.Write(heightmapFile, pointHashSet.GetHeightMap(), pointHashSet.GetHeightMapNormals());

        Console.WriteLine("Complete.");
    }
コード例 #3
0
    private static void fix(string inputFile, string outputFile, string heightmapFile)
    {
        Console.WriteLine("Reading input file... ");

        var points = XYZFile.Read(inputFile);

        Console.WriteLine("Fixing holes... ");
        var holeFixer = new HoleFixer(points);

        var edgePoints = holeFixer.GetEdgePoints().ToArray();
        var patches    = holeFixer.CreatePatches(edgePoints).ToArray();

        points = patches.Concat(points).ToArray();

        Console.WriteLine("Writing output files... ");
        XYZFile.Write(outputFile, points);

        var pointHashSet = new PointHashSet(1d, points);

        XYZFile.Write(heightmapFile, pointHashSet.GetHeightMap(), pointHashSet.GetHeightMapNormals());

        Console.WriteLine("Complete.");
    }
コード例 #4
0
 public HoleFixer(Vector3[] points)
 {
     this.points  = points;
     this.hashSet = new PointHashSet(2.0, points);
 }