예제 #1
0
#     try:
#         x[c] = rs.seg2cell[s.y - 1]
#     except:
#         x[c] = -1

y = np.zeros(x.shape[0])
for i in range(0, x.shape[0]):
   y[i] = i % 2 if x[i] >= 0 else i % 2 - 2  #

for i in range(0, x.shape[0]):
   x[i] = x[i] if x[i] >= 0 else -1

ana = pb.SegmentAnalyser(r.rs)
ana.addData("linear_index", x)  # node data are converted to segment data
ana.addData("zebra", y)
pd = vp.segs_to_polydata(ana, 1., ["radius", "subType", "creationTime", "linear_index", "zebra"])
rootActor, rootCBar = vp.plot_roots(pd, "zebra", False)

""" Mesh """
width_ = max_ - min_
ind_ = res_ / width_
print("min    ", min_)
print("max    ", max_)
print("width  ", width_)
print("cuboids", 1 / ind_)
grid = vp.uniform_grid(min_, max_, res_)
meshActor, meshCBar = vp.plot_mesh(grid, "", "", False)

vp.render_window([meshActor, rootActor], "Test mapping", rootCBar).Start()

예제 #2
0
def vector_3d(a):
    return pb.Vector3d(a[0], a[1], a[2])


""" root problem """
r = XylemFluxPython("RootSystem.rsml")  # returns a MappedSegments object
segs = r.rs.segments

nodes = r.rs.nodes
for i in range(0, len(nodes)):
    nodes[i] = vector_3d(np.array(nodes[i]) / 100.)
r.rs.nodes = nodes
""" Mixed plot """
ana = pb.SegmentAnalyser(r.rs)
pd = vp.segs_to_polydata(ana, 1.e-2, ["radius", "subType", "creationTime"])
print("Root system bounds", pd.GetBounds())
rootActor, rootCBar = vp.plot_roots(pd, "creationTime", False)

ug = vp.read_vtu("benchmark3d_2-00001.vtu")
print("Mesh bounds", ug.GetBounds())
meshActor, meshCBar = vp.plot_mesh(
    ug, "water content", "",
    False)  # "pressure head"  # e.g. "S_liq" "water content"

vp.render_window([rootActor, meshActor], "mixed fun", meshCBar).Start()

# # Plot, using vtk
# rootActor, cBar = vp.plot_roots(rs, "creationTime", False)
# rootActor.RotateX(90) # to look at it from top
# vp.render_window(rootActor,"top view", cBar).Start()
예제 #3
0
import sys
sys.path.append("../../../..")

# from xylem_flux import XylemFluxPython  # Python hybrid solver
# import plantbox as pb
# import rsml_reader as rsml
import vtk_plot as vp

# from math import *
# import numpy as np
# import matplotlib.pyplot as plt

#
# def vector_3d(a):
#     return pb.Vector3d(a[0], a[1], a[2])
""" 
Tests if we manage to plot a mesh
"""

ug = vp.read_vtu("benchmark3d_2-00001.vtu")
vp.plot_mesh(ug, "water content",
             "Mesh")  # "pressure head, "S_liq" "water content"
# vp.plot_mesh_cuts(ug, p_name)

# p         write png (added it)
# s         as solid (built in default)
# w         as wireframe (built in default)