def onBeginAnimationStep(self, deltaTime): if self.options['time_parameters']['time_profiling']: Sofa.timerSetEnabled(self.options['time_parameters']['timer_name'], True) Sofa.timerBegin(self.options['time_parameters']['timer_name']) return 0
def animate(self, iterations): #setup the environment #Animation loop with open("poutre_grid_sofa_timerLog.log", "w+") as outputFile : outputFile.write("{") i = 0 Sofa.timerSetOutPutType("timer_poutre_grid_sofa", "ljson") while i < iterations: Sofa.timerBegin("timer_poutre_grid_sofa") self.rootNode.simulationStep(0.1) result = Sofa.timerEnd("timer_poutre_grid_sofa", self.rootNode) if result != None : outputFile.write(result + ",") oldResult = result i = i+1 last_pose = outputFile.tell() outputFile.seek(last_pose - 1) outputFile.write("\n}") outputFile.seek(7) firstStep = outputFile.read(1) outputFile.close() Sofa.timerSetEnabled("timer_poutre_grid_sofa", 0) data = [firstStep] self.rootNode.sendScriptEvent('end', data) return 0
def measureAnimationTime(node, timerName, timerInterval, timerOutputType, resultFileName, simulationDeltaTime, iterations): # timer Sofa.timerSetInterval( timerName, timerInterval) # Set the number of steps neded to compute the timer Sofa.timerSetEnabled(timerName, True) resultFileName = resultFileName + ".log" rootNode = node.getRoot() with open(resultFileName, "w+") as outputFile: outputFile.write("{") i = 0 Sofa.timerSetOutPutType(timerName, timerOutputType) while i < iterations: Sofa.timerBegin(timerName) rootNode.simulationStep(simulationDeltaTime) result = Sofa.timerEnd(timerName, rootNode) if result != None: outputFile.write(result + ",") oldResult = result i = i + 1 last_pose = outputFile.tell() outputFile.seek(last_pose - 1) outputFile.write("\n}") outputFile.seek(7) firstStep = outputFile.read(1) outputFile.close() Sofa.timerSetEnabled(timerName, 0) print "[Scene info]: end of simulation." return 0
def animate(self, iterations): #setup the environment #Animation loop with open("poutre_grid_CGOGN_timerLog.log", "w+") as outputFile: outputFile.write("{") i = 0 Sofa.timerSetOutPutType("timer_poutre_grid_CGOGN", "ljson") while i < iterations: Sofa.timerBegin("timer_poutre_grid_CGOGN") self.rootNode.simulationStep(0.1) result = Sofa.timerEnd("timer_poutre_grid_CGOGN", self.rootNode) if result != None: outputFile.write(result + ",") oldResult = result i = i + 1 last_pose = outputFile.tell() outputFile.seek(last_pose - 1) outputFile.write("\n}") outputFile.seek(7) firstStep = outputFile.read(1) outputFile.close() Sofa.timerSetEnabled("timer_poutre_grid_CGOGN", 0) data = [firstStep] self.rootNode.sendScriptEvent('end', data) return 0
def onBeginAnimationStep(self, deltaTime): if self.opt['time']['time_profiling']: Sofa.timerSetEnabled(self.opt['time']['timer_name'], True) Sofa.timerBegin(self.opt['time']['timer_name']) self.numStep += 1 if self.numStep <= self.opt['model']['control']['nsteps']: self.actualPressure = map(sum, zip(self.actualPressure, self.opt['model']['control']['deltaPressure'])) self.pressureField.pressure = self.actualPressure print 'Setting actual pressure: ',self.actualPressure return 0