Ejemplo n.º 1
0
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()
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
# 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()