Example #1
0
    def is_closed_edge(edge):
        """
        Check if edge is closed.

        :param afem.topology.entities.Edge edge: The edge.

        :return: *True* if closed, *False* if not.
        :rtype: bool
        """
        return SMESH_MesherHelper.IsClosedEdge_(edge.object)
Example #2
0
    def is_structured(submesh):
        """
        Check if a 2-D mesh on a face is structured.

        :param afem.smesh.meshes.SubMesh submesh: The submesh.

        :return: *True* if structured, *False* if not.
        :rtype: bool
        """
        return SMESH_MesherHelper.IsStructured_(submesh.object)
Example #3
0
    def is_subshape_by_mesh(shape, mesh):
        """
        Check to see if the shape is a sub-shape in a mesh.

        :param afem.topology.entities.Shape shape: The shape.
        :param afem.smesh.meshes.Mesh mesh: The mesh.

        :return: *True* if a sub-shape, *False* if not.
        :rtype: bool
        """
        return SMESH_MesherHelper.IsSubShape_(shape.object, mesh.object)
Example #4
0
    def is_subshape_by_shape(shape, main_shape):
        """
        Check to see if the shape is a sub-shape in a shape.

        :param afem.topology.entities.Shape shape: The shape.
        :param afem.topology.entities.Shape main_shape: The main shape.

        :return: *True* if a sub-shape, *False* if not.
        :rtype: bool
        """
        return SMESH_MesherHelper.IsSubShape_(shape.object, main_shape.object)
Example #5
0
    def is_distorted2d(submesh, check_uv=False):
        """
        Check if a 2-D mesh on a face is distorted.

        :param afem.smesh.meshes.SubMesh submesh: The submesh.
        :param bool check_uv: Option to check using *uv* parameters.

        :return: *True* if distored, *False* if not.
        :rtype: bool
        """
        return SMESH_MesherHelper.IsDistorted2D_(submesh.object, check_uv)
Example #6
0
    def shape_by_hypothesis(hyp, shape, mesh):
        """
        Get a shape the hypothesis is applied to.

        :param afem.smesh.hypotheses.Hypothesis hyp: The hypothesis.
        :param afem.topology.entities.Shape shape: The shape.
        :param afem.smesh.meshes.Mesh mesh: The mesh.

        :return: The shape that the hypothesis is applied to.
        :rtype: afem.topology.entities.Shape
        """
        h, s, m = hyp.object, shape.object, mesh.object
        return Shape.wrap(SMESH_MesherHelper.GetShapeOfHypothesis_(h, s, m))
Example #7
0
    def subshape_by_node(node, mesh_ds):
        """
        Get the support shape of a node.

        :param afem.smesh.entities.Node node: The node.
        :param afem.smesh.meshes.MeshDS mesh_ds: The mesh data structure.

        :return: The support shape.
        :rtype: afem.topology.entities.Shape
        """
        n, m = node.object, mesh_ds.object
        shape = Shape.wrap(SMESH_MesherHelper.GetSubShapeByNode_(n, m))
        return shape
Example #8
0
    def get_angle(e1, e2, f, v):
        """
        Determine the angle between the two edges on a face.

        :param afem.topology.entities.Edge e1: The first edge.
        :param afem.topology.entities.Edge e2: The second edge.
        :param afem.topology.entities.Face f: The face the edges belong to.
        :param afem.topology.entities.Vertex v: The vertex connecting the two
            edges.

        :return: The angle between the edges.
        :rtype: float
        """
        return SMESH_MesherHelper.GetAngle_(e1.object, e2.object,
                                            f.object, v.object)
Example #9
0
    def common_ancestor(shape1, shape2, mesh, ancestor_type=Shape.EDGE):
        """
        Get a common ancestor between the two shapes.

        :param afem.topology.entities.Shape shape1: The first shape.
        :param afem.topology.entities.Shape shape2: The second shape.
        :param afem.smesh.meshes.Mesh mesh: The mesh.
        :param OCCT.TopAbs.TopAbs_ShapeEnum ancestor_type: The shape type.

        :return: The common ancestor.
        :rtype: afem.topology.entities.Edge
        """
        s1, s2, m = shape1.object, shape2.object, mesh.object
        e = Shape.wrap(SMESH_MesherHelper.GetCommonAncestor_(s1, s2, m,
                                                             ancestor_type))
        return e
Example #10
0
 def __init__(self, mesh):
     self._helper = SMESH_MesherHelper(mesh.object)
Example #11
0
class MeshHelper(object):
    """
    Mesh helper.

    :param afem.smesh.meshes.Mesh mesh: A mesh.
    """

    def __init__(self, mesh):
        self._helper = SMESH_MesherHelper(mesh.object)

    @property
    def object(self):
        """
        :return: The underlying object.
        :rtype: OCCT.SMESH.SMESH_MesherHelper
        """
        return self._helper

    @staticmethod
    def is_structured(submesh):
        """
        Check if a 2-D mesh on a face is structured.

        :param afem.smesh.meshes.SubMesh submesh: The submesh.

        :return: *True* if structured, *False* if not.
        :rtype: bool
        """
        return SMESH_MesherHelper.IsStructured_(submesh.object)

    @staticmethod
    def is_distorted2d(submesh, check_uv=False):
        """
        Check if a 2-D mesh on a face is distorted.

        :param afem.smesh.meshes.SubMesh submesh: The submesh.
        :param bool check_uv: Option to check using *uv* parameters.

        :return: *True* if distored, *False* if not.
        :rtype: bool
        """
        return SMESH_MesherHelper.IsDistorted2D_(submesh.object, check_uv)

    @staticmethod
    def subshape_by_node(node, mesh_ds):
        """
        Get the support shape of a node.

        :param afem.smesh.entities.Node node: The node.
        :param afem.smesh.meshes.MeshDS mesh_ds: The mesh data structure.

        :return: The support shape.
        :rtype: afem.topology.entities.Shape
        """
        n, m = node.object, mesh_ds.object
        shape = Shape.wrap(SMESH_MesherHelper.GetSubShapeByNode_(n, m))
        return shape

    @staticmethod
    def common_ancestor(shape1, shape2, mesh, ancestor_type=Shape.EDGE):
        """
        Get a common ancestor between the two shapes.

        :param afem.topology.entities.Shape shape1: The first shape.
        :param afem.topology.entities.Shape shape2: The second shape.
        :param afem.smesh.meshes.Mesh mesh: The mesh.
        :param OCCT.TopAbs.TopAbs_ShapeEnum ancestor_type: The shape type.

        :return: The common ancestor.
        :rtype: afem.topology.entities.Edge
        """
        s1, s2, m = shape1.object, shape2.object, mesh.object
        e = Shape.wrap(SMESH_MesherHelper.GetCommonAncestor_(s1, s2, m,
                                                             ancestor_type))
        return e

    @staticmethod
    def is_subshape_by_shape(shape, main_shape):
        """
        Check to see if the shape is a sub-shape in a shape.

        :param afem.topology.entities.Shape shape: The shape.
        :param afem.topology.entities.Shape main_shape: The main shape.

        :return: *True* if a sub-shape, *False* if not.
        :rtype: bool
        """
        return SMESH_MesherHelper.IsSubShape_(shape.object, main_shape.object)

    @staticmethod
    def is_subshape_by_mesh(shape, mesh):
        """
        Check to see if the shape is a sub-shape in a mesh.

        :param afem.topology.entities.Shape shape: The shape.
        :param afem.smesh.meshes.Mesh mesh: The mesh.

        :return: *True* if a sub-shape, *False* if not.
        :rtype: bool
        """
        return SMESH_MesherHelper.IsSubShape_(shape.object, mesh.object)

    @staticmethod
    def get_angle(e1, e2, f, v):
        """
        Determine the angle between the two edges on a face.

        :param afem.topology.entities.Edge e1: The first edge.
        :param afem.topology.entities.Edge e2: The second edge.
        :param afem.topology.entities.Face f: The face the edges belong to.
        :param afem.topology.entities.Vertex v: The vertex connecting the two
            edges.

        :return: The angle between the edges.
        :rtype: float
        """
        return SMESH_MesherHelper.GetAngle_(e1.object, e2.object,
                                            f.object, v.object)

    @staticmethod
    def is_closed_edge(edge):
        """
        Check if edge is closed.

        :param afem.topology.entities.Edge edge: The edge.

        :return: *True* if closed, *False* if not.
        :rtype: bool
        """
        return SMESH_MesherHelper.IsClosedEdge_(edge.object)

    @staticmethod
    def shape_by_hypothesis(hyp, shape, mesh):
        """
        Get a shape the hypothesis is applied to.

        :param afem.smesh.hypotheses.Hypothesis hyp: The hypothesis.
        :param afem.topology.entities.Shape shape: The shape.
        :param afem.smesh.meshes.Mesh mesh: The mesh.

        :return: The shape that the hypothesis is applied to.
        :rtype: afem.topology.entities.Shape
        """
        h, s, m = hyp.object, shape.object, mesh.object
        return Shape.wrap(SMESH_MesherHelper.GetShapeOfHypothesis_(h, s, m))

    def is_reversed_submesh(self, face):
        """
        Check to see if the elements have opposite orientation on the face.

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

        :return: *True* if reversed, *False* if not.
        :rtype: bool
        """
        return self._helper.IsReversedSubMesh(face.object)

    def set_subshape(self, shape):
        """
        Set the shape to make elements on.

        :param shape: The shape or the shape ID.
        :type shape: afem.topology.entities.Shape or int

        :return: None.
        """
        if isinstance(shape, Shape):
            self._helper.SetSubShape(shape.object)
        else:
            self._helper.SetSubShape(shape)

    def shape_to_index(self, shape):
        """
        Get the shape index.

        :param afem.topology.entities.Shape shape: The shape.

        :return: The shape index.
        :rtype: int
        """
        return self._helper.ShapeToIndex(shape.object)

    def add_node(self, x, y, z, id_=0, u=0., v=0.):
        """
        Create a node.

        :param float x: The x-location.
        :param float y: The y-location.
        :param float z: The z-location.
        :param int id_: The node ID. If zero then the ID will be assigned.
        :param float u: The node u-parameter.
        :param float v: The node v-parameter.

        :return: The created node.
        :rtype: afem.smesh.entities.Node
        """
        smesh_node = self._helper.AddNode(x, y, z, id_, u, v)
        return Node(smesh_node)

    def add_edge(self, n1, n2, id_=0, force3d=True):
        """
        Add an edge.

        :param afem.smesh.entities.Node n1: The first node.
        :param afem.smesh.entities.Node n2: The second node.
        :param int id_: The edge ID. If zero then the ID will be assigned.
        :param force3d: Unknown option.

        :return: The created edge.
        :rtype: afem.smesh.entities.Element
        """
        smesh_elm = self._helper.AddEdge(n1.object, n2.object, id_, force3d)
        return Element(smesh_elm)

    def add_face(self, n1, n2, n3, n4=None, id_=0, force3d=False):
        """
        Add a face.

        :param afem.smesh.entities.Node n1: The first node.
        :param afem.smesh.entities.Node n2: The second node.
        :param afem.smesh.entities.Node n3: The third node.
        :param afem.smesh.entities.Node n4: The fourth node. If provided then
            the face will be a quadrangle, if not provided then the face is
            a triangle.
        :param int id_: The face ID. If zero then the ID will be assigned.
        :param force3d: Unknown option.

        :return: The created face.
        :rtype: afem.smesh.entities.Element
        """
        if n4 is None:
            smesh_elm = self._helper.AddFace(n1.object, n2.object, n3.object,
                                             id_, force3d)
        else:
            smesh_elm = self._helper.AddFace(n1.object, n2.object, n3.object,
                                             n4.object, id_, force3d)
        return Element(smesh_elm)