def buildEllipses2(opts, args): alltransforms = loadJSON(args[0]) for (subjId, subj) in enumerate(alltransforms): print "Processing", subjId appender = vtkAppendPolyData() for part in subj: try: S = part[0] R = np.matrix(part[1]).reshape(3,3).transpose() T = part[2] except: print "Error:", part return print S, R, T txf = vtkTransformPolyDataFilter() txf.SetTransform(createTransform(S, R, T)) sphereSource = vtkSphereSource() sphereSource.SetRadius(1); sphereSource.SetThetaResolution(16); sphereSource.SetPhiResolution(16); sphereSource.Update() sphere = sphereSource.GetOutput() txf.SetInput(sphere) txf.Update() #nu.writeVTK(opts.output%(id+1), txf.GetOutput()) appender.AddInput(txf.GetOutput()) appender.Update() fileOut = opts.output % (subjId) print "Saving", fileOut nu.writeVTK(opts.output % (subjId), appender.GetOutput())
def main(opts, args): appender = vtk.vtkAppendPolyData() for f in args: o = nu.readVTK(f) appender.AddInput(o) appender.Update() nu.writeVTK(opts.output, appender.GetOutput())
def buildBoundingBox(fname,fout): obbList = loadJSON(fname) appender = vtkAppendPolyData() for (id,label) in enumerate(obbList): vertexList = []; for vertex in sorted(obbList[label]['obb_vertices']): obbVertices = obbList[label]['obb_vertices'][vertex] vertexList.append(obbVertices) cubePolyData = createCube(vertexList) nu.writeVTK(fout % (id+1), cubePolyData) appender.AddInput(cubePolyData) appender.Update() nu.writeVTK(fout%(0),appender.GetOutput())
def main(opts, args): inputTransform = np.array(opts.transform.split(","), dtype='double').reshape((4,4)) transformMatrix = vtk.vtkMatrix4x4() for i in range(0,4): for j in range(0,4): transformMatrix.SetElement(i,j,inputTransform[i,j]) print "InputTransform\n", inputTransform, "vtkMatrix\n", transformMatrix transform = vtk.vtkTransform() transform.SetMatrix(transformMatrix) transformFilter = vtk.vtkTransformPolyDataFilter() transformFilter.SetTransform(transform) for (inputId, input) in enumerate(args): obj = nu.readVTK(input) transformFilter.SetInput(obj) transformFilter.Update() objOut = transformFilter.GetOutput() if (opts.output.find("%") > 0): nu.writeVTK(opts.output % (inputId), objOut) else: nu.writeVTK(opts.output, objOut)
#!/biomed-resimg/crews_rodent/devel/linux/ParaView3/ParaView-3.10.0-Linux-x86_64/bin/pvpython import niral import sys p = niral.readVTK(sys.argv[1]) niral.writeVTK(sys.argv[2], p)