Пример #1
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GeometryBase Geom    = default(GeometryBase);
            string       InfoKey = default(string);
            //特别注意
            dynamic InfoValue = default(dynamic);

            if (!DA.GetData(0, ref Geom))
            {
                return;
            }
            if (!DA.GetData(1, ref InfoKey))
            {
                return;
            }
            if (!DA.GetData(2, ref InfoValue))
            {
                return;
            }
            //这句代码至关重要
            GeometryBase TempGeom = Geom.Duplicate();

            if ((TempGeom is Rhino.Geometry.Point))
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "目前尚不支持Point的户自定义数据写入");
                return;
            }
            TempGeom.UserDictionary.Set(InfoKey, InfoValue.Value);
            DA.SetData(0, TempGeom);
        }
Пример #2
0
        /// <summary>
        /// Computes the distance of a point to a given geometry. (Brep, Mesh or closed Surface)
        /// </summary>
        public static double DistanceTo(GeometryBase geometry, Point3d testPoint, int spaceType)
        {
            double  distanceTo = 0;
            Point3d closestPoint;

            switch (spaceType)
            {
            // Brep design space
            case 1:
                closestPoint = ((Brep)geometry).ClosestPoint(testPoint);
                distanceTo   = testPoint.DistanceTo(closestPoint);
                break;

            // Mesh design space
            case 2:
                closestPoint = ((Mesh)geometry).ClosestPoint(testPoint);
                distanceTo   = testPoint.DistanceTo(closestPoint);
                break;

            // Solid surface design space (must be converted to brep)
            case 3:
                closestPoint = ((Surface)geometry).ToBrep().ClosestPoint(testPoint);
                distanceTo   = testPoint.DistanceTo(closestPoint);
                break;
            }

            return(distanceTo);
        }
Пример #3
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            IGH_GeometricGoo shape = null;

            if (!DA.GetData <IGH_GeometricGoo>(0, ref shape))
            {
                return;
            }

            GeometryBase geo = null;

            if (shape is Mesh || shape is GH_Mesh ||
                shape is Brep || shape is GH_Brep ||
                shape is Surface || shape is GH_Surface ||
                shape is Curve || shape is GH_Curve ||
                shape is GH_Box || shape is GH_Line)
            {
                geo = GH_Convert.ToGeometryBase(shape);
            }
            else
            {
                return;
            }

            var bbox = geo.GetBoundingBox(true);

            DA.SetData(0, bbox.Center);
        }
        public static Brep ReadHouseGeometry(string houseType)
        {
            string       fileName = ReadResourceFile("Engine.Resources." + houseType + ".txt");
            GeometryBase geometry = GH_Convert.ByteArrayToCommonObject <GeometryBase>(System.Convert.FromBase64String(fileName));

            return(geometry as Brep);
        }
Пример #5
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GeometryBase Geometry = null;
            double       XSpan    = 0.2;
            double       YSpan    = 0.2;
            double       ZSpan    = 0.2;
            double       DXSpan   = 0.2;
            double       DYSpan   = 0.2;
            double       Angle    = 45.0;
            double       minSpan  = 0.0001;

            if (!DA.GetData(0, ref Geometry))
            {
                return;
            }
            DA.GetData(1, ref XSpan);
            DA.GetData(2, ref YSpan);
            DA.GetData(3, ref ZSpan);
            DA.GetData(4, ref DXSpan);
            DA.GetData(5, ref DYSpan);
            DA.GetData(6, ref Angle);

            if (XSpan < minSpan)
            {
                XSpan = minSpan;
            }
            if (YSpan < minSpan)
            {
                YSpan = minSpan;
            }
            if (ZSpan < minSpan)
            {
                ZSpan = minSpan;
            }
            if (DXSpan < minSpan)
            {
                DXSpan = minSpan;
            }
            if (DXSpan < minSpan)
            {
                DXSpan = minSpan;
            }

            List <List <Plane> > Frames = V2GRhinoGeometry.BoundingFrames(
                Geometry,
                XSpan,
                YSpan,
                ZSpan,
                DXSpan,
                DYSpan,
                Angle// Optional
                );

            DA.SetDataList(0, Frames[0]);
            DA.SetDataList(1, Frames[1]);
            DA.SetDataList(2, Frames[2]);
            DA.SetDataList(3, Frames[3]);
            DA.SetDataList(4, Frames[4]);
            DA.SetDataList(5, Frames);
        }
Пример #6
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            object obj2 = null;

            DA.GetData(0, ref obj2);
            if (obj2 == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Failed to get object"); return;
            }

            var          theValue = obj2.GetType().GetProperty("Value").GetValue(obj2, null);
            GeometryBase geometry = null;

            geometry = theValue as GeometryBase;


            if (geometry == null)
            {
                DA.SetData(0, null);
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Input object not supported.");
                return;
            }

            if (geometry.UserDictionary == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Object has no user dictionary.");
                DA.SetData(0, null);
                return;
            }

            DA.SetData(0, geometry.UserDictionary);
        }
        public static DB.GeometryObject[] ToShape(this GeometryBase geometry, double factor)
        {
            switch (geometry)
            {
            case Point point:
                return(new DB.Point[] { point.ToPoint(factor) });

            case PointCloud pointCloud:
                return(pointCloud.ToPoints(factor));

            case Curve curve:
                return(curve.ToCurveMany(factor).SelectMany(x => x.ToBoundedCurves()).ToArray());

            case Brep brep:
                return(new DB.GeometryObject[] { ToShape(brep, factor) });

            case Extrusion extrusion:
                return(new DB.GeometryObject[] { ToShape(extrusion, factor) });

            case SubD subD:
                return(new DB.GeometryObject[] { ToShape(subD, factor) });

            case Mesh mesh:
                return(new DB.GeometryObject[] { MeshEncoder.ToMesh(MeshEncoder.ToRawMesh(mesh, factor)) });

            default:
                if (geometry.HasBrepForm)
                {
                    var brepForm = Brep.TryConvertBrep(geometry);
                    return(new DB.GeometryObject[] { ToShape(brepForm, factor) });
                }

                return(new DB.GeometryObject[0]);
            }
        }
Пример #8
0
        public new static FaceEntity TryGetFrom(GeometryBase rhinoGeo)
        {
            var rc = new FaceEntity();

            if (!rhinoGeo.IsValid)
            {
                return(rc);
            }

            if (rhinoGeo is BrepFace brepFace)
            {
                //var ent = brepFace.Brep.Surfaces[brepFace.SurfaceIndex].UserData.Find(typeof(FaceEntity)) as FaceEntity;
                var ent = brepFace.UnderlyingSurface().TryGetFaceEntity();
                return(ent == null ? rc : ent);
            }
            else if (rhinoGeo is Surface surface)
            {
                var ent = surface.UserData.Find(typeof(FaceEntity)) as FaceEntity;
                return(ent == null ? rc : ent);
            }
            else
            {
                var ent = (rhinoGeo as Rhino.Geometry.Brep).Surfaces[0].UserData.Find(typeof(FaceEntity)) as FaceEntity;
                return(ent == null ? rc : ent);
            }
        }
Пример #9
0
            public virtual bool Regen()
            {
                if (geometry != null)
                {
                    if (!BeginRegen())
                    {
                        return(false);
                    }

                    if (geometry.IsValid)
                    {
                        if (geometry is Mesh mesh)
                        {
                            vertexBuffer = ToVertexBuffer(mesh, part, out vertexFormatBits);
                            vertexCount  = part.VertexCount;

                            triangleBuffer = ToTrianglesBuffer(mesh, part, out triangleCount);
                            linesBuffer    = ToEdgeBuffer(mesh, part, out linesCount);
                        }
                        else if (geometry is Curve curve)
                        {
                            using (var polyline = curve.ToPolyline(Revit.ShortCurveTolerance * Revit.ModelUnits, Revit.AngleTolerance * 100.0, Revit.ShortCurveTolerance * Revit.ModelUnits, 0.0))
                            {
                                var pline = polyline.ToPolyline();

                                // Reduce too complex polylines.
                                {
                                    var tol = Revit.VertexTolerance * Revit.ModelUnits;
                                    while (pline.Count > 0x4000)
                                    {
                                        tol *= 2.0;
                                        if (pline.ReduceSegments(tol) == 0)
                                        {
                                            break;
                                        }
                                    }
                                }

                                linesCount = ToPolylineBuffer(pline, out vertexFormatBits, out vertexBuffer, out vertexCount, out linesBuffer);
                            }
                        }
                        else if (geometry is Point point)
                        {
                            linesCount = -ToPointsBuffer(point, out vertexFormatBits, out vertexBuffer, out vertexCount, out linesBuffer);
                        }
                        else if (geometry is PointCloud pointCloud)
                        {
                            linesCount = -ToPointsBuffer(pointCloud, part, out vertexFormatBits, out vertexBuffer, out vertexCount, out linesBuffer);
                        }

                        vertexFormat = new DB3D.VertexFormat(vertexFormatBits);
                    }

                    geometry = null;

                    EndRegen();
                }

                return(true);
            }
Пример #10
0
        public static RhinoGeometryContainer ReadRhino(string path)
        {
            RhinoGeometryContainer geoContainer = new RhinoGeometryContainer();

            try
            {
                File3dm rhinoFile = File3dm.Read(path);
                geoContainer.FilePath = path;

                File3dmObjectTable objects = rhinoFile.Objects;
                foreach (File3dmObject fileObj in objects)
                {
                    Guid         objId    = fileObj.Attributes.ObjectId;
                    string       name     = fileObj.Name;
                    GeometryBase geometry = fileObj.Geometry;

                    RhinoObjectInfo objInfo = new RhinoObjectInfo(objId, name, geometry);

                    CollectGeometryInfo(objInfo, ref geoContainer);
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
            return(geoContainer);
        }
Пример #11
0
        private static bool _changeInstanceDefinitionGeometryLayer(InstanceDefinition definition, RhinoDoc doc, Layer layer)
        {
            if (!doc.Layers.Contains(layer))
            {
                RhinoApp.WriteLine($"No Layer {layer} in document!");
                return(false);
            }

            var rhObjects  = definition.GetObjects();
            var geometries = new GeometryBase[rhObjects.Length];
            var attributes = new ObjectAttributes[rhObjects.Length];

            for (int i = 0; i < rhObjects.Length; i++)
            {
                geometries[i]            = rhObjects[i].Geometry;
                attributes[i]            = rhObjects[i].Attributes;
                attributes[i].LayerIndex = layer.Index;
            }

            var serial  = doc.BeginUndoRecord("Change Block geometry layer");
            var success = doc.InstanceDefinitions.ModifyGeometry(definition.Index, geometries, attributes);

            doc.EndUndoRecord(serial);
            return(success);
        }
Пример #12
0
        public static bool ExportNestedBlock(NestedBlock nested, string filePath)
        {
            var doc = new File3dm();

            // Add all instance definitions
            foreach (var references in nested.GetRootTreeByRootDepth().Reverse())
            {
                var nameIndexDict = new Dictionary <string, int>();
                foreach (var referencedBlock in references)
                {
                    if (!nameIndexDict.ContainsKey(referencedBlock.Definition.Name))
                    {
                        var objs  = referencedBlock.Definition.GetObjects();
                        var geos  = new GeometryBase[objs.Length];
                        var attrs = new ObjectAttributes[objs.Length];
                        for (int i = 0; i < objs.Length; i++)
                        {
                            geos[i]  = objs[i].Geometry;
                            attrs[i] = objs[i].Attributes;
                        }

                        var index = doc.AllInstanceDefinitions.Add(referencedBlock.Definition.Name, nested.Definition.Description,
                                                                   Point3d.Origin, geos, attrs);
                        nameIndexDict.Add(referencedBlock.Definition.Name, index);
                    }

                    doc.Objects.AddInstanceObject(nameIndexDict[referencedBlock.Definition.Name],
                                                  referencedBlock.BlockInsertionParameters.InstanceXform);
                }
            }

            return(doc.Write(filePath, RhinoApp.ExeVersion));
        }
        /// <summary>
        /// Returns the total route lenght. -1 if error.
        /// </summary>
        /// <returns></returns>
        public static double TotalRouteLength()
        {
            string layername = "Heating Network";

            // Get all of the objects on the layer. If layername is bogus, you will
            // just get an empty list back
            Rhino.DocObjects.RhinoObject[] rhobjs = RhinoDoc.ActiveDoc.Objects.FindByLayer(layername).Where(x => x.ObjectType == Rhino.DocObjects.ObjectType.Curve).ToArray();
            if (rhobjs == null || rhobjs.Length < 1)
            {
                return(-1);
            }

            var curves = new Curve[rhobjs.Length];

            for (int i = 0; i < rhobjs.Length; i++)
            {
                GeometryBase geom = rhobjs[i].Geometry;
                Curve        x    = geom as Curve;
                if (x != null && x.IsValid)
                {
                    curves[i] = x;
                }
            }
            double lenght = curves.Sum(x => x.GetLength());

            return(lenght);
        }
Пример #14
0
        /// <summary>
        /// Replace a geometry object in the active Rhino document
        /// </summary>
        /// <param name="objID"></param>
        /// <param name="geometry"></param>
        /// <returns></returns>
        public static bool Replace(Guid objID, GeometryBase geometry)
        {
            bool result = false;

            Writing = true;
            if (geometry == null)
            {
                result = false;
            }
            else if (geometry is RC.Curve)
            {
                result = RhinoDoc.ActiveDoc.Objects.Replace(objID, (RC.Curve)geometry);
            }
            else if (geometry is RC.Mesh)
            {
                result = RhinoDoc.ActiveDoc.Objects.Replace(objID, (RC.Mesh)geometry);
            }
            else if (geometry is RC.Brep)
            {
                result = RhinoDoc.ActiveDoc.Objects.Replace(objID, (RC.Brep)geometry);
            }
            else if (geometry is RC.Surface)
            {
                result = RhinoDoc.ActiveDoc.Objects.Replace(objID, (RC.Curve)geometry);
            }
            Writing = false;
            return(result);
        }
Пример #15
0
        /// <summary>
        /// Creates an object that inherits from GeometryBase from an array of bytes.
        /// </summary>
        private static GeometryBase ToGeometryBase(byte[] bytes)
        {
            if (null == bytes || 0 == bytes.Length)
            {
                return(null);
            }

            GeometryBase rc = null;

            try
            {
                using (var stream = new MemoryStream())
                {
                    var formatter = new BinaryFormatter();
                    stream.Write(bytes, 0, bytes.Length);
                    stream.Seek(0, SeekOrigin.Begin);
                    var geometry = formatter.Deserialize(stream) as GeometryBase;
                    if (null != geometry && geometry.IsValid)
                    {
                        rc = geometry;
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }

            return(rc);
        }
Пример #16
0
 public void AddGeometry(GeometryBase Geometry)
 {
     if (_geometries != null)
     {
         _geometries.Add(Geometry);
     }
 }
Пример #17
0
 private void AddPath(IContainerElement container, GeometryBase geometry)
 {
     #region radpdfprocessing-model-path_1
     Path path = container.Content.AddPath();
     path.Geometry = geometry;
     #endregion
 }
Пример #18
0
        /// <summary>
        /// Checks geometry to see if it can be selected.
        /// Override to provide fancy filtering.
        /// </summary>
        /// <param name="rhObject">parent object being considered.</param>
        /// <param name="geometry">geometry being considered.</param>
        /// <param name="componentIndex">
        /// if >= 0, geometry is a proper sub-part of object->Geometry() with componentIndex.
        /// </param>
        /// <returns>
        /// The default returns true unless you've set a custom geometry filter. If a custom
        /// filter has been set, that delegate is called.
        /// </returns>
        /// <remarks>The delegate should not throw exceptions. If an exception is thrown, a message box will show and
        /// the filter will be disabled.</remarks>
        public virtual bool CustomGeometryFilter(RhinoObject rhObject, GeometryBase geometry, ComponentIndex componentIndex)
        {
            if (m_filter != null)
            {
                try
                {
                    return(m_filter(rhObject, geometry, componentIndex));
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(
                        "The CustomGeometryFilter() function threw an uncaught exception. It will be disabled." +
                        "Details: \n\n" +
                        $"Type: {ex.GetType().FullName} \n" +
                        $"Message: {ex.Message} \n" +
                        $"StackTrace: \n{ex.StackTrace}"
                        ,
                        "CustomGeometryFilter exception boundary");

                    //we need to stop the exception from repeating.
                    m_filter = null;
                }
            }
            return(true);
        }
        ////////////////////////////////////////////////////////////////////////////////////
        ///Need to Clean up here............................................................
        ////////////////////////////////////////////////////////////////////////////////////
        public T EnsureUnit_test <T>(object rhGeo)
        {
            GeometryBase geo = rhGeo as GeometryBase;

            if (targetUnit == baseUnit)
            {
                return((T)Convert.ChangeType(geo, typeof(T)));
            }
            else
            {
                if (baseUnit == "Meters" && targetUnit == "Feet")
                {
                    geo.Transform(Transform.Scale(Point3d.Origin, 3.280841666667));
                    return((T)Convert.ChangeType(rhGeo, typeof(T)));
                }
                else if (baseUnit == "Feet" && targetUnit == "Meters")
                {
                    geo.Transform(Transform.Scale(Point3d.Origin, 0.304800164592));
                    return((T)Convert.ChangeType(rhGeo, typeof(T)));
                }
                else
                {
                    return(default(T));
                }
            }
        }
Пример #20
0
        /// <summary>
        /// Converts an object that inherits from GeometryBase to an array of bytes.
        /// </summary>
        private static byte[] ToBytes(GeometryBase src)
        {
            var rc = new byte[0];

            if (null == src)
            {
                return(rc);
            }

            try
            {
                var formatter = new BinaryFormatter();
                using (var stream = new MemoryStream())
                {
                    formatter.Serialize(stream, src);
                    rc = stream.ToArray();
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }

            return(rc);
        }
        static Curve[] Section(Plane plane, GeometryBase geometry, double tolerance)
        {
            var rc   = new Curve[0];
            var brep = geometry as Brep;

            if (brep != null)
            {
                Point3d[] pts;
                Rhino.Geometry.Intersect.Intersection.BrepPlane(brep, plane, tolerance, out rc, out pts);
                return(rc);
            }
            var mesh = geometry as Mesh;

            if (mesh != null)
            {
                var polylines = Rhino.Geometry.Intersect.Intersection.MeshPlane(mesh, plane);
                if (polylines != null)
                {
                    rc = new Curve[polylines.Length];
                    for (int i = 0; i < polylines.Length; i++)
                    {
                        rc[i] = new PolylineCurve(polylines[i]);
                    }
                }
            }
            return(rc);
        }
Пример #22
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GeometryBase Geom    = default(GeometryBase);
            string       InfoKey = null;

            if (!DA.GetData(0, ref Geom))
            {
                return;
            }
            if (!DA.GetData(1, ref InfoKey))
            {
                return;
            }
            //此处务必对几何体进行拷贝,否则将会影响到前面的几何体
            GeometryBase TempGeom = Geom.Duplicate();

            try
            {
                if (TempGeom.UserDictionary.ContainsKey(InfoKey))
                {
                    TempGeom.UserDictionary.Remove(InfoKey);
                    DA.SetData(0, TempGeom);
                }
                else
                {
                    throw new Exception("在几何体中未找到Key值为:" + InfoKey + " 的字段");
                }
            }catch (Exception ex)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, ex.Message);
            }
        }
        public override bool CustomGeometryFilter(RhinoObject rhObject, GeometryBase geometry, ComponentIndex componentIndex)
        {
            if (null == rhObject || null == geometry)
            {
                return(false);
            }

            if (ComponentIndexType.BrepLoop != componentIndex.ComponentIndexType)
            {
                return(false);
            }

            var loop = geometry as BrepLoop;

            if (null == loop)
            {
                return(false);
            }

            var brep = loop.Brep;

            if (null == brep)
            {
                return(false);
            }

            return(IsHoleLoop(brep, loop.LoopIndex, true, false, m_tolerance));
        }
Пример #24
0
 private void CreatePath(IContainerElement container, GeometryBase geometry)
 {
     #region radpdfprocessing-model-path_0
     Path path = new Path();
     path.Geometry = geometry;
     container.Content.Add(path);
     #endregion
 }
Пример #25
0
        public void LoadData(GeometryBase geometry)
        {
            elementSizeCheckBox.Checked = geometry.GetUserString("Ibra.MaxElementSize") != null;
            elementSizeTextBox.Text     = geometry.GetUserString("Ibra.MaxElementSize");

            polynomialDegreeCheckBox.Checked = geometry.GetUserString("Ibra.MinPolynomialDegree") != null;
            polynomialDegreeTextBox.Text     = geometry.GetUserString("Ibra.MinPolynomialDegree");
        }
Пример #26
0
 /// <summary>
 /// Checks geometry to see if it can be selected.
 /// Override to provide fancy filtering.
 /// </summary>
 /// <param name="rhObject">parent object being considered.</param>
 /// <param name="geometry">geometry being considered.</param>
 /// <param name="componentIndex">
 /// if >= 0, geometry is a proper sub-part of object->Geometry() with componentIndex.
 /// </param>
 /// <returns>
 /// The default returns true unless you've set a custom geometry filter. If a custom
 /// filter has been set, that delegate is called
 /// </returns>
 public virtual bool CustomGeometryFilter(RhinoObject rhObject, GeometryBase geometry, ComponentIndex componentIndex)
 {
     if (m_filter != null)
     {
         return(m_filter(rhObject, geometry, componentIndex));
     }
     return(true);
 }
Пример #27
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GeometryBase Geom = default(GeometryBase);
            Vector3d     Direction = default(Vector3d);
            bool         IsDubleSide = true, IsCape = true;
            Brep         Output = default(Brep);

            if (!DA.GetData(0, ref Geom))
            {
                return;
            }
            if (!DA.GetData(1, ref Direction))
            {
                return;
            }
            if (!DA.GetData(2, ref IsDubleSide))
            {
                return;
            }
            if (!DA.GetData(3, ref IsCape))
            {
                return;
            }

            if (Geom is Curve)
            {
                Curve Crv = Geom as Curve;
                Output = this.ExtrudeCurveBothSide(Crv, Direction, IsDubleSide, IsCape);
            }
            else if (Geom is Surface)
            {
                Surface Srf = Geom as Surface;
                //
                //实现在函数里面书写函数
                //
                //
                Func <Surface, Curve> CreateBoundary = _Srf =>
                {
                    Brep      b    = _Srf.ToBrep();
                    CurveList Crvs = new CurveList();

                    BrepEdgeList es = b.Edges;

                    foreach (BrepEdge e in es)
                    {
                        Crvs.Add(e.EdgeCurve);
                    }
                    return(Curve.JoinCurves(Crvs)[0]);
                };
                Curve Crv = CreateBoundary(Srf);
                Output = this.ExtrudeCurveBothSide(Crv, Direction, IsDubleSide, IsCape);
            }
            if (Output == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "输入的几何体不是平面几何体");
            }
            DA.SetData(0, Output);
        }
        //This method creates a bounding box to a geometry in a given plane and returns the min and max coordinates of that box in the plane coordinates.
        private static Tuple <Point3d, Point3d> getMinAndMax(GeometryBase geometry, Plane plane)
        {
            Transform   vali     = Transform.PlaneToPlane(Plane.WorldXY, plane);
            BoundingBox box      = geometry.GetBoundingBox(plane);
            Point3d     minPoint = box.Min;
            Point3d     maxPoint = box.Max;

            return(Tuple.Create(minPoint, maxPoint));
        }
 /// <summary>
 /// Initializes a new instance of the ObjController class.
 /// </summary>
 public ObjController1()
     : base("Controller1", "Controller1",
            "Tracking of HTC Vive Controller",
            "ViveTrack", "Tracking Device")
 {
     controller          = GH_Convert.ByteArrayToCommonObject <GeometryBase>(System.Convert.FromBase64String(Resources.controller));
     CurrenTrackedDevice = new VrTrackedDevice();
     //(this as IGH_PreviewObject).Hidden = true;
 }
Пример #30
0
 /// <summary>
 /// Initializes a new instance of the ObjHMD class.
 /// </summary>
 public ObjHMD()
     : base("Vive HMD", "HMD",
            "Tracking of HTC Vive HMD",
            "ViveTrack", "Tracking Device")
 {
     HMD = GH_Convert.ByteArrayToCommonObject <GeometryBase>(System.Convert.FromBase64String(Resources.HMD));
     CurrenTrackedDevice = new VrTrackedDevice();
     //(this as IGH_PreviewObject).Hidden = true;
 }