Esempio n. 1
0
        /******************************************/
        /****            IElement2D            ****/
        /******************************************/

        public static Point Centroid(this IElement2D element2D)
        {
            Point  tmp  = Geometry.Query.Centroid(element2D.IOutlineCurve());
            double area = Geometry.Query.Area(element2D.IOutlineCurve());

            double x = tmp.X * area;
            double y = tmp.Y * area;
            double z = tmp.Z * area;


            List <PolyCurve> openings = Geometry.Compute.BooleanUnion(element2D.IInternalOutlineCurves());

            foreach (ICurve o in openings)
            {
                Point  oTmp  = Geometry.Query.ICentroid(o);
                double oArea = o.IArea();
                x    -= oTmp.X * oArea;
                y    -= oTmp.Y * oArea;
                z    -= oTmp.Z * oArea;
                area -= oArea;
            }

            return(new Point {
                X = x / area, Y = y / area, Z = z / area
            });
        }
Esempio n. 2
0
        /******************************************/
        /****            IElement2D            ****/
        /******************************************/

        public static double Area(this IElement2D element2D)
        {
            //TODO: make this work for PolyCurves (Booleans needed)

            double result = element2D.IOutlineCurve().Area();

            List <Polyline> openings = new List <Polyline>();

            foreach (PolyCurve o in element2D.IInternalOutlineCurves())
            {
                Polyline p = o.ToPolyline();
                if (p == null)
                {
                    throw new NotImplementedException();
                }

                openings.Add(p);
            }

            foreach (Polyline p in openings.BooleanUnion())
            {
                result -= p.Area();
            }

            return(result);
        }
Esempio n. 3
0
        /******************************************/
        /****            IElement2D            ****/
        /******************************************/

        public static double Area(this IElement2D element2D)
        {
            double result = element2D.IOutlineCurve().IArea();

            List <PolyCurve> openings = element2D.IInternalOutlineCurves().BooleanUnion();

            foreach (PolyCurve o in openings)
            {
                result -= o.Area();
            }

            return(result);
        }
Esempio n. 4
0
        /******************************************/
        /****            IElement2D            ****/
        /******************************************/

        public static bool IsSelfIntersecting(this IElement2D element2D, double tolerance = Tolerance.Distance)
        {
            if (Geometry.Query.IIsSelfIntersecting(element2D.IOutlineCurve(), tolerance))
            {
                return(true);
            }

            foreach (PolyCurve internalOutline in element2D.IInternalOutlineCurves())
            {
                if (Geometry.Query.IIsSelfIntersecting(internalOutline, tolerance))
                {
                    return(true);
                }
            }

            return(false);
        }