예제 #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_cref(self, cref):
        """
        Set the reference curve.

        :param afem.geometry.entities.Curve cref: The curve. If it is not a
            :class:`.TrimmedCurve`, then it will be converted to one. Access
            the original curve using the *basis_curve* property (i.e.,
            part.cref.basis_curve).
        :param cref: The reference curve.

        :return: None.

        :raise TypeError: If *cref* is not a curve.
        """
        if not CheckGeom.is_curve(cref):
            raise TypeError('Invalid curve type.')

        if isinstance(cref, TrimmedCurve):
            self._cref = cref
        else:
            self._cref = TrimmedCurve.by_parameters(cref)
예제 #3
0
 def has_cref(self):
     """
     :return: *True* if reference curve is available, *False* if not.
     :rtype: bool
     """
     return CheckGeom.is_curve(self.cref)
예제 #4
0
 def has_cref(self):
     """
     :return: *True* if part has a reference curve, *False* if not.
     :rtype: bool
     """
     return CheckGeom.is_curve(self._cref)