コード例 #1
0
 private QuadEdgeSubdivision BuildDelaunay()
 {
     var builder = new DelaunayTriangulationBuilder();
     builder.SetSites(_geom);
     var subDiv = builder.GetSubdivision();
     return subDiv;
 }
コード例 #2
0
 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));
        }
コード例 #4
0
        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));
        }
コード例 #6
0
 /// <summary>
 /// Sets the sites (point or vertices) which will be triangulated.
 /// All vertices of the given geometry will be used as sites.
 /// The site vertices do not have to contain the constraint
 /// vertices as well; any site vertices which are
 /// identical to a constraint vertex will be removed
 /// from the site vertex set.
 /// </summary>
 /// <remarks>The geometry from which the sites will be extracted.</remarks>
 public void SetSites(IGeometry sites)
 {
     _siteCoords = DelaunayTriangulationBuilder.ExtractUniqueCoordinates(sites);
 }
コード例 #7
0
 public static IGeometry DelaunayTriangles(IGeometry geom)
 {
     DelaunayTriangulationBuilder builder = new DelaunayTriangulationBuilder();
     builder.SetSites(geom);
     builder.Tolerance = TriangulationTolerance;
     IGeometryCollection tris = builder.GetTriangles(geom.Factory);
     return tris;
 }
コード例 #8
0
 public static IGeometry DelaunayEdges(IGeometry geom)
 {
     DelaunayTriangulationBuilder builder = new DelaunayTriangulationBuilder();
     builder.SetSites(geom);
     builder.Tolerance = TriangulationTolerance;
     IMultiLineString edges = builder.GetEdges(geom.Factory);
     return edges;
 }
コード例 #9
0
 /// <summary>
 /// Sets the sites (point or vertices) which will be diagrammed
 /// from a collection of <see cref="Coordinate"/>s.
 /// </summary>
 /// <param name="coords">a collection of Coordinates.</param>
 public void SetSites(ICollection <Coordinate> coords)
 {
     // remove any duplicate points (they will cause the triangulation to fail)
     _siteCoords = DelaunayTriangulationBuilder.Unique(CoordinateArrays.ToCoordinateArray(coords));
 }
コード例 #10
0
 /// <summary>
 /// Sets the sites (point or vertices) which will be diagrammed.
 /// All vertices of the given geometry will be used as sites.
 /// </summary>
 /// <param name="geom">geom the geometry from which the sites will be extracted.</param>
 public void SetSites(IGeometry geom)
 {
     // remove any duplicate points (they will cause the triangulation to fail)
     _siteCoords = DelaunayTriangulationBuilder.ExtractUniqueCoordinates(geom);
 }
コード例 #11
0
 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;
 }
コード例 #12
0
        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());
        }