Exemplo n.º 1
0
def makeWireFromPointList(points):
    
    edges = [];
    for (p,q) in Util.ntuples(points,2,True):
        print p,q
        edges.append(OCCUtil.edgeFromTwoPoints(OCCUtil.pnt(p[0],p[1]),OCCUtil.pnt(q[0],q[1])));
    return OCCUtil.wireFromEdges(edges);
Exemplo n.º 2
0
def makeFaceWithHold():
    "creates a face with a thin feature due to a hole"
    ow = makeSquareWire(); #box 0,0 --> 5,5
    
    p1 = OCCUtil.pnt(0.4,0.4);
    p2 = OCCUtil.pnt(2.0,0.4);
    p3 = OCCUtil.pnt(2.0,2.0);
    p4 = OCCUtil.pnt(2.0,0.4);
Exemplo n.º 3
0
def makeWireFromPointList(points):

    edges = []
    for (p, q) in Util.ntuples(points, 2, True):
        print p, q
        edges.append(
            OCCUtil.edgeFromTwoPoints(OCCUtil.pnt(p[0], p[1]),
                                      OCCUtil.pnt(q[0], q[1])))
    return OCCUtil.wireFromEdges(edges)
Exemplo n.º 4
0
def makeFaceWithHold():
    "creates a face with a thin feature due to a hole"
    ow = makeSquareWire()
    #box 0,0 --> 5,5

    p1 = OCCUtil.pnt(0.4, 0.4)
    p2 = OCCUtil.pnt(2.0, 0.4)
    p3 = OCCUtil.pnt(2.0, 2.0)
    p4 = OCCUtil.pnt(2.0, 0.4)
Exemplo n.º 5
0
def makeOffsetTestWire():
    "creates difficult test cases for offsetting"
    p1 = OCCUtil.pnt(11.0,0);
    p2 = OCCUtil.pnt(7.0,8.0);
    p3 = OCCUtil.pnt(7.0,12.0);
    p4 = OCCUtil.pnt(17.0,22.0);
    p5 = OCCUtil.pnt(0.0,22.0);
    p6 = OCCUtil.pnt(3.0,17.0);
    p7 = OCCUtil.pnt(4.0,8.0 );
    c1 = OCCUtil.pnt(10.0,18.5);
    c2 = OCCUtil.pnt(6.0,3.0);
    
    edges = [];
    edges.append( OCCUtil.edgeFromTwoPoints( p1, p2 ));
    edges.append( OCCUtil.edgeFromTwoPoints( p2, p3 ));
    
    circle = GC.GC_MakeArcOfCircle(p3, c1, p4); #circle through 3 points
    e2 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle.Value()).Edge();
    edges.append(e2);
    
    edges.append( OCCUtil.edgeFromTwoPoints( p4, p5 ));
    edges.append( OCCUtil.edgeFromTwoPoints( p5, p6 ));
    edges.append( OCCUtil.edgeFromTwoPoints( p6, p7 ));

    circle = GC.GC_MakeArcOfCircle(p1, c2, p7 ); #circle through 3 points
    e3 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle.Value() ).Edge();
    edges.append(e3);

    return OCCUtil.wireFromEdges(edges);
Exemplo n.º 6
0
def makeOffsetTestWire():
    "creates difficult test cases for offsetting"
    p1 = OCCUtil.pnt(11.0, 0)
    p2 = OCCUtil.pnt(7.0, 8.0)
    p3 = OCCUtil.pnt(7.0, 12.0)
    p4 = OCCUtil.pnt(17.0, 22.0)
    p5 = OCCUtil.pnt(0.0, 22.0)
    p6 = OCCUtil.pnt(3.0, 17.0)
    p7 = OCCUtil.pnt(4.0, 8.0)
    c1 = OCCUtil.pnt(10.0, 18.5)
    c2 = OCCUtil.pnt(6.0, 3.0)

    edges = []
    edges.append(OCCUtil.edgeFromTwoPoints(p1, p2))
    edges.append(OCCUtil.edgeFromTwoPoints(p2, p3))

    circle = GC.GC_MakeArcOfCircle(p3, c1, p4)
    #circle through 3 points
    e2 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle.Value()).Edge()
    edges.append(e2)

    edges.append(OCCUtil.edgeFromTwoPoints(p4, p5))
    edges.append(OCCUtil.edgeFromTwoPoints(p5, p6))
    edges.append(OCCUtil.edgeFromTwoPoints(p6, p7))

    circle = GC.GC_MakeArcOfCircle(p1, c2, p7)
    #circle through 3 points
    e3 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle.Value()).Edge()
    edges.append(e3)

    return OCCUtil.wireFromEdges(edges)
Exemplo n.º 7
0
def makeBsplineEdge():
    pts=[]
    pts.append(OCCUtil.pnt(0.0,0));
    pts.append( OCCUtil.pnt(1.0,0.0));
    pts.append( OCCUtil.pnt(1.2,0.1));
    pts.append( OCCUtil.pnt(2.0,2.0));
    pts.append( OCCUtil.pnt(2.0,2.4));
    pts.append( OCCUtil.pnt(3.0,2.4));
    pts.append( OCCUtil.pnt(4.0,1.5 ));
    pts.append( OCCUtil.pnt(5.0,1.5 ));
    pts.append( OCCUtil.pnt(4.0,0 ));
    pts.append( OCCUtil.pnt(3.0,-0.1 ));    
    pts.append( OCCUtil.pnt(2.0,-0.1 ));
    pts.append( OCCUtil.pnt(2.0,-0.1 ));
    pts.append( OCCUtil.pnt(2.0,0.2 ));
    pts.append( OCCUtil.pnt(3.0,0.5 ));    
    pts.append( OCCUtil.pnt(3.0,1.0 ));     
            
    points = TColgp.TColgp_HArray1OfPnt(1,len(pts));
    i = 1;
    for p in pts:
        points.SetValue(i,p);
        i+=1;
    
    #q = time.clock();
    #for i in range(1000):
    gi = GeomAPI.GeomAPI_Interpolate(points.GetHandle(),False,0.001);
    gi.Perform();
    curve = gi.Curve();
    #print "1000 iters: Elapsed: %0.3f " % ( time.clock() -  q)
    
    builder = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(curve);
    return builder.Edge();
Exemplo n.º 8
0
def makeBsplineEdge():
    pts = []
    pts.append(OCCUtil.pnt(0.0, 0))
    pts.append(OCCUtil.pnt(1.0, 0.0))
    pts.append(OCCUtil.pnt(1.2, 0.1))
    pts.append(OCCUtil.pnt(2.0, 2.0))
    pts.append(OCCUtil.pnt(2.0, 2.4))
    pts.append(OCCUtil.pnt(3.0, 2.4))
    pts.append(OCCUtil.pnt(4.0, 1.5))
    pts.append(OCCUtil.pnt(5.0, 1.5))
    pts.append(OCCUtil.pnt(4.0, 0))
    pts.append(OCCUtil.pnt(3.0, -0.1))
    pts.append(OCCUtil.pnt(2.0, -0.1))
    pts.append(OCCUtil.pnt(2.0, -0.1))
    pts.append(OCCUtil.pnt(2.0, 0.2))
    pts.append(OCCUtil.pnt(3.0, 0.5))
    pts.append(OCCUtil.pnt(3.0, 1.0))

    points = TColgp.TColgp_HArray1OfPnt(1, len(pts))
    i = 1
    for p in pts:
        points.SetValue(i, p)
        i += 1

    #q = time.clock();
    #for i in range(1000):
    gi = GeomAPI.GeomAPI_Interpolate(points.GetHandle(), False, 0.001)
    gi.Perform()
    curve = gi.Curve()
    #print "1000 iters: Elapsed: %0.3f " % ( time.clock() -  q)

    builder = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(curve)
    return builder.Edge()