示例#1
0
def make_offset(wire_or_face,
                offsetDistance,
                altitude=0,
                joinType=GeomAbs_Arc):
    '''
    builds a offsetted wire or face from a wire or face
    construct an offsetted version of the shape

    @param wire_or_face:        the wire or face to offset
    @param offsetDistance:      the distance to offset
    @param altitude:            move the offsetted shape to altitude
    from the normal of the wire or face
    @param joinType:            the type of offset you want
    can be one of GeomAbs_Arc, GeomAbs_Tangent, GeomAbs_Intersection

    note: a shape that has a negative offsetDistance will return
    a sharp corner
    '''
    from OCC.Core.BRepOffsetAPI import BRepOffsetAPI_MakeOffset
    _joints = [GeomAbs_Arc, GeomAbs_Tangent, GeomAbs_Intersection]
    assert joinType in _joints, '%s is not one of %s' % (joinType, _joints)
    try:
        offset = BRepOffsetAPI_MakeOffset(wire_or_face, joinType)
        offset.Perform(offsetDistance, altitude)
        if offset.IsDone():
            return ST(offset.Shape())
        else:
            return None
    except RuntimeError('failed to offset shape'):
        return None
示例#2
0
 def __init__(self,
              spine,
              distance,
              altitude=0.,
              join=Geometry.ARC,
              is_open=False):
     offset = BRepOffsetAPI_MakeOffset(spine.object, join, is_open)
     offset.Perform(distance, altitude)
     self._w = Wire(offset.Shape())
示例#3
0
    def getDaoOffsetWire(self, offset):

        classicWire = self.getCached('getDaoClassicWire')

        tool = BRepOffsetAPI_MakeOffset()
        tool.AddWire(classicWire)
        tool.Perform(-offset)
        offsetWire = tool.Shape()

        return offsetWire
示例#4
0
def create_offsets(face, nr_of_counters, distance_between_contours):
    offset = BRepOffsetAPI_MakeOffset()
    offset.Init(GeomAbs_Arc)

    for wi in TopologyExplorer(face).wires():
        offset.AddWire(wi)

    for i in range(nr_of_counters):
        offset.Perform(-distance_between_contours * i)
        if offset.IsDone():
            yield offset.Shape()
示例#5
0
def make_offsets(face, num, distance):
    offset = BRepOffsetAPI_MakeOffset(face, GeomAbs_Arc, False)
    # add all wires to offset algo
    for w in TopologyExplorer(face).wires():
        offset.AddWire(w)
    result = []
    # perform offsets
    for i in range(num):
        offset.Perform(-1 * distance * i)
        if offset.IsDone():
            # display.DisplayShape(offset.Shape(), update=True)
            result.append(offset.Shape())

    return result
示例#6
0
def makeOffsetWire(aWire, offset):
    tool = BRepOffsetAPI_MakeOffset()
    tool.AddWire(aWire)
    tool.Perform(offset)
    aOffsetWire = tool.Shape()
    return aOffsetWire
示例#7
0
def getShapeOffset(shape, offset):
    tool = BRepOffsetAPI_MakeOffset()
    tool.AddWire(shape)
    tool.Perform(offset)
    shape = tool.Shape()
    return shape