Exemplo n.º 1
0
        /***************************************************/
        /**** Public Methods - Curves                   ****/
        /***************************************************/

        public static List <BuildingElement> SplitBuildingElementsByOverlap(this List <BuildingElement> elementsToSplit)
        {
            List <BuildingElement> rtnElements = new List <BuildingElement>();
            List <BuildingElement> oriElements = new List <BuildingElement>(elementsToSplit);

            while (elementsToSplit.Count > 0)
            {
                BuildingElement        currentElement = elementsToSplit[0];
                List <BuildingElement> overlaps       = currentElement.IdentifyOverlaps(elementsToSplit);
                overlaps.AddRange(currentElement.IdentifyOverlaps(rtnElements));

                if (overlaps.Count == 0)
                {
                    rtnElements.Add(currentElement);
                }
                else
                {
                    //Cut the smaller building element out of the bigger one as an opening
                    List <Line> cuttingLines = new List <Line>();
                    foreach (BuildingElement be in overlaps)
                    {
                        cuttingLines.AddRange(be.PanelCurve.ICollapseToPolyline(BH.oM.Geometry.Tolerance.Angle).SubParts());
                    }


                    rtnElements.AddRange(currentElement.Split(cuttingLines));
                }

                elementsToSplit.RemoveAt(0);
            }

            return(rtnElements);
        }
Exemplo n.º 2
0
        public static List <BuildingElement> SplitBuildingElementsByPoints(this List <BuildingElement> elementsToSplit)
        {
            List <BuildingElement> rtnElements = new List <BuildingElement>();
            List <BuildingElement> oriElements = new List <BuildingElement>(elementsToSplit);

            while (elementsToSplit.Count > 0)
            {
                BuildingElement currentElement = elementsToSplit[0];

                bool wasSplit = false;
                List <BuildingElement> elementSplitResult = new List <BuildingElement>();
                for (int x = 0; x < oriElements.Count; x++)
                {
                    if (oriElements[x].BHoM_Guid == currentElement.BHoM_Guid)
                    {
                        continue;                                                       //Don't split by the same element
                    }
                    //Split this element by each other element in the list
                    elementSplitResult = currentElement.Split(oriElements[x]);

                    if (elementSplitResult.Count > 1)
                    {
                        elementsToSplit.AddRange(elementSplitResult);
                        wasSplit = true;
                        break; //Don't attempt to split this element any further, wait to split its new parts later in the loop...
                    }
                }

                elementsToSplit.RemoveAt(0); //Remove the element we have just worked with, regardless of whether we split it or not
                if (!wasSplit)
                {
                    rtnElements.Add(currentElement);            //We have a pure element ready to use
                }
                else
                {
                    //Add the new elements to the list of cutting objects
                    oriElements.RemoveAt(oriElements.IndexOf(oriElements.Where(x => x.BHoM_Guid == currentElement.BHoM_Guid).FirstOrDefault()));
                    oriElements.AddRange(elementSplitResult);
                }
            }

            return(rtnElements);
        }