def createScene(rootNode): # Import Original Scene with the animation added # Here we use a wrapper (MORWrapper) that will allow us (with MORreplace) # to modify the initial scene and get informations on its structures # For more details on the process involved additionnal doc are with : # - mor.wrapper.MORWrapper # - mor.script.sceneCreationUtility phase1_snapshots.createScene(Wrapper(rootNode, replaceAndSave.MORreplace, paramWrapper)) # Add MOR plugin if not found u.addPlugin(rootNode,"ModelOrderReduction") # Save connectivity list that will allow us after work only on the necessary elements if phase == phaseToSave: u.saveElements(rootNode,rootNode.dt,replaceAndSave.forcefield) param['paramMappedMatrixMapping']['saveReducedMass'] = True # Modify the scene to perform hyper-reduction according # to the informations collected by the wrapper u.modifyGraphScene(rootNode,nbrOfModes,paramWrapper) # We Update the link for path , item in replaceAndSave.pathToUpdate.iteritems(): data , newValue = item obj = get(rootNode,path) setattr(obj,data,newValue)
def createScene(rootNode): print( "This Scene will crash : it is NORMAL\n\ Its purpose is only to save the scene (thanks to MORWrapper)\n\ To create the package with it afterward") # Import Original Scene # Here we use a wrapper (MORWrapper) that will allow us (with MORreplace) # to modify the initial scene and get informations on its structures # For more details on the process involved additionnal doc are with : # - mor.wrapper.MORWrapper # - mor.script.sceneCreationUtility originalScene.createScene(Wrapper(rootNode, replaceAndSave.MORreplace, paramWrapper)) # 1 # Add MOR plugin if not found u.addPlugin(rootNode,"ModelOrderReduction") pluginName = [] plugins = u.searchObjectClassInGraphScene(rootNode,"RequiredPlugin") for plugin in plugins: pluginName.append(plugin.pluginName) # Modify the scene to perform hyper-reduction according # to the informations collected by the wrapper u.modifyGraphScene(rootNode,nbrOfModes,paramWrapper,save=True) # 2 # We collect all the informations during 1 & 2 to be able to create with # writeGraphScene a SOFA scene containing only our reduced model that we can instanciate # as a whole component with differents usefull argument (translation/rotation/color...) # For more details on the process involved additionnal doc are with : # - mor.wrapper.writeScene if packageName: myMORModel = replaceAndSave.myMORModel myModel = replaceAndSave.myModel nodeName = paramWrapper[0][0].split('/')[-1] writeScene.writeHeader(packageName,nbrOfModes) modelTransform = writeScene.writeGraphScene(packageName,nodeName,myMORModel,myModel) writeScene.writeFooter(packageName,nodeName,modelTransform,pluginName,rootNode.dt,rootNode.gravity[0])