Пример #1
0
        /// <summary>
        /// Creates a voronoi mesh inside a polygon.
        /// </summary>
        /// <param name="nodePositions">
        /// Voronoi nodes: Center of each agglomerated cell. Will not be considered if outside of PolygonBoundary.
        /// </param>
        /// <param name="polygonBoundary">
        /// Outer boundary of mesh. Is expected to be closed and must be non-overlapping.
        /// </param>
        /// <param name="noOfLyyodsIter">
        /// Number of smoothing iterations.
        /// </param>
        /// <param name="FirstCellNodeIndice">
        /// Indice of node where the algorithm will start looking for the first Vector of PolygonBoundary.
        /// </param>
        /// <returns></returns>
        public static VoronoiGrid Polygonal(
            MultidimensionalArray nodePositions,
            Vector[] polygonBoundary,
            int noOfLyyodsIter,
            int firstCellNodeIndice)
        {
            //Short hack
            VoronoiNodes nodes = new VoronoiNodes(nodePositions);

            Vector[] boundingBox = BoundingBox(polygonBoundary);

            VoronoiMesher.Settings settings = new VoronoiMesher.Settings
            {
                Boundary = new VoronoiBoundary()
                {
                    BoundingBox = boundingBox,
                    Polygon     = polygonBoundary,
                    EdgeTags    = DefaultEdgeTags(polygonBoundary.Length),
                },
                NumberOfLloydIterations = noOfLyyodsIter,
            };

            VoronoiMesher mesher = new VoronoiMesher(settings);

            return(mesher.CreateGrid(nodes, firstCellNodeIndice));
        }
Пример #2
0
        /// <summary>
        /// Creates a voronoi mesh inside a polygon.
        /// </summary>
        /// <param name="Nodes">
        /// Voronoi nodes: Center of each agglomerated cell. Will not be considered if outside of PolygonBoundary.
        /// </param>
        /// <param name="PolygonBoundary">
        /// Outer boundary of mesh. Is expected to be closed and must be non-overlapping.
        /// </param>
        /// <param name="NoOfLyyodsIter">
        /// Number of smoothing iterations.
        /// </param>
        /// <param name="FirstCellNode_Indice">
        /// Indice of node where the algorithm will start looking for the first Vector of PolygonBoundary.
        /// </param>
        /// <returns></returns>
        public static VoronoiGrid Polygonal(
            MultidimensionalArray nodePositions,
            Vector[] PolygonBoundary,
            int NoOfLyyodsIter,
            int FirstCellNode_Indice)
        {
            //Short hack
            VoronoiNodes nodes = new VoronoiNodes(nodePositions);

            Vector[] boundingBox = BoundingBox(PolygonBoundary);

            VoronoiMesher.Settings settings = new VoronoiMesher.Settings
            {
                GridInfo = new VoronoiInfo
                {
                    BoundingBox = boundingBox,
                    Boundary    = PolygonBoundary
                },
                NumberOfLloydIterations = NoOfLyyodsIter,
                FirstCellNode_indice    = FirstCellNode_Indice
            };

            VoronoiMesher mesher = new VoronoiMesher();

            return(mesher.CreateGrid(nodes, settings));
        }
Пример #3
0
        /// <summary>
        /// Creates a random voronoi mesh inside a polygon.
        /// </summary>
        /// <param name="PolygonBoundary">
        /// Outer boundary of mesh. Is expected to be closed and must be non-overlapping.
        /// </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(
            Vector[] PolygonBoundary,
            int NoOfLyyodsIter,
            int noOfNodeSeed)
        {
            //creates random nodes in bounding box of PolygonBoundary, first node ist first entry of polygon boundary
            Vector[] boundingBox = BoundingBox(PolygonBoundary);
            MultidimensionalArray nodePositions = RandomVoronoiNodesInBoundingBox(boundingBox, noOfNodeSeed);

            nodePositions.SetRowPt(0, PolygonBoundary[0]);
            VoronoiNodes nodes = new VoronoiNodes(nodePositions);

            VoronoiMesher.Settings mesherSettings = new VoronoiMesher.Settings
            {
                GridInfo = new VoronoiInfo
                {
                    BoundingBox = boundingBox,
                    Boundary    = PolygonBoundary
                },
                NumberOfLloydIterations = NoOfLyyodsIter
            };

            VoronoiMesher mesher = new VoronoiMesher();

            return(mesher.CreateGrid(nodes, mesherSettings));
        }
Пример #4
0
 public VoronoiGrid(GridCommons pGrid,
                    int[][] logialToGeometricalCellMap,
                    VoronoiNodes nodes,
                    VoronoiBoundary boundary)
     : base(pGrid, logialToGeometricalCellMap)
 {
     this.nodes    = nodes;
     this.boundary = boundary;
 }
Пример #5
0
        //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);
        }
Пример #6
0
 public VoronoiGrid(IGrid pGrid,
                    int[][] logialToGeometricalCellMap,
                    VoronoiNodes nodes,
                    VoronoiInfo voronoiInfo)
     : base(pGrid, logialToGeometricalCellMap)
 {
     this.nodes = nodes;
     info       = voronoiInfo;
 }
Пример #7
0
        /// <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));
        }
Пример #8
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));
        }
Пример #9
0
        /// <summary>
        /// Creates a random voronoi mesh inside a polygon.
        /// </summary>
        /// <param name="polygonBoundary">
        /// Outer boundary of mesh. Is expected to be closed and must be non-overlapping.
        /// </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(
            Vector[] polygonBoundary,
            int noOfLyyodsIter,
            int noOfNodeSeed)
        {
            Vector[] boundingBox = BoundingBox(polygonBoundary);
            VoronoiMesher.Settings mesherSettings = new VoronoiMesher.Settings
            {
                Boundary = new VoronoiBoundary()
                {
                    BoundingBox = boundingBox,
                    Polygon     = polygonBoundary,
                    EdgeTags    = DefaultEdgeTags(polygonBoundary.Length),
                },
                NumberOfLloydIterations = noOfLyyodsIter
            };

            VoronoiNodes  nodes  = GetVoronoiNodesIn(mesherSettings.Boundary, noOfNodeSeed);
            VoronoiMesher mesher = new VoronoiMesher(mesherSettings);

            return(mesher.CreateGrid(nodes, 0));
        }