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; //} if (obj.Geometry.ObjectType == ObjectType.Mesh) { var m = (Mesh)obj.Geometry; m_value = RhinoSupport.ToPlanktonMesh(m); ClearCaches(); return(true); } return(false); }
//public override IGH_GooProxy EmitProxy() //{ // return new GH_PlanktonMeshProxy(this); //} public override bool CastFrom(object source) { if (source == null) { m_value = null; ClearCaches(); return(false); } if (typeof(GH_Mesh).IsAssignableFrom(source.GetType())) { var tmp = ((GH_Mesh)source).Value; m_value = RhinoSupport.ToPlanktonMesh((Mesh)tmp); ClearCaches(); return(true); } if (typeof(GH_PlanktonMesh).IsAssignableFrom(source.GetType())) { var tmp = ((GH_PlanktonMesh)source).Value; m_value = tmp as PlanktonMesh; ClearCaches(); return(true); } return(false); }
private static GH_PlanktonMesh HandleOne(GetObject go, int index) { var o = go.Object(index); var m = o.Mesh(); var p = RhinoSupport.ToPlanktonMesh(m); return(new GH_PlanktonMesh(p) { ReferenceID = o.ObjectId }); }
public override void ClearCaches() { //base.ClearCaches(); if (m_value == null) { _polylines = null; _b = BoundingBox.Empty; _mesh = null; } else { _polylines = RhinoSupport.ToPolylines(m_value); _mesh = RhinoSupport.ToRhinoMesh(m_value); } }
//public override IGH_GooProxy EmitProxy() //{ // return new GH_PlanktonMeshProxy(this); //} 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 PlanktonMesh) { m_value = source as PlanktonMesh; ClearCaches(); return(true); } else if (source is Mesh) { m_value = RhinoSupport.ToPlanktonMesh((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)); }
public Mesh[] GetPreviewMeshes() { if (m_value == null) { _mesh = null; return(null); } if (_mesh == null) { _mesh = RhinoSupport.ToRhinoMesh(m_value); } return(new Mesh[] { _mesh, }); }
public override bool CastTo <Q>(out Q target) { if (typeof(Q) == typeof(Mesh) || typeof(Q) == typeof(GeometryBase)) { target = (Q)(object)RhinoSupport.ToRhinoMesh(m_value); return(true); } if (typeof(Q) == (typeof(GH_Mesh))) { target = (Q)(object)new GH_Mesh(RhinoSupport.ToRhinoMesh(m_value)); return(true); } if (typeof(Q) == typeof(PlanktonMesh)) { target = (Q)(object)m_value; return(true); } return(base.CastTo <Q>(out target)); }
public override bool CastTo <T>(out T target) { // cast to GH_Mesh if (typeof(T).IsAssignableFrom(typeof(GH_Mesh))) { object msh = new GH_Mesh(RhinoSupport.ToRhinoMesh(m_value)); target = (T)msh; return(true); } // cast to Mesh if (typeof(T).IsAssignableFrom(typeof(Mesh))) { Object msh = RhinoSupport.ToRhinoMesh(m_value); target = (T)msh; return(true); } // cast to GH_PlanktonMesh if (typeof(T).IsAssignableFrom(typeof(GH_PlanktonMesh))) { object msh = new GH_PlanktonMesh(new PlanktonMesh(m_value)); target = (T)msh; return(true); } // cast to PlanktonMesh if (typeof(T).IsAssignableFrom(typeof(PlanktonMesh))) { Object msh = new PlanktonMesh(m_value); target = (T)msh; return(true); } target = default(T); return(false); }