public List <List <ControlPoint> > ControlPointsToSpeckle(AC.NurbSurface surface, string units = null) { var u = units ?? ModelUnits; var points = new List <List <ControlPoint> >(); int count = 0; for (var i = 0; i < surface.NumControlPointsInU; i++) { var row = new List <ControlPoint>(); for (var j = 0; j < surface.NumControlPointsInV; j++) { var point = surface.ControlPoints[count]; double weight = 1; try { weight = surface.Weights[count]; } catch { } row.Add(new ControlPoint(point.X, point.Y, point.Z, weight, u)); count++; } points.Add(row); } return(points); }
public Geometry.Surface SurfaceToSpeckle(AC.NurbSurface surface) { List <double> Uknots = new List <double>(); List <double> Vknots = new List <double>(); foreach (var knot in surface.UKnots) { Uknots.Add((double)knot); } foreach (var knot in surface.VKnots) { Vknots.Add((double)knot); } var _surface = new Geometry.Surface { degreeU = surface.DegreeInU, degreeV = surface.DegreeInV, rational = surface.IsRationalInU && surface.IsRationalInV, closedU = surface.IsClosedInU(), closedV = surface.IsClosedInV(), domainU = IntervalToSpeckle(surface.GetEnvelope()[0]), domainV = IntervalToSpeckle(surface.GetEnvelope()[1]), knotsU = Uknots, knotsV = Vknots }; _surface.units = ModelUnits; _surface.SetControlPoints(ControlPointsToSpeckle(surface.ControlPoints, surface.Weights)); return(_surface); }
public Surface SurfaceToSpeckle(AC.NurbSurface surface, string units = null) { var u = units ?? ModelUnits; List <double> Uknots = new List <double>(); List <double> Vknots = new List <double>(); foreach (var knot in surface.UKnots) { Uknots.Add((double)knot); } foreach (var knot in surface.VKnots) { Vknots.Add((double)knot); } var _surface = new Surface() { degreeU = surface.DegreeInU, degreeV = surface.DegreeInV, rational = surface.IsRationalInU && surface.IsRationalInV, closedU = surface.IsClosedInU(), closedV = surface.IsClosedInV(), knotsU = Uknots, knotsV = Vknots, countU = surface.NumControlPointsInU, countV = surface.NumControlPointsInV, domainU = IntervalToSpeckle(surface.GetEnvelope()[0]), domainV = IntervalToSpeckle(surface.GetEnvelope()[1]) }; _surface.SetControlPoints(ControlPointsToSpeckle(surface)); _surface.units = u; return(_surface); }