Commit 9c47e9f0 authored by sfritschi's avatar sfritschi
Browse files

Now visualizing generated network

parent 9960e37b
......@@ -15,7 +15,7 @@ def main():
print("Min. number of throats per pore: %d" % min(pore_throat_counts))
print("Avg. number of throats per pore: %f" % (sum(pore_throat_counts) / len(pore_throat_counts)))
target = [3, 3, 3]
target = [2, 2, 2]
cutoff = 0.5 * max([basenet.ub[i] - basenet.lb[i] \
for i in range(len(basenet.ub))])
......
......@@ -13,7 +13,8 @@ def coord_transform(pos: List[float], lb: float, ub: float):
return np.array(list(map(transform, pos)))
def main():
basenet = netflow.load_network_from("../netflow/network/network.h5")
dendro = netflow.load_network_from("network/dendro.h5")
# Setup GUI
vis = o3d.visualization.VisualizerWithKeyCallback()
vis.create_window()
......@@ -36,7 +37,7 @@ def main():
magenta = np.array([1.0, 0.0, 1.0])
n_zero_radius = 0
for i, pore in enumerate(basenet.pores):
for i, pore in enumerate(dendro.pores):
radius = .6e4 * pore.r
if pore.r < 1e-6:
n_zero_radius += 1
......@@ -54,16 +55,16 @@ def main():
sphere.paint_uniform_color(magenta)
"""
sphere.paint_uniform_color(blue)
pos = coord_transform(pore.pos, basenet.lb[0], basenet.ub[0])
pos = coord_transform(pore.pos, dendro.lb[0], dendro.ub[0])
sphere.translate(pos)
vis.add_geometry(sphere)
print("Did not render %d/%d pores because of too small radius" % (n_zero_radius, len(basenet.pores)))
print("Did not render %d/%d pores because of too small radius" % (n_zero_radius, len(dendro.pores)))
n = 500 # Upper limit of throats to render
n = 400 # Upper limit of throats to render
n_zero_radius = 0
for i, throat in enumerate(basenet.throats):
for i, throat in enumerate(dendro.throats):
if i == n:
break
radius = .4e4 * throat.r
......@@ -71,9 +72,9 @@ def main():
n_zero_radius += 1
continue
x1, x2 = netflow.throat_ends(throat,
[ub-lb for lb,ub in zip(basenet.lb,basenet.ub)])
x1_t = coord_transform(x1, basenet.lb[0], basenet.ub[0])
x2_t = coord_transform(x2, basenet.lb[0], basenet.ub[0])
[ub-lb for lb,ub in zip(dendro.lb,dendro.ub)])
x1_t = coord_transform(x1, dendro.lb[0], dendro.ub[0])
x2_t = coord_transform(x2, dendro.lb[0], dendro.ub[0])
height = np.linalg.norm(x1_t - x2_t)
cylinder = o3d.geometry.TriangleMesh.create_cylinder(radius=radius, height=height, resolution=8, split=4)
cylinder.paint_uniform_color(red)
......@@ -94,7 +95,7 @@ def main():
vis.add_geometry(cylinder)
print("Did not render %d/%d throats because of too small radius" % (n_zero_radius, len(basenet.throats)))
print("Did not render %d/%d throats because of too small radius" % (n_zero_radius, n))
while True:
if not vis.poll_events():
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment