Beispiel #1
0
    def fuse(self, *other_parts):
        """
        Fuse with other surface parts and rebuild both.

        :param afem.structure.entities.SurfacePart other_parts: The other
            part(s).

        :return: *True* if fused, *False* if not.
        :rtype: bool
        """
        # Putting the other parts in a compound avoids fusing them to each
        # other
        other_shapes = [part.shape for part in other_parts]
        other_compound = CompoundByShapes(other_shapes).compound

        fuse = FuseShapes(self._shape, other_compound)
        if not fuse.is_done:
            return False

        # Rebuild the part shapes
        parts = [self] + list(other_parts)
        shapes = [part.shape for part in parts]
        rebuild = RebuildShapesByTool(shapes, fuse)
        for part in parts:
            new_shape = rebuild.new_shape(part.shape)
            part.set_shape(new_shape)

        return True
Beispiel #2
0
    def __init__(self, groups, fuzzy_val=None, include_subgroup=True):
        if len(groups) < 2:
            raise ValueError('Not enough groups to fuse. Need at least '
                             'two.')

        bop = FuseShapes(fuzzy_val=fuzzy_val)

        groups = list(groups)
        parts1 = groups[0].get_parts(include_subgroup)
        shapes1 = [part.shape for part in parts1]
        shape1 = CompoundByShapes(shapes1).compound
        bop.set_args([shape1])

        tools = []
        other_parts = []
        for group in groups[1:]:
            parts = group.get_parts(include_subgroup)
            other_parts += parts
            shapes = [part.shape for part in parts]
            shape = CompoundByShapes(shapes).compound
            tools.append(shape)
        bop.set_tools(tools)

        bop.build()

        all_parts = parts1 + other_parts
        all_shapes = [part.shape for part in all_parts]
        rebuild = RebuildShapesByTool(all_shapes, bop)
        for part in all_parts:
            new_shape = rebuild.new_shape(part.shape)
            part.set_shape(new_shape)

        self._bop = bop
Beispiel #3
0
    def __init__(self, parts, tools, fuzzy_val=None):
        bop = FuseShapes(fuzzy_val=fuzzy_val)

        parts = list(parts)
        other_parts = list(tools)
        args = [part.shape for part in parts]
        bop.set_args(args)
        tools = [part.shape for part in tools]
        bop.set_tools(tools)
        bop.build()

        rebuild = RebuildShapesByTool(args + tools, bop)
        for part in parts + other_parts:
            new_shape = rebuild.new_shape(part.shape)
            part.set_shape(new_shape)

        self._is_done = bop.is_done
        self._fused_shape = bop.shape
Beispiel #4
0
    def __init__(self, parts, tools=None, fuzzy_val=None):
        bop = SplitShapes(fuzzy_val=fuzzy_val)

        args = [part.shape for part in parts]
        bop.set_args(args)

        if tools is not None:
            tools = [part.shape for part in tools]
            bop.set_tools(tools)

        bop.build()

        rebuild = RebuildShapesByTool(args, bop)
        for part in parts:
            new_shape = rebuild.new_shape(part.shape)
            part.set_shape(new_shape)

        self._is_done = bop.is_done
        self._split_shape = bop.shape