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()); }
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); }
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)); }
/// <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); }
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; }
/// <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)); }
/// <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); }
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()); }