Ejemplo n.º 1
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
# 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()

# Set up the mirror
aTrsf = gp_Trsf()
aTrsf.SetMirror(xAxis)

# Apply the mirror transformation
aBRespTrsf = BRepBuilderAPI_Transform(aWire.Wire(), aTrsf)
Ejemplo n.º 3
0
# 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()
aMirroredWire = OCC.TopoDS.TopoDS_Shape(aMirroredShape)
aMirroredWire = OCC.TopoDS.topods().Wire(aMirroredWire)

mkWire = MakeWire()
mkWire.Add(aWire.Wire())
mkWire.Add(aMirroredWire)
Ejemplo n.º 4
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
Ejemplo n.º 5
0
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))
Gbase = Construct.boolean_fuse(Gbase,\
                               Construct.translate_topods_from_vector(Gtag,\