コード例 #1
0
bigpar = np.zeros((d * len(parents)), dtype=np.float32)

print bigpar.shape

off = 0
offpar = 0
poslen = len(pos)
parlen = len(parents)

for i in range(d):
    pos2 = pos.copy()
    # spread in xy plane
    pos2[:, 0] = pos2[:, 0] + (randn() - 0.5) * s
    pos2[:, 1] = pos2[:, 1] + (randn() - 0.5) * s

    bigpos[off:off + poslen, :] = pos2.copy()
    bigpar[offpar:offpar + parlen] = parents + off

    print "offset", off
    print bigpos
    print "bigpar,", bigpar[offpar:offpar + parlen]

    off += poslen
    offpar += parlen
    # create an globaltopology array

treeregion = TreeRegion(vertices=pos2, connectivity=parents)
window.add_actor_to_world(treeregion)

fos.run()
コード例 #2
0
ファイル: treedemo2.py プロジェクト: arokem/Fos
mycpt = "Treedemo - Fos.me"
try:
    # Try and create a window with multisampling (antialiasing)
    config = Config(sample_buffers=1, samples=4, depth_size=16, double_buffer=True)
    window = Window(
        resizable=True, config=config, vsync=False, width=1000, height=800, caption=mycpt
    )  # "vsync=False" to check the framerate
except fos.lib.pyglet.window.NoSuchConfigException:
    # Fall back to no multisampling for old hardware
    print "fallback"
    window = Window(resizable=True, caption=mycpt)

ac = []
s = 500
# tune it up
# this is very inefficient, because it copies the position arrays
for i in range(1000):
    pos2 = pos.copy()
    pos2[:, 0] = pos2[:, 0] + (randn() - 0.5) * s
    pos2[:, 1] = pos2[:, 1] + (randn() - 0.5) * s
    # random width array
    # wid = np.random.randn(1, 5, (len(pos2),) )
    wid = np.random.rand(len(pos2)) * 2
    ac.append(Tree(vertices=pos2, connectivity=parents, colors=colors, vertices_width=wid))

for e in ac:
    window.add_actor_to_world(e)

fos.run()
コード例 #3
0
# node positions
pos = np.array( [ [0,0,0], [10,10,10] ], dtype = np.float32)
siz = np.array( [ [1.0, 1.0 ]], dtype = np.float32 )
col = np.array( [ [255,0,0,255],
                  [0,255,0,255]], dtype = np.ubyte)
edg = np.array( [ [0,1]], dtype = np.uint32 )

aff = np.eye(4, dtype = np.float32)
aff[:3,3] = [0,0,0]

nlabs = {0 : { 'label'  : 'Node 1',
               'size'   : 20,
               'font'   : 'Times New Roman',
               'color'  : ( 255, 0, 0, 255 ) },
              1 : { 'label' : 'Node 2'}
              }

cu = AttributeNetwork(affine = aff,
                      node_position = pos,
                      node_size = siz,
                      node_color = col,
                      node_label = nlabs,
                      edge_connectivity = edg)

wi.add_actor_to_world(cu)
run()

#cu.start()
#w.delete(cu)