def display_mesh(the_mesh): # First, erase all display.EraseAll() # then redisplay the shape display.DisplayShape(aShape) # then the mesh aDS = SMESH_MeshVSLink(the_mesh) aMeshVS = MeshVS_Mesh(True) DMF = 1 # to wrap! aPrsBuilder = MeshVS_MeshPrsBuilder(aMeshVS.GetHandle(), DMF, aDS.GetHandle(), 0, MeshVS_BP_Mesh) aMeshVS.SetDataSource(aDS.GetHandle()) aMeshVS.AddBuilder(aPrsBuilder.GetHandle(), True) #Create the graphic window and display the mesh context = display.Context context.Display(aMeshVS.GetHandle()) context.Deactivate(aMeshVS.GetHandle()) display.FitAll()
# courtesy of Mauricio Oliveira print('Loading STL geometry ...', end='') init_time = time.time() aMesh.STLToMesh(os.path.join('..', 'assets', 'models', 'five_spoke_wheel.stl')) final_time = time.time() delta_t = final_time - init_time print('Done.') print('STL model loaded in %.2fs' % delta_t) # Data statistics print("Model statistics:") print("\tNb Nodes", aMesh.NbNodes()) print("\tNb Faces", aMesh.NbFaces()) print("\tTransfer rate: %i triangles per seconds" % (aMesh.NbFaces() / delta_t)) # Display mesh display, start_display, add_menu, add_function_to_menu = init_display() aDS = SMESH_MeshVSLink(aMesh) aMeshVS = MeshVS_Mesh(True) aPrsBuilder = MeshVS_MeshPrsBuilder(aMeshVS.GetHandle(), MeshVS_DMF_WireFrame, aDS.GetHandle(), 0, MeshVS_BP_Mesh) aMeshVS.SetDataSource(aDS.GetHandle()) aMeshVS.AddBuilder(aPrsBuilder.GetHandle(), True) context = display.Context context.Display(aMeshVS.GetHandle()) context.Deactivate(aMeshVS.GetHandle()) display.FitAll() start_display()