Пример #1
0
        void SetFirstCellToCellContaining(Vector start)
        {
            //Find cell that contains boundaryLine.Start;
            bool foundFirstCell = false;

            //Check if boundaryLine.Start is still in cell, else search neighborhood
            foreach (MeshCell <T> cell in EnumerateCellsInConcentricCircles())
            {
                Vector[] verts = Array.ConvertAll(cell.Vertices, item => (Vector)item);
                //At this point, every cell is convex!
                bool isInside = PolygonTesselation.PointInConvexPolygon(verts, start);
                if (isInside)
                {
                    foundFirstCell       = true;
                    boundary.FirstCorner = cell;
                    break;
                }
            }
            if (!foundFirstCell)
            {
                throw new Exception("First cell could not be found: boundaryLine.start not inside a cell");
            }
        }
Пример #2
0
        public (MeshCell <T>, IEnumerator <Edge <T> >) GetFirst(Line boundaryLine)
        {
            //Find cell that contains boundaryLine.Start;
            bool foundFirstCell = false;

            if (insideCell == null)
            {
                //SetFirst Cell: any random cell. Influences runtime, though
                insideCell     = Cells[0];
                foundFirstCell = true;
            }

            //Check if boundaryLine.Start is still in cell, else search neighborhood
            foreach (MeshCell <T> cell in CellsOnSameSideOfBoundary_Iterative(insideCell))
            {
                Vector[] verts = Array.ConvertAll(cell.Vertices, item => (Vector)item);
                //At this point, every cell is convex!
                bool isInside = PolygonTesselation.PointInConvexPolygon(verts, (Vector)boundaryLine.start);
                if (isInside)
                {
                    foundFirstCell = true;
                    insideCell     = cell;
                    break;
                }
            }
            if (foundFirstCell)
            {
                AfterCutRidgeEnumerator enumerator = new AfterCutRidgeEnumerator(insideCell.Edges, insideCell.Edges[1]);
                enumerator.Reset();
                return(insideCell, enumerator);
            }
            else
            {
                throw new Exception("First cell could not be found: boundaryLine.start not inside a cell");
            }
        }