Exemplo n.º 1
0
    private void Start()
    {
        Instance = this;

        // Get all buildings and add parent them to the content transform
        BuildingCost[] buildingCosts = BuildingCostDict.Instance.Buildings;
        for (int i = 0; i < buildingCosts.Length; i++)
        {
            BuildingElement ele = Instantiate(elementPrefab, content);
            ele.Building = buildingCosts[i];
        }
    }
Exemplo n.º 2
0
        public static bool ExposedToSun(this BuildingElement element)
        {
            if ((element.ElementProperties() as ElementProperties) != null)
            {
                BuildingElementType elementType = (element.ElementProperties() as ElementProperties).BuildingElementType;
                if (elementType == BuildingElementType.Roof || elementType == BuildingElementType.Rooflight || elementType == BuildingElementType.RooflightWithFrame || elementType == BuildingElementType.WallExternal)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 3
0
        public static double MinimumLevel(this BuildingElement bElement)
        {
            List <Point> crvPts = bElement.PanelCurve.IControlPoints();

            double min = 1e10;

            foreach (Point p in crvPts)
            {
                min = Math.Min(min, p.Z);
            }

            return(min);
        }
Exemplo n.º 4
0
        public static double MaximumLevel(this BuildingElement bElement)
        {
            List <Point> crvPts = bElement.PanelCurve.IControlPoints();

            double max = -1e10;

            foreach (Point p in crvPts)
            {
                max = Math.Max(max, p.Z);
            }

            return(max);
        }
Exemplo n.º 5
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static List <BuildingElement> IdentifyOverlaps(this BuildingElement element, List <BuildingElement> elementsToCompare)
        {
            List <BuildingElement> overlappingElements = new List <BuildingElement>();

            foreach (BuildingElement be in elementsToCompare)
            {
                if (element.BHoM_Guid != be.BHoM_Guid && element.DoesBooleanIntersect(be))
                {
                    overlappingElements.Add(be);
                }
            }

            return(overlappingElements);
        }
Exemplo n.º 6
0
        public static BuildingElement MergeBuildingElement(this BuildingElement element1, BuildingElement element2)
        {
            BuildingElement rtnElement = null;

            if (element1.Area() > element2.Area())
            {
                rtnElement = element2.Copy();
            }
            else
            {
                rtnElement = element1.Copy();
            }

            rtnElement.ExtendedProperties.Remove(rtnElement.ContextProperties());

            //Move any properties over which need to be merged between the two elements... Currently only adjacent spaces
            BuildingElementContextProperties masterProperties = new BuildingElementContextProperties();

            BuildingElementContextProperties mergeToProps = (element1.ContextProperties() as BuildingElementContextProperties);

            if (mergeToProps != null)
            {
                masterProperties.Colour          = mergeToProps.Colour;
                masterProperties.ConnectedSpaces = new List <string>(mergeToProps.ConnectedSpaces);
                masterProperties.IsAir           = mergeToProps.IsAir;
                masterProperties.IsGround        = mergeToProps.IsGround;
                masterProperties.Reversed        = mergeToProps.Reversed;
            }

            BuildingElementContextProperties mergeProps = (element2.ContextProperties() as BuildingElementContextProperties);

            if (mergeProps == null)
            {
                mergeProps = new BuildingElementContextProperties(); //Hopefully this will never be needed...
            }
            if (mergeProps.ConnectedSpaces.Count > 0)
            {
                if (masterProperties.ConnectedSpaces.Count == 1)
                {
                    masterProperties.ConnectedSpaces.Add(mergeProps.ConnectedSpaces.Where(x => x != "-1").FirstOrDefault());
                }
                else
                {
                    masterProperties.ConnectedSpaces[masterProperties.ConnectedSpaces.IndexOf("-1")] = mergeProps.ConnectedSpaces.Where(x => x != "-1").FirstOrDefault();
                }
            }

            rtnElement.ExtendedProperties.Add(masterProperties);
            return(rtnElement);
        }
Exemplo n.º 7
0
    public bool GetBuildingElement(int buildID, out BuildingElement portBuildingElement)
    {
        portBuildingElement = null;

        foreach (PortBuildingElement portBuildElement in _portBuildingElementList.Values)
        {
            portBuildingElement = portBuildElement.GetBuildingElement(buildID);
            if (portBuildingElement != null)
            {
                return(true);
            }
        }
        return(true);
    }
Exemplo n.º 8
0
        public static List <BuildingElement> Split(this BuildingElement elementToSplit, List <Line> cuttingLines)
        {
            if (elementToSplit == null || cuttingLines.Count == 0)
            {
                return new List <BuildingElement> {
                           elementToSplit
                }
            }
            ;

            List <BuildingElement> splitElements = new List <BuildingElement> {
                elementToSplit
            };

            foreach (Line l in cuttingLines)
            {
                List <BuildingElement> elementsToSplit = new List <BuildingElement>(splitElements);

                foreach (BuildingElement be in elementsToSplit)
                {
                    Polyline        elementToSplitCrv = be.PanelCurve.ICollapseToPolyline(BH.oM.Geometry.Tolerance.Angle);
                    List <Point>    cuttingPnts       = elementToSplitCrv.LineIntersections(l, true);
                    List <Polyline> cutLines          = elementToSplitCrv.SplitAtPoints(cuttingPnts);
                    if (cutLines.Count == 1)
                    {
                        continue;
                    }

                    splitElements.Remove(be);
                    foreach (Polyline pLine in cutLines)
                    {
                        if (!pLine.IsLinear())
                        {
                            //Only do this for non-straight line cuts
                            List <Point> ctrlPts = pLine.IControlPoints();
                            ctrlPts.Add(ctrlPts[0]); //Close the polyline
                            Polyline completeCrv = BH.Engine.Geometry.Create.Polyline(ctrlPts);

                            BuildingElement cpy = elementToSplit.Copy();
                            cpy.PanelCurve = completeCrv;
                            cpy.CustomData = new Dictionary <string, object>(elementToSplit.CustomData);
                            splitElements.Add(cpy);
                        }
                    }
                }
            }

            return(splitElements);
        }
        public void Set(int row, int column, BuildingModel data)
        {
            Assert.IsNotNull(data);
            BuildingElement element = new BuildingElement();

            element.Row     = row;
            element.Column  = column;
            element.Element = data;
            _buildings.Value.Add(element);

            if (ElementAdded != null)
            {
                ElementAdded(row, column, data);
            }

            _buildings.Save();
        }
Exemplo n.º 10
0
        public static List <Space> AdjacentSpaces(this BuildingElement element, List <List <BuildingElement> > besAsSpace, List <Space> spaces)
        {
            List <Space> rtn = new List <oM.Environment.Elements.Space>();

            List <Point> spaces1 = element.AdjacentSpaces(besAsSpace).SpaceCentres();

            foreach (Point p in spaces1)
            {
                Space add = spaces.MatchSpace(p);
                if (add != null)
                {
                    rtn.Add(add);
                }
            }

            return(rtn);
        }
Exemplo n.º 11
0
        public static List <BuildingElement> AddOpenings(this List <BuildingElement> elements, List <Opening> openings)
        {
            foreach (Opening o in openings)
            {
                Point centre = o.OpeningCurve.ICollapseToPolyline(Tolerance.Angle).Centre();
                if (centre != null)
                {
                    BuildingElement be = elements.ElementsByPoint(centre).First();
                    if (be != null)
                    {
                        be.Openings.Add(o);
                    }
                }
            }

            return(elements);
        }
Exemplo n.º 12
0
        public static List <Line> UnconnectedEdges(this BuildingElement element, List <BuildingElement> space)
        {
            List <Line> edges = element.Edges();

            List <Line> unconnected = new List <Line>();

            List <Line> allEdges = space.Edges();

            foreach (Line l in edges)
            {
                if (allEdges.Where(x => x.BooleanIntersection(l) != null).ToList().Count < 2)
                {
                    unconnected.Add(l);
                }
            }

            return(unconnected);
        }
Exemplo n.º 13
0
        public static List <BuildingElement> UniqueBuildingElements(this List <List <BuildingElement> > elements)
        {
            List <BuildingElement> rtn = new List <BuildingElement>();

            foreach (List <BuildingElement> lst in elements)
            {
                foreach (BuildingElement be in lst)
                {
                    BuildingElement beInList = rtn.Where(x => x.BHoM_Guid == be.BHoM_Guid).FirstOrDefault();
                    if (beInList == null)
                    {
                        rtn.Add(be);
                    }
                }
            }

            return(rtn);
        }
Exemplo n.º 14
0
 public static bool MatchAdjacencies(this BuildingElement element, BuildingElement compare)
 {
     if (element.CustomData.ContainsKey("Revit_spaceId") && compare.CustomData.ContainsKey("Revit_spaceId"))
     {
         if ((element.CustomData.ContainsKey("Revit_adjacentSpaceId") && compare.CustomData.ContainsKey("Revit_adjacentSpaceId")))
         {
             return(element.CustomData["Revit_spaceId"].ToString().Equals(compare.CustomData["Revit_spaceId"].ToString()) &&
                    element.CustomData["Revit_adjacentSpaceId"].ToString().Equals(compare.CustomData["Revit_adjacentSpaceId"].ToString()));
         }
         else
         {
             return(element.CustomData["Revit_spaceId"].ToString().Equals(compare.CustomData["Revit_spaceId"].ToString()));
         }
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 15
0
        /***************************************************/

        public static BuildingElement BuildingElementOpening(this BuildingElement be, List <BHG.ICurve> bounds)
        {
            if (be == null)
            {
                return(be);
            }

            foreach (BHG.ICurve bound in bounds)
            {
                Opening opening = Opening(bound);

                //Assign the properties from the Element to the Opening
                opening.Name = be.Name;

                be.Openings.Add(opening);
            }

            return(be);
        }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static List <BuildingElement> CullOverlaps(this List <BuildingElement> elements)
        {
            List <BuildingElement> ori      = new List <BuildingElement>(elements);
            List <BuildingElement> toReturn = new List <BuildingElement>();

            while (ori.Count > 0)
            {
                BuildingElement        current  = ori[0];
                List <BuildingElement> overlaps = current.IdentifyOverlaps(elements);

                foreach (BuildingElement be in overlaps)
                {
                    ori.Remove(be);
                }

                toReturn.Add(current);
                ori.RemoveAt(0);
            }

            return(toReturn);
        }
Exemplo n.º 18
0
        private void DrawElementAndItsChildren(BuildingElement element, CanvasContext context)
        {
            //rootElement.DrawSelf(graphics, context);
            element.DrawSelf(graphics, context);
            //CanvasContext context = GetCanvasForChildren(rootContext);
            //DrawChildren(rootElement, )
            List <BuildingElement> childElements = element.GetChildren();

            // Are there any children at all?
            if (childElements.Count > 0)
            {
                CanvasContext contextForChildren = element.GetContextForChildren(context);
                LayoutType    layoutForChildren  = element.GetLayoutForChildren();
                double        sizeRecalcRatio    = GetSizeRecalculationRatio(childElements, contextForChildren, layoutForChildren);
                //int childLeft = contextForChildren.Left;
                //int childTop = contextForChildren.Top;
                //int childLeft = GetChildLeftStart(childElements, sizeRecalcRatio, contextForChildren, layoutForChildren);
                //int childTop = GetChildTopStart(childElements, sizeRecalcRatio, contextForChildren, layoutForChildren);
                int childLeft = GetChildLeftStart(contextForChildren, layoutForChildren);
                int childTop  = GetChildTopStart(contextForChildren, layoutForChildren);
                foreach (BuildingElement childElement in childElements)
                {
                    //int childWidth = CalculateWidth(childLeft, childElement.GetRealWidth(), sizeRecalcRatio, contextForChildren, layoutForChildren);
                    //int childHeight = CalculateHeight(childTop, childElement.GetRealHeight(), sizeRecalcRatio, contextForChildren, layoutForChildren);
                    int childWidth  = CalculateWidth(childElement.GetRealWidth(), sizeRecalcRatio, contextForChildren, layoutForChildren);
                    int childHeight = CalculateHeight(childElement.GetRealHeight(), sizeRecalcRatio, contextForChildren, layoutForChildren);
                    // ***
                    childLeft -= GetWidthDecrement(childWidth, layoutForChildren);
                    childTop  -= GetHeightDecrement(childHeight, layoutForChildren);
                    // ***
                    CanvasContext childContext = GenerateChildContext(childLeft, childTop, childWidth, childHeight);
                    DrawElementAndItsChildren(childElement, childContext);
                    //childLeft += childWidth;
                    //childTop += childHeight;
                    childLeft += GetWidthIncrement(childWidth, layoutForChildren);
                    childTop  += GetHeightIncrement(childHeight, layoutForChildren);
                }
            }
        }
Exemplo n.º 19
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static double UValue(this BuildingElement element)
        {
            if (element == null)
            {
                return(0);
            }
            if (element.ElementProperties() == null)
            {
                return(-1);
            }
            if ((element.ElementProperties() as ElementProperties) == null)
            {
                return(-1);
            }

            ElementProperties props = element.ElementProperties() as ElementProperties;

            if (props.Construction.UValues.Count == 0)
            {
                return(-1);
            }

            if (props.Construction.UValues.Count == 1)
            {
                return(props.Construction.UValues[0]);
            }

            switch (props.BuildingElementType)
            {
            case BuildingElementType.Ceiling:
                if (props.Construction.UValues.Count < 5)
                {
                    return(-1);
                }
                return(props.Construction.UValues[4]);

            case BuildingElementType.CurtainWall:
                if (props.Construction.UValues.Count < 7)
                {
                    return(-1);
                }
                return(props.Construction.UValues[6]);

            case BuildingElementType.Door:
                if (props.Construction.UValues.Count < 1)
                {
                    return(-1);
                }
                return(props.Construction.UValues[0]);

            case BuildingElementType.Floor:
                if (props.Construction.UValues.Count < 6)
                {
                    return(-1);
                }
                return(props.Construction.UValues[5]);    //Exposed floor would be 2...

            case BuildingElementType.Roof:
                if (props.Construction.UValues.Count < 2)
                {
                    return(-1);
                }
                return(props.Construction.UValues[1]);

            case BuildingElementType.Rooflight:
                if (props.Construction.UValues.Count < 7)
                {
                    return(-1);
                }
                return(props.Construction.UValues[6]);

            case BuildingElementType.Wall:
                if (props.Construction.UValues.Count < 4)
                {
                    return(-1);
                }
                return(props.Construction.UValues[3]);

            case BuildingElementType.Window:
                if (props.Construction.UValues.Count < 1)
                {
                    return(-1);
                }
                return(props.Construction.UValues[0]);    //Not sure if correct...

            case BuildingElementType.RooflightWithFrame:
                if (props.Construction.UValues.Count < 7)
                {
                    return(-1);
                }
                return(props.Construction.UValues[6]);

            case BuildingElementType.WindowWithFrame:
                if (props.Construction.UValues.Count < 1)
                {
                    return(-1);
                }
                return(props.Construction.UValues[0]);    //Not sure if correct...

            default:
                return(-1);
            }
        }
Exemplo n.º 20
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static List <Line> Edges(this BuildingElement element)
        {
            return(element.PanelCurve.ISubParts() as List <Line>);
        }
Exemplo n.º 21
0
        public static List <BuildingElement> SplitBuildingElements(this List <BuildingElement> elementsToSplit)
        {
            //Go through all building elements and compare to see if any should be split into smaller building elements
            List <BuildingElement> rtn = new List <BuildingElement>();

            Dictionary <BuildingElement, List <BuildingElement> > overlaps = new Dictionary <BuildingElement, List <BuildingElement> >();

            foreach (BuildingElement be in elementsToSplit)
            {
                overlaps.Add(be, be.IdentifyOverlaps(elementsToSplit));
            }

            foreach (KeyValuePair <BuildingElement, List <BuildingElement> > kvp in overlaps)
            {
                Dictionary <BuildingElement, List <BuildingElement> > rtn2            = new Dictionary <BuildingElement, List <BuildingElement> >();
                Dictionary <BuildingElement, List <Polyline> >        replacementGeom = new Dictionary <BuildingElement, List <Polyline> >();
                Polyline be1P = kvp.Key.PanelCurve.ICollapseToPolyline(Tolerance.Angle);

                foreach (BuildingElement be2 in kvp.Value)
                {
                    Polyline be2p = be2.PanelCurve.ICollapseToPolyline(Tolerance.Angle);

                    Dictionary <BuildingElement, List <Polyline> > geomBuild = new Dictionary <BuildingElement, List <Polyline> >();
                    geomBuild.Add(kvp.Key, new List <Polyline>());
                    geomBuild.Add(be2, new List <Polyline>());

                    List <Polyline> intersections = be1P.BooleanIntersection(be2p);
                    foreach (Polyline p in intersections)
                    {
                        geomBuild[kvp.Key].AddRange(be1P.SplitAtPoints(p.ControlPoints));
                        geomBuild[be2].AddRange(be2p.SplitAtPoints(p.ControlPoints));
                    }

                    foreach (KeyValuePair <BuildingElement, List <Polyline> > kvp2 in geomBuild)
                    {
                        List <Polyline> remove = new List <Polyline>();
                        foreach (Polyline p5 in kvp2.Value)
                        {
                            bool isNotIn = true;
                            foreach (Point px in p5.ControlPoints)
                            {
                                foreach (Polyline p6 in intersections)
                                {
                                    if (p6.ControlPoints.Contains(px))
                                    {
                                        isNotIn = false;
                                    }

                                    if (!isNotIn)
                                    {
                                        break;
                                    }
                                }
                                if (!isNotIn)
                                {
                                    break;
                                }
                            }

                            if (!isNotIn)
                            {
                                remove.Add(p5);
                            }
                        }

                        foreach (Polyline l5 in remove)
                        {
                            kvp2.Value.Remove(l5);
                        }
                    }

                    foreach (KeyValuePair <BuildingElement, List <Polyline> > kvp3 in geomBuild)
                    {
                        foreach (Polyline p5 in kvp3.Value)
                        {
                            while (p5.ControlPoints.Last().Distance(p5.ControlPoints.First()) > 0.01)
                            {
                                bool addedPoint = false;
                                foreach (Point px in intersections[0].ControlPoints)
                                {
                                    if (!p5.ControlPoints.Contains(px) && !kvp3.Key.PanelCurve.ICollapseToPolyline(1e-06).ControlPoints.Contains(px) && px.Match2Of3(p5.ControlPoints.Last()))
                                    {
                                        p5.ControlPoints.Add(px);
                                        addedPoint = true;
                                    }
                                }
                                if (!addedPoint)
                                {
                                    p5.ControlPoints.Add(p5.ControlPoints[0]);
                                }
                            }
                        }
                    }

                    foreach (KeyValuePair <BuildingElement, List <Polyline> > kvp4 in geomBuild)
                    {
                        if (!replacementGeom.ContainsKey(kvp4.Key))
                        {
                            replacementGeom.Add(kvp4.Key, new List <Polyline>());
                        }
                        replacementGeom[kvp4.Key].AddRange(kvp4.Value);
                    }
                }

                //Make the new BE from the new polylines
                if (replacementGeom.Count == 0)
                {
                    rtn2.Add(kvp.Key, new List <BuildingElement>());
                }
                foreach (KeyValuePair <BuildingElement, List <Polyline> > kvp6 in replacementGeom)
                {
                    BuildingElement ori = kvp6.Key;
                    if (kvp6.Value.Count > 1)
                    {
                        //Only do this if we have more than 1 BE to replace
                        foreach (Polyline p in kvp6.Value)
                        {
                            BuildingElement newBE = ori.GetShallowClone() as BuildingElement;
                            if (newBE.PanelCurve == null)
                            {
                                newBE.PanelCurve = ori.PanelCurve;
                            }

                            newBE.PanelCurve = p;

                            if (!rtn2.ContainsKey(ori))
                            {
                                rtn2.Add(ori, new List <BuildingElement>());
                            }
                            rtn2[ori].Add(newBE);
                        }
                    }
                    else if (kvp6.Value.Count == 0)
                    {
                        //This BE was cut in such a way that it ended up with no polygon - slightly problematic but basically the entire polygon was the intersection with the other BE - so add the old BE back
                        if (!rtn2.ContainsKey(ori))
                        {
                            rtn2.Add(ori, new List <BuildingElement>());
                        }
                        rtn2[ori].Add(ori);
                    }
                    else if (kvp6.Value.Count == 1)
                    {
                        rtn2.Add(ori, new List <BuildingElement>());
                    }
                }

                //Update the building elements
                if (rtn2[kvp.Key].Count == 0)
                {
                    rtn.Add(kvp.Key); //Not split at all
                }
                else
                {
                    rtn.AddRange(rtn2[kvp.Key]);
                }
            }


            /*for(int x = 0; x < elementsToSplit.Count; x++)
             * {
             *  List<BuildingElement> overlappingElements = elementsToSplit[x].IdentifyOverlaps(elementsToSplit);
             *  if (overlappingElements.Count == 0) rtn.Add(elementsToSplit[x]);
             *  else
             *  {
             *      //This element overlaps with some elements in the list - split them up into new elements
             *      foreach(BuildingElement be in overlappingElements)
             *      {
             *          //Split the original element by this BE
             *          Polyline original = elementsToSplit[x].PanelCurve.ICollapseToPolyline(Tolerance.Angle);
             *          Polyline cutting = be.PanelCurve.ICollapseToPolyline(Tolerance.Angle);
             *
             *          List<Polyline> intersections = original.BooleanIntersection(cutting);
             *          foreach(Polyline p in intersections)
             *          {
             *              List<Polyline> splits = original.SplitAtPoints(p.ControlPoints);
             *              List<Point> points = new List<Point>();
             *              foreach (Polyline p2 in splits)
             *                  points.AddRange(p2.ControlPoints);
             *
             *              original = BH.Engine.Geometry.Create.Polyline(points);
             *          }
             *
             *          elementsToSplit[x].PanelCurve = original; //Reset the cut geometry to the BE ready for the next overlap
             *      }
             *  }
             *
             *  rtn.Add(elementsToSplit[x]);
             * }*/

            return(rtn);
        }
Exemplo n.º 22
0
 public static BuildingElement AddAdjacentSpace(this BuildingElement element, string spaceName)
 {
     return(AddAdjacentSpace(new List <BuildingElement> {
         element
     }, spaceName)[0]);
 }
Exemplo n.º 23
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static Panel AnalyticalPanel(this BuildingElement bElement)
        {
            return(Create.Panel(bElement.PanelCurve, bElement.Openings));
        }
Exemplo n.º 24
0
 public static double Width(this BuildingElement element)
 {
     return(element.PanelCurve.Width());
 }
Exemplo n.º 25
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static List <Point> Vertices(this BuildingElement element)
        {
            return(element.PanelCurve.IControlPoints());
        }
Exemplo n.º 26
0
 private static IBHoMExtendedProperties AnalyticalProperties(this BuildingElement element)
 {
     return(element.PropertiesByType(typeof(BuildingElementAnalyticalProperties)));
 }
Exemplo n.º 27
0
 private static IBHoMExtendedProperties ResultProperties(this BuildingElement element)
 {
     return(null); //Building Elements do not currently have result properties
 }
Exemplo n.º 28
0
    // private bool LoadPortBuildingElement(SecurityElement element, out PortBuildingElement portBuildingElement)
    // {
    //  portBuildingElement = new PortBuildingElement();
    //
    //  string attribute = element.Attribute("Port_ID");
    //  if (attribute != null)
    //      portBuildingElement._portID = StrParser.ParseDecInt(attribute, -1);
    //
    //  if (element.Children == null)
    //      return false;
    //
    //  foreach(SecurityElement childrenElement in element.Children)
    //  {
    //      if (childrenElement.Tag == "Building")
    //      {
    //          BuildingElement buildingElement;
    //          if (!LoadBuildingElement(childrenElement, out buildingElement))
    //              continue;
    //
    //          buildingElement._portID = portBuildingElement._portID;
    //
    //          // An leixing tianchong
    //          int type = buildingElement._buildingType;
    //          bool has = portBuildingElement._buildingListByKind.ContainsKey(type);
    //          if (has)
    //          {
    //              List<BuildingElement> list = portBuildingElement._buildingListByKind[type];
    //              list.Add(buildingElement);
    //          }
    //          else
    //          {
    //              List<BuildingElement> list = new List<BuildingElement>();
    //              list.Add(buildingElement);
    //              portBuildingElement._buildingListByKind.Add(type, list);
    //          }
    //
    //          portBuildingElement._buildingElementList.Add(buildingElement);
    //      }
    //      else
    //          continue;
    //  }
    //
    //  return true;
    // }

    private bool LoadBuildingElement(SecurityElement element, out BuildingElement buildingElement)
    {
        buildingElement = new BuildingElement();

        string attribute = element.Attribute("Port_ID");

        if (attribute != null)
        {
            buildingElement._portID = StrParser.ParseDecInt(attribute, -1);
        }

        attribute = element.Attribute("Build_ID");
        if (attribute != null)
        {
            buildingElement._buildingID = StrParser.ParseDecInt(attribute, -1);
        }

        attribute = element.Attribute("Build_Type");
        if (attribute != null)
        {
            buildingElement._buildingType = StrParser.ParseDecInt(attribute, -1);
        }

        attribute = element.Attribute("Build_Name");
        if (attribute != null)
        {
            buildingElement._buildingNameID = StrParser.ParseDecInt(attribute, -1);
        }

        attribute = element.Attribute("Build_NPC_Icon");
        if (attribute != null)
        {
            buildingElement._buildingNpcIcon = StrParser.ParseStr(attribute, "");
        }

        attribute = element.Attribute("Build_Icon");
        if (attribute != null)
        {
            buildingElement._buildIcon = StrParser.ParseStr(attribute, "");
        }

        attribute = element.Attribute("Build_NPC_Name");
        if (attribute != null)
        {
            buildingElement._buildingNpcNameID = StrParser.ParseDecInt(attribute, -1);
        }

        attribute = element.Attribute("Flourish_Require");
        if (attribute != null)
        {
            buildingElement._flourishRequire = StrParser.ParseDecInt(attribute, -1);
        }

        attribute = element.Attribute("Defense_Require");
        if (attribute != null)
        {
            buildingElement._defenseRequire = StrParser.ParseDecInt(attribute, -1);
        }

        attribute = element.Attribute("Build_Location");
        if (attribute != null)
        {
            buildingElement._buildingPostion = attribute;
        }

        attribute = element.Attribute("Build_Faceto");
        if (attribute != null)
        {
            buildingElement._buildingOrientation = attribute;
        }

        attribute = element.Attribute("Build_Model");
        if (attribute != null)
        {
            buildingElement._buildingModelName = StrParser.ParseStr(attribute, "");
        }

        attribute = element.Attribute("Build_Texture");
        if (attribute != null)
        {
            buildingElement._buildingTextureName = StrParser.ParseStr(attribute, "");
        }

        attribute = element.Attribute("Build_Particle");
        if (attribute != null)
        {
            buildingElement._buildingParticleName = StrParser.ParseStr(attribute, "");
        }

        attribute = element.Attribute("Function_ID");
        if (attribute != null)
        {
            buildingElement._functionID = StrParser.ParseDecInt(attribute, -1);
        }

        attribute = element.Attribute("Buff_ID");
        if (attribute != null)
        {
            buildingElement._buffID = StrParser.ParseDecInt(attribute, -1);
        }

        attribute = element.Attribute("Camp");
        if (attribute != null)
        {
            buildingElement._campID = StrParser.ParseDecInt(attribute, -1);
        }

        attribute = element.Attribute("Build_Picture");
        if (attribute != null)
        {
            buildingElement._buildBG = StrParser.ParseStr(attribute, "");
        }
        _BuildingMapList.Add(buildingElement._buildingID, buildingElement._portID);

        return(true);
    }
Exemplo n.º 29
0
 private static IBHoMExtendedProperties ContextProperties(this BuildingElement element)
 {
     return(element.PropertiesByType(typeof(BuildingElementContextProperties)));
 }
Exemplo n.º 30
0
 public DrawEngine(BuildingElement rootElement, Graphics graphics, CanvasContext rootContext)
 {
     this.rootElement = rootElement;
     this.graphics    = graphics;
     this.rootContext = rootContext;
 }