コード例 #1
0
 def showSolution(self, n=0):
     if self.soln:
         self.applySolution(n)
         print "Rendering solution..."
         drawBB(assemble(self.listBitblox()), grid=False)
     else:
         print "No solutions are stored!"
コード例 #2
0
def showMe(bb1, bb2, perm):
    print "Drawing " + str(len(perm)) + " arrangements..."
    bb1.reHome()
    for p in perm:
        bb2.translateTo(p[0])
        bb2.rotateTo(p[1])
        drawBB(bb1 + bb2)
        raw_input("Press enter to draw next...")
コード例 #3
0
def drawPropositions(props, p2b):
    out = []
    for bb in props:
        pos = p2b[bb]
        cop = deepcopy(pos[0])
        cop.translateTo(grid2origin(pos[1:4]))
        cop.rotateTo(pos[4])
        out = cop + out
    drawBB(out, grid=True, gridRadius=2)
コード例 #4
0
    # in positional grid units.

    ws = (1, 5, 2)

    # For now, we define corresponding Bitblox of interest explicitly, though this
    # could easily be done automatically later. It is simply a list of Bitblox object
    # pairs directly corresponding to the netlist format.

    bb = [
        bat,
        but1,
        led1,
    ]

    cbb = [
        (but1, led1),
        (bat, but1),
    ]

    cn = [
        ('B1', 'LED'),
        ('PWR', 'B2'),
    ]

    # Call the solver, which positions the Bitblox correctly.

    solve(ws, bb, cbb, cn)

    # Draw the assembly resulting from the solution.
    drawBB(assemble(bb), grid = True, gridRadius = 3)
コード例 #5
0
    ws = (3, 3, 2)

    # For now, we define corresponding Bitblox of interest explicitly, though this
    # could easily be done automatically later. It is simply a list of Bitblox object
    # pairs directly corresponding to the netlist format.

    bb = [
        bat,
        but1,
        but2,
    ]

    cbb = [
        (bat, but1),
        (bat, but2),
    ]

    cn = [
        ('PWR', 'B2'),
        ('PWR', 'B1'),
    ]

    # Call the solver, which positions the Bitblox correctly.

    solve(ws, bb, cbb, cn)

    # Draw the assembly resulting from the solution.

    drawBB(assemble(bb), grid = False, gridRadius = 3)
コード例 #6
0
        butA = But()
        butB = But()

        # A workspace is defined by a (x, y, z) tuple of available positions
        # in positional grid units. These are ranges - ie, "3" means
        # grid spots 0, 1, and 2 are made available for placement.

        ws = (2, 2, 2)

        # For now, we define corresponding Bitblox of interest explicitly, though this
        # could easily be done automatically later. It is simply a list of Bitblox object
        # pairs directly corresponding to the netlist format.

        bb = [butA, butB]

        cbb = [(butA, butB)]

        cn = [('B1', 'B1')]

        # Call the solver, which positions the Bitblox correctly.

        solve(ws, bb, cbb, cn)

        # Draw the assembly resulting from the solution.

        drawBB(butA + butB)

    except Exception, e:

        traceback.print_exc()
        pdb.post_mortem()
コード例 #7
0
# mybut.translate([1,1,1])
# interest = mybut.FGU_list[3]
# mybut.rotateAbout(interest, 1)
# print mybut.orientation
# drawBB(mybut)

led = Led()
but = But()
bat = Bat()
led.translateTo((-1, 3, 1.5))  # 1, 2, 1, 3
led.rotateTo(3)
but.translateTo((0, 4, .5))  # 2, 2, 0, 0; 2, 2, 0, 3
but.rotateTo(3)
bat.translateTo((1, 3, 1.5))  # 2, 1, 1, 0
w = newWindow()
drawBB(led)
drawBB(but)
drawBB(bat)

# matches = findMatches(but, 'B1', but2, 'B1')
# matches = findCollisions(but, but2)
# print matches
# print len(matches)
# but.reHome()
# for result in matches:
#      w = newWindow()
# #     but2.translateTo(result[0])
# #     but2.rotateTo(result[1])
#      drawBB(led)
#      drawBB(but)
#      drawBB(bat)
コード例 #8
0
# matches = findCollisions(but, but2)
# print matches
# print len(matches)
# but.reHome()
# for result in matches:
#      w = newWindow()
# #     but2.translateTo(result[0])
# #     but2.rotateTo(result[1])
#      drawBB(led)
#      drawBB(but)
#      drawBB(bat)
#     print anchor2grid(result[0])
#     print but2
#     w.waitfor('keyup')
#     w.delete()

#61, 137, 140, 192

if __name__ == '__main__':
    bat = Bat()
    but = But()
    led = Led()
    but.translateTo((1, 1, 1))
    led.translateTo((2, 2, 0))
    print origin2grid(bat.origin)
    print origin2grid(but.origin)
    print origin2grid(led.origin)
    print bat
    drawBB(bat + but + led, grid=True, gridRadius=2)
    import pdb
    pdb.set_trace()