コード例 #1
0
        private static GH_TurtleMesh HandleOne(GetObject go, int index)
        {
            var o = go.Object(index);
            var c = o.Curve();

            var m = RhinoMeshSupport.ExtractTMesh(c);

            return(new GH_TurtleMesh(m)
            {
                ReferenceID = o.ObjectId
            });
        }
コード例 #2
0
        public override void ClearCaches()
        {
            //base.ClearCaches();

            if (m_value == null)
            {
                _polylines = null;
                _b         = BoundingBox.Empty;
                _mesh      = null;
            }
            else
            {
                _polylines = RhinoMeshSupport.ExportRhinoPolylines(m_value);

                _mesh = RhinoMeshSupport.ExportTriangolatedRhinoMesh(m_value);
            }
        }
コード例 #3
0
        public override bool CastFrom(object source)
        {
            if (source == null)
            {
                m_value = null;
                ClearCaches();
                return(true);
            }

            if (source is GH_GeometricGoo <Mesh> )
            {
                source = ((GH_GeometricGoo <Mesh>)source).Value;
            }
            else if (source is GH_GeometricGoo <Curve> )
            {
                source = ((GH_GeometricGoo <Curve>)source).Value;
            }

            if (source is ITurtleMesh)
            {
                m_value = source as ITurtleMesh;
                ClearCaches();
                return(true);
            }
            else if (source is Mesh)
            {
                m_value = RhinoMeshSupport.ImportRhinoMesh((Mesh)source);
                ClearCaches();
                return(true);
            }
            else if (source is Curve)
            {
                m_value = RhinoMeshSupport.ExtractTMesh((Curve)source);
                ClearCaches();
                return(true);
            }
            else if (source is Grasshopper.Kernel.Types.GH_Curve)
            {
                m_value = RhinoMeshSupport.ExtractTMesh((Curve)source);
                ClearCaches();
                return(true);
            }

            return(base.CastFrom(source));
        }
コード例 #4
0
        public override bool LoadGeometry(Rhino.RhinoDoc doc)
        {
            RhinoObject obj = doc.Objects.Find(ReferenceID);

            if (obj == null)
            {
                return(false);
            }
            if (obj.Geometry.ObjectType == ObjectType.Curve)
            {
                var c = (Curve)obj.Geometry;

                m_value = RhinoMeshSupport.ExtractTMesh(c);
                ClearCaches();
                return(true);
            }
            return(false);
        }
コード例 #5
0
        public Mesh[] GetPreviewMeshes()
        {
            if (m_value == null)
            {
                _mesh = null;
                return(null);
            }

            if (_mesh == null)
            {
                _mesh = RhinoMeshSupport.ExportTriangolatedRhinoMesh(m_value);
            }

            return(new Mesh[]
            {
                _mesh,
            });
        }
コード例 #6
0
        public override bool CastTo <Q>(out Q target)
        {
            if (typeof(Q) == typeof(Mesh) || typeof(Q) == typeof(GeometryBase))
            {
                target = (Q)(object)RhinoMeshSupport.ExportTriangolatedRhinoMesh(m_value);
                return(true);
            }
            if (typeof(Q) == (typeof(GH_Mesh)))
            {
                target = (Q)(object)new GH_Mesh(RhinoMeshSupport.ExportTriangolatedRhinoMesh(m_value));
                return(true);
            }
            if (typeof(Q) == typeof(ITurtleMesh))
            {
                target = (Q)(object)m_value;
                return(true);
            }

            return(base.CastTo <Q>(out target));
        }