public static global::Topologic.Face ToTopologic(this Rhino.Geometry.NurbsSurface nurbsSurface) { if (nurbsSurface == null) { return(null); } int uDegree = nurbsSurface.Degree(0); int vDegree = nurbsSurface.Degree(1); bool isUPeriodic = nurbsSurface.IsPeriodic(0); bool isVPeriodic = nurbsSurface.IsPeriodic(1); bool isRational = nurbsSurface.IsRational; NurbsSurfaceKnotList ghUKnots = nurbsSurface.KnotsU; List <double> uKnots = ghUKnots.ToList(); NurbsSurfaceKnotList ghVKnots = nurbsSurface.KnotsV; List <double> vKnots = ghVKnots.ToList(); // OCCT-compatible uKnots.Insert(0, uKnots[0]); uKnots.Add(uKnots.Last()); vKnots.Insert(0, vKnots[0]); vKnots.Add(vKnots.Last()); NurbsSurfacePointList ghControlPoints = nurbsSurface.Points; List <IList <Vertex> > controlPoints = new List <IList <Vertex> >(); List <IList <double> > weights = new List <IList <double> >(); for (int i = 0; i < ghControlPoints.CountU; ++i) { List <Vertex> controlPoints1D = new List <Vertex>(); List <double> weights1D = new List <double>(); for (int j = 0; j < ghControlPoints.CountV; ++j) { ControlPoint ghControlPoint = ghControlPoints.GetControlPoint(i, j); controlPoints1D.Add(ghControlPoint.Location.ToTopologic()); weights1D.Add(ghControlPoint.Weight); } controlPoints.Add(controlPoints1D); weights.Add(weights1D); } return(global::Topologic.Face.ByNurbsParameters(controlPoints, weights, uKnots, vKnots, isRational, isUPeriodic, isVPeriodic, uDegree, vDegree)); }
public List <List <ControlPoint> > ControlPointsToSpeckle(NurbsSurfacePointList controlPoints, string units = null) { var points = new List <List <ControlPoint> >(); for (var i = 0; i < controlPoints.CountU; i++) { var row = new List <ControlPoint>(); for (var j = 0; j < controlPoints.CountV; j++) { var pt = controlPoints.GetControlPoint(i, j); var pos = pt.Location; row.Add(new ControlPoint(pos.X, pos.Y, pos.Z, pt.Weight, units ?? ModelUnits)); } points.Add(row); } return(points); }
private Face ByNurbsSurface(Rhino.Geometry.NurbsSurface ghNurbsSurface) { int uDegree = ghNurbsSurface.Degree(0); int vDegree = ghNurbsSurface.Degree(1); bool isUClosed = ghNurbsSurface.IsClosed(0); bool isVClosed = ghNurbsSurface.IsClosed(1); bool isUPeriodic = ghNurbsSurface.IsPeriodic(0); bool isVPeriodic = ghNurbsSurface.IsPeriodic(1); bool isRational = ghNurbsSurface.IsRational; NurbsSurfaceKnotList ghUKnots = ghNurbsSurface.KnotsU; List <double> uKnots = ghUKnots.ToList(); NurbsSurfaceKnotList ghVKnots = ghNurbsSurface.KnotsV; List <double> vKnots = ghVKnots.ToList(); // OCCT-compatible uKnots.Insert(0, uKnots[0]); uKnots.Add(uKnots.Last()); vKnots.Insert(0, vKnots[0]); vKnots.Add(vKnots.Last()); NurbsSurfacePointList ghControlPoints = ghNurbsSurface.Points; List <List <Topologic.Vertex> > controlPoints = new List <List <Topologic.Vertex> >(); List <List <double> > weights = new List <List <double> >(); for (int i = 0; i < ghControlPoints.CountU; ++i) { List <Topologic.Vertex> controlPoints1D = new List <Topologic.Vertex>(); List <double> weights1D = new List <double>(); for (int j = 0; j < ghControlPoints.CountV; ++j) { ControlPoint ghControlPoint = ghControlPoints.GetControlPoint(i, j); controlPoints1D.Add(ByPoint(ghControlPoint.Location)); weights1D.Add(ghControlPoint.Weight); } controlPoints.Add(controlPoints1D); weights.Add(weights1D); } return(Topologic.Face.ByNurbsParameters(controlPoints, weights, uKnots, vKnots, isRational, isUPeriodic, isVPeriodic, uDegree, vDegree)); }