예제 #1
0
파일: entities.py 프로젝트: trelau/AFEM
    def to_shape(entity):
        """
        Convent an entity to a shape. If already a shape the entity is
        returned. If the entity is geometry it is converted to its
        corresponding shape.

        :param entity: The entity.
        :type entity: afem.topology.entities.Shape or
            afem.geometry.entities.Curve or afem.geometry.entities.Surface or
            point_like

        :return: The shape.
        :rtype: afem.topology.entities.Shape

        :raise TypeError: If entity cannot be converted to a shape.
        """
        if entity is None:
            return None

        if isinstance(entity, Shape):
            return entity

        if CheckGeom.is_point_like(entity):
            return Vertex.by_point(entity)
        elif CheckGeom.is_curve(entity):
            return Edge.by_curve(entity)
        elif CheckGeom.is_surface(entity):
            return Face.by_surface(entity)
        else:
            n = entity.__class__.__name__
            raise TypeError('Cannot convert a {} to a shape.'.format(n))
예제 #2
0
    def set_sref(self, sref):
        """
        Set the reference surface. This method also automatically creates a
        "reference surface shape" by converting the given surface into a face,
        dividing it if it is closed, and then dividing it at C0 boundaries.
        This shape is made available to improve robustness for certain
        topological operations and can be accessed via the `sref_shape`
        property.

        :param afem.geometry.entities.Surface sref: The surface.

        :return: None.

        :raise TypeError: If *sref* is not a surface.
        """
        if not CheckGeom.is_surface(sref):
            msg = 'Invalid surface type.'
            raise TypeError(msg)

        # Set the surface
        self._sref = sref

        # Convert to a shape for robustness
        shape = FaceBySurface(sref).face
        shape = DivideClosedShape(shape).shape
        shape = DivideC0Shape(shape).shape
        self._sref_shape = shape
예제 #3
0
    def set_sref(self, sref):
        """
        Set the part reference surface.

        :param afem.geometry.entities.Surface sref: The surface.

        :return: None.

        :raise TypeError: If *sref* is an invalid surface.
        """
        if not CheckGeom.is_surface(sref):
            msg = 'Invalid surface type.'
            raise TypeError(msg)
        self._sref = sref
예제 #4
0
 def has_sref(self):
     """
     :return: *True* if reference surface is available, *False* if not.
     :rtype: bool
     """
     return CheckGeom.is_surface(self.sref)
예제 #5
0
 def has_sref(self):
     """
     :return: *True* if part has a reference surface, *False* if not.
     :rtype: bool
     """
     return CheckGeom.is_surface(self._sref)