Exemplo n.º 1
0
        internal static Box GetBox(GH_TwistedBox tb)
        {
            var plane = new Plane(tb.Corner(0), tb.Corner(1), tb.Corner(3));
            var bbox  = tb.GetBoundingBox(Transform.ChangeBasis(Plane.WorldXY, plane));

            return(new Box(plane, bbox));
        }
Exemplo n.º 2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_TwistedBox tb   = null;
            Interval      uDom = Interval.Unset;
            Interval      vDom = Interval.Unset;
            Interval      wDom = Interval.Unset;

            try
            {
                if (!DA.GetData("Box", ref tb))
                {
                    return;
                }
            }
            catch // this is maybe not necessary? IDK LOL
            {
                object tboxObj = null;
                DA.GetData("Box", ref tboxObj);
            }
            if (!DA.GetData("U Domain", ref uDom))
            {
                return;
            }
            if (!DA.GetData("V Domain", ref vDom))
            {
                return;
            }
            if (!DA.GetData("W Domain", ref wDom))
            {
                return;
            }

            if (tb == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "one or more boxes was null");
                return;
            }

            var paramSpaceCorners = GetParamSpaceCorners(uDom, vDom, wDom);

            var corners = paramSpaceCorners.Select(p => tb.PointAt(p.X, p.Y, p.Z));

            var resultBox = new GH_TwistedBox(corners);

            Box asBox;

            if (IsBox(resultBox, out asBox, Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance))
            {
                DA.SetData("Sub-Box", asBox);
            }
            else
            {
                DA.SetData("Sub-Box", resultBox);
            }
        }
Exemplo n.º 3
0
        internal static bool IsBox(GH_TwistedBox tb, out Box asBox, double tolerance)
        {
            asBox = GetBox(tb);
            var boxCorners = asBox.GetCorners();

            for (int i = 0; i < 8; i++)
            {
                if (tb.Corner(i).DistanceTo(boxCorners[i]) > tolerance)
                {
                    return(false);
                }
            }
            return(true);
        }