Esempio n. 1
0
sys.path.append("/home/jonathan/Programing/Python/SpiNNer")

import diagram

from model import board
from model import coordinates
from model import transforms
from model import topology

d = diagram.Diagram()

# Create a small system of boards on a hexagonal coordinate system
boards = board.create_torus(4, 4)
boards = transforms.hex_to_cartesian(boards)
boards = transforms.rhombus_to_rect(boards)
#boards = transforms.compress(boards)
boards = transforms.space_folds(boards, (4, 2), (0.7, 1))
#boards = transforms.fold(boards, (2,1))

# Create a dictionary which maps boards to coordinates to use for labelling
# boards in the diagram.
board2coord = dict(boards)

# Draw the boards on the diagram as a hexagons
for b, coords in boards:
    d.add_board_hexagon(b, coords)

    #for direction, colour in ( (topology.NORTH,      "red")
    #                         , (topology.NORTH_EAST, "green")
    #                         , (topology.EAST,       "blue")):
import sys
sys.path.append("/home/jonathan/Programing/Python/SpiNNer")

import diagram

from model import board
from model import coordinates
from model import transforms
from model import topology

d = diagram.Diagram()

# Create a small system of boards on a hexagonal coordinate system
boards = board.create_torus(4,4)
boards = transforms.hex_to_cartesian(boards)
boards = transforms.rhombus_to_rect(boards)
boards = transforms.compress(boards)
#boards = transforms.space_folds(boards, (4,2), (0.7,1))
boards = transforms.fold(boards, (4,2))

# Create a dictionary which maps boards to coordinates to use for labelling
# boards in the diagram.
board2coord = dict(boards)

# Draw the boards on the diagram as a hexagons
for b, coords in boards:
	d.add_board_square(b, coords)
	
	for direction, colour in ( (topology.NORTH,      "red")
	                         , (topology.NORTH_EAST, "green")
	                         , (topology.EAST,       "blue")):
Esempio n. 3
0
		rack_spacing = rack_spacing,
		rack_offset  = rack_offset,
	),
	num_cabinets    = num_cabinets,
	cabinet_spacing = cabinet_spacing,
)

# Create an inter-linked torus
torus = board.create_torus(width, height)

# Convert to Cartesian coordinates as the coming manipulations use/abuse this
cart_torus = transforms.hex_to_cartesian(torus)

# Cut the left-hand side of the torus off and move it to the right to form a
# rectangle
rect_torus = transforms.rhombus_to_rect(cart_torus)

# Compress the coordinates to eliminate the "wavy" pattern on the y-axis turning
# the board coordinates into a continuous mesh.
comp_torus = transforms.compress(rect_torus, 1 if compress_rows else 2
                                           , 2 if compress_rows else 1
                                           )

# Show where the folds will occur
fold_spaced_torus = transforms.space_folds(comp_torus, (num_folds_x, num_folds_y))

# Actually do the folds
folded_torus = transforms.fold(comp_torus, (num_folds_x, num_folds_y))

# Place spaces in the folded version to see how it folded
folded_spaced_torus = transforms.space_folds(folded_torus, (num_folds_x, num_folds_y))