Beispiel #1
0
        public static IGeometry GeometricalRepresentation(this Panel panel, RepresentationOptions reprOptions = null)
        {
            if (panel == null)
            {
                BH.Engine.Base.Compute.RecordError("Cannot compute the geometrical representation of a null Structural Panel.");
                return(null);
            }

            reprOptions = reprOptions ?? new RepresentationOptions();

            PlanarSurface centralPlanarSurface = Engine.Geometry.Create.PlanarSurface(
                Engine.Geometry.Compute.IJoin(panel.ExternalEdges.Select(x => x.Curve).ToList()).FirstOrDefault(),
                panel.Openings.SelectMany(x => Engine.Geometry.Compute.IJoin(x.Edges.Select(y => y.Curve).ToList())).Cast <ICurve>().ToList());

            if (!reprOptions.Detailed2DElements) //simple representation
            {
                return(centralPlanarSurface);
            }
            else
            {
                CompositeGeometry compositeGeometry = new CompositeGeometry();

                double thickness     = panel.Property.IAverageThickness();
                Vector translateVect = new Vector()
                {
                    Z = -thickness / 2
                };
                Vector extrudeVect = new Vector()
                {
                    Z = thickness
                };

                Vector upHalf = new Vector()
                {
                    X = 0, Y = 0, Z = thickness / 2
                };
                Vector downHalf = new Vector()
                {
                    X = 0, Y = 0, Z = -thickness / 2
                };

                PlanarSurface topSrf = centralPlanarSurface.ITranslate(upHalf) as PlanarSurface;
                PlanarSurface botSrf = centralPlanarSurface.ITranslate(downHalf) as PlanarSurface;

                IEnumerable <ICurve>    internalEdgesBot        = panel.InternalElementCurves().Select(c => c.ITranslate(translateVect));
                IEnumerable <Extrusion> internalEdgesExtrusions = internalEdgesBot.Select(c => BH.Engine.Geometry.Create.Extrusion(c, extrudeVect));

                IEnumerable <ICurve>    externalEdgesBot        = panel.ExternalEdges.Select(c => c.Curve.ITranslate(translateVect));
                IEnumerable <Extrusion> externalEdgesExtrusions = externalEdgesBot.Select(c => BH.Engine.Geometry.Create.Extrusion(c, extrudeVect));

                compositeGeometry.Elements.Add(topSrf);
                compositeGeometry.Elements.Add(botSrf);
                compositeGeometry.Elements.AddRange(internalEdgesExtrusions);
                compositeGeometry.Elements.AddRange(externalEdgesExtrusions);

                return(compositeGeometry);
            }
        }
Beispiel #2
0
        public static IGeometry Geometry3D(this Panel panel, bool onlyCentralSurface = false)
        {
            if (panel.IsNull())
            {
                return(null);
            }

            PlanarSurface centralPlanarSurface = Engine.Geometry.Create.PlanarSurface(
                Engine.Geometry.Compute.IJoin(panel.ExternalEdges.Select(x => x.Curve).ToList()).FirstOrDefault(),
                panel.Openings.SelectMany(x => Engine.Geometry.Compute.IJoin(x.Edges.Select(y => y.Curve).ToList())).Cast <ICurve>().ToList());

            if (onlyCentralSurface)
            {
                return(centralPlanarSurface);
            }
            else
            {
                CompositeGeometry compositeGeometry = new CompositeGeometry();

                double thickness     = panel.Property.IAverageThickness();
                Vector translateVect = new Vector()
                {
                    Z = -thickness / 2
                };
                Vector extrudeVect = new Vector()
                {
                    Z = thickness
                };

                Vector upHalf = new Vector()
                {
                    X = 0, Y = 0, Z = thickness / 2
                };
                Vector downHalf = new Vector()
                {
                    X = 0, Y = 0, Z = -thickness / 2
                };

                PlanarSurface topSrf = centralPlanarSurface.ITranslate(upHalf) as PlanarSurface;
                PlanarSurface botSrf = centralPlanarSurface.ITranslate(downHalf) as PlanarSurface;

                IEnumerable <ICurve>    internalEdgesBot        = panel.InternalElementCurves().Select(c => c.ITranslate(translateVect));
                IEnumerable <Extrusion> internalEdgesExtrusions = internalEdgesBot.Select(c => BH.Engine.Geometry.Create.Extrusion(c, extrudeVect));

                IEnumerable <ICurve>    externalEdgesBot        = panel.ExternalEdges.Select(c => c.Curve.ITranslate(translateVect));
                IEnumerable <Extrusion> externalEdgesExtrusions = externalEdgesBot.Select(c => BH.Engine.Geometry.Create.Extrusion(c, extrudeVect));

                compositeGeometry.Elements.Add(topSrf);
                compositeGeometry.Elements.Add(botSrf);
                compositeGeometry.Elements.AddRange(internalEdgesExtrusions);
                compositeGeometry.Elements.AddRange(externalEdgesExtrusions);

                return(compositeGeometry);
            }
        }