public VoronoiGrid(GridCommons pGrid, int[][] logialToGeometricalCellMap, VoronoiNodes nodes, VoronoiBoundary boundary) : base(pGrid, logialToGeometricalCellMap) { this.nodes = nodes; this.boundary = boundary; }
//creates random nodes in bounding box of PolygonBoundary, //first node coincides with first corner of polygon boundary static VoronoiNodes GetVoronoiNodesIn(VoronoiBoundary boundary, int amount) { MultidimensionalArray nodePositions = RandomVoronoiNodesInBoundingBox(boundary.BoundingBox, amount); nodePositions.SetRowPt(0, boundary.Polygon[0] + new Vector(0.01, -0.01)); VoronoiNodes nodes = new VoronoiNodes(nodePositions); return(nodes); }
/// <summary> /// Creates a voronoi mesh inside a polygon. /// </summary> /// <param name="boundary"> /// Specifies polygonal boundary, edgetags, bounding box, ... /// </param> /// <param name="noOfLyyodsIter"> /// Number of smoothing iterations. /// </param> /// <param name="noOfNodeSeed"> /// Number of random nodes that are placed in the bounding box of the PolygonBoundary. /// </param> /// <returns></returns> public static VoronoiGrid Polygonal( VoronoiBoundary boundary, int noOfLyyodsIter, int noOfNodeSeed) { if (boundary.BoundingBox == null) { boundary.BoundingBox = BoundingBox(boundary.Polygon); } VoronoiMesher.Settings mesherSettings = new VoronoiMesher.Settings { Boundary = boundary, NumberOfLloydIterations = noOfLyyodsIter, }; VoronoiNodes nodes = GetVoronoiNodesIn(mesherSettings.Boundary, noOfNodeSeed); VoronoiMesher mesher = new VoronoiMesher(mesherSettings); return(mesher.CreateGrid(nodes, 0)); }
public static VoronoiGrid Polygonal( MultidimensionalArray nodePositions, VoronoiBoundary boundary, int noOfLyyodsIter, int firstCellNodeIndice) { VoronoiNodes nodes = new VoronoiNodes(nodePositions); if (boundary.BoundingBox == null) { boundary.BoundingBox = BoundingBox(boundary.Polygon); } VoronoiMesher.Settings settings = new VoronoiMesher.Settings { Boundary = boundary, NumberOfLloydIterations = noOfLyyodsIter, }; VoronoiMesher mesher = new VoronoiMesher(settings); return(mesher.CreateGrid(nodes, firstCellNodeIndice)); }