예제 #1
0
        /***************************************************/

        public static IGeometry Geometry(this PanelPlanar panel)
        {
            return(Engine.Geometry.Create.PlanarSurface(
                       Engine.Geometry.Modify.IJoin(panel.ExternalEdges.Select(x => x.Curve).ToList()).FirstOrDefault(),
                       panel.Openings.SelectMany(x => Engine.Geometry.Modify.IJoin(x.Edges.Select(y => y.Curve).ToList())).Cast <ICurve>().ToList()
                       ));
        }
예제 #2
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static double Area(this PanelPlanar panel)
        {
            List <PolyCurve> externalEdges = panel.ExternalEdgeCurves().IJoin();
            List <PolyCurve> internalEdges = panel.InternalEdgeCurves().IJoin();

            return(externalEdges.Select(x => x.Area()).Sum() - internalEdges.Select(x => x.Area()).Sum());
        }
예제 #3
0
        /***************************************************/

        public static List <PanelPlanar> PanelPlanar(List <ICurve> outlines, ISurfaceProperty property = null, string name = "")
        {
            List <PanelPlanar>        result       = new List <PanelPlanar>();
            List <List <IElement1D> > outlineEdges = outlines.Select(x => x.ISubParts().Select(y => new Edge {
                Curve = y
            } as IElement1D).ToList()).ToList();

            List <List <List <IElement1D> > > sortedOutlines = outlineEdges.DistributeOutlines();

            foreach (List <List <IElement1D> > panelOutlines in sortedOutlines)
            {
                PanelPlanar panel = new PanelPlanar();
                panel = panel.SetOutlineElements1D(panelOutlines[0]);
                List <Opening> openings = new List <Opening>();
                foreach (List <IElement1D> p in panelOutlines.Skip(1))
                {
                    Opening opening = (new Opening()).SetOutlineElements1D(p);
                    openings.Add(opening);
                }
                panel.Openings = openings;
                panel.Property = property;
                panel.Name     = name;
                result.Add(panel);
            }
            return(result);
        }
예제 #4
0
        /***************************************************/

        public static List <ICurve> AllEdgeCurves(this PanelPlanar panel)
        {
            List <ICurve> result = panel.ExternalEdgeCurves();

            result.AddRange(panel.InternalEdgeCurves());
            return(result);
        }
예제 #5
0
        /***************************************************/

        public static PanelPlanar SetOutlineElements1D(this PanelPlanar panelPlanar, List <IElement1D> outlineElements1D)
        {
            PanelPlanar pp = panelPlanar.GetShallowClone() as PanelPlanar;

            pp.ExternalEdges = new List <Edge>(outlineElements1D.Cast <Edge>());
            return(pp);
        }
예제 #6
0
        /***************************************************/

        public static PanelPlanar SetInternalElements2D(this PanelPlanar panelPlanar, List <IElement2D> internalElements2D)
        {
            PanelPlanar pp = panelPlanar.GetShallowClone() as PanelPlanar;

            pp.Openings = new List <Opening>(internalElements2D.Cast <Opening>().ToList());
            return(pp);
        }
예제 #7
0
        /***************************************************/

        public static List <ICurve> InternalEdgeCurves(this PanelPlanar panel)
        {
            List <ICurve> edges = new List <ICurve>();

            foreach (Opening o in panel.Openings)
            {
                edges.AddRange(o.Edges.Select(e => e.Curve).ToList());
            }
            return(edges);
        }
예제 #8
0
        /******************************************/
        /****      Element control points      ****/
        /******************************************/

        public static List <Point> ControlPoints(this PanelPlanar panel, bool externalOnly = false)
        {
            List <Point> pts = panel.ExternalEdges.ControlPoints();

            if (!externalOnly)
            {
                foreach (Opening o in panel.Openings)
                {
                    pts.AddRange(o.ControlPoints());
                }
            }
            return(pts);
        }
예제 #9
0
        /***************************************************/

        public static List <ICurve> ExternalEdgeCurves(this PanelPlanar panel)
        {
            return(panel.ExternalEdges.Select(x => x.Curve).ToList());
        }
예제 #10
0
        /***************************************************/

        public static List <Point> PointGrid(this PanelPlanar panel)
        {
            List <ICurve> curves = panel.ExternalEdgeCurves();

            List <PolyCurve> joined = curves.IJoin();
            List <PolyCurve> joinedOpeningCurves = panel.InternalEdgeCurves().IJoin();

            Plane plane = joined.First().FitPlane();

            Vector z = Vector.ZAxis;

            double angle = plane.Normal.Angle(z);

            Vector axis = plane.Normal.CrossProduct(z);

            TransformMatrix matrix = Engine.Geometry.Create.RotationMatrix(Point.Origin, axis, angle);

            List <PolyCurve> rotated = curves.Select(x => x.IRotate(Point.Origin, axis, angle)).ToList().IJoin();

            BoundingBox bounds = rotated.First().Bounds();

            for (int i = 1; i < rotated.Count; i++)
            {
                bounds += rotated[i].Bounds();
            }

            double xMin = bounds.Min.X;
            double yMin = bounds.Min.Y;
            double zVal = bounds.Min.Z;

            int steps = 9;

            double xStep = (bounds.Max.X - xMin) / steps;
            double yStep = (bounds.Max.Y - yMin) / steps;

            List <Point>    pts       = new List <Point>();
            TransformMatrix transpose = matrix.Transpose();

            for (int i = 0; i < steps; i++)
            {
                double x = xMin + xStep * i;
                for (int j = 0; j < steps; j++)
                {
                    Point pt = new Point {
                        X = x, Y = yMin + yStep * j, Z = zVal
                    };
                    bool isInside = false;

                    pt = pt.Transform(transpose);

                    foreach (PolyCurve crv in joined)
                    {
                        List <Point> list = new List <Point> {
                            pt
                        };
                        if (crv.IsContaining(list, true, 1E-3))
                        {
                            if (!joinedOpeningCurves.Any(c => c.IsContaining(list, false)))
                            {
                                isInside = true;
                                break;
                            }
                        }
                    }
                    if (isInside)
                    {
                        pts.Add(pt);
                    }
                }
            }

            return(pts);
        }
예제 #11
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static IElement2D NewInternalElement2D(this PanelPlanar panelPlanar)
        {
            return(new Opening());
        }
예제 #12
0
        /***************************************************/

        public static double Mass(this PanelPlanar panel)
        {
            return(panel.Area() * panel.Property.IMassPerArea());
        }
예제 #13
0
        /***************************************************/

        public static List <IElement1D> OutlineElements1D(this PanelPlanar panelPlanar)
        {
            return(new List <IElement1D>(panelPlanar.ExternalEdges));
        }
예제 #14
0
        /***************************************************/

        public static IElement1D NewElement1D(this PanelPlanar panel, ICurve curve)
        {
            return(new Edge {
                Curve = curve.IClone()
            });
        }
예제 #15
0
        /***************************************************/

        public static Vector Normal(this PanelPlanar panel)
        {
            return(panel.AllEdgeCurves().SelectMany(x => x.IControlPoints()).ToList().FitPlane().Normal);
        }
예제 #16
0
        /******************************************/
        /****          Panel outline           ****/
        /******************************************/

        public static PolyCurve Outline(this PanelPlanar panel)
        {
            return(new PolyCurve {
                Curves = panel.ExternalEdgeCurves()
            });
        }
예제 #17
0
        /***************************************************/

        public static List <IElement2D> InternalElements2D(this PanelPlanar panelPlanar)
        {
            return(new List <IElement2D>(panelPlanar.Openings));
        }