Beispiel #1
0
        public static List <Brep> SplitByCurves(Brep brepToSplit, List <Curve> splitters)
        {
            List <Brep> splitBreps = new List <Brep>();

            splitBreps.Add(brepToSplit);

            //RhinoApp.WriteLine("Region being split by {0} curves.", splitters.Count);

            foreach (Curve splitter in splitters)
            {
                List <Brep> splitCache = new List <Brep>();

                //RhinoApp.WriteLine("--About to split {0} regions.", splitBreps.Count);

                for (int i = 0; i < splitBreps.Count; i++)
                {
                    if (Confirm.CurveRegionIntersection(splitter, splitBreps[i]))
                    {
                        List <Brep> splitResult = SplitByCurve(splitBreps[i], splitter);

                        if (splitResult.Count < 2)
                        {
                            splitCache.Add(splitBreps[i]);
                        }
                        else
                        {
                            foreach (Brep result in splitResult)
                            {
                                splitCache.Add(result);
                            }
                        }
                    }
                    else
                    {
                        splitCache.Add(splitBreps[i]);
                    }
                }

                //RhinoApp.WriteLine("--Split into {0} regions.", splitCache.Count);

                if (splitCache.Count != 0)
                {
                    splitBreps.Clear();

                    foreach (Brep brep in splitCache)
                    {
                        splitBreps.Add(brep);
                    }

                    splitCache.Clear();
                }
            }

            return(splitBreps);
        }