Ejemplo n.º 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
    """
    _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
Ejemplo n.º 2
0
    def update_shape(self, change={}):
        d = self.declaration

        #: Get the shape to apply the fillet to
        s = self.get_shape()

        if isinstance(s.shape, BRepBuilderAPI_MakeWire):
            shape = BRepOffsetAPI_MakeOffset(s.shape.Wire(),
                                             self.join_types[d.join_type])
            shape.Perform(d.offset)
            self.shape = shape
        else:

            self.shape = BRepOffsetAPI_MakeOffsetShape(
                s.shape.Shape() if hasattr(s.shape, 'Shape') else s.shape,
                d.offset, d.tolerance, self.offset_modes[d.offset_mode],
                d.intersection, False, self.join_types[d.join_type])
Ejemplo n.º 3
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()