예제 #1
0
파일: gui.py 프로젝트: rituparnamatkar/skdb
def show_interface_arrow(self, color=None):
        tmp = self.part.transformation
        tmp2 = self.get_transformation()
        trsf1 = tmp.Multiplied(tmp2)
        arrow = Arrow(scale=5)
        arrow.transformation = trsf1
        if color:
            display.DisplayColoredShape(make_vertex(Point(0,0,0).Transformed(trsf1)), color)
            display.DisplayColoredShape(arrow.Shape(), color)
        else:
            display.DisplayShape(make_vertex(Point(0,0,0).Transformed(trsf1)))
            display.DisplayShape(arrow.Shape())
예제 #2
0
파일: gui.py 프로젝트: rituparnamatkar/skdb
def show_next_mate(event=None, mate=None):
    '''cycle through available options and display them with each keypress'''
    global opt
    display.EraseAll()
    display.DisplayColoredShape(current_brick.shapes[0], 'RED')
    conn=opts[opt]
    opt += 1
    trsf = mate_connection(conn)

    display.DisplayShape(BRepBuilderAPI_Transform(conn.interface2.part.shapes[0], trsf, True).Shape())
    display.DisplayShape(make_vertex(Point(conn.interface1.point).Transformed(trsf)))
    display.DisplayShape(make_vertex(Point(conn.interface2.point).Transformed(trsf)))
예제 #3
0
def line_arc_line_path(event=None):
    radius = 10
    mkwire = BRepBuilderAPI_MakeWire()
    print "create edges"
    for i in range(3):
        edge = BRepBuilderAPI_MakeEdge2d(random_line()).Edge()
        mkwire.Add(edge)
    wire = mkwire.Wire()
    print "create face"
    face = BRepBuilderAPI_MakeFace(wire).Face()
    fillet = BRepFilletAPI_MakeFillet2d(face)
    #print fillet.Status()
    print "explore face"
    explorer = TopExp_Explorer(face, TopAbs_VERTEX)
    i = 0
    while explorer.More():
        print "vertex: ", i
        vertex = TopoDS().Vertex(explorer.Current())
        make_vertex(BRep_Tool().Pnt(vertex))
        #help( vertex.Location().Value())
        fillet.AddFillet(vertex, radius)
        fillet.Build()
        print fillet.NbFillet()
        #print fillet.IsDone()
        #while not fillet.IsDone(): pass
        explorer.Next()
        i += 1

    display.DisplayShape([face])
    return wire
예제 #4
0
    def find_solns(TR):
        if TR.IsDone():
            NbSol = TR.NbSolutions()
            solutions = []
            for k in range(1, NbSol + 1):
                circ = TR.ThisSolution(k)
                display.DisplayShape(make_edge2d(circ))
                # find the solution circle ( index, outvalue, outvalue, gp_Pnt2d )
                pnt1 = gp_Pnt2d()
                # find the first tangent point
                parsol, pararg = TR.Tangency1(k, pnt1)  #gross
                display.DisplayShape(make_vertex(pnt1))

                pnt2 = gp_Pnt2d()
                # find the second tangent point
                parsol, pararg = TR.Tangency2(k, pnt2)
                display.DisplayShape(make_vertex(pnt2))
                solutions += (circ, pnt1, pnt2)
            return solutions
        else:
            print "TR didnt finish!"
            return
예제 #5
0
def draw_all_tangents(event=None):
    display.EraseAll()
    init_display()
    points = []
    for i in range(5):
        point = gp_Pnt2d(random.randint(0, 10), random.randint(0, 10))
        points += [point]
        make_text('P' + str(i), point, 6)
        display.DisplayShape(make_vertex(point))

    C = GCE2d_MakeArcOfCircle(points[0], points[1], points[2]).Value()
    display.DisplayShape(make_edge2d(C))
    C_gp = gce_MakeCirc2d(points[0], points[1], points[2]).Value(
    )  #ew. same thing; tangent solver wants a circle, not arc

    L = GCE2d_MakeSegment(points[3], points[4]).Value()
    #L = GccAna_Lin2d2Tan(points[3], points[4],Precision().Confusion()).ThisSolution(1)
    display.DisplayShape([make_edge2d(L)])
    L_gp = gce_MakeLin2d(points[3], points[4]).Value(
    )  #yuck. same thing; tangent solver wants a line, not segment

    tangents(C_gp, L_gp, radius=2)
예제 #6
0
def add_lego(event=None, brick=None, app=app):
    opts = None
    n = 0
    if brick is not None: brick2 = brick
    else: brick2 = get_brick()
    while True:
        i1 = app.current_brick.interfaces[random.randint(
            0,
            len(app.current_brick.interfaces) - 1)]
        opts = i1.options(brick2)
        if opts: break
        elif n > 20:
            raise OverflowError, "I can't figure it out!"  #timeout; impossible situation
        else:
            brick2 = get_brick()  #try again
        n += 1
    conn = opts[random.randint(0, len(opts) - 1)]

    #i1 = app.current_brick.interfaces[3]
    #i2 = brick2.interfaces[7]
    #conn = skdb.Connection(i1, i2)

    trsf = mate_connection(conn)
    brick2.transformation = trsf
    #brick2.shapes[0] keeps on being overwritten. what's the point of having it be a list?
    brick2.shapes[0] = BRepBuilderAPI_Transform(brick2.shapes[0], trsf,
                                                True).Shape()  #move it
    conn.interface1.show()
    print "%.2f %.2f %.2f" % Point(conn.interface1.point).Transformed(
        conn.interface1.part.transformation).Coord()
    conn.interface2.show()
    print "%.2f %.2f %.2f" % Point(conn.interface2.point).Transformed(
        conn.interface2.part.transformation).Coord()

    app.all_bricks.append(brick2)
    try:
        app.cgraph.add_part(brick2)
        naive_coincidence_fixer(app.all_bricks, cgraph=app.cgraph)
    except GayError:
        app.cgraph.del_part(brick2)
        add_lego()  #try again
    #conn.connect(cgraph=app.cgraph) #this should whine about interface busy

    brick2.AIS_handle = display.DisplayShape(brick2.shapes[0])
    app.current_brick = brick2
예제 #7
0
def random_cone(event=None):
    #p1, p2, p3, p4 = None, None, None, None #ew
    #for i in p1, p2, p3, p4:
    #i = gp_Pnt(random.uniform(0, 1), random.uniform(0, 1), random.uniform(0, 1))
    #print i.Coord()
    p1 = gp_Pnt(0, 0, 0)
    p2 = gp_Pnt(0, 0, 1)
    p3 = 1
    p4 = 2
    cone = gce_MakeCone(p1, p2, p3, p4).Value()
    cone = BRepPrimAPI_MakeCone(gp.gp().XOY(), 1, 1.1, 1)
    try:
        cone = BRepPrimAPI_MakeCone(gp.gp().XOY(), random.uniform(0, 1),
                                    random.uniform(0, 1),
                                    random.uniform(0, 1)).Shape()
        display.DisplayShape([cone])
    except RuntimeError:
        cone = random_cone()
    return cone
예제 #8
0
def draw_random_arc(event=None):
    display.DisplayShape([make_edge2d(random_arc())])
예제 #9
0
def show_bounding_box(event=None, app=app):
    brick = app.working_brick()
    displayed_shape = display.DisplayShape(
        BoundingBox(brick.shapes[0]).make_box())
    display.Context.SetTransparency(displayed_shape, 0.3)
예제 #10
0
def show_bricks():
    display.EraseAll()
    display.DisplayShape([brick.shapes[0] for brick in app.all_bricks])
예제 #11
0
def random_sweep(event=None):
    display.DisplayShape([sweep_path(line_arc_line_path(), random_cone())])
예제 #12
0
    #now pick one
    connection = valid_opts[random.randint(0, len(valid_opts) - 1)]
    trsf = mate_connection(connection)
    brick2.transformation = trsf
    brick2.shapes[0] = BRepBuilderAPI_Transform(brick2.shapes[0], trsf,
                                                True).Shape()

    #set the globals
    app.all_bricks.append(brick2)
    app.current_brick = brick2

    #visual stuff
    connection.interface1.show()
    connection.interface2.show()
    brick2.AIS_handle = display.DisplayShape(brick2.shapes[0])


def show_bounding_box(event=None, app=app):
    brick = app.working_brick()
    displayed_shape = display.DisplayShape(
        BoundingBox(brick.shapes[0]).make_box())
    display.Context.SetTransparency(displayed_shape, 0.3)


def add_lego(event=None, brick=None, app=app):
    opts = None
    n = 0
    if brick is not None: brick2 = brick
    else: brick2 = get_brick()
    while True:
예제 #13
0
    itr.Next()

ok = selector.Solve(aMap)
print "solve OK", ok

nt = TNaming.TNaming_Tool()
shape = nt.CurrentShape(selector.NamedShape())

#edge = TopoDS.TopoDS().Edge(shape)

#face = Topo(box2).faces_from_edge(edge).next()

#chamf = BRepFilletAPI.BRepFilletAPI_MakeChamfer(box2)
#chamf.Add(3,3,edge,face)

display.DisplayShape(shape)
display.DisplayShape(box2)
start_display()

import sys

sys.exit(0)

cut_tool = BRepPrimAPI.BRepPrimAPI_MakeBox(gp.gp_Pnt(6, 6, 6), 5., 5.,
                                           5.).Shape()

#tool_label = ts.NewChild(root)
#ns_builder = TNaming.TNaming_Builder(tool_label)
#ns_builder.Generated(cut_tool)
#
#topo = Topo(cut_tool)
예제 #14
0
파일: gui.py 프로젝트: rituparnamatkar/skdb
def chain_arrows(event=None):
    #a silly chain of arrows
    make_arrow(origin=gp_Pnt(0,0,1), direction=gp_Dir(1,1,1))
    display.DisplayShape(make_vertex(gp_Pnt(1,1,2)))
    s=math.sqrt(3)/3
    make_arrow(origin=gp_Pnt(s,s,s+1), direction=gp_Dir(1,1,1), text='hmm')
예제 #15
0
파일: gui.py 프로젝트: rituparnamatkar/skdb
def coordinate_arrows(event=None):
    #typical origin symbol
    display.DisplayShape(make_vertex(gp_Pnt(0,0,0)))
    for (v, c) in [[(1,0,0), 'RED'], [(0,1,0), 'GREEN'], [(0,0,1), 'BLUE']]:
        coordinate_arrow(v, c)
def get_box(event=None):
    shape_factory = xmlrpclib.ServerProxy(xmlrpc_address)
    dumped_box = shape_factory.getBox(10., 10., 10.)
    box = pickle.loads(dumped_box)
    display.DisplayShape(box)
def get_sphere(event=None):
    shape_factory = xmlrpclib.ServerProxy(xmlrpc_address)
    dumped_sphere = shape_factory.getSphere(50.)
    sphere = pickle.loads(dumped_sphere)
    display.DisplayShape(sphere)
예제 #18
0
import os
os.environ['CSF_GraphicShr'] = r"/usr/local/lib/libTKOpenGl.so"

from OCC.Display.wxSamplesGui import display, start_display

from raytrace.step_export import make_interp_parabola

para = make_interp_parabola(12.5, 5.0, 15.0, segments=20)

display.DisplayShape(para)

start_display()