bbox = [[-1.,-1.],[7.,6.]] mesh = nmesh.mesh(objects = [box,cone],a0=0.4, bounding_box=bbox) mesh_info=mesh.tolists() # create mesh_info lists for parts 1&2 combined and for part 2 alone [mesh_info1, mesh_info2] = viz.separate_parts(mesh_info, listOfParts=[[1,2],[2]]) # generate a VTK dataset for parts 1&2 combined vtkData, points, simplices,indices, icradii, ccradii = \ viz.mesh2vtk(mesh_info1, VTKonly=False) in2circ=viz.findRatios(icradii, ccradii, factor=2) vtkData=viz.append2vtk(vtkData, in2circ, "in2circ") vtkData=viz.append2vtk(vtkData, indices, "part indices") viz.save_vtk(vtkData, "compound_example_1.vtk") # create VTK data for part 2 alone and apply outer_skin() to it # request that only cells with two or more points on the surface are shown mesh_info2 = viz.outer_skin(mesh_info2, condition='>=2') vtkData2, points2, simplices2, indices2, icradii2, ccradii2 = \ viz.mesh2vtk(mesh_info2, VTKonly=False) in2circ2=viz.findRatios(icradii2, ccradii2, factor=2) vtkData2=viz.append2vtk(vtkData2, in2circ2, "in2circ") vtkData2=viz.append2vtk(vtkData2, indices2, "part indices") viz.save_vtk(vtkData2, "compound_example_2.vtk")
cone = nmesh.conic([3.0, 0.0], 1.0, [3.0, 4.0], 0.0) bbox = [[-2., -2.], [7., 6.]] rod = 0.4 mesh = nmesh.mesh(objects=[box, cone], a0=rod, bounding_box=bbox) mesh_info = mesh.tolists() # visualise in MayaVi, using the ratio of inradius:circumradius # as cell_data for a colour scale mesh_info2 = viz.surface_only(mesh_info) vtkData, points, simplices, indices, icradii, ccradii = viz.mesh2vtk( mesh_info2, VTKonly=False) # calculate ratio of actual:requested rod_length for surface elements rod_length2a0 = [] for i in icradii: rod_length2a0.append(i / rod) # append this as a scalar dataset and also the part indices vtkData = viz.append2vtk(vtkData, rod_length2a0, "actual/requested rod_length") vtkData = viz.append2vtk(vtkData, indices, "part indices") # display mesh from file viz.save_vtk(vtkData, 'temp.vtk') myv = viz.mesh2mayavi('temp.vtk') myv.renwin.z_plus_view() # open the data selection dialog so the user can choose between # the available scalar datasets. dvm = myv.get_current_dvm() dvm.data_src.configure()
rod=0.4 mesh=nmesh.mesh(objects=[box,cone],a0=rod,bounding_box=bbox) mesh_info=mesh.tolists() # visualise in MayaVi, using the ratio of inradius:circumradius # as cell_data for a colour scale mesh_info2 = viz.surface_only(mesh_info) vtkData, points, simplices, indices, icradii, ccradii=viz.mesh2vtk(mesh_info2, VTKonly=False) # calculate ratio of actual:requested rod_length for surface elements rod_length2a0=[] for i in icradii: rod_length2a0.append(i/rod) # append this as a scalar dataset and also the part indices vtkData=viz.append2vtk(vtkData, rod_length2a0, "actual/requested rod_length") vtkData=viz.append2vtk(vtkData, indices, "part indices") # display mesh from file viz.save_vtk(vtkData,'temp.vtk') myv = viz.mesh2mayavi('temp.vtk') myv.renwin.z_plus_view() # open the data selection dialog so the user can choose between # the available scalar datasets. dvm = myv.get_current_dvm() dvm.data_src.configure()
cone = nmesh.conic([0.0, 0.0, 0.0], 1.0, [2.0, 0.0, 0.0], 2.0) bbox = [[-4.0, -4.0, -4.0], [4.0, 4.0, 4.0]] mesh = nmesh.mesh(objects=[cone], bounding_box=bbox) mesh_info = mesh.tolists() ##add the next line to only look at surface elements # mesh_info = viz.surface_only(mesh_info) vtkData, points, simplices, indices, icradii, ccradii = viz.mesh2vtk(mesh_info, VTKonly=False) # append the point index to each point - this will be a scalar field customScalars = [] for i in range(len(points)): customScalars.append(i) # append the data to the mesh and visualise it vtkData = viz.append2vtk(vtkData, customScalars, "point indices", sites="point") viz.save_vtk(vtkData, "example_for_tf.vtk") myv = viz.mesh2mayavi("example_for_tf.vtk") # extensive customisation of MayaVi visualisation # users are encouraged to use MayaVi GUI for similar operations dvm = myv.get_current_dvm() # data-visualisation-manager mm = dvm.get_current_module_mgr() # module manager m0 = mm.get_module(0) # this is the SurfaceMap (first module) m1 = myv.load_module("Glyph", 0) # change SurfaceMap to wireframe, line_width=1.0, no scalar colouring m0.actor.GetProperty().SetRepresentationToWireframe() # .SetRepresentation(1) m0.actor.GetProperty().SetLineWidth(1.0) m0.mapper.SetScalarVisibility(0)
cone = nmesh.conic([0.0,0.0,0.0],1.0,[2.0,0.0,0.0],2.0) bbox = [[-4.,-4.,-4.0],[4.,4.,4.]] mesh = nmesh.mesh(objects = [cone], bounding_box=bbox) mesh_info=mesh.tolists() ##add the next line to only look at surface elements #mesh_info = viz.surface_only(mesh_info) vtkData, points, simplices, indices, icradii, ccradii=viz.mesh2vtk(mesh_info, VTKonly=False) # append the point index to each point - this will be a scalar field customScalars = [] for i in range(len(points)): customScalars.append(i) # append the data to the mesh and visualise it vtkData=viz.append2vtk(vtkData, customScalars, "point indices", sites='point') viz.save_vtk(vtkData, "example_for_tf.vtk") myv = viz.mesh2mayavi("example_for_tf.vtk") # extensive customisation of MayaVi visualisation # users are encouraged to use MayaVi GUI for similar operations dvm = myv.get_current_dvm() # data-visualisation-manager mm = dvm.get_current_module_mgr() # module manager m0 = mm.get_module(0) # this is the SurfaceMap (first module) m1 = myv.load_module('Glyph',0) # change SurfaceMap to wireframe, line_width=1.0, no scalar colouring m0.actor.GetProperty().SetRepresentationToWireframe() #.SetRepresentation(1) m0.actor.GetProperty().SetLineWidth(1.0) m0.mapper.SetScalarVisibility(0)