Exemple #1
0
        public static string PrintPtsInsideBox(this Solid solid, BoundingBoxXYZ bb)
        {
            string o = "";

            o += "Bounding Box Coordinates" + "\n";
            o += bb.Min.ToString() + " " + bb.BoundingBoxContains(bb.Min).ToString() + "\n";
            o += bb.Max.ToString() + " " + bb.BoundingBoxContains(bb.Max).ToString() + "\n";
            o += "------------------------------\n\n";
            o += "Points For Each Edge Of Solid" + "\n";

            foreach (var e in solid.Edges)
            {
                var e1 = (e as Edge).AsCurve().GetEndPoint(0);
                var e2 = (e as Edge).AsCurve().GetEndPoint(1);
                o +=
                    e1.ToString() + " " + bb.BoundingBoxContains(e1).ToString() + "\n" +
                    e2.ToString() + " " + bb.BoundingBoxContains(e2).ToString() + "\n" +
                    "------------------------------\n";
            }

            return(o);
        }
Exemple #2
0
        public static bool IsPtInsideSolid(this Solid solid, XYZ pt)
        {
            var ep1s = solid.Edges.Cast <Edge>().Select(x => x.AsCurve().GetEndPoint(0));
            var ep2s = solid.Edges.Cast <Edge>().Select(x => x.AsCurve().GetEndPoint(1));
            var eps  = ep1s.Concat(ep2s);

            var min_x = eps.MinBy(x => x.X).First().X;
            var min_y = eps.MinBy(x => x.Y).First().Y;
            var min_z = eps.MinBy(x => x.Z).First().Z;

            var max_x = eps.MaxBy(x => x.X).First().X;
            var max_y = eps.MaxBy(x => x.Y).First().Y;
            var max_z = eps.MaxBy(x => x.Z).First().Z;

            var min_pt = new XYZ(min_x, min_y, min_z);
            var max_pt = new XYZ(max_x, max_y, max_z);

            BoundingBoxXYZ bb = new BoundingBoxXYZ();

            bb.Min = min_pt;
            bb.Max = max_pt;

            return(bb.BoundingBoxContains(pt));
        }