Exemplo n.º 1
0
    def set_shape(self, shape):
        """
        Set the shape.

        :param afem.topology.entities.Shape shape: The shape.

        :return: None.
        """
        if not isinstance(shape, self._types):
            this = self.__class__.__name__
            other = shape.__class__.__name__

            expected = []
            for type_ in self._types:
                expected.append(type_.__name__)
            if len(expected) == 1:
                expected = 'a ' + expected[0]
            else:
                expected = 'one of (' + ', '.join(expected) + ')'
            name = 'Unknown'
            if isinstance(self, NamedItem):
                name = self.name
            msg = ('Invalid shape provided for a {} object with name {}. '
                   'Got a {} but expected {}.'.format(this, name, other,
                                                      expected))
            logger.warning(msg)

        self._shape = shape
Exemplo n.º 2
0
    def __init__(self, shape, other_shapes):
        results = []
        for shape2 in other_shapes:
            dist = DistanceShapeToShape(shape, shape2)
            if dist.nsol == 0:
                logger.warning("Could not calculate distance to a shape in "
                               "DistanceShapeToShapes tool. Continuing...")
                continue
            results.append((dist.dmin, shape2))

        results.sort(key=lambda tup: tup[0])
        self._distances = [data[0] for data in results]
        self._shapes = [data[1] for data in results]
Exemplo n.º 3
0
    def refine_edges(self):
        """
        Fuse C1 edges.

        :return: None.
        """
        if isinstance(self._bop, (BRepAlgoAPI_Splitter, BOPAlgo_MakerVolume,
                                  BRepFeat_MakeCylindricalHole)):
            n = self._bop.__class__.__name__
            msg = ('Refining edges not available for {}. '
                   'Doing nothing.'.format(n))
            logger.warning(msg)
        else:
            self._bop.RefineEdges()
Exemplo n.º 4
0
    def set_tools(self, shapes):
        """
        Set the tools.

        :param list(afem.topology.entities.Shape) shapes: The tools.

        :return: None.
        """
        if isinstance(self._bop, BOPAlgo_MakerVolume):
            n = self._bop.__class__.__name__
            msg = ('Setting tools not available for {}. '
                   'Doing nothing.'.format(n))
            logger.warning(msg)
            return None

        tools = to_topods_list(shapes)
        self._bop.SetTools(tools)