Esempio n. 1
0
def read_mesh_from_h5(h5file, outputfilename):
    f=tables.openFile(h5file)
    
    points = f.root.mesh['points'][0].tolist()
    simplices = f.root.mesh['simplices'][0].tolist()
    simplicesregions = f.root.mesh['sregions'][0].tolist()

    mesh = nmesh.mesh_from_points_and_simplices(points,simplices,simplicesregions)

    mesh.save(outputfilename,directory='.')
Esempio n. 2
0
    m2.mapper.SetScalarVisibility(0)
    m2.renwin.Render()
    dvm = v.get_current_dvm()
    mm = dvm.get_current_module_mgr()
    luthandler = mm.get_scalar_lut_handler()
    luthandler.set_lut_red_blue()
    luthandler.sc_bar.SetVisibility(1)
    luthandler.sc_bar.GetTitleTextProperty().SetShadow(1)
    luthandler.sc_bar.GetLabelTextProperty().SetShadow(1)
    globals()['v'].renwin.z_plus_view()  # this line will reduce fluidity
    v.Render()
    raw_input()

#--------------------------------------------------------------
#                    MAIN file
#--------------------------------------------------------------

filename = "cube+sph.stl"

from subprocess import Popen, PIPE
print Popen(["bunzip2", "-k", filename+".bz2"], stdout=PIPE).communicate()[0]

points,simplices_indices,simplices_regions = ReadMeshFromNetgenNeutral(filename)

the_mesh = nmesh.mesh_from_points_and_simplices(points = points,
                                                simplices_indices = simplices_indices,
                                                simplices_regions = simplices_regions,
                                                initial = 1)

visualise_mesh(the_mesh)
Esempio n. 3
0
def test_nmeshmirror():
    os.chdir(os.path.split(__file__)[0])

    #define my non-periodic mesh

    points = [[0,0],[1,0],[0,1],[1,1]]

    simplices = [[0,2,3],[0,1,3]]

    regions=[1,1]

    import nmesh

    mesh = nmesh.mesh_from_points_and_simplices(points,simplices,regions,[],0,False)

    mesh.save('org.nmesh')

    import nmesh.visual
    nmesh.visual.plot2d_ps(mesh,'org.ps')

    # mirror along the x axis (horizontal direction)
    command = "%s org.nmesh 1e-6 1e-6 1,0 mirror1.nmesh" % nmeshmirror_exec

    status = os.system(command)

    assert status==0, "after command '%s' status is %s" % (command,status)

    periodicmesh = nmesh.load('mirror1.nmesh')

    nmesh.visual.plot2d_ps(periodicmesh,'mirror1.ps')

    for i in range(4):
        assert mesh.points[i] == periodicmesh.points[i], \
            "org/mirror1, point %i differs: %s %s" % \
            (i,mesh.points[i],periodicmesh.points[i])

    assert [2.0, 0.0] in periodicmesh.points," [2.0, 0.0] not in periodic points"
    assert [2.0, 1.0] in periodicmesh.points," [2.0, 1.0] not in periodic points"

    command = "%s org.nmesh 1e-6 1e-6 -1,0 mirror2.nmesh" % nmeshmirror_exec

    status = os.system(command)

    assert status==0, "after command '%s' status is %s" % (command,status)

    periodicmesh = nmesh.load('mirror2.nmesh')

    nmesh.visual.plot2d_ps(periodicmesh,'mirror2.ps')

    for i in range(4):
        assert mesh.points[i] == periodicmesh.points[i], \
            "org/mirror2, point %i differs: %s %s" % \
            (i,mesh.points[i],periodicmesh.points[i])

    assert [-1.0, 0.0] in periodicmesh.points," [-1.0, 0.0] not in periodic points"
    assert [-1.0, 1.0] in periodicmesh.points," [-1.0, 1.0] not in periodic points"

    # mirror along the y axis (vertical direction)
    command = "%s org.nmesh 1e-6 1e-6 0,1 mirror3.nmesh" % nmeshmirror_exec

    status = os.system(command)

    assert status==0, "after command '%s' status is %s" % (command,status)

    periodicmesh = nmesh.load('mirror3.nmesh')

    nmesh.visual.plot2d_ps(periodicmesh,'mirror3.ps')

    for i in range(4):
        assert mesh.points[i] == periodicmesh.points[i], \
            "org/mirror3, point %i differs: %s %s" % \
            (i,mesh.points[i],periodicmesh.points[i])

    assert [0.0, 2.0] in periodicmesh.points," [0.0, 2.0] not in periodic points"
    assert [1.0, 2.0] in periodicmesh.points," [1.0, 2.0] not in periodic points"


    # mirror along the x and y axis (horizontal and vertical directions)
    command = "%s org.nmesh 1e-6 1e-6 1,1 mirror4.nmesh" % nmeshmirror_exec

    status = os.system(command)

    assert status==0, "after command '%s' status is %s" % (command,status)

    periodicmesh = nmesh.load('mirror4.nmesh')

    nmesh.visual.plot2d_ps(periodicmesh,'mirror4.ps')

    for i in range(4):
        assert mesh.points[i] == periodicmesh.points[i], \
            "org/mirror4, point %i differs: %s %s" % \
            (i,mesh.points[i],periodicmesh.points[i])

    assert [2.0, 0.0] in periodicmesh.points," [2.0, 0.0] not in periodic points"
    assert [2.0, 1.0] in periodicmesh.points," [2.0, 1.0] not in periodic points"
    assert [0.0, 2.0] in periodicmesh.points," [0.0, 2.0] not in periodic points"
    assert [1.0, 2.0] in periodicmesh.points," [1.0, 2.0] not in periodic points"



    os.chdir(org_dir)
Esempio n. 4
0
    mm = dvm.get_current_module_mgr()
    luthandler = mm.get_scalar_lut_handler()
    luthandler.set_lut_red_blue()
    luthandler.sc_bar.SetVisibility(1)
    luthandler.sc_bar.GetTitleTextProperty().SetShadow(1)
    luthandler.sc_bar.GetLabelTextProperty().SetShadow(1)
    globals()['v'].renwin.z_plus_view()  # this line will reduce fluidity
    v.Render()
    raw_input()


#--------------------------------------------------------------
#                    MAIN file
#--------------------------------------------------------------

filename = "cube+sph.stl"

from subprocess import Popen, PIPE
print Popen(["bunzip2", "-k", filename + ".bz2"], stdout=PIPE).communicate()[0]

points, simplices_indices, simplices_regions = ReadMeshFromNetgenNeutral(
    filename)

the_mesh = nmesh.mesh_from_points_and_simplices(
    points=points,
    simplices_indices=simplices_indices,
    simplices_regions=simplices_regions,
    initial=1)

visualise_mesh(the_mesh)