def NURBSCurve(self, ctrlpoints, dimension, **kwds): ctrlpoints = str(ctrlpoints) ctrlpoints = [float(num) for num in ctrlpoints.split(",")] dimension = int(dimension) items, chunk = ctrlpoints, dimension pointArray = zip(*[iter(items)] * chunk) if (dimension == 2): v4array = [] for item in pointArray: v4array.append(pgl.Vector2(item)) parray = pgl.Point3Array(0) for item in v4array: parray.append(Vector3(item,1)) return (pgl.NurbsCurve2D(parray), None) elif (dimension == 3): v4array = [] for item in pointArray: v4array.append(pgl.Vector3(item)) parray = pgl.Point4Array(0) for item in v4array: parray.append(Vector4(item,1)) return (pgl.NurbsCurve(parray), None)
def __initialiseContext__(context): import openalea.plantgl.all as pgl width = pgl.NurbsCurve2D( ctrlPointList = pgl.Point3Array([(0, 0.0368034, 1),(0.321038, 0.20082, 1),(0.674863, 0.127049, 1),(1, 0.00418017, 1)]) , ) width.name = "width" panel_0 = ({'active': True, 'visible': True, 'name': 'Functions'},[('Function',width)]) import openalea.plantgl.all as pgl nerve = pgl.NurbsCurve2D( ctrlPointList = pgl.Point3Array([(-0.5, 0, 1),(-0.223915, 0.114315, 1),(0.121756, 0.0370409, 1),(0.467244, -0.216243, 1)]) , ) nerve.name = "nerve" section = pgl.NurbsCurve2D( ctrlPointList = pgl.Point3Array([(-0.5, 0, 1),(-0.195355, -0.24554, 1),(0.203326, -0.162142, 1),(0.5, 0, 1)]) , ) section.name = "section" panel_1 = ({'active': True, 'visible': True, 'name': 'Curve2D'},[('Curve2D',nerve),('Curve2D',section)]) parameterset = [panel_0,panel_1,] context["__functions__"] = [('width',width),] context["__curves__"] = [('nerve',nerve),('section',section),] context["__parameterset__"] = parameterset context["width"] = pgl.QuantisedFunction(width) context["nerve"] = nerve context["section"] = section
try:
def createDefaultObject(self, subtype=None): import openalea.plantgl.all as pgl nbP = 4 return pgl.NurbsCurve2D( pgl.Point3Array([(float(i) / (nbP - 1), 0) for i in range(nbP)], 1))