Esempio n. 1
0
    def to_shell(cls, entity):
        """
        Convert an entity to a shell.

        :param entity: The entity.

        :return: A shell.
        :rtype: OCCT.TopoDS.TopoDS_Shell

        :raise TypeError: If entity cannot be converted to a shell.
        """
        if isinstance(entity, TopoDS_Shell):
            return entity

        if cls.is_shape(entity) and entity.ShapeType() == TopAbs_SHELL:
            return TopoDS.Shell_(entity)

        if cls.is_shape(entity) and entity.ShapeType() == TopAbs_FACE:
            shell = TopoDS_Shell()
            builder = BRep_Builder()
            builder.MakeShell(shell)
            builder.Add(shell, entity)
            return shell

        raise TypeError('Failed to convert entity to a shell.')
Esempio n. 2
0
 def __init__(self, faces):
     topods_shell = TopoDS_Shell()
     builder = BRep_Builder()
     builder.MakeShell(topods_shell)
     for face in faces:
         builder.Add(topods_shell, face.object)
     self._shell = Shell(topods_shell)
Esempio n. 3
0
    def to_shell(self):
        """
        Create a shell from the face.

        :return: The shell.
        :rtype: afem.topology.entities.Shell
        """
        topods_shell = TopoDS_Shell()
        builder = BRep_Builder()
        builder.MakeShell(topods_shell)
        builder.Add(topods_shell, self.object)
        return Shell(topods_shell)
Esempio n. 4
0
    def by_face(face):
        """
        Create a shell from a face.

        :param afem.topology.entities.Face face: The face.

        :return: The shell.
        :rtype: afem.topology.entities.Shell
        """
        topods_shell = TopoDS_Shell()
        builder = BRep_Builder()
        builder.MakeShell(topods_shell)
        builder.Add(topods_shell, face.object)
        return Shell(topods_shell)