public static Geometry DelaunayEdges(Geometry geom) { var builder = new DelaunayTriangulationBuilder(); builder.SetSites(geom); builder.Tolerance = TriangulationTolerance; var edges = builder.GetEdges(geom.Factory); return(edges); }
public static Geometry delaunayEdges(Geometry geom) { var builder = new DelaunayTriangulationBuilder(); builder.SetSites(geom); builder.Tolerance = TRIANGULATION_TOLERANCE; var edges = builder.GetEdges(geom.Factory); return(edges); }
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 void Test1() { var geom = _wktReader.Read("POLYGON ((0 0, 0 10, 4 10, 4 8, 6 8, 6 10, 10 10, 10 0, 0 0))"); var dtb = new DelaunayTriangulationBuilder(); dtb.SetSites(geom); var resultEdges = dtb.GetEdges(geom.Factory); Console.WriteLine(resultEdges.AsText()); var resultTriangles = dtb.GetTriangles(geom.Factory); Console.WriteLine(resultTriangles.AsText()); }
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()); }
TemplateResults selectHallways(TemplateResults formattedRects) { var edges = new List <Edge>(); var coordinates = new List <Coordinate>(); formattedRects.centers.ForEach((p) => { coordinates.Add(new Coordinate(p.min.X, p.min.Y)); }); var triangulator = new DelaunayTriangulationBuilder(); triangulator.SetSites(coordinates.ToArray()); var triangulatedEdges = triangulator.GetEdges(new GeometryFactory(new PrecisionModel(.1))); triangulatedEdges.Geometries.ToList().ForEach((edge) => { var Q = edge.Coordinates[0]; var P = edge.Coordinates[1]; edges.Add(new Edge(new Point((int)Q.X, (int)Q.Y), new Point((int)P.X, (int)P.Y))); }); var edgePoints = new HashSet <Point>(); edges = new Prims().exec(edges); edges.ForEach((edge) => { var p12 = edge.getPoints(); edgePoints.UnionWith(edge.getPoints()); }); var newPaths = new HashSet <Rect>(); var newNonPaths = formattedRects.nonPathIndices; formattedRects.allRects.ForEach((r) => { if (edgePoints.Contains(r.min)) { newPaths.Add(r); } else { newNonPaths.Add(r); } }); formattedRects.nonPathIndices = newNonPaths.ToList(); formattedRects.pathIndices = newPaths.ToList(); return(formattedRects); }
private static void RunDelaunay(string sitesWKT, bool computeTriangles, string expectedWKT) { var reader = new WKTReader(); var sites = reader.Read(sitesWKT); var builder = new DelaunayTriangulationBuilder(); builder.SetSites(sites); var geomFact = GeometryFactory.Default; Geometry result = computeTriangles ? builder.GetTriangles(geomFact) : builder.GetEdges(geomFact); Assert.IsNotNull(result); var expected = reader.Read(expectedWKT); result.Normalize(); expected.Normalize(); Assert.IsTrue(expected.EqualsExact(result, ComparisonTolerance)); }
public static HashSet<Edge> getDelaunayFromPoints (IEnumerable<Vector3> points){ HashSet<Edge> edges = new HashSet<Edge>(); NetTopologySuite.Triangulate.DelaunayTriangulationBuilder builder = new DelaunayTriangulationBuilder(); var coords = new List<Coordinate>(); foreach (Vector3 v in points) coords.Add(new Coordinate((int)v.x,(int)v.y,0)); builder.SetSites(coords); var lines = builder.GetEdges(new GeometryFactory()); foreach (LineString l in lines.Geometries){ edges.Add(new Edge(new Vector3((int)l.Coordinates[0].X,(int)l.Coordinates[0].Y,0),new Vector3((int)l.Coordinates[1].X,(int)l.Coordinates[1].Y,0))); } /*foreach (Vector3 v1 in points){ foreach (Vector3 v2 in points){ if (v1.Equals(v2)) continue; var e = new Edge(v1,v2); edges.Add(e); ; } }*/ return edges; }
public void TestInvertedItalicNTS() { var 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)); var geom = _wktReader.Read(NTS); //Apply italic effect geom = atb.GetTransformation().Transform(geom); Console.WriteLine(geom.AsText()); //Setup var dtb = new DelaunayTriangulationBuilder(); dtb.SetSites(geom); var result = dtb.GetEdges(geom.Factory); Console.WriteLine(result.AsText()); }