def generate_pov(i=0, nbpovprocess=1, maxstep=None): """ generate ith images modulo nbpovprocess """ print('Image generator ', i, ' launched') from openalea.plantgl.all import Scene, Tesselator, PovFilePrinter print('Look at', stepfile) wait_for_file(stepfile) if maxstep is None: maxstep = int(open(stepfile, 'r').read()) step = i os.chdir(workingrep) while step < maxstep: bgeomfname = bgeomfile.format(str(step).zfill(4)) steppovfile = povfile.format(str(step).zfill(4)) stepimgfile = imgfile.format(str(step).zfill(4)) if os.path.exists(stepimgfile): print('Image ', step, 'already computed ...') step += nbpovprocess continue wait_for_file(bgeomfname) lscene = Scene(bgeomfname) for sh in lscene: sh.setComputedName() lscene.save(steppovfile) #tess = Tesselator() #printer = PovFilePrinter(steppovfile,tess) #lscene.apply(printer) if os.path.exists(steppovfile): mpovtext = mainpovtemplate % ( imageresolution[0], imageresolution[1], steppovfile, step) mpovfile = mainpovfile.format(str(step).zfill(4)) file(mpovfile, 'w').write(mpovtext) cmd = povcomdline.format(mpovfile, stepimgfile, imageresolution[0], imageresolution[1]) print() print(i, '>>>', cmd) print('Image ', step, 'computed ...') os.system(cmd) if os.path.exists(stepimgfile): os.remove(mpovfile) os.remove(steppovfile) os.remove(bgeomfname) else: print('Error with image', step) else: print('Error with image', step) step += nbpovprocess
def save(self, obj, filename): """ Store obj into filename """ filename = Path(filename) try: from openalea.plantgl.all import Scene sc = Scene() sc.add(obj) return sc.save(str(filename), "BGEOM") except ImportError: warnings.warn("You must install PlantGL if you want to load a BGEOM object.") except Exception, e: print e warnings.warn("Impossible to save the scene for object %s into %s" % (obj, filename))
def save(self, obj, filename): """ Store obj into filename """ filename = Path(filename) try: from openalea.plantgl.all import Scene sc = Scene() sc.add(obj) return sc.save(str(filename), "BGEOM") except ImportError: warnings.warn( "You must install PlantGL if you want to load a BGEOM object.") except Exception, e: print e warnings.warn( "Impossible to save the scene for object %s into %s" % (obj, filename))