public void Add(Rhino.Geometry.Box box, RenderMaterial material)
 {
     UnsafeNativeMethods.Rdk_CustomMeshes_AddBox(NonConstPointer(),
                                                 box.Plane.Origin,
                                                 box.Plane.XAxis,
                                                 box.Plane.YAxis,
                                                 box.X.Min, box.X.Max,
                                                 box.Y.Min, box.Y.Max,
                                                 box.Z.Min, box.Z.Max,
                                                 material.ConstPointer());
 }
        public static Rhino.Geometry.Brep ToRhino(Wall wall)
        {
            // i know the coordinates are not right, but it's work in progress and i'm past caring.
            var vector = new Rhino.Geometry.Vector3d(wall.BaseLine.EndPoint.X, wall.BaseLine.EndPoint.Y, wall.BaseLine.EndPoint.Z);
            var origin = new Rhino.Geometry.Point3d(wall.BaseLine.StartPoint.X, wall.BaseLine.StartPoint.Y, wall.BaseLine.StartPoint.Z);
            var plane  = new Rhino.Geometry.Plane(origin, vector);

            Rhino.Geometry.Interval xInterval = new Rhino.Geometry.Interval(-wall.Length / 2, wall.Length / 2);
            Rhino.Geometry.Interval yInterval = new Rhino.Geometry.Interval(-wall.Thickness / 2, wall.Thickness / 2);
            Rhino.Geometry.Interval zInterval = new Rhino.Geometry.Interval(0, wall.Height);

            Rhino.Geometry.Box box = new Rhino.Geometry.Box(plane, xInterval, yInterval, zInterval);
            var brep = box.ToBrep();

            brep.Rotate(Math.PI / 2, vector, origin);

            return(brep);
        }
        public bool Box(int index, ref Rhino.Geometry.Box box)
        {
            Rhino.Geometry.Point3d  origin = new Rhino.Geometry.Point3d();
            Rhino.Geometry.Vector3d xaxis = new Rhino.Geometry.Vector3d();
            Rhino.Geometry.Vector3d yaxis = new Rhino.Geometry.Vector3d();
            double minX = 0.0, maxX = 0.0;
            double minY = 0.0, maxY = 0.0;
            double minZ = 0.0, maxZ = 0.0;

            if (UnsafeNativeMethods.Rdk_CustomMeshes_Box(ConstPointer(), index, ref origin, ref xaxis, ref yaxis, ref minX, ref maxX, ref minY, ref maxY, ref minZ, ref maxZ))
            {
                box = new Rhino.Geometry.Box(new Rhino.Geometry.Plane(origin, xaxis, yaxis),
                                             new Rhino.Geometry.Interval(minX, maxX),
                                             new Rhino.Geometry.Interval(minY, maxY),
                                             new Rhino.Geometry.Interval(minZ, maxZ));
                return(true);
            }
            return(false);
        }
예제 #4
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var points = new List <Rhino.Geometry.Point3d>();

            if (!DA.GetDataList("Points", points))
            {
                return;
            }

            var tolerance = 0.0;

            if (!DA.GetData("Tolerance", ref tolerance))
            {
                return;
            }

            var boundingBox = true;

            if (!DA.GetData("BoundingBox", ref boundingBox))
            {
                return;
            }

            var strict = true;

            if (!DA.GetData("Strict", ref strict))
            {
                return;
            }

            var inverted = false;

            if (!DA.GetData("Inverted", ref inverted))
            {
                return;
            }

            var scaleFactor = 1.0 / Revit.ModelUnits;

            var targets = new List <Rhino.Geometry.Box>();

            Autodesk.Revit.DB.ElementFilter filter = null;

            if (boundingBox)
            {
                var pointsBBox = new Rhino.Geometry.BoundingBox(points);
                {
                    var box = new Rhino.Geometry.Box(pointsBBox);
                    box.Inflate(tolerance);
                    targets.Add(box);
                }

                pointsBBox = pointsBBox.ChangeUnits(scaleFactor);
                var outline = new Autodesk.Revit.DB.Outline(pointsBBox.Min.ToHost(), pointsBBox.Max.ToHost());

                if (strict)
                {
                    filter = new Autodesk.Revit.DB.BoundingBoxIsInsideFilter(outline, tolerance * scaleFactor, inverted);
                }
                else
                {
                    filter = new Autodesk.Revit.DB.BoundingBoxIntersectsFilter(outline, tolerance * scaleFactor, inverted);
                }
            }
            else
            {
                var filters = points.Select <Rhino.Geometry.Point3d, Autodesk.Revit.DB.ElementFilter>
                                  (x =>
                {
                    var pointsBBox = new Rhino.Geometry.BoundingBox(x, x);
                    {
                        var box = new Rhino.Geometry.Box(pointsBBox);
                        box.Inflate(tolerance);
                        targets.Add(box);
                    }

                    x = x.ChangeUnits(scaleFactor);

                    if (strict)
                    {
                        var outline = new Autodesk.Revit.DB.Outline(x.ToHost(), x.ToHost());
                        return(new Autodesk.Revit.DB.BoundingBoxIsInsideFilter(outline, tolerance * scaleFactor, inverted));
                    }
                    else
                    {
                        return(new Autodesk.Revit.DB.BoundingBoxContainsPointFilter(x.ToHost(), tolerance * scaleFactor, inverted));
                    }
                });

                var filterList = filters.ToArray();
                filter = filterList.Length == 1 ?
                         filterList[0] :
                         new Autodesk.Revit.DB.LogicalOrFilter(filterList);
            }

            DA.SetData("Filter", filter);
            DA.SetDataList("Target", targets);
        }
    public bool Box(int index, ref Rhino.Geometry.Box box)
    {
      Rhino.Geometry.Point3d origin = new Rhino.Geometry.Point3d();
      Rhino.Geometry.Vector3d xaxis = new Rhino.Geometry.Vector3d();
      Rhino.Geometry.Vector3d yaxis = new Rhino.Geometry.Vector3d();
      double minX = 0.0, maxX = 0.0;
      double minY = 0.0, maxY = 0.0;
      double minZ = 0.0, maxZ = 0.0;

      if (UnsafeNativeMethods.Rdk_CustomMeshes_Box(ConstPointer(), index, ref origin, ref xaxis, ref yaxis, ref minX, ref maxX, ref minY, ref maxY, ref minZ, ref maxZ))
      {
        box = new Rhino.Geometry.Box(new Rhino.Geometry.Plane(origin, xaxis, yaxis),
                                                        new Rhino.Geometry.Interval(minX, maxX),
                                                        new Rhino.Geometry.Interval(minY, maxY),
                                                        new Rhino.Geometry.Interval(minZ, maxZ));
        return true;
      }
      return false;
    }