Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 4
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));
        }
Esempio n. 5
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));
        }
Esempio n. 6
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));
        }