示例#1
0
def translate_shape(shape, vec):
    """
    Translate a shape along a vector.

    :param afem.topology.entities.Shape shape: The shape.
    :param Union[afem.geometry.entitites.Vector, Sequence] vec: The vector.

    :return: The translated shape.
    :rtype: afem.topology.entities.Shape

    :raise RuntimeError: If the translation fails or is not done.
    """
    trsf = gce_MakeTranslation(vec.gp_vec).Value()
    builder = BRepBuilderAPI_Transform(shape.object, trsf, True)
    if not builder.IsDone():
        raise RuntimeError('Failed to mirror the shape.')
    return Shape.wrap(builder.Shape())
示例#2
0
def mirror_shape(shape, pln):
    """
    Mirror a shape about a plane.

    :param afem.topology.entities.Shape shape: The shape.
    :param afem.geometry.entities.Plane pln: The plane.

    :return: The mirrored shape.
    :rtype: afem.topology.entities.Shape

    :raise RuntimeError: If the transformation fails or is not done.
    """
    trsf = gce_MakeMirror(pln.gp_pln).Value()
    builder = BRepBuilderAPI_Transform(shape.object, trsf, True)
    if not builder.IsDone():
        raise RuntimeError('Failed to mirror the shape.')
    return Shape.wrap(builder.Shape())