Beispiel #1
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")
Beispiel #2
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
Beispiel #3
0
    def makeThreePointArc(cls, v1, v2, v3):
        """
        Makes a three point arc through the provided points
        :param cls:
        :param v1: start vector
        :param v2: middle vector
        :param v3: end vector
        :return: an edge object through the three points
        """
        circle_geom = GC_MakeArcOfCircle(v1.toPnt(), v2.toPnt(),
                                         v3.toPnt()).Value()

        return cls(BRepBuilderAPI_MakeEdge(circle_geom).Edge())
Beispiel #4
0
    def createModel(self):
        #         edges = makeEdgesFromPoints(self.points)
        #         self.a1 =
        edge1 = BRepBuilderAPI_MakeEdge(getGpPt(self.a1), getGpPt(self.a2))
        edge2 = BRepBuilderAPI_MakeEdge(getGpPt(self.a2), getGpPt(self.a3))
        arc1 = GC_MakeArcOfCircle(getGpPt(self.a3), getGpPt(self.a4),
                                  getGpPt(self.a5))
        edge3 = BRepBuilderAPI_MakeEdge(arc1.Value())
        edge4 = BRepBuilderAPI_MakeEdge(getGpPt(self.a5), getGpPt(self.a6))
        arc2 = GC_MakeArcOfCircle(getGpPt(self.a6), getGpPt(self.a7),
                                  getGpPt(self.a8))
        edge5 = BRepBuilderAPI_MakeEdge(arc2.Value())
        edge6 = BRepBuilderAPI_MakeEdge(getGpPt(self.a8), getGpPt(self.a9))
        arc3 = GC_MakeArcOfCircle(getGpPt(self.a9), getGpPt(self.a10),
                                  getGpPt(self.a11))
        edge7 = BRepBuilderAPI_MakeEdge(arc3.Value())
        edge8 = BRepBuilderAPI_MakeEdge(getGpPt(self.a11), getGpPt(self.a12))
        edge9 = BRepBuilderAPI_MakeEdge(getGpPt(self.a12), getGpPt(self.a1))
        #         wire = makeWireFromEdges(edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9)
        wire = BRepBuilderAPI_MakeWire(edge1.Edge(), edge2.Edge(),
                                       edge3.Edge(), edge4.Edge())
        wire = BRepBuilderAPI_MakeWire(wire.Wire(), edge5.Edge())
        wire = BRepBuilderAPI_MakeWire(wire.Wire(), edge6.Edge())
        wire = BRepBuilderAPI_MakeWire(wire.Wire(), edge7.Edge())
        wire = BRepBuilderAPI_MakeWire(wire.Wire(), edge8.Edge())
        wire = BRepBuilderAPI_MakeWire(wire.Wire(), edge9.Edge())

        aFace = makeFaceFromWire(wire.Wire())
        extrudeDir = self.L * self.wDir  # extrudeDir is a numpy array

        prism = makePrismFromFace(aFace, extrudeDir)
        mkFillet = BRepFilletAPI_MakeFillet(prism)
        anEdgeExplorer = TopExp_Explorer(prism, TopAbs_EDGE)
        while anEdgeExplorer.More():
            aEdge = topods.Edge(anEdgeExplorer.Current())
            mkFillet.Add(self.T / 17., aEdge)
            anEdgeExplorer.Next()

        prism = mkFillet.Shape()

        return prism
Beispiel #5
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())
    """
    return Handle_Geom_Plane.DownCast(BRep_Tool_Surface(aFace)).GetObject()


height = 70
width = 50
thickness = 30

# The points we'll use to create the profile of the bottle's body
aPnt1 = gp_Pnt(-width / 2.0, 0, 0)
aPnt2 = gp_Pnt(-width / 2.0, -thickness / 4.0, 0)
aPnt3 = gp_Pnt(0, -thickness / 2.0, 0)
aPnt4 = gp_Pnt(width / 2.0, -thickness / 4.0, 0)
aPnt5 = gp_Pnt(width / 2.0, 0, 0)

aArcOfCircle = GC_MakeArcOfCircle(aPnt2, aPnt3, aPnt4)
aSegment1 = GC_MakeSegment(aPnt1, aPnt2)
aSegment2 = GC_MakeSegment(aPnt4, aPnt5)

# Could also construct the line edges directly using the points
# instead of the resulting line
aEdge1 = BRepBuilderAPI_MakeEdge(aSegment1.Value())
aEdge2 = BRepBuilderAPI_MakeEdge(aArcOfCircle.Value())
aEdge3 = BRepBuilderAPI_MakeEdge(aSegment2.Value())

# Create a wire out of the edges
aWire = BRepBuilderAPI_MakeWire(aEdge1.Edge(), aEdge2.Edge(), aEdge3.Edge())

# Quick way to specify the X axis
xAxis = gp_OX()
Beispiel #7
0
'''
display, start_display = init_display()[:2]

myWidth = 50
myHeight = 70
myThickness = 30

# Profile : Define Support Points
aPnt1 = gp_Pnt(-myWidth / 2, 0, 0)
aPnt2 = gp_Pnt(-myWidth / 2, -myThickness / 4, 0)
aPnt3 = gp_Pnt(0, -myThickness / 2, 0)
aPnt4 = gp_Pnt(myWidth / 2, -myThickness / 4, 0)
aPnt5 = gp_Pnt(myWidth / 2, 0, 0)

# Profile : Define the Geometry
aArcOfCircle = GC_MakeArcOfCircle(aPnt2, aPnt3, aPnt4)
aSegment1 = GC_MakeSegment(aPnt1, aPnt2)
aSegment2 = GC_MakeSegment(aPnt4, aPnt5)

# Profile : Define the Topology
aEdge1 = MakeEdge(aSegment1.Value())
aEdge2 = MakeEdge(aArcOfCircle.Value())
aEdge3 = MakeEdge(aSegment2.Value())
aWire = MakeWire(aEdge1.Edge(), aEdge2.Edge(), aEdge3.Edge())

# Complete Profile
xAxis = OCC.gp.gp_OX()
aTrsf = OCC.gp.gp_Trsf()
aTrsf.SetMirror(xAxis)
aBRepTrsf = Transform(aWire.Wire(), aTrsf)
aMirroredShape = aBRepTrsf.Shape()
Beispiel #8
0
    def create_model(self):

        ######################################################
        edges = []
        if self.R2 == 0.0 or self.R1 == 0.0:
            self.a3 = self.a4 = self.a5
            edge1 = make_edge(getGpPt(self.a1), getGpPt(self.a2))
            edges.append(edge1)
            edge2 = make_edge(getGpPt(self.a2), getGpPt(self.a3))
            edges.append(edge2)
            edge3 = make_edge(getGpPt(self.a3), getGpPt(self.a6))
            edges.append(edge3)
            # arc2 = GC_MakeArcOfCircle(getGpPt(self.a6), getGpPt(self.a7), getGpPt(self.a8))
            # edge4 = make_edge(arc2.Value())
            # edges.append(edge4)
            # edge5 = make_edge(getGpPt(self.a8), getGpPt(self.a9))
            # edges.append(edge5)
            # edge6 = make_edge(getGpPt(self.a9), getGpPt(self.a12))
            # edges.append(edge6)
            # edge7 = make_edge(getGpPt(self.a12), getGpPt(self.a1))
            # edges.append(edge7)
            edge4 = make_edge(getGpPt(self.a6), getGpPt(self.a9))
            edges.append(edge4)
            edge5 = make_edge(getGpPt(self.a9), getGpPt(self.a12))
            edges.append(edge5)
            edge6 = make_edge(getGpPt(self.a12), getGpPt(self.a1))
            edges.append(edge6)

        else:
            edge1 = make_edge(getGpPt(self.a1), getGpPt(self.a2))
            edges.append(edge1)
            edge2 = make_edge(getGpPt(self.a2), getGpPt(self.a3))
            edges.append(edge2)
            arc1 = GC_MakeArcOfCircle(getGpPt(self.a3), getGpPt(self.a4),
                                      getGpPt(self.a5))
            edge3 = make_edge(arc1.Value())
            edges.append(edge3)
            edge4 = make_edge(getGpPt(self.a5), getGpPt(self.a6))
            edges.append(edge4)
            arc2 = GC_MakeArcOfCircle(getGpPt(self.a6), getGpPt(self.a7),
                                      getGpPt(self.a8))
            edge5 = make_edge(arc2.Value())
            edges.append(edge5)
            edge6 = make_edge(getGpPt(self.a8), getGpPt(self.a9))
            edges.append(edge6)
            arc3 = GC_MakeArcOfCircle(getGpPt(self.a9), getGpPt(self.a10),
                                      getGpPt(self.a11))
            edge7 = make_edge(arc3.Value())
            edges.append(edge7)
            edge8 = make_edge(getGpPt(self.a11), getGpPt(self.a12))
            edges.append(edge8)
            edge9 = make_edge(getGpPt(self.a12), getGpPt(self.a1))
            edges.append(edge9)

        wire = makeWireFromEdges(edges)
        aFace = makeFaceFromWire(wire)
        extrudeDir = self.L * self.wDir  # extrudeDir is a numpy array
        prism = makePrismFromFace(aFace, extrudeDir)
        mkFillet = BRepFilletAPI_MakeFillet(prism)
        anEdgeExplorer = TopExp_Explorer(prism, TopAbs_EDGE)
        while anEdgeExplorer.More():
            aEdge = topods.Edge(anEdgeExplorer.Current())
            mkFillet.Add(self.T / 17., aEdge)
            anEdgeExplorer.Next()

        prism = mkFillet.Shape()
        return prism
Beispiel #9
0
Gbody = topods.Solid(Gbody)
TF['case'] = Construct.boolean_fuse(TF['case'], Gbody)  # join seat to body

Gax = Construct.gp_Ax1(gp_Pnt(rGS, 0, zGS - GSwidth / 2), gp_Dir(1, 0, 0))
pin = Construct.gp_Circ()
pin.SetRadius(GSwidth / 4)
pin.SetAxis(Gax)
pin = Construct.make_edge(pin)
pin = Construct.make_wire(pin)
pin = Construct.make_face(pin)
pin = Construct.make_prism(pin, Construct.gp_Vec(GSwidth, 0, 0))
pin = Construct.translate_topods_from_vector(
    pin, Construct.gp_Vec(-GSwidth / 2, 0, 0))

arc = GC_MakeArcOfCircle(gp_Pnt(rGS, -GSwidth / 2, zGS - GSwidth / 2),
                         gp_Pnt(rGS, 0, zGS - GSwidth),
                         gp_Pnt(rGS, GSwidth / 2, zGS - GSwidth / 2))
arc = Construct.make_edge(arc.Value())
base = BRepBuilderAPI_MakePolygon()
base.Add(gp_Pnt(rGS, -GSwidth / 2, zGS - GSwidth / 2))
base.Add(gp_Pnt(rGS, -GSwidth / 2, zGS))
base.Add(gp_Pnt(rGS, GSwidth / 2, zGS))
base.Add(gp_Pnt(rGS, GSwidth / 2, zGS - GSwidth / 2))
Gloop = Construct.make_wire([arc, base.Wire()])
Gface = Construct.make_face(Gloop)
Gbody = Construct.make_prism(Gface, Construct.gp_Vec(GSwidth / 3, 0, 0))
Gbody = topods.Solid(Gbody)
Gtag = Construct.translate_topods_from_vector(
    Gbody, Construct.gp_Vec(-GSwidth / 6, 0, 0))
Gbase = Construct.translate_topods_from_vector(Gtag,\
        Construct.gp_Vec(-GSwidth/2+GSwidth/6,0,0))