示例#1
0
def fillet(event=None):
    display.EraseAll()
    box = BRepPrimAPI_MakeBox(gp_Pnt(-400, 0, 0), 200, 230, 180).Shape()
    fillet = BRepFilletAPI_MakeFillet(box)
    # Add fillet on each edge
    for e in TopologyExplorer(box).edges():
        fillet.Add(20, e)

    blended_box = fillet.Shape()

    p_1 = gp_Pnt(250, 150, 75)
    s_1 = BRepPrimAPI_MakeBox(300, 200, 200).Shape()
    s_2 = BRepPrimAPI_MakeBox(p_1, 120, 180, 70).Shape()
    fused_shape = BRepAlgoAPI_Fuse(s_1, s_2).Shape()

    fill = BRepFilletAPI_MakeFillet(fused_shape)
    for e in TopologyExplorer(fused_shape).edges():
        fill.Add(e)

    for i in range(1, fill.NbContours() + 1):
        length = fill.Length(i)
        radius = 0.15 * length
        fill.SetRadius(radius, i, 1)

    blended_fused_solids = fill.Shape()

    display.DisplayShape(blended_box)
    display.DisplayShape(blended_fused_solids, update=True)
def fillet(event=None):
    Box = BRepPrimAPI_MakeBox(gp_Pnt(-400, 0, 0), 200, 230, 180).Shape()
    fillet_ = BRepFilletAPI_MakeFillet(Box)
    # Add fillet on each edge
    for e in TopologyExplorer(Box).edges():
        fillet_.Add(20, e)

    blendedBox = fillet_.Shape()

    P1 = gp_Pnt(250, 150, 75)
    S1 = BRepPrimAPI_MakeBox(300, 200, 200).Shape()
    S2 = BRepPrimAPI_MakeBox(P1, 120, 180, 70).Shape()
    Fuse = BRepAlgoAPI_Fuse(S1, S2)
    FusedShape = Fuse.Shape()

    fill = BRepFilletAPI_MakeFillet(FusedShape)
    for e in TopologyExplorer(FusedShape).edges():
        fill.Add(e)

    for i in range(1, fill.NbContours() + 1):
        length = fill.Length(i)
        Rad = 0.15 * length
        fill.SetRadius(Rad, i, 1)

    blendedFusedSolids = fill.Shape()

    display.EraseAll()
    display.DisplayShape(blendedBox)
    display.DisplayShape(blendedFusedSolids)
    display.FitAll()
示例#3
0
def _fillet(shp, r, refs=None):
    if (shp.shapetype() == "face"):
        return _fillet2d(shp, r, refs)

    if refs:
        refs = points(refs)

    if shp.is_solid() or shp.is_compound() or shp.is_compsolid():
        mk = BRepFilletAPI_MakeFillet(shp.Shape())

        if refs:
            for p in refs:
                minimum = float("inf")
                vtx = p.Vtx()

                for edg in shp.edges():
                    extrema = BRepExtrema_DistShapeShape(edg.Edge(), vtx)

                    if minimum > extrema.Value():
                        ret = edg
                        minimum = extrema.Value()

                mk.Add(r, ret.Edge())
        else:
            for edg in shp.edges():
                mk.Add(r, edg.Edge())

        return Shape(mk.Shape())
    else:
        raise Exception("Fillet argument has unsuported type.")
示例#4
0
def vertex_fillet(cube_shp, vert):
    # apply a fillet on incident edges on a vertex
    afillet = BRepFilletAPI_MakeFillet(cube_shp)
    cnt = 0
    # find edges from vertex
    _map = TopTools_IndexedDataMapOfShapeListOfShape()
    topexp_MapShapesAndAncestors(cube_shp, TopAbs_VERTEX, TopAbs_EDGE, _map)
    results = _map.FindFromKey(vert)
    topology_iterator = TopTools_ListIteratorOfListOfShape(results)
    while topology_iterator.More():
        edge = topods_Edge(topology_iterator.Value())
        topology_iterator.Next()
        first, last = topexp_FirstVertex(edge), topexp_LastVertex(edge)
        vertex, first_vert, last_vert = BRep_Tool().Pnt(vert), BRep_Tool().Pnt(first), BRep_Tool().Pnt(last)
        if edge.Orientation():
            if not vertex.IsEqual(first_vert, 0.001):
                afillet.Add(0, 20., edge)
            else:
                afillet.Add(20, 0, edge)
        cnt += 1
    afillet.Build()
    if afillet.IsDone():
        return afillet.Shape()
    else:
        raise AssertionError('you failed on me you fool!')
示例#5
0
def variable_filleting(event=None):
    a_pnt = gp_Pnt(350, 0, 0)
    box_2 = BRepPrimAPI_MakeBox(a_pnt, 200, 200, 200).Shape()
    a_fillet = BRepFilletAPI_MakeFillet(box_2)

    tab_point = TColgp_Array1OfPnt2d(1, 6)
    p_1 = gp_Pnt2d(0., 8.)
    p_2 = gp_Pnt2d(0.2, 16.)
    p_3 = gp_Pnt2d(0.4, 25.)
    p_4 = gp_Pnt2d(0.6, 55.)
    p_5 = gp_Pnt2d(0.8, 28.)
    p_6 = gp_Pnt2d(1., 20.)
    tab_point.SetValue(1, p_1)
    tab_point.SetValue(2, p_2)
    tab_point.SetValue(3, p_3)
    tab_point.SetValue(4, p_4)
    tab_point.SetValue(5, p_5)
    tab_point.SetValue(6, p_6)

    expl3 = list(TopologyExplorer(box_2).edges())

    a_fillet.Add(tab_point, expl3[9])
    a_fillet.Build()
    if a_fillet.IsDone():
        law_evolved_box = a_fillet.Shape()
        display.DisplayShape(law_evolved_box)
    else:
        print("aFillet not done.")
    display.FitAll()
示例#6
0
def makeFillets(event=None):
    newPrtName = 'bodyWithFillets'
    workPart = win.activePart
    wrkPrtUID = win.activePartUID
    mkFillet = BRepFilletAPI_MakeFillet(workPart)
    aEdgeExplorer = TopExp_Explorer(workPart, TopAbs_EDGE)
    while aEdgeExplorer.More():
        aEdge = topods_Edge(aEdgeExplorer.Current())
        mkFillet.Add(thickness / 12., aEdge)
        aEdgeExplorer.Next()
    myBody = mkFillet.Shape()
    win.getNewPartUID(myBody, name=newPrtName, ancestor=wrkPrtUID)
    win.statusBar().showMessage('Bottle with fillets complete')
    win.redraw()
示例#7
0
def rake(event=None):
    display.EraseAll()
    # Create Box
    box = BRepPrimAPI_MakeBox(200, 200, 200).Shape()
    # Fillet
    rake = BRepFilletAPI_MakeFillet(box)
    expl = list(TopologyExplorer(box).edges())

    rake.Add(8, 50, expl[3])
    rake.Build()
    if rake.IsDone():
        evolved_box = rake.Shape()
        display.DisplayShape(evolved_box, update=True)
    else:
        print("Rake not done.")
示例#8
0
def fillet(event=None):
    """Fillet (blend) edges of active part"""
    if win.lineEditStack and win.edgeStack:
        topo = Topology.Topo(win.activePart)
        text = win.lineEditStack.pop()
        filletR = float(text) * win.unitscale
        edges = []
        # Test if edge(s) selected are in active part
        for edge in win.edgeStack:
            try:
                if edge in topo.edges():
                    edges.append(edge)
                else:
                    print("Selected edge(s) must be in Active Part.")
                    win.clearCallback()
                    return
            except ValueError:
                print("You must first set the Active Part.")
                win.clearCallback()
                return
        win.edgeStack = []
        workPart = win.activePart
        uid = win.activePartUID
        mkFillet = BRepFilletAPI_MakeFillet(workPart)
        for edge in edges:
            mkFillet.Add(filletR, edge)
        try:
            newPart = mkFillet.Shape()
            win.erase_shape(uid)
            doc.replaceShape(uid, newPart)
            win.draw_shape(uid)
            win.statusBar().showMessage("Fillet operation complete")
        except RuntimeError as e:
            print(f"Unable to make Fillet. {e}")
        win.setActivePart(uid)
        win.clearCallback()
    else:
        win.registerCallback(filletC)
        display.SetSelectionModeEdge()
        statusText = "Select edge(s) to fillet then specify fillet radius."
        win.statusBar().showMessage(statusText)
示例#9
0
def fillet_cylinder(event=None):
    display.EraseAll()
    # Create Cylinder
    cylinder = BRepPrimAPI_MakeCylinder(
        gp_Ax2(gp_Pnt(-300, 0, 0), gp_Dir(0, 0, 1)), 100, 200).Shape()
    fillet = BRepFilletAPI_MakeFillet(cylinder)
    display.DisplayShape(cylinder, update=True)
    tab_point_2 = TColgp_Array1OfPnt2d(0, 20)
    for i in range(0, 20):
        point_2d = gp_Pnt2d(i * 2 * pi / 19,
                            60 * cos(i * pi / 19 - pi / 2) + 10)
        tab_point_2.SetValue(i, point_2d)
        display.DisplayShape(point_2d)

    expl2 = TopologyExplorer(cylinder).edges()
    fillet.Add(tab_point_2, next(expl2))
    fillet.Build()
    if fillet.IsDone():
        law_evolved_cylinder = fillet.Shape()
        display.DisplayShape(law_evolved_cylinder, update=True)
    else:
        print("fillet not done.")
示例#10
0
def fillet(event=None):
    if (win.lineEditStack and win.edgeStack):
        text = win.lineEditStack.pop()
        filletR = float(text) * win.unitscale
        edges = []
        for edge in win.edgeStack:
            edges.append(edge)
        win.edgeStack = []
        workPart = win.activePart
        wrkPrtUID = win.activePartUID
        mkFillet = BRepFilletAPI_MakeFillet(workPart)
        for edge in edges:
            mkFillet.Add(filletR, edge)
        newPart = mkFillet.Shape()
        win.getNewPartUID(newPart, ancestor=wrkPrtUID)
        win.statusBar().showMessage('Fillet operation complete')
        win.clearCallback()
    else:
        win.registerCallback(filletC)
        display.SetSelectionModeEdge()
        statusText = "Select edge(s) to fillet then specify fillet radius."
        win.statusBar().showMessage(statusText)
def variable_filleting(event=None):
    display.EraseAll()
    # Create Box
    Box = BRepPrimAPI_MakeBox(200, 200, 200).Shape()
    # Fillet
    Rake = BRepFilletAPI_MakeFillet(Box)
    ex = TopologyExplorer(Box).edges()
    next(ex)
    next(ex)
    next(ex)

    Rake.Add(8, 50, next(ex))
    Rake.Build()
    if Rake.IsDone():
        evolvedBox = Rake.Shape()
        display.DisplayShape(evolvedBox)
    else:
        print("Rake not done.")
    # Create Cylinder
    Cylinder = BRepPrimAPI_MakeCylinder(
        gp_Ax2(gp_Pnt(-300, 0, 0), gp_Dir(0, 0, 1)), 100, 200).Shape()
    fillet_ = BRepFilletAPI_MakeFillet(Cylinder)

    TabPoint2 = TColgp_Array1OfPnt2d(0, 20)
    for i in range(0, 20):
        Point2d = gp_Pnt2d(i * 2 * pi / 19,
                           60 * cos(i * pi / 19 - pi / 2) + 10)
        TabPoint2.SetValue(i, Point2d)

    exp2 = TopologyExplorer(Cylinder).edges()
    fillet_.Add(TabPoint2, next(exp2))
    fillet_.Build()
    if fillet_.IsDone():
        LawEvolvedCylinder = fillet_.Shape()
        display.DisplayShape(LawEvolvedCylinder)
    else:
        print("fillet not done.")  ## TODO : fillet not done
    P = gp_Pnt(350, 0, 0)
    Box2 = BRepPrimAPI_MakeBox(P, 200, 200, 200).Shape()
    afillet = BRepFilletAPI_MakeFillet(Box2)

    TabPoint = TColgp_Array1OfPnt2d(1, 6)
    P1 = gp_Pnt2d(0., 8.)
    P2 = gp_Pnt2d(0.2, 16.)
    P3 = gp_Pnt2d(0.4, 25.)
    P4 = gp_Pnt2d(0.6, 55.)
    P5 = gp_Pnt2d(0.8, 28.)
    P6 = gp_Pnt2d(1., 20.)
    TabPoint.SetValue(1, P1)
    TabPoint.SetValue(2, P2)
    TabPoint.SetValue(3, P3)
    TabPoint.SetValue(4, P4)
    TabPoint.SetValue(5, P5)
    TabPoint.SetValue(6, P6)

    exp = TopologyExplorer(Box2).edges()
    next(exp)
    next(exp)
    next(exp)

    afillet.Add(TabPoint, next(exp))
    afillet.Build()
    if afillet.IsDone():
        LawEvolvedBox = afillet.Shape()
        display.DisplayShape(LawEvolvedBox)
    else:
        print("aFillet not done.")
    display.FitAll()
示例#12
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
# Combine the two constituent wires
mkWire = BRepBuilderAPI_MakeWire()
mkWire.Add(aWire.Wire())
mkWire.Add(aMirroredWire)
myWireProfile = mkWire.Wire()

# The face that we'll sweep to make the prism
myFaceProfile = BRepBuilderAPI_MakeFace(myWireProfile)

# We want to sweep the face along the Z axis to the height
aPrismVec = gp_Vec(0, 0, height)
myBody_step1 = BRepPrimAPI_MakePrism(myFaceProfile.Face(), aPrismVec)

# Add fillets to all edges through the explorer
mkFillet = BRepFilletAPI_MakeFillet(myBody_step1.Shape())
anEdgeExplorer = TopExp_Explorer(myBody_step1.Shape(), TopAbs_EDGE)

while anEdgeExplorer.More():
    anEdge = topods.Edge(anEdgeExplorer.Current())
    mkFillet.Add(thickness / 12.0, anEdge)

    anEdgeExplorer.Next()

# Create the neck of the bottle
neckLocation = gp_Pnt(0, 0, height)
neckAxis = gp_DZ()
neckAx2 = gp_Ax2(neckLocation, neckAxis)

myNeckRadius = thickness / 4.0
myNeckHeight = height / 10.0
示例#14
0
import os

from compas.geometry import Frame
from compas_occ.conversions.shapes import Box
from compas_occ.brep.datastructures import BRepShape

from OCC.Core.BRepFilletAPI import BRepFilletAPI_MakeFillet

HERE = os.path.dirname(__file__)
FILE = os.path.join(HERE, '__fillet.stp')

box = BRepShape(Box(Frame.worldXY(), 1, 1, 1).to_occ_shape())
fillet = BRepFilletAPI_MakeFillet(box.occ_shape)

for edge in box.edges():
    fillet.Add(0.1, edge)

shape = BRepShape(fillet.Shape())
shape.to_step(FILE)
# Combine the two constituent wires
mkWire = BRepBuilderAPI_MakeWire()
mkWire.Add(aWire.Wire())
mkWire.Add(aMirroredWire)
myWireProfile = mkWire.Wire()

# The face that we'll sweep to make the prism
myFaceProfile = BRepBuilderAPI_MakeFace(myWireProfile)

# We want to sweep the face along the Z axis to the height
aPrismVec = gp_Vec(0, 0, height)
myBody = BRepPrimAPI_MakePrism(myFaceProfile.Face(), aPrismVec)

# Add fillets to all edges through the explorer
mkFillet = BRepFilletAPI_MakeFillet(myBody.Shape())
anEdgeExplorer = TopExp_Explorer(myBody.Shape(), TopAbs_EDGE)

while anEdgeExplorer.More():
    anEdge = topods.Edge(anEdgeExplorer.Current())
    mkFillet.Add(thickness / 12.0, anEdge)

    anEdgeExplorer.Next()

myBody = mkFillet

# Create the neck of the bottle
neckLocation = gp_Pnt(0, 0, height)
neckAxis = gp_DZ()
neckAx2 = gp_Ax2(neckLocation, neckAxis)
示例#16
0
def startBottle(startOnly=True):  # minus the neck fillet, shelling & threads
    partName = "Bottle-start"
    # 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)

    # Get the mirrored shape back out of the transformation
    # and convert back to a wire
    aMirroredShape = aBRespTrsf.Shape()

    # A wire instead of a generic shape now
    aMirroredWire = topods.Wire(aMirroredShape)

    # Combine the two constituent wires
    mkWire = BRepBuilderAPI_MakeWire()
    mkWire.Add(aWire.Wire())
    mkWire.Add(aMirroredWire)
    myWireProfile = mkWire.Wire()

    # The face that we'll sweep to make the prism
    myFaceProfile = BRepBuilderAPI_MakeFace(myWireProfile)

    # We want to sweep the face along the Z axis to the height
    aPrismVec = gp_Vec(0, 0, height)
    myBody = BRepPrimAPI_MakePrism(myFaceProfile.Face(), aPrismVec)

    # Add fillets to all edges through the explorer
    mkFillet = BRepFilletAPI_MakeFillet(myBody.Shape())
    anEdgeExplorer = TopExp_Explorer(myBody.Shape(), TopAbs_EDGE)

    while anEdgeExplorer.More():
        anEdge = topods.Edge(anEdgeExplorer.Current())
        mkFillet.Add(thickness / 12.0, anEdge)

        anEdgeExplorer.Next()

    myBody = mkFillet.Shape()

    # Create the neck of the bottle
    neckLocation = gp_Pnt(0, 0, height)
    neckAxis = gp_DZ()
    neckAx2 = gp_Ax2(neckLocation, neckAxis)

    myNeckRadius = thickness / 4.0
    myNeckHeight = height / 10.0

    mkCylinder = BRepPrimAPI_MakeCylinder(neckAx2, myNeckRadius, myNeckHeight)
    myBody = BRepAlgoAPI_Fuse(myBody, mkCylinder.Shape())
    if startOnly:  # quit here
        uid = win.getNewPartUID(myBody.Shape(), name=partName)
        win.redraw()
        return

    partName = "Bottle-complete"
    # Our goal is to find the highest Z face and remove it
    faceToRemove = None
    zMax = -1

    # We have to work our way through all the faces to find the highest Z face
    aFaceExplorer = TopExp_Explorer(myBody.Shape(), TopAbs_FACE)
    while aFaceExplorer.More():
        aFace = topods.Face(aFaceExplorer.Current())

        if face_is_plane(aFace):
            aPlane = geom_plane_from_face(aFace)

            # We want the highest Z face, so compare this to the previous faces
            aPnt = aPlane.Location()
            aZ = aPnt.Z()
            if aZ > zMax:
                zMax = aZ
                faceToRemove = aFace

        aFaceExplorer.Next()

    facesToRemove = TopTools_ListOfShape()
    facesToRemove.Append(faceToRemove)

    myBody = BRepOffsetAPI_MakeThickSolid(myBody.Shape(), facesToRemove,
                                          -thickness / 50.0, 0.001)

    # Set up our surfaces for the threading on the neck
    neckAx2_Ax3 = gp_Ax3(neckLocation, gp_DZ())
    aCyl1 = Geom_CylindricalSurface(neckAx2_Ax3, myNeckRadius * 0.99)
    aCyl2 = Geom_CylindricalSurface(neckAx2_Ax3, myNeckRadius * 1.05)

    # Set up the curves for the threads on the bottle's neck
    aPnt = gp_Pnt2d(2.0 * math.pi, myNeckHeight / 2.0)
    aDir = gp_Dir2d(2.0 * math.pi, myNeckHeight / 4.0)
    anAx2d = gp_Ax2d(aPnt, aDir)

    aMajor = 2.0 * math.pi
    aMinor = myNeckHeight / 10.0

    anEllipse1 = Geom2d_Ellipse(anAx2d, aMajor, aMinor)
    anEllipse2 = Geom2d_Ellipse(anAx2d, aMajor, aMinor / 4.0)

    anArc1 = Geom2d_TrimmedCurve(anEllipse1, 0, math.pi)
    anArc2 = Geom2d_TrimmedCurve(anEllipse2, 0, math.pi)

    anEllipsePnt1 = anEllipse1.Value(0)
    anEllipsePnt2 = anEllipse1.Value(math.pi)

    aSegment = GCE2d_MakeSegment(anEllipsePnt1, anEllipsePnt2)

    # Build edges and wires for threading
    anEdge1OnSurf1 = BRepBuilderAPI_MakeEdge(anArc1, aCyl1)
    anEdge2OnSurf1 = BRepBuilderAPI_MakeEdge(aSegment.Value(), aCyl1)
    anEdge1OnSurf2 = BRepBuilderAPI_MakeEdge(anArc2, aCyl2)
    anEdge2OnSurf2 = BRepBuilderAPI_MakeEdge(aSegment.Value(), aCyl2)

    threadingWire1 = BRepBuilderAPI_MakeWire(anEdge1OnSurf1.Edge(),
                                             anEdge2OnSurf1.Edge())
    threadingWire2 = BRepBuilderAPI_MakeWire(anEdge1OnSurf2.Edge(),
                                             anEdge2OnSurf2.Edge())

    # Compute the 3D representations of the edges/wires
    breplib.BuildCurves3d(threadingWire1.Shape())
    breplib.BuildCurves3d(threadingWire2.Shape())

    # Create the surfaces of the threading
    aTool = BRepOffsetAPI_ThruSections(True)
    aTool.AddWire(threadingWire1.Wire())
    aTool.AddWire(threadingWire2.Wire())
    aTool.CheckCompatibility(False)
    myThreading = aTool.Shape()

    # Build the resulting compound
    aRes = TopoDS_Compound()
    aBuilder = BRep_Builder()
    aBuilder.MakeCompound(aRes)
    aBuilder.Add(aRes, myBody.Shape())
    aBuilder.Add(aRes, myThreading)
    uid = win.getNewPartUID(aRes, name=partName)
    win.redraw()
示例#17
0
    argvs = sys.argv
    parser = OptionParser()
    opt, argc = parser.parse_args(argvs)
    print(opt, argc)

    obj = plotocc()
    #
    # https://www.opencascade.com/doc/occt-7.4.0/overview/html/occt_user_guides__modeling_algos.html#occt_modalg_6
    # https://www.opencascade.com/doc/occt-7.5.0/overview/html/occt_user_guides__modeling_algos.html#occt_modalg_6
    #

    axs = gp_Ax3()
    box = make_box(200, 200, 200)
    chf = BRepFilletAPI_MakeChamfer(box)
    # chf.Build()
    fil = BRepFilletAPI_MakeFillet(box)
    fil.SetFilletShape(ChFi3d_Rational)
    par = TColgp_Array1OfPnt2d(1, 2)
    par.SetValue(1, gp_Pnt2d(-1000, 10))
    par.SetValue(2, gp_Pnt2d(1000, 10))
    top = TopExp_Explorer(box, TopAbs_EDGE)

    fil.Add(par, top.Current())
    top.Next()
    fil.Add(par, top.Current())
    top.Next()
    fil.Add(par, top.Current())

    write_step_file(box, obj.tmpdir + "box.stp")
    write_step_file(fil.Shape(), obj.tmpdir + "box_fillet.stp", "AP214IS")
    write_stl_file(fil.Shape(), obj.tmpdir + "box_fillet.stl")