<commit_before>#  Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
#  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
#  This library is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Lesser General Public
#  License as published by the Free Software Foundation; either
#  version 2.1 of the License.
#
#  This library is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public
#  License along with this library; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
#
#  See http://www.opencascade.org/SALOME/ or email : <EMAIL>
#
#  File   : smesh.py
#  Author : <NAME>, OCC
#  Module : SMESH

"""
 \namespace smesh
 \brief Module smesh
"""

import salome
import geompy
import StdMeshers
import SMESH

# Public variables
# ----------------

REGULAR = 1
PYTHON  = 2

NETGEN  = 3
GHS3D   = 4

smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
smesh.SetCurrentStudy(salome.myStudy)

# Private functions
# -----------------

def GetName(obj):
    ior  = salome.orb.object_to_string(obj)
    sobj = salome.myStudy.FindObjectIOR(ior)
    attr = sobj.FindAttribute("AttributeName")[1]
    return attr.Value()

def SetName(obj, name):
    ior  = salome.orb.object_to_string(obj)
    sobj = salome.myStudy.FindObjectIOR(ior)
    attr = sobj.FindAttribute("AttributeName")[1]
    attr.SetValue(name)

# Algorithms and hypothesis
# =========================

# Private class: Mesh_Algorithm
# -----------------------------

class Mesh_Algorithm:
    """
    Mother class to define algorithm, recommended to don't use directly
    """

    mesh = 0
    geom = 0
    subm = 0

    def GetSubMesh(self):
        """
         If the algorithm is global, return 0
         else return the submesh associated to this algorithm
        """
        return self.subm

    def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
        """
         Private method
        """
        self.mesh = mesh
        piece = mesh.geom
        if geom==0:
            self.geom = piece
            name = GetName(piece)
        else:
            self.geom = geom
            name = geompy.SubShapeName(geom, piece)
            geompy.addToStudyInFather(piece, geom, name)
            self.subm = mesh.mesh.GetSubMesh(geom, hypo)

        algo = smesh.CreateHypothesis(hypo, so)
        SetName(algo, name + "/" + hypo)
        mesh.mesh.AddHypothesis(self.geom, algo)

    def Hypothesis(self, hyp, args=[], so="libStdMeshersEngine.so"):
        """
         Private method
        """
        hypo = smesh.CreateHypothesis(hyp, so)
        a = ""
        s = "="
        i = 0
        n = len(args)
        while i<n:
            a = a + s + str(args[i])
            s = ","
            i = i + 1
        SetName(hypo, GetName(self.geom) + "/" + hyp + a)
        self.mesh.mesh.AddHypothesis(self.geom, hypo)
        return hypo

# Public class: Mesh_Segment
# --------------------------

class Mesh_Segment(Mesh_Algorithm):
    """
    Class to define a segment 1D algorithm for discretization
    """
<commit_msg>PAL8626: do not publish GEOM object, already present in the study.<commit_after>#  Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
#  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
#  This library is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Lesser General Public
#  License as published by the Free Software Foundation; either
#  version 2.1 of the License.
#
#  This library is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public
#  License along with this library; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
#
#  See http://www.opencascade.org/SALOME/ or email : <EMAIL>
#
#  File   : smesh.py
#  Author : <NAME>, OCC
#  Module : SMESH

"""
 \namespace smesh
 \brief Module smesh
"""

import salome
import geompy
import StdMeshers
import SMESH

# Public variables
# ----------------

REGULAR = 1
PYTHON  = 2

NETGEN  = 3
GHS3D   = 4

smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
smesh.SetCurrentStudy(salome.myStudy)

# Private functions
# -----------------

NO_NAME = "NoName"

def GetName(obj):
    ior  = salome.orb.object_to_string(obj)
    sobj = salome.myStudy.FindObjectIOR(ior)
    if sobj is None:
        return NO_NAME
    else:
        attr = sobj.FindAttribute("AttributeName")[1]
        return attr.Value()

def SetName(obj, name):
    ior  = salome.orb.object_to_string(obj)
    sobj = salome.myStudy.FindObjectIOR(ior)
    attr = sobj.FindAttribute("AttributeName")[1]
    attr.SetValue(name)

# Algorithms and hypothesis
# =========================

# Private class: Mesh_Algorithm
# -----------------------------

class Mesh_Algorithm:
    """
    Mother class to define algorithm, recommended to don't use directly
    """

    mesh = 0
    geom = 0
    subm = 0

    def GetSubMesh(self):
        """
         If the algorithm is global, return 0
         else return the submesh associated to this algorithm
        """
        return self.subm

    def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
        """
         Private method
        """
        self.mesh = mesh
        piece = mesh.geom
        if geom==0:
            self.geom = piece
            name = GetName(piece)
        else:
            self.geom = geom
            name = GetName(geom)
            if name==NO_NAME:
                name = geompy.SubShapeName(geom, piece)
                geompy.addToStudyInFather(piece, geom, name)
            self.subm = mesh.mesh.GetSubMesh(geom, hypo)

        algo = smesh.CreateHypothesis(hypo, so)
        SetName(algo, name + "/" + hypo)
        mesh.mesh.AddHypothesis(self.geom, algo)

    def Hypothesis(self, hyp, args=[], so="libStdMeshersEngine.so"):
        """
         Private method
        """
        hypo = smesh.CreateHypothesis(hyp, so)
        a = ""
        s = "="
        i = 0
        n = len(args)
        while i<n:
            a = a + s + str(args[i])
            s = ","
            i = i + 1
        SetName(hypo, GetName(self.geom) + "/" + hyp + a)
        self.mesh.mesh.AddHypothesis(self.geom, hypo)
        return hypo

# Public class: Mesh_Segment
# --------------------------

class Mesh_Segment(Mesh_Algorithm):
    """
    Class to define a segment 1D algorithm for discretization
    """

{'fraction_non_alphanumeric': 0.12942191544434858, 'fraction_numerical': 0.01092896174863388, 'mean_word_length': 2.293087121212121, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '479769', 'n_tokens_mistral': 2305, 'n_tokens_neox': 2187, 'n_words': 655}