Пример #1
0
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")


# display in MayaVi, reverse LUT and open slider bar to choose between datasets
myv = viz.mesh2mayavi("compound_example_1.vtk",lut_range=(0,1))
Пример #2
0
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()
Пример #3
0
# define a simple mesh and submit request to mesher (include outer box)
box = nmesh.box([0.0, 0.0], [1.0, 1.0])
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_bounding_box=True)
mesh_info = mesh.tolists()

# visualise in MayaVi, using the ratio of 2*inradius:circumradius
# as cell_data for a colour scale
mesh_info = viz.surface_only(mesh_info)
vtkData = viz.mesh2vtk(mesh_info)
viz.save_vtk(vtkData, "outerbox_bug_1.vtk")

########### NOW DO THE SAME, BUT WITHOUT THE OUTER BOX ################

# define a simple mesh and submit request to mesher
box = nmesh.box([0.0, 0.0], [1.0, 1.0])
cone = nmesh.conic([3.0, 0.0], 1.0, [3.0, 4.0], 0.0)
bbox = [[-2., -2.], [7., 6.]]
rod = 0.4
mesh2 = nmesh.mesh(objects=[box, cone], a0=rod, bounding_box=bbox)
mesh_info2 = mesh2.tolists()

# visualise in MayaVi, using the ratio of 2*inradius:circumradius
# as cell_data for a colour scale
mesh_info2 = viz.surface_only(mesh_info2)
vtkData2 = viz.mesh2vtk(mesh_info2)
Пример #4
0
# define a simple mesh and submit request to mesher
box=nmesh.box( [0.0,0.0], [1.0,1.0] )
cone=nmesh.conic([3.0,0.0],1.0,[3.0,4.0],0.0)
bbox=[[-1.,-1.],[7.,6.]]
mesh=nmesh.mesh(objects=[box,cone],a0=0.4,bounding_box=bbox)
mesh_info=mesh.tolists()

# separate the triangle and square into different VTK datasets
[mesh_info1, mesh_info2] = viz.separate_parts(mesh_info, listOfParts=[(1,),(2,)])

# calculate inradius/circumradius and append part indices to vtk dataset1
vtkData, points, simplices, indices, icradii, ccradii=viz.mesh2vtk(mesh_info1,VTKonly=False)
in2circ=viz.findRatios(icradii, ccradii, factor=2)
vtkData=viz.append2vtk(vtkData, indices, "part indices")
vtkData=viz.append2vtk(vtkData, in2circ, "in2circ")
viz.save_vtk(vtkData, "temp_1.vtk")

# calculate inradius/circumradius and append part indices to vtk dataset2
vtkData2, points2, simplices2, indices2, icradii2, ccradii2=viz.mesh2vtk(mesh_info2,VTKonly=False)
in2circ2=viz.findRatios(icradii2, ccradii2, factor=2)
vtkData2=viz.append2vtk(vtkData2, indices2, "part indices")
vtkData2=viz.append2vtk(vtkData2, in2circ2, "in2circ")
viz.save_vtk(vtkData2, filename="temp_2.vtk")

# display the data in MayaVi and open the 'Configure Data' dialog
myv = viz.mesh2mayavi(input="temp_2.vtk")
myv.renwin.z_plus_view()
dvm = myv.get_current_dvm()
dvm.data_src.configure()

Пример #5
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)
m0.renwin.Render()
Пример #6
0

# define a simple mesh and submit request to mesher (include outer box)
box = nmesh.box([0.0, 0.0], [1.0, 1.0])
cone = nmesh.conic([3.0, 0.0], 1.0, [3.0, 4.0], 0.0)
bbox = [[-2.0, -2.0], [7.0, 6.0]]
rod = 0.4
mesh = nmesh.mesh(objects=[box, cone], a0=rod, bounding_box=bbox, mesh_bounding_box=True)
mesh_info = mesh.tolists()


# visualise in MayaVi, using the ratio of 2*inradius:circumradius
# as cell_data for a colour scale
mesh_info = viz.surface_only(mesh_info)
vtkData = viz.mesh2vtk(mesh_info)
viz.save_vtk(vtkData, "outerbox_bug_1.vtk")


########### NOW DO THE SAME, BUT WITHOUT THE OUTER BOX ################


# define a simple mesh and submit request to mesher
box = nmesh.box([0.0, 0.0], [1.0, 1.0])
cone = nmesh.conic([3.0, 0.0], 1.0, [3.0, 4.0], 0.0)
bbox = [[-2.0, -2.0], [7.0, 6.0]]
rod = 0.4
mesh2 = nmesh.mesh(objects=[box, cone], a0=rod, bounding_box=bbox)
mesh_info2 = mesh2.tolists()


# visualise in MayaVi, using the ratio of 2*inradius:circumradius
Пример #7
0
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()




Пример #8
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)
m0.renwin.Render()