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))
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
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
def has_sref(self): """ :return: *True* if reference surface is available, *False* if not. :rtype: bool """ return CheckGeom.is_surface(self.sref)
def has_sref(self): """ :return: *True* if part has a reference surface, *False* if not. :rtype: bool """ return CheckGeom.is_surface(self._sref)