コード例 #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
ファイル: example6a_mapping.py プロジェクト: mvdcvp/CPlantBox
                      True)  # cut and map segments
""" add segment indices """
segs = rs.segments
x = np.zeros(len(segs))
for i, s in enumerate(segs):
    try:
        x[i] = rs.seg2cell[i]
    except:  # in case the segment is not within the domain
        x[i] = -1
""" infos on a specific cell"""
ci = rs.soil_index(0, 0, -7)
print("Cell at [0,0,-7] has index", ci)
try:
    print(len(rs.cell2seg[ci]), "segments in this cell:")
    print(rs.cell2seg[ci])
except:
    print("There are no segments in this cell")
""" vizualise roots """
# ana = pb.SegmentAnalyser(rs)  # <---- wrong!
ana = pb.SegmentAnalyser(rs.mappedSegments())
ana.addData("linear_index", x)
pd = vp.segs_to_polydata(ana, 1.,
                         ["radius", "subType", "creationTime", "linear_index"])
rootActor, rootCBar = vp.plot_roots(pd, "linear_index", "segment index plot",
                                    False)
"""  vizualise soil  """
grid = vp.uniform_grid(min_, max_, res_)  # for visualization
meshActor, meshCBar = vp.plot_mesh(grid, "", "", False)
vp.render_window([meshActor, rootActor], "Test mapping", rootCBar,
                 grid.GetBounds()).Start()