Exemplo n.º 1
0
        public void AddAreaElement(IAreaElement element)
        {
            this.Version++;

            Debug.Assert(!m_areaElements.Contains(element));
            Debug.Assert(m_areaElements.All(s => (s.Area.IntersectsWith(element.Area)) == false));
            m_areaElements.Add(element);
            element.Register();
        }
Exemplo n.º 2
0
        public void RemoveAreaElement(IAreaElement element)
        {
            this.Version++;

            element.Unregister();
            var ok = m_areaElements.Remove(element);

            Debug.Assert(ok);
        }
Exemplo n.º 3
0
        /***************************************************/
        /**** Private Methods - Fallback                ****/
        /***************************************************/

        private static bool IsNull(this IAreaElement element, string msg = "", [CallerMemberName] string methodName = "Method")
        {
            if (element == null)
            {
                ErrorMessage(methodName, "AreaElement", msg);
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
        public static MaterialComposition MaterialComposition(this IAreaElement areaElement)
        {
            if (areaElement.Property == null || areaElement.Property.Material == null)
            {
                Engine.Reflection.Compute.RecordError("The areaElements MaterialComposition could not be calculated as no Material has been assigned.");
                return(null);
            }
            Material mat = Physical.Create.Material(areaElement.Property.Material);

            return((MaterialComposition)mat);
        }
Exemplo n.º 5
0
        /***************************************************/
        /**** Public Methods - Interfaces               ****/
        /***************************************************/

        public static IEnumerable <ICurve> IEdges(this IAreaElement element)
        {
            if (element is PanelPlanar)
            {
                return(AllEdgeCurves(element as PanelPlanar));
            }
            else
            {
                return(Edges(element as dynamic));
            }
        }
Exemplo n.º 6
0
        public static List <ICurve> Visualize(this GravityLoad gravityLoad, double scaleFactor = 1.0, bool displayForces = true, bool displayMoments = true, bool asResultants = true)
        {
            if (gravityLoad.IsNull())
            {
                return(null);
            }

            List <ICurve> arrows = new List <ICurve>();

            Vector gravityDir   = gravityLoad.GravityDirection * scaleFactor * 9.80665;
            int    barDivisions = 5;

            foreach (BH.oM.Base.BHoMObject obj in gravityLoad.Objects.Elements)
            {
                if (obj is Bar)
                {
                    Bar bar = obj as Bar;

                    if (bar.SectionProperty == null || bar.SectionProperty.Material == null)
                    {
                        Reflection.Compute.RecordWarning("Bar needs a valid sectionproperty and material to display gravity loading");
                        continue;
                    }

                    Vector loadVector = bar.SectionProperty.IMassPerMetre() * gravityDir;

                    List <Point> pts = DistributedPoints(bar, barDivisions);

                    if (displayForces)
                    {
                        arrows.AddRange(ConnectedArrows(new List <ICurve> {
                            bar.Centreline()
                        }, loadVector, true, null, 1, true));
                    }
                }
                else if (obj is IAreaElement)
                {
                    IAreaElement element = obj as IAreaElement;

                    Vector loadVector = element.Property.IMassPerArea() * gravityDir;

                    if (displayForces)
                    {
                        arrows.AddRange(ConnectedArrows(element.IEdges(), loadVector, true));
                    }
                }
                else
                {
                    Reflection.Compute.RecordWarning("Display for gravity loads only implemented for Bars and IAreaElements. No area elements will be displayed");
                }
            }

            return(arrows);
        }
Exemplo n.º 7
0
        public static double SolidVolume(this IAreaElement areaElement)
        {
            if (areaElement.Property == null)
            {
                Engine.Reflection.Compute.RecordError("The IAreaElements Solid Volume could not be calculated as no surface property has been assigned. Returning zero volume.");
                return(0);
            }

            double area      = areaElement.IArea();
            double thickness = areaElement.Property.IAverageThickness();

            return(area * thickness);
        }
Exemplo n.º 8
0
        public static bool IIsNull(this IAreaElement element, string msg = "", [CallerMemberName] string methodName = "Method")
        {
            if (element == null)
            {
                ErrorMessage(methodName, "AreaElement", msg);
                return(true);
            }

            if (element is Panel)
            {
                return(IsNull(element as Panel, msg, methodName));
            }
            else if (element is FEMesh)
            {
                return(IsNull(element as FEMesh, true, true, null, msg, methodName));
            }

            return(false);
        }
        void AddElement(IAreaElement element)
        {
            var shape = new Rectangle();

            if (element is Stockpile)
                shape.Stroke = Brushes.Gray;

            shape.StrokeThickness = 1;
            shape.IsHitTestVisible = false;
            shape.Width = element.Area.Columns * 10;
            shape.Height = element.Area.Rows * 10;

            var r = element.Area;
            Canvas.SetLeft(shape, r.X * 10);
            Canvas.SetTop(shape, r.Y * 10);
            SetElementZ(shape, r.Z);

            m_canvas.Children.Add(shape);
            m_elementMap[element] = shape;
        }
Exemplo n.º 10
0
 public static double IArea(this IAreaElement element)
 {
     return(element.IIsNull() ? 0 : Area(element as dynamic));
 }
 void RemoveElement(IAreaElement element)
 {
     var e = m_elementMap[element];
     m_canvas.Children.Remove(e);
     m_elementMap.Remove(element);
 }
Exemplo n.º 12
0
        /***************************************************/
        /**** Private Methods - fall back               ****/
        /***************************************************/

        private static List <Point> PointGrid(this IAreaElement element)
        {
            Reflection.Compute.RecordWarning("Point grid for element of type " + element.GetType().Name + " not implemented.");
            return(new List <Point>());
        }
Exemplo n.º 13
0
        /***************************************************/
        /**** Private Methods - fall back               ****/
        /***************************************************/

        private static Vector Normal(this IAreaElement areaElement)
        {
            Reflection.Compute.RecordWarning("Cannot get normal for element of type " + areaElement.GetType().Name);
            return(null);
        }
Exemplo n.º 14
0
 public static List <Point> IPointGrid(this IAreaElement element)
 {
     return(element.IIsNull() ? null : PointGrid(element as dynamic));
 }
Exemplo n.º 15
0
        public void AddAreaElement(IAreaElement element)
        {
            this.Version++;

            Debug.Assert(!m_areaElements.Contains(element));
            Debug.Assert(m_areaElements.All(s => (s.Area.IntersectsWith(element.Area)) == false));
            m_areaElements.Add(element);
            element.Register();
        }
Exemplo n.º 16
0
 private static IEnumerable <ICurve> Edges(this IAreaElement element)
 {
     Reflection.Compute.RecordWarning("Can not extract edges for obejcts of type " + element.GetType().FullName);
     return(new List <ICurve>());
 }
Exemplo n.º 17
0
        public void RemoveAreaElement(IAreaElement element)
        {
            this.Version++;

            element.Unregister();
            var ok = m_areaElements.Remove(element);
            Debug.Assert(ok);
        }
Exemplo n.º 18
0
        /***************************************************/
        /**** Public Methods - Interfaces               ****/
        /***************************************************/

        public static double IArea(this IAreaElement element)
        {
            return(Area(element as dynamic));
        }
Exemplo n.º 19
0
 public static Vector INormal(this IAreaElement areaElement)
 {
     return(areaElement.IsNull() ? null : Normal(areaElement as dynamic));
 }
Exemplo n.º 20
0
        /***************************************************/
        /**** Public Methods Interface                  ****/
        /***************************************************/

        public static List <Point> IPointGrid(this IAreaElement element)
        {
            return(PointGrid(element as dynamic));
        }
Exemplo n.º 21
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private static List <List <Point> > ISubElementPointGrids(IAreaElement element)
        {
            return(SubElementPointGrids(element as dynamic));
        }
Exemplo n.º 22
0
 public static IEnumerable <ICurve> IEdges(this IAreaElement element)
 {
     return(element.IIsNull() ? null : Edges(element as dynamic));
 }
Exemplo n.º 23
0
        /***************************************************/

        private static List <Basis> IAllLocalOrientations(IAreaElement element)
        {
            return(AllLocalOrientations(element as dynamic));
        }
Exemplo n.º 24
0
        /***************************************************/
        /**** Public Methods - Interface methods        ****/
        /***************************************************/

        public static Vector INormal(this IAreaElement areaElement)
        {
            return(Normal(areaElement as dynamic));
        }
Exemplo n.º 25
0
        /***************************************************/

        private static List <List <ICurve> > ISubElementBoundaries(IAreaElement element)
        {
            return(SubElementBoundaries(element as dynamic));
        }