예제 #1
0
파일: entities.py 프로젝트: sanderboer/AFEM
    def distance(self, other):
        """
        Find the minimum distance between the part and other shape.

        :param other: Other part or shape.
        :type other: afem.topology.entities.Shape or
            afem.structure.entities.Part

        :return: The minimum distance.
        :rtype: float
        """
        other = shape_of_entity(other)
        return DistanceShapeToShape(self._shape, other).dmin
예제 #2
0
파일: entities.py 프로젝트: sanderboer/AFEM
    def discard_by_dmin(self, entity, dmin):
        """
        Discard shapes of the part using a shape and a distance. If the
        distance between a shape of the part and the given shape is less
        than *dmin*, then the shape is removed. Edges are checked
        for curve parts and faces are checked for surface parts.

        :param entity: The shape.
        :type entity: afem.topology.entities.Shape or
            afem.geometry.entities.Geometry
        :param float dmin: The minimum distance.

        :return: *True* if shapes were discarded, *False* if not.
        :rtype: bool

        :raise TypeError: If this part is not a curve or surface part.
        """
        entity = Shape.to_shape(entity)

        if isinstance(self, CurvePart):
            shapes = self.shape.edges
        elif isinstance(self, SurfacePart):
            shapes = self.shape.faces
        else:
            msg = 'Invalid part type in discard operation.'
            raise TypeError(msg)

        rebuild = RebuildShapeWithShapes(self._shape)

        modified = False
        for part_shape in shapes:
            dmin_ = DistanceShapeToShape(entity, part_shape).dmin
            if dmin > dmin_:
                rebuild.remove(part_shape)
                modified = True

        if not modified:
            return False

        new_shape = rebuild.apply()
        self.set_shape(new_shape)
        return True