public static Rhino.Geometry.NurbsSurface ToRhino_NurbsSurface(this global::Topologic.NurbsSurface nurbsSurface) { int uDegree = nurbsSurface.UDegree; int vDegree = nurbsSurface.VDegree; bool isRational = nurbsSurface.IsURational && nurbsSurface.IsVRational; int uCount = nurbsSurface.NumOfUControlVertices; int vCount = nurbsSurface.NumOfVControlVertices; Rhino.Geometry.NurbsSurface ghNurbsSurface = Rhino.Geometry.NurbsSurface.Create( 3, isRational, uDegree + 1, vDegree + 1, uCount, vCount ); int i = 0; for (int u = 0; u < uCount; ++u) { for (int v = 0; v < vCount; ++v) { global::Topologic.Vertex controlVertex = nurbsSurface.ControlVertex(u, v); ghNurbsSurface.Points.SetPoint(u, v, ToRhino(controlVertex)); ++i; } } List <double> uKnots = nurbsSurface.UKnots; uKnots = uKnots.GetRange(1, uKnots.Count - 2); for (int u = 0; u < uKnots.Count; u++) { ghNurbsSurface.KnotsU[u] = uKnots[u]; } List <double> vKnots = nurbsSurface.VKnots; vKnots = vKnots.GetRange(1, vKnots.Count - 2); for (int v = 0; v < vKnots.Count; v++) { ghNurbsSurface.KnotsV[v] = vKnots[v]; } if (!ghNurbsSurface.IsValid) { throw new Exception("A valid surface cannot be created from this Face."); } return(ghNurbsSurface); }
public static Rhino.Geometry.Surface ToRhino(global::Topologic.Face face) { Object faceGeometry = face.BasicGeometry; // 1. Compute the base surface Based on https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_NurbsSurface_Create.htm global::Topologic.NurbsSurface nurbsSurface = faceGeometry as global::Topologic.NurbsSurface; if (nurbsSurface != null) { return(ToRhino_NurbsSurface(nurbsSurface)); } global::Topologic.PlanarSurface planarSurface = faceGeometry as global::Topologic.PlanarSurface; if (planarSurface != null) { PlaneSurface planeSurface = ToRhino(planarSurface, face); return(planeSurface); } throw new Exception("An invalid surface is created."); }