Esempio n. 1
0
def makeHeartWire():
	"make a heart wire"
	e1 = Wrappers.edgeFromTwoPoints(gp.gp_Pnt(0,0,0), gp.gp_Pnt(4.0,4.0,0));
	circle = gp.gp_Circ(gp.gp_Ax2(gp.gp_Pnt(2,4,0),gp.gp().DZ()),2);
	e2 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle, gp.gp_Pnt(4,4,0),gp.gp_Pnt(0,4,0)).Edge();
	circle = gp.gp_Circ(gp.gp_Ax2(gp.gp_Pnt(-2,4,0),gp.gp().DZ()),2);
	e3 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle, gp.gp_Pnt(0,4,0),gp.gp_Pnt(-4,4,0)).Edge();
	e4 = Wrappers.edgeFromTwoPoints(gp.gp_Pnt(-4,4,0), gp.gp_Pnt(0,0,0));
	return Wrappers.wireFromEdges([e1,e2,e3,e4]);
Esempio n. 2
0
def makeHeartWire():
    "make a heart wire"
    e1 = Wrappers.edgeFromTwoPoints(gp.gp_Pnt(0, 0, 0), gp.gp_Pnt(4.0, 4.0, 0))
    circle = gp.gp_Circ(gp.gp_Ax2(gp.gp_Pnt(2, 4, 0),
                                  gp.gp().DZ()), 2)
    e2 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle, gp.gp_Pnt(4, 4, 0),
                                                gp.gp_Pnt(0, 4, 0)).Edge()
    circle = gp.gp_Circ(gp.gp_Ax2(gp.gp_Pnt(-2, 4, 0),
                                  gp.gp().DZ()), 2)
    e3 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle, gp.gp_Pnt(0, 4, 0),
                                                gp.gp_Pnt(-4, 4, 0)).Edge()
    e4 = Wrappers.edgeFromTwoPoints(gp.gp_Pnt(-4, 4, 0), gp.gp_Pnt(0, 0, 0))
    return Wrappers.wireFromEdges([e1, e2, e3, e4])
def through_sections():
    #ruled
    circle_1 = gp_Circ(gp_Ax2(gp_Pnt(-100., 0., -100.), gp_Dir(0., 0., 1.)), 40.)
    wire_1 = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_1).Edge()).Wire()
    circle_2 = gp_Circ(gp_Ax2(gp_Pnt(-10., 0., -0.), gp_Dir(0., 0., 1.)), 40.)
    wire_2 = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_2).Edge()).Wire()
    circle_3 = gp_Circ(gp_Ax2(gp_Pnt(-75., 0., 100.), gp_Dir(0., 0., 1.)), 40.)
    wire_3 = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_3).Edge()).Wire()
    circle_4 = gp_Circ(gp_Ax2(gp_Pnt(0., 0., 200.), gp_Dir(0., 0., 1.)), 40.)
    wire_4 = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_4).Edge()).Wire()

    generatorA = BRepOffsetAPI_ThruSections(False, True)
    map(generatorA.AddWire, [wire_1, wire_2, wire_3, wire_4])
    generatorA.Build()
    display.DisplayShape(generatorA.Shape())

    #smooth
    circle_1b = gp_Circ(gp_Ax2(gp_Pnt(100., 0., -100.), gp_Dir(0., 0., 1.)), 40.)
    wire_1b = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_1b).Edge()).Wire()
    circle_2b = gp_Circ(gp_Ax2(gp_Pnt(210., 0., -0.), gp_Dir(0., 0., 1.)), 40.)
    wire_2b = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_2b).Edge()).Wire()
    circle_3b = gp_Circ(gp_Ax2(gp_Pnt(275., 0., 100.), gp_Dir(0., 0., 1.)), 40.)
    wire_3b = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_3b).Edge()).Wire()
    circle_4b = gp_Circ(gp_Ax2(gp_Pnt(200., 0., 200.), gp_Dir(0., 0., 1.)), 40.)
    wire_4b = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_4b).Edge()).Wire()
    generatorB = BRepOffsetAPI_ThruSections(True, False)
    map(generatorB.AddWire, [wire_1b, wire_2b, wire_3b, wire_4b])
    generatorB.Build()
    display.DisplayShape(generatorB.Shape(), update=True)
Esempio n. 4
0
    def createEdges(self):
        
        edges= []
        # Join points a,b
        edge = make_edge(getGpPt(self.a), getGpPt(self.b))
        edges.append(edge)
        # # Join points b1 and b2
        # cirl = gp_Circ(gp_Ax2(getGpPt(self.o1), getGpDir(self.wDir)), self.R1)
        # edge = make_edge(cirl,getGpPt(self.b2), getGpPt(self.b1))
        # edges.append(edge)
        # Join points b and c2
        edge = make_edge(getGpPt(self.b), getGpPt(self.c2))
        edges.append(edge)
        # join points c2 and c1
        cirl2 = gp_Circ(gp_Ax2(getGpPt(self.o2), getGpDir(self.wDir)), self.R1)
        edge = make_edge(cirl2, getGpPt(self.c1), getGpPt(self.c2))
        edges.append(edge)
        # Join points c1 and d
        edge = make_edge(getGpPt(self.c1), getGpPt(self.d))
        edges.append(edge)
        # Join points d and a
        edge = make_edge(getGpPt(self.d), getGpPt(self.a))
        edges.append(edge)

          
        return edges
Esempio n. 5
0
    def createEdges(self):

        edges = []
        # Join points a,b
        edge = make_edge(getGpPt(self.a), getGpPt(self.b))
        edges.append(edge)
        # # Join points b1 and b2
        # cirl = gp_Circ(gp_Ax2(getGpPt(self.o1), getGpDir(self.wDir)), self.R1)
        # edge = make_edge(cirl,getGpPt(self.b2), getGpPt(self.b1))
        # edges.append(edge)
        # Join points b and c2
        edge = make_edge(getGpPt(self.b), getGpPt(self.c2))
        edges.append(edge)
        # join points c2 and c1
        cirl2 = gp_Circ(gp_Ax2(getGpPt(self.o2), getGpDir(self.wDir)), self.R1)
        edge = make_edge(cirl2, getGpPt(self.c1), getGpPt(self.c2))
        edges.append(edge)
        # Join points c1 and d
        edge = make_edge(getGpPt(self.c1), getGpPt(self.d))
        edges.append(edge)
        # Join points d and a
        edge = make_edge(getGpPt(self.d), getGpPt(self.a))
        edges.append(edge)

        return edges
def pipe_fillet(radius):
    # the points
    p1 = gp_Pnt(0, 0, 0)
    p2 = gp_Pnt(0, 1, 0)
    p3 = gp_Pnt(1, 2, 0)
    p4 = gp_Pnt(2, 2, 0)
    # the edges
    ed1 = BRepBuilderAPI_MakeEdge(p1, p2).Edge()
    ed2 = BRepBuilderAPI_MakeEdge(p2, p3).Edge()
    ed3 = BRepBuilderAPI_MakeEdge(p3, p4).Edge()
    # inbetween
    fillet12 = filletEdges(ed1, ed2)
    fillet23 = filletEdges(ed2, ed3)
    # the wire
    makeWire = BRepBuilderAPI_MakeWire()
    makeWire.Add(ed1)
    makeWire.Add(fillet12)
    makeWire.Add(ed2)
    makeWire.Add(fillet23)
    makeWire.Add(ed3)
    makeWire.Build()
    wire = makeWire.Wire()
    # the pipe
    dir = gp_Dir(0, 1, 0)
    circle = gp_Circ(gp_Ax2(p1, dir), radius)
    profile_edge = BRepBuilderAPI_MakeEdge(circle).Edge()
    profile_wire = BRepBuilderAPI_MakeWire(profile_edge).Wire()
    profile_face = BRepBuilderAPI_MakeFace(profile_wire).Face()
    pipe = BRepOffsetAPI_MakePipe(wire, profile_face).Shape()
    #display.DisplayShape(pipe, update=True)
    return (pipe)
Esempio n. 7
0
 def create_shape(self):
     attrs = self.element.attrib
     cx = parse_unit(attrs.get('cx', 0))
     cy = parse_unit(attrs.get('cy', 0))
     r = parse_unit(attrs.get('r', 0))
     circle = gp_Circ(gp_Ax2(gp_Pnt(cx, cy, 0), Z_DIR), r)
     return BRepBuilderAPI_MakeEdge(circle).Edge()
Esempio n. 8
0
def pipe(event=None):
  CurvePoles = TColgp_Array1OfPnt(1,6)
  pt1 = gp_Pnt(0.,0.,0.);
  pt2 = gp_Pnt(20.,50.,0.);
  pt3 = gp_Pnt(60.,100.,0.);
  pt4 = gp_Pnt(150.,0.,0.);
  CurvePoles.SetValue(1, pt1)
  CurvePoles.SetValue(2, pt2)
  CurvePoles.SetValue(3, pt3)
  CurvePoles.SetValue(4, pt4)

  curve = Geom_BezierCurve(CurvePoles)
  print type(curve)
  E = BRepBuilderAPI_MakeEdge(curve.GetHandle()).Edge()
  W = BRepBuilderAPI_MakeWire(E).Wire()
   
  #ais1 = AIS_Shape(W)
  #self.interactive_context.Display(ais1,1)
   
  c = gp_Circ(gp_Ax2(gp_Pnt(0.,0.,0.),gp_Dir(0.,1.,0.)),10.)
  Ec = BRepBuilderAPI_MakeEdge(c).Edge()
  Wc = BRepBuilderAPI_MakeWire(Ec).Wire()

  #ais3 = AIS_Shape(Wc)
  #self.interactive_context.Display(ais3,1)
   
  F = BRepBuilderAPI_MakeFace(gp_Pln(gp_Ax3(gp.gp().ZOX())),Wc,1).Face()
  MKPipe = BRepOffsetAPI_MakePipe(W,F)
  MKPipe.Build()
  display.DisplayShape(MKPipe.Shape())
Esempio n. 9
0
 def update_shape(self, change):
     d = self.declaration
     points = [c.shape for c in self.children()]
     if d.radius:
         circle = gp_Circ(d.axis, d.radius)
         sense = True
         if len(points) == 2:
             arc = GC_MakeArcOfCircle(circle, points[0], points[1],
                                      sense).Value()
             self.make_edge(arc)
         elif len(points) == 1:
             arc = GC_MakeArcOfCircle(circle, d.alpha1, points[0],
                                      sense).Value()
             self.make_edge(arc)
         else:
             arc = GC_MakeArcOfCircle(circle, d.alpha1, d.alpha2,
                                      sense).Value()
             self.make_edge(arc)
     elif len(points) == 3:
         if not points[0].IsEqual(points[2], d.tolerance):
             arc = GC_MakeArcOfCircle(points[0], points[1],
                                      points[2]).Value()
             self.make_edge(arc)
     else:
         raise ValueError("Could not create an Arc with the given children "
                          "and parameters. Must be given one of:\n\t"
                          "- three points\n\t"
                          "- radius and 2 points\n\t"
                          "- radius, alpha1 and one point\n\t"
                          "- raidus, alpha1 and alpha2")
Esempio n. 10
0
def wire_sweep_circle(ct1, ct2):
    '''
    input
        c1:     gp_Pnt
        c2:     gp_Pnt
    output
        w:      TopoDS_Wire
    '''
    center = DRAIN_RCS.Location()
    vec = DRAIN_RCS.Direction()

    radius = center.Distance(ct1)

    pt1 = gp_Pnt(ct1.XYZ())
    pt2 = gp_Pnt(ct1.XYZ())
    pt3 = gp_Pnt(ct2.XYZ())
    pt4 = gp_Pnt(ct2.XYZ())

    vec1 = gp_Vec(ct1, center)
    vec1.Normalize()
    vec2 = gp_Vec(ct2, center)
    vec2.Normalize()

    pt1.Translate(vec1 * DRAIN_S)
    pt2.Translate(-vec1 * DRAIN_S)
    pt3.Translate(vec2 * DRAIN_S)
    pt4.Translate(-vec2 * DRAIN_S)

    cir1 = gp_Circ(gp_Ax2(ct1, vec), DRAIN_S)
    ed1 = BRepBuilderAPI_MakeEdge(
        GC_MakeArcOfCircle(cir1, pt1, pt2, True).Value()).Edge()

    cir2 = gp_Circ(gp_Ax2(center, vec), radius + DRAIN_S)
    ed2 = BRepBuilderAPI_MakeEdge(
        GC_MakeArcOfCircle(cir2, pt2, pt4, False).Value()).Edge()

    cir3 = gp_Circ(gp_Ax2(ct2, vec), DRAIN_S)
    ed3 = BRepBuilderAPI_MakeEdge(
        GC_MakeArcOfCircle(cir3, pt4, pt3, True).Value()).Edge()

    cir4 = gp_Circ(gp_Ax2(center, vec), radius - DRAIN_S)
    ed4 = BRepBuilderAPI_MakeEdge(
        GC_MakeArcOfCircle(cir4, pt1, pt3, False).Value()).Edge()

    wire = BRepBuilderAPI_MakeWire(ed1, ed2, ed3, ed4).Wire()

    return wire
Esempio n. 11
0
def makeCircleWire():
    "designed to be include inside the square to simulate an island"
    
    circle = gp.gp_Circ(gp.gp_Ax2(gp.gp_Pnt(2,2,0),gp.gp().DZ()),1);
    e1 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle).Edge();
    mw = BRepBuilderAPI.BRepBuilderAPI_MakeWire();
    mw.Add(e1);
    return mw.Wire();   
Esempio n. 12
0
def makeCircleWire():
    "designed to be include inside the square to simulate an island"

    circle = gp.gp_Circ(gp.gp_Ax2(gp.gp_Pnt(2, 2, 0),
                                  gp.gp().DZ()), 1)
    e1 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle).Edge()
    mw = BRepBuilderAPI.BRepBuilderAPI_MakeWire()
    mw.Add(e1)
    return mw.Wire()
Esempio n. 13
0
def make_circle(pnt, radius):
    '''
    returns an edge
    @param pnt:
    @param radius:
    '''
    circ = gp_Circ()
    circ.SetLocation(pnt)
    circ.SetRadius(radius)
    return make_edge(circ)
Esempio n. 14
0
def make_circle(pnt, radius):
    """
    returns an edge
    @param pnt:
    @param radius:
    """
    circ = gp_Circ()
    circ.SetLocation(pnt)
    circ.SetRadius(radius)
    return make_edge(circ)
Esempio n. 15
0
def wire_circle():
    '''
        standard circle on XY plane, centered at origin, with radius 1

    output
        w:     TopoDS_Wire
    '''
    circ = gp_Circ(DRAIN_RCS, 1.0)
    edge = BRepBuilderAPI_MakeEdge(circ, 0., 2 * pi).Edge()
    wire = BRepBuilderAPI_MakeWire(edge).Wire()

    return wire
Esempio n. 16
0
def compute_minimal_distance_between_circles():
    """ compute the minimal distance between 2 circles

    here the minimal distance overlaps the intersection of the circles
    the points are rendered to indicate the locations

    """
    # required for precise rendering of the circles
    display.Context.SetDeviationCoefficient(0.0001)
    L = gp_Pnt(4, 10, 0)
    M = gp_Pnt(10, 16, 0)

    Laxis = gp_Ax2()
    Maxis = gp_Ax2()
    Laxis.SetLocation(L)
    Maxis.SetLocation(M)

    r1 = 12.0
    r2 = 15.0
    Lcircle = gp_Circ(Laxis, r1)
    Mcircle = gp_Circ(Maxis, r2)

    l_circle, m_circle = make_edge(Lcircle), make_edge(Mcircle)
    display.DisplayShape((l_circle, m_circle))

    # compute the minimal distance between 2 circles
    # the minimal distance here matches the intersection of the circles
    dss = BRepExtrema_DistShapeShape(l_circle, m_circle)

    print("intersection parameters on l_circle:",
          [dss.ParOnEdgeS1(i) for i in range(1,
                                             dss.NbSolution() + 1)])
    print("intersection parameters on m_circle:",
          [dss.ParOnEdgeS2(i) for i in range(1,
                                             dss.NbSolution() + 1)])

    for i in range(1, dss.NbSolution() + 1):
        pnt = dss.PointOnShape1(i)
        display.DisplayShape(make_vertex(pnt))
Esempio n. 17
0
def through_sections():
    #ruled
    circle_1 = gp_Circ(gp_Ax2(gp_Pnt(-100., 0., -100.), gp_Dir(0., 0., 1.)),
                       40.)
    wire_1 = BRepBuilderAPI_MakeWire(
        BRepBuilderAPI_MakeEdge(circle_1).Edge()).Wire()
    circle_2 = gp_Circ(gp_Ax2(gp_Pnt(-10., 0., -0.), gp_Dir(0., 0., 1.)), 40.)
    wire_2 = BRepBuilderAPI_MakeWire(
        BRepBuilderAPI_MakeEdge(circle_2).Edge()).Wire()
    circle_3 = gp_Circ(gp_Ax2(gp_Pnt(-75., 0., 100.), gp_Dir(0., 0., 1.)), 40.)
    wire_3 = BRepBuilderAPI_MakeWire(
        BRepBuilderAPI_MakeEdge(circle_3).Edge()).Wire()
    circle_4 = gp_Circ(gp_Ax2(gp_Pnt(0., 0., 200.), gp_Dir(0., 0., 1.)), 40.)
    wire_4 = BRepBuilderAPI_MakeWire(
        BRepBuilderAPI_MakeEdge(circle_4).Edge()).Wire()

    generatorA = BRepOffsetAPI_ThruSections(False, True)
    # the use of the map function fails at producing the ThruSection
    # on py3k. Why ?
    # map(generatorA.AddWire, [wire_1, wire_2, wire_3, wire_4])
    # we have to use a loop
    for wir in [wire_1, wire_2, wire_3, wire_4]:
        generatorA.AddWire(wir)
    generatorA.Build()
    display.DisplayShape(generatorA.Shape())

    #smooth
    circle_1b = gp_Circ(gp_Ax2(gp_Pnt(100., 0., -100.), gp_Dir(0., 0., 1.)),
                        40.)
    wire_1b = BRepBuilderAPI_MakeWire(
        BRepBuilderAPI_MakeEdge(circle_1b).Edge()).Wire()
    circle_2b = gp_Circ(gp_Ax2(gp_Pnt(210., 0., -0.), gp_Dir(0., 0., 1.)), 40.)
    wire_2b = BRepBuilderAPI_MakeWire(
        BRepBuilderAPI_MakeEdge(circle_2b).Edge()).Wire()
    circle_3b = gp_Circ(gp_Ax2(gp_Pnt(275., 0., 100.), gp_Dir(0., 0., 1.)),
                        40.)
    wire_3b = BRepBuilderAPI_MakeWire(
        BRepBuilderAPI_MakeEdge(circle_3b).Edge()).Wire()
    circle_4b = gp_Circ(gp_Ax2(gp_Pnt(200., 0., 200.), gp_Dir(0., 0., 1.)),
                        40.)
    wire_4b = BRepBuilderAPI_MakeWire(
        BRepBuilderAPI_MakeEdge(circle_4b).Edge()).Wire()
    generatorB = BRepOffsetAPI_ThruSections(True, False)
    # same here, the following line fails
    # map(generatorB.AddWire, [wire_1b, wire_2b, wire_3b, wire_4b])
    for wir in [wire_1b, wire_2b, wire_3b, wire_4b]:
        generatorB.AddWire(wir)
    generatorB.Build()
    display.DisplayShape(generatorB.Shape(), update=True)
Esempio n. 18
0
def makeSquareWithRoundHole():
    
    points = [ (0,0),(0.05,-1.0),(1.0,0),(2.0,0),(2.0,6.0),(0.0,6.0) ];
    ow = makeWireFromPointList(points);

    circle = gp.gp_Circ(gp.gp_Ax2(gp.gp_Pnt(1.0,2,0),gp.gp().DZ()),0.75);
    e1 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle).Edge();
    mw = BRepBuilderAPI.BRepBuilderAPI_MakeWire();
    mw.Add(e1);
    circle = mw.Wire();
    builder = BRepBuilderAPI.BRepBuilderAPI_MakeFace(ow,True);
    builder.Add(circle);
    return builder.Face();         
Esempio n. 19
0
def makeSquareWithRoundHole():

    points = [(0, 0), (0.05, -1.0), (1.0, 0), (2.0, 0), (2.0, 6.0), (0.0, 6.0)]
    ow = makeWireFromPointList(points)

    circle = gp.gp_Circ(gp.gp_Ax2(gp.gp_Pnt(1.0, 2, 0),
                                  gp.gp().DZ()), 0.75)
    e1 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle).Edge()
    mw = BRepBuilderAPI.BRepBuilderAPI_MakeWire()
    mw.Add(e1)
    circle = mw.Wire()
    builder = BRepBuilderAPI.BRepBuilderAPI_MakeFace(ow, True)
    builder.Add(circle)
    return builder.Face()
Esempio n. 20
0
def makeKeyHoleWire():
    circle2 = gp.gp_Circ(gp.gp_Ax2(gp.gp_Pnt(40,40,2),gp.gp_Dir(0,0,1)),10)
    Edge4 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle2,gp.gp_Pnt(40,50,2),gp.gp_Pnt(50,40,2)).Edge()
    ExistingWire2 = BRepBuilderAPI.BRepBuilderAPI_MakeWire(Edge4).Wire()
    P1 = gp.gp_Pnt(50,40,2)
    P2 = gp.gp_Pnt(80,40,2) #5,204,0
    Edge5 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(P1,P2).Edge()
    MW = BRepBuilderAPI.BRepBuilderAPI_MakeWire()
    MW.Add(Edge5)
    MW.Add(ExistingWire2)

    if MW.IsDone():
        WhiteWire = MW.Wire()
        return [WhiteWire,Edge5,ExistingWire2];    
def compute_minimal_distance_between_circles():
    """ compute the minimal distance between 2 circles

    here the minimal distance overlaps the intersection of the circles
    the points are rendered to indicate the locations

    """
    # required for precise rendering of the circles
    display.Context.SetDeviationCoefficient(0.0001)
    L = gp_Pnt(4, 10, 0)
    M = gp_Pnt(10, 16, 0)

    Laxis = gp_Ax2()
    Maxis = gp_Ax2()
    Laxis.SetLocation(L)
    Maxis.SetLocation(M)

    r1 = 12.0
    r2 = 15.0
    Lcircle = gp_Circ(Laxis, r1)
    Mcircle = gp_Circ(Maxis, r2)

    l_circle, m_circle = make_edge(Lcircle), make_edge(Mcircle)
    display.DisplayShape((l_circle, m_circle))

    # compute the minimal distance between 2 circles
    # the minimal distance here matches the intersection of the circles
    dss = BRepExtrema_DistShapeShape(l_circle, m_circle)

    print("intersection parameters on l_circle:",
          [dss.ParOnEdgeS1(i) for i in range(1, dss.NbSolution() + 1)])
    print("intersection parameters on m_circle:",
          [dss.ParOnEdgeS2(i) for i in range(1, dss.NbSolution() + 1)])

    for i in range(1, dss.NbSolution() + 1):
        pnt = dss.PointOnShape1(i)
        display.DisplayShape(make_vertex(pnt))
def pipe(point1, point2, radius):
    makeWire = BRepBuilderAPI_MakeWire()
    edge = BRepBuilderAPI_MakeEdge(point1, point2).Edge()
    makeWire.Add(edge)
    makeWire.Build()
    wire = makeWire.Wire()

    dir = gp_Dir(point2.X() - point1.X(),
                 point2.Y() - point1.Y(),
                 point2.Z() - point1.Z())
    circle = gp_Circ(gp_Ax2(point1, dir), radius)
    profile_edge = BRepBuilderAPI_MakeEdge(circle).Edge()
    profile_wire = BRepBuilderAPI_MakeWire(profile_edge).Wire()
    profile_face = BRepBuilderAPI_MakeFace(profile_wire).Face()
    pipe = BRepOffsetAPI_MakePipe(wire, profile_face).Shape()
    return (pipe)
Esempio n. 23
0
def face():

    #The brown face
    circle = gp_Circ(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)), 80)
    Edge1 = BRepBuilderAPI_MakeEdge(circle, 0, math.pi)
    Edge2 = BRepBuilderAPI_MakeEdge(gp_Pnt(0, 0, -80), gp_Pnt(0, -10, 40))
    Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(0, -10.00001, 40), gp_Pnt(0, 0, 80))

    ##TopoDS_Wire YellowWire
    MW1 = BRepBuilderAPI_MakeWire(Edge1.Edge(), Edge2.Edge(), Edge3.Edge())

    print MW1.IsDone()
    
    if MW1.IsDone():
        yellow_wire = MW1.Wire()
    brown_face = BRepBuilderAPI_MakeFace(yellow_wire)
	
    display.DisplayColoredShape(brown_face.Face(), 'BLUE')
Esempio n. 24
0
def makeKeyHoleWire():
    circle2 = gp.gp_Circ(gp.gp_Ax2(gp.gp_Pnt(40, 40, 2), gp.gp_Dir(0, 0, 1)),
                         10)
    Edge4 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle2,
                                                   gp.gp_Pnt(40, 50, 2),
                                                   gp.gp_Pnt(50, 40,
                                                             2)).Edge()
    ExistingWire2 = BRepBuilderAPI.BRepBuilderAPI_MakeWire(Edge4).Wire()
    P1 = gp.gp_Pnt(50, 40, 2)
    P2 = gp.gp_Pnt(80, 40, 2)  #5,204,0
    Edge5 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(P1, P2).Edge()
    MW = BRepBuilderAPI.BRepBuilderAPI_MakeWire()
    MW.Add(Edge5)
    MW.Add(ExistingWire2)

    if MW.IsDone():
        WhiteWire = MW.Wire()
        return [WhiteWire, Edge5, ExistingWire2]
Esempio n. 25
0
def through_sections():
    #ruled
    circle_1 = gp_Circ(gp_Ax2(gp_Pnt(-100., 0., -100.), gp_Dir(0., 0., 1.)),
                       40.)
    wire_1 = BRepBuilderAPI_MakeWire(
        BRepBuilderAPI_MakeEdge(circle_1).Edge()).Wire()
    circle_2 = gp_Circ(gp_Ax2(gp_Pnt(-10., 0., -0.), gp_Dir(0., 0., 1.)), 40.)
    wire_2 = BRepBuilderAPI_MakeWire(
        BRepBuilderAPI_MakeEdge(circle_2).Edge()).Wire()
    circle_3 = gp_Circ(gp_Ax2(gp_Pnt(-75., 0., 100.), gp_Dir(0., 0., 1.)), 40.)
    wire_3 = BRepBuilderAPI_MakeWire(
        BRepBuilderAPI_MakeEdge(circle_3).Edge()).Wire()
    circle_4 = gp_Circ(gp_Ax2(gp_Pnt(0., 0., 200.), gp_Dir(0., 0., 1.)), 40.)
    wire_4 = BRepBuilderAPI_MakeWire(
        BRepBuilderAPI_MakeEdge(circle_4).Edge()).Wire()

    generatorA = BRepOffsetAPI_ThruSections(False, True)
    [generatorA.AddWire(w) for w in [wire_1, wire_2, wire_3, wire_4]]
    generatorA.Build()
    display.DisplayShape(generatorA.Shape())

    # smooth
    circle_1b = gp_Circ(gp_Ax2(gp_Pnt(100., 0., -100.), gp_Dir(0., 0., 1.)),
                        40.)
    wire_1b = BRepBuilderAPI_MakeWire(
        BRepBuilderAPI_MakeEdge(circle_1b).Edge()).Wire()
    circle_2b = gp_Circ(gp_Ax2(gp_Pnt(210., 0., -0.), gp_Dir(0., 0., 1.)), 40.)
    wire_2b = BRepBuilderAPI_MakeWire(
        BRepBuilderAPI_MakeEdge(circle_2b).Edge()).Wire()
    circle_3b = gp_Circ(gp_Ax2(gp_Pnt(275., 0., 100.), gp_Dir(0., 0., 1.)),
                        40.)
    wire_3b = BRepBuilderAPI_MakeWire(
        BRepBuilderAPI_MakeEdge(circle_3b).Edge()).Wire()
    circle_4b = gp_Circ(gp_Ax2(gp_Pnt(200., 0., 200.), gp_Dir(0., 0., 1.)),
                        40.)
    wire_4b = BRepBuilderAPI_MakeWire(
        BRepBuilderAPI_MakeEdge(circle_4b).Edge()).Wire()
    generatorB = BRepOffsetAPI_ThruSections(True, False)
    [generatorB.AddWire(w) for w in [wire_1b, wire_2b, wire_3b, wire_4b]]
    generatorB.Build()
    display.DisplayShape(generatorB.Shape(), update=True)
Esempio n. 26
0
    def makeCircle(cls,
                   radius,
                   pnt=Vector(0, 0, 0),
                   dir=Vector(0, 0, 1),
                   angle1=360.0,
                   angle2=360):
        """

        """
        pnt = Vector(pnt)
        dir = Vector(dir)

        circle_gp = gp_Circ(gp_Ax2(pnt.toPnt(), dir.toDir()), radius)

        if angle1 == angle2:  # full circle case
            return cls(BRepBuilderAPI_MakeEdge(circle_gp).Edge())
        else:  # arc case
            circle_geom = GC_MakeArcOfCircle(circle_gp, angle1 * DEG2RAD,
                                             angle2 * DEG2RAD, True).Value()
            return cls(BRepBuilderAPI_MakeEdge(circle_geom).Edge())
Esempio n. 27
0
 def update_shape(self,change):
     d = self.declaration
     points = [c.shape for c in self.children()]
     if d.radius:
         circle = gp_Circ(d.axis,d.radius)
         sense = True
         if len(points)==2:
             arc = GC_MakeArcOfCircle(circle,points[0],points[1],sense).Value()
             self.make_edge(arc)
         elif len(points)==1:
             arc = GC_MakeArcOfCircle(circle,d.alpha1,points[0],sense).Value()
             self.make_edge(arc)
         else:
             arc = GC_MakeArcOfCircle(circle,d.alpha1,d.alpha2,sense).Value()
             self.make_edge(arc)
     elif len(points)==3:
         if not points[0].IsEqual(points[2],d.tolerance):
             arc = GC_MakeArcOfCircle(points[0],points[1],points[2]).Value()
             self.make_edge(arc)
     else:
         raise ValueError("Could not create an Arc with the given children and parameters. Must be given one of:\n\t- three points\n\t- radius and 2 points\n\t- radius, alpha1 and one point\n\t- raidus, alpha1 and alpha2")
def through_sections():
    #ruled
    circle_1 = gp_Circ(gp_Ax2(gp_Pnt(-100., 0., -100.), gp_Dir(0., 0., 1.)), 40.)
    wire_1 = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_1).Edge()).Wire()
    circle_2 = gp_Circ(gp_Ax2(gp_Pnt(-10., 0., -0.), gp_Dir(0., 0., 1.)), 40.)
    wire_2 = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_2).Edge()).Wire()
    circle_3 = gp_Circ(gp_Ax2(gp_Pnt(-75., 0., 100.), gp_Dir(0., 0., 1.)), 40.)
    wire_3 = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_3).Edge()).Wire()
    circle_4 = gp_Circ(gp_Ax2(gp_Pnt(0., 0., 200.), gp_Dir(0., 0., 1.)), 40.)
    wire_4 = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_4).Edge()).Wire()

    generatorA = BRepOffsetAPI_ThruSections(False, True)
    # the use of the map function fails at producing the ThruSection
    # on py3k. Why ?
    # map(generatorA.AddWire, [wire_1, wire_2, wire_3, wire_4])
    # we have to use a loop
    for wir in [wire_1, wire_2, wire_3, wire_4]:
        generatorA.AddWire(wir)
    generatorA.Build()
    display.DisplayShape(generatorA.Shape())

    #smooth
    circle_1b = gp_Circ(gp_Ax2(gp_Pnt(100., 0., -100.), gp_Dir(0., 0., 1.)), 40.)
    wire_1b = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_1b).Edge()).Wire()
    circle_2b = gp_Circ(gp_Ax2(gp_Pnt(210., 0., -0.), gp_Dir(0., 0., 1.)), 40.)
    wire_2b = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_2b).Edge()).Wire()
    circle_3b = gp_Circ(gp_Ax2(gp_Pnt(275., 0., 100.), gp_Dir(0., 0., 1.)), 40.)
    wire_3b = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_3b).Edge()).Wire()
    circle_4b = gp_Circ(gp_Ax2(gp_Pnt(200., 0., 200.), gp_Dir(0., 0., 1.)), 40.)
    wire_4b = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_4b).Edge()).Wire()
    generatorB = BRepOffsetAPI_ThruSections(True, False)
    # same here, the following line fails
    # map(generatorB.AddWire, [wire_1b, wire_2b, wire_3b, wire_4b])
    for wir in [wire_1b, wire_2b, wire_3b, wire_4b]:
        generatorB.AddWire(wir)
    generatorB.Build()
    display.DisplayShape(generatorB.Shape(), update=True)
Esempio n. 29
0
##the Free Software Foundation, either version 3 of the License, or
##(at your option) any later version.
##
##pythonOCC is distributed in the hope that it will be useful,
##but WITHOUT ANY WARRANTY; without even the implied warranty of
##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##GNU Lesser General Public License for more details.
##
##You should have received a copy of the GNU Lesser General Public License
##along with pythonOCC.  If not, see <http://www.gnu.org/licenses/>.

from OCC.gp import gp_Dir, gp_Ax2, gp_Circ, gp_Pnt
from OCC.AIS import AIS_Shape, AIS_RadiusDimension
from OCC.BRepBuilderAPI import BRepBuilderAPI_MakeEdge
from OCC.TCollection import TCollection_ExtendedString
from OCC.Display.SimpleGui import init_display

display, start_display, add_menu, add_function_to_menu = init_display()

c = gp_Circ(gp_Ax2(gp_Pnt(200., 200., 0.), gp_Dir(0., 0., 1.)), 80)
ec = BRepBuilderAPI_MakeEdge(c).Edge()
ais_shp = AIS_Shape(ec)
display.Context.Display(ais_shp.GetHandle())


rd = AIS_RadiusDimension(ec)
#rd.SetArrowSize(12)
display.Context.Display(rd.GetHandle())
display.FitAll()
start_display()
def face():
    p1 = gp_Pnt()
    p2 = gp_Pnt()
    p3 = gp_Pnt()
    p4 = gp_Pnt()
    p5 = gp_Pnt()
    p6 = gp_Pnt()

    # The white Face
    sphere = gp_Sphere(gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)), 150)
    green_face = BRepBuilderAPI_MakeFace(sphere, 0.1, 0.7, 0.2, 0.9)

    # The red face
    p1.SetCoord(-15, 200, 10)
    p2.SetCoord(5, 204, 0)
    p3.SetCoord(15, 200, 0)
    p4.SetCoord(-15, 20, 15)
    p5.SetCoord(-5, 20, 0)
    p6.SetCoord(15, 20, 35)
    array = TColgp_Array2OfPnt(1, 3, 1, 2)
    array.SetValue(1, 1, p1)
    array.SetValue(2, 1, p2)
    array.SetValue(3, 1, p3)
    array.SetValue(1, 2, p4)
    array.SetValue(2, 2, p5)
    array.SetValue(3, 2, p6)
    curve = GeomAPI_PointsToBSplineSurface(array, 3, 8, GeomAbs_C2,
                                           0.001).Surface()
    red_face = BRepBuilderAPI_MakeFace(curve, 1e-6)

    #The brown face
    circle = gp_Circ(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)), 80)
    Edge1 = BRepBuilderAPI_MakeEdge(circle, 0, math.pi)
    Edge2 = BRepBuilderAPI_MakeEdge(gp_Pnt(0, 0, -80), gp_Pnt(0, -10, 40))
    Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(0, -10, 40), gp_Pnt(0, 0, 80))

    ##TopoDS_Wire YellowWire
    MW1 = BRepBuilderAPI_MakeWire(Edge1.Edge(), Edge2.Edge(), Edge3.Edge())
    if MW1.IsDone():
        yellow_wire = MW1.Wire()
    brown_face = BRepBuilderAPI_MakeFace(yellow_wire)

    #The pink face
    p1.SetCoord(35, -200, 40)
    p2.SetCoord(50, -204, 30)
    p3.SetCoord(65, -200, 30)
    p4.SetCoord(35, -20, 45)
    p5.SetCoord(45, -20, 30)
    p6.SetCoord(65, -20, 65)
    array2 = TColgp_Array2OfPnt(1, 3, 1, 2)
    array2.SetValue(1, 1, p1)
    array2.SetValue(2, 1, p2)
    array2.SetValue(3, 1, p3)
    array2.SetValue(1, 2, p4)
    array2.SetValue(2, 2, p5)
    array2.SetValue(3, 2, p6)
    BSplineSurf = GeomAPI_PointsToBSplineSurface(array2, 3, 8, GeomAbs_C2,
                                                 0.001)
    aFace = BRepBuilderAPI_MakeFace(BSplineSurf.Surface(), 1e-6).Face()
    ##
    ##//2d lines
    P12d = gp_Pnt2d(0.9, 0.1)
    P22d = gp_Pnt2d(0.2, 0.7)
    P32d = gp_Pnt2d(0.02, 0.1)
    ##
    line1 = Geom2d_Line(P12d, gp_Dir2d((0.2-0.9), (0.7-0.1)))
    line2 = Geom2d_Line(P22d, gp_Dir2d((0.02-0.2), (0.1-0.7)))
    line3 = Geom2d_Line(P32d, gp_Dir2d((0.9-0.02), (0.1-0.1)))
    ##
    ##//Edges are on the BSpline surface
    Edge1 = BRepBuilderAPI_MakeEdge(line1.GetHandle(), BSplineSurf.Surface(),
                                    0, P12d.Distance(P22d)).Edge()
    Edge2 = BRepBuilderAPI_MakeEdge(line2.GetHandle(), BSplineSurf.Surface(),
                                    0, P22d.Distance(P32d)).Edge()
    Edge3 = BRepBuilderAPI_MakeEdge(line3.GetHandle(), BSplineSurf.Surface(),
                                    0, P32d.Distance(P12d)).Edge()
    ##
    Wire1 = BRepBuilderAPI_MakeWire(Edge1, Edge2, Edge3).Wire()
    Wire1.Reverse()
    pink_face = BRepBuilderAPI_MakeFace(aFace, Wire1).Face()
    breplib_BuildCurves3d(pink_face)

    display.DisplayColoredShape(green_face.Face(), 'GREEN')
    display.DisplayColoredShape(red_face.Face(), 'RED')
    display.DisplayColoredShape(pink_face, Quantity_Color(Quantity_NOC_PINK))
    display.DisplayColoredShape(brown_face.Face(), 'BLUE')
    display.DisplayColoredShape(yellow_wire, 'YELLOW', update=True)
Esempio n. 31
0
 def create_shape(self):
     d = self.declaration
     self.make_edge(gp_Circ(d.axis,d.radius))
#!/usr/bin/python
# coding: utf-8
r"""Core dimensions display example"""

import os

from OCC.gp import gp_Dir, gp_Ax2, gp_Circ, gp_Pnt
from OCC.AIS import AIS_Shape, AIS_RadiusDimension
from OCC.BRepBuilderAPI import BRepBuilderAPI_MakeEdge
from OCC.Display.SimpleGui import init_display

display, start_display, add_menu, add_function_to_menu = init_display('wx')

c = gp_Circ(gp_Ax2(gp_Pnt(200., 200., 0.), gp_Dir(0., 0., 1.)), 80)
ec = BRepBuilderAPI_MakeEdge(c).Edge()
ais_shp = AIS_Shape(ec)
display.Context.Display(ais_shp.GetHandle())

# Does not solve problem !!
# os.environ["OCE_LIB_PATH"] = \
#     "C:/_Guillaume/__gf_files__/____Projets/5xx-Developpement/_Repositories/github/guillaume-florent/oce"
os.environ["CASROOT"] = \
    "C:/_Guillaume/__gf_files__/____Projets/5xx-Developpement/_Repositories/github/guillaume-florent/oce"
os.environ["CSF_UnitsLexicon"] = \
    os.environ["CASROOT"] + "/src/UnitsAPI/Lexi_Expr.dat"
os.environ["CSF_UnitsDefinition"] = \
    os.environ["CASROOT"] + "/src/UnitsAPI/Units.dat"

rd = AIS_RadiusDimension(ec)
# rd.SetArrowSize(12)
handle = rd.GetHandle()
Esempio n. 33
0
def make_circle(pycentre_pt, pydirection, radius):
    circle = gp_Circ(
        gp_Ax2(gp_Pnt(pycentre_pt[0], pycentre_pt[1], pycentre_pt[2]),
               gp_Dir(pydirection[0], pydirection[1], pydirection[2])), radius)
    circle_edge = BRepBuilderAPI_MakeEdge(circle, 0, circle.Length())
    return circle_edge.Edge()
Esempio n. 34
0
def makeCircleWire():
    circle = gp.gp_Circ(gp.gp_Ax2(gp.gp_Pnt(0, 2, 0),
                                  gp.gp().DZ()), .75)
    e2 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle, gp.gp_Pnt(0, 1.25, 0),
                                                gp.gp_Pnt(0, 1.25, 0)).Edge()
    return Wrappers.wireFromEdges([e2])
Esempio n. 35
0
brt = OCC.BRep.BRep_Tool()
pnt = brt.Pnt(vertices.next())

import pprint
pp = pprint.PrettyPrinter(indent=4)
print("orientation")
curve, f1, l1 = brt.Curve(lowest_edge)
print(f1)
print(l1)
pp.pprint(curve.GetObject())
print("done")
dotp = gp_Pnt()
curve.GetObject().D0(0, dotp)
aVec = gp_Vec(dotp.X(), dotp.Y(), dotp.Z())
aDir = gp_Dir(aVec)
circle = gp_Circ(gp_Ax2(pnt, aDir), 1)
profile_edge = OCC.BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle).Edge()
pipe = BRepOffsetAPI_MakePipe(wire_make.Wire(), profile_edge).Shape()
section = OCC.BRepAlgoAPI.BRepAlgoAPI_Section(pipe, front_face)
section.Build()
if section.IsDone():
    display.DisplayShape(section.Shape(), update=True)
section.Destroy()
display.DisplayShape(pipe, update=True)
#circle1 = gp_Circ(gp_Ax2(gp_Pnt(0,50,0),gp().DX()),5)
#profile_edge = BRepBuilderAPI_MakeEdge(circle1).Edge()
#for v in vertices:
#print(pnt)
#display.DisplayShape(v)
#print(v)
Esempio n. 36
0
    def _make_circle(self):

        circle = gp_Circ(gp_Ax2(gp_Pnt(1, 2, 3), gp_DZ()), 2.)
        return Shape.cast(BRepBuilderAPI_MakeEdge(circle).Edge())
Esempio n. 37
0
	for p in Wrappers.frange6(pStart,pEnd,interval):
		tangent = gp.gp_Vec();
		tanpoint = gp.gp_Pnt();
		curve.D1(p,tanpoint,tangent );
		axis = gp.gp_Ax1(tanpoint, gp.gp_Dir(tangent.Crossed(zVec) ) );
	
		line = Geom.Geom_Line(axis );
		e = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(line.GetHandle(),0, length).Edge();	
		if e:
			edgeList.append(e);
			
	return edgeList;
	
if __name__=='__main__':

	circle = gp.gp_Circ(gp.gp_Ax2(gp.gp_Pnt(0,0,0),gp.gp().DZ()),1);
	
	#make a few edges
	e1 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle,5,6.2).Edge();
	TestDisplay.display.showShape(e1);

	for e in normalEdgesAlongEdge(e1,0.1,0.1 ):
		TestDisplay.display.showShape(e);
		
	
	e2 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(gp.gp_Pnt(0,0,0),gp.gp_Pnt(1,1,0)).Edge();
	TestDisplay.display.showShape(e2);

	for e in normalEdgesAlongEdge(e2,0.1,0.1 ):
		TestDisplay.display.showShape(e);	
Esempio n. 38
0
def makeCircleWire():
	circle = gp.gp_Circ(gp.gp_Ax2(gp.gp_Pnt(0,2,0),gp.gp().DZ()),.75);
	e2 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle, gp.gp_Pnt(0,1.25,0),gp.gp_Pnt(0,1.25,0)).Edge();
	return Wrappers.wireFromEdges([e2]);
Esempio n. 39
0
def face():
    p1 = gp_Pnt()
    p2 = gp_Pnt()
    p3 = gp_Pnt()
    p4 = gp_Pnt()
    p5 = gp_Pnt()
    p6 = gp_Pnt()

    # The white Face
    sphere = gp_Sphere(gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)), 150)
    green_face = BRepBuilderAPI_MakeFace(sphere, 0.1, 0.7, 0.2, 0.9)

    # The red face
    p1.SetCoord(-15, 200, 10)
    p2.SetCoord(5, 204, 0)
    p3.SetCoord(15, 200, 0)
    p4.SetCoord(-15, 20, 15)
    p5.SetCoord(-5, 20, 0)
    p6.SetCoord(15, 20, 35)
    array = TColgp_Array2OfPnt(1, 3, 1, 2)
    array.SetValue(1, 1, p1)
    array.SetValue(2, 1, p2)
    array.SetValue(3, 1, p3)
    array.SetValue(1, 2, p4)
    array.SetValue(2, 2, p5)
    array.SetValue(3, 2, p6)
    curve = GeomAPI_PointsToBSplineSurface(array, 3, 8, GeomAbs_C2, 0.001).Surface()
    red_face = BRepBuilderAPI_MakeFace(curve, 1e-6)

    #The brown face
    circle = gp_Circ(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)), 80)
    Edge1 = BRepBuilderAPI_MakeEdge(circle, 0, math.pi)
    Edge2 = BRepBuilderAPI_MakeEdge(gp_Pnt(0, 0, -80), gp_Pnt(0, -10, 40))
    Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(0, -10, 40), gp_Pnt(0, 0, 80))

    ##TopoDS_Wire YellowWire
    MW1 = BRepBuilderAPI_MakeWire(Edge1.Edge(), Edge2.Edge(), Edge3.Edge())
    if MW1.IsDone():
        yellow_wire = MW1.Wire()
    brown_face = BRepBuilderAPI_MakeFace(yellow_wire)

    #The pink face
    p1.SetCoord(35, -200, 40)
    p2.SetCoord(50, -204, 30)
    p3.SetCoord(65, -200, 30)
    p4.SetCoord(35, -20, 45)
    p5.SetCoord(45, -20, 30)
    p6.SetCoord(65, -20, 65)
    array2 = TColgp_Array2OfPnt(1, 3, 1, 2)
    array2.SetValue(1, 1, p1)
    array2.SetValue(2, 1, p2)
    array2.SetValue(3, 1, p3)
    array2.SetValue(1, 2, p4)
    array2.SetValue(2, 2, p5)
    array2.SetValue(3, 2, p6)
    BSplineSurf = GeomAPI_PointsToBSplineSurface(array2, 3, 8, GeomAbs_C2,
                                                 0.001)
    aFace = BRepBuilderAPI_MakeFace(BSplineSurf.Surface(), 1e-6).Face()
    ##
    ##//2d lines
    P12d = gp_Pnt2d(0.9, 0.1)
    P22d = gp_Pnt2d(0.2, 0.7)
    P32d = gp_Pnt2d(0.02, 0.1)
    ##
    line1 = Geom2d_Line(P12d, gp_Dir2d((0.2-0.9), (0.7-0.1)))
    line2 = Geom2d_Line(P22d, gp_Dir2d((0.02-0.2), (0.1-0.7)))
    line3 = Geom2d_Line(P32d, gp_Dir2d((0.9-0.02), (0.1-0.1)))
    ##
    ##//Edges are on the BSpline surface
    Edge1 = BRepBuilderAPI_MakeEdge(line1.GetHandle(), BSplineSurf.Surface(),
                                    0, P12d.Distance(P22d)).Edge()
    Edge2 = BRepBuilderAPI_MakeEdge(line2.GetHandle(), BSplineSurf.Surface(),
                                    0, P22d.Distance(P32d)).Edge()
    Edge3 = BRepBuilderAPI_MakeEdge(line3.GetHandle(), BSplineSurf.Surface(),
                                    0, P32d.Distance(P12d)).Edge()
    ##
    Wire1 = BRepBuilderAPI_MakeWire(Edge1, Edge2, Edge3).Wire()
    Wire1.Reverse()
    pink_face = BRepBuilderAPI_MakeFace(aFace, Wire1).Face()
    breplib_BuildCurves3d(pink_face)

    display.DisplayColoredShape(green_face.Face(), 'GREEN')
    display.DisplayColoredShape(red_face.Face(), 'RED')
    display.DisplayColoredShape(pink_face, Quantity_Color(Quantity_NOC_PINK))
    display.DisplayColoredShape(brown_face.Face(), 'BLUE')
    display.DisplayColoredShape(yellow_wire, 'YELLOW', update=True)
Esempio n. 40
0
 def create_shape(self):
     d = self.declaration
     self.make_edge(gp_Circ(d.axis, d.radius))