Пример #1
0
 private QuadEdgeSubdivision BuildDelaunay()
 {
     var builder = new DelaunayTriangulationBuilder();
     builder.SetSites(_geom);
     var subDiv = builder.GetSubdivision();
     return subDiv;
 }
 public void Test1()
 {
     IGeometry geom = _wktReader.Read("POLYGON ((0 0, 0 10, 4 10, 4 8, 6 8, 6 10, 10 10, 10 0, 0 0))");
     DelaunayTriangulationBuilder dtb = new DelaunayTriangulationBuilder();
     dtb.SetSites(geom);
     IMultiLineString resultEdges = dtb.GetEdges(geom.Factory);
     Console.WriteLine(resultEdges.AsText());
     IGeometryCollection resultTriangles = dtb.GetTriangles(geom.Factory);
     Console.WriteLine(resultTriangles.AsText());
 }
Пример #3
0
        private static void RunVoronoi(string sitesWKT, string expectedWKT)
        {
            WKTReader reader = new WKTReader();
            IGeometry sites = reader.Read(sitesWKT);

            DelaunayTriangulationBuilder builder = new DelaunayTriangulationBuilder();
            builder.SetSites(sites);

            QuadEdgeSubdivision subdiv = builder.GetSubdivision();
            IGeometry result = subdiv.GetVoronoiDiagram(GeometryFactory.Default);
            Assert.IsNotNull(result);

            IGeometry expectedEdges = reader.Read(expectedWKT);
            result.Normalize();
            expectedEdges.Normalize();
            Assert.IsTrue(expectedEdges.EqualsExact(result, ComparisonTolerance));
        }
        public void Run(int nPts)
        {
            ICollection<Coordinate> pts = RandomPoints(nPts);
            Console.WriteLine("# pts: " + pts.Count);
            Stopwatch sw = new Stopwatch();
            sw.Start();
            DelaunayTriangulationBuilder builder = new DelaunayTriangulationBuilder();
            builder.SetSites(pts);

            // don't actually form output geometry, to save time and memory
            //var g = builder.GetEdges(GeomFact);
            builder.GetSubdivision();

            Console.WriteLine("  --  Time: " + sw.ElapsedMilliseconds
                              + "  Mem: " + Memory.TotalString);
            //Console.WriteLine(g);
        }
Пример #5
0
        private static void RunDelaunay(string sitesWKT, bool computeTriangles, string expectedWKT)
        {
            WKTReader reader = new WKTReader();
            IGeometry sites = reader.Read(sitesWKT);

            DelaunayTriangulationBuilder builder = new DelaunayTriangulationBuilder();
            builder.SetSites(sites);

            IGeometryFactory geomFact = GeometryFactory.Default;
            IGeometry result = computeTriangles ? builder.GetTriangles(geomFact) : builder.GetEdges(geomFact);
            Assert.IsNotNull(result);

            IGeometry expected = reader.Read(expectedWKT);
            result.Normalize();
            expected.Normalize();
            Assert.IsTrue(expected.EqualsExact(result, ComparisonTolerance));
        }
 public static IGeometry DelaunayTriangles(IGeometry geom)
 {
     DelaunayTriangulationBuilder builder = new DelaunayTriangulationBuilder();
     builder.SetSites(geom);
     builder.Tolerance = TriangulationTolerance;
     IGeometryCollection tris = builder.GetTriangles(geom.Factory);
     return tris;
 }
 public static IGeometry DelaunayEdges(IGeometry geom)
 {
     DelaunayTriangulationBuilder builder = new DelaunayTriangulationBuilder();
     builder.SetSites(geom);
     builder.Tolerance = TriangulationTolerance;
     IMultiLineString edges = builder.GetEdges(geom.Factory);
     return edges;
 }
 public static IGeometry delaunayTriangles(IGeometry geom)
 {
     var builder = new DelaunayTriangulationBuilder();
     builder.SetSites(geom);
     builder.Tolerance = TRIANGULATION_TOLERANCE;
     var tris = builder.GetTriangles(geom.Factory);
     return tris;
 }
        public void TestInvertedItalicNTS()
        {
            AffineTransformationBuilder atb = new AffineTransformationBuilder(
                new Coordinate(0, 0),
                new Coordinate(50, 0),
                new Coordinate(0, 100),
                new Coordinate(0, 0),
                new Coordinate(50, 0),
                new Coordinate(20, 100));

            IGeometry geom = _wktReader.Read(NTS);

            //Apply italic effect
            geom = atb.GetTransformation().Transform(geom);
            Console.WriteLine(geom.AsText());

            //Setup 
            DelaunayTriangulationBuilder dtb = new DelaunayTriangulationBuilder();
            dtb.SetSites(geom);
            IMultiLineString result = dtb.GetEdges(geom.Factory);
            Console.WriteLine(result.AsText());
        }