Beispiel #1
0
        public void TestSimpleTriangulation()
        {
            var a = new Point3D(2, 0, 2);
            var b = new Point3D(12, 0, 3);
            var c = new Point3D(10, 10, 1);
            var d = new Point3D(2, 20, 4);
            var e = new Point3D(12, 20, 5);

            var points = new [] { a, b, c, d, e };

            SourceSurface surface = new SourceSurface(points);

            DefaultTriangulation triangulation = new DefaultTriangulation();

            var result = triangulation.GetTriangulatedSurface(surface, triangulation.GetDefaultOptions());

            Triangle3D[] triangles = new [] { new Triangle3D(a, b, c), new Triangle3D(d, e, c), new Triangle3D(a, d, c), new Triangle3D(b, e, c) };

            Assert.AreEqual(triangles.Length, result.Triangles.Length);

            foreach (var triangle in triangles)
            {
                Assert.True(result.Triangles.Any(t => t.AreEqual(triangle)));
            }
        }
Beispiel #2
0
        public void TestRealTriangulation()
        {
            CsvDataSource csvDataSource = new CsvDataSource();
            CsvOptions    options       = (CsvOptions)csvDataSource.GetDefaultOptions();

            options.FileName  = Path.Combine(TestDir, "depthvalues.csv");
            options.GridStep  = "200 ft";
            options.Separator = " ";

            SourceSurface surface = csvDataSource.GetSurface(options);

            DefaultTriangulation triangulation = new DefaultTriangulation();

            var result = triangulation.GetTriangulatedSurface(surface, triangulation.GetDefaultOptions());

            Assert.AreEqual(15 * 25 * 2, result.Triangles.Length); // 16 x 26 points transformed to 15 x 25 rectangles, each is splitted into 2 triangles.
        }
Beispiel #3
0
        public void TestFailedTriangulation()
        {
            var a = new Point3D(2, 0, 2);
            var b = new Point3D(3, 1, 3);
            var c = new Point3D(4, 2, 1);
            var d = new Point3D(5, 3, 4);
            var e = new Point3D(6, 4, 5);

            var points = new [] { a, b, c, d, e };

            SourceSurface surface = new SourceSurface(points);

            DefaultTriangulation triangulation = new DefaultTriangulation();

            var result = triangulation.GetTriangulatedSurface(surface, triangulation.GetDefaultOptions());

            Assert.AreEqual(0, result.Triangles.Length);
        }
Beispiel #4
0
        public void TestRealVolumeDiff()
        {
            CsvDataSource csvDataSource = new CsvDataSource();
            CsvOptions    csvOptions    = (CsvOptions)csvDataSource.GetDefaultOptions();

            csvOptions.FileName  = Path.Combine(TestDir, "depthvalues.csv");
            csvOptions.GridStep  = "200 m";
            csvOptions.Separator = " ";

            DefaultTriangulation triangulation = new DefaultTriangulation();

            SourceSurface surfaceTop             = csvDataSource.GetSurface(csvOptions);
            var           triangulatedSurfaceTop = triangulation.GetTriangulatedSurface(surfaceTop, triangulation.GetDefaultOptions());

            SourceSurfaceMover mover = new SourceSurfaceMover();
            var moverOptions         = (SourceSurfaceMoverOptions)mover.GetDefaultOptions();

            moverOptions.Z = "100 m";
            SourceSurface surfaceBottom             = mover.GetModifiedSurface(surfaceTop, moverOptions);
            var           triangulatedSurfaceBottom = triangulation.GetTriangulatedSurface(surfaceBottom, triangulation.GetDefaultOptions());

            IVolumeService service = new VolumeService();

            var topVolume    = service.GetVolumeUnderSurface(triangulatedSurfaceTop, 10000);
            var bottomVolume = service.GetVolumeUnderSurface(triangulatedSurfaceBottom, 10000);

            var diff = (int)(topVolume - bottomVolume);

            Assert.AreEqual(200 * 200 * 100 * 15 * 25, diff);
        }