Esempio n. 1
0
import subprocess
import struct
import sys
from evtk.hl import pointsToVTK
from evtk.hl import unstructuredGridToVTK
from evtk.vtk import VtkTriangle
from evtk.vtk import VtkTetra
import read_write as rw  # read_write.py
import utils as ut  # utils.py

###########################################################################
# main program
###########################################################################

#  NOTE: one-based indexing
print("read basic mesh, write vtu's")
mesh_names = subprocess.check_output("ls 4sim*.bin", shell=True).split()
mesh_names = [s.decode("utf-8") for s in mesh_names]  # bytes -> string
for mesh in mesh_names:
    fname = mesh.split('.')[0]
    print(fname[-4])
    sys.stdout.flush()
    verts, tris, tets = rw.read_basic_bin(fname)
    rw.write_points("nodes_" + fname, verts)
    rw.write_tris("surface_" + fname, verts,
                  tris + 1)  # change to one based indexing
    rw.write_tets("elements_" + fname, verts, tets + 1)  #

###########################################################################
###########################################################################
Esempio n. 2
0
###################################
IMAGE_SIZE_XY = 1024.0
IMAGE_SIZE_Z = 26.0
ACTUAL_XY = 80.0
ACTUAL_STEP_Z = 2.0
ACTUAL_GLYPH = 3.0

###################
SCALE_X = ACTUAL_XY / IMAGE_SIZE_XY
SCALE_Y = SCALE_X
SCALE_Z = ACTUAL_STEP_Z

###########################################################################
# main program
###########################################################################

fname = 'points'

verts = rw.get_points(fname + '.txt')
print(verts)

verts[:, 0] *= SCALE_X
verts[:, 1] *= SCALE_Y
verts[:, 2] *= SCALE_Z
print(verts)

rw.write_points(fname, verts)

#rw.write_tris("basal_"+fname, lverts[i], ltris[i][btrisi-1]) # has all the verts
#rw.write_tets("elements_"+fname, lverts[i], ltets[i], data={"dfa" : ldfa_tet[i], "dfb" : dfb})
Esempio n. 3
0
        nverts)  # get the integer and fractional part of all nverts

    # iterate through rvertsi and store the vert that is closest to each (integer) grid point
    for i in rvertsi:
        dist = np.linalg.norm(ifverts[0][i])
        vgridi = (ifverts[1][i]).astype(
            int)  # grid index is simply the vertex location integer part
        if dist > 0.5:  # don't bother with grid points that have no close vertex
            continue
        noise = 0.3 * np.random.ranf(
        )  # some spatial dithering to break up an aligned visual
        dist += noise

        # is this vertex closest to the grid point?
        if dist < vgrid[vgridi[0]][vgridi[1]][vgridi[2]][0]:
            vgrid[vgridi[0]][vgridi[1]][
                vgridi[2]][0] = dist  # store the new closer distance
            vgrid[vgridi[0]][vgridi[1]][
                vgridi[2]][1] = i  # update the associated vertex index

    # extract the close vertex indices
    cvi = vgrid[:, :, :, 1]
    cvi = np.extract(cvi < toohigh, cvi)
    print "Vertex count reduction:", verts.shape[0], "->", cvi.shape[0]

    rw.write_points("reduced-nodes_" + fname, verts[cvi.astype(int)])
    rw.write_indicies("reduced-indices_" + fname, cvi)

###########################################################################
###########################################################################
Esempio n. 4
0
print("read mesh, calc dnl/apical/dfa, write nodes/surface/apical")
lsegs = rw.read_lumen()
mesh_names = subprocess.check_output("ls *.msh", shell=True).split()
mesh_names = [s.decode("utf-8") for s in mesh_names]  # bytes -> string
for mesh in mesh_names:
    fname = mesh.split('.')[0]
    print(fname[-4], end='')
    sys.stdout.flush()
    verts, tris, tets = rw.read_mesh(fname)
    dnl = ut.get_dnl(tris, verts, lsegs)
    atrisiS, atrisiL = ut.get_apical(tris, dnl, APICAL_SMALL, APICAL_LARGE)
    dfa_vert, dfa_tet = ut.get_dfa(atrisiS, tris, verts, tets)
    ldfa_vert.append(dfa_vert)
    ldfa_tet.append(dfa_tet)
    rw.write_points("nodes_" + fname, verts, pdata={"dfa": dfa_vert})
    rw.write_tris("surface_" + fname, verts, tris, data={"dnl": dnl})
    rw.write_tris("apical_" + fname, verts,
                  tris[atrisiS - 1])  # has all the verts
    lverts.append(verts)
    ltris.append(tris)
    ltets.append(tets)
    latrisiS.append(atrisiS)
    latrisiL.append(atrisiL)

print("\ncalc/write common")
ncells = len(mesh_names)
for c1 in range(ncells):
    ctrisi = np.empty((3, 0), dtype=int)  # common tri indices per cell
    for c2 in range(ncells):
        if (c1 == c2): continue