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, DMF, aDS, 0, MeshVS_BP_Mesh) aMeshVS.SetDataSource(aDS) aMeshVS.AddBuilder(aPrsBuilder, True) #Create the graphic window and display the mesh context = display.Context context.Display(aMeshVS) context.Deactivate(aMeshVS) display.FitAll()
def display_mesh(self, mesh, mode=2): """ Display a mesh. :param mesh: The mesh. :type mesh: OCC.Core.SMESH_SMESH_Mesh or OCC.Core.SMESH_SMESH_subMesh :param int mode: Display mode for mesh elements (1=wireframe, 2=solid). :return: The MeshVS_Mesh created for the mesh. :rtype: OCC.Core.MeshVS.MeshVS_Mesh """ vs_link = SMESH_MeshVSLink(mesh) mesh_vs = MeshVS_Mesh() mesh_vs.SetDataSource(vs_link) prs_builder = MeshVS_MeshPrsBuilder(mesh_vs) mesh_vs.AddBuilder(prs_builder) mesh_vs_drawer = mesh_vs.GetDrawer() mesh_vs_drawer.SetBoolean(MeshVS_DA_DisplayNodes, False) mesh_vs_drawer.SetColor(MeshVS_DA_EdgeColor, self._black) mesh_vs.SetDisplayMode(mode) self._my_context.Display(mesh_vs, True) return mesh_vs
# Calculate mesh aMesh.ShapeToMesh(aShape) # Assign hyptothesis to mesh aMesh.AddHypothesis(aShape, 0) aMesh.AddHypothesis(aShape, 1) aMesh.AddHypothesis(aShape, 2) aMesh.AddHypothesis(aShape, 3) aMesh.AddHypothesis(aShape, 4) print('Done.') # Compute the data print('Computing mesh ...', end='') aMeshGen.Compute(aMesh, aMesh.GetShapeToMesh()) print('Done.') print(aMesh.NbNodes()) # Display the data aDS = SMESH_MeshVSLink(aMesh) aMeshVS = MeshVS_Mesh(True) DMF = 1 # to wrap! MeshVS_BP_Mesh = 5 # To wrap! aPrsBuilder = MeshVS_MeshPrsBuilder(aMeshVS, DMF, aDS, 0, MeshVS_BP_Mesh) aMeshVS.SetDataSource(aDS) aMeshVS.AddBuilder(aPrsBuilder, True) context = display.Context context.Display(aMeshVS) context.Deactivate(aMeshVS) display.FitAll() start_display()
# 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()
aBuilder->SetTextureCoords (aScaleMap); aMesh->AddBuilder (aBuilder, true); """ # from matplotlib import (_path, artist, cbook, cm, colors as mcolors, docstring, # lines as mlines, path as mpath, transforms) #from matplotlib.collections import Collection display, start_display, add_menu, add_function_to_menu = init_display() myBox = BRepPrimAPI_MakeBox(60, 60, 50).Shape() view = display.View colorscale = view.ColorScale() aMesh = MeshVS_Mesh() builder = MeshVS_NodalColorPrsBuilder(aMesh) a_cm = Aspect_SequenceOfColor() a_cm.Append(Quantity_Color()) #a_cm.Append(Quantity_NOC_BLUE1) a_cl = TColStd_DataMapOfIntegerReal(10) for i in range(10 + 1): a_cl.Bind(i + 1, i) builder.SetColorMap(a_cm) builder.SetTextureCoords(a_cl) #builder.SetInvalidColor(Quantity_NOC_BLACK) aMesh.AddBuilder(builder, True)