Пример #1
0
def TestWireJoiner():
    wire = TestObjects.makeOffsetTestWire()
    conditions = []

    #each test condition is two points, representing an edge
    #that was drawn last.
    #in these tests, the red curve is the trimmed one, and the green is the original.
    #the yellow markers on the leadin edges and the joining segment is closer to the end

    #in each case, the solution found should minimize overlap and trim the other edge
    #as necessary.

    conditions.append((gp.gp_Pnt(11.2, 1.0, 0), gp.gp_Pnt(11.2, 0.0, 0)))
    conditions.append((gp.gp_Pnt(11.2, -1.0, 0), gp.gp_Pnt(11.2, 0.0, 0)))
    conditions.append((gp.gp_Pnt(15.2, 0.0, 0), gp.gp_Pnt(11.2, 0.0, 0)))
    conditions.append((gp.gp_Pnt(11.2, -3.0, 0), gp.gp_Pnt(11.2, -1.0, 0)))
    conditions.append((gp.gp_Pnt(20.2, 19.0, 0), gp.gp_Pnt(20.2, 20.0, 0)))
    conditions.append((gp.gp_Pnt(30.2, 25.0, 0), gp.gp_Pnt(20.2, 20.0, 0)))

    for (startPoint, endPoint) in conditions:
        display.EraseAll()
        display.DisplayColoredShape(wire, 'GREEN')
        initVector = OCCUtil.edgeFromTwoPoints(startPoint, endPoint)
        display.DisplayColoredShape(
            OCCUtil.edgeFromTwoPoints(startPoint, endPoint), 'BLUE')
        display.DisplayColoredShape(TestObjects.makeEdgeIndicator(initVector))
        vec = gp.gp_Vec(startPoint, endPoint)
        jrequest = JointRequest(endPoint, vec, 0.8, wire)
        wj = WireJoiner(jrequest, 4.0)
        #this is a huge tolerance, but helps for testing
        solution = wj.build()
        display.DisplayColoredShape(solution.wire, 'RED')
        entryEdge = OCCUtil.edgeFromTwoPoints(endPoint, solution.entryPoint)
        display.DisplayColoredShape(TestObjects.makeEdgeIndicator(entryEdge))
        if solution.isJoint:
            display.DisplayColoredShape(entryEdge, 'WHITE')
        else:
            display.DisplayColoredShape(entryEdge, 'YELLOW')
        time.sleep(5)
Пример #2
0
def TestWireJoiner():
    wire = TestObjects.makeOffsetTestWire()
    conditions = []

    # each test condition is two points, representing an edge
    # that was drawn last.
    # in these tests, the red curve is the trimmed one, and the green is the original.
    # the yellow markers on the leadin edges and the joining segment is closer to the end

    # in each case, the solution found should minimize overlap and trim the other edge
    # as necessary.

    conditions.append((gp.gp_Pnt(11.2, 1.0, 0), gp.gp_Pnt(11.2, 0.0, 0)))
    conditions.append((gp.gp_Pnt(11.2, -1.0, 0), gp.gp_Pnt(11.2, 0.0, 0)))
    conditions.append((gp.gp_Pnt(15.2, 0.0, 0), gp.gp_Pnt(11.2, 0.0, 0)))
    conditions.append((gp.gp_Pnt(11.2, -3.0, 0), gp.gp_Pnt(11.2, -1.0, 0)))
    conditions.append((gp.gp_Pnt(20.2, 19.0, 0), gp.gp_Pnt(20.2, 20.0, 0)))
    conditions.append((gp.gp_Pnt(30.2, 25.0, 0), gp.gp_Pnt(20.2, 20.0, 0)))

    for (startPoint, endPoint) in conditions:
        display.EraseAll()
        display.DisplayColoredShape(wire, "GREEN")
        initVector = OCCUtil.edgeFromTwoPoints(startPoint, endPoint)
        display.DisplayColoredShape(OCCUtil.edgeFromTwoPoints(startPoint, endPoint), "BLUE")
        display.DisplayColoredShape(TestObjects.makeEdgeIndicator(initVector))
        vec = gp.gp_Vec(startPoint, endPoint)
        jrequest = JointRequest(endPoint, vec, 0.8, wire)
        wj = WireJoiner(jrequest, 4.0)
        # this is a huge tolerance, but helps for testing
        solution = wj.build()
        display.DisplayColoredShape(solution.wire, "RED")
        entryEdge = OCCUtil.edgeFromTwoPoints(endPoint, solution.entryPoint)
        display.DisplayColoredShape(TestObjects.makeEdgeIndicator(entryEdge))
        if solution.isJoint:
            display.DisplayColoredShape(entryEdge, "WHITE")
        else:
            display.DisplayColoredShape(entryEdge, "YELLOW")
        time.sleep(5)
Пример #3
0
def TestTrimmedWire():
    # test triming a wire
    #this will select each vertex of the heart.
    square = TestObjects.makeOffsetTestWire()
    conditions = []

    #each test condition is two points, representing an edge
    #that was drawn last.

    conditions.append((gp.gp_Pnt(11.2, 1.0, 0), gp.gp_Pnt(11.2, 0.0, 0)))
    conditions.append((gp.gp_Pnt(11.2, -1.0, 0), gp.gp_Pnt(11.2, 0.0, 0)))

    for (startPoint, endPoint) in conditions:
        display.EraseAll()
        display.DisplayColoredShape(square, 'GREEN')
        display.DisplayColoredShape(edgeFromTwoPoints(startPoint, endPoint),
                                    'YELLOW')

        vec = gp.gp_Vec(startPoint, endPoint)
        (w2, edge, p2, newVec) = getTrimmedWire(square, vec, endPoint, 0.1)
        display.DisplayColoredShape(w2, 'RED')
        display.DisplayColoredShape(make_vertex(p2), 'RED')
        time.sleep(5)
Пример #4
0
def TestTrimmedWire():
    # test triming a wire
    #this will select each vertex of the heart.
    square = TestObjects.makeOffsetTestWire();
    conditions= [];
    
    #each test condition is two points, representing an edge
    #that was drawn last.
    

    conditions.append((gp.gp_Pnt(11.2,1.0,0),gp.gp_Pnt(11.2,0.0,0)) );
    conditions.append((gp.gp_Pnt(11.2,-1.0,0),gp.gp_Pnt(11.2,0.0,0)) );
    
    for (startPoint,endPoint) in conditions:
        display.EraseAll();
        display.DisplayColoredShape(square, 'GREEN');
        display.DisplayColoredShape(edgeFromTwoPoints(startPoint,endPoint),'YELLOW');
               
        vec = gp.gp_Vec(startPoint,endPoint);
        (w2,edge,p2,newVec) = getTrimmedWire(square,vec,endPoint,0.1);
        display.DisplayColoredShape(w2,'RED');
        display.DisplayColoredShape(make_vertex(p2),'RED');
        time.sleep(5);