Exemple #1
0
    def shared_faces(self, other, as_compound=False):
        """
        Get shared faces between this shape and the other.

        :param afem.topology.entities.Shape other: The other shape.
        :param bool as_compound: Option to return shared shapes as a single
            compound.

        :return: Shared faces.
        :rtype: list(afem.topology.entities.Face) or
            afem.topology.entities.Compound
        """
        this_map = TopTools_IndexedMapOfShape()
        TopExp.MapShapes_(self.object, Shape.FACE, this_map)
        if this_map.Extent() == 0:
            return []

        other_map = TopTools_IndexedMapOfShape()
        TopExp.MapShapes_(other.object, Shape.FACE, other_map)
        if other_map.Extent() == 0:
            return []

        faces = []
        for i in range(1, this_map.Size() + 1):
            f1 = this_map.FindKey(i)
            if other_map.Contains(f1):
                faces.append(Shape.wrap(f1))

        if as_compound:
            return Compound.by_shapes(faces)
        return faces
Exemple #2
0
 def num_faces(self):
     """
     :return: The number of faces in the shape.
     :rtype: int
     """
     map_ = TopTools_IndexedMapOfShape()
     TopExp.MapShapes_(self.object, Shape.FACE, map_)
     return map_.Extent()