From 14c45e1f6f60a0c520f3c9b5164f342eddbe45d6 Mon Sep 17 00:00:00 2001 From: GERALD NICOLAS Date: Mon, 26 Apr 2021 09:42:17 +0200 Subject: [PATCH 01/17] Changement de nom --- ...ssure_without_session.py => blocFissure_01_without_session.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename doc/salome/examples/{blocFissure_without_session.py => blocFissure_01_without_session.py} (100%) diff --git a/doc/salome/examples/blocFissure_without_session.py b/doc/salome/examples/blocFissure_01_without_session.py similarity index 100% rename from doc/salome/examples/blocFissure_without_session.py rename to doc/salome/examples/blocFissure_01_without_session.py From e55b4566a423f05e3f986988a596b299bc9d58a3 Mon Sep 17 00:00:00 2001 From: GERALD NICOLAS Date: Mon, 26 Apr 2021 10:34:06 +0200 Subject: [PATCH 02/17] passage en classe --- .../blocFissure/CasTests/execution_Cas.py | 686 ++++++++++++------ 1 file changed, 470 insertions(+), 216 deletions(-) diff --git a/src/Tools/blocFissure/CasTests/execution_Cas.py b/src/Tools/blocFissure/CasTests/execution_Cas.py index 2213dbce7..ef550f868 100644 --- a/src/Tools/blocFissure/CasTests/execution_Cas.py +++ b/src/Tools/blocFissure/CasTests/execution_Cas.py @@ -17,10 +17,13 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # +__revision__ = "V02.01" + """Lancement des cas-tests de blocFissure""" import logging import os +import sys import tempfile import traceback @@ -35,236 +38,437 @@ LOGFILE = os.path.join(tempfile.gettempdir(),"blocFissure.log") #initLog.setPerfTests(LOGFILE) # critical = 50 #initLog.setAlways(LOGFILE) # critical = 50 -# ---tous les cas en séquence, ou les cas sélectionnés ... +# Les cas qui marchent ... TORUNOK = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ] # OK 19/04/2021 # 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28 -#RUNALL = False -RUNALL = True -if RUNALL: - TORUN = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] -# 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28 - TORUN = TORUNOK -else: - TORUNPB = list() - for IAUX in TORUNOK: - TORUNPB.append((IAUX+1)%2) - print ("TORUN = {} # OK".format(TORUNOK)) - print ("TORUN = {} # PB".format(TORUNPB)) -# genereMateriel - TORUN = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0] # aucun - TORUN = [ 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # cubeAngle - TORUN = [ 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # cubeFin - TORUN = [ 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # decoupeCylindre - TORUN = [ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # disque_perce + ellipse_disque - TORUN = [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # ellipse + fissureGauche2 - TORUN = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # ellipse_probleme + fissureGauche2 - TORUN = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # eprouvetteCourbe - TORUN = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # eprouvetteDroite - TORUN = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # fissureGauche - TORUN = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # fissureGauche2 - TORUN = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0] # vis - TORUN = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] # tube -# 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28 - TORUN = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0] # OK -# ----------------------------------------------------------------------------------------------- +TORUNPB = list() +for IAUX in TORUNOK: + TORUNPB.append((IAUX+1)%2) +print ("TORUN = {} # OK".format(TORUNOK)) +print ("TORUN = {} # PB".format(TORUNPB)) -def caract_l_problemes (): - """Caractérisation des problèmes""" - d_aux = dict() - l_problemes = list() +# Numéro de référence associé à chaque problème +NREF_PB = dict() +NREF_PB["cubeAngle"] = 0 +NREF_PB["cubeAngle2"] = 1 +NREF_PB["cubeCoin"] = 2 +NREF_PB["cubeMilieu"] = 3 +NREF_PB["cubeTransverse"] = 4 +NREF_PB["cylindre"] = 5 +NREF_PB["cylindre2"] = 6 +NREF_PB["disquePerce"] = 7 +NREF_PB["ellipse1"] = 8 +NREF_PB["ellipse2"] = 9 +NREF_PB["eprouvetteCourbe"] = 10 +NREF_PB["eprouvetteDroite"] = 11 +NREF_PB["eprouvetteDroite_2"] = 12 +NREF_PB["faceGauche"] = 13 +NREF_PB["faceGauche_2"] = 14 +NREF_PB["fissureCoude_1"] = 15 +NREF_PB["fissureCoude_2"] = 16 +NREF_PB["fissureCoude_3"] = 17 +NREF_PB["fissureCoude_4"] = 18 +NREF_PB["fissureCoude_5"] = 19 +NREF_PB["fissureCoude_6"] = 20 +NREF_PB["fissureCoude_7"] = 21 +NREF_PB["fissureCoude_8"] = 22 +NREF_PB["fissureCoude_9"] = 23 +NREF_PB["fissureCoude_10"] = 24 +NREF_PB["fissure_Coude"] = 25 +NREF_PB["fissure_Coude_4"] = 26 +NREF_PB["vis_1"] = 27 +NREF_PB["tube"] = 28 - n_cas = 0 - # genereMateriel : cubeAngle - from blocFissure.CasTests.cubeAngle import cubeAngle - l_problemes.append(cubeAngle(n_cas)) +#========================= Début de la classe =================================== - n_cas = 1 - # genereMateriel : cubeAngle - from blocFissure.CasTests.cubeAngle2 import cubeAngle2 - l_problemes.append(cubeAngle2(n_cas)) +class blocFissureTest (object): - n_cas = 2 - # genereMateriel : cubeFin - from blocFissure.CasTests import cubeCoin - l_problemes.append(casStandard(cubeCoin.dicoParams, cubeCoin.referencesMaillageFissure, n_cas)) - d_aux[n_cas] = "cubeCoin" + """Test de blocFissure - n_cas = 3 - # genereMateriel : cubeFin - from blocFissure.CasTests import cubeMilieu - l_problemes.append(casStandard(cubeMilieu.dicoParams, cubeMilieu.referencesMaillageFissure, n_cas)) - d_aux[n_cas] = "cubeMilieu" +Options facultatives +******************** +Le(s) numéro/nom du/des tests à passer. Si aucun n'est donné, tous les cas sont passés. + """ - n_cas = 4 - # genereMateriel : cubeFin - from blocFissure.CasTests import cubeTransverse - l_problemes.append(casStandard(cubeTransverse.dicoParams, cubeTransverse.referencesMaillageFissure, n_cas)) - d_aux[n_cas] = "cubeTransverse" +# A. La base - n_cas = 5 - # genereMateriel : decoupeCylindre - from blocFissure.CasTests.cylindre import cylindre - l_problemes.append(cylindre(n_cas)) + message_info = "" + _verbose = 0 + _verbose_max = 0 + affiche_aide_globale = 0 - n_cas = 6 - # genereMateriel : decoupeCylindre - from blocFissure.CasTests.cylindre_2 import cylindre_2 - l_problemes.append(cylindre_2(n_cas)) +# B. Les variables - n_cas = 7 - # genereMateriel : disque_perce - # genereMateriel : ellipse_disque - from blocFissure.CasTests import disquePerce - l_problemes.append(casStandard(disquePerce.dicoParams, disquePerce.referencesMaillageFissure, n_cas)) - d_aux[n_cas] = "disquePerce" + l_cas = None + l_problemes = None + d_nom_probleme = None + l_materiels = None - n_cas = 8 - # genereMateriel: ellipse - # genereMateriel : fissureGauche2 - from blocFissure.CasTests.ellipse_1 import ellipse_1 - l_problemes.append(ellipse_1(n_cas)) +#=========================== Début de la méthode ================================= - n_cas = 9 - # genereMateriel: ellipse_probleme - # genereMateriel : fissureGauche2 - from blocFissure.CasTests.ellipse_2 import ellipse_2 - l_problemes.append(ellipse_2(n_cas)) + def __init__ ( self, liste_option ): - n_cas = 10 - # genereMateriel : eprouvetteCourbe - from blocFissure.CasTests.eprouvetteCourbe import eprouvetteCourbe - l_problemes.append(eprouvetteCourbe(n_cas)) + """Le constructeur de la classe blocFissureTest""" - n_cas = 11 - # genereMateriel : eprouvetteDroite - from blocFissure.CasTests.eprouvetteDroite import eprouvetteDroite - l_problemes.append(eprouvetteDroite(n_cas)) + self.l_cas = list() + erreur = False - n_cas = 12 - # genereMateriel : eprouvetteDroite - from blocFissure.CasTests.eprouvetteDroite_2 import eprouvetteDroite_2 - l_problemes.append(eprouvetteDroite_2(n_cas)) + for option in liste_option : - n_cas = 13 - # genereMateriel : fissureGauche - from blocFissure.CasTests.faceGauche import faceGauche - l_problemes.append(faceGauche(n_cas)) + #print (option, type(option)) + if isinstance(option, str): + saux = option.upper() + else: + saux = option + #print (saux) + # Options générales de pilotage + if saux in ( "-H", "-HELP" ): + self.affiche_aide_globale = 1 + elif saux == "-V" : + self._verbose = 1 + elif saux == "-VMAX" : + self._verbose = 1 + self._verbose_max = 1 - n_cas = 14 - # genereMateriel : fissureGauche2 - from blocFissure.CasTests.faceGauche_2 import faceGauche_2 - l_problemes.append(faceGauche_2(n_cas)) + else : + # Options du traitement + if isinstance(option, int): + self.l_cas.append(option) + elif ( option in NREF_PB ): + self.l_cas.append(NREF_PB[option]) + else: + print ("Option inconnue : {}".format(option)) + erreur = True - n_cas = 15 - # genereMateriel : aucun - from blocFissure.CasTests.fissureCoude_1 import fissureCoude_1 - l_problemes.append(fissureCoude_1(n_cas)) +# Si aucun cas n'est donné, on prend tous ceux par défaut + if not self.l_cas: + for i_aux, valeur in enumerate(TORUNOK): + if valeur: + self.l_cas.append(i_aux) - n_cas = 16 - # genereMateriel : aucun - from blocFissure.CasTests.fissureCoude_2 import fissureCoude_2 - l_problemes.append(fissureCoude_2(n_cas)) + if erreur: + self.l_cas = list() - n_cas = 17 - # genereMateriel : aucun - from blocFissure.CasTests.fissureCoude_3 import fissureCoude_3 - l_problemes.append(fissureCoude_3(n_cas)) + if self._verbose_max: + print ("Liste des cas : {}".format(self.l_cas)) - n_cas = 18 - # genereMateriel : aucun - from blocFissure.CasTests.fissureCoude_4 import fissureCoude_4 - l_problemes.append(fissureCoude_4(n_cas)) + if self._verbose_max: + initLog.setVerbose(LOGFILE) # info = 20 + #if self._verbose_max: + #initLog.setDebug(LOGFILE) # debug = 10 - n_cas = 19 - # genereMateriel : aucun - from blocFissure.CasTests.fissureCoude_5 import fissureCoude_5 - l_problemes.append(fissureCoude_5(n_cas)) +#=========================== Fin de la méthode ================================== - n_cas = 20 - # genereMateriel : aucun - from blocFissure.CasTests.fissureCoude_6 import fissureCoude_6 - l_problemes.append(fissureCoude_6(n_cas)) +#=========================== Début de la méthode ================================= - n_cas = 21 - # genereMateriel : aucun - from blocFissure.CasTests.fissureCoude_7 import fissureCoude_7 - l_problemes.append(fissureCoude_7(n_cas)) + def __del__(self): + """A la suppression de l'instance de classe""" + if self._verbose_max: + print ("Suppression de l'instance de la classe.") - n_cas = 22 - # genereMateriel : aucun - from blocFissure.CasTests.fissureCoude_8 import fissureCoude_8 - l_problemes.append(fissureCoude_8(n_cas)) +#=========================== Fin de la méthode ================================== - n_cas = 23 - # genereMateriel : aucun - from blocFissure.CasTests.fissureCoude_9 import fissureCoude_9 - l_problemes.append(fissureCoude_9(n_cas)) +#=========================== Début de la méthode ================================= - n_cas = 24 - # genereMateriel : aucun - from blocFissure.CasTests.fissureCoude_10 import fissureCoude_10 - l_problemes.append(fissureCoude_10(n_cas)) + def caract_l_problemes (self): + """Caractérisation des problèmes""" + self.d_nom_probleme = dict() + self.l_problemes = list() + self.l_materiels = list() - n_cas = 25 - # genereMateriel : aucun - from blocFissure.CasTests.fissure_Coude import fissure_Coude - l_problemes.append(fissure_Coude(n_cas)) + n_cas = 0 + if n_cas in self.l_cas: + # genereMateriel : cubeAngle + from blocFissure.CasTests.cubeAngle import cubeAngle + self.l_problemes.append(cubeAngle(n_cas)) + self.l_materiels.append("cubeAngle") - n_cas = 26 - # genereMateriel : aucun - from blocFissure.CasTests.fissure_Coude_4 import fissure_Coude_4 - l_problemes.append(fissure_Coude_4(n_cas)) + n_cas = 1 + if n_cas in self.l_cas: + # genereMateriel : cubeAngle + from blocFissure.CasTests.cubeAngle2 import cubeAngle2 + self.l_problemes.append(cubeAngle2(n_cas)) + self.l_materiels.append("cubeAngle") - n_cas = 27 - # genereMateriel : vis - from blocFissure.CasTests.vis_1 import vis_1 - l_problemes.append(vis_1(n_cas)) + n_cas = 2 + if n_cas in self.l_cas: + # genereMateriel : cubeFin + from blocFissure.CasTests import cubeCoin + self.l_problemes.append(casStandard(cubeCoin.dicoParams, cubeCoin.referencesMaillageFissure, n_cas)) + self.d_nom_probleme[n_cas] = "cubeCoin" + self.l_materiels.append("cubeFin") - n_cas = 28 - # genereMateriel : tube - from blocFissure.CasTests.tube import tube - l_problemes.append(tube(n_cas)) - #"Mesh_13" has not been computed: - #- "algo2d_facePeau_0" failed on "FACE_12 to mesh". Error: Algorithm failed. NgException at Surface meshing: Problem in Surface mesh generation - #- "algo1d_cercle1_0" failed on EDGE #20. Error: Algorithm failed. Source elements don't cover totally the geometrical edge - #- "algo1d_cercle1_0" failed on EDGE #17. Error: Algorithm failed. Source elements don't cover totally the geometrical edge - #- "algo1d_cercle1_0" failed on EDGE #15. Error: Algorithm failed. Source elements don't cover totally the geometrical edge - #- "algo1d_cercle1_0" failed on EDGE #12. Error: Algorithm failed. Source elements don't cover totally the geometrical edge + n_cas = 3 + if n_cas in self.l_cas: + # genereMateriel : cubeFin + from blocFissure.CasTests import cubeMilieu + self.l_problemes.append(casStandard(cubeMilieu.dicoParams, cubeMilieu.referencesMaillageFissure, n_cas)) + self.d_nom_probleme[n_cas] = "cubeMilieu" + self.l_materiels.append("cubeFin") - return l_problemes, d_aux -#============================================================= -def calcul_cas (n_cas, cas, d_aux, ligne): - """Calcul d'un cas""" - texte = "" - if n_cas in d_aux: - nom = d_aux[n_cas] - else: - nom = cas.nomProbleme - texte_a = "\n=== Exécution du cas n° {}, '{}'".format(n_cas,nom) - logging.critical(ligne+texte_a) + n_cas = 4 + if n_cas in self.l_cas: + # genereMateriel : cubeFin + from blocFissure.CasTests import cubeTransverse + self.l_problemes.append(casStandard(cubeTransverse.dicoParams, cubeTransverse.referencesMaillageFissure, n_cas)) + self.d_nom_probleme[n_cas] = "cubeTransverse" + self.l_materiels.append("cubeFin") - try: - ok_maillage = cas.executeProbleme() - except: - traceback.print_exc() - ok_maillage = False - if not ok_maillage: - texte = "Problème avec le cas n° {}, '{}'\n".format(n_cas,nom) - print(ligne) + n_cas = 5 + if n_cas in self.l_cas: + # genereMateriel : decoupeCylindre + from blocFissure.CasTests.cylindre import cylindre + self.l_problemes.append(cylindre(n_cas)) + self.l_materiels.append("decoupeCylindre") - return ok_maillage, texte -#============================================================= -def calcul_tout (l_problemes, d_aux): - """Calcul de tous les cas""" + n_cas = 6 + if n_cas in self.l_cas: + # genereMateriel : decoupeCylindre + from blocFissure.CasTests.cylindre_2 import cylindre_2 + self.l_problemes.append(cylindre_2(n_cas)) + self.l_materiels.append("decoupeCylindre") - ligne = "---------------------------------------------------------------------" - texte = "\n" - nb_cas_ok = 0 - nb_cas_nook = 0 - for n_cas, cas in enumerate(l_problemes): - #print ("Cas n° {}, '{}'".format(n_cas,cas.nomProbleme)) - if TORUN[n_cas]: - ok_maillage, texte_a = calcul_cas (n_cas, cas, d_aux, ligne) + n_cas = 7 + if n_cas in self.l_cas: + # genereMateriel : disque_perce + # genereMateriel : ellipse_disque + from blocFissure.CasTests import disquePerce + self.l_problemes.append(casStandard(disquePerce.dicoParams, disquePerce.referencesMaillageFissure, n_cas)) + self.d_nom_probleme[n_cas] = "disquePerce" + self.l_materiels.append("disque_perce") + self.l_materiels.append("ellipse_disque") + + n_cas = 8 + if n_cas in self.l_cas: + # genereMateriel: ellipse + # genereMateriel : fissureGauche2 + from blocFissure.CasTests.ellipse_1 import ellipse_1 + self.l_problemes.append(ellipse_1(n_cas)) + self.l_materiels.append("ellipse") + self.l_materiels.append("fissureGauche2") + + n_cas = 9 + if n_cas in self.l_cas: + # genereMateriel: ellipse_probleme + # genereMateriel : fissureGauche2 + from blocFissure.CasTests.ellipse_2 import ellipse_2 + self.l_problemes.append(ellipse_2(n_cas)) + self.l_materiels.append("ellipse_probleme") + self.l_materiels.append("fissureGauche2") + + n_cas = 10 + if n_cas in self.l_cas: + # genereMateriel : eprouvetteCourbe + from blocFissure.CasTests.eprouvetteCourbe import eprouvetteCourbe + self.l_problemes.append(eprouvetteCourbe(n_cas)) + self.l_materiels.append("eprouvetteCourbe") + + n_cas = 11 + if n_cas in self.l_cas: + # genereMateriel : eprouvetteDroite + from blocFissure.CasTests.eprouvetteDroite import eprouvetteDroite + self.l_problemes.append(eprouvetteDroite(n_cas)) + self.l_materiels.append("eprouvetteDroite") + + n_cas = 12 + if n_cas in self.l_cas: + # genereMateriel : eprouvetteDroite + from blocFissure.CasTests.eprouvetteDroite_2 import eprouvetteDroite_2 + self.l_problemes.append(eprouvetteDroite_2(n_cas)) + self.l_materiels.append("eprouvetteDroite") + + n_cas = 13 + if n_cas in self.l_cas: + # genereMateriel : fissureGauche + from blocFissure.CasTests.faceGauche import faceGauche + self.l_problemes.append(faceGauche(n_cas)) + self.l_materiels.append("fissureGauche") + + n_cas = 14 + if n_cas in self.l_cas: + # genereMateriel : fissureGauche2 + from blocFissure.CasTests.faceGauche_2 import faceGauche_2 + self.l_problemes.append(faceGauche_2(n_cas)) + self.l_materiels.append("fissureGauche2") + + n_cas = 15 + if n_cas in self.l_cas: + # genereMateriel : aucun + from blocFissure.CasTests.fissureCoude_1 import fissureCoude_1 + self.l_problemes.append(fissureCoude_1(n_cas)) + + n_cas = 16 + if n_cas in self.l_cas: + # genereMateriel : aucun + from blocFissure.CasTests.fissureCoude_2 import fissureCoude_2 + self.l_problemes.append(fissureCoude_2(n_cas)) + + n_cas = 17 + if n_cas in self.l_cas: + # genereMateriel : aucun + from blocFissure.CasTests.fissureCoude_3 import fissureCoude_3 + self.l_problemes.append(fissureCoude_3(n_cas)) + + n_cas = 18 + if n_cas in self.l_cas: + # genereMateriel : aucun + from blocFissure.CasTests.fissureCoude_4 import fissureCoude_4 + self.l_problemes.append(fissureCoude_4(n_cas)) + + n_cas = 19 + if n_cas in self.l_cas: + # genereMateriel : aucun + from blocFissure.CasTests.fissureCoude_5 import fissureCoude_5 + self.l_problemes.append(fissureCoude_5(n_cas)) + + n_cas = 20 + if n_cas in self.l_cas: + # genereMateriel : aucun + from blocFissure.CasTests.fissureCoude_6 import fissureCoude_6 + self.l_problemes.append(fissureCoude_6(n_cas)) + + n_cas = 21 + if n_cas in self.l_cas: + # genereMateriel : aucun + from blocFissure.CasTests.fissureCoude_7 import fissureCoude_7 + self.l_problemes.append(fissureCoude_7(n_cas)) + + n_cas = 22 + if n_cas in self.l_cas: + # genereMateriel : aucun + from blocFissure.CasTests.fissureCoude_8 import fissureCoude_8 + self.l_problemes.append(fissureCoude_8(n_cas)) + + n_cas = 23 + if n_cas in self.l_cas: + # genereMateriel : aucun + from blocFissure.CasTests.fissureCoude_9 import fissureCoude_9 + self.l_problemes.append(fissureCoude_9(n_cas)) + + n_cas = 24 + if n_cas in self.l_cas: + # genereMateriel : aucun + from blocFissure.CasTests.fissureCoude_10 import fissureCoude_10 + self.l_problemes.append(fissureCoude_10(n_cas)) + + n_cas = 25 + if n_cas in self.l_cas: + # genereMateriel : aucun + from blocFissure.CasTests.fissure_Coude import fissure_Coude + self.l_problemes.append(fissure_Coude(n_cas)) + + n_cas = 26 + if n_cas in self.l_cas: + # genereMateriel : aucun + from blocFissure.CasTests.fissure_Coude_4 import fissure_Coude_4 + self.l_problemes.append(fissure_Coude_4(n_cas)) + + n_cas = 27 + if n_cas in self.l_cas: + # genereMateriel : vis + from blocFissure.CasTests.vis_1 import vis_1 + self.l_problemes.append(vis_1(n_cas)) + self.l_materiels.append("vis") + + n_cas = 28 + if n_cas in self.l_cas: + # genereMateriel : tube + from blocFissure.CasTests.tube import tube + self.l_problemes.append(tube(n_cas)) + self.l_materiels.append("tube") + #"Mesh_13" has not been computed: + #- "algo2d_facePeau_0" failed on "FACE_12 to mesh". Error: Algorithm failed. NgException at Surface meshing: Problem in Surface mesh generation + #- "algo1d_cercle1_0" failed on EDGE #20. Error: Algorithm failed. Source elements don't cover totally the geometrical edge + #- "algo1d_cercle1_0" failed on EDGE #17. Error: Algorithm failed. Source elements don't cover totally the geometrical edge + #- "algo1d_cercle1_0" failed on EDGE #15. Error: Algorithm failed. Source elements don't cover totally the geometrical edge + #- "algo1d_cercle1_0" failed on EDGE #12. Error: Algorithm failed. Source elements don't cover totally the geometrical edge + + return + +#=========================== Fin de la méthode ================================== + +#=========================== Début de la méthode ================================= + + def cree_materiels (self): + """Création des matériels""" + + if "cubeAngle" in self.l_materiels: + from blocFissure.materielCasTests import cubeAngle + + if "cubeFin" in self.l_materiels: + from blocFissure.materielCasTests import cubeFin + + if "decoupeCylindre" in self.l_materiels: + from blocFissure.materielCasTests import decoupeCylindre + + if "disque_perce" in self.l_materiels: + from blocFissure.materielCasTests import disque_perce + + if "ellipse_disque" in self.l_materiels: + from blocFissure.materielCasTests import ellipse_disque + + if "ellipse" in self.l_materiels: + from blocFissure.materielCasTests import ellipse + + if "fissureGauche" in self.l_materiels: + from blocFissure.materielCasTests import fissureGauche + + if "fissureGauche2" in self.l_materiels: + from blocFissure.materielCasTests import fissureGauche2 + + if "eprouvetteCourbe" in self.l_materiels: + from blocFissure.materielCasTests import eprouvetteCourbe + + if "eprouvetteDroite" in self.l_materiels: + from blocFissure.materielCasTests import eprouvetteDroite + + if "vis" in self.l_materiels: + from blocFissure.materielCasTests import vis + + if "tube" in self.l_materiels: + from blocFissure.materielCasTests import tube + + return + +#=========================== Fin de la méthode ================================== + +#=========================== Début de la méthode ================================= + + def calcul_cas (self, n_cas, cas, ligne): + """Calcul d'un cas""" + texte = "" + if n_cas in self.d_nom_probleme: + nom = self.d_nom_probleme[n_cas] + else: + nom = cas.nomProbleme + texte_a = "\n=== Exécution du cas n° {}, '{}'".format(NREF_PB[nom],nom) + logging.critical(ligne+texte_a) + + try: + ok_maillage = cas.executeProbleme() + except: + traceback.print_exc() + ok_maillage = False + if not ok_maillage: + texte = "Problème avec le cas n° {}, '{}'\n".format(NREF_PB[nom],nom) + print(ligne) + + return ok_maillage, texte + +#=========================== Fin de la méthode ================================== + +#=========================== Début de la méthode ================================= + + def calcul_tout (self): + """Calcul de tous les cas""" + + ligne = "---------------------------------------------------------------------" + texte = "\n" + nb_cas_ok = 0 + nb_cas_nook = 0 + for n_cas, cas in enumerate(self.l_problemes): + #print ("Cas n° {}, '{}'".format(n_cas,cas.nomProbleme)) + ok_maillage, texte_a = self.calcul_cas (n_cas, cas, ligne) texte += texte_a if ok_maillage: nb_cas_ok += 1 @@ -272,31 +476,81 @@ def calcul_tout (l_problemes, d_aux): nb_cas_nook += 1 print(ligne) - nb_cas = nb_cas_nook + nb_cas_ok - if ( nb_cas > 1): - if nb_cas_nook: - texte += ". Nombre de cas_tests OK : {}\n".format(nb_cas_ok) - texte += ". Nombre de cas_tests NOOK : {}\n".format(nb_cas_nook) - else: - texte += "Les {} tests se sont bien passés.\n".format(nb_cas) - print (texte+ligne) - logging.critical(ligne+texte) + nb_cas = nb_cas_nook + nb_cas_ok + if ( nb_cas > 1): + if nb_cas_nook: + texte += ". Nombre de cas_tests OK : {}\n".format(nb_cas_ok) + texte += ". Nombre de cas_tests NOOK : {}\n".format(nb_cas_nook) + else: + texte += "Les {} tests se sont bien passés.\n".format(nb_cas) + print (texte+ligne) + logging.critical(ligne+texte) - return -#============================================================= -#============================================================= + return texte -while True: +#=========================== Fin de la méthode ================================== - L_PROBLEMES, D_AUX = caract_l_problemes() +#=========================== Début de la méthode ================================= - if ( len(L_PROBLEMES) != len(TORUN) ): - TEXTE = "\nNombre de problèmes définis : {}\n".format(len(L_PROBLEMES)) - TEXTE += "Longueur de la liste 'TORUN' : {}\n".format(len(TORUN)) - TEXTE += "\t==> Incohérence de programmation à corriger dans {}".format(__name__) - print (TEXTE) - break + def lancement (self): + """Lancement général""" - calcul_tout (L_PROBLEMES, D_AUX) + # Tri des problèmes + self.caract_l_problemes () - break + # Création des matériels + self.cree_materiels () + + # Calcul des fissures + texte = self.calcul_tout () + + return texte + +#=========================== Fin de la méthode ================================== + +#========================== Fin de la classe ==================================== + +#================================================================================== +# Lancement +#================================================================================== + +if __name__ == "__main__" : + +# 1. Options + + L_OPTIONS = sys.argv[1:] + L_OPTIONS.append("-v") + +# 2. Lancement de la classe + + #print ("L_OPTIONS :", L_OPTIONS) + BLOCFISSURE_TEST = blocFissureTest(L_OPTIONS) + + if BLOCFISSURE_TEST.affiche_aide_globale: + sys.stdout.write(BLOCFISSURE_TEST.__doc__+"\n") + else: + TEXTE = BLOCFISSURE_TEST.lancement() + sys.stdout.write(TEXTE) + + del BLOCFISSURE_TEST + + #sys.exit(0) + + +#while True: + + #import sys + #print ("arguments = '{}'".format(sys.argv[1:])) + + #L_PROBLEMES, D_AUX = caract_l_problemes() + + #if ( len(L_PROBLEMES) != len(TORUN) ): + #TEXTE = "\nNombre de problèmes définis : {}\n".format(len(L_PROBLEMES)) + #TEXTE += "Longueur de la liste 'TORUN' : {}\n".format(len(TORUN)) + #TEXTE += "\t==> Incohérence de programmation à corriger dans {}".format(__name__) + #print (TEXTE) + #break + + #calcul_tout (L_PROBLEMES, D_AUX) + + #break From 95de5fabdc238bcf1dbc3399e79d3b5c5ff41a5e Mon Sep 17 00:00:00 2001 From: GERALD NICOLAS Date: Mon, 26 Apr 2021 10:35:00 +0200 Subject: [PATCH 03/17] =?UTF-8?q?D=C3=A9placement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../blocFissure/{CasTests/execution_Cas.py => blocFissureTest.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/Tools/blocFissure/{CasTests/execution_Cas.py => blocFissureTest.py} (100%) diff --git a/src/Tools/blocFissure/CasTests/execution_Cas.py b/src/Tools/blocFissure/blocFissureTest.py similarity index 100% rename from src/Tools/blocFissure/CasTests/execution_Cas.py rename to src/Tools/blocFissure/blocFissureTest.py From 069b583dab475d377bc34e336ca7e618b8ef279c Mon Sep 17 00:00:00 2001 From: GERALD NICOLAS Date: Mon, 26 Apr 2021 10:51:38 +0200 Subject: [PATCH 04/17] mise en place des tests --- src/Tools/blocFissure/CasTests/CMakeLists.txt | 2 +- src/Tools/blocFissure/{ => CasTests}/blocFissureTest.py | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/Tools/blocFissure/{ => CasTests}/blocFissureTest.py (100%) diff --git a/src/Tools/blocFissure/CasTests/CMakeLists.txt b/src/Tools/blocFissure/CasTests/CMakeLists.txt index 768955a58..d6bce955a 100644 --- a/src/Tools/blocFissure/CasTests/CMakeLists.txt +++ b/src/Tools/blocFissure/CasTests/CMakeLists.txt @@ -22,6 +22,7 @@ # scripts / static SET(plugin_SCRIPTS __init__.py + blocFissureTest.py cubeAngle2.py cubeAngle.py cubeCoin.py @@ -35,7 +36,6 @@ SET(plugin_SCRIPTS eprouvetteCourbe.py eprouvetteDroite_2.py eprouvetteDroite.py - execution_Cas.py faceGauche_2.py faceGauche.py fissureCoude_10.py diff --git a/src/Tools/blocFissure/blocFissureTest.py b/src/Tools/blocFissure/CasTests/blocFissureTest.py similarity index 100% rename from src/Tools/blocFissure/blocFissureTest.py rename to src/Tools/blocFissure/CasTests/blocFissureTest.py From 17c79a5fcf3b726b9beb583d93b238dc3da54d31 Mon Sep 17 00:00:00 2001 From: GERALD NICOLAS Date: Mon, 26 Apr 2021 11:12:52 +0200 Subject: [PATCH 05/17] lacncements des 1ers cas-tests --- .../blocFissure_01_without_session.py | 25 +++++++------------ doc/salome/examples/tests.set | 2 +- .../blocFissure/CasTests/blocFissureTest.py | 23 +---------------- 3 files changed, 11 insertions(+), 39 deletions(-) diff --git a/doc/salome/examples/blocFissure_01_without_session.py b/doc/salome/examples/blocFissure_01_without_session.py index 0be55d4c6..224f917e5 100644 --- a/doc/salome/examples/blocFissure_01_without_session.py +++ b/doc/salome/examples/blocFissure_01_without_session.py @@ -7,39 +7,32 @@ Gérald NICOLAS +33.1.78.19.43.52 """ -__revision__ = "V02.01" +__revision__ = "V02.02" import os -import tempfile import sys -# Fichier de diagnostic -LOGFILE = os.path.join(tempfile.gettempdir(),"blocFissure.log") -if os.path.isfile(LOGFILE): - os.remove(LOGFILE) - # Lancement des cas-tests import salome salome.standalone() salome.salome_init() -from blocFissure.materielCasTests import genereMateriel - -from blocFissure.CasTests import execution_Cas +from blocFissure.CasTests import blocFissureTest +BLOCFISSURE_TEST = blocFissureTest(["cubeAngle", "cubeAngle2", "cubeCoin", "cubeMilieu", "cubeTransverse"]) +TEXTE = BLOCFISSURE_TEST.lancement() +del BLOCFISSURE_TEST # Diagnostic ERREUR = 0 -if os.path.isfile(LOGFILE): - with open(LOGFILE, 'r') as FICHIER: - LES_LIGNES = FICHIER.readlines() - for LIGNE in LES_LIGNES: +if TEXTE: + for LIGNE in TEXTE: #print (LIGNE[:-1]) if ( "NOOK" in LIGNE ): - MESSAGE_ERREUR = LIGNE + MESSAGE_ERREUR = TEXTE ERREUR = int(LIGNE.split()[-1]) break else: - MESSAGE_ERREUR = "Impossible de trouver le fichier de diagnostic {}".format(LOGFILE) + MESSAGE_ERREUR = "Impossible de trouver le diagnostic de la procédure de tests." ERREUR = -1 if ERREUR: diff --git a/doc/salome/examples/tests.set b/doc/salome/examples/tests.set index 99000efd5..531a85c51 100644 --- a/doc/salome/examples/tests.set +++ b/doc/salome/examples/tests.set @@ -46,7 +46,7 @@ SET(BAD_TESTS test_smeshplugin_mg_tetra_parallele.py test_smeshplugins.py MGAdaptTests_without_session.py - blocFissure_without_session.py + blocFissure_01_without_session.py ) SET(GOOD_TESTS diff --git a/src/Tools/blocFissure/CasTests/blocFissureTest.py b/src/Tools/blocFissure/CasTests/blocFissureTest.py index ef550f868..a0ccc2121 100644 --- a/src/Tools/blocFissure/CasTests/blocFissureTest.py +++ b/src/Tools/blocFissure/CasTests/blocFissureTest.py @@ -17,7 +17,7 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -__revision__ = "V02.01" +__revision__ = "V03.01" """Lancement des cas-tests de blocFissure""" @@ -533,24 +533,3 @@ if __name__ == "__main__" : sys.stdout.write(TEXTE) del BLOCFISSURE_TEST - - #sys.exit(0) - - -#while True: - - #import sys - #print ("arguments = '{}'".format(sys.argv[1:])) - - #L_PROBLEMES, D_AUX = caract_l_problemes() - - #if ( len(L_PROBLEMES) != len(TORUN) ): - #TEXTE = "\nNombre de problèmes définis : {}\n".format(len(L_PROBLEMES)) - #TEXTE += "Longueur de la liste 'TORUN' : {}\n".format(len(TORUN)) - #TEXTE += "\t==> Incohérence de programmation à corriger dans {}".format(__name__) - #print (TEXTE) - #break - - #calcul_tout (L_PROBLEMES, D_AUX) - - #break From ed4300495a5fc6fd2047e16cdf32f6a4db21c66a Mon Sep 17 00:00:00 2001 From: GERALD NICOLAS Date: Mon, 26 Apr 2021 16:02:24 +0200 Subject: [PATCH 06/17] =?UTF-8?q?Passage=20en=20attribut=20du=20maillage?= =?UTF-8?q?=20r=C3=A9sultat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Tools/blocFissure/gmu/fissureGenerique.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Tools/blocFissure/gmu/fissureGenerique.py b/src/Tools/blocFissure/gmu/fissureGenerique.py index f053e93bf..0092b6462 100644 --- a/src/Tools/blocFissure/gmu/fissureGenerique.py +++ b/src/Tools/blocFissure/gmu/fissureGenerique.py @@ -34,6 +34,7 @@ class fissureGenerique(object): """ nomProbleme = "fissureGenerique" + maillageFissure = None geomParams = dict() meshParams = dict() shapeFissureParams = dict() @@ -132,10 +133,10 @@ class fissureGenerique(object): if step == 4: return - maillageFissure = self.genereMaillageFissure(geometriesSaines, maillagesSains, \ - shapesFissure, self.shapeFissureParams, self.maillageFissureParams, \ - elementsDefaut, step, mailleur) + self.maillageFissure = self.genereMaillageFissure(geometriesSaines, maillagesSains, \ + shapesFissure, self.shapeFissureParams, self.maillageFissureParams, \ + elementsDefaut, step, mailleur) self.setReferencesMaillageFissure() - ok_maillage = getStatsMaillageFissure(maillageFissure, self.referencesMaillageFissure, self.maillageFissureParams) + ok_maillage = getStatsMaillageFissure(self.maillageFissure, self.referencesMaillageFissure, self.maillageFissureParams) return ok_maillage From 55864e5a23613e8a04e92211ef6bf79b560e06b5 Mon Sep 17 00:00:00 2001 From: GERALD NICOLAS Date: Mon, 26 Apr 2021 18:31:20 +0200 Subject: [PATCH 07/17] =?UTF-8?q?Pr=C3=A9paration=20=C3=A0=20l'ajout=20de?= =?UTF-8?q?=20cas-tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../blocFissure_01_without_session.py | 39 ++++++++---- doc/salome/examples/tests.set | 6 ++ .../blocFissure/CasTests/blocFissureTest.py | 61 ++++++++----------- 3 files changed, 57 insertions(+), 49 deletions(-) mode change 100644 => 100755 doc/salome/examples/blocFissure_01_without_session.py diff --git a/doc/salome/examples/blocFissure_01_without_session.py b/doc/salome/examples/blocFissure_01_without_session.py old mode 100644 new mode 100755 index 224f917e5..798b5fd69 --- a/doc/salome/examples/blocFissure_01_without_session.py +++ b/doc/salome/examples/blocFissure_01_without_session.py @@ -2,12 +2,16 @@ # -*- coding: utf-8 -*- """Tests de blocFissure ; en standalone +Cas tests basés sur les matériels : +. cubeAngle +. cubeFin + Copyright 2021 EDF Gérald NICOLAS +33.1.78.19.43.52 """ -__revision__ = "V02.02" +__revision__ = "V02.03" import os import sys @@ -17,20 +21,30 @@ import salome salome.standalone() salome.salome_init() -from blocFissure.CasTests import blocFissureTest -BLOCFISSURE_TEST = blocFissureTest(["cubeAngle", "cubeAngle2", "cubeCoin", "cubeMilieu", "cubeTransverse"]) -TEXTE = BLOCFISSURE_TEST.lancement() +from blocFissure.CasTests.blocFissureTest import blocFissureTest +BLOCFISSURE_TEST = blocFissureTest(["cubeAngle", "cubeAngle2","cubeCoin", "cubeMilieu", "cubeTransverse"]) +#BLOCFISSURE_TEST = blocFissureTest(["cylindre", "cylindre_2"]) +#BLOCFISSURE_TEST = blocFissureTest(["disque_perce"]) +#BLOCFISSURE_TEST = blocFissureTest(["faceGauche"]) +#BLOCFISSURE_TEST = blocFissureTest(["ellipse_1", "ellipse_2", "faceGauche_2"]) +#BLOCFISSURE_TEST = blocFissureTest(["eprouvetteCourbe"]) +#BLOCFISSURE_TEST = blocFissureTest(["eprouvetteDroite", "eprouvetteDroite_2"]) +#BLOCFISSURE_TEST = blocFissureTest(["vis"]) +#BLOCFISSURE_TEST = blocFissureTest(["fissureCoude_1", "fissureCoude_2", "fissureCoude_3", "fissureCoude_4", "fissureCoude_5", "fissureCoude_6", "fissureCoude_7", "fissureCoude_8", "fissureCoude_9", "fissureCoude_10", "fissure_Coude", "fissure_Coude_4"]) +#BLOCFISSURE_TEST = blocFissureTest(["fissureCoude_1", "fissureCoude_2", "fissureCoude_3", "fissureCoude_4", "fissureCoude_5"]) +#BLOCFISSURE_TEST = blocFissureTest(["fissureCoude_6", "fissureCoude_7", "fissureCoude_8", "fissureCoude_9", "fissureCoude_10"]) +#BLOCFISSURE_TEST = blocFissureTest(["fissure_Coude", "fissure_Coude_4"]) +MESSAGE_ERREUR = BLOCFISSURE_TEST.lancement() +#sys.stdout.write(MESSAGE_ERREUR) del BLOCFISSURE_TEST # Diagnostic -ERREUR = 0 -if TEXTE: - for LIGNE in TEXTE: - #print (LIGNE[:-1]) - if ( "NOOK" in LIGNE ): - MESSAGE_ERREUR = TEXTE - ERREUR = int(LIGNE.split()[-1]) - break +if MESSAGE_ERREUR: + if ( "NOOK" in MESSAGE_ERREUR ): + LAUX = MESSAGE_ERREUR.split() + ERREUR = int(LAUX[LAUX.index("NOOK")+2]) + else: + ERREUR = 0 else: MESSAGE_ERREUR = "Impossible de trouver le diagnostic de la procédure de tests." ERREUR = -1 @@ -39,3 +53,4 @@ if ERREUR: sys.stderr.write(MESSAGE_ERREUR) #raise Exception(MESSAGE_ERREUR) assert(False) + diff --git a/doc/salome/examples/tests.set b/doc/salome/examples/tests.set index 531a85c51..e0293d388 100644 --- a/doc/salome/examples/tests.set +++ b/doc/salome/examples/tests.set @@ -47,6 +47,12 @@ SET(BAD_TESTS test_smeshplugins.py MGAdaptTests_without_session.py blocFissure_01_without_session.py + blocFissure_02_without_session.py + blocFissure_03_without_session.py + blocFissure_04_without_session.py + blocFissure_05_without_session.py + blocFissure_06_without_session.py + blocFissure_07_without_session.py ) SET(GOOD_TESTS diff --git a/src/Tools/blocFissure/CasTests/blocFissureTest.py b/src/Tools/blocFissure/CasTests/blocFissureTest.py index a0ccc2121..8a5335753 100644 --- a/src/Tools/blocFissure/CasTests/blocFissureTest.py +++ b/src/Tools/blocFissure/CasTests/blocFissureTest.py @@ -19,7 +19,23 @@ # __revision__ = "V03.01" -"""Lancement des cas-tests de blocFissure""" +"""Lancement des cas-tests de blocFissure + +Temps par type de matériel : +. cubeAngle : 24s ["cubeAngle", "cubeAngle2"]) +. cubeFin : 42s ["cubeCoin", "cubeMilieu", "cubeTransverse"] +. decoupeCylindre : 8s ["cylindre", "cylindre_2"] +. disque_perce (+ ellipse_disque) : 9s ["disque_perce"] +. fissureGauche : 26s ["faceGauche"] +. fissureGauche2 (+ ellipse + ellipse_probleme): 22s ["ellipse_1", "ellipse_2", "faceGauche_2"] +. eprouvetteCourbe : 22s ["eprouvetteCourbe"] +. eprouvetteDroite : 31s ["eprouvetteDroite", "eprouvetteDroite_2"] +. vis : 9s ["vis"] +. tube : ["tube"] +. sans matériel : 66s ["fissureCoude_1", "fissureCoude_2", "fissureCoude_3", "fissureCoude_4", "fissureCoude_5"] +. sans matériel : 69s ["fissureCoude_6", "fissureCoude_7", "fissureCoude_8", "fissureCoude_9", "fissureCoude_10"] +. sans matériel : 28s ["fissure_Coude", "fissure_Coude_4"] +""" import logging import os @@ -47,7 +63,7 @@ for IAUX in TORUNOK: print ("TORUN = {} # OK".format(TORUNOK)) print ("TORUN = {} # PB".format(TORUNPB)) -# Numéro de référence associé à chaque problème +# Numéro de référence associé à chaque problème défini par le nom de son fichier dans le répertoire CasTests NREF_PB = dict() NREF_PB["cubeAngle"] = 0 NREF_PB["cubeAngle2"] = 1 @@ -55,10 +71,10 @@ NREF_PB["cubeCoin"] = 2 NREF_PB["cubeMilieu"] = 3 NREF_PB["cubeTransverse"] = 4 NREF_PB["cylindre"] = 5 -NREF_PB["cylindre2"] = 6 +NREF_PB["cylindre_2"] = 6 NREF_PB["disquePerce"] = 7 -NREF_PB["ellipse1"] = 8 -NREF_PB["ellipse2"] = 9 +NREF_PB["ellipse_1"] = 8 +NREF_PB["ellipse_2"] = 9 NREF_PB["eprouvetteCourbe"] = 10 NREF_PB["eprouvetteDroite"] = 11 NREF_PB["eprouvetteDroite_2"] = 12 @@ -154,8 +170,6 @@ Le(s) numéro/nom du/des tests à passer. Si aucun n'est donné, tous les cas so if self._verbose_max: initLog.setVerbose(LOGFILE) # info = 20 - #if self._verbose_max: - #initLog.setDebug(LOGFILE) # debug = 10 #=========================== Fin de la méthode ================================== @@ -178,21 +192,18 @@ Le(s) numéro/nom du/des tests à passer. Si aucun n'est donné, tous les cas so n_cas = 0 if n_cas in self.l_cas: - # genereMateriel : cubeAngle from blocFissure.CasTests.cubeAngle import cubeAngle self.l_problemes.append(cubeAngle(n_cas)) self.l_materiels.append("cubeAngle") n_cas = 1 if n_cas in self.l_cas: - # genereMateriel : cubeAngle from blocFissure.CasTests.cubeAngle2 import cubeAngle2 self.l_problemes.append(cubeAngle2(n_cas)) self.l_materiels.append("cubeAngle") n_cas = 2 if n_cas in self.l_cas: - # genereMateriel : cubeFin from blocFissure.CasTests import cubeCoin self.l_problemes.append(casStandard(cubeCoin.dicoParams, cubeCoin.referencesMaillageFissure, n_cas)) self.d_nom_probleme[n_cas] = "cubeCoin" @@ -200,7 +211,6 @@ Le(s) numéro/nom du/des tests à passer. Si aucun n'est donné, tous les cas so n_cas = 3 if n_cas in self.l_cas: - # genereMateriel : cubeFin from blocFissure.CasTests import cubeMilieu self.l_problemes.append(casStandard(cubeMilieu.dicoParams, cubeMilieu.referencesMaillageFissure, n_cas)) self.d_nom_probleme[n_cas] = "cubeMilieu" @@ -208,7 +218,6 @@ Le(s) numéro/nom du/des tests à passer. Si aucun n'est donné, tous les cas so n_cas = 4 if n_cas in self.l_cas: - # genereMateriel : cubeFin from blocFissure.CasTests import cubeTransverse self.l_problemes.append(casStandard(cubeTransverse.dicoParams, cubeTransverse.referencesMaillageFissure, n_cas)) self.d_nom_probleme[n_cas] = "cubeTransverse" @@ -216,22 +225,18 @@ Le(s) numéro/nom du/des tests à passer. Si aucun n'est donné, tous les cas so n_cas = 5 if n_cas in self.l_cas: - # genereMateriel : decoupeCylindre from blocFissure.CasTests.cylindre import cylindre self.l_problemes.append(cylindre(n_cas)) self.l_materiels.append("decoupeCylindre") n_cas = 6 if n_cas in self.l_cas: - # genereMateriel : decoupeCylindre from blocFissure.CasTests.cylindre_2 import cylindre_2 self.l_problemes.append(cylindre_2(n_cas)) self.l_materiels.append("decoupeCylindre") n_cas = 7 if n_cas in self.l_cas: - # genereMateriel : disque_perce - # genereMateriel : ellipse_disque from blocFissure.CasTests import disquePerce self.l_problemes.append(casStandard(disquePerce.dicoParams, disquePerce.referencesMaillageFissure, n_cas)) self.d_nom_probleme[n_cas] = "disquePerce" @@ -240,8 +245,6 @@ Le(s) numéro/nom du/des tests à passer. Si aucun n'est donné, tous les cas so n_cas = 8 if n_cas in self.l_cas: - # genereMateriel: ellipse - # genereMateriel : fissureGauche2 from blocFissure.CasTests.ellipse_1 import ellipse_1 self.l_problemes.append(ellipse_1(n_cas)) self.l_materiels.append("ellipse") @@ -249,8 +252,6 @@ Le(s) numéro/nom du/des tests à passer. Si aucun n'est donné, tous les cas so n_cas = 9 if n_cas in self.l_cas: - # genereMateriel: ellipse_probleme - # genereMateriel : fissureGauche2 from blocFissure.CasTests.ellipse_2 import ellipse_2 self.l_problemes.append(ellipse_2(n_cas)) self.l_materiels.append("ellipse_probleme") @@ -258,108 +259,91 @@ Le(s) numéro/nom du/des tests à passer. Si aucun n'est donné, tous les cas so n_cas = 10 if n_cas in self.l_cas: - # genereMateriel : eprouvetteCourbe from blocFissure.CasTests.eprouvetteCourbe import eprouvetteCourbe self.l_problemes.append(eprouvetteCourbe(n_cas)) self.l_materiels.append("eprouvetteCourbe") n_cas = 11 if n_cas in self.l_cas: - # genereMateriel : eprouvetteDroite from blocFissure.CasTests.eprouvetteDroite import eprouvetteDroite self.l_problemes.append(eprouvetteDroite(n_cas)) self.l_materiels.append("eprouvetteDroite") n_cas = 12 if n_cas in self.l_cas: - # genereMateriel : eprouvetteDroite from blocFissure.CasTests.eprouvetteDroite_2 import eprouvetteDroite_2 self.l_problemes.append(eprouvetteDroite_2(n_cas)) self.l_materiels.append("eprouvetteDroite") n_cas = 13 if n_cas in self.l_cas: - # genereMateriel : fissureGauche from blocFissure.CasTests.faceGauche import faceGauche self.l_problemes.append(faceGauche(n_cas)) self.l_materiels.append("fissureGauche") n_cas = 14 if n_cas in self.l_cas: - # genereMateriel : fissureGauche2 from blocFissure.CasTests.faceGauche_2 import faceGauche_2 self.l_problemes.append(faceGauche_2(n_cas)) self.l_materiels.append("fissureGauche2") n_cas = 15 if n_cas in self.l_cas: - # genereMateriel : aucun from blocFissure.CasTests.fissureCoude_1 import fissureCoude_1 self.l_problemes.append(fissureCoude_1(n_cas)) n_cas = 16 if n_cas in self.l_cas: - # genereMateriel : aucun from blocFissure.CasTests.fissureCoude_2 import fissureCoude_2 self.l_problemes.append(fissureCoude_2(n_cas)) n_cas = 17 if n_cas in self.l_cas: - # genereMateriel : aucun from blocFissure.CasTests.fissureCoude_3 import fissureCoude_3 self.l_problemes.append(fissureCoude_3(n_cas)) n_cas = 18 if n_cas in self.l_cas: - # genereMateriel : aucun from blocFissure.CasTests.fissureCoude_4 import fissureCoude_4 self.l_problemes.append(fissureCoude_4(n_cas)) n_cas = 19 if n_cas in self.l_cas: - # genereMateriel : aucun from blocFissure.CasTests.fissureCoude_5 import fissureCoude_5 self.l_problemes.append(fissureCoude_5(n_cas)) n_cas = 20 if n_cas in self.l_cas: - # genereMateriel : aucun from blocFissure.CasTests.fissureCoude_6 import fissureCoude_6 self.l_problemes.append(fissureCoude_6(n_cas)) n_cas = 21 if n_cas in self.l_cas: - # genereMateriel : aucun from blocFissure.CasTests.fissureCoude_7 import fissureCoude_7 self.l_problemes.append(fissureCoude_7(n_cas)) n_cas = 22 if n_cas in self.l_cas: - # genereMateriel : aucun from blocFissure.CasTests.fissureCoude_8 import fissureCoude_8 self.l_problemes.append(fissureCoude_8(n_cas)) n_cas = 23 if n_cas in self.l_cas: - # genereMateriel : aucun from blocFissure.CasTests.fissureCoude_9 import fissureCoude_9 self.l_problemes.append(fissureCoude_9(n_cas)) n_cas = 24 if n_cas in self.l_cas: - # genereMateriel : aucun from blocFissure.CasTests.fissureCoude_10 import fissureCoude_10 self.l_problemes.append(fissureCoude_10(n_cas)) n_cas = 25 if n_cas in self.l_cas: - # genereMateriel : aucun from blocFissure.CasTests.fissure_Coude import fissure_Coude self.l_problemes.append(fissure_Coude(n_cas)) n_cas = 26 if n_cas in self.l_cas: - # genereMateriel : aucun from blocFissure.CasTests.fissure_Coude_4 import fissure_Coude_4 self.l_problemes.append(fissure_Coude_4(n_cas)) @@ -407,6 +391,9 @@ Le(s) numéro/nom du/des tests à passer. Si aucun n'est donné, tous les cas so if "ellipse_disque" in self.l_materiels: from blocFissure.materielCasTests import ellipse_disque + if "ellipse_probleme" in self.l_materiels: + from blocFissure.materielCasTests import ellipse_probleme + if "ellipse" in self.l_materiels: from blocFissure.materielCasTests import ellipse From 89b205395d338a1dab9d104d06f86757526365ef Mon Sep 17 00:00:00 2001 From: GERALD NICOLAS Date: Mon, 26 Apr 2021 18:31:41 +0200 Subject: [PATCH 08/17] =?UTF-8?q?Pr=C3=A9paration=20=C3=A0=20la=20scission?= =?UTF-8?q?=20des=20cas-tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../blocFissure_02_without_session.py | 49 +++++++++++++++++++ .../blocFissure_03_without_session.py | 45 +++++++++++++++++ .../blocFissure_04_without_session.py | 43 ++++++++++++++++ .../blocFissure_05_without_session.py | 43 ++++++++++++++++ .../blocFissure_06_without_session.py | 43 ++++++++++++++++ .../blocFissure_07_without_session.py | 46 +++++++++++++++++ 6 files changed, 269 insertions(+) create mode 100755 doc/salome/examples/blocFissure_02_without_session.py create mode 100755 doc/salome/examples/blocFissure_03_without_session.py create mode 100755 doc/salome/examples/blocFissure_04_without_session.py create mode 100755 doc/salome/examples/blocFissure_05_without_session.py create mode 100755 doc/salome/examples/blocFissure_06_without_session.py create mode 100755 doc/salome/examples/blocFissure_07_without_session.py diff --git a/doc/salome/examples/blocFissure_02_without_session.py b/doc/salome/examples/blocFissure_02_without_session.py new file mode 100755 index 000000000..454c70f3d --- /dev/null +++ b/doc/salome/examples/blocFissure_02_without_session.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +"""Tests de blocFissure ; en standalone + +Cas tests basés sur les matériels : +. decoupeCylindre +. disque_perce +. fissureGauche +. fissureGauche2 ++ ellipse, ellipse_disque, ellipse_probleme + +Copyright 2021 EDF +Gérald NICOLAS ++33.1.78.19.43.52 +""" + +__revision__ = "V02.03" + +import os +import sys + +# Lancement des cas-tests +import salome +salome.standalone() +salome.salome_init() + +from blocFissure.CasTests.blocFissureTest import blocFissureTest +BLOCFISSURE_TEST = blocFissureTest(["cylindre", "cylindre_2", "disquePerce", "faceGauche","ellipse_1", "ellipse_2", "faceGauche_2"]) +#BLOCFISSURE_TEST = blocFissureTest(["cylindre", "cylindre_2", "disquePerce", "faceGauche","ellipse_1", "ellipse_2"]) +MESSAGE_ERREUR = BLOCFISSURE_TEST.lancement() +sys.stdout.write(MESSAGE_ERREUR) +del BLOCFISSURE_TEST + +# Diagnostic +if MESSAGE_ERREUR: + if ( "NOOK" in MESSAGE_ERREUR ): + LAUX = MESSAGE_ERREUR.split() + ERREUR = int(LAUX[LAUX.index("NOOK")+2]) + else: + ERREUR = 0 +else: + MESSAGE_ERREUR = "Impossible de trouver le diagnostic de la procédure de tests." + ERREUR = -1 + +if ERREUR: + sys.stderr.write(MESSAGE_ERREUR) + #raise Exception(MESSAGE_ERREUR) + assert(False) + diff --git a/doc/salome/examples/blocFissure_03_without_session.py b/doc/salome/examples/blocFissure_03_without_session.py new file mode 100755 index 000000000..a6f730c21 --- /dev/null +++ b/doc/salome/examples/blocFissure_03_without_session.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +"""Tests de blocFissure ; en standalone + +Cas tests basés sur les matériels : +. eprouvetteCourbe +. eprouvetteDroite + +Copyright 2021 EDF +Gérald NICOLAS ++33.1.78.19.43.52 +""" + +__revision__ = "V02.03" + +import os +import sys + +# Lancement des cas-tests +import salome +salome.standalone() +salome.salome_init() + +from blocFissure.CasTests.blocFissureTest import blocFissureTest +BLOCFISSURE_TEST = blocFissureTest(["eprouvetteCourbe", "eprouvetteDroite", "eprouvetteDroite_2"]) +MESSAGE_ERREUR = BLOCFISSURE_TEST.lancement() +#sys.stdout.write(MESSAGE_ERREUR) +del BLOCFISSURE_TEST + +# Diagnostic +if MESSAGE_ERREUR: + if ( "NOOK" in MESSAGE_ERREUR ): + LAUX = MESSAGE_ERREUR.split() + ERREUR = int(LAUX[LAUX.index("NOOK")+2]) + else: + ERREUR = 0 +else: + MESSAGE_ERREUR = "Impossible de trouver le diagnostic de la procédure de tests." + ERREUR = -1 + +if ERREUR: + sys.stderr.write(MESSAGE_ERREUR) + #raise Exception(MESSAGE_ERREUR) + assert(False) + diff --git a/doc/salome/examples/blocFissure_04_without_session.py b/doc/salome/examples/blocFissure_04_without_session.py new file mode 100755 index 000000000..e535f7632 --- /dev/null +++ b/doc/salome/examples/blocFissure_04_without_session.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +"""Tests de blocFissure ; en standalone + +Cas tests basés sans matériels (1/3) + +Copyright 2021 EDF +Gérald NICOLAS ++33.1.78.19.43.52 +""" + +__revision__ = "V02.03" + +import os +import sys + +# Lancement des cas-tests +import salome +salome.standalone() +salome.salome_init() + +from blocFissure.CasTests.blocFissureTest import blocFissureTest +BLOCFISSURE_TEST = blocFissureTest(["fissureCoude_1", "fissureCoude_2", "fissureCoude_3", "fissureCoude_4", "fissureCoude_5"]) +MESSAGE_ERREUR = BLOCFISSURE_TEST.lancement() +#sys.stdout.write(MESSAGE_ERREUR) +del BLOCFISSURE_TEST + +# Diagnostic +if MESSAGE_ERREUR: + if ( "NOOK" in MESSAGE_ERREUR ): + LAUX = MESSAGE_ERREUR.split() + ERREUR = int(LAUX[LAUX.index("NOOK")+2]) + else: + ERREUR = 0 +else: + MESSAGE_ERREUR = "Impossible de trouver le diagnostic de la procédure de tests." + ERREUR = -1 + +if ERREUR: + sys.stderr.write(MESSAGE_ERREUR) + #raise Exception(MESSAGE_ERREUR) + assert(False) + diff --git a/doc/salome/examples/blocFissure_05_without_session.py b/doc/salome/examples/blocFissure_05_without_session.py new file mode 100755 index 000000000..16e4bb331 --- /dev/null +++ b/doc/salome/examples/blocFissure_05_without_session.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +"""Tests de blocFissure ; en standalone + +Cas tests basés sans matériels (1/3) + +Copyright 2021 EDF +Gérald NICOLAS ++33.1.78.19.43.52 +""" + +__revision__ = "V02.03" + +import os +import sys + +# Lancement des cas-tests +import salome +salome.standalone() +salome.salome_init() + +from blocFissure.CasTests.blocFissureTest import blocFissureTest +BLOCFISSURE_TEST = blocFissureTest(["fissureCoude_6", "fissureCoude_7", "fissureCoude_8", "fissureCoude_9", "fissureCoude_10"]) +MESSAGE_ERREUR = BLOCFISSURE_TEST.lancement() +#sys.stdout.write(MESSAGE_ERREUR) +del BLOCFISSURE_TEST + +# Diagnostic +if MESSAGE_ERREUR: + if ( "NOOK" in MESSAGE_ERREUR ): + LAUX = MESSAGE_ERREUR.split() + ERREUR = int(LAUX[LAUX.index("NOOK")+2]) + else: + ERREUR = 0 +else: + MESSAGE_ERREUR = "Impossible de trouver le diagnostic de la procédure de tests." + ERREUR = -1 + +if ERREUR: + sys.stderr.write(MESSAGE_ERREUR) + #raise Exception(MESSAGE_ERREUR) + assert(False) + diff --git a/doc/salome/examples/blocFissure_06_without_session.py b/doc/salome/examples/blocFissure_06_without_session.py new file mode 100755 index 000000000..185f5d74f --- /dev/null +++ b/doc/salome/examples/blocFissure_06_without_session.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +"""Tests de blocFissure ; en standalone + +Cas tests basés sans matériels (1/3) + +Copyright 2021 EDF +Gérald NICOLAS ++33.1.78.19.43.52 +""" + +__revision__ = "V02.03" + +import os +import sys + +# Lancement des cas-tests +import salome +salome.standalone() +salome.salome_init() + +from blocFissure.CasTests.blocFissureTest import blocFissureTest +BLOCFISSURE_TEST = blocFissureTest(["fissure_Coude", "fissure_Coude_4"]) +MESSAGE_ERREUR = BLOCFISSURE_TEST.lancement() +#sys.stdout.write(MESSAGE_ERREUR) +del BLOCFISSURE_TEST + +# Diagnostic +if MESSAGE_ERREUR: + if ( "NOOK" in MESSAGE_ERREUR ): + LAUX = MESSAGE_ERREUR.split() + ERREUR = int(LAUX[LAUX.index("NOOK")+2]) + else: + ERREUR = 0 +else: + MESSAGE_ERREUR = "Impossible de trouver le diagnostic de la procédure de tests." + ERREUR = -1 + +if ERREUR: + sys.stderr.write(MESSAGE_ERREUR) + #raise Exception(MESSAGE_ERREUR) + assert(False) + diff --git a/doc/salome/examples/blocFissure_07_without_session.py b/doc/salome/examples/blocFissure_07_without_session.py new file mode 100755 index 000000000..0d5413215 --- /dev/null +++ b/doc/salome/examples/blocFissure_07_without_session.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +"""Tests de blocFissure ; en standalone + +Cas tests basés sur les matériels : +. vis +. tube + +Copyright 2021 EDF +Gérald NICOLAS ++33.1.78.19.43.52 +""" + +__revision__ = "V02.03" + +import os +import sys + +# Lancement des cas-tests +import salome +salome.standalone() +salome.salome_init() + +from blocFissure.CasTests.blocFissureTest import blocFissureTest +BLOCFISSURE_TEST = blocFissureTest(["vis"]) +#BLOCFISSURE_TEST = blocFissureTest(["vis", "tube"]) +MESSAGE_ERREUR = BLOCFISSURE_TEST.lancement() +#sys.stdout.write(MESSAGE_ERREUR) +del BLOCFISSURE_TEST + +# Diagnostic +if MESSAGE_ERREUR: + if ( "NOOK" in MESSAGE_ERREUR ): + LAUX = MESSAGE_ERREUR.split() + ERREUR = int(LAUX[LAUX.index("NOOK")+2]) + else: + ERREUR = 0 +else: + MESSAGE_ERREUR = "Impossible de trouver le diagnostic de la procédure de tests." + ERREUR = -1 + +if ERREUR: + sys.stderr.write(MESSAGE_ERREUR) + #raise Exception(MESSAGE_ERREUR) + assert(False) + From e2f6c813044ef7f4d7cc5b431d0a2581b34ddca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rald=20NICOLAS?= Date: Mon, 19 Apr 2021 15:53:53 +0200 Subject: [PATCH 09/17] =?UTF-8?q?Tri=20dans=20le=20rep=C3=A9rage=20des=20a?= =?UTF-8?q?r=C3=AAtes=20de=20peau?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gmu/construitFissureGenerale.py | 6 +-- .../gmu/construitFissureGenerale_b.py | 4 +- .../blocFissure/gmu/identifieEdgesPeau.py | 4 +- .../blocFissure/gmu/identifieEdgesPeau_a.py | 33 +++++++------- .../blocFissure/gmu/identifieEdgesPeau_b.py | 12 +++-- .../blocFissure/gmu/identifieEdgesPeau_c.py | 45 ++++++++++--------- .../gmu/identifieElementsGeometriquesPeau.py | 11 +++-- .../blocFissure/gmu/mailleFacesFissure.py | 3 +- src/Tools/blocFissure/gmu/mailleFacesPeau.py | 39 ++++++++-------- 9 files changed, 80 insertions(+), 77 deletions(-) diff --git a/src/Tools/blocFissure/gmu/construitFissureGenerale.py b/src/Tools/blocFissure/gmu/construitFissureGenerale.py index a2aa580c4..90e0f60f7 100644 --- a/src/Tools/blocFissure/gmu/construitFissureGenerale.py +++ b/src/Tools/blocFissure/gmu/construitFissureGenerale.py @@ -132,8 +132,8 @@ def construitFissureGenerale(shapesFissure, shapeFissureParams, \ # --- inventaire des faces de peau coupées par la fissure - ptEdgeFond, fsFissuExt, edFisExtPe, edFisExtPi, \ - facesPeaux, edCircPeau, ptCircPeau, gpedgeBord, gpedgeVifs, edFissPeau, ptFisExtPi, \ + ptEdgeFond, fsFissuExt, edFisExtPe, edFisExtPi, facesPeaux, edCircPeau, \ + gpedgeBord, gpedgeVifs, edFissPeau, ptFisExtPi, \ edgeRadFacePipePeau, facesPipePeau = \ construitFissureGenerale_b( partitionsPeauFissFond, \ edgesPipeFiss, edgesFondFiss, wireFondFiss, aretesVivesC, \ @@ -201,7 +201,7 @@ def construitFissureGenerale(shapesFissure, shapeFissureParams, \ # --- maillage faces de peau meshesFacesPeau = mailleFacesPeau(partitionsPeauFissFond, idFillingFromBout, facesDefaut, \ - facesPeaux, edCircPeau, ptCircPeau, gpedgeBord, gpedgeVifs, edFissPeau, \ + facesPeaux, edCircPeau, gpedgeBord, gpedgeVifs, edFissPeau, \ bordsLibres, grpEdgesPeauFissureExterne, grpAretesVives, \ edgesCircPipeGroup, dmoyen, rayonPipe, nbsegRad, \ mailleur, nro_cas) diff --git a/src/Tools/blocFissure/gmu/construitFissureGenerale_b.py b/src/Tools/blocFissure/gmu/construitFissureGenerale_b.py index bf2c5d4fd..b96ce6386 100644 --- a/src/Tools/blocFissure/gmu/construitFissureGenerale_b.py +++ b/src/Tools/blocFissure/gmu/construitFissureGenerale_b.py @@ -50,7 +50,6 @@ pour chaque face de peau : 0, 1 ou 2 faces débouchante du fond de fissure edFisExtPi = [ list() for _ in range(nbFacesFilling)] # pour chaque face [edge commun au pipe des faces de fissure externes] facesPeaux = [None for _ in range(nbFacesFilling)] # pour chaque face : la face de peau finale a mailler (percée des faces débouchantes) edCircPeau = [ list() for _ in range(nbFacesFilling)] # pour chaque face de peau : [subshape edge circulaire aux débouchés du pipe] - ptCircPeau = [ list() for _ in range(nbFacesFilling)] # pour chaque face de peau : [subshape point sur edge circulaire aux débouchés du pipe] gpedgeBord = [None for _ in range(nbFacesFilling)] # pour chaque face de peau : groupe subshape des edges aux bords liés à la partie saine gpedgeVifs = [None for _ in range(nbFacesFilling)] # pour chaque face de peau : groupes subshape des edges aux arêtes vives entre fillings edFissPeau = [ list() for _ in range(nbFacesFilling)] # pour chaque face de peau : [subshape edge en peau des faces de fissure externes] @@ -70,7 +69,6 @@ pour chaque face de peau : 0, 1 ou 2 faces débouchante du fond de fissure edFisExtPi[ifil] = dataPPFF['edgesFissExtPipe'] facesPeaux[ifil] = dataPPFF['facePeau'] edCircPeau[ifil] = dataPPFF['edgesCircPeau'] - ptCircPeau[ifil] = dataPPFF['verticesCircPeau'] gpedgeBord[ifil] = dataPPFF['groupEdgesBordPeau'] gpedgeVifs[ifil] = dataPPFF['bordsVifs'] edFissPeau[ifil] = dataPPFF['edgesFissurePeau'] @@ -87,5 +85,5 @@ pour chaque face de peau : 0, 1 ou 2 faces débouchante du fond de fissure geomPublish(initLog.debug, avc, name, nro_cas) return ptEdgeFond, fsFissuExt, edFisExtPe, edFisExtPi, facesPeaux, edCircPeau, \ - ptCircPeau, gpedgeBord, gpedgeVifs, edFissPeau, ptFisExtPi, \ + gpedgeBord, gpedgeVifs, edFissPeau, ptFisExtPi, \ edgeRadFacePipePeau, facesPipePeau diff --git a/src/Tools/blocFissure/gmu/identifieEdgesPeau.py b/src/Tools/blocFissure/gmu/identifieEdgesPeau.py index c4cbe095c..f782d8d7c 100644 --- a/src/Tools/blocFissure/gmu/identifieEdgesPeau.py +++ b/src/Tools/blocFissure/gmu/identifieEdgesPeau.py @@ -57,6 +57,6 @@ def identifieEdgesPeau(edgesFissExtPipe, verticesPipePeau, facePeau, facesPeauSo # --- edges de la face de peau partagées avec la face de fissure edgesFissurePeau = identifieEdgesPeau_c(verticesPipePeau, facePeau, edgesListees, verticesCircPeau) - return (endsEdgeFond, facesPipePeau, edgeRadFacePipePeau, - edgesCircPeau, verticesCircPeau, groupEdgesBordPeau, + return (endsEdgeFond, facesPipePeau, edgeRadFacePipePeau, \ + edgesCircPeau, groupEdgesBordPeau, \ bordsVifs, edgesFissurePeau, aretesVivesCoupees) diff --git a/src/Tools/blocFissure/gmu/identifieEdgesPeau_a.py b/src/Tools/blocFissure/gmu/identifieEdgesPeau_a.py index b13a9ec49..869b17894 100644 --- a/src/Tools/blocFissure/gmu/identifieEdgesPeau_a.py +++ b/src/Tools/blocFissure/gmu/identifieEdgesPeau_a.py @@ -32,6 +32,7 @@ def identifieEdgesPeau_a(edgesFissExtPipe, facePeau, facesPeauSorted, edgesPeauF nro_cas=None): """Identification précise des edges et disques des faces de peau selon index extremité fissure""" logging.info('start') + logging.info("Traitement des arêtes de '%s'", facePeau.GetName()) for face in facesPeauSorted[:-1]: # la ou les faces débouchantes, pas la grande face de peau logging.debug("examen face debouchante circulaire") @@ -46,7 +47,6 @@ def identifieEdgesPeau_a(edgesFissExtPipe, facePeau, facesPeauSorted, edgesPeauF sharedVertices = geompy.GetSharedShapesMulti([face, edgesPeauFondIn[j_aux_0]], geompy.ShapeType["VERTEX"]) nameFace = "facePipePeau_{}".format(i_aux) nameVert = "endEdgeFond_{}".format(i_aux) - nameEdge = "edgeRadFacePipePeau_{}".format(i_aux) facesPipePeau[i_aux] = face endsEdgeFond[i_aux] = sharedVertices[0] geomPublish(initLog.debug, face, nameFace, nro_cas) @@ -55,29 +55,30 @@ def identifieEdgesPeau_a(edgesFissExtPipe, facePeau, facesPeauSorted, edgesPeauF for edge in edgesFace: if geompy.MinDistance(edge, sharedVertices[0]) < 1e-3: edgeRadFacePipePeau[i_aux] = edge + nameEdge = "edgeRadFacePipePeau_{}".format(i_aux) geomPublish(initLog.debug, edge, nameEdge, nro_cas) break # --- edges elliptiques de la face de peau et points de jonction de la face externe de fissure - logging.info("Traitement des arêtes de '%s'", facePeau.GetName()) - edgesCircPeau = [None for _ in range(len(facesPipePeau))] - verticesCircPeau = [None for _ in range(len(facesPipePeau))] + logging.info('Nombre de faces : len(facesPipePeau) = %d', len(facesPipePeau)) + edgesCircPeau = list() + verticesCircPeau = list() for i_aux,fcirc in enumerate(facesPipePeau): - logging.info(". Partage avec la face '%s'", fcirc.GetName()) + # Arêtes edges = geompy.GetSharedShapesMulti([facePeau, fcirc], geompy.ShapeType["EDGE"]) - grpEdgesCirc = geompy.CreateGroup(facePeau, geompy.ShapeType["EDGE"]) - geompy.UnionList(grpEdgesCirc, edges) - edgesCircPeau[i_aux] = grpEdgesCirc - name = "edgeCirc_{}".format(i_aux) - geomPublishInFather(initLog.always, facePeau, grpEdgesCirc, name) + groupe = geompy.CreateGroup(facePeau, geompy.ShapeType["EDGE"]) + geompy.UnionList(groupe, edges) + geomPublishInFather(initLog.always, facePeau, groupe, "edgeCirc_{}".format(i_aux)) + edgesCircPeau.append(groupe) edgesListees = edgesListees + edges + # Sommets vertices = geompy.GetSharedShapesMulti([facePeau, fcirc], geompy.ShapeType["VERTEX"]) - grpVertCircPeau = geompy.CreateGroup(facePeau, geompy.ShapeType["VERTEX"]) - geompy.UnionList(grpVertCircPeau, vertices) - verticesCircPeau[i_aux] = grpVertCircPeau - name = "pointEdgeCirc_{}".format(i_aux) - geomPublishInFather(initLog.info, facePeau, grpVertCircPeau, name) + groupe = geompy.CreateGroup(facePeau, geompy.ShapeType["VERTEX"]) + geompy.UnionList(groupe, vertices) + geomPublishInFather(initLog.info, facePeau, groupe, "point(s)EdgeCirc_{}".format(i_aux)) + verticesCircPeau.append(groupe) - logging.info('==> Nombre de sommets : len(verticesCircPeau) = %d', len(verticesCircPeau)) + logging.info("==> Nombre de groupes d'arêtes : len(edgesCircPeau) = %d", len(edgesCircPeau)) + logging.info("==> Nombre de groupes de sommets : len(verticesCircPeau) = %d", len(verticesCircPeau)) return edgesCircPeau, verticesCircPeau diff --git a/src/Tools/blocFissure/gmu/identifieEdgesPeau_b.py b/src/Tools/blocFissure/gmu/identifieEdgesPeau_b.py index 3044d61de..bdde0322b 100644 --- a/src/Tools/blocFissure/gmu/identifieEdgesPeau_b.py +++ b/src/Tools/blocFissure/gmu/identifieEdgesPeau_b.py @@ -32,7 +32,9 @@ def identifieEdgesPeau_b(facePeau, edgesListees, \ """edges de bord de la face de peau""" logging.info('start') + # Liste des arêtes de bord edgesFilling = geompy.ExtractShapes(fillingFaceExterne, geompy.ShapeType["EDGE"], False) + logging.info('Détermination des arêtes de bord à partir des %d arêtes de fillingFaceExterne', len(edgesFilling)) edgesBords = list() for i_aux, edge in enumerate(edgesFilling): edgepeau = geompy.GetInPlace(facePeau, edge) @@ -42,18 +44,19 @@ def identifieEdgesPeau_b(facePeau, edgesListees, \ if geompy.ShapeInfo(edgepeau)['EDGE'] > 1: logging.debug(" EDGES multiples") l_edges = geompy.ExtractShapes(edgepeau, geompy.ShapeType["EDGE"], False) - edgesBords += l_edges - edgesListees += l_edges + edgesBords.extend(l_edges) + edgesListees.extend(l_edges) else: logging.debug(" EDGE") edgesBords.append(edgepeau) edgesListees.append(edgepeau) + logging.info('==> Nombre d arêtes de bord : len(edgesBords) = %d', len(edgesBords)) groupEdgesBordPeau = geompy.CreateGroup(facePeau, geompy.ShapeType["EDGE"]) geompy.UnionList(groupEdgesBordPeau, edgesBords) bordsVifs = None if aretesVivesC is not None: - logging.debug("identification des bords vifs par GetInPlace") + logging.info("identification des bords vifs par GetInPlace") bordsVifs = geompy.GetInPlace(facePeau, aretesVivesC) if bordsVifs is None: logging.debug("pas d'identification des bords vifs par GetInPlace: test par distance") @@ -69,7 +72,8 @@ def identifieEdgesPeau_b(facePeau, edgesListees, \ if ( dist < 0.001 ): edvifs.append(edge) break - if len(edvifs) >0: + if edvifs: + logging.info('==> Nombre d arêtes de bord vif : len(edvifs) = %d', len(edvifs)) bordsVifs = geompy.CreateGroup(facePeau,geompy.ShapeType["EDGE"]) for edge in edvifs: geompy.AddObject(bordsVifs, geompy.GetSubShapeID(facePeau, edge)) diff --git a/src/Tools/blocFissure/gmu/identifieEdgesPeau_c.py b/src/Tools/blocFissure/gmu/identifieEdgesPeau_c.py index afe027f1f..233e3c9a8 100644 --- a/src/Tools/blocFissure/gmu/identifieEdgesPeau_c.py +++ b/src/Tools/blocFissure/gmu/identifieEdgesPeau_c.py @@ -33,38 +33,39 @@ def identifieEdgesPeau_c(verticesPipePeau, facePeau, edgesListees, verticesCircP logging.info('start') logging.info("Traitement des arêtes de '%s'", facePeau.GetName()) logging.info('Nombre de sommets : len(verticesPipePeau) = %d', len(verticesPipePeau)) - #logging.info('verticesPipePeau = %s', verticesPipePeau) - logging.info('Nombre de sommets : len(verticesCircPeau) = %d', len(verticesCircPeau)) - #logging.info('verticesCircPeau = %s', verticesCircPeau) edgesPeau = geompy.ExtractShapes(facePeau, geompy.ShapeType["EDGE"], False) logging.info('Nombre total d arêtes de la peau : len(edgesPeau) = %d', len(edgesPeau)) edges = substractSubShapes(facePeau, edgesPeau, edgesListees) - edgesFissurePeau = list() -# --- au moins une extrémité du pipe sur cette face de peau + l_edge_cercle = list() +# --- au moins une extrémité du pipe sur cette face de peau : arêtes sui les prenent toutes if verticesPipePeau: - # En premier, les edges associés aux extrémités du pipe - edgesFissurePeau = [None for _ in range(len(verticesCircPeau))] + i_aux = -1 for edge in edges: - for i_aux, vertex in enumerate(verticesCircPeau): - logging.info(".. distance %s", geompy.MinDistance(vertex, edge)) - if ( ( geompy.MinDistance(vertex, edge) < 1.e-3 ) and ( edge not in edgesFissurePeau ) ): - edgesFissurePeau[i_aux] = edge - name = "edgeFissurePeau_{}".format(i_aux) - logging.info("... entrée de %s à la place %d", edge, i_aux) - geomPublishInFather(initLog.debug, facePeau, edge, name) - # Ensuite, on ajoute les edges manquantes - for edge in edges: - if edge not in edgesFissurePeau: - logging.info("... ajout") - edgesFissurePeau.append(edge) + for groupe in verticesCircPeau: + cercle = True + for id_vertex in geompy.GetObjectIDs(groupe): + vertex = geompy.GetSubShape(facePeau, [id_vertex]) + distance = geompy.MinDistance(vertex, edge) + logging.info(".. distance %s", distance) + if ( distance > 1.e-3 ): + cercle = False + break + if cercle: + logging.info("... entrée de %s dans l_edge_cercle", edge) + l_edge_cercle.append(edge) + i_aux += 1 + name = "edgeFissurePeauCercle_{}".format(i_aux) + geomPublishInFather(initLog.info, facePeau, edge, name) - else: - for i_aux, edge in enumerate(edges): +# --- Les arêtes n'appartenant pas aux cercles + edgesFissurePeau = list() + for i_aux, edge in enumerate(edges): + if edge not in l_edge_cercle: edgesFissurePeau.append(edge) - name = "edgeFissurePeau{}".format(i_aux) + name = "edgeFissurePeau_{}".format(i_aux) geomPublishInFather(initLog.debug, facePeau, edge, name) logging.info('==> Nombre d arêtes : len(edgesFissurePeau) = %d', len(edgesFissurePeau)) diff --git a/src/Tools/blocFissure/gmu/identifieElementsGeometriquesPeau.py b/src/Tools/blocFissure/gmu/identifieElementsGeometriquesPeau.py index e585993b7..3e32edb8c 100644 --- a/src/Tools/blocFissure/gmu/identifieElementsGeometriquesPeau.py +++ b/src/Tools/blocFissure/gmu/identifieElementsGeometriquesPeau.py @@ -27,10 +27,9 @@ from .trouveEdgesFissPeau import trouveEdgesFissPeau from .identifieFacesPeau import identifieFacesPeau from .identifieEdgesPeau import identifieEdgesPeau -def identifieElementsGeometriquesPeau(ifil, partitionPeauFissFond, edgesPipeFiss, \ - edgesFondFiss, wireFondFiss, aretesVivesC, \ - facesDefaut, centreFondFiss, rayonPipe, \ - aretesVivesCoupees, \ +def identifieElementsGeometriquesPeau(ifil, partitionPeauFissFond, \ + edgesPipeFiss, edgesFondFiss, wireFondFiss, aretesVivesC, \ + facesDefaut, centreFondFiss, rayonPipe, aretesVivesCoupees, \ nro_cas=None): """Identification des éléments géométriques de la face de peau""" logging.info('start') @@ -69,7 +68,8 @@ def identifieElementsGeometriquesPeau(ifil, partitionPeauFissFond, edgesPipeFiss # --- identification précise des edges et disques des faces de peau selon index extremité fissure - (endsEdgeFond, facesPipePeau, edgeRadFacePipePeau, edgesCircPeau, verticesCircPeau, groupEdgesBordPeau, \ + (endsEdgeFond, facesPipePeau, edgeRadFacePipePeau, \ + edgesCircPeau, groupEdgesBordPeau, \ bordsVifs, edgesFissurePeau, aretesVivesCoupees) = \ identifieEdgesPeau(edgesFissExtPipe, verticesPipePeau, facePeau, facesPeauSorted, \ edgesPeauFondIn, fillingFaceExterne, aretesVivesC, aretesVivesCoupees, \ @@ -83,7 +83,6 @@ def identifieElementsGeometriquesPeau(ifil, partitionPeauFissFond, edgesPipeFiss edgesFissExtPipe = edgesFissExtPipe, # pour chaque face [edge commun au pipe des faces de fissure externes] facePeau = facePeau, # pour chaque face : la face de peau finale a mailler (percee des faces débouchantes) edgesCircPeau = edgesCircPeau, # pour chaque face de peau : [groupe subshapes edges circulaires aux débouchés du pipe] - verticesCircPeau = verticesCircPeau, # pour chaque face de peau : [groupe subshapes points sur edges circulaires aux débouchés du pipe] groupEdgesBordPeau = groupEdgesBordPeau, # pour chaque face de peau : groupe subshape des edges aux bords liés à la partie saine bordsVifs = bordsVifs, # pour chaque face de peau : groupe subshape des edges aux bords correspondant à des arêtes vives edgesFissurePeau = edgesFissurePeau, # pour chaque face de peau : [subshape edge en peau des faces de fissure externes] diff --git a/src/Tools/blocFissure/gmu/mailleFacesFissure.py b/src/Tools/blocFissure/gmu/mailleFacesFissure.py index 546525af9..456386235 100644 --- a/src/Tools/blocFissure/gmu/mailleFacesFissure.py +++ b/src/Tools/blocFissure/gmu/mailleFacesFissure.py @@ -60,7 +60,8 @@ def mailleFacesFissure(faceFissureExterne, \ hypo2d.SetQuadAllowed( 0 ) putName(hypo2d, "faceFiss", i_pref=nro_cas) - logging.info("UseExisting1DElements depuis '%s'", edgesPipeFissureExterneC.GetName()) + logging.info("UseExisting1DElements sur la géométrie '%s' avec les mailles de '%s'", \ + edgesPipeFissureExterneC.GetName(), edgeFaceFissGroup.GetName()) algo1d = meshFaceFiss.UseExisting1DElements(geom=edgesPipeFissureExterneC) putName(algo1d.GetSubMesh(), "edgeFissPeau", i_pref=nro_cas) hypo1d = algo1d.SourceEdges([ edgeFaceFissGroup ],0,0) diff --git a/src/Tools/blocFissure/gmu/mailleFacesPeau.py b/src/Tools/blocFissure/gmu/mailleFacesPeau.py index 9e56f5815..f53859b71 100644 --- a/src/Tools/blocFissure/gmu/mailleFacesPeau.py +++ b/src/Tools/blocFissure/gmu/mailleFacesPeau.py @@ -34,7 +34,7 @@ from . import initLog from .putName import putName def mailleFacesPeau(partitionsPeauFissFond, idFillingFromBout, facesDefaut, \ - facesPeaux, edCircPeau, ptCircPeau, gpedgeBord, gpedgeVifs, edFissPeau, \ + facesPeaux, edCircPeau, gpedgeBord, gpedgeVifs, edFissPeau, \ bordsLibres, grpEdgesPeauFissureExterne, grpAretesVives, \ edgesCircPipeGroup, dmoyen, rayonPipe, nbsegRad, \ mailleur="MeshGems", nro_cas=None): @@ -91,13 +91,13 @@ def mailleFacesPeau(partitionsPeauFissFond, idFillingFromBout, facesDefaut, \ # --- edges de bord de la face de filling filling = facesDefaut[ifil] edgesFilling = geompy.ExtractShapes(filling, geompy.ShapeType["EDGE"], False) - groupEdgesBordPeau = geompy.CreateGroup(filling, geompy.ShapeType["EDGE"]) - geompy.UnionList(groupEdgesBordPeau, edgesFilling) - geomPublishInFather(initLog.always, filling, groupEdgesBordPeau, "EdgesBords", nro_cas) + gpedgeBord[ifil] = geompy.CreateGroup(filling, geompy.ShapeType["EDGE"]) + geompy.UnionList(gpedgeBord[ifil], edgesFilling) + geomPublishInFather(initLog.always, filling, gpedgeBord[ifil], "EdgesBords", nro_cas) logging.info("UseExisting1DElements sur la géométrie '%s' avec les mailles de '%s'", \ - groupEdgesBordPeau.GetName(), bordsLibres.GetName()) - algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau) + gpedgeBord[ifil].GetName(), bordsLibres.GetName()) + algo1d = meshFacePeau.UseExisting1DElements(geom=gpedgeBord[ifil]) putName(algo1d.GetSubMesh(), "bordsLibres", ifil, nro_cas) hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0) putName(hypo1d, "SourceEdges_{}".format(bordsLibres.GetName()), ifil, nro_cas) @@ -105,21 +105,20 @@ def mailleFacesPeau(partitionsPeauFissFond, idFillingFromBout, facesDefaut, \ else: logging.info("face de peau %d coupée par la fissure", ifil) - edgesCircPeau = edCircPeau[ifil] # pour chaque face de peau : [subshape edge circulaire aux débouchés du pipe] - _ = ptCircPeau[ifil] # pour chaque face de peau : [subshape point sur edge circulaire aux débouchés du pipe] - groupEdgesBordPeau = gpedgeBord[ifil] # pour chaque face de peau : groupe subshape des edges aux bords liés à la partie saine - bordsVifs = gpedgeVifs[ifil] # pour chaque face de peau : groupe subshape des edges aux bords correspondant à des arêtes vives - edgesFissurePeau = edFissPeau[ifil] # pour chaque face de peau : [subshape edge en peau des faces de fissure externes] + # edCircPeau[ifil] # pour chaque face de peau : [subshape edge circulaire aux débouchés du pipe] + # gpedgeBord[ifil] : pour chaque face de peau : groupe subshape des edges aux bords liés à la partie saine + # gpedgeVifs[ifil] : pour chaque face de peau : groupe subshape des edges aux bords correspondant à des arêtes vives + # edFissPeau[ifil] : pour chaque face de peau : [subshape edge en peau des faces de fissure externes] logging.info("UseExisting1DElements sur la géométrie '%s' avec les mailles de '%s'", \ - groupEdgesBordPeau.GetName(), bordsLibres.GetName()) - algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau) + gpedgeBord[ifil].GetName(), bordsLibres.GetName()) + algo1d = meshFacePeau.UseExisting1DElements(geom=gpedgeBord[ifil]) putName(algo1d.GetSubMesh(), "bordsLibres", ifil, nro_cas) hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0) putName(hypo1d, "SourceEdges_{}".format(bordsLibres.GetName()), i_pref=nro_cas) - objet = geompy.MakeCompound(edgesFissurePeau) - geomPublishInFather(initLog.always, facePeau, objet, "edgesFissurePeau") + objet = geompy.MakeCompound(edFissPeau[ifil]) + geomPublishInFather(initLog.always, facePeau, objet, "edFissPeau_{}".format(ifil)) logging.info("UseExisting1DElements sur la géométrie '%s' avec les mailles de '%s'", \ objet.GetName(), grpEdgesPeauFissureExterne.GetName()) algo1d = meshFacePeau.UseExisting1DElements(geom=objet) @@ -127,15 +126,15 @@ def mailleFacesPeau(partitionsPeauFissFond, idFillingFromBout, facesDefaut, \ hypo1d = algo1d.SourceEdges([ grpEdgesPeauFissureExterne ],0,0) putName(hypo1d, "SourceEdges_{}".format(grpEdgesPeauFissureExterne.GetName()), i_pref=nro_cas) - if bordsVifs is not None: + if gpedgeVifs[ifil] is not None: logging.info("UseExisting1DElements sur la géométrie '%s' avec les mailles de '%s'", \ - bordsVifs.GetName(), grpAretesVives.GetName()) - algo1d = meshFacePeau.UseExisting1DElements(geom=bordsVifs) - putName(algo1d.GetSubMesh(), "bordsVifs", ifil, nro_cas) + gpedgeVifs[ifil].GetName(), grpAretesVives.GetName()) + algo1d = meshFacePeau.UseExisting1DElements(geom=gpedgeVifs[ifil]) + putName(algo1d.GetSubMesh(), "gpedgeVifs", ifil, nro_cas) hypo1d = algo1d.SourceEdges([ grpAretesVives ],0,0) putName(hypo1d, "SourceEdges_{}".format(grpAretesVives.GetName()), i_pref=nro_cas) - for i_aux, edgeCirc in enumerate(edgesCircPeau): + for i_aux, edgeCirc in enumerate(edCircPeau[ifil]): texte = "i_aux = {}".format(i_aux) logging.info(texte) if edgeCirc is not None: From dafba4c57c0590a4793ca88560b7b419ab837407 Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 27 Apr 2021 16:20:32 +0300 Subject: [PATCH 10/17] Increment version: 9.7.0 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b322f2b40..f9e93d6ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,11 +27,11 @@ INCLUDE(CMakeDependentOption) STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC) SET(${PROJECT_NAME_UC}_MAJOR_VERSION 9) -SET(${PROJECT_NAME_UC}_MINOR_VERSION 6) +SET(${PROJECT_NAME_UC}_MINOR_VERSION 7) SET(${PROJECT_NAME_UC}_PATCH_VERSION 0) SET(${PROJECT_NAME_UC}_VERSION ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION}) -SET(${PROJECT_NAME_UC}_VERSION_DEV 1) +SET(${PROJECT_NAME_UC}_VERSION_DEV 0) # Common CMake macros # =================== From 705ff2e64ca884a8b62d28974fd63a9f15772cb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rald=20NICOLAS?= Date: Tue, 27 Apr 2021 16:17:18 +0200 Subject: [PATCH 11/17] Passage des cas-tests en moins de 1mn chacun --- .../blocFissure_01_without_session.py | 15 +- .../blocFissure_02_without_session.py | 10 +- .../blocFissure_07_without_session.py | 6 +- src/Tools/blocFissure/CasTests/CMakeLists.txt | 2 +- .../blocFissure/CasTests/blocFissureTest.py | 30 +-- .../{cubeAngle2.py => cubeAngle_2.py} | 4 +- src/Tools/blocFissure/CasTests/cylindre_2.py | 2 +- src/Tools/blocFissure/CasTests/disquePerce.py | 4 +- src/Tools/blocFissure/CasTests/ellipse_1.py | 4 +- src/Tools/blocFissure/CasTests/ellipse_2.py | 4 +- src/Tools/blocFissure/doc/conf.py.in | 2 +- ...{01_CubeAngle_2.png => 01_CubeAngle_a.png} | Bin .../{02_CubeAngle2.png => 02_CubeAngle_2.png} | Bin ..._CubeAngle2_2.png => 02_CubeAngle_2_a.png} | Bin .../{03_cylindre_2.png => 03_cylindre_a.png} | Bin .../{04_cylindre2.png => 04_cylindre_2.png} | Bin ...04_cylindre2_2.png => 04_cylindre_2_a.png} | Bin .../{05_disque_2.png => 05_disque_a.png} | Bin .../{06_ellipse1.png => 06_ellipse_1.png} | Bin .../{06_ellipse1_2.png => 06_ellipse_1_a.png} | Bin .../{07_ellipse2.png => 07_ellipse_2.png} | Bin .../{07_ellipse2_2.png => 07_ellipse_2_a.png} | Bin ...Courbe_2.png => 08_eprouvetteCourbe_a.png} | Bin ...Droite_2.png => 09_eprouvetteDroite_a.png} | Bin ...eDroite2.png => 10_eprouvetteDroite_2.png} | Bin ...ite2_2.png => 10_eprouvetteDroite_2_a.png} | Bin ...12_faceGauche2.png => 12_faceGauche_2.png} | Bin ...aceGauche2_2.png => 12_faceGauche_2_a.png} | Bin src/Tools/blocFissure/doc/scripts.rst | 14 +- src/Tools/blocFissure/doc/testcases.rst | 218 +++++++++--------- .../materielCasTests/CMakeLists.txt | 4 +- .../blocFissure/materielCasTests/cubeAngle.py | 2 +- .../{disque_perce.py => disquePerce.py} | 2 +- .../blocFissure/materielCasTests/ellipse.py | 10 +- .../materielCasTests/ellipse_probleme.py | 6 +- .../{fissureGauche2.py => fissureGauche_2.py} | 0 .../materielCasTests/genereMateriel.py | 4 +- 37 files changed, 163 insertions(+), 180 deletions(-) rename src/Tools/blocFissure/CasTests/{cubeAngle2.py => cubeAngle_2.py} (97%) rename src/Tools/blocFissure/doc/images/{01_CubeAngle_2.png => 01_CubeAngle_a.png} (100%) rename src/Tools/blocFissure/doc/images/{02_CubeAngle2.png => 02_CubeAngle_2.png} (100%) rename src/Tools/blocFissure/doc/images/{02_CubeAngle2_2.png => 02_CubeAngle_2_a.png} (100%) rename src/Tools/blocFissure/doc/images/{03_cylindre_2.png => 03_cylindre_a.png} (100%) rename src/Tools/blocFissure/doc/images/{04_cylindre2.png => 04_cylindre_2.png} (100%) rename src/Tools/blocFissure/doc/images/{04_cylindre2_2.png => 04_cylindre_2_a.png} (100%) rename src/Tools/blocFissure/doc/images/{05_disque_2.png => 05_disque_a.png} (100%) rename src/Tools/blocFissure/doc/images/{06_ellipse1.png => 06_ellipse_1.png} (100%) rename src/Tools/blocFissure/doc/images/{06_ellipse1_2.png => 06_ellipse_1_a.png} (100%) rename src/Tools/blocFissure/doc/images/{07_ellipse2.png => 07_ellipse_2.png} (100%) rename src/Tools/blocFissure/doc/images/{07_ellipse2_2.png => 07_ellipse_2_a.png} (100%) rename src/Tools/blocFissure/doc/images/{08_eprouvetteCourbe_2.png => 08_eprouvetteCourbe_a.png} (100%) rename src/Tools/blocFissure/doc/images/{09_eprouvetteDroite_2.png => 09_eprouvetteDroite_a.png} (100%) rename src/Tools/blocFissure/doc/images/{10_eprouvetteDroite2.png => 10_eprouvetteDroite_2.png} (100%) rename src/Tools/blocFissure/doc/images/{10_eprouvetteDroite2_2.png => 10_eprouvetteDroite_2_a.png} (100%) rename src/Tools/blocFissure/doc/images/{12_faceGauche2.png => 12_faceGauche_2.png} (100%) rename src/Tools/blocFissure/doc/images/{12_faceGauche2_2.png => 12_faceGauche_2_a.png} (100%) rename src/Tools/blocFissure/materielCasTests/{disque_perce.py => disquePerce.py} (99%) rename src/Tools/blocFissure/materielCasTests/{fissureGauche2.py => fissureGauche_2.py} (100%) diff --git a/doc/salome/examples/blocFissure_01_without_session.py b/doc/salome/examples/blocFissure_01_without_session.py index 798b5fd69..fcdda3284 100755 --- a/doc/salome/examples/blocFissure_01_without_session.py +++ b/doc/salome/examples/blocFissure_01_without_session.py @@ -11,7 +11,7 @@ Gérald NICOLAS +33.1.78.19.43.52 """ -__revision__ = "V02.03" +__revision__ = "V02.04" import os import sys @@ -22,18 +22,7 @@ salome.standalone() salome.salome_init() from blocFissure.CasTests.blocFissureTest import blocFissureTest -BLOCFISSURE_TEST = blocFissureTest(["cubeAngle", "cubeAngle2","cubeCoin", "cubeMilieu", "cubeTransverse"]) -#BLOCFISSURE_TEST = blocFissureTest(["cylindre", "cylindre_2"]) -#BLOCFISSURE_TEST = blocFissureTest(["disque_perce"]) -#BLOCFISSURE_TEST = blocFissureTest(["faceGauche"]) -#BLOCFISSURE_TEST = blocFissureTest(["ellipse_1", "ellipse_2", "faceGauche_2"]) -#BLOCFISSURE_TEST = blocFissureTest(["eprouvetteCourbe"]) -#BLOCFISSURE_TEST = blocFissureTest(["eprouvetteDroite", "eprouvetteDroite_2"]) -#BLOCFISSURE_TEST = blocFissureTest(["vis"]) -#BLOCFISSURE_TEST = blocFissureTest(["fissureCoude_1", "fissureCoude_2", "fissureCoude_3", "fissureCoude_4", "fissureCoude_5", "fissureCoude_6", "fissureCoude_7", "fissureCoude_8", "fissureCoude_9", "fissureCoude_10", "fissure_Coude", "fissure_Coude_4"]) -#BLOCFISSURE_TEST = blocFissureTest(["fissureCoude_1", "fissureCoude_2", "fissureCoude_3", "fissureCoude_4", "fissureCoude_5"]) -#BLOCFISSURE_TEST = blocFissureTest(["fissureCoude_6", "fissureCoude_7", "fissureCoude_8", "fissureCoude_9", "fissureCoude_10"]) -#BLOCFISSURE_TEST = blocFissureTest(["fissure_Coude", "fissure_Coude_4"]) +BLOCFISSURE_TEST = blocFissureTest(["cubeAngle", "cubeAngle_2","cubeCoin", "cubeMilieu", "cubeTransverse"]) MESSAGE_ERREUR = BLOCFISSURE_TEST.lancement() #sys.stdout.write(MESSAGE_ERREUR) del BLOCFISSURE_TEST diff --git a/doc/salome/examples/blocFissure_02_without_session.py b/doc/salome/examples/blocFissure_02_without_session.py index 454c70f3d..72700e3e9 100755 --- a/doc/salome/examples/blocFissure_02_without_session.py +++ b/doc/salome/examples/blocFissure_02_without_session.py @@ -6,7 +6,7 @@ Cas tests basés sur les matériels : . decoupeCylindre . disque_perce . fissureGauche -. fissureGauche2 +. fissureGauche_2 + ellipse, ellipse_disque, ellipse_probleme Copyright 2021 EDF @@ -14,7 +14,7 @@ Gérald NICOLAS +33.1.78.19.43.52 """ -__revision__ = "V02.03" +__revision__ = "V02.04" import os import sys @@ -25,10 +25,10 @@ salome.standalone() salome.salome_init() from blocFissure.CasTests.blocFissureTest import blocFissureTest -BLOCFISSURE_TEST = blocFissureTest(["cylindre", "cylindre_2", "disquePerce", "faceGauche","ellipse_1", "ellipse_2", "faceGauche_2"]) -#BLOCFISSURE_TEST = blocFissureTest(["cylindre", "cylindre_2", "disquePerce", "faceGauche","ellipse_1", "ellipse_2"]) +BLOCFISSURE_TEST = blocFissureTest(["cylindre", "cylindre_2", "disquePerce", "faceGauche","ellipse_1", "ellipse_2"]) +#BLOCFISSURE_TEST = blocFissureTest(["cylindre", "cylindre_2", "disquePerce", "faceGauche","ellipse_1", "ellipse_2", "faceGauche_2"]) MESSAGE_ERREUR = BLOCFISSURE_TEST.lancement() -sys.stdout.write(MESSAGE_ERREUR) +#sys.stdout.write(MESSAGE_ERREUR) del BLOCFISSURE_TEST # Diagnostic diff --git a/doc/salome/examples/blocFissure_07_without_session.py b/doc/salome/examples/blocFissure_07_without_session.py index 0d5413215..87ff9823b 100755 --- a/doc/salome/examples/blocFissure_07_without_session.py +++ b/doc/salome/examples/blocFissure_07_without_session.py @@ -11,7 +11,7 @@ Gérald NICOLAS +33.1.78.19.43.52 """ -__revision__ = "V02.03" +__revision__ = "V02.04" import os import sys @@ -22,8 +22,8 @@ salome.standalone() salome.salome_init() from blocFissure.CasTests.blocFissureTest import blocFissureTest -BLOCFISSURE_TEST = blocFissureTest(["vis"]) -#BLOCFISSURE_TEST = blocFissureTest(["vis", "tube"]) +BLOCFISSURE_TEST = blocFissureTest(["vis_1"]) +#BLOCFISSURE_TEST = blocFissureTest(["vis_1", "tube"]) MESSAGE_ERREUR = BLOCFISSURE_TEST.lancement() #sys.stdout.write(MESSAGE_ERREUR) del BLOCFISSURE_TEST diff --git a/src/Tools/blocFissure/CasTests/CMakeLists.txt b/src/Tools/blocFissure/CasTests/CMakeLists.txt index d6bce955a..2aec25d1e 100644 --- a/src/Tools/blocFissure/CasTests/CMakeLists.txt +++ b/src/Tools/blocFissure/CasTests/CMakeLists.txt @@ -23,7 +23,7 @@ SET(plugin_SCRIPTS __init__.py blocFissureTest.py - cubeAngle2.py + cubeAngle_2.py cubeAngle.py cubeCoin.py cubeMilieu.py diff --git a/src/Tools/blocFissure/CasTests/blocFissureTest.py b/src/Tools/blocFissure/CasTests/blocFissureTest.py index 8a5335753..6beab0aed 100644 --- a/src/Tools/blocFissure/CasTests/blocFissureTest.py +++ b/src/Tools/blocFissure/CasTests/blocFissureTest.py @@ -17,17 +17,17 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -__revision__ = "V03.01" +__revision__ = "V03.02" """Lancement des cas-tests de blocFissure Temps par type de matériel : -. cubeAngle : 24s ["cubeAngle", "cubeAngle2"]) +. cubeAngle : 24s ["cubeAngle", "cubeAngle_2"]) . cubeFin : 42s ["cubeCoin", "cubeMilieu", "cubeTransverse"] . decoupeCylindre : 8s ["cylindre", "cylindre_2"] -. disque_perce (+ ellipse_disque) : 9s ["disque_perce"] +. disquePerce (+ ellipse_disque) : 9s ["disquePerce"] . fissureGauche : 26s ["faceGauche"] -. fissureGauche2 (+ ellipse + ellipse_probleme): 22s ["ellipse_1", "ellipse_2", "faceGauche_2"] +. fissureGauche_2 (+ ellipse + ellipse_probleme): 22s ["ellipse_1", "ellipse_2", "faceGauche_2"] . eprouvetteCourbe : 22s ["eprouvetteCourbe"] . eprouvetteDroite : 31s ["eprouvetteDroite", "eprouvetteDroite_2"] . vis : 9s ["vis"] @@ -66,7 +66,7 @@ print ("TORUN = {} # PB".format(TORUNPB)) # Numéro de référence associé à chaque problème défini par le nom de son fichier dans le répertoire CasTests NREF_PB = dict() NREF_PB["cubeAngle"] = 0 -NREF_PB["cubeAngle2"] = 1 +NREF_PB["cubeAngle_2"] = 1 NREF_PB["cubeCoin"] = 2 NREF_PB["cubeMilieu"] = 3 NREF_PB["cubeTransverse"] = 4 @@ -198,8 +198,8 @@ Le(s) numéro/nom du/des tests à passer. Si aucun n'est donné, tous les cas so n_cas = 1 if n_cas in self.l_cas: - from blocFissure.CasTests.cubeAngle2 import cubeAngle2 - self.l_problemes.append(cubeAngle2(n_cas)) + from blocFissure.CasTests.cubeAngle_2 import cubeAngle_2 + self.l_problemes.append(cubeAngle_2(n_cas)) self.l_materiels.append("cubeAngle") n_cas = 2 @@ -240,7 +240,7 @@ Le(s) numéro/nom du/des tests à passer. Si aucun n'est donné, tous les cas so from blocFissure.CasTests import disquePerce self.l_problemes.append(casStandard(disquePerce.dicoParams, disquePerce.referencesMaillageFissure, n_cas)) self.d_nom_probleme[n_cas] = "disquePerce" - self.l_materiels.append("disque_perce") + self.l_materiels.append("disquePerce") self.l_materiels.append("ellipse_disque") n_cas = 8 @@ -248,14 +248,14 @@ Le(s) numéro/nom du/des tests à passer. Si aucun n'est donné, tous les cas so from blocFissure.CasTests.ellipse_1 import ellipse_1 self.l_problemes.append(ellipse_1(n_cas)) self.l_materiels.append("ellipse") - self.l_materiels.append("fissureGauche2") + self.l_materiels.append("fissureGauche_2") n_cas = 9 if n_cas in self.l_cas: from blocFissure.CasTests.ellipse_2 import ellipse_2 self.l_problemes.append(ellipse_2(n_cas)) self.l_materiels.append("ellipse_probleme") - self.l_materiels.append("fissureGauche2") + self.l_materiels.append("fissureGauche_2") n_cas = 10 if n_cas in self.l_cas: @@ -285,7 +285,7 @@ Le(s) numéro/nom du/des tests à passer. Si aucun n'est donné, tous les cas so if n_cas in self.l_cas: from blocFissure.CasTests.faceGauche_2 import faceGauche_2 self.l_problemes.append(faceGauche_2(n_cas)) - self.l_materiels.append("fissureGauche2") + self.l_materiels.append("fissureGauche_2") n_cas = 15 if n_cas in self.l_cas: @@ -385,8 +385,8 @@ Le(s) numéro/nom du/des tests à passer. Si aucun n'est donné, tous les cas so if "decoupeCylindre" in self.l_materiels: from blocFissure.materielCasTests import decoupeCylindre - if "disque_perce" in self.l_materiels: - from blocFissure.materielCasTests import disque_perce + if "disquePerce" in self.l_materiels: + from blocFissure.materielCasTests import disquePerce if "ellipse_disque" in self.l_materiels: from blocFissure.materielCasTests import ellipse_disque @@ -400,8 +400,8 @@ Le(s) numéro/nom du/des tests à passer. Si aucun n'est donné, tous les cas so if "fissureGauche" in self.l_materiels: from blocFissure.materielCasTests import fissureGauche - if "fissureGauche2" in self.l_materiels: - from blocFissure.materielCasTests import fissureGauche2 + if "fissureGauche_2" in self.l_materiels: + from blocFissure.materielCasTests import fissureGauche_2 if "eprouvetteCourbe" in self.l_materiels: from blocFissure.materielCasTests import eprouvetteCourbe diff --git a/src/Tools/blocFissure/CasTests/cubeAngle2.py b/src/Tools/blocFissure/CasTests/cubeAngle_2.py similarity index 97% rename from src/Tools/blocFissure/CasTests/cubeAngle2.py rename to src/Tools/blocFissure/CasTests/cubeAngle_2.py index f2ede5d65..24f2d01e1 100644 --- a/src/Tools/blocFissure/CasTests/cubeAngle2.py +++ b/src/Tools/blocFissure/CasTests/cubeAngle_2.py @@ -23,13 +23,13 @@ import os from .cubeAngle import cubeAngle -class cubeAngle2(cubeAngle): +class cubeAngle_2(cubeAngle): """problème de fissure plane coupant 2 faces (angle), débouches normaux, objet plan detection d'un probleme de tolerance sur les edges de jonction pipe et face fissure externe """ - nomProbleme = "cubeAngle2" + nomProbleme = "cubeAngle_2" # --------------------------------------------------------------------------- def setParamShapeFissure(self): diff --git a/src/Tools/blocFissure/CasTests/cylindre_2.py b/src/Tools/blocFissure/CasTests/cylindre_2.py index 05e6f22bc..4d0a93d4f 100644 --- a/src/Tools/blocFissure/CasTests/cylindre_2.py +++ b/src/Tools/blocFissure/CasTests/cylindre_2.py @@ -33,7 +33,7 @@ from .cylindre import cylindre class cylindre_2(cylindre): """problème de fissure plane sur cylindre hexa, fond de fissure complexe : polyline""" - nomProbleme = "cylindre2" + nomProbleme = "cylindre_2" # --------------------------------------------------------------------------- def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams, \ diff --git a/src/Tools/blocFissure/CasTests/disquePerce.py b/src/Tools/blocFissure/CasTests/disquePerce.py index 558afb038..8412b52d1 100644 --- a/src/Tools/blocFissure/CasTests/disquePerce.py +++ b/src/Tools/blocFissure/CasTests/disquePerce.py @@ -23,8 +23,8 @@ import os from blocFissure import gmu -dicoParams = dict(nomCas = 'disque', - nomProbleme = "disque", +dicoParams = dict(nomCas = 'disquePerce', + nomProbleme = "disquePerce", maillageSain = os.path.join(gmu.pathBloc, "materielCasTests", "disque.med"), CAOFaceFissure = os.path.join(gmu.pathBloc, "materielCasTests", "ellipse_disque.brep"), edgeFiss = [3], diff --git a/src/Tools/blocFissure/CasTests/ellipse_1.py b/src/Tools/blocFissure/CasTests/ellipse_1.py index 764e75c48..d29eddc25 100644 --- a/src/Tools/blocFissure/CasTests/ellipse_1.py +++ b/src/Tools/blocFissure/CasTests/ellipse_1.py @@ -34,7 +34,7 @@ from blocFissure.gmu.putName import putName class ellipse_1(fissureGenerique): """problème de fissure non plane, débouchante non normale""" - nomProbleme = "ellipse1" + nomProbleme = "ellipse_1" shapeFissureParams = dict() maillageFissureParams = dict() referencesMaillageFissure = dict() @@ -78,7 +78,7 @@ class ellipse_1(fissureGenerique): lgInfluence = shapeFissureParams['lgInfluence'] - shellFiss = geompy.ImportBREP(os.path.join(gmu.pathBloc, "materielCasTests", "ellipse1.brep")) + shellFiss = geompy.ImportBREP(os.path.join(gmu.pathBloc, "materielCasTests", "ellipse_1.brep")) fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"]) geompy.UnionIDs(fondFiss, [3]) geompy.addToStudy( shellFiss, 'shellFiss' ) diff --git a/src/Tools/blocFissure/CasTests/ellipse_2.py b/src/Tools/blocFissure/CasTests/ellipse_2.py index b1dd29490..aaf78dc8a 100644 --- a/src/Tools/blocFissure/CasTests/ellipse_2.py +++ b/src/Tools/blocFissure/CasTests/ellipse_2.py @@ -32,7 +32,7 @@ from .ellipse_1 import ellipse_1 class ellipse_2(ellipse_1): """problème de fissure non plane, débouchante non normale""" - nomProbleme = "ellipse2" + nomProbleme = "ellipse_2" # --------------------------------------------------------------------------- def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams, \ @@ -43,7 +43,7 @@ class ellipse_2(ellipse_1): lgInfluence = shapeFissureParams['lgInfluence'] - shellFiss = geompy.ImportBREP(os.path.join(gmu.pathBloc, "materielCasTests", "ellipse1_pb.brep")) + shellFiss = geompy.ImportBREP(os.path.join(gmu.pathBloc, "materielCasTests", "ellipse_1_pb.brep")) fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"]) geompy.UnionIDs(fondFiss, [3]) geompy.addToStudy( shellFiss, 'shellFiss' ) diff --git a/src/Tools/blocFissure/doc/conf.py.in b/src/Tools/blocFissure/doc/conf.py.in index 5d530fb5c..b72f48cc0 100644 --- a/src/Tools/blocFissure/doc/conf.py.in +++ b/src/Tools/blocFissure/doc/conf.py.in @@ -43,7 +43,7 @@ master_doc = 'index' # General substitutions. project = 'Plug-in blocFissure' -copyright = '2010-2021 EDF R&D' +copyright = '2010-2021 EDF' # The default replacements for |version| and |release|, also used in various # other places throughout the built documents. diff --git a/src/Tools/blocFissure/doc/images/01_CubeAngle_2.png b/src/Tools/blocFissure/doc/images/01_CubeAngle_a.png similarity index 100% rename from src/Tools/blocFissure/doc/images/01_CubeAngle_2.png rename to src/Tools/blocFissure/doc/images/01_CubeAngle_a.png diff --git a/src/Tools/blocFissure/doc/images/02_CubeAngle2.png b/src/Tools/blocFissure/doc/images/02_CubeAngle_2.png similarity index 100% rename from src/Tools/blocFissure/doc/images/02_CubeAngle2.png rename to src/Tools/blocFissure/doc/images/02_CubeAngle_2.png diff --git a/src/Tools/blocFissure/doc/images/02_CubeAngle2_2.png b/src/Tools/blocFissure/doc/images/02_CubeAngle_2_a.png similarity index 100% rename from src/Tools/blocFissure/doc/images/02_CubeAngle2_2.png rename to src/Tools/blocFissure/doc/images/02_CubeAngle_2_a.png diff --git a/src/Tools/blocFissure/doc/images/03_cylindre_2.png b/src/Tools/blocFissure/doc/images/03_cylindre_a.png similarity index 100% rename from src/Tools/blocFissure/doc/images/03_cylindre_2.png rename to src/Tools/blocFissure/doc/images/03_cylindre_a.png diff --git a/src/Tools/blocFissure/doc/images/04_cylindre2.png b/src/Tools/blocFissure/doc/images/04_cylindre_2.png similarity index 100% rename from src/Tools/blocFissure/doc/images/04_cylindre2.png rename to src/Tools/blocFissure/doc/images/04_cylindre_2.png diff --git a/src/Tools/blocFissure/doc/images/04_cylindre2_2.png b/src/Tools/blocFissure/doc/images/04_cylindre_2_a.png similarity index 100% rename from src/Tools/blocFissure/doc/images/04_cylindre2_2.png rename to src/Tools/blocFissure/doc/images/04_cylindre_2_a.png diff --git a/src/Tools/blocFissure/doc/images/05_disque_2.png b/src/Tools/blocFissure/doc/images/05_disque_a.png similarity index 100% rename from src/Tools/blocFissure/doc/images/05_disque_2.png rename to src/Tools/blocFissure/doc/images/05_disque_a.png diff --git a/src/Tools/blocFissure/doc/images/06_ellipse1.png b/src/Tools/blocFissure/doc/images/06_ellipse_1.png similarity index 100% rename from src/Tools/blocFissure/doc/images/06_ellipse1.png rename to src/Tools/blocFissure/doc/images/06_ellipse_1.png diff --git a/src/Tools/blocFissure/doc/images/06_ellipse1_2.png b/src/Tools/blocFissure/doc/images/06_ellipse_1_a.png similarity index 100% rename from src/Tools/blocFissure/doc/images/06_ellipse1_2.png rename to src/Tools/blocFissure/doc/images/06_ellipse_1_a.png diff --git a/src/Tools/blocFissure/doc/images/07_ellipse2.png b/src/Tools/blocFissure/doc/images/07_ellipse_2.png similarity index 100% rename from src/Tools/blocFissure/doc/images/07_ellipse2.png rename to src/Tools/blocFissure/doc/images/07_ellipse_2.png diff --git a/src/Tools/blocFissure/doc/images/07_ellipse2_2.png b/src/Tools/blocFissure/doc/images/07_ellipse_2_a.png similarity index 100% rename from src/Tools/blocFissure/doc/images/07_ellipse2_2.png rename to src/Tools/blocFissure/doc/images/07_ellipse_2_a.png diff --git a/src/Tools/blocFissure/doc/images/08_eprouvetteCourbe_2.png b/src/Tools/blocFissure/doc/images/08_eprouvetteCourbe_a.png similarity index 100% rename from src/Tools/blocFissure/doc/images/08_eprouvetteCourbe_2.png rename to src/Tools/blocFissure/doc/images/08_eprouvetteCourbe_a.png diff --git a/src/Tools/blocFissure/doc/images/09_eprouvetteDroite_2.png b/src/Tools/blocFissure/doc/images/09_eprouvetteDroite_a.png similarity index 100% rename from src/Tools/blocFissure/doc/images/09_eprouvetteDroite_2.png rename to src/Tools/blocFissure/doc/images/09_eprouvetteDroite_a.png diff --git a/src/Tools/blocFissure/doc/images/10_eprouvetteDroite2.png b/src/Tools/blocFissure/doc/images/10_eprouvetteDroite_2.png similarity index 100% rename from src/Tools/blocFissure/doc/images/10_eprouvetteDroite2.png rename to src/Tools/blocFissure/doc/images/10_eprouvetteDroite_2.png diff --git a/src/Tools/blocFissure/doc/images/10_eprouvetteDroite2_2.png b/src/Tools/blocFissure/doc/images/10_eprouvetteDroite_2_a.png similarity index 100% rename from src/Tools/blocFissure/doc/images/10_eprouvetteDroite2_2.png rename to src/Tools/blocFissure/doc/images/10_eprouvetteDroite_2_a.png diff --git a/src/Tools/blocFissure/doc/images/12_faceGauche2.png b/src/Tools/blocFissure/doc/images/12_faceGauche_2.png similarity index 100% rename from src/Tools/blocFissure/doc/images/12_faceGauche2.png rename to src/Tools/blocFissure/doc/images/12_faceGauche_2.png diff --git a/src/Tools/blocFissure/doc/images/12_faceGauche2_2.png b/src/Tools/blocFissure/doc/images/12_faceGauche_2_a.png similarity index 100% rename from src/Tools/blocFissure/doc/images/12_faceGauche2_2.png rename to src/Tools/blocFissure/doc/images/12_faceGauche_2_a.png diff --git a/src/Tools/blocFissure/doc/scripts.rst b/src/Tools/blocFissure/doc/scripts.rst index 078da2596..d8804c1c3 100644 --- a/src/Tools/blocFissure/doc/scripts.rst +++ b/src/Tools/blocFissure/doc/scripts.rst @@ -51,21 +51,21 @@ Geometrical parameters of the tore are illustrated : :align: center :alt: Geometrical parameters of the tore -Different levels of verbose are available. Use one of this 4 optional functions to set verbose type: +Different levels of verbose are available. The prints are located in the file ''LOGFILE''. Use one of this 4 optional functions to set verbose type: -- / **setDebug()** +- / **setDebug(LOGFILE)** -- / **setVerbose()** +- / **setVerbose(LOGFILE)** -- / **setRelease()** +- / **setRelease(LOGFILE)** -- / **setUnitTests()** +- / **setUnitTests(LOGFILE)** **example to run in salome session**:: from blocFissure import gmu from blocFissure.gmu import initLog - initLog.setDebug() + initLog.setDebug("/tmp/blocFissure.log") from blocFissure.casStandard import casStandard @@ -83,6 +83,8 @@ Different levels of verbose are available. Use one of this 4 optional functions execInstance = casStandard(dicoParams) + newmesh = execInstance.maillageFissure + diff --git a/src/Tools/blocFissure/doc/testcases.rst b/src/Tools/blocFissure/doc/testcases.rst index 8119c4e6e..57dc09481 100644 --- a/src/Tools/blocFissure/doc/testcases.rst +++ b/src/Tools/blocFissure/doc/testcases.rst @@ -4,96 +4,102 @@ Test cases ####################### -A base of 30 test cases guarantees the correct functioning of « Bloc Fissure ». 12 cases are dedicated to :ref:`cracked bended pipes ` and the others 13 are for other :ref:`generic geometries `. They are shown here in order to illustrate cases on which « Bloc Fissure » works. +A base of 28 test cases guarantees the correct functioning of « Bloc Fissure ». 12 cases are dedicated to :ref:`cracked bended pipes ` and the others 16 are for other :ref:`generic geometries `. They are shown here in order to illustrate cases on which « Bloc Fissure » works. .. _genericTC: Generic cases =============================== -All 13 cases are shown Table 2. Two views show the whole cracked structure and a zoom onto the crack with its tore. +All 16 cases are shown Table 2. Two views show the whole cracked structure and a zoom onto the crack with its tore. -+-------------------------------------------+----------------------------------------------+ -| CubeAngle | -+-------------------------------------------+----------------------------------------------+ -|.. image:: images/01_CubeAngle.png | .. image:: images/01_CubeAngle_2.png | -| :height: 300 | :height: 300 | -| :align: center | :align: center | -+-------------------------------------------+----------------------------------------------+ -| CubeAngle2 | -+-------------------------------------------+----------------------------------------------+ -|.. image:: images/02_CubeAngle2.png | .. image:: images/02_CubeAngle2_2.png | -| :height: 300 | :height: 300 | -| :align: center | :align: center | -+-------------------------------------------+----------------------------------------------+ -| cylindre | -+-------------------------------------------+----------------------------------------------+ -|.. image:: images/03_cylindre.png | .. image:: images/03_cylindre_2.png | -| :height: 300 | :height: 300 | -| :align: center | :align: center | -+-------------------------------------------+----------------------------------------------+ -| cylindre2 | -+-------------------------------------------+----------------------------------------------+ -|.. image:: images/04_cylindre2.png | .. image:: images/04_cylindre2_2.png | -| :height: 300 | :height: 300 | -| :align: center | :align: center | -+-------------------------------------------+----------------------------------------------+ -| disque | -+-------------------------------------------+----------------------------------------------+ -|.. image:: images/05_disque.png | .. image:: images/05_disque_2.png | -| :height: 300 | :height: 300 | -| :align: center | :align: center | -+-------------------------------------------+----------------------------------------------+ -| ellipse1 | -+-------------------------------------------+----------------------------------------------+ -|.. image:: images/06_ellipse1.png | .. image:: images/06_ellipse1_2.png | -| :height: 300 | :height: 300 | -| :align: center | :align: center | -+-------------------------------------------+----------------------------------------------+ -| ellipse2 (tilted crack) | -+-------------------------------------------+----------------------------------------------+ -|.. image:: images/07_ellipse2.png | .. image:: images/07_ellipse2_2.png | -| :height: 300 | :height: 300 | -| :align: center | :align: center | -+-------------------------------------------+----------------------------------------------+ -| eprouvetteCourbe | -+-------------------------------------------+----------------------------------------------+ -|.. image:: images/08_eprouvetteCourbe.png | .. image:: images/08_eprouvetteCourbe_2.png | -| :height: 300 | :height: 300 | -| :align: center | :align: center | -+-------------------------------------------+----------------------------------------------+ -| eprouvetteDroite | -+-------------------------------------------+----------------------------------------------+ -|.. image:: images/09_eprouvetteDroite.png | .. image:: images/09_eprouvetteDroite_2.png | -| :height: 300 | :height: 300 | -| :align: center | :align: center | -+-------------------------------------------+----------------------------------------------+ -| eprouvetteDroite2 | -+-------------------------------------------+----------------------------------------------+ -|.. image:: images/10_eprouvetteDroite2.png | .. image:: images/10_eprouvetteDroite2_2.png | -| :height: 300 | :height: 300 | -| :align: center | :align: center | -+-------------------------------------------+----------------------------------------------+ -| faceGauche | -+-------------------------------------------+----------------------------------------------+ -|.. image:: images/11_faceGauche.png | .. image:: images/11_faceGauche_2.png | -| :height: 300 | :height: 300 | -| :align: center | :align: center | -+-------------------------------------------+----------------------------------------------+ -| faceGauche2 | -+-------------------------------------------+----------------------------------------------+ -|.. image:: images/12_faceGauche2.png | .. image:: images/12_faceGauche2_2.png | -| :height: 300 | :height: 300 | -| :align: center | :align: center | -+-------------------------------------------+----------------------------------------------+ -| vis (Crack is in the radius filet between the screw head and the screw shank) | -+-------------------------------------------+----------------------------------------------+ -|.. image:: images/13_vis_1.png | .. image:: images/13_vis_1_2.png | -| :width: 400 | :width: 400 | -| :align: center | :align: center | -+-------------------------------------------+----------------------------------------------+ -| tube | -+-------------------------------------------+----------------------------------------------+ ++--------------------------------------------+-----------------------------------------------+ +| CubeAngle | ++--------------------------------------------+-----------------------------------------------+ +|.. image:: images/01_CubeAngle.png | .. image:: images/01_CubeAngle_a.png | +| :height: 300 | :height: 300 | +| :align: center | :align: center | ++--------------------------------------------+-----------------------------------------------+ +| CubeAngle_2 | ++--------------------------------------------+-----------------------------------------------+ +|.. image:: images/02_CubeAngle_2.png | .. image:: images/02_CubeAngle_2_a.png | +| :height: 300 | :height: 300 | +| :align: center | :align: center | ++--------------------------------------------+-----------------------------------------------+ +| cubeCoin | ++--------------------------------------------+-----------------------------------------------+ +| cubeMilieu | ++--------------------------------------------+-----------------------------------------------+ +| cubeTransverse | ++--------------------------------------------+-----------------------------------------------+ +| cylindre | ++--------------------------------------------+-----------------------------------------------+ +|.. image:: images/03_cylindre.png | .. image:: images/03_cylindre_a.png | +| :height: 300 | :height: 300 | +| :align: center | :align: center | ++--------------------------------------------+-----------------------------------------------+ +| cylindre_2 | ++--------------------------------------------+-----------------------------------------------+ +|.. image:: images/04_cylindre_2.png | .. image:: images/04_cylindre_2_a.png | +| :height: 300 | :height: 300 | +| :align: center | :align: center | ++--------------------------------------------+-----------------------------------------------+ +| disquePerce | ++--------------------------------------------+-----------------------------------------------+ +|.. image:: images/05_disque.png | .. image:: images/05_disque_a.png | +| :height: 300 | :height: 300 | +| :align: center | :align: center | ++--------------------------------------------+-----------------------------------------------+ +| ellipse_1 | ++--------------------------------------------+-----------------------------------------------+ +|.. image:: images/06_ellipse_1.png | .. image:: images/06_ellipse_1_a.png | +| :height: 300 | :height: 300 | +| :align: center | :align: center | ++--------------------------------------------+-----------------------------------------------+ +| ellipse_2 (tilted crack) | ++--------------------------------------------+-----------------------------------------------+ +|.. image:: images/07_ellipse_2.png | .. image:: images/07_ellipse_2_a.png | +| :height: 300 | :height: 300 | +| :align: center | :align: center | ++--------------------------------------------+-----------------------------------------------+ +| eprouvetteCourbe | ++--------------------------------------------+-----------------------------------------------+ +|.. image:: images/08_eprouvetteCourbe.png | .. image:: images/08_eprouvetteCourbe_a.png | +| :height: 300 | :height: 300 | +| :align: center | :align: center | ++--------------------------------------------+-----------------------------------------------+ +| eprouvetteDroite | ++--------------------------------------------+-----------------------------------------------+ +|.. image:: images/09_eprouvetteDroite.png | .. image:: images/09_eprouvetteDroite_a.png | +| :height: 300 | :height: 300 | +| :align: center | :align: center | ++--------------------------------------------+-----------------------------------------------+ +| eprouvetteDroite_2 | ++--------------------------------------------+-----------------------------------------------+ +|.. image:: images/10_eprouvetteDroite_2.png | .. image:: images/10_eprouvetteDroite_2_a.png | +| :height: 300 | :height: 300 | +| :align: center | :align: center | ++--------------------------------------------+-----------------------------------------------+ +| faceGauche | ++--------------------------------------------+-----------------------------------------------+ +|.. image:: images/11_faceGauche.png | .. image:: images/11_faceGauche_2.png | +| :height: 300 | :height: 300 | +| :align: center | :align: center | ++--------------------------------------------+-----------------------------------------------+ +| faceGauche_2 | ++--------------------------------------------+-----------------------------------------------+ +|.. image:: images/12_faceGauche_2.png | .. image:: images/12_faceGauche_2_a.png | +| :height: 300 | :height: 300 | +| :align: center | :align: center | ++--------------------------------------------+-----------------------------------------------+ +| vis (Crack is in the radius filet between the screw head and the screw shank) | ++--------------------------------------------+-----------------------------------------------+ +|.. image:: images/13_vis_1.png | .. image:: images/13_vis_1_2.png | +| :width: 400 | :width: 400 | +| :align: center | :align: center | ++--------------------------------------------+-----------------------------------------------+ +| tube | ++--------------------------------------------+-----------------------------------------------+ .. _pipeTC: @@ -123,16 +129,14 @@ coude_0 can be computed using this file for the data: « Bloc Fissure » is very efficient for the case of bended pipes. The generation of the geometry and the crack insertion takes only around 15s. -Running test cases +Data for the test cases ===================================== All the files for these test cases are stored in the directory of the installation of SALOME: ``Salome-VXXXX_package-YY/modules/SMESH_VXXXX/lib/python3.6/site-packages/salome/blocFissure`` -The test cases can be runned either through the python window of the SALOME GUI or with a python script. - -0) **Generate med and breps files.**:: +The set of the med, xao and brep files can be created by the following importation: from blocFissure.materielCasTests import genereMateriel @@ -142,48 +146,36 @@ Once the files are generated, they are saved into the directory of the installat There is no need to generate them again. -1) **To execute all test cases**:: +To check the installation of salome, the test cases can be computed by the salome test process:: - from blocFissure.CasTests import execution_Cas + salome -test blocFissure -2) **To execute only selected test cases**: +Running test cases +===================================== -modify the file ``CasTests/execution_Cas.py`` and change:: +The test cases can be runned by the following instructions:: - runall = False. #old : True + from blocFissure.CasTests.blocFissureTest import blocFissureTest + BLOCFISSURE_TEST = blocFissureTest(list_of_cases) + MESSAGE_ERREUR = BLOCFISSURE_TEST.lancement() + sys.stdout.write(MESSAGE_ERREUR) + del BLOCFISSURE_TEST -And change from 0 to 1 of the index of the test you want to launch:: +If ``list_of_cases`` is an empty list, all the cases are computed. - torun = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - -then launch the test cases:: - - from blocFissure.CasTests import execution_Cas - -The index of each test is the position of the test in the following table, from 0 for cubeAngle, 1 for cubeAngle2, -2 for cubeCoin... from top to bottom, then from left to right. +If not, ``list_of_cases`` is made of the list of the numbers and/or the name of the requested case. The index of each test is the position of the test in the following table, from 0 for cubeAngle, 1 for cubeAngle_2, 2 for cubeCoin... from top to bottom, then from left to right. +--------------------+--------------------+--------------------+-----------------+-----------------+ | cubeAngle | cylindre_2 | eprouvetteDroite_2 | fissureCoude_3 | fissureCoude_9 | +--------------------+--------------------+--------------------+-----------------+-----------------+ -| cubeAngle2 | disquePerce | faceGauche | fissureCoude_4 | fissure_Coude | +| cubeAngle_2 | disquePerce | faceGauche | fissureCoude_4 | fissure_Coude | +--------------------+--------------------+--------------------+-----------------+-----------------+ | cubeCoin | ellipse_1 | faceGauche_2 | fissureCoude_5 | fissure_Coude_4 | +--------------------+--------------------+--------------------+-----------------+-----------------+ | cubeMilieu | ellipse_2 | fissureCoude_1 | fissureCoude_6 | vis_1 | +--------------------+--------------------+--------------------+-----------------+-----------------+ -| cubeTransverse | eprouvetteCourbe | fissureCoude_10 | fissureCoude_7 | tube | +| cubeTransverse | eprouvetteCourbe | fissureCoude_10 | fissureCoude_7 | | +--------------------+--------------------+--------------------+-----------------+-----------------+ | cylindre | eprouvetteDroite | fissureCoude_2 | fissureCoude_8 | | +--------------------+--------------------+--------------------+-----------------+-----------------+ -3) **To execute only one test case**:: - - from blocFissure.CasTests.[TEST_CASE_NAME] import [TEST_CASE_NAME] - - [TEST_CASE_NAME](0).executeProbleme() - -[TEST_CASE_NAME] is the name of the test case in the previous list. Note that the test cases fissureCoude_4 and fissure_Coude_4 are very similar. - - - diff --git a/src/Tools/blocFissure/materielCasTests/CMakeLists.txt b/src/Tools/blocFissure/materielCasTests/CMakeLists.txt index 51701fde3..af61ca4b1 100644 --- a/src/Tools/blocFissure/materielCasTests/CMakeLists.txt +++ b/src/Tools/blocFissure/materielCasTests/CMakeLists.txt @@ -25,13 +25,13 @@ SET(plugin_SCRIPTS cubeAngle.py cubeFin.py decoupeCylindre.py - disque_perce.py + disquePerce.py ellipse_disque.py ellipse_probleme.py ellipse.py eprouvetteCourbe.py eprouvetteDroite.py - fissureGauche2.py + fissureGauche_2.py fissureGauche.py genereMateriel.py tube.py diff --git a/src/Tools/blocFissure/materielCasTests/cubeAngle.py b/src/Tools/blocFissure/materielCasTests/cubeAngle.py index b3ed2808b..fe9332e1e 100644 --- a/src/Tools/blocFissure/materielCasTests/cubeAngle.py +++ b/src/Tools/blocFissure/materielCasTests/cubeAngle.py @@ -19,7 +19,7 @@ # """Géométries et maillages de base nécessaires aux cas-tests : . cubeAngle -. cubeAngle2 +. cubeAngle_2 """ import os diff --git a/src/Tools/blocFissure/materielCasTests/disque_perce.py b/src/Tools/blocFissure/materielCasTests/disquePerce.py similarity index 99% rename from src/Tools/blocFissure/materielCasTests/disque_perce.py rename to src/Tools/blocFissure/materielCasTests/disquePerce.py index 0bc931a23..c56b9ec9c 100644 --- a/src/Tools/blocFissure/materielCasTests/disque_perce.py +++ b/src/Tools/blocFissure/materielCasTests/disquePerce.py @@ -18,7 +18,7 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # """Géométrie et maillage de base nécessaire au cas-test : -. disque_perce +. disquePerce """ import os diff --git a/src/Tools/blocFissure/materielCasTests/ellipse.py b/src/Tools/blocFissure/materielCasTests/ellipse.py index d2e592577..dd3272758 100644 --- a/src/Tools/blocFissure/materielCasTests/ellipse.py +++ b/src/Tools/blocFissure/materielCasTests/ellipse.py @@ -54,8 +54,8 @@ Scale_1 = geompy.MakeScaleAlongAxes(Rotation_1, Vertex_1, 1, 1.5, 1) Vertex_3 = geompy.MakeVertex(420, -400, 300) Vertex_4 = geompy.MakeVertex(500, 400, 500) Box_1 = geompy.MakeBoxTwoPnt(Vertex_4, Vertex_3) -ellipse1 = geompy.MakeCut(Scale_1, Box_1) -[fondFiss] = geompy.SubShapes(ellipse1, [4]) +ellipse_1 = geompy.MakeCut(Scale_1, Box_1) +[fondFiss] = geompy.SubShapes(ellipse_1, [4]) geompy.addToStudy( O, 'O' ) geompy.addToStudy( OX, 'OX' ) geompy.addToStudy( OY, 'OY' ) @@ -69,9 +69,9 @@ geompy.addToStudy( Scale_1, 'Scale_1' ) geompy.addToStudy( Vertex_3, 'Vertex_3' ) geompy.addToStudy( Vertex_4, 'Vertex_4' ) geompy.addToStudy( Box_1, 'Box_1' ) -geompy.addToStudy( ellipse1, 'ellipse1' ) -geompy.addToStudyInFather( ellipse1, fondFiss, 'fondFiss' ) -geompy.ExportBREP(ellipse1, os.path.join(gmu.pathBloc, "materielCasTests", "ellipse1.brep")) +geompy.addToStudy( ellipse_1, 'ellipse_1' ) +geompy.addToStudyInFather( ellipse_1, fondFiss, 'fondFiss' ) +geompy.ExportBREP(ellipse_1, os.path.join(gmu.pathBloc, "materielCasTests", "ellipse_1.brep")) if salome.sg.hasDesktop(): diff --git a/src/Tools/blocFissure/materielCasTests/ellipse_probleme.py b/src/Tools/blocFissure/materielCasTests/ellipse_probleme.py index 1d271c599..096f805aa 100644 --- a/src/Tools/blocFissure/materielCasTests/ellipse_probleme.py +++ b/src/Tools/blocFissure/materielCasTests/ellipse_probleme.py @@ -54,7 +54,7 @@ Vertex_2 = geompy.MakeVertex(20, -100, -50) Vertex_4 = geompy.MakeVertex(100, 100, 50) Box_1 = geompy.MakeBoxTwoPnt(Vertex_2, Vertex_4) Cut_1 = geompy.MakeCut(Rotation_1, Box_1) -ellipse1 = geompy.MakeTranslation(Cut_1, 400, 0, 400) +ellipse_1 = geompy.MakeTranslation(Cut_1, 400, 0, 400) geompy.addToStudy( Disk_1, 'Disk_1' ) geompy.addToStudy( O, 'O' ) geompy.addToStudy( OX, 'OX' ) @@ -68,8 +68,8 @@ geompy.addToStudy( Vertex_2, 'Vertex_2' ) geompy.addToStudy( Box_1, 'Box_1' ) geompy.addToStudy( Vertex_4, 'Vertex_4' ) geompy.addToStudy( Cut_1, 'Cut_1' ) -geompy.addToStudy( ellipse1, 'ellipse1_pb' ) -geompy.ExportBREP(ellipse1, os.path.join(gmu.pathBloc, "materielCasTests", "ellipse1_pb.brep")) +geompy.addToStudy( ellipse_1, 'ellipse_1_pb' ) +geompy.ExportBREP(ellipse_1, os.path.join(gmu.pathBloc, "materielCasTests", "ellipse_1_pb.brep")) if salome.sg.hasDesktop(): diff --git a/src/Tools/blocFissure/materielCasTests/fissureGauche2.py b/src/Tools/blocFissure/materielCasTests/fissureGauche_2.py similarity index 100% rename from src/Tools/blocFissure/materielCasTests/fissureGauche2.py rename to src/Tools/blocFissure/materielCasTests/fissureGauche_2.py diff --git a/src/Tools/blocFissure/materielCasTests/genereMateriel.py b/src/Tools/blocFissure/materielCasTests/genereMateriel.py index f597b9eb9..7ef23abb6 100644 --- a/src/Tools/blocFissure/materielCasTests/genereMateriel.py +++ b/src/Tools/blocFissure/materielCasTests/genereMateriel.py @@ -21,13 +21,13 @@ from blocFissure.materielCasTests import cubeAngle from blocFissure.materielCasTests import cubeFin from blocFissure.materielCasTests import decoupeCylindre -from blocFissure.materielCasTests import disque_perce +from blocFissure.materielCasTests import disquePerce from blocFissure.materielCasTests import ellipse_disque from blocFissure.materielCasTests import ellipse from blocFissure.materielCasTests import ellipse_probleme from blocFissure.materielCasTests import eprouvetteCourbe from blocFissure.materielCasTests import eprouvetteDroite from blocFissure.materielCasTests import fissureGauche -from blocFissure.materielCasTests import fissureGauche2 +from blocFissure.materielCasTests import fissureGauche_2 from blocFissure.materielCasTests import vis from blocFissure.materielCasTests import tube From a8e83192f609abfc18584268b8d109455b5c69fa Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 29 Apr 2021 13:22:23 +0300 Subject: [PATCH 12/17] bos #20256 [CEA 18523] Porting SMESH to int 64 bits Fix export huge mesh to MED --- src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx index e7739b177..b0d98d2c3 100644 --- a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx @@ -786,7 +786,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() // iterator on elements of a current type SMDS_ElemIteratorPtr elemIterator; - int iElem = 0; + TInt iElem = 0; // Treat POLYGONs // --------------- From 26446f72ec526d701a348e77aeda95e1ae35c128 Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 29 Apr 2021 13:51:32 +0300 Subject: [PATCH 13/17] bos #20256 [CEA 18523] Porting SMESH to int 64 bits Fix import huge mesh from MED --- src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx index 1a3fd08a5..bc343e1b5 100644 --- a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx @@ -503,7 +503,7 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform() default:; } vector aNodeIds(aNbNodes); - for ( int iElem = 0; iElem < aNbElems; iElem++ ) + for ( TInt iElem = 0; iElem < aNbElems; iElem++ ) { bool anIsValidConnect = false; TCConnSlice aConnSlice = aCellInfo->GetConnSlice(iElem); From 61bac50f78623aabd9e4ddbcbba072c63ea02165 Mon Sep 17 00:00:00 2001 From: rnv Date: Thu, 29 Apr 2021 18:04:20 +0300 Subject: [PATCH 14/17] Fix compilation problems under windows. --- src/Controls/SMESH_ControlsDef.hxx | 38 +- src/OBJECT/SMESH_ActorUtils.cxx | 14 +- src/OBJECT/SMESH_ActorUtils.h | 2 +- src/OBJECT/SMESH_Object.cxx | 2 +- src/SMESHGUI/SMESHGUI_VTKUtils.cxx | 18 +- src/SMESHGUI/SMESHGUI_VTKUtils.h | 4 +- src/SMESH_I/SMESH_Filter_i.cxx | 7951 +++++++++-------- src/SMESH_I/SMESH_Group_i.cxx | 46 +- src/SMESH_I/SMESH_Measurements_i.cxx | 32 +- src/SMESH_I/SMESH_MeshEditor_i.cxx | 16 +- src/SMESH_I/SMESH_MeshEditor_i.hxx | 2 +- .../StdMeshersGUI_DistrPreview.cxx | 5 - 12 files changed, 4060 insertions(+), 4070 deletions(-) diff --git a/src/Controls/SMESH_ControlsDef.hxx b/src/Controls/SMESH_ControlsDef.hxx index 1ce5f4da5..c1fe797bc 100644 --- a/src/Controls/SMESH_ControlsDef.hxx +++ b/src/Controls/SMESH_ControlsDef.hxx @@ -133,12 +133,12 @@ namespace SMESH{ virtual void SetMesh( const SMDS_Mesh* theMesh ); virtual double GetValue( long theElementId ); virtual double GetValue(const TSequenceOfXYZ& /*thePoints*/) { return -1.0;}; - void GetHistogram(int nbIntervals, - std::vector& nbEvents, - std::vector& funValues, - const std::vector& elements, - const double* minmax=0, - const bool isLogarithmic = false); + void GetHistogram(int nbIntervals, + std::vector& nbEvents, + std::vector& funValues, + const std::vector<::smIdType>& elements, + const double* minmax=0, + const bool isLogarithmic = false); bool IsApplicable( long theElementId ) const; virtual bool IsApplicable( const SMDS_MeshElement* element ) const; virtual SMDSAbs_ElementType GetType() const = 0; @@ -147,7 +147,7 @@ namespace SMESH{ void SetPrecision( const long thePrecision ); double Round( const double & value ); - bool GetPoints(const smIdType theId, TSequenceOfXYZ& theRes) const; + bool GetPoints(const ::smIdType theId, TSequenceOfXYZ& theRes) const; static bool GetPoints(const SMDS_MeshElement* theElem, TSequenceOfXYZ& theRes); protected: const SMDS_Mesh* myMesh; @@ -594,7 +594,7 @@ namespace SMESH{ virtual void SetMesh( const SMDS_Mesh* theMesh ); virtual bool IsSatisfy( long theElementId ); virtual SMDSAbs_ElementType GetType() const; - static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const smIdType theFaceId ); + static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const ::smIdType theFaceId ); typedef long TElemId; struct Border{ TElemId myElemId; @@ -653,8 +653,8 @@ namespace SMESH{ protected: const SMDS_Mesh* myMesh; - std::vector< smIdType > myMin; - std::vector< smIdType > myMax; + std::vector< ::smIdType > myMin; + std::vector< ::smIdType > myMax; TIDsMap myIds; SMDSAbs_ElementType myType; @@ -1165,9 +1165,9 @@ namespace SMESH{ public: ConnectedElements(); //virtual Predicate* clone() const { return new ConnectedElements( *this ); } - void SetNode( smIdType nodeID ); + void SetNode( ::smIdType nodeID ); void SetPoint( double x, double y, double z ); - smIdType GetNode() const; + ::smIdType GetNode() const; std::vector GetPoint() const; void SetType( SMDSAbs_ElementType theType ); @@ -1179,14 +1179,14 @@ namespace SMESH{ //const std::set& GetDomainIDs() const { return myOkIDs; } private: - smIdType myNodeID; - std::vector myXYZ; - SMDSAbs_ElementType myType; - TMeshModifTracer myMeshModifTracer; + ::smIdType myNodeID; + std::vector myXYZ; + SMDSAbs_ElementType myType; + TMeshModifTracer myMeshModifTracer; - void clearOkIDs(); - bool myOkIDsReady; - std::set myOkIDs; // empty means that there is one domain + void clearOkIDs(); + bool myOkIDsReady; + std::set<::smIdType> myOkIDs; // empty means that there is one domain }; typedef boost::shared_ptr ConnectedElementsPtr; diff --git a/src/OBJECT/SMESH_ActorUtils.cxx b/src/OBJECT/SMESH_ActorUtils.cxx index f79f01ae8..203f7931b 100644 --- a/src/OBJECT/SMESH_ActorUtils.cxx +++ b/src/OBJECT/SMESH_ActorUtils.cxx @@ -157,17 +157,17 @@ namespace SMESH } } - std::map GetEntitiesFromObject(SMESH_VisualObj *theObject) { - std::map entities; - entities.insert(std::pair(SMDSAbs_0DElement, + std::map GetEntitiesFromObject(SMESH_VisualObj *theObject) { + std::map entities; + entities.insert(std::pair(SMDSAbs_0DElement, theObject ? theObject->GetNbEntities(SMDSAbs_0DElement) : 0)); - entities.insert(std::pair(SMDSAbs_Ball, + entities.insert(std::pair(SMDSAbs_Ball, theObject ? theObject->GetNbEntities(SMDSAbs_Ball) : 0)); - entities.insert(std::pair(SMDSAbs_Edge, + entities.insert(std::pair(SMDSAbs_Edge, theObject ? theObject->GetNbEntities(SMDSAbs_Edge) : 0)); - entities.insert(std::pair(SMDSAbs_Face, + entities.insert(std::pair(SMDSAbs_Face, theObject ? theObject->GetNbEntities(SMDSAbs_Face) : 0)); - entities.insert(std::pair(SMDSAbs_Volume, + entities.insert(std::pair(SMDSAbs_Volume, theObject ? theObject->GetNbEntities(SMDSAbs_Volume) : 0)); return entities; } diff --git a/src/OBJECT/SMESH_ActorUtils.h b/src/OBJECT/SMESH_ActorUtils.h index a6ea963a5..4167e5ae1 100644 --- a/src/OBJECT/SMESH_ActorUtils.h +++ b/src/OBJECT/SMESH_ActorUtils.h @@ -84,7 +84,7 @@ SMESHOBJECT_EXPORT QString def); SMESHOBJECT_EXPORT - std::map + std::map GetEntitiesFromObject(SMESH_VisualObj *theObject); SMESHOBJECT_EXPORT diff --git a/src/OBJECT/SMESH_Object.cxx b/src/OBJECT/SMESH_Object.cxx index 6f8551d09..846c81562 100644 --- a/src/OBJECT/SMESH_Object.cxx +++ b/src/OBJECT/SMESH_Object.cxx @@ -557,7 +557,7 @@ void SMESH_VisualObjDef::updateEntitiesFlags() unsigned int tmp = myEntitiesState; ClearEntitiesFlags(); - map entities = SMESH::GetEntitiesFromObject(this); + map entities = SMESH::GetEntitiesFromObject(this); if( myEntitiesCache[SMDSAbs_0DElement] != 0 || diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx index eb7a7e5bf..e3d6adeab 100644 --- a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx @@ -1226,8 +1226,8 @@ namespace SMESH int GetEdgeNodes(SVTK_Selector* theSelector, const TVisualObjPtr& theVisualObject, - smIdType& theId1, - smIdType& theId2) + ::smIdType& theId1, + ::smIdType& theId2) { const SALOME_ListIO& selected = theSelector->StoredIObjects(); @@ -1243,9 +1243,9 @@ namespace SMESH if ( aMapIndex.Extent() != 2 ) return -1; - smIdType anObjId = -1, anEdgeNum = -1; - for ( smIdType i = 1; i <= aMapIndex.Extent(); i++ ) { - smIdType aVal = aMapIndex( i ); + ::smIdType anObjId = -1, anEdgeNum = -1; + for ( ::smIdType i = 1; i <= aMapIndex.Extent(); i++ ) { + ::smIdType aVal = aMapIndex( i ); if ( aVal > 0 ) anObjId = aVal; else @@ -1343,7 +1343,7 @@ namespace SMESH } - int GetEdgeNodes( LightApp_SelectionMgr* theMgr, smIdType& theId1, smIdType& theId2 ) + int GetEdgeNodes( LightApp_SelectionMgr* theMgr, ::smIdType& theId1, ::smIdType& theId2 ) { SALOME_ListIO selected; theMgr->selectedObjects( selected ); @@ -1363,9 +1363,9 @@ namespace SMESH if ( aMapIndex.Extent() != 2 ) return -1; - smIdType anObjId = -1, anEdgeNum = -1; - for ( smIdType i = 1; i <= aMapIndex.Extent(); i++ ) { - smIdType aVal = aMapIndex( i ); + ::smIdType anObjId = -1, anEdgeNum = -1; + for ( ::smIdType i = 1; i <= aMapIndex.Extent(); i++ ) { + ::smIdType aVal = aMapIndex( i ); if ( aVal > 0 ) anObjId = aVal; else diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.h b/src/SMESHGUI/SMESHGUI_VTKUtils.h index dec7bdc65..1adcd5c56 100644 --- a/src/SMESHGUI/SMESHGUI_VTKUtils.h +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.h @@ -169,7 +169,7 @@ SMESHGUI_EXPORT const Handle(SALOME_InteractiveObject)&, QString& ); SMESHGUI_EXPORT - int GetEdgeNodes( SVTK_Selector*, const TVisualObjPtr&, smIdType&, smIdType& ); + int GetEdgeNodes( SVTK_Selector*, const TVisualObjPtr&, ::smIdType&, ::smIdType& ); //---------------------------------------------------------------------------- SMESHGUI_EXPORT @@ -189,7 +189,7 @@ SMESHGUI_EXPORT const bool = true ); SMESHGUI_EXPORT - int GetEdgeNodes( LightApp_SelectionMgr*, smIdType&, smIdType& ); + int GetEdgeNodes( LightApp_SelectionMgr*, ::smIdType&, ::smIdType& ); SMESHGUI_EXPORT void SetControlsPrecision( const long ); diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index 2429d5fc1..40b20acbb 100644 --- a/src/SMESH_I/SMESH_Filter_i.cxx +++ b/src/SMESH_I/SMESH_Filter_i.cxx @@ -60,8 +60,8 @@ #include #include -using namespace SMESH; -using namespace SMESH::Controls; +//using namespace SMESH; +//using namespace SMESH::Controls; namespace SMESH @@ -79,9 +79,9 @@ namespace SMESH inline const SMDS_Mesh* -MeshPtr2SMDSMesh( SMESH_Mesh_ptr theMesh ) +MeshPtr2SMDSMesh( SMESH::SMESH_Mesh_ptr theMesh ) { - SMESH_Mesh_i* anImplPtr = DownCast(theMesh); + SMESH_Mesh_i* anImplPtr = SMESH::DownCast(theMesh); return anImplPtr ? anImplPtr->GetImpl().GetMeshDS() : 0; } @@ -117,11 +117,11 @@ static SMESH::Filter::Criterion createCriterion() { SMESH::Filter::Criterion aCriterion; - aCriterion.Type = FT_Undefined; - aCriterion.Compare = FT_Undefined; + aCriterion.Type = SMESH::FT_Undefined; + aCriterion.Compare = SMESH::FT_Undefined; aCriterion.Threshold = 0; - aCriterion.UnaryOp = FT_Undefined; - aCriterion.BinaryOp = FT_Undefined; + aCriterion.UnaryOp = SMESH::FT_Undefined; + aCriterion.BinaryOp = SMESH::FT_Undefined; aCriterion.ThresholdStr = ""; aCriterion.ThresholdID = ""; aCriterion.Tolerance = Precision::Confusion(); @@ -181,2309 +181,13 @@ static TopoDS_Shape getShapeByID (const char* theID) FUNCTORS */ -/* - Class : Functor_i - Description : An abstract class for all functors -*/ -Functor_i::Functor_i(): - SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() ) -{ - //Base class Salome_GenericObject do it inmplicitly by overriding PortableServer::POA_ptr _default_POA() method - //PortableServer::ObjectId_var anObjectId = - // SMESH_Gen_i::GetPOA()->activate_object( this ); -} - -Functor_i::~Functor_i() -{ - //TPythonDump()<SetMesh( MeshPtr2SMDSMesh( theMesh ) ); - TPythonDump()<GetType(); -} - - -/* - Class : NumericalFunctor_i - Description : Base class for numerical functors -*/ -CORBA::Double NumericalFunctor_i::GetValue( SMESH::smIdType theId ) -{ - return myNumericalFunctorPtr->GetValue( theId ); -} - -CORBA::Boolean NumericalFunctor_i::IsApplicable( SMESH::smIdType theElementId ) -{ - return myNumericalFunctorPtr->IsApplicable( theElementId ); -} - -SMESH::Histogram* NumericalFunctor_i::GetHistogram(CORBA::Short nbIntervals, CORBA::Boolean isLogarithmic) -{ - std::vector nbEvents; - std::vector funValues; - std::vector elements; - myNumericalFunctorPtr->GetHistogram(nbIntervals,nbEvents,funValues,elements,0,isLogarithmic); - - SMESH::Histogram_var histogram = new SMESH::Histogram; - - nbIntervals = CORBA::Short( Min( int( nbEvents.size()), - int( funValues.size() - 1 ))); - if ( nbIntervals > 0 ) - { - histogram->length( nbIntervals ); - for ( int i = 0; i < nbIntervals; ++i ) - { - HistogramRectangle& rect = histogram[i]; - rect.nbEvents = nbEvents[i]; - rect.min = funValues[i]; - rect.max = funValues[i+1]; - } - } - return histogram._retn(); -} - -SMESH::Histogram* NumericalFunctor_i::GetLocalHistogram(CORBA::Short nbIntervals, - CORBA::Boolean isLogarithmic, - SMESH::SMESH_IDSource_ptr object) -{ - SMESH::Histogram_var histogram = new SMESH::Histogram; - - std::vector nbEvents; - std::vector funValues; - std::vector elements; - - SMDS_ElemIteratorPtr elemIt; - if ( SMESH::DownCast< SMESH_GroupOnFilter_i* >( object ) || - SMESH::DownCast< SMESH::Filter_i* >( object )) - { - elemIt = SMESH_Mesh_i::GetElements( object, GetElementType() ); - if ( !elemIt ) return histogram._retn(); - } - else - { - SMESH::SMESH_Mesh_var mesh = object->GetMesh(); - SMESH::smIdType_array_var objNbElems = object->GetNbElementsByType(); - SMESH::smIdType_array_var meshNbElems = mesh-> GetNbElementsByType(); - if ( meshNbElems[ GetElementType() ] != - objNbElems [ GetElementType() ] ) - { - elements.reserve( objNbElems[ GetElementType() ]); - elemIt = SMESH_Mesh_i::GetElements( object, GetElementType() ); - } - } - if ( elemIt ) - { - while ( elemIt->more() ) - elements.push_back( elemIt->next()->GetID() ); - if ( elements.empty() ) return histogram._retn(); - } - - myNumericalFunctorPtr->GetHistogram(nbIntervals,nbEvents,funValues,elements,0,isLogarithmic); - - nbIntervals = CORBA::Short( Min( int( nbEvents.size()), - int( funValues.size() - 1 ))); - if ( nbIntervals > 0 ) - { - histogram->length( nbIntervals ); - for ( int i = 0; i < nbIntervals; ++i ) - { - HistogramRectangle& rect = histogram[i]; - rect.nbEvents = nbEvents[i]; - rect.min = funValues[i]; - rect.max = funValues[i+1]; - } - } - return histogram._retn(); -} - -void NumericalFunctor_i::SetPrecision( CORBA::Long thePrecision ) -{ - myNumericalFunctorPtr->SetPrecision( thePrecision ); - TPythonDump()<GetPrecision(); -} - -Controls::NumericalFunctorPtr NumericalFunctor_i::GetNumericalFunctor() -{ - return myNumericalFunctorPtr; -} - - -/* - Class : SMESH_MinimumAngle - Description : Functor for calculation of minimum angle -*/ -MinimumAngle_i::MinimumAngle_i() -{ - myNumericalFunctorPtr.reset( new Controls::MinimumAngle() ); - myFunctorPtr = myNumericalFunctorPtr; -} - -FunctorType MinimumAngle_i::GetFunctorType() -{ - return SMESH::FT_MinimumAngle; -} - - -/* - Class : AspectRatio - Description : Functor for calculating aspect ratio -*/ -AspectRatio_i::AspectRatio_i() -{ - myNumericalFunctorPtr.reset( new Controls::AspectRatio() ); - myFunctorPtr = myNumericalFunctorPtr; -} - -FunctorType AspectRatio_i::GetFunctorType() -{ - return SMESH::FT_AspectRatio; -} - - -/* - Class : AspectRatio3D - Description : Functor for calculating aspect ratio 3D -*/ -AspectRatio3D_i::AspectRatio3D_i() -{ - myNumericalFunctorPtr.reset( new Controls::AspectRatio3D() ); - myFunctorPtr = myNumericalFunctorPtr; -} - -FunctorType AspectRatio3D_i::GetFunctorType() -{ - return SMESH::FT_AspectRatio3D; -} - - -/* - Class : Warping_i - Description : Functor for calculating warping -*/ -Warping_i::Warping_i() -{ - myNumericalFunctorPtr.reset( new Controls::Warping() ); - myFunctorPtr = myNumericalFunctorPtr; -} - -FunctorType Warping_i::GetFunctorType() -{ - return SMESH::FT_Warping; -} - - -/* - Class : Taper_i - Description : Functor for calculating taper -*/ -Taper_i::Taper_i() -{ - myNumericalFunctorPtr.reset( new Controls::Taper() ); - myFunctorPtr = myNumericalFunctorPtr; -} - -FunctorType Taper_i::GetFunctorType() -{ - return SMESH::FT_Taper; -} - -/* - Class : Skew_i - Description : Functor for calculating skew in degrees -*/ -Skew_i::Skew_i() -{ - myNumericalFunctorPtr.reset( new Controls::Skew() ); - myFunctorPtr = myNumericalFunctorPtr; -} - -FunctorType Skew_i::GetFunctorType() -{ - return SMESH::FT_Skew; -} - -/* - Class : Area_i - Description : Functor for calculating area -*/ -Area_i::Area_i() -{ - myNumericalFunctorPtr.reset( new Controls::Area() ); - myFunctorPtr = myNumericalFunctorPtr; -} - -FunctorType Area_i::GetFunctorType() -{ - return SMESH::FT_Area; -} - -/* - Class : Volume3D_i - Description : Functor for calculating volume of 3D element -*/ -Volume3D_i::Volume3D_i() -{ - myNumericalFunctorPtr.reset( new Controls::Volume() ); - myFunctorPtr = myNumericalFunctorPtr; -} - -FunctorType Volume3D_i::GetFunctorType() -{ - return SMESH::FT_Volume3D; -} - -/* - Class : MaxElementLength2D_i - Description : Functor for calculating maximum length of 2D element -*/ -MaxElementLength2D_i::MaxElementLength2D_i() -{ - myNumericalFunctorPtr.reset( new Controls::MaxElementLength2D() ); - myFunctorPtr = myNumericalFunctorPtr; -} - -FunctorType MaxElementLength2D_i::GetFunctorType() -{ - return SMESH::FT_MaxElementLength2D; -} - -/* - Class : MaxElementLength3D_i - Description : Functor for calculating maximum length of 3D element -*/ -MaxElementLength3D_i::MaxElementLength3D_i() -{ - myNumericalFunctorPtr.reset( new Controls::MaxElementLength3D() ); - myFunctorPtr = myNumericalFunctorPtr; -} - -FunctorType MaxElementLength3D_i::GetFunctorType() -{ - return SMESH::FT_MaxElementLength3D; -} - -/* - Class : Length_i - Description : Functor for calculating length off edge -*/ -Length_i::Length_i() -{ - myNumericalFunctorPtr.reset( new Controls::Length() ); - myFunctorPtr = myNumericalFunctorPtr; -} - -FunctorType Length_i::GetFunctorType() -{ - return SMESH::FT_Length; -} - -/* - Class : Length2D_i - Description : Functor for calculating length of edge -*/ -Length2D_i::Length2D_i() -{ - myNumericalFunctorPtr.reset( new Controls::Length2D() ); - myFunctorPtr = myNumericalFunctorPtr; -} - -FunctorType Length2D_i::GetFunctorType() -{ - return SMESH::FT_Length2D; -} - -SMESH::Length2D::Values* Length2D_i::GetValues() -{ - SMESH::Controls::Length2D::TValues aValues; - (dynamic_cast(myFunctorPtr.get()))->GetValues( aValues ); - - long i = 0, iEnd = aValues.size(); - - SMESH::Length2D::Values_var aResult = new SMESH::Length2D::Values(iEnd); - aResult->length(iEnd); - - SMESH::Controls::Length2D::TValues::const_iterator anIter; - for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ ) - { - const SMESH::Controls::Length2D::Value& aVal = *anIter; - SMESH::Length2D::Value &aValue = aResult[ i ]; - - aValue.myLength = aVal.myLength; - aValue.myPnt1 = aVal.myPntId[ 0 ]; - aValue.myPnt2 = aVal.myPntId[ 1 ]; - } - - return aResult._retn(); -} - - -/* - Class : Length3D_i - Description : Functor for calculating length of edge -*/ -Length3D_i::Length3D_i() -{ - myNumericalFunctorPtr.reset( new Controls::Length3D() ); - myFunctorPtr = myNumericalFunctorPtr; -} - -FunctorType Length3D_i::GetFunctorType() -{ - return SMESH::FT_Length3D; -} - -// SMESH::Length3D::Values* Length3D_i::GetValues() -// { -// SMESH::Controls::Length3D::TValues aValues; -// (dynamic_cast(myFunctorPtr.get()))->GetValues( aValues ); - -// long i = 0, iEnd = aValues.size(); - -// SMESH::Length3D::Values_var aResult = new SMESH::Length3D::Values(iEnd); -// aResult->length(iEnd); - -// SMESH::Controls::Length3D::TValues::const_iterator anIter; -// for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ ) -// { -// const SMESH::Controls::Length3D::Value& aVal = *anIter; -// SMESH::Length3D::Value &aValue = aResult[ i ]; - -// aValue.myLength = aVal.myLength; -// aValue.myPnt1 = aVal.myPntId[ 0 ]; -// aValue.myPnt2 = aVal.myPntId[ 1 ]; -// } - -// return aResult._retn(); -// } - -/* - Class : Deflection2D_i - Description : Functor for calculating distance between a face and geometry -*/ -Deflection2D_i::Deflection2D_i() -{ - myNumericalFunctorPtr.reset( new Controls::Deflection2D() ); - myFunctorPtr = myNumericalFunctorPtr; -} - -FunctorType Deflection2D_i::GetFunctorType() -{ - return SMESH::FT_Deflection2D; -} - -/* - Class : MultiConnection_i - Description : Functor for calculating number of faces conneted to the edge -*/ -MultiConnection_i::MultiConnection_i() -{ - myNumericalFunctorPtr.reset( new Controls::MultiConnection() ); - myFunctorPtr = myNumericalFunctorPtr; -} - -FunctorType MultiConnection_i::GetFunctorType() -{ - return SMESH::FT_MultiConnection; -} - -/* - Class : BallDiameter_i - Description : Functor returning diameter of a ball element -*/ -BallDiameter_i::BallDiameter_i() -{ - myNumericalFunctorPtr.reset( new Controls::BallDiameter() ); - myFunctorPtr = myNumericalFunctorPtr; -} - -FunctorType BallDiameter_i::GetFunctorType() -{ - return SMESH::FT_BallDiameter; -} - -/* - Class : NodeConnectivityNumber_i - Description : Functor returning diameter of a ball element -*/ -NodeConnectivityNumber_i::NodeConnectivityNumber_i() -{ - myNumericalFunctorPtr.reset( new Controls::NodeConnectivityNumber() ); - myFunctorPtr = myNumericalFunctorPtr; -} - -FunctorType NodeConnectivityNumber_i::GetFunctorType() -{ - return SMESH::FT_NodeConnectivityNumber; -} - -/* - Class : MultiConnection2D_i - Description : Functor for calculating number of faces conneted to the edge -*/ -MultiConnection2D_i::MultiConnection2D_i() -{ - myNumericalFunctorPtr.reset( new Controls::MultiConnection2D() ); - myFunctorPtr = myNumericalFunctorPtr; -} - -FunctorType MultiConnection2D_i::GetFunctorType() -{ - return SMESH::FT_MultiConnection2D; -} - -SMESH::MultiConnection2D::Values* MultiConnection2D_i::GetValues() -{ - SMESH::Controls::MultiConnection2D::MValues aValues; - (dynamic_cast(myFunctorPtr.get()))->GetValues( aValues ); - - long i = 0, iEnd = aValues.size(); - - SMESH::MultiConnection2D::Values_var aResult = new SMESH::MultiConnection2D::Values(iEnd); - aResult->length(iEnd); - - SMESH::Controls::MultiConnection2D::MValues::const_iterator anIter; - for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ ) - { - const SMESH::Controls::MultiConnection2D::Value& aVal = (*anIter).first; - SMESH::MultiConnection2D::Value &aValue = aResult[ i ]; - - aValue.myPnt1 = aVal.myPntId[ 0 ]; - aValue.myPnt2 = aVal.myPntId[ 1 ]; - aValue.myNbConnects = (*anIter).second; - } - - return aResult._retn(); -} - -/* - PREDICATES -*/ - - -/* - Class : Predicate_i - Description : Base class for all predicates -*/ -CORBA::Boolean Predicate_i::IsSatisfy( CORBA::Long theId ) -{ - return myPredicatePtr->IsSatisfy( theId ); -} - -CORBA::Long Predicate_i::NbSatisfying( SMESH::SMESH_IDSource_ptr obj ) -{ - SMESH::SMESH_Mesh_var meshVar = obj->GetMesh(); - const SMDS_Mesh* meshDS = MeshPtr2SMDSMesh( meshVar ); - if ( !meshDS ) - return 0; - myPredicatePtr->SetMesh( meshDS ); - - SMDSAbs_ElementType elemType = SMDSAbs_ElementType( GetElementType() ); - - int nb = 0; - SMDS_ElemIteratorPtr elemIt = - SMESH::DownCast( meshVar )->GetElements( obj, GetElementType() ); - if ( elemIt ) - while ( elemIt->more() ) - { - const SMDS_MeshElement* e = elemIt->next(); - if ( e && e->GetType() == elemType ) - nb += myPredicatePtr->IsSatisfy( e->GetID() ); - } - return nb; -} - -Controls::PredicatePtr Predicate_i::GetPredicate() -{ - return myPredicatePtr; -} - -/* - Class : BadOrientedVolume_i - Description : Verify whether a mesh volume is incorrectly oriented from - the point of view of MED convention -*/ -BadOrientedVolume_i::BadOrientedVolume_i() -{ - Controls::PredicatePtr control( new Controls::BadOrientedVolume() ); - myFunctorPtr = myPredicatePtr = control; -} - -FunctorType BadOrientedVolume_i::GetFunctorType() -{ - return SMESH::FT_BadOrientedVolume; -} - -/* - Class : BareBorderVolume_i - Description : Verify whether a mesh volume has a free facet without a face on it -*/ -BareBorderVolume_i::BareBorderVolume_i() -{ - Controls::PredicatePtr control( new Controls::BareBorderVolume() ); - myFunctorPtr = myPredicatePtr = control; -} - -FunctorType BareBorderVolume_i::GetFunctorType() -{ - return SMESH::FT_BareBorderVolume; -} - -/* - Class : BareBorderFace_i - Description : Verify whether a mesh face has a free border without an edge on it -*/ -BareBorderFace_i::BareBorderFace_i() -{ - Controls::PredicatePtr control( new Controls::BareBorderFace() ); - myFunctorPtr = myPredicatePtr = control; -} - -FunctorType BareBorderFace_i::GetFunctorType() -{ - return SMESH::FT_BareBorderFace; -} - -/* - Class : OverConstrainedVolume_i - Description : Verify whether a mesh volume has only one facet shared with other volumes -*/ -OverConstrainedVolume_i::OverConstrainedVolume_i() -{ - Controls::PredicatePtr control( new Controls::OverConstrainedVolume() ); - myFunctorPtr = myPredicatePtr = control; -} - -FunctorType OverConstrainedVolume_i::GetFunctorType() -{ - return SMESH::FT_OverConstrainedVolume; -} - -/* - Class : OverConstrainedFace_i - Description : Verify whether a mesh face has only one border shared with other faces -*/ -OverConstrainedFace_i::OverConstrainedFace_i() -{ - Controls::PredicatePtr control( new Controls::OverConstrainedFace() ); - myFunctorPtr = myPredicatePtr = control; -} - -FunctorType OverConstrainedFace_i::GetFunctorType() -{ - return SMESH::FT_OverConstrainedFace; -} - -/* - Class : BelongToMeshGroup_i - Description : Verify whether a mesh element is included into a mesh group -*/ -BelongToMeshGroup_i::BelongToMeshGroup_i() -{ - myBelongToMeshGroup = Controls::BelongToMeshGroupPtr( new Controls::BelongToMeshGroup() ); - myFunctorPtr = myPredicatePtr = myBelongToMeshGroup; -} - -BelongToMeshGroup_i::~BelongToMeshGroup_i() -{ - SetGroup( SMESH::SMESH_GroupBase::_nil() ); -} - -void BelongToMeshGroup_i::SetGroup( SMESH::SMESH_GroupBase_ptr theGroup ) -{ - if ( myGroup->_is_equivalent( theGroup )) - return; - - if ( ! myGroup->_is_nil() ) - myGroup->UnRegister(); - - myGroup = SMESH_GroupBase::_duplicate( theGroup ); - - myBelongToMeshGroup->SetGroup( 0 ); - if ( SMESH_GroupBase_i* gr_i = SMESH::DownCast< SMESH_GroupBase_i* >( myGroup )) - { - myBelongToMeshGroup->SetGroup( gr_i->GetGroupDS() ); - myGroup->Register(); - } -} - -void BelongToMeshGroup_i::SetGroupID( const char* theID ) // IOR or StoreName -{ - myID = theID; - if ( strncmp( "IOR:", myID.c_str(), 4 ) == 0 ) // transient mode, no GUI - { - CORBA::Object_var obj = SMESH_Gen_i::GetORB()->string_to_object( myID.c_str() ); - SetGroup( SMESH::SMESH_GroupBase::_narrow( obj )); - } - else if ( strncmp( "0:", myID.c_str(), 2 ) == 0 ) // transient mode + GUI - { - SALOMEDS::SObject_wrap aSObj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( myID.c_str() ); - if ( !aSObj->_is_nil() ) { - CORBA::Object_var obj = aSObj->GetObject(); - SetGroup( SMESH::SMESH_GroupBase::_narrow( obj )); - } - } - else if ( !myID.empty() ) // persistent mode - { - myBelongToMeshGroup->SetStoreName( myID ); - } -} - -std::string BelongToMeshGroup_i::GetGroupID() -{ - if ( myGroup->_is_nil() ) - SMESH::SMESH_GroupBase_var( GetGroup() ); // decref the returned pointer - - if ( !myGroup->_is_nil() ) - myID = SMESH_Gen_i::GetORB()->object_to_string( myGroup ); - - return myID; -} - -SMESH::SMESH_GroupBase_ptr BelongToMeshGroup_i::GetGroup() -{ - if ( myGroup->_is_nil() && myBelongToMeshGroup->GetGroup() ) - { - // search for a group in a current study - SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); - if ( StudyContext* sc = aSMESHGen->GetStudyContext() ) - { - int id = 1; - std::string ior; - while (true) - { - ior = sc->getIORbyId( id++ ); - if ( ior.empty() ) break; - CORBA::Object_var obj = aSMESHGen->GetORB()->string_to_object( ior.c_str() ); - if ( SMESH_GroupBase_i* g_i = SMESH::DownCast( obj )) - if ( g_i->GetGroupDS() == myBelongToMeshGroup->GetGroup() ) - { - SetGroup( g_i->_this() ); - break; - } - } - } - } - return SMESH::SMESH_GroupBase::_duplicate( myGroup ); -} - -FunctorType BelongToMeshGroup_i::GetFunctorType() -{ - return SMESH::FT_BelongToMeshGroup; -} - -/* - Class : BelongToGeom_i - Description : Predicate for selection on geometrical support -*/ -BelongToGeom_i::BelongToGeom_i() -{ - myBelongToGeomPtr.reset( new Controls::BelongToGeom() ); - myFunctorPtr = myPredicatePtr = myBelongToGeomPtr; - myShapeName = 0; - myShapeID = 0; -} - -BelongToGeom_i::~BelongToGeom_i() -{ - CORBA::string_free( myShapeName ); - CORBA::string_free( myShapeID ); -} - -void BelongToGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom ) -{ - if ( theGeom->_is_nil() ) - return; - TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom ); - myBelongToGeomPtr->SetGeom( aLocShape ); - TPythonDump()<SetGeom( theShape ); -} - -void BelongToGeom_i::SetElementType(ElementType theType) -{ - myBelongToGeomPtr->SetType(SMDSAbs_ElementType(theType)); - TPythonDump()<SetGeom( getShapeByName( myShapeName ) ); - TPythonDump()<SetGeom( S ); -} - -char* BelongToGeom_i::GetShapeName() -{ - return CORBA::string_dup( myShapeName ); -} - -char* BelongToGeom_i::GetShapeID() -{ - return CORBA::string_dup( myShapeID ); -} - -void BelongToGeom_i::SetTolerance( CORBA::Double theToler ) -{ - myBelongToGeomPtr->SetTolerance( theToler ); - TPythonDump()<GetTolerance(); -} - -/* - Class : BelongToSurface_i - Description : Predicate for selection on geometrical support -*/ -BelongToSurface_i::BelongToSurface_i( const Handle(Standard_Type)& theSurfaceType ) -{ - myElementsOnSurfacePtr.reset( new Controls::ElementsOnSurface() ); - myFunctorPtr = myPredicatePtr = myElementsOnSurfacePtr; - myShapeName = 0; - myShapeID = 0; - mySurfaceType = theSurfaceType; -} - -BelongToSurface_i::~BelongToSurface_i() -{ - CORBA::string_free( myShapeName ); - CORBA::string_free( myShapeID ); -} - -void BelongToSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType ) -{ - if ( theGeom->_is_nil() ) - return; - TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom ); - - if ( aLocShape.ShapeType() == TopAbs_FACE ) - { - Handle(Geom_Surface) aSurf = BRep_Tool::Surface( TopoDS::Face( aLocShape ) ); - if ( !aSurf.IsNull() && aSurf->DynamicType() == mySurfaceType ) - { - myElementsOnSurfacePtr->SetSurface( aLocShape, (SMDSAbs_ElementType)theType ); - return; - } - } - - myElementsOnSurfacePtr->SetSurface( TopoDS_Shape(), (SMDSAbs_ElementType)theType ); -} - -void BelongToSurface_i::SetShapeName( const char* theName, ElementType theType ) -{ - CORBA::string_free( myShapeName ); - myShapeName = CORBA::string_dup( theName ); - myElementsOnSurfacePtr->SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType ); - TPythonDump()<SetSurface( S, (SMDSAbs_ElementType)theType ); -} - -char* BelongToSurface_i::GetShapeName() -{ - return CORBA::string_dup( myShapeName ); -} - -char* BelongToSurface_i::GetShapeID() -{ - return CORBA::string_dup( myShapeID ); -} - -void BelongToSurface_i::SetTolerance( CORBA::Double theToler ) -{ - myElementsOnSurfacePtr->SetTolerance( theToler ); - TPythonDump()<GetTolerance(); -} - -void BelongToSurface_i::SetUseBoundaries( CORBA::Boolean theUseBndRestrictions ) -{ - myElementsOnSurfacePtr->SetUseBoundaries( theUseBndRestrictions ); - TPythonDump()<GetUseBoundaries(); -} - - -/* - Class : BelongToPlane_i - Description : Verify whether mesh element lie in pointed Geom planar object -*/ - -BelongToPlane_i::BelongToPlane_i() -: BelongToSurface_i( STANDARD_TYPE( Geom_Plane ) ) -{ -} - -void BelongToPlane_i::SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType ) -{ - BelongToSurface_i::SetSurface( theGeom, theType ); - TPythonDump()<_is_nil() ) - return; - TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom ); - if ( !aLocShape.IsNull() && aLocShape.ShapeType() != TopAbs_FACE ) - aLocShape.Nullify(); - - BelongToSurface_i::myElementsOnSurfacePtr->SetSurface( aLocShape, (SMDSAbs_ElementType)theType ); - TPythonDump()<_is_nil() ) - return; - TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom ); - myLyingOnGeomPtr->SetGeom( aLocShape ); - TPythonDump()<SetGeom( theShape ); -} - -void LyingOnGeom_i::SetElementType(ElementType theType){ - myLyingOnGeomPtr->SetType(SMDSAbs_ElementType(theType)); - TPythonDump()<SetGeom( getShapeByName( myShapeName ) ); - TPythonDump()<SetGeom( S ); -} - -char* LyingOnGeom_i::GetShapeName() -{ - return CORBA::string_dup( myShapeName ); -} - -char* LyingOnGeom_i::GetShapeID() -{ - return CORBA::string_dup( myShapeID ); -} - -void LyingOnGeom_i::SetTolerance( CORBA::Double theToler ) -{ - myLyingOnGeomPtr->SetTolerance( theToler ); - TPythonDump()<GetTolerance(); -} - -/* - Class : FreeBorders_i - Description : Predicate for free borders -*/ -FreeBorders_i::FreeBorders_i() -{ - myPredicatePtr.reset(new Controls::FreeBorders()); - myFunctorPtr = myPredicatePtr; -} - -FunctorType FreeBorders_i::GetFunctorType() -{ - return SMESH::FT_FreeBorders; -} - -/* - Class : FreeEdges_i - Description : Predicate for free borders -*/ -FreeEdges_i::FreeEdges_i() -: myFreeEdgesPtr( new Controls::FreeEdges() ) -{ - myFunctorPtr = myPredicatePtr = myFreeEdgesPtr; -} - -SMESH::FreeEdges::Borders* FreeEdges_i::GetBorders() -{ - SMESH::Controls::FreeEdges::TBorders aBorders; - myFreeEdgesPtr->GetBoreders( aBorders ); - - long i = 0, iEnd = aBorders.size(); - - SMESH::FreeEdges::Borders_var aResult = new SMESH::FreeEdges::Borders; - aResult->length(iEnd); - - SMESH::Controls::FreeEdges::TBorders::const_iterator anIter; - for ( anIter = aBorders.begin() ; anIter != aBorders.end(); anIter++, i++ ) - { - const SMESH::Controls::FreeEdges::Border& aBord = *anIter; - SMESH::FreeEdges::Border &aBorder = aResult[ i ]; - - aBorder.myElemId = aBord.myElemId; - aBorder.myPnt1 = aBord.myPntId[ 0 ]; - aBorder.myPnt2 = aBord.myPntId[ 1 ]; - } - return aResult._retn(); -} - -FunctorType FreeEdges_i::GetFunctorType() -{ - return SMESH::FT_FreeEdges; -} - -/* - Class : FreeFaces_i - Description : Predicate for free faces -*/ -FreeFaces_i::FreeFaces_i() -{ - myPredicatePtr.reset(new Controls::FreeFaces()); - myFunctorPtr = myPredicatePtr; -} - -FunctorType FreeFaces_i::GetFunctorType() -{ - return SMESH::FT_FreeFaces; -} - -/* - Class : FreeNodes_i - Description : Predicate for free nodes -*/ -FreeNodes_i::FreeNodes_i() -{ - myPredicatePtr.reset(new Controls::FreeNodes()); - myFunctorPtr = myPredicatePtr; -} - -FunctorType FreeNodes_i::GetFunctorType() -{ - return SMESH::FT_FreeNodes; -} - -/* - Class : EqualNodes_i - Description : Predicate for Equal nodes -*/ -EqualNodes_i::EqualNodes_i() -{ - myCoincidentNodesPtr.reset(new Controls::CoincidentNodes()); - myFunctorPtr = myPredicatePtr = myCoincidentNodesPtr; -} - -FunctorType EqualNodes_i::GetFunctorType() -{ - return SMESH::FT_EqualNodes; -} - -void EqualNodes_i::SetTolerance( double tol ) -{ - myCoincidentNodesPtr->SetTolerance( tol ); -} - -double EqualNodes_i::GetTolerance() -{ - return myCoincidentNodesPtr->GetTolerance(); -} - -/* - Class : EqualEdges_i - Description : Predicate for Equal Edges -*/ -EqualEdges_i::EqualEdges_i() -{ - myPredicatePtr.reset(new Controls::CoincidentElements1D()); - myFunctorPtr = myPredicatePtr; -} - -FunctorType EqualEdges_i::GetFunctorType() -{ - return SMESH::FT_EqualEdges; -} - -/* - Class : EqualFaces_i - Description : Predicate for Equal Faces -*/ -EqualFaces_i::EqualFaces_i() -{ - myPredicatePtr.reset(new Controls::CoincidentElements2D()); - myFunctorPtr = myPredicatePtr; -} - -FunctorType EqualFaces_i::GetFunctorType() -{ - return SMESH::FT_EqualFaces; -} - -/* - Class : EqualVolumes_i - Description : Predicate for Equal Volumes -*/ -EqualVolumes_i::EqualVolumes_i() -{ - myPredicatePtr.reset(new Controls::CoincidentElements3D()); - myFunctorPtr = myPredicatePtr; -} - -FunctorType EqualVolumes_i::GetFunctorType() -{ - return SMESH::FT_EqualVolumes; -} - - -/* - Class : RangeOfIds_i - Description : Predicate for Range of Ids. - Range may be specified with two ways. - 1. Using AddToRange method - 2. With SetRangeStr method. Parameter of this method is a string - like as "1,2,3,50-60,63,67,70-" -*/ - -RangeOfIds_i::RangeOfIds_i() -{ - myRangeOfIdsPtr.reset( new Controls::RangeOfIds() ); - myFunctorPtr = myPredicatePtr = myRangeOfIdsPtr; -} - -void RangeOfIds_i::SetRange( const SMESH::smIdType_array& theIds ) -{ - SMESH::smIdType iEnd = theIds.length(); - for ( SMESH::smIdType i = 0; i < iEnd; i++ ) - myRangeOfIdsPtr->AddToRange( theIds[ i ] ); - TPythonDump()<SetRangeStr( - TCollection_AsciiString( (Standard_CString)theRange ) ); -} - -char* RangeOfIds_i::GetRangeStr() -{ - TCollection_AsciiString aStr; - myRangeOfIdsPtr->GetRangeStr( aStr ); - return CORBA::string_dup( aStr.ToCString() ); -} - -void RangeOfIds_i::SetElementType( ElementType theType ) -{ - myRangeOfIdsPtr->SetType( SMDSAbs_ElementType( theType ) ); - TPythonDump()<SetType(SMDSAbs_ElementType(theType)); - TPythonDump()<SetColorStr( - TCollection_AsciiString( (Standard_CString)theColor ) ); - TPythonDump()<GetColorStr( aStr ); - return CORBA::string_dup( aStr.ToCString() ); -} - -void GroupColor_i::SetElementType(ElementType theType) -{ - myGroupColorPtr->SetType(SMDSAbs_ElementType(theType)); - TPythonDump()<SetType(SMDSAbs_ElementType(theType)); - TPythonDump()<SetGeomType(SMDSAbs_GeometryType(theType)); - TPythonDump()<GetGeomType(); -} - -FunctorType ElemGeomType_i::GetFunctorType() -{ - return SMESH::FT_ElemGeomType; -} - -/* - Class : ElemEntityType_i - Description : Predicate check is element has indicated entity type -*/ -ElemEntityType_i::ElemEntityType_i() -{ - myElemEntityTypePtr.reset(new Controls::ElemEntityType()); - myFunctorPtr = myPredicatePtr = myElemEntityTypePtr; -} - -void ElemEntityType_i::SetElementType(ElementType theType) -{ - myElemEntityTypePtr->SetType(SMDSAbs_ElementType(theType)); - TPythonDump()<SetElemEntityType(SMDSAbs_EntityType (theEntityType)); - TPythonDump()<GetElemEntityType(); -} - -FunctorType ElemEntityType_i::GetFunctorType() -{ - return SMESH::FT_EntityType; -} - -/* - Class : CoplanarFaces_i - Description : Returns true if a mesh face is a coplanar neighbour to a given one -*/ -CoplanarFaces_i::CoplanarFaces_i() -{ - myCoplanarFacesPtr.reset(new Controls::CoplanarFaces()); - myFunctorPtr = myPredicatePtr = myCoplanarFacesPtr; -} - -void CoplanarFaces_i::SetFace ( CORBA::Long theFaceID ) -{ - myCoplanarFacesPtr->SetFace(theFaceID); - TPythonDump()<SetTolerance(theToler); - TPythonDump()<GetFace(); -} - -char* CoplanarFaces_i::GetFaceAsString () const -{ - TCollection_AsciiString str(Standard_Integer(myCoplanarFacesPtr->GetFace())); - return CORBA::string_dup( str.ToCString() ); -} - -CORBA::Double CoplanarFaces_i::GetTolerance() const -{ - return myCoplanarFacesPtr->GetTolerance(); -} - -FunctorType CoplanarFaces_i::GetFunctorType() -{ - return SMESH::FT_CoplanarFaces; -} - -/* - * Class : ConnectedElements_i - * Description : Returns true if an element is connected via other elements to the element - * located at a given point. - */ -ConnectedElements_i::ConnectedElements_i() -{ - myConnectedElementsPtr.reset(new Controls::ConnectedElements()); - myFunctorPtr = myPredicatePtr = myConnectedElementsPtr; -} - -FunctorType ConnectedElements_i::GetFunctorType() -{ - return FT_ConnectedElements; -} - -void ConnectedElements_i::SetElementType( ElementType theType ) -{ - myConnectedElementsPtr->SetType( SMDSAbs_ElementType( theType )); - TPythonDump() << this << ".SetElementType( " << theType << " )"; -} - -void ConnectedElements_i::SetPoint( CORBA::Double x, CORBA::Double y, CORBA::Double z ) -{ - myConnectedElementsPtr->SetPoint( x,y,z ); - myVertexID.clear(); - TPythonDump() << this << ".SetPoint( " << x << ", " << y << ", " << z << " )"; -} - -void ConnectedElements_i::SetVertex( GEOM::GEOM_Object_ptr vertex ) -{ - TopoDS_Shape shape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( vertex ); - if ( shape.IsNull() ) - THROW_SALOME_CORBA_EXCEPTION( "ConnectedElements_i::SetVertex(): NULL Vertex", - SALOME::BAD_PARAM ); - - TopExp_Explorer v( shape, TopAbs_VERTEX ); - if ( !v.More() ) - THROW_SALOME_CORBA_EXCEPTION( "ConnectedElements_i::SetVertex(): empty vertex", - SALOME::BAD_PARAM ); - - gp_Pnt p = BRep_Tool::Pnt( TopoDS::Vertex( v.Current() )); - myConnectedElementsPtr->SetPoint( p.X(), p.Y(), p.Z() ); - // - CORBA::String_var id = vertex->GetStudyEntry(); - myVertexID = id.in(); - - TPythonDump() << this << ".SetVertex( " << vertex << " )"; -} - -void ConnectedElements_i::SetNode ( SMESH::smIdType nodeID ) -{ - if ( nodeID < 1 ) - THROW_SALOME_CORBA_EXCEPTION( "ConnectedElements_i::SetNode(): nodeID must be > 0", - SALOME::BAD_PARAM ); - - myConnectedElementsPtr->SetNode( nodeID ); - myVertexID.clear(); - TPythonDump() << this << ".SetNode( " << nodeID << " )"; -} - -/*! - * \brief This is a comfort method for Filter dialog - */ -void ConnectedElements_i::SetThreshold ( const char* threshold, - SMESH::ConnectedElements::ThresholdType type ) -{ - if ( !threshold ) - THROW_SALOME_CORBA_EXCEPTION( "ConnectedElements_i::SetThreshold(): NULL threshold", - SALOME::BAD_PARAM ); - switch ( type ) - { - case SMESH::ConnectedElements::POINT: // read 3 node coordinates /////////////////// - { - std::vector< double > xyz; - char* endptr; - do - { - // skip a separator - while ( *threshold && - *threshold != '+' && - *threshold != '-' && - !isdigit( *threshold )) - ++threshold; - if ( !*threshold ) - break; - // read a coordinate - xyz.push_back( strtod( threshold, &endptr )); - if ( threshold == endptr ) - { - xyz.resize( xyz.size() - 1 ); - break; - } - threshold = endptr; - } - while ( xyz.size() < 3 ); - - if ( xyz.size() < 3 ) - THROW_SALOME_CORBA_EXCEPTION - ( "ConnectedElements_i::SetThreshold(): invalid point coordinates", SALOME::BAD_PARAM ); - - SetPoint( xyz[0], xyz[1], xyz[2] ); - break; - } - case SMESH::ConnectedElements::VERTEX: // get a VERTEX by its entry ///////////////// - { - SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( threshold ); - if ( sobj->_is_nil() ) - THROW_SALOME_CORBA_EXCEPTION - ( "ConnectedElements_i::SetThreshold(): invalid vertex study entry", SALOME::BAD_PARAM ); - CORBA::Object_var obj = sobj->GetObject(); - GEOM::GEOM_Object_var vertex = GEOM::GEOM_Object::_narrow( obj ); - if ( vertex->_is_nil() ) - THROW_SALOME_CORBA_EXCEPTION - ( "ConnectedElements_i::SetThreshold(): no GEOM_Object in SObject", SALOME::BAD_PARAM ); - SetVertex( vertex ); - break; - } - case SMESH::ConnectedElements::NODE: // read a node ID //////////////////////////// - { - char* endptr; - int id = strtol( threshold, &endptr, 10 ); - if ( threshold == endptr ) - THROW_SALOME_CORBA_EXCEPTION - ( "ConnectedElements_i::SetThreshold(): invalid node ID", SALOME::BAD_PARAM ); - SetNode( id ); - break; - } - default: - THROW_SALOME_CORBA_EXCEPTION - ( "ConnectedElements_i::SetThreshold(): invalid ThresholdType", SALOME::BAD_PARAM ); - } -} - -char* ConnectedElements_i::GetThreshold ( SMESH::ConnectedElements::ThresholdType& type ) -{ - std::string threshold; - if ( !myVertexID.empty() ) - { - threshold = myVertexID; - type = SMESH::ConnectedElements::VERTEX; - } - else - { - std::vector xyz = myConnectedElementsPtr->GetPoint(); - if ( xyz.size() == 3 ) - { - threshold = SMESH_Comment( xyz[0] ) << "; " << xyz[1] << "; " << xyz[2]; - type = SMESH::ConnectedElements::POINT; - } - else - { - threshold = SMESH_Comment( myConnectedElementsPtr->GetNode() ); - type = SMESH::ConnectedElements::NODE; - } - } - return CORBA::string_dup( threshold.c_str() ); -} - -/* - Class : Comparator_i - Description : Base class for comparators -*/ -Comparator_i::Comparator_i(): - myNumericalFunctor( NULL ) -{} - -Comparator_i::~Comparator_i() -{ - if ( myNumericalFunctor ) - myNumericalFunctor->UnRegister(); -} - -void Comparator_i::SetMargin( CORBA::Double theValue ) -{ - myComparatorPtr->SetMargin( theValue ); - TPythonDump()<GetMargin(); -} - -void Comparator_i::SetNumFunctor( NumericalFunctor_ptr theFunct ) -{ - if ( myNumericalFunctor ) - myNumericalFunctor->UnRegister(); - - myNumericalFunctor = DownCast(theFunct); - - if ( myNumericalFunctor ) - { - myComparatorPtr->SetNumFunctor( myNumericalFunctor->GetNumericalFunctor() ); - myNumericalFunctor->Register(); - TPythonDump()<" -*/ -MoreThan_i::MoreThan_i() -{ - myComparatorPtr.reset( new Controls::MoreThan() ); - myFunctorPtr = myPredicatePtr = myComparatorPtr; -} - -FunctorType MoreThan_i::GetFunctorType() -{ - return SMESH::FT_MoreThan; -} - - -/* - Class : EqualTo_i - Description : Comparator "=" -*/ -EqualTo_i::EqualTo_i() -: myEqualToPtr( new Controls::EqualTo() ) -{ - myFunctorPtr = myPredicatePtr = myComparatorPtr = myEqualToPtr; -} - -void EqualTo_i::SetTolerance( CORBA::Double theToler ) -{ - myEqualToPtr->SetTolerance( theToler ); - TPythonDump()<GetTolerance(); -} - -FunctorType EqualTo_i::GetFunctorType() -{ - return SMESH::FT_EqualTo; -} - -/* - Class : LogicalNOT_i - Description : Logical NOT predicate -*/ -LogicalNOT_i::LogicalNOT_i(): - myLogicalNOTPtr( new Controls::LogicalNOT() ), - myPredicate( NULL ) -{ - myFunctorPtr = myPredicatePtr = myLogicalNOTPtr; -} - -LogicalNOT_i::~LogicalNOT_i() -{ - if ( myPredicate ) - myPredicate->UnRegister(); -} - -void LogicalNOT_i::SetPredicate( Predicate_ptr thePredicate ) -{ - if ( myPredicate ) - myPredicate->UnRegister(); - - myPredicate = SMESH::GetPredicate(thePredicate); - - if ( myPredicate ){ - myLogicalNOTPtr->SetPredicate(myPredicate->GetPredicate()); - myPredicate->Register(); - TPythonDump()<UnRegister(); - - if ( myPredicate2 ) - myPredicate2->UnRegister(); -} - -void LogicalBinary_i::SetMesh( SMESH_Mesh_ptr theMesh ) -{ - if ( myPredicate1 ) - myPredicate1->SetMesh( theMesh ); - - if ( myPredicate2 ) - myPredicate2->SetMesh( theMesh ); -} - -void LogicalBinary_i::SetPredicate1( Predicate_ptr thePredicate ) -{ - if ( myPredicate1 ) - myPredicate1->UnRegister(); - - myPredicate1 = SMESH::GetPredicate(thePredicate); - - if ( myPredicate1 ){ - myLogicalBinaryPtr->SetPredicate1(myPredicate1->GetPredicate()); - myPredicate1->Register(); - TPythonDump()<UnRegister(); - - myPredicate2 = SMESH::GetPredicate(thePredicate); - - if ( myPredicate2 ){ - myLogicalBinaryPtr->SetPredicate2(myPredicate2->GetPredicate()); - myPredicate2->Register(); - TPythonDump()<activate_object( this ); -} - - -FilterManager_i::~FilterManager_i() -{ - //TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<_this(); - TPythonDump()<UnRegister(); - - if(!CORBA::is_nil(myMesh)) - myMesh->UnRegister(); - - myPredicate = 0; - FindBaseObjects(); -} - -//======================================================================= -// name : Filter_i::SetPredicate -// Purpose : Set predicate -//======================================================================= -void Filter_i::SetPredicate( Predicate_ptr thePredicate ) -{ - if ( myPredicate ) - myPredicate->UnRegister(); - - myPredicate = SMESH::GetPredicate(thePredicate); - - if ( myPredicate ) +namespace SMESH { + /* + Class : Functor_i + Description : An abstract class for all functors + */ + Functor_i::Functor_i(): + SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() ) { - myFilter.SetPredicate( myPredicate->GetPredicate() ); - myPredicate->Register(); - if ( const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh)) - myPredicate->GetPredicate()->SetMesh( aMesh ); - TPythonDump()<activate_object( this ); } - NotifyerAndWaiter::Modified(); -} -//======================================================================= -// name : Filter_i::GetElementType -// Purpose : Get entity type -//======================================================================= -SMESH::ElementType Filter_i::GetElementType() -{ - return myPredicate != 0 ? myPredicate->GetElementType() : SMESH::ALL; -} - -//======================================================================= -// name : Filter_i::SetMesh -// Purpose : Set mesh -//======================================================================= -void -Filter_i:: -SetMesh( SMESH_Mesh_ptr theMesh ) -{ - if(!CORBA::is_nil(theMesh)) - theMesh->Register(); - - if(!CORBA::is_nil(myMesh)) - myMesh->UnRegister(); - - myMesh = SMESH_Mesh::_duplicate( theMesh ); - TPythonDump()<GetPredicate()->SetMesh( aMesh ); -} - -SMESH::smIdType_array* -Filter_i:: -GetIDs() -{ - return GetElementsId(myMesh); -} - -//======================================================================= -// name : Filter_i::GetElementsId -// Purpose : Get ids of entities -//======================================================================= -void -Filter_i:: -GetElementsId( Predicate_i* thePredicate, - const SMDS_Mesh* theMesh, - Controls::Filter::TIdSequence& theSequence ) -{ - if (thePredicate) - Controls::Filter::GetElementsId(theMesh,thePredicate->GetPredicate(),theSequence); -} - -void -Filter_i:: -GetElementsId( Predicate_i* thePredicate, - SMESH_Mesh_ptr theMesh, - Controls::Filter::TIdSequence& theSequence ) -{ - if (thePredicate) - if(const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh)) - Controls::Filter::GetElementsId(aMesh,thePredicate->GetPredicate(),theSequence); -} - -SMESH::smIdType_array* -Filter_i:: -GetElementsId( SMESH_Mesh_ptr theMesh ) -{ - SMESH::smIdType_array_var anArray = new SMESH::smIdType_array; - if(!CORBA::is_nil(theMesh) && myPredicate){ - theMesh->Load(); - Controls::Filter::TIdSequence aSequence; - GetElementsId(myPredicate,theMesh,aSequence); - long i = 0, iEnd = aSequence.size(); - anArray->length( iEnd ); - for ( ; i < iEnd; i++ ) - anArray[ i ] = aSequence[i]; - } - return anArray._retn(); -} - -SMESH::smIdType_array* -Filter_i:: -GetElementsIdFromParts( const ListOfIDSources& theParts ) -{ - SMESH::smIdType_array_var array = new SMESH::smIdType_array; - if ( theParts.length() > 0 && myPredicate ) + Functor_i::~Functor_i() { - SMESH_Mesh_ptr mesh = theParts[0]->GetMesh(); - mesh->Load(); - const SMDS_Mesh* meshDS = MeshPtr2SMDSMesh( mesh ); - Controls::Filter::TIdSequence totalSequence; - for ( CORBA::ULong i = 0; i < theParts.length(); ++i ) + //TPythonDump()<SetMesh( MeshPtr2SMDSMesh( theMesh ) ); + TPythonDump()<GetType(); + } + + + /* + Class : NumericalFunctor_i + Description : Base class for numerical functors + */ + CORBA::Double NumericalFunctor_i::GetValue( SMESH::smIdType theId ) + { + return myNumericalFunctorPtr->GetValue( theId ); + } + + CORBA::Boolean NumericalFunctor_i::IsApplicable( SMESH::smIdType theElementId ) + { + return myNumericalFunctorPtr->IsApplicable( theElementId ); + } + + SMESH::Histogram* NumericalFunctor_i::GetHistogram(CORBA::Short nbIntervals, CORBA::Boolean isLogarithmic) + { + std::vector nbEvents; + std::vector funValues; + std::vector<::smIdType> elements; + myNumericalFunctorPtr->GetHistogram(nbIntervals, nbEvents, funValues ,elements, 0, isLogarithmic); + + SMESH::Histogram_var histogram = new SMESH::Histogram; + + nbIntervals = CORBA::Short( Min( int( nbEvents.size()), + int( funValues.size() - 1 ))); + if ( nbIntervals > 0 ) { - if ( SMESH::Filter_i* filter = SMESH::DownCast( theParts[i] )) - filter->SetMesh( mesh ); - SMDS_ElemIteratorPtr iter = SMESH_Mesh_i::GetElements( theParts[i], GetElementType() ); - if ( iter && meshDS ) + histogram->length( nbIntervals ); + for ( int i = 0; i < nbIntervals; ++i ) { - Controls::Filter::TIdSequence sequence; - Controls::Filter::GetElementsId( meshDS, myPredicate->GetPredicate(), sequence, iter ); - totalSequence.insert( totalSequence.end(), sequence.begin(), sequence.end() ); + HistogramRectangle& rect = histogram[i]; + rect.nbEvents = nbEvents[i]; + rect.min = funValues[i]; + rect.max = funValues[i+1]; } } - array->length( totalSequence.size() ); - for ( size_t i = 0; i < totalSequence.size(); ++i ) - array[ i ] = totalSequence[ i ]; + return histogram._retn(); } - return array._retn(); -} -//============================================================================= -/*! - * \brief Returns number of mesh elements per each \a EntityType - */ -//============================================================================= - -SMESH::smIdType_array* ::Filter_i::GetMeshInfo() -{ - SMESH::smIdType_array_var aRes = new SMESH::smIdType_array(); - aRes->length(SMESH::Entity_Last); - for (int i = 0; i < SMESH::Entity_Last; i++) - aRes[i] = 0; - - if ( !CORBA::is_nil(myMesh) && myPredicate ) + SMESH::Histogram* NumericalFunctor_i::GetLocalHistogram(CORBA::Short nbIntervals, + CORBA::Boolean isLogarithmic, + SMESH::SMESH_IDSource_ptr object) { - const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh); - SMDS_ElemIteratorPtr it = aMesh->elementsIterator( SMDSAbs_ElementType( GetElementType() )); - while ( it->more() ) + SMESH::Histogram_var histogram = new SMESH::Histogram; + + std::vector nbEvents; + std::vector funValues; + std::vector<::smIdType> elements; + + SMDS_ElemIteratorPtr elemIt; + if ( SMESH::DownCast< SMESH_GroupOnFilter_i* >( object ) || + SMESH::DownCast< SMESH::Filter_i* >( object )) { - const SMDS_MeshElement* anElem = it->next(); - if ( myPredicate->IsSatisfy( anElem->GetID() ) ) - aRes[ anElem->GetEntityType() ]++; + elemIt = SMESH_Mesh_i::GetElements( object, GetElementType() ); + if ( !elemIt ) return histogram._retn(); } - } - - return aRes._retn(); -} - -//============================================================================= -/*! - * \brief Returns number of mesh elements of each \a ElementType - */ -//============================================================================= - -SMESH::smIdType_array* ::Filter_i::GetNbElementsByType() -{ - SMESH::smIdType_array_var aRes = new SMESH::smIdType_array(); - aRes->length(SMESH::NB_ELEMENT_TYPES); - for (int i = 0; i < SMESH::NB_ELEMENT_TYPES; i++) - aRes[i] = 0; - - if ( !CORBA::is_nil(myMesh) && myPredicate ) { - const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh); - SMDS_ElemIteratorPtr it = aMesh->elementsIterator( SMDSAbs_ElementType( GetElementType() )); - SMESH::smIdType& nbElems = aRes[ GetElementType() ]; - while ( it->more() ) + else { - const SMDS_MeshElement* anElem = it->next(); - if ( myPredicate->IsSatisfy( anElem->GetID() ) ) - nbElems++; + SMESH::SMESH_Mesh_var mesh = object->GetMesh(); + SMESH::smIdType_array_var objNbElems = object->GetNbElementsByType(); + SMESH::smIdType_array_var meshNbElems = mesh-> GetNbElementsByType(); + if ( meshNbElems[ GetElementType() ] != + objNbElems [ GetElementType() ] ) + { + elements.reserve( objNbElems[ GetElementType() ]); + elemIt = SMESH_Mesh_i::GetElements( object, GetElementType() ); + } + } + if ( elemIt ) + { + while ( elemIt->more() ) + elements.push_back( elemIt->next()->GetID() ); + if ( elements.empty() ) return histogram._retn(); + } + + myNumericalFunctorPtr->GetHistogram(nbIntervals,nbEvents,funValues, elements, 0, isLogarithmic); + + nbIntervals = CORBA::Short( Min( int( nbEvents.size()), + int( funValues.size() - 1 ))); + if ( nbIntervals > 0 ) + { + histogram->length( nbIntervals ); + for ( int i = 0; i < nbIntervals; ++i ) + { + HistogramRectangle& rect = histogram[i]; + rect.nbEvents = nbEvents[i]; + rect.min = funValues[i]; + rect.max = funValues[i+1]; + } + } + return histogram._retn(); + } + + void NumericalFunctor_i::SetPrecision( CORBA::Long thePrecision ) + { + myNumericalFunctorPtr->SetPrecision( thePrecision ); + TPythonDump()<GetPrecision(); + } + + Controls::NumericalFunctorPtr NumericalFunctor_i::GetNumericalFunctor() + { + return myNumericalFunctorPtr; + } + + + /* + Class : SMESH_MinimumAngle + Description : Functor for calculation of minimum angle + */ + MinimumAngle_i::MinimumAngle_i() + { + myNumericalFunctorPtr.reset( new Controls::MinimumAngle() ); + myFunctorPtr = myNumericalFunctorPtr; + } + + FunctorType MinimumAngle_i::GetFunctorType() + { + return SMESH::FT_MinimumAngle; + } + + + /* + Class : AspectRatio + Description : Functor for calculating aspect ratio + */ + AspectRatio_i::AspectRatio_i() + { + myNumericalFunctorPtr.reset( new Controls::AspectRatio() ); + myFunctorPtr = myNumericalFunctorPtr; + } + + FunctorType AspectRatio_i::GetFunctorType() + { + return SMESH::FT_AspectRatio; + } + + + /* + Class : AspectRatio3D + Description : Functor for calculating aspect ratio 3D + */ + AspectRatio3D_i::AspectRatio3D_i() + { + myNumericalFunctorPtr.reset( new Controls::AspectRatio3D() ); + myFunctorPtr = myNumericalFunctorPtr; + } + + FunctorType AspectRatio3D_i::GetFunctorType() + { + return SMESH::FT_AspectRatio3D; + } + + + /* + Class : Warping_i + Description : Functor for calculating warping + */ + Warping_i::Warping_i() + { + myNumericalFunctorPtr.reset( new Controls::Warping() ); + myFunctorPtr = myNumericalFunctorPtr; + } + + FunctorType Warping_i::GetFunctorType() + { + return SMESH::FT_Warping; + } + + + /* + Class : Taper_i + Description : Functor for calculating taper + */ + Taper_i::Taper_i() + { + myNumericalFunctorPtr.reset( new Controls::Taper() ); + myFunctorPtr = myNumericalFunctorPtr; + } + + FunctorType Taper_i::GetFunctorType() + { + return SMESH::FT_Taper; + } + + /* + Class : Skew_i + Description : Functor for calculating skew in degrees + */ + Skew_i::Skew_i() + { + myNumericalFunctorPtr.reset( new Controls::Skew() ); + myFunctorPtr = myNumericalFunctorPtr; + } + + FunctorType Skew_i::GetFunctorType() + { + return SMESH::FT_Skew; + } + + /* + Class : Area_i + Description : Functor for calculating area + */ + Area_i::Area_i() + { + myNumericalFunctorPtr.reset( new Controls::Area() ); + myFunctorPtr = myNumericalFunctorPtr; + } + + FunctorType Area_i::GetFunctorType() + { + return SMESH::FT_Area; + } + + /* + Class : Volume3D_i + Description : Functor for calculating volume of 3D element + */ + Volume3D_i::Volume3D_i() + { + myNumericalFunctorPtr.reset( new Controls::Volume() ); + myFunctorPtr = myNumericalFunctorPtr; + } + + FunctorType Volume3D_i::GetFunctorType() + { + return SMESH::FT_Volume3D; + } + + /* + Class : MaxElementLength2D_i + Description : Functor for calculating maximum length of 2D element + */ + MaxElementLength2D_i::MaxElementLength2D_i() + { + myNumericalFunctorPtr.reset( new Controls::MaxElementLength2D() ); + myFunctorPtr = myNumericalFunctorPtr; + } + + FunctorType MaxElementLength2D_i::GetFunctorType() + { + return SMESH::FT_MaxElementLength2D; + } + + /* + Class : MaxElementLength3D_i + Description : Functor for calculating maximum length of 3D element + */ + MaxElementLength3D_i::MaxElementLength3D_i() + { + myNumericalFunctorPtr.reset( new Controls::MaxElementLength3D() ); + myFunctorPtr = myNumericalFunctorPtr; + } + + FunctorType MaxElementLength3D_i::GetFunctorType() + { + return SMESH::FT_MaxElementLength3D; + } + + /* + Class : Length_i + Description : Functor for calculating length off edge + */ + Length_i::Length_i() + { + myNumericalFunctorPtr.reset( new Controls::Length() ); + myFunctorPtr = myNumericalFunctorPtr; + } + + FunctorType Length_i::GetFunctorType() + { + return SMESH::FT_Length; + } + + /* + Class : Length2D_i + Description : Functor for calculating length of edge + */ + Length2D_i::Length2D_i() + { + myNumericalFunctorPtr.reset( new Controls::Length2D() ); + myFunctorPtr = myNumericalFunctorPtr; + } + + FunctorType Length2D_i::GetFunctorType() + { + return SMESH::FT_Length2D; + } + + SMESH::Length2D::Values* Length2D_i::GetValues() + { + SMESH::Controls::Length2D::TValues aValues; + (dynamic_cast(myFunctorPtr.get()))->GetValues( aValues ); + + long i = 0, iEnd = aValues.size(); + + SMESH::Length2D::Values_var aResult = new SMESH::Length2D::Values(iEnd); + aResult->length(iEnd); + + SMESH::Controls::Length2D::TValues::const_iterator anIter; + for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ ) + { + const SMESH::Controls::Length2D::Value& aVal = *anIter; + SMESH::Length2D::Value &aValue = aResult[ i ]; + + aValue.myLength = aVal.myLength; + aValue.myPnt1 = aVal.myPntId[ 0 ]; + aValue.myPnt2 = aVal.myPntId[ 1 ]; + } + + return aResult._retn(); + } + + + /* + Class : Length3D_i + Description : Functor for calculating length of edge + */ + Length3D_i::Length3D_i() + { + myNumericalFunctorPtr.reset( new Controls::Length3D() ); + myFunctorPtr = myNumericalFunctorPtr; + } + + FunctorType Length3D_i::GetFunctorType() + { + return SMESH::FT_Length3D; + } + + // SMESH::Length3D::Values* Length3D_i::GetValues() + // { + // SMESH::Controls::Length3D::TValues aValues; + // (dynamic_cast(myFunctorPtr.get()))->GetValues( aValues ); + + // long i = 0, iEnd = aValues.size(); + + // SMESH::Length3D::Values_var aResult = new SMESH::Length3D::Values(iEnd); + // aResult->length(iEnd); + + // SMESH::Controls::Length3D::TValues::const_iterator anIter; + // for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ ) + // { + // const SMESH::Controls::Length3D::Value& aVal = *anIter; + // SMESH::Length3D::Value &aValue = aResult[ i ]; + + // aValue.myLength = aVal.myLength; + // aValue.myPnt1 = aVal.myPntId[ 0 ]; + // aValue.myPnt2 = aVal.myPntId[ 1 ]; + // } + + // return aResult._retn(); + // } + + /* + Class : Deflection2D_i + Description : Functor for calculating distance between a face and geometry + */ + Deflection2D_i::Deflection2D_i() + { + myNumericalFunctorPtr.reset( new Controls::Deflection2D() ); + myFunctorPtr = myNumericalFunctorPtr; + } + + FunctorType Deflection2D_i::GetFunctorType() + { + return SMESH::FT_Deflection2D; + } + + /* + Class : MultiConnection_i + Description : Functor for calculating number of faces conneted to the edge + */ + MultiConnection_i::MultiConnection_i() + { + myNumericalFunctorPtr.reset( new Controls::MultiConnection() ); + myFunctorPtr = myNumericalFunctorPtr; + } + + FunctorType MultiConnection_i::GetFunctorType() + { + return SMESH::FT_MultiConnection; + } + + /* + Class : BallDiameter_i + Description : Functor returning diameter of a ball element + */ + BallDiameter_i::BallDiameter_i() + { + myNumericalFunctorPtr.reset( new Controls::BallDiameter() ); + myFunctorPtr = myNumericalFunctorPtr; + } + + FunctorType BallDiameter_i::GetFunctorType() + { + return SMESH::FT_BallDiameter; + } + + /* + Class : NodeConnectivityNumber_i + Description : Functor returning diameter of a ball element + */ + NodeConnectivityNumber_i::NodeConnectivityNumber_i() + { + myNumericalFunctorPtr.reset( new Controls::NodeConnectivityNumber() ); + myFunctorPtr = myNumericalFunctorPtr; + } + + FunctorType NodeConnectivityNumber_i::GetFunctorType() + { + return SMESH::FT_NodeConnectivityNumber; + } + + /* + Class : MultiConnection2D_i + Description : Functor for calculating number of faces conneted to the edge + */ + MultiConnection2D_i::MultiConnection2D_i() + { + myNumericalFunctorPtr.reset( new Controls::MultiConnection2D() ); + myFunctorPtr = myNumericalFunctorPtr; + } + + FunctorType MultiConnection2D_i::GetFunctorType() + { + return SMESH::FT_MultiConnection2D; + } + + SMESH::MultiConnection2D::Values* MultiConnection2D_i::GetValues() + { + SMESH::Controls::MultiConnection2D::MValues aValues; + (dynamic_cast(myFunctorPtr.get()))->GetValues( aValues ); + + long i = 0, iEnd = aValues.size(); + + SMESH::MultiConnection2D::Values_var aResult = new SMESH::MultiConnection2D::Values(iEnd); + aResult->length(iEnd); + + SMESH::Controls::MultiConnection2D::MValues::const_iterator anIter; + for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ ) + { + const SMESH::Controls::MultiConnection2D::Value& aVal = (*anIter).first; + SMESH::MultiConnection2D::Value &aValue = aResult[ i ]; + + aValue.myPnt1 = aVal.myPntId[ 0 ]; + aValue.myPnt2 = aVal.myPntId[ 1 ]; + aValue.myNbConnects = (*anIter).second; + } + + return aResult._retn(); + } + + /* + PREDICATES + */ + + + /* + Class : Predicate_i + Description : Base class for all predicates + */ + CORBA::Boolean Predicate_i::IsSatisfy( CORBA::Long theId ) + { + return myPredicatePtr->IsSatisfy( theId ); + } + + CORBA::Long Predicate_i::NbSatisfying( SMESH::SMESH_IDSource_ptr obj ) + { + SMESH::SMESH_Mesh_var meshVar = obj->GetMesh(); + const SMDS_Mesh* meshDS = MeshPtr2SMDSMesh( meshVar ); + if ( !meshDS ) + return 0; + myPredicatePtr->SetMesh( meshDS ); + + SMDSAbs_ElementType elemType = SMDSAbs_ElementType( GetElementType() ); + + int nb = 0; + SMDS_ElemIteratorPtr elemIt = + SMESH::DownCast( meshVar )->GetElements( obj, GetElementType() ); + if ( elemIt ) + while ( elemIt->more() ) + { + const SMDS_MeshElement* e = elemIt->next(); + if ( e && e->GetType() == elemType ) + nb += myPredicatePtr->IsSatisfy( e->GetID() ); + } + return nb; + } + + Controls::PredicatePtr Predicate_i::GetPredicate() + { + return myPredicatePtr; + } + + /* + Class : BadOrientedVolume_i + Description : Verify whether a mesh volume is incorrectly oriented from + the point of view of MED convention + */ + BadOrientedVolume_i::BadOrientedVolume_i() + { + Controls::PredicatePtr control( new Controls::BadOrientedVolume() ); + myFunctorPtr = myPredicatePtr = control; + } + + FunctorType BadOrientedVolume_i::GetFunctorType() + { + return SMESH::FT_BadOrientedVolume; + } + + /* + Class : BareBorderVolume_i + Description : Verify whether a mesh volume has a free facet without a face on it + */ + BareBorderVolume_i::BareBorderVolume_i() + { + Controls::PredicatePtr control( new Controls::BareBorderVolume() ); + myFunctorPtr = myPredicatePtr = control; + } + + FunctorType BareBorderVolume_i::GetFunctorType() + { + return SMESH::FT_BareBorderVolume; + } + + /* + Class : BareBorderFace_i + Description : Verify whether a mesh face has a free border without an edge on it + */ + BareBorderFace_i::BareBorderFace_i() + { + Controls::PredicatePtr control( new Controls::BareBorderFace() ); + myFunctorPtr = myPredicatePtr = control; + } + + FunctorType BareBorderFace_i::GetFunctorType() + { + return SMESH::FT_BareBorderFace; + } + + /* + Class : OverConstrainedVolume_i + Description : Verify whether a mesh volume has only one facet shared with other volumes + */ + OverConstrainedVolume_i::OverConstrainedVolume_i() + { + Controls::PredicatePtr control( new Controls::OverConstrainedVolume() ); + myFunctorPtr = myPredicatePtr = control; + } + + FunctorType OverConstrainedVolume_i::GetFunctorType() + { + return SMESH::FT_OverConstrainedVolume; + } + + /* + Class : OverConstrainedFace_i + Description : Verify whether a mesh face has only one border shared with other faces + */ + OverConstrainedFace_i::OverConstrainedFace_i() + { + Controls::PredicatePtr control( new Controls::OverConstrainedFace() ); + myFunctorPtr = myPredicatePtr = control; + } + + FunctorType OverConstrainedFace_i::GetFunctorType() + { + return SMESH::FT_OverConstrainedFace; + } + + /* + Class : BelongToMeshGroup_i + Description : Verify whether a mesh element is included into a mesh group + */ + BelongToMeshGroup_i::BelongToMeshGroup_i() + { + myBelongToMeshGroup = Controls::BelongToMeshGroupPtr( new Controls::BelongToMeshGroup() ); + myFunctorPtr = myPredicatePtr = myBelongToMeshGroup; + } + + BelongToMeshGroup_i::~BelongToMeshGroup_i() + { + SetGroup( SMESH::SMESH_GroupBase::_nil() ); + } + + void BelongToMeshGroup_i::SetGroup( SMESH::SMESH_GroupBase_ptr theGroup ) + { + if ( myGroup->_is_equivalent( theGroup )) + return; + + if ( ! myGroup->_is_nil() ) + myGroup->UnRegister(); + + myGroup = SMESH_GroupBase::_duplicate( theGroup ); + + myBelongToMeshGroup->SetGroup( 0 ); + if ( SMESH_GroupBase_i* gr_i = SMESH::DownCast< SMESH_GroupBase_i* >( myGroup )) + { + myBelongToMeshGroup->SetGroup( gr_i->GetGroupDS() ); + myGroup->Register(); } } - return aRes._retn(); -} - - -//================================================================================ -/*! - * \brief Return GetElementType() within an array - * Implement SMESH_IDSource interface - */ -//================================================================================ - -SMESH::array_of_ElementType* Filter_i::GetTypes() -{ - SMESH::array_of_ElementType_var types = new SMESH::array_of_ElementType; - - // check if any element passes through the filter - if ( !CORBA::is_nil(myMesh) && myPredicate ) + void BelongToMeshGroup_i::SetGroupID( const char* theID ) // IOR or StoreName { - const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh); - SMDS_ElemIteratorPtr it = aMesh->elementsIterator( SMDSAbs_ElementType( GetElementType() )); - bool satisfies = false; - while ( !satisfies && it->more() ) - satisfies = myPredicate->IsSatisfy( it->next()->GetID() ); - if ( satisfies ) { - types->length( 1 ); - types[0] = GetElementType(); + myID = theID; + if ( strncmp( "IOR:", myID.c_str(), 4 ) == 0 ) // transient mode, no GUI + { + CORBA::Object_var obj = SMESH_Gen_i::GetORB()->string_to_object( myID.c_str() ); + SetGroup( SMESH::SMESH_GroupBase::_narrow( obj )); + } + else if ( strncmp( "0:", myID.c_str(), 2 ) == 0 ) // transient mode + GUI + { + SALOMEDS::SObject_wrap aSObj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( myID.c_str() ); + if ( !aSObj->_is_nil() ) { + CORBA::Object_var obj = aSObj->GetObject(); + SetGroup( SMESH::SMESH_GroupBase::_narrow( obj )); + } + } + else if ( !myID.empty() ) // persistent mode + { + myBelongToMeshGroup->SetStoreName( myID ); } } - return types._retn(); -} -//======================================================================= -//function : GetMesh -//purpose : Returns mesh -//======================================================================= - -SMESH::SMESH_Mesh_ptr Filter_i::GetMesh() -{ - return SMESH_Mesh::_duplicate( myMesh ); -} - -//======================================================================= -//function : GetVtkUgStream -//purpose : Return data vtk unstructured grid (not implemented) -//======================================================================= - -SALOMEDS::TMPFile* Filter_i::GetVtkUgStream() -{ - SALOMEDS::TMPFile_var SeqFile; - return SeqFile._retn(); -} -//======================================================================= -// name : getCriteria -// Purpose : Retrieve criterions from predicate -//======================================================================= -static inline void getPrediacates( Predicate_i* thePred, - std::vector & thePredVec ) -{ - const int aFType = thePred->GetFunctorType(); - - switch ( aFType ) + std::string BelongToMeshGroup_i::GetGroupID() { - case FT_LogicalNOT: - { - Predicate_i* aPred = ( dynamic_cast( thePred ) )->GetPredicate_i(); - getPrediacates( aPred, thePredVec ); - break; + if ( myGroup->_is_nil() ) + SMESH::SMESH_GroupBase_var( GetGroup() ); // decref the returned pointer + + if ( !myGroup->_is_nil() ) + myID = SMESH_Gen_i::GetORB()->object_to_string( myGroup ); + + return myID; } - case FT_LogicalAND: - case FT_LogicalOR: + + SMESH::SMESH_GroupBase_ptr BelongToMeshGroup_i::GetGroup() { - Predicate_i* aPred1 = ( dynamic_cast( thePred ) )->GetPredicate1_i(); - Predicate_i* aPred2 = ( dynamic_cast( thePred ) )->GetPredicate2_i(); - getPrediacates( aPred1, thePredVec ); - getPrediacates( aPred2, thePredVec ); - break; - } - default:; + if ( myGroup->_is_nil() && myBelongToMeshGroup->GetGroup() ) + { + // search for a group in a current study + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + if ( StudyContext* sc = aSMESHGen->GetStudyContext() ) + { + int id = 1; + std::string ior; + while (true) + { + ior = sc->getIORbyId( id++ ); + if ( ior.empty() ) break; + CORBA::Object_var obj = aSMESHGen->GetORB()->string_to_object( ior.c_str() ); + if ( SMESH_GroupBase_i* g_i = SMESH::DownCast( obj )) + if ( g_i->GetGroupDS() == myBelongToMeshGroup->GetGroup() ) + { + SetGroup( g_i->_this() ); + break; + } + } + } + } + return SMESH::SMESH_GroupBase::_duplicate( myGroup ); } - thePredVec.push_back( thePred ); -} -//======================================================================= -// name : getCriteria -// Purpose : Retrieve criterions from predicate -//======================================================================= -static inline bool getCriteria( Predicate_i* thePred, - SMESH::Filter::Criteria_out theCriteria ) -{ - const int aFType = thePred->GetFunctorType(); - - switch ( aFType ) + FunctorType BelongToMeshGroup_i::GetFunctorType() { - case FT_LogicalNOT: + return SMESH::FT_BelongToMeshGroup; + } + + /* + Class : BelongToGeom_i + Description : Predicate for selection on geometrical support + */ + BelongToGeom_i::BelongToGeom_i() + { + myBelongToGeomPtr.reset( new Controls::BelongToGeom() ); + myFunctorPtr = myPredicatePtr = myBelongToGeomPtr; + myShapeName = 0; + myShapeID = 0; + } + + BelongToGeom_i::~BelongToGeom_i() + { + CORBA::string_free( myShapeName ); + CORBA::string_free( myShapeID ); + } + + void BelongToGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom ) + { + if ( theGeom->_is_nil() ) + return; + TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom ); + myBelongToGeomPtr->SetGeom( aLocShape ); + TPythonDump()<SetGeom( theShape ); + } + + void BelongToGeom_i::SetElementType(ElementType theType) + { + myBelongToGeomPtr->SetType(SMDSAbs_ElementType(theType)); + TPythonDump()<SetGeom( getShapeByName( myShapeName ) ); + TPythonDump()<SetGeom( S ); + } + + char* BelongToGeom_i::GetShapeName() + { + return CORBA::string_dup( myShapeName ); + } + + char* BelongToGeom_i::GetShapeID() + { + return CORBA::string_dup( myShapeID ); + } + + void BelongToGeom_i::SetTolerance( CORBA::Double theToler ) + { + myBelongToGeomPtr->SetTolerance( theToler ); + TPythonDump()<GetTolerance(); + } + + /* + Class : BelongToSurface_i + Description : Predicate for selection on geometrical support + */ + BelongToSurface_i::BelongToSurface_i( const Handle(Standard_Type)& theSurfaceType ) + { + myElementsOnSurfacePtr.reset( new Controls::ElementsOnSurface() ); + myFunctorPtr = myPredicatePtr = myElementsOnSurfacePtr; + myShapeName = 0; + myShapeID = 0; + mySurfaceType = theSurfaceType; + } + + BelongToSurface_i::~BelongToSurface_i() + { + CORBA::string_free( myShapeName ); + CORBA::string_free( myShapeID ); + } + + void BelongToSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType ) + { + if ( theGeom->_is_nil() ) + return; + TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom ); + + if ( aLocShape.ShapeType() == TopAbs_FACE ) + { + Handle(Geom_Surface) aSurf = BRep_Tool::Surface( TopoDS::Face( aLocShape ) ); + if ( !aSurf.IsNull() && aSurf->DynamicType() == mySurfaceType ) + { + myElementsOnSurfacePtr->SetSurface( aLocShape, (SMDSAbs_ElementType)theType ); + return; + } + } + + myElementsOnSurfacePtr->SetSurface( TopoDS_Shape(), (SMDSAbs_ElementType)theType ); + } + + void BelongToSurface_i::SetShapeName( const char* theName, ElementType theType ) + { + CORBA::string_free( myShapeName ); + myShapeName = CORBA::string_dup( theName ); + myElementsOnSurfacePtr->SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType ); + TPythonDump()<SetSurface( S, (SMDSAbs_ElementType)theType ); + } + + char* BelongToSurface_i::GetShapeName() + { + return CORBA::string_dup( myShapeName ); + } + + char* BelongToSurface_i::GetShapeID() + { + return CORBA::string_dup( myShapeID ); + } + + void BelongToSurface_i::SetTolerance( CORBA::Double theToler ) + { + myElementsOnSurfacePtr->SetTolerance( theToler ); + TPythonDump()<GetTolerance(); + } + + void BelongToSurface_i::SetUseBoundaries( CORBA::Boolean theUseBndRestrictions ) + { + myElementsOnSurfacePtr->SetUseBoundaries( theUseBndRestrictions ); + TPythonDump()<GetUseBoundaries(); + } + + + /* + Class : BelongToPlane_i + Description : Verify whether mesh element lie in pointed Geom planar object + */ + + BelongToPlane_i::BelongToPlane_i() + : BelongToSurface_i( STANDARD_TYPE( Geom_Plane ) ) + { + } + + void BelongToPlane_i::SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType ) + { + BelongToSurface_i::SetSurface( theGeom, theType ); + TPythonDump()<_is_nil() ) + return; + TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom ); + if ( !aLocShape.IsNull() && aLocShape.ShapeType() != TopAbs_FACE ) + aLocShape.Nullify(); + + BelongToSurface_i::myElementsOnSurfacePtr->SetSurface( aLocShape, (SMDSAbs_ElementType)theType ); + TPythonDump()<_is_nil() ) + return; + TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom ); + myLyingOnGeomPtr->SetGeom( aLocShape ); + TPythonDump()<SetGeom( theShape ); + } + + void LyingOnGeom_i::SetElementType(ElementType theType){ + myLyingOnGeomPtr->SetType(SMDSAbs_ElementType(theType)); + TPythonDump()<SetGeom( getShapeByName( myShapeName ) ); + TPythonDump()<SetGeom( S ); + } + + char* LyingOnGeom_i::GetShapeName() + { + return CORBA::string_dup( myShapeName ); + } + + char* LyingOnGeom_i::GetShapeID() + { + return CORBA::string_dup( myShapeID ); + } + + void LyingOnGeom_i::SetTolerance( CORBA::Double theToler ) + { + myLyingOnGeomPtr->SetTolerance( theToler ); + TPythonDump()<GetTolerance(); + } + + /* + Class : FreeBorders_i + Description : Predicate for free borders + */ + FreeBorders_i::FreeBorders_i() + { + myPredicatePtr.reset(new Controls::FreeBorders()); + myFunctorPtr = myPredicatePtr; + } + + FunctorType FreeBorders_i::GetFunctorType() + { + return SMESH::FT_FreeBorders; + } + + /* + Class : FreeEdges_i + Description : Predicate for free borders + */ + FreeEdges_i::FreeEdges_i() + : myFreeEdgesPtr( new Controls::FreeEdges() ) + { + myFunctorPtr = myPredicatePtr = myFreeEdgesPtr; + } + + SMESH::FreeEdges::Borders* FreeEdges_i::GetBorders() + { + SMESH::Controls::FreeEdges::TBorders aBorders; + myFreeEdgesPtr->GetBoreders( aBorders ); + + long i = 0, iEnd = aBorders.size(); + + SMESH::FreeEdges::Borders_var aResult = new SMESH::FreeEdges::Borders; + aResult->length(iEnd); + + SMESH::Controls::FreeEdges::TBorders::const_iterator anIter; + for ( anIter = aBorders.begin() ; anIter != aBorders.end(); anIter++, i++ ) + { + const SMESH::Controls::FreeEdges::Border& aBord = *anIter; + SMESH::FreeEdges::Border &aBorder = aResult[ i ]; + + aBorder.myElemId = aBord.myElemId; + aBorder.myPnt1 = aBord.myPntId[ 0 ]; + aBorder.myPnt2 = aBord.myPntId[ 1 ]; + } + return aResult._retn(); + } + + FunctorType FreeEdges_i::GetFunctorType() + { + return SMESH::FT_FreeEdges; + } + + /* + Class : FreeFaces_i + Description : Predicate for free faces + */ + FreeFaces_i::FreeFaces_i() + { + myPredicatePtr.reset(new Controls::FreeFaces()); + myFunctorPtr = myPredicatePtr; + } + + FunctorType FreeFaces_i::GetFunctorType() + { + return SMESH::FT_FreeFaces; + } + + /* + Class : FreeNodes_i + Description : Predicate for free nodes + */ + FreeNodes_i::FreeNodes_i() + { + myPredicatePtr.reset(new Controls::FreeNodes()); + myFunctorPtr = myPredicatePtr; + } + + FunctorType FreeNodes_i::GetFunctorType() + { + return SMESH::FT_FreeNodes; + } + + /* + Class : EqualNodes_i + Description : Predicate for Equal nodes + */ + EqualNodes_i::EqualNodes_i() + { + myCoincidentNodesPtr.reset(new Controls::CoincidentNodes()); + myFunctorPtr = myPredicatePtr = myCoincidentNodesPtr; + } + + FunctorType EqualNodes_i::GetFunctorType() + { + return SMESH::FT_EqualNodes; + } + + void EqualNodes_i::SetTolerance( double tol ) + { + myCoincidentNodesPtr->SetTolerance( tol ); + } + + double EqualNodes_i::GetTolerance() + { + return myCoincidentNodesPtr->GetTolerance(); + } + + /* + Class : EqualEdges_i + Description : Predicate for Equal Edges + */ + EqualEdges_i::EqualEdges_i() + { + myPredicatePtr.reset(new Controls::CoincidentElements1D()); + myFunctorPtr = myPredicatePtr; + } + + FunctorType EqualEdges_i::GetFunctorType() + { + return SMESH::FT_EqualEdges; + } + + /* + Class : EqualFaces_i + Description : Predicate for Equal Faces + */ + EqualFaces_i::EqualFaces_i() + { + myPredicatePtr.reset(new Controls::CoincidentElements2D()); + myFunctorPtr = myPredicatePtr; + } + + FunctorType EqualFaces_i::GetFunctorType() + { + return SMESH::FT_EqualFaces; + } + + /* + Class : EqualVolumes_i + Description : Predicate for Equal Volumes + */ + EqualVolumes_i::EqualVolumes_i() + { + myPredicatePtr.reset(new Controls::CoincidentElements3D()); + myFunctorPtr = myPredicatePtr; + } + + FunctorType EqualVolumes_i::GetFunctorType() + { + return SMESH::FT_EqualVolumes; + } + + + /* + Class : RangeOfIds_i + Description : Predicate for Range of Ids. + Range may be specified with two ways. + 1. Using AddToRange method + 2. With SetRangeStr method. Parameter of this method is a string + like as "1,2,3,50-60,63,67,70-" + */ + + RangeOfIds_i::RangeOfIds_i() + { + myRangeOfIdsPtr.reset( new Controls::RangeOfIds() ); + myFunctorPtr = myPredicatePtr = myRangeOfIdsPtr; + } + + void RangeOfIds_i::SetRange( const SMESH::smIdType_array& theIds ) + { + SMESH::smIdType iEnd = theIds.length(); + for ( SMESH::smIdType i = 0; i < iEnd; i++ ) + myRangeOfIdsPtr->AddToRange( theIds[ i ] ); + TPythonDump()<SetRangeStr( + TCollection_AsciiString( (Standard_CString)theRange ) ); + } + + char* RangeOfIds_i::GetRangeStr() + { + TCollection_AsciiString aStr; + myRangeOfIdsPtr->GetRangeStr( aStr ); + return CORBA::string_dup( aStr.ToCString() ); + } + + void RangeOfIds_i::SetElementType( ElementType theType ) + { + myRangeOfIdsPtr->SetType( SMDSAbs_ElementType( theType ) ); + TPythonDump()<SetType(SMDSAbs_ElementType(theType)); + TPythonDump()<SetColorStr( + TCollection_AsciiString( (Standard_CString)theColor ) ); + TPythonDump()<GetColorStr( aStr ); + return CORBA::string_dup( aStr.ToCString() ); + } + + void GroupColor_i::SetElementType(ElementType theType) + { + myGroupColorPtr->SetType(SMDSAbs_ElementType(theType)); + TPythonDump()<SetType(SMDSAbs_ElementType(theType)); + TPythonDump()<SetGeomType(SMDSAbs_GeometryType(theType)); + TPythonDump()<GetGeomType(); + } + + FunctorType ElemGeomType_i::GetFunctorType() + { + return SMESH::FT_ElemGeomType; + } + + /* + Class : ElemEntityType_i + Description : Predicate check is element has indicated entity type + */ + ElemEntityType_i::ElemEntityType_i() + { + myElemEntityTypePtr.reset(new Controls::ElemEntityType()); + myFunctorPtr = myPredicatePtr = myElemEntityTypePtr; + } + + void ElemEntityType_i::SetElementType(ElementType theType) + { + myElemEntityTypePtr->SetType(SMDSAbs_ElementType(theType)); + TPythonDump()<SetElemEntityType(SMDSAbs_EntityType (theEntityType)); + TPythonDump()<GetElemEntityType(); + } + + FunctorType ElemEntityType_i::GetFunctorType() + { + return SMESH::FT_EntityType; + } + + /* + Class : CoplanarFaces_i + Description : Returns true if a mesh face is a coplanar neighbour to a given one + */ + CoplanarFaces_i::CoplanarFaces_i() + { + myCoplanarFacesPtr.reset(new Controls::CoplanarFaces()); + myFunctorPtr = myPredicatePtr = myCoplanarFacesPtr; + } + + void CoplanarFaces_i::SetFace ( CORBA::Long theFaceID ) + { + myCoplanarFacesPtr->SetFace(theFaceID); + TPythonDump()<SetTolerance(theToler); + TPythonDump()<GetFace(); + } + + char* CoplanarFaces_i::GetFaceAsString () const + { + TCollection_AsciiString str(Standard_Integer(myCoplanarFacesPtr->GetFace())); + return CORBA::string_dup( str.ToCString() ); + } + + CORBA::Double CoplanarFaces_i::GetTolerance() const + { + return myCoplanarFacesPtr->GetTolerance(); + } + + FunctorType CoplanarFaces_i::GetFunctorType() + { + return SMESH::FT_CoplanarFaces; + } + + /* + * Class : ConnectedElements_i + * Description : Returns true if an element is connected via other elements to the element + * located at a given point. + */ + ConnectedElements_i::ConnectedElements_i() + { + myConnectedElementsPtr.reset(new Controls::ConnectedElements()); + myFunctorPtr = myPredicatePtr = myConnectedElementsPtr; + } + + FunctorType ConnectedElements_i::GetFunctorType() + { + return FT_ConnectedElements; + } + + void ConnectedElements_i::SetElementType( ElementType theType ) + { + myConnectedElementsPtr->SetType( SMDSAbs_ElementType( theType )); + TPythonDump() << this << ".SetElementType( " << theType << " )"; + } + + void ConnectedElements_i::SetPoint( CORBA::Double x, CORBA::Double y, CORBA::Double z ) + { + myConnectedElementsPtr->SetPoint( x,y,z ); + myVertexID.clear(); + TPythonDump() << this << ".SetPoint( " << x << ", " << y << ", " << z << " )"; + } + + void ConnectedElements_i::SetVertex( GEOM::GEOM_Object_ptr vertex ) + { + TopoDS_Shape shape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( vertex ); + if ( shape.IsNull() ) + THROW_SALOME_CORBA_EXCEPTION( "ConnectedElements_i::SetVertex(): NULL Vertex", + SALOME::BAD_PARAM ); + + TopExp_Explorer v( shape, TopAbs_VERTEX ); + if ( !v.More() ) + THROW_SALOME_CORBA_EXCEPTION( "ConnectedElements_i::SetVertex(): empty vertex", + SALOME::BAD_PARAM ); + + gp_Pnt p = BRep_Tool::Pnt( TopoDS::Vertex( v.Current() )); + myConnectedElementsPtr->SetPoint( p.X(), p.Y(), p.Z() ); + // + CORBA::String_var id = vertex->GetStudyEntry(); + myVertexID = id.in(); + + TPythonDump() << this << ".SetVertex( " << vertex << " )"; + } + + void ConnectedElements_i::SetNode ( SMESH::smIdType nodeID ) + { + if ( nodeID < 1 ) + THROW_SALOME_CORBA_EXCEPTION( "ConnectedElements_i::SetNode(): nodeID must be > 0", + SALOME::BAD_PARAM ); + + myConnectedElementsPtr->SetNode( nodeID ); + myVertexID.clear(); + TPythonDump() << this << ".SetNode( " << nodeID << " )"; + } + + /*! + * \brief This is a comfort method for Filter dialog + */ + void ConnectedElements_i::SetThreshold ( const char* threshold, + SMESH::ConnectedElements::ThresholdType type ) + { + if ( !threshold ) + THROW_SALOME_CORBA_EXCEPTION( "ConnectedElements_i::SetThreshold(): NULL threshold", + SALOME::BAD_PARAM ); + switch ( type ) + { + case SMESH::ConnectedElements::POINT: // read 3 node coordinates /////////////////// + { + std::vector< double > xyz; + char* endptr; + do + { + // skip a separator + while ( *threshold && + *threshold != '+' && + *threshold != '-' && + !isdigit( *threshold )) + ++threshold; + if ( !*threshold ) + break; + // read a coordinate + xyz.push_back( strtod( threshold, &endptr )); + if ( threshold == endptr ) + { + xyz.resize( xyz.size() - 1 ); + break; + } + threshold = endptr; + } + while ( xyz.size() < 3 ); + + if ( xyz.size() < 3 ) + THROW_SALOME_CORBA_EXCEPTION + ( "ConnectedElements_i::SetThreshold(): invalid point coordinates", SALOME::BAD_PARAM ); + + SetPoint( xyz[0], xyz[1], xyz[2] ); + break; + } + case SMESH::ConnectedElements::VERTEX: // get a VERTEX by its entry ///////////////// + { + SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( threshold ); + if ( sobj->_is_nil() ) + THROW_SALOME_CORBA_EXCEPTION + ( "ConnectedElements_i::SetThreshold(): invalid vertex study entry", SALOME::BAD_PARAM ); + CORBA::Object_var obj = sobj->GetObject(); + GEOM::GEOM_Object_var vertex = GEOM::GEOM_Object::_narrow( obj ); + if ( vertex->_is_nil() ) + THROW_SALOME_CORBA_EXCEPTION + ( "ConnectedElements_i::SetThreshold(): no GEOM_Object in SObject", SALOME::BAD_PARAM ); + SetVertex( vertex ); + break; + } + case SMESH::ConnectedElements::NODE: // read a node ID //////////////////////////// + { + char* endptr; + int id = strtol( threshold, &endptr, 10 ); + if ( threshold == endptr ) + THROW_SALOME_CORBA_EXCEPTION + ( "ConnectedElements_i::SetThreshold(): invalid node ID", SALOME::BAD_PARAM ); + SetNode( id ); + break; + } + default: + THROW_SALOME_CORBA_EXCEPTION + ( "ConnectedElements_i::SetThreshold(): invalid ThresholdType", SALOME::BAD_PARAM ); + } + } + + char* ConnectedElements_i::GetThreshold ( SMESH::ConnectedElements::ThresholdType& type ) + { + std::string threshold; + if ( !myVertexID.empty() ) + { + threshold = myVertexID; + type = SMESH::ConnectedElements::VERTEX; + } + else + { + std::vector xyz = myConnectedElementsPtr->GetPoint(); + if ( xyz.size() == 3 ) + { + threshold = SMESH_Comment( xyz[0] ) << "; " << xyz[1] << "; " << xyz[2]; + type = SMESH::ConnectedElements::POINT; + } + else + { + threshold = SMESH_Comment( myConnectedElementsPtr->GetNode() ); + type = SMESH::ConnectedElements::NODE; + } + } + return CORBA::string_dup( threshold.c_str() ); + } + + /* + Class : Comparator_i + Description : Base class for comparators + */ + Comparator_i::Comparator_i(): + myNumericalFunctor( NULL ) + {} + + Comparator_i::~Comparator_i() + { + if ( myNumericalFunctor ) + myNumericalFunctor->UnRegister(); + } + + void Comparator_i::SetMargin( CORBA::Double theValue ) + { + myComparatorPtr->SetMargin( theValue ); + TPythonDump()<GetMargin(); + } + + void Comparator_i::SetNumFunctor( NumericalFunctor_ptr theFunct ) + { + if ( myNumericalFunctor ) + myNumericalFunctor->UnRegister(); + + myNumericalFunctor = DownCast(theFunct); + + if ( myNumericalFunctor ) + { + myComparatorPtr->SetNumFunctor( myNumericalFunctor->GetNumericalFunctor() ); + myNumericalFunctor->Register(); + TPythonDump()<" + */ + MoreThan_i::MoreThan_i() + { + myComparatorPtr.reset( new Controls::MoreThan() ); + myFunctorPtr = myPredicatePtr = myComparatorPtr; + } + + FunctorType MoreThan_i::GetFunctorType() + { + return SMESH::FT_MoreThan; + } + + + /* + Class : EqualTo_i + Description : Comparator "=" + */ + EqualTo_i::EqualTo_i() + : myEqualToPtr( new Controls::EqualTo() ) + { + myFunctorPtr = myPredicatePtr = myComparatorPtr = myEqualToPtr; + } + + void EqualTo_i::SetTolerance( CORBA::Double theToler ) + { + myEqualToPtr->SetTolerance( theToler ); + TPythonDump()<GetTolerance(); + } + + FunctorType EqualTo_i::GetFunctorType() + { + return SMESH::FT_EqualTo; + } + + /* + Class : LogicalNOT_i + Description : Logical NOT predicate + */ + LogicalNOT_i::LogicalNOT_i(): + myLogicalNOTPtr( new Controls::LogicalNOT() ), + myPredicate( NULL ) + { + myFunctorPtr = myPredicatePtr = myLogicalNOTPtr; + } + + LogicalNOT_i::~LogicalNOT_i() + { + if ( myPredicate ) + myPredicate->UnRegister(); + } + + void LogicalNOT_i::SetPredicate( Predicate_ptr thePredicate ) + { + if ( myPredicate ) + myPredicate->UnRegister(); + + myPredicate = SMESH::GetPredicate(thePredicate); + + if ( myPredicate ){ + myLogicalNOTPtr->SetPredicate(myPredicate->GetPredicate()); + myPredicate->Register(); + TPythonDump()<UnRegister(); + + if ( myPredicate2 ) + myPredicate2->UnRegister(); + } + + void LogicalBinary_i::SetMesh( SMESH_Mesh_ptr theMesh ) + { + if ( myPredicate1 ) + myPredicate1->SetMesh( theMesh ); + + if ( myPredicate2 ) + myPredicate2->SetMesh( theMesh ); + } + + void LogicalBinary_i::SetPredicate1( Predicate_ptr thePredicate ) + { + if ( myPredicate1 ) + myPredicate1->UnRegister(); + + myPredicate1 = SMESH::GetPredicate(thePredicate); + + if ( myPredicate1 ){ + myLogicalBinaryPtr->SetPredicate1(myPredicate1->GetPredicate()); + myPredicate1->Register(); + TPythonDump()<UnRegister(); + + myPredicate2 = SMESH::GetPredicate(thePredicate); + + if ( myPredicate2 ){ + myLogicalBinaryPtr->SetPredicate2(myPredicate2->GetPredicate()); + myPredicate2->Register(); + TPythonDump()<activate_object( this ); + } + + + FilterManager_i::~FilterManager_i() + { + //TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<UnRegister(); + + if(!CORBA::is_nil(myMesh)) + myMesh->UnRegister(); + + myPredicate = 0; + FindBaseObjects(); + } + + //======================================================================= + // name : Filter_i::SetPredicate + // Purpose : Set predicate + //======================================================================= + void Filter_i::SetPredicate( Predicate_ptr thePredicate ) + { + if ( myPredicate ) + myPredicate->UnRegister(); + + myPredicate = SMESH::GetPredicate(thePredicate); + + if ( myPredicate ) + { + myFilter.SetPredicate( myPredicate->GetPredicate() ); + myPredicate->Register(); + if ( const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh)) + myPredicate->GetPredicate()->SetMesh( aMesh ); + TPythonDump()<GetElementType() : SMESH::ALL; + } + + //======================================================================= + // name : Filter_i::SetMesh + // Purpose : Set mesh + //======================================================================= + void + Filter_i:: + SetMesh( SMESH_Mesh_ptr theMesh ) + { + if(!CORBA::is_nil(theMesh)) + theMesh->Register(); + + if(!CORBA::is_nil(myMesh)) + myMesh->UnRegister(); + + myMesh = SMESH_Mesh::_duplicate( theMesh ); + TPythonDump()<GetPredicate()->SetMesh( aMesh ); + } + + SMESH::smIdType_array* + Filter_i:: + GetIDs() + { + return GetElementsId(myMesh); + } + + //======================================================================= + // name : Filter_i::GetElementsId + // Purpose : Get ids of entities + //======================================================================= + void + Filter_i:: + GetElementsId( Predicate_i* thePredicate, + const SMDS_Mesh* theMesh, + Controls::Filter::TIdSequence& theSequence ) + { + if (thePredicate) + Controls::Filter::GetElementsId(theMesh,thePredicate->GetPredicate(),theSequence); + } + + void + Filter_i:: + GetElementsId( Predicate_i* thePredicate, + SMESH_Mesh_ptr theMesh, + Controls::Filter::TIdSequence& theSequence ) + { + if (thePredicate) + if(const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh)) + Controls::Filter::GetElementsId(aMesh,thePredicate->GetPredicate(),theSequence); + } + + SMESH::smIdType_array* + Filter_i:: + GetElementsId( SMESH_Mesh_ptr theMesh ) + { + SMESH::smIdType_array_var anArray = new SMESH::smIdType_array; + if(!CORBA::is_nil(theMesh) && myPredicate){ + theMesh->Load(); + Controls::Filter::TIdSequence aSequence; + GetElementsId(myPredicate,theMesh,aSequence); + long i = 0, iEnd = aSequence.size(); + anArray->length( iEnd ); + for ( ; i < iEnd; i++ ) + anArray[ i ] = aSequence[i]; + } + return anArray._retn(); + } + + SMESH::smIdType_array* + Filter_i:: + GetElementsIdFromParts( const ListOfIDSources& theParts ) + { + SMESH::smIdType_array_var array = new SMESH::smIdType_array; + if ( theParts.length() > 0 && myPredicate ) + { + SMESH_Mesh_ptr mesh = theParts[0]->GetMesh(); + mesh->Load(); + const SMDS_Mesh* meshDS = MeshPtr2SMDSMesh( mesh ); + Controls::Filter::TIdSequence totalSequence; + for ( CORBA::ULong i = 0; i < theParts.length(); ++i ) + { + if ( SMESH::Filter_i* filter = SMESH::DownCast( theParts[i] )) + filter->SetMesh( mesh ); + SMDS_ElemIteratorPtr iter = SMESH_Mesh_i::GetElements( theParts[i], GetElementType() ); + if ( iter && meshDS ) + { + Controls::Filter::TIdSequence sequence; + Controls::Filter::GetElementsId( meshDS, myPredicate->GetPredicate(), sequence, iter ); + totalSequence.insert( totalSequence.end(), sequence.begin(), sequence.end() ); + } + } + array->length( totalSequence.size() ); + for ( size_t i = 0; i < totalSequence.size(); ++i ) + array[ i ] = totalSequence[ i ]; + } + return array._retn(); + } + + //============================================================================= + /*! + * \brief Returns number of mesh elements per each \a EntityType + */ + //============================================================================= + + SMESH::smIdType_array* Filter_i::GetMeshInfo() + { + SMESH::smIdType_array_var aRes = new SMESH::smIdType_array(); + aRes->length(SMESH::Entity_Last); + for (int i = 0; i < SMESH::Entity_Last; i++) + aRes[i] = 0; + + if ( !CORBA::is_nil(myMesh) && myPredicate ) + { + const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh); + SMDS_ElemIteratorPtr it = aMesh->elementsIterator( SMDSAbs_ElementType( GetElementType() )); + while ( it->more() ) + { + const SMDS_MeshElement* anElem = it->next(); + if ( myPredicate->IsSatisfy( anElem->GetID() ) ) + aRes[ anElem->GetEntityType() ]++; + } + } + + return aRes._retn(); + } + + //============================================================================= + /*! + * \brief Returns number of mesh elements of each \a ElementType + */ + //============================================================================= + + SMESH::smIdType_array* Filter_i::GetNbElementsByType() + { + SMESH::smIdType_array_var aRes = new SMESH::smIdType_array(); + aRes->length(SMESH::NB_ELEMENT_TYPES); + for (int i = 0; i < SMESH::NB_ELEMENT_TYPES; i++) + aRes[i] = 0; + + if ( !CORBA::is_nil(myMesh) && myPredicate ) { + const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh); + SMDS_ElemIteratorPtr it = aMesh->elementsIterator( SMDSAbs_ElementType( GetElementType() )); + SMESH::smIdType& nbElems = aRes[ GetElementType() ]; + while ( it->more() ) + { + const SMDS_MeshElement* anElem = it->next(); + if ( myPredicate->IsSatisfy( anElem->GetID() ) ) + nbElems++; + } + } + + return aRes._retn(); + } + + + //================================================================================ + /*! + * \brief Return GetElementType() within an array + * Implement SMESH_IDSource interface + */ + //================================================================================ + + SMESH::array_of_ElementType* Filter_i::GetTypes() + { + SMESH::array_of_ElementType_var types = new SMESH::array_of_ElementType; + + // check if any element passes through the filter + if ( !CORBA::is_nil(myMesh) && myPredicate ) + { + const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh); + SMDS_ElemIteratorPtr it = aMesh->elementsIterator( SMDSAbs_ElementType( GetElementType() )); + bool satisfies = false; + while ( !satisfies && it->more() ) + satisfies = myPredicate->IsSatisfy( it->next()->GetID() ); + if ( satisfies ) { + types->length( 1 ); + types[0] = GetElementType(); + } + } + return types._retn(); + } + + //======================================================================= + //function : GetMesh + //purpose : Returns mesh + //======================================================================= + + SMESH::SMESH_Mesh_ptr Filter_i::GetMesh() + { + return SMESH_Mesh::_duplicate( myMesh ); + } + + //======================================================================= + //function : GetVtkUgStream + //purpose : Return data vtk unstructured grid (not implemented) + //======================================================================= + + SALOMEDS::TMPFile* Filter_i::GetVtkUgStream() + { + SALOMEDS::TMPFile_var SeqFile; + return SeqFile._retn(); + } + //======================================================================= + // name : getCriteria + // Purpose : Retrieve criterions from predicate + //======================================================================= + static inline void getPrediacates( Predicate_i* thePred, + std::vector & thePredVec ) + { + const int aFType = thePred->GetFunctorType(); + + switch ( aFType ) + { + case FT_LogicalNOT: { Predicate_i* aPred = ( dynamic_cast( thePred ) )->GetPredicate_i(); - getCriteria( aPred, theCriteria ); - theCriteria[ theCriteria->length() - 1 ].UnaryOp = FT_LogicalNOT; + getPrediacates( aPred, thePredVec ); + break; } - return true; - - case FT_LogicalAND: - case FT_LogicalOR: + case FT_LogicalAND: + case FT_LogicalOR: { Predicate_i* aPred1 = ( dynamic_cast( thePred ) )->GetPredicate1_i(); Predicate_i* aPred2 = ( dynamic_cast( thePred ) )->GetPredicate2_i(); - if ( !getCriteria( aPred1, theCriteria ) ) - return false; - theCriteria[ theCriteria->length() - 1 ].BinaryOp = aFType; - return getCriteria( aPred2, theCriteria ); + getPrediacates( aPred1, thePredVec ); + getPrediacates( aPred2, thePredVec ); + break; + } + default:; } - case FT_Undefined: - return false; + thePredVec.push_back( thePred ); } - // resize theCriteria - CORBA::ULong i = theCriteria->length(); - theCriteria->length( i + 1 ); - theCriteria[ i ] = createCriterion(); - - // set members of the added Criterion - - theCriteria[ i ].Type = aFType; - theCriteria[ i ].TypeOfElement = thePred->GetElementType(); - - switch ( aFType ) + //======================================================================= + // name : getCriteria + // Purpose : Retrieve criterions from predicate + //======================================================================= + static inline bool getCriteria( Predicate_i* thePred, + SMESH::Filter::Criteria_out theCriteria ) { - case FT_FreeBorders: - case FT_FreeEdges: - case FT_FreeFaces: - case FT_LinearOrQuadratic: - case FT_FreeNodes: - case FT_EqualEdges: - case FT_EqualFaces: - case FT_EqualVolumes: - case FT_BadOrientedVolume: - case FT_BareBorderVolume: - case FT_BareBorderFace: - case FT_OverConstrainedVolume: - case FT_OverConstrainedFace: + const int aFType = thePred->GetFunctorType(); + + switch ( aFType ) { - return true; - } - case FT_BelongToMeshGroup: - { - BelongToMeshGroup_i* aPred = dynamic_cast( thePred ); - SMESH::SMESH_GroupBase_var grp = aPred->GetGroup(); - if ( !grp->_is_nil() ) + case FT_LogicalNOT: { - theCriteria[ i ].ThresholdStr = grp->GetName(); - theCriteria[ i ].ThresholdID = aPred->GetGroupID().c_str(); + Predicate_i* aPred = ( dynamic_cast( thePred ) )->GetPredicate_i(); + getCriteria( aPred, theCriteria ); + theCriteria[ theCriteria->length() - 1 ].UnaryOp = FT_LogicalNOT; } return true; - } - case FT_BelongToGeom: - { - BelongToGeom_i* aPred = dynamic_cast( thePred ); - theCriteria[ i ].ThresholdStr = aPred->GetShapeName(); - theCriteria[ i ].ThresholdID = aPred->GetShapeID(); - theCriteria[ i ].Tolerance = aPred->GetTolerance(); - return true; - } - case FT_BelongToPlane: - case FT_BelongToCylinder: - case FT_BelongToGenSurface: - { - BelongToSurface_i* aPred = dynamic_cast( thePred ); - theCriteria[ i ].ThresholdStr = aPred->GetShapeName(); - theCriteria[ i ].ThresholdID = aPred->GetShapeID(); - theCriteria[ i ].Tolerance = aPred->GetTolerance(); - return true; - } - case FT_LyingOnGeom: - { - LyingOnGeom_i* aPred = dynamic_cast( thePred ); - theCriteria[ i ].ThresholdStr = aPred->GetShapeName(); - theCriteria[ i ].ThresholdID = aPred->GetShapeID(); - theCriteria[ i ].Tolerance = aPred->GetTolerance(); - return true; - } - case FT_CoplanarFaces: - { - CoplanarFaces_i* aPred = dynamic_cast( thePred ); - theCriteria[ i ].ThresholdID = aPred->GetFaceAsString(); - theCriteria[ i ].Tolerance = aPred->GetTolerance(); - return true; - } - case FT_ConnectedElements: - { - ConnectedElements_i* aPred = dynamic_cast( thePred ); - SMESH::ConnectedElements::ThresholdType type; - CORBA::String_var threshold = aPred->GetThreshold( type ); - switch ( type ) { - case SMESH::ConnectedElements::POINT: - theCriteria[ i ].ThresholdStr = threshold; break; - case SMESH::ConnectedElements::VERTEX: - theCriteria[ i ].ThresholdID = threshold; break; - case SMESH::ConnectedElements::NODE: - theCriteria[ i ].Threshold = atof( threshold.in() ); break; - default:; - } - return true; - } - case FT_EqualNodes: - { - EqualNodes_i* aPred = dynamic_cast( thePred ); - theCriteria[ i ].Tolerance = aPred->GetTolerance(); - return true; - } - case FT_RangeOfIds: - { - RangeOfIds_i* aPred = dynamic_cast( thePred ); - theCriteria[ i ].ThresholdStr = aPred->GetRangeStr(); - return true; - } - case FT_LessThan: - case FT_MoreThan: - case FT_EqualTo: - { - Comparator_i* aCompar = dynamic_cast( thePred ); - theCriteria[ i ].Type = aCompar->GetNumFunctor_i()->GetFunctorType(); - theCriteria[ i ].Compare = aFType; - theCriteria[ i ].Threshold = aCompar->GetMargin(); - if ( aFType == FT_EqualTo ) + + case FT_LogicalAND: + case FT_LogicalOR: { - EqualTo_i* aCompar = dynamic_cast( thePred ); - theCriteria[ i ].Tolerance = aCompar->GetTolerance(); + Predicate_i* aPred1 = ( dynamic_cast( thePred ) )->GetPredicate1_i(); + Predicate_i* aPred2 = ( dynamic_cast( thePred ) )->GetPredicate2_i(); + if ( !getCriteria( aPred1, theCriteria ) ) + return false; + theCriteria[ theCriteria->length() - 1 ].BinaryOp = aFType; + return getCriteria( aPred2, theCriteria ); } - return true; + case FT_Undefined: + return false; } - case FT_GroupColor: + + // resize theCriteria + CORBA::ULong i = theCriteria->length(); + theCriteria->length( i + 1 ); + theCriteria[ i ] = createCriterion(); + + // set members of the added Criterion + + theCriteria[ i ].Type = aFType; + theCriteria[ i ].TypeOfElement = thePred->GetElementType(); + + switch ( aFType ) { - GroupColor_i* aPred = dynamic_cast( thePred ); - theCriteria[ i ].ThresholdStr = aPred->GetColorStr(); - return true; + case FT_FreeBorders: + case FT_FreeEdges: + case FT_FreeFaces: + case FT_LinearOrQuadratic: + case FT_FreeNodes: + case FT_EqualEdges: + case FT_EqualFaces: + case FT_EqualVolumes: + case FT_BadOrientedVolume: + case FT_BareBorderVolume: + case FT_BareBorderFace: + case FT_OverConstrainedVolume: + case FT_OverConstrainedFace: + { + return true; + } + case FT_BelongToMeshGroup: + { + BelongToMeshGroup_i* aPred = dynamic_cast( thePred ); + SMESH::SMESH_GroupBase_var grp = aPred->GetGroup(); + if ( !grp->_is_nil() ) + { + theCriteria[ i ].ThresholdStr = grp->GetName(); + theCriteria[ i ].ThresholdID = aPred->GetGroupID().c_str(); + } + return true; + } + case FT_BelongToGeom: + { + BelongToGeom_i* aPred = dynamic_cast( thePred ); + theCriteria[ i ].ThresholdStr = aPred->GetShapeName(); + theCriteria[ i ].ThresholdID = aPred->GetShapeID(); + theCriteria[ i ].Tolerance = aPred->GetTolerance(); + return true; + } + case FT_BelongToPlane: + case FT_BelongToCylinder: + case FT_BelongToGenSurface: + { + BelongToSurface_i* aPred = dynamic_cast( thePred ); + theCriteria[ i ].ThresholdStr = aPred->GetShapeName(); + theCriteria[ i ].ThresholdID = aPred->GetShapeID(); + theCriteria[ i ].Tolerance = aPred->GetTolerance(); + return true; + } + case FT_LyingOnGeom: + { + LyingOnGeom_i* aPred = dynamic_cast( thePred ); + theCriteria[ i ].ThresholdStr = aPred->GetShapeName(); + theCriteria[ i ].ThresholdID = aPred->GetShapeID(); + theCriteria[ i ].Tolerance = aPred->GetTolerance(); + return true; + } + case FT_CoplanarFaces: + { + CoplanarFaces_i* aPred = dynamic_cast( thePred ); + theCriteria[ i ].ThresholdID = aPred->GetFaceAsString(); + theCriteria[ i ].Tolerance = aPred->GetTolerance(); + return true; + } + case FT_ConnectedElements: + { + ConnectedElements_i* aPred = dynamic_cast( thePred ); + SMESH::ConnectedElements::ThresholdType type; + CORBA::String_var threshold = aPred->GetThreshold( type ); + switch ( type ) { + case SMESH::ConnectedElements::POINT: + theCriteria[ i ].ThresholdStr = threshold; break; + case SMESH::ConnectedElements::VERTEX: + theCriteria[ i ].ThresholdID = threshold; break; + case SMESH::ConnectedElements::NODE: + theCriteria[ i ].Threshold = atof( threshold.in() ); break; + default:; + } + return true; + } + case FT_EqualNodes: + { + EqualNodes_i* aPred = dynamic_cast( thePred ); + theCriteria[ i ].Tolerance = aPred->GetTolerance(); + return true; + } + case FT_RangeOfIds: + { + RangeOfIds_i* aPred = dynamic_cast( thePred ); + theCriteria[ i ].ThresholdStr = aPred->GetRangeStr(); + return true; + } + case FT_LessThan: + case FT_MoreThan: + case FT_EqualTo: + { + Comparator_i* aCompar = dynamic_cast( thePred ); + theCriteria[ i ].Type = aCompar->GetNumFunctor_i()->GetFunctorType(); + theCriteria[ i ].Compare = aFType; + theCriteria[ i ].Threshold = aCompar->GetMargin(); + if ( aFType == FT_EqualTo ) + { + EqualTo_i* aCompar = dynamic_cast( thePred ); + theCriteria[ i ].Tolerance = aCompar->GetTolerance(); + } + return true; + } + case FT_GroupColor: + { + GroupColor_i* aPred = dynamic_cast( thePred ); + theCriteria[ i ].ThresholdStr = aPred->GetColorStr(); + return true; + } + case FT_ElemGeomType: + { + ElemGeomType_i* aPred = dynamic_cast( thePred ); + theCriteria[ i ].Threshold = (double)aPred->GetGeometryType(); + return true; + } + case FT_EntityType: + { + ElemEntityType_i* aPred = dynamic_cast( thePred ); + theCriteria[ i ].Threshold = (double)aPred->GetEntityType(); + return true; + } + default: + return false; } - case FT_ElemGeomType: - { - ElemGeomType_i* aPred = dynamic_cast( thePred ); - theCriteria[ i ].Threshold = (double)aPred->GetGeometryType(); - return true; - } - case FT_EntityType: - { - ElemEntityType_i* aPred = dynamic_cast( thePred ); - theCriteria[ i ].Threshold = (double)aPred->GetEntityType(); - return true; - } - default: - return false; } -} -//======================================================================= -// name : Filter_i::GetCriteria -// Purpose : Retrieve criterions from predicate -//======================================================================= -CORBA::Boolean Filter_i::GetCriteria( SMESH::Filter::Criteria_out theCriteria ) -{ - theCriteria = new SMESH::Filter::Criteria; - return myPredicate != 0 ? getCriteria( myPredicate, theCriteria ) : true; -} - -//======================================================================= -// name : Filter_i::SetCriteria -// Purpose : Create new predicate and set criterions in it -//======================================================================= -CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria ) -{ - SetPredicate( SMESH::Predicate::_nil() ); - - SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i(); - FilterManager_ptr aFilterMgr = aFilter->_this(); - - // CREATE two lists ( PREDICATES and LOG OP ) - - // Criterion - TPythonDump()<<"aCriteria = []"; - std::list aPredicates; - std::list aBinaries; - for ( int i = 0, n = theCriteria.length(); i < n; i++ ) + //======================================================================= + // name : Filter_i::GetCriteria + // Purpose : Retrieve criterions from predicate + //======================================================================= + CORBA::Boolean Filter_i::GetCriteria( SMESH::Filter::Criteria_out theCriteria ) { - int aCriterion = theCriteria[ i ].Type; - int aCompare = theCriteria[ i ].Compare; - double aThreshold = theCriteria[ i ].Threshold; - const char* aThresholdStr = theCriteria[ i ].ThresholdStr; - const char* aThresholdID = theCriteria[ i ].ThresholdID; - int aUnary = theCriteria[ i ].UnaryOp; - int aBinary = theCriteria[ i ].BinaryOp; - double aTolerance = theCriteria[ i ].Tolerance; - ElementType aTypeOfElem = theCriteria[ i ].TypeOfElement; - long aPrecision = theCriteria[ i ].Precision; + theCriteria = new SMESH::Filter::Criteria; + return myPredicate != 0 ? getCriteria( myPredicate, theCriteria ) : true; + } + //======================================================================= + // name : Filter_i::SetCriteria + // Purpose : Create new predicate and set criterions in it + //======================================================================= + CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria ) + { + SetPredicate( SMESH::Predicate::_nil() ); + + SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i(); + FilterManager_ptr aFilterMgr = aFilter->_this(); + + // CREATE two lists ( PREDICATES and LOG OP ) + + // Criterion + TPythonDump()<<"aCriteria = []"; + std::list aPredicates; + std::list aBinaries; + for ( int i = 0, n = theCriteria.length(); i < n; i++ ) { + int aCriterion = theCriteria[ i ].Type; + int aCompare = theCriteria[ i ].Compare; + double aThreshold = theCriteria[ i ].Threshold; + const char* aThresholdStr = theCriteria[ i ].ThresholdStr; + const char* aThresholdID = theCriteria[ i ].ThresholdID; + int aUnary = theCriteria[ i ].UnaryOp; + int aBinary = theCriteria[ i ].BinaryOp; + double aTolerance = theCriteria[ i ].Tolerance; + ElementType aTypeOfElem = theCriteria[ i ].TypeOfElement; + long aPrecision = theCriteria[ i ].Precision; + + { + TPythonDump pd; + pd << "aCriterion = SMESH.Filter.Criterion(" + << aCriterion << ", " + << aCompare << ", " + << aThreshold << ", '" + << aThresholdStr << "', '" + << aThresholdID << "', " + << aUnary << ", " + << aBinary << ", " + << aTolerance << ", " + << aTypeOfElem << ", " + << aPrecision << ")"; + } TPythonDump pd; - pd << "aCriterion = SMESH.Filter.Criterion(" - << aCriterion << ", " - << aCompare << ", " - << aThreshold << ", '" - << aThresholdStr << "', '" - << aThresholdID << "', " - << aUnary << ", " - << aBinary << ", " - << aTolerance << ", " - << aTypeOfElem << ", " - << aPrecision << ")"; - } - TPythonDump pd; - SMESH::Predicate_ptr aPredicate = SMESH::Predicate::_nil(); - SMESH::NumericalFunctor_ptr aFunctor = SMESH::NumericalFunctor::_nil(); + SMESH::Predicate_ptr aPredicate = SMESH::Predicate::_nil(); + SMESH::NumericalFunctor_ptr aFunctor = SMESH::NumericalFunctor::_nil(); - switch ( aCriterion ) - { - // Functors + switch ( aCriterion ) + { + // Functors - case SMESH::FT_MultiConnection: - aFunctor = aFilterMgr->CreateMultiConnection(); - break; - case SMESH::FT_MultiConnection2D: - aFunctor = aFilterMgr->CreateMultiConnection2D(); - break; - case SMESH::FT_Length: - aFunctor = aFilterMgr->CreateLength(); - break; - case SMESH::FT_Length2D: - aFunctor = aFilterMgr->CreateLength2D(); - break; - case SMESH::FT_Length3D: - aFunctor = aFilterMgr->CreateLength3D(); - break; - case SMESH::FT_Deflection2D: - aFunctor = aFilterMgr->CreateDeflection2D(); - break; - case SMESH::FT_AspectRatio: - aFunctor = aFilterMgr->CreateAspectRatio(); - break; - case SMESH::FT_AspectRatio3D: - aFunctor = aFilterMgr->CreateAspectRatio3D(); - break; - case SMESH::FT_Warping: - aFunctor = aFilterMgr->CreateWarping(); - break; - case SMESH::FT_MinimumAngle: - aFunctor = aFilterMgr->CreateMinimumAngle(); - break; - case SMESH::FT_Taper: - aFunctor = aFilterMgr->CreateTaper(); - break; - case SMESH::FT_Skew: - aFunctor = aFilterMgr->CreateSkew(); - break; - case SMESH::FT_Area: - aFunctor = aFilterMgr->CreateArea(); - break; - case SMESH::FT_Volume3D: - aFunctor = aFilterMgr->CreateVolume3D(); - break; - case SMESH::FT_MaxElementLength2D: - aFunctor = aFilterMgr->CreateMaxElementLength2D(); - break; - case SMESH::FT_MaxElementLength3D: - aFunctor = aFilterMgr->CreateMaxElementLength3D(); - break; - case SMESH::FT_BallDiameter: - aFunctor = aFilterMgr->CreateBallDiameter(); - break; - case SMESH::FT_NodeConnectivityNumber: - aFunctor = aFilterMgr->CreateNodeConnectivityNumber(); - break; - - // Predicates - - case SMESH::FT_FreeBorders: - aPredicate = aFilterMgr->CreateFreeBorders(); - break; - case SMESH::FT_FreeEdges: - aPredicate = aFilterMgr->CreateFreeEdges(); - break; - case SMESH::FT_FreeFaces: - aPredicate = aFilterMgr->CreateFreeFaces(); - break; - case SMESH::FT_FreeNodes: - aPredicate = aFilterMgr->CreateFreeNodes(); - break; - case SMESH::FT_EqualNodes: - { - SMESH::EqualNodes_ptr pred = aFilterMgr->CreateEqualNodes(); - pred->SetTolerance( aTolerance ); - aPredicate = pred; + case SMESH::FT_MultiConnection: + aFunctor = aFilterMgr->CreateMultiConnection(); break; - } - case SMESH::FT_EqualEdges: - aPredicate = aFilterMgr->CreateEqualEdges(); - break; - case SMESH::FT_EqualFaces: - aPredicate = aFilterMgr->CreateEqualFaces(); - break; - case SMESH::FT_EqualVolumes: - aPredicate = aFilterMgr->CreateEqualVolumes(); - break; - case SMESH::FT_BelongToMeshGroup: - { - SMESH::BelongToMeshGroup_ptr tmpPred = aFilterMgr->CreateBelongToMeshGroup(); - tmpPred->SetGroupID( aThresholdID ); - aPredicate = tmpPred; - } - break; - case SMESH::FT_BelongToGeom: - { - SMESH::BelongToGeom_ptr tmpPred = aFilterMgr->CreateBelongToGeom(); - tmpPred->SetElementType( aTypeOfElem ); - tmpPred->SetShape( aThresholdID, aThresholdStr ); - tmpPred->SetTolerance( aTolerance ); - aPredicate = tmpPred; - } - break; - case SMESH::FT_BelongToPlane: - case SMESH::FT_BelongToCylinder: - case SMESH::FT_BelongToGenSurface: - { - SMESH::BelongToSurface_ptr tmpPred; - switch ( aCriterion ) { - case SMESH::FT_BelongToPlane: - tmpPred = aFilterMgr->CreateBelongToPlane(); break; - case SMESH::FT_BelongToCylinder: - tmpPred = aFilterMgr->CreateBelongToCylinder(); break; - default: - tmpPred = aFilterMgr->CreateBelongToGenSurface(); + case SMESH::FT_MultiConnection2D: + aFunctor = aFilterMgr->CreateMultiConnection2D(); + break; + case SMESH::FT_Length: + aFunctor = aFilterMgr->CreateLength(); + break; + case SMESH::FT_Length2D: + aFunctor = aFilterMgr->CreateLength2D(); + break; + case SMESH::FT_Length3D: + aFunctor = aFilterMgr->CreateLength3D(); + break; + case SMESH::FT_Deflection2D: + aFunctor = aFilterMgr->CreateDeflection2D(); + break; + case SMESH::FT_AspectRatio: + aFunctor = aFilterMgr->CreateAspectRatio(); + break; + case SMESH::FT_AspectRatio3D: + aFunctor = aFilterMgr->CreateAspectRatio3D(); + break; + case SMESH::FT_Warping: + aFunctor = aFilterMgr->CreateWarping(); + break; + case SMESH::FT_MinimumAngle: + aFunctor = aFilterMgr->CreateMinimumAngle(); + break; + case SMESH::FT_Taper: + aFunctor = aFilterMgr->CreateTaper(); + break; + case SMESH::FT_Skew: + aFunctor = aFilterMgr->CreateSkew(); + break; + case SMESH::FT_Area: + aFunctor = aFilterMgr->CreateArea(); + break; + case SMESH::FT_Volume3D: + aFunctor = aFilterMgr->CreateVolume3D(); + break; + case SMESH::FT_MaxElementLength2D: + aFunctor = aFilterMgr->CreateMaxElementLength2D(); + break; + case SMESH::FT_MaxElementLength3D: + aFunctor = aFilterMgr->CreateMaxElementLength3D(); + break; + case SMESH::FT_BallDiameter: + aFunctor = aFilterMgr->CreateBallDiameter(); + break; + case SMESH::FT_NodeConnectivityNumber: + aFunctor = aFilterMgr->CreateNodeConnectivityNumber(); + break; + + // Predicates + + case SMESH::FT_FreeBorders: + aPredicate = aFilterMgr->CreateFreeBorders(); + break; + case SMESH::FT_FreeEdges: + aPredicate = aFilterMgr->CreateFreeEdges(); + break; + case SMESH::FT_FreeFaces: + aPredicate = aFilterMgr->CreateFreeFaces(); + break; + case SMESH::FT_FreeNodes: + aPredicate = aFilterMgr->CreateFreeNodes(); + break; + case SMESH::FT_EqualNodes: + { + SMESH::EqualNodes_ptr pred = aFilterMgr->CreateEqualNodes(); + pred->SetTolerance( aTolerance ); + aPredicate = pred; + break; } - tmpPred->SetShape( aThresholdID, aThresholdStr, aTypeOfElem ); - tmpPred->SetTolerance( aTolerance ); - aPredicate = tmpPred; - } - break; - case SMESH::FT_LyingOnGeom: - { - SMESH::LyingOnGeom_ptr tmpPred = aFilterMgr->CreateLyingOnGeom(); - tmpPred->SetElementType( aTypeOfElem ); - tmpPred->SetShape( aThresholdID, aThresholdStr ); - tmpPred->SetTolerance( aTolerance ); - aPredicate = tmpPred; - } - break; - case SMESH::FT_RangeOfIds: - { - SMESH::RangeOfIds_ptr tmpPred = aFilterMgr->CreateRangeOfIds(); - tmpPred->SetRangeStr( aThresholdStr ); - tmpPred->SetElementType( aTypeOfElem ); - aPredicate = tmpPred; - } - break; - case SMESH::FT_BadOrientedVolume: - { - aPredicate = aFilterMgr->CreateBadOrientedVolume(); - } - break; - case SMESH::FT_BareBorderVolume: - { - aPredicate = aFilterMgr->CreateBareBorderVolume(); - } - break; - case SMESH::FT_BareBorderFace: - { - aPredicate = aFilterMgr->CreateBareBorderFace(); - } - break; - case SMESH::FT_OverConstrainedVolume: - { - aPredicate = aFilterMgr->CreateOverConstrainedVolume(); - } - break; - case SMESH::FT_OverConstrainedFace: - { - aPredicate = aFilterMgr->CreateOverConstrainedFace(); - } - break; - case SMESH::FT_LinearOrQuadratic: - { - SMESH::LinearOrQuadratic_ptr tmpPred = aFilterMgr->CreateLinearOrQuadratic(); - tmpPred->SetElementType( aTypeOfElem ); - aPredicate = tmpPred; + case SMESH::FT_EqualEdges: + aPredicate = aFilterMgr->CreateEqualEdges(); break; - } - case SMESH::FT_GroupColor: - { - SMESH::GroupColor_ptr tmpPred = aFilterMgr->CreateGroupColor(); - tmpPred->SetElementType( aTypeOfElem ); - tmpPred->SetColorStr( aThresholdStr ); - aPredicate = tmpPred; + case SMESH::FT_EqualFaces: + aPredicate = aFilterMgr->CreateEqualFaces(); break; - } - case SMESH::FT_ElemGeomType: - { - SMESH::ElemGeomType_ptr tmpPred = aFilterMgr->CreateElemGeomType(); - tmpPred->SetElementType( aTypeOfElem ); - tmpPred->SetGeometryType( (GeometryType)(int)(aThreshold + 0.5) ); - aPredicate = tmpPred; + case SMESH::FT_EqualVolumes: + aPredicate = aFilterMgr->CreateEqualVolumes(); break; - } - case SMESH::FT_EntityType: - { - SMESH::ElemEntityType_ptr tmpPred = aFilterMgr->CreateElemEntityType(); - tmpPred->SetElementType( aTypeOfElem ); - tmpPred->SetEntityType( EntityType( (int (aThreshold + 0.5)))); - aPredicate = tmpPred; + case SMESH::FT_BelongToMeshGroup: + { + SMESH::BelongToMeshGroup_ptr tmpPred = aFilterMgr->CreateBelongToMeshGroup(); + tmpPred->SetGroupID( aThresholdID ); + aPredicate = tmpPred; + } break; - } - case SMESH::FT_CoplanarFaces: - { - SMESH::CoplanarFaces_ptr tmpPred = aFilterMgr->CreateCoplanarFaces(); - tmpPred->SetFace( atol (aThresholdID )); - tmpPred->SetTolerance( aTolerance ); - aPredicate = tmpPred; + case SMESH::FT_BelongToGeom: + { + SMESH::BelongToGeom_ptr tmpPred = aFilterMgr->CreateBelongToGeom(); + tmpPred->SetElementType( aTypeOfElem ); + tmpPred->SetShape( aThresholdID, aThresholdStr ); + tmpPred->SetTolerance( aTolerance ); + aPredicate = tmpPred; + } break; - } - case SMESH::FT_ConnectedElements: - { - SMESH::ConnectedElements_ptr tmpPred = aFilterMgr->CreateConnectedElements(); - if ( strlen( aThresholdID ) > 0 ) // shape ID - tmpPred->SetThreshold( aThresholdID, SMESH::ConnectedElements::VERTEX ); - else if ( strlen( aThresholdStr ) > 0 ) // point coords - tmpPred->SetThreshold( aThresholdStr, SMESH::ConnectedElements::POINT ); - else if ( aThreshold >= 1 ) - tmpPred->SetNode( (CORBA::Long) aThreshold ); // node ID - tmpPred->SetElementType( aTypeOfElem ); - aPredicate = tmpPred; + case SMESH::FT_BelongToPlane: + case SMESH::FT_BelongToCylinder: + case SMESH::FT_BelongToGenSurface: + { + SMESH::BelongToSurface_ptr tmpPred; + switch ( aCriterion ) { + case SMESH::FT_BelongToPlane: + tmpPred = aFilterMgr->CreateBelongToPlane(); break; + case SMESH::FT_BelongToCylinder: + tmpPred = aFilterMgr->CreateBelongToCylinder(); break; + default: + tmpPred = aFilterMgr->CreateBelongToGenSurface(); + } + tmpPred->SetShape( aThresholdID, aThresholdStr, aTypeOfElem ); + tmpPred->SetTolerance( aTolerance ); + aPredicate = tmpPred; + } break; + case SMESH::FT_LyingOnGeom: + { + SMESH::LyingOnGeom_ptr tmpPred = aFilterMgr->CreateLyingOnGeom(); + tmpPred->SetElementType( aTypeOfElem ); + tmpPred->SetShape( aThresholdID, aThresholdStr ); + tmpPred->SetTolerance( aTolerance ); + aPredicate = tmpPred; + } + break; + case SMESH::FT_RangeOfIds: + { + SMESH::RangeOfIds_ptr tmpPred = aFilterMgr->CreateRangeOfIds(); + tmpPred->SetRangeStr( aThresholdStr ); + tmpPred->SetElementType( aTypeOfElem ); + aPredicate = tmpPred; + } + break; + case SMESH::FT_BadOrientedVolume: + { + aPredicate = aFilterMgr->CreateBadOrientedVolume(); + } + break; + case SMESH::FT_BareBorderVolume: + { + aPredicate = aFilterMgr->CreateBareBorderVolume(); + } + break; + case SMESH::FT_BareBorderFace: + { + aPredicate = aFilterMgr->CreateBareBorderFace(); + } + break; + case SMESH::FT_OverConstrainedVolume: + { + aPredicate = aFilterMgr->CreateOverConstrainedVolume(); + } + break; + case SMESH::FT_OverConstrainedFace: + { + aPredicate = aFilterMgr->CreateOverConstrainedFace(); + } + break; + case SMESH::FT_LinearOrQuadratic: + { + SMESH::LinearOrQuadratic_ptr tmpPred = aFilterMgr->CreateLinearOrQuadratic(); + tmpPred->SetElementType( aTypeOfElem ); + aPredicate = tmpPred; + break; + } + case SMESH::FT_GroupColor: + { + SMESH::GroupColor_ptr tmpPred = aFilterMgr->CreateGroupColor(); + tmpPred->SetElementType( aTypeOfElem ); + tmpPred->SetColorStr( aThresholdStr ); + aPredicate = tmpPred; + break; + } + case SMESH::FT_ElemGeomType: + { + SMESH::ElemGeomType_ptr tmpPred = aFilterMgr->CreateElemGeomType(); + tmpPred->SetElementType( aTypeOfElem ); + tmpPred->SetGeometryType( (GeometryType)(int)(aThreshold + 0.5) ); + aPredicate = tmpPred; + break; + } + case SMESH::FT_EntityType: + { + SMESH::ElemEntityType_ptr tmpPred = aFilterMgr->CreateElemEntityType(); + tmpPred->SetElementType( aTypeOfElem ); + tmpPred->SetEntityType( EntityType( (int (aThreshold + 0.5)))); + aPredicate = tmpPred; + break; + } + case SMESH::FT_CoplanarFaces: + { + SMESH::CoplanarFaces_ptr tmpPred = aFilterMgr->CreateCoplanarFaces(); + tmpPred->SetFace( atol (aThresholdID )); + tmpPred->SetTolerance( aTolerance ); + aPredicate = tmpPred; + break; + } + case SMESH::FT_ConnectedElements: + { + SMESH::ConnectedElements_ptr tmpPred = aFilterMgr->CreateConnectedElements(); + if ( strlen( aThresholdID ) > 0 ) // shape ID + tmpPred->SetThreshold( aThresholdID, SMESH::ConnectedElements::VERTEX ); + else if ( strlen( aThresholdStr ) > 0 ) // point coords + tmpPred->SetThreshold( aThresholdStr, SMESH::ConnectedElements::POINT ); + else if ( aThreshold >= 1 ) + tmpPred->SetNode( (CORBA::Long) aThreshold ); // node ID + tmpPred->SetElementType( aTypeOfElem ); + aPredicate = tmpPred; + break; + } + + default: + continue; + } + + // Comparator + if ( !aFunctor->_is_nil() && aPredicate->_is_nil() ) + { + SMESH::Comparator_ptr aComparator = SMESH::Comparator::_nil(); + + if ( aCompare == SMESH::FT_LessThan ) + aComparator = aFilterMgr->CreateLessThan(); + else if ( aCompare == SMESH::FT_MoreThan ) + aComparator = aFilterMgr->CreateMoreThan(); + else if ( aCompare == SMESH::FT_EqualTo ) + aComparator = aFilterMgr->CreateEqualTo(); + else + continue; + + aComparator->SetNumFunctor( aFunctor ); + aComparator->SetMargin( aThreshold ); + + if ( aCompare == FT_EqualTo ) + { + SMESH::EqualTo_var anEqualTo = SMESH::EqualTo::_narrow( aComparator ); + anEqualTo->SetTolerance( aTolerance ); } - default: - continue; - } + aPredicate = aComparator; - // Comparator - if ( !aFunctor->_is_nil() && aPredicate->_is_nil() ) + aFunctor->SetPrecision( aPrecision ); + } + + // Logical not + if ( aUnary == FT_LogicalNOT ) + { + SMESH::LogicalNOT_ptr aNotPred = aFilterMgr->CreateLogicalNOT(); + aNotPred->SetPredicate( aPredicate ); + aPredicate = aNotPred; + } + + // logical op + aPredicates.push_back( aPredicate ); + aBinaries.push_back( aBinary ); + pd <<"aCriteria.append(aCriterion)"; + + } // end of for + TPythonDump pd; pd< aResList; + + std::list::iterator aPredIter; + std::list::iterator aBinaryIter; + + SMESH::Predicate_ptr aPrevPredicate = SMESH::Predicate::_nil(); + int aPrevBinary = SMESH::FT_Undefined; + if ( !aBinaries.empty() ) + aBinaries.back() = SMESH::FT_Undefined; + + for ( aPredIter = aPredicates.begin(), aBinaryIter = aBinaries.begin(); + aPredIter != aPredicates.end() && aBinaryIter != aBinaries.end(); + ++aPredIter, ++aBinaryIter ) { - SMESH::Comparator_ptr aComparator = SMESH::Comparator::_nil(); + int aCurrBinary = *aBinaryIter; - if ( aCompare == SMESH::FT_LessThan ) - aComparator = aFilterMgr->CreateLessThan(); - else if ( aCompare == SMESH::FT_MoreThan ) - aComparator = aFilterMgr->CreateMoreThan(); - else if ( aCompare == SMESH::FT_EqualTo ) - aComparator = aFilterMgr->CreateEqualTo(); + SMESH::Predicate_ptr aCurrPred = SMESH::Predicate::_nil(); + + if ( aPrevBinary == SMESH::FT_LogicalAND ) + { + + SMESH::LogicalBinary_ptr aBinaryPred = aFilterMgr->CreateLogicalAND(); + aBinaryPred->SetPredicate1( aPrevPredicate ); + aBinaryPred->SetPredicate2( *aPredIter ); + aCurrPred = aBinaryPred; + } else - continue; + aCurrPred = *aPredIter; - aComparator->SetNumFunctor( aFunctor ); - aComparator->SetMargin( aThreshold ); + if ( aCurrBinary != SMESH::FT_LogicalAND ) + aResList.push_back( aCurrPred ); - if ( aCompare == FT_EqualTo ) + aPrevPredicate = aCurrPred; + aPrevBinary = aCurrBinary; + } + + // combine all "OR" operations + + SMESH::Predicate_ptr aResPredicate = SMESH::Predicate::_nil(); + + if ( aResList.size() == 1 ) + aResPredicate = *aResList.begin(); + else if ( aResList.size() > 1 ) + { + std::list::iterator anIter = aResList.begin(); + aResPredicate = *anIter; + anIter++; + for ( ; anIter != aResList.end(); ++anIter ) { - SMESH::EqualTo_var anEqualTo = SMESH::EqualTo::_narrow( aComparator ); - anEqualTo->SetTolerance( aTolerance ); + SMESH::LogicalBinary_ptr aBinaryPred = aFilterMgr->CreateLogicalOR(); + aBinaryPred->SetPredicate1( aResPredicate ); + aBinaryPred->SetPredicate2( *anIter ); + aResPredicate = aBinaryPred; } - - aPredicate = aComparator; - - aFunctor->SetPrecision( aPrecision ); } - // Logical not - if ( aUnary == FT_LogicalNOT ) - { - SMESH::LogicalNOT_ptr aNotPred = aFilterMgr->CreateLogicalNOT(); - aNotPred->SetPredicate( aPredicate ); - aPredicate = aNotPred; - } + SetPredicate( aResPredicate ); + if ( !aResPredicate->_is_nil() ) + aResPredicate->UnRegister(); - // logical op - aPredicates.push_back( aPredicate ); - aBinaries.push_back( aBinary ); - pd <<"aCriteria.append(aCriterion)"; + return !aResPredicate->_is_nil(); + } - } // end of for - TPythonDump pd; pd< aResList; - - std::list::iterator aPredIter; - std::list::iterator aBinaryIter; - - SMESH::Predicate_ptr aPrevPredicate = SMESH::Predicate::_nil(); - int aPrevBinary = SMESH::FT_Undefined; - if ( !aBinaries.empty() ) - aBinaries.back() = SMESH::FT_Undefined; - - for ( aPredIter = aPredicates.begin(), aBinaryIter = aBinaries.begin(); - aPredIter != aPredicates.end() && aBinaryIter != aBinaries.end(); - ++aPredIter, ++aBinaryIter ) + //======================================================================= + // name : Filter_i::GetPredicate_i + // Purpose : Get implementation of predicate + //======================================================================= + Predicate_i* Filter_i::GetPredicate_i() { - int aCurrBinary = *aBinaryIter; + return myPredicate; + } - SMESH::Predicate_ptr aCurrPred = SMESH::Predicate::_nil(); - - if ( aPrevBinary == SMESH::FT_LogicalAND ) - { - - SMESH::LogicalBinary_ptr aBinaryPred = aFilterMgr->CreateLogicalAND(); - aBinaryPred->SetPredicate1( aPrevPredicate ); - aBinaryPred->SetPredicate2( *aPredIter ); - aCurrPred = aBinaryPred; - } + //======================================================================= + // name : Filter_i::GetPredicate + // Purpose : Get predicate + //======================================================================= + Predicate_ptr Filter_i::GetPredicate() + { + if ( myPredicate == 0 ) + return SMESH::Predicate::_nil(); else - aCurrPred = *aPredIter; - - if ( aCurrBinary != SMESH::FT_LogicalAND ) - aResList.push_back( aCurrPred ); - - aPrevPredicate = aCurrPred; - aPrevBinary = aCurrBinary; - } - - // combine all "OR" operations - - SMESH::Predicate_ptr aResPredicate = SMESH::Predicate::_nil(); - - if ( aResList.size() == 1 ) - aResPredicate = *aResList.begin(); - else if ( aResList.size() > 1 ) - { - std::list::iterator anIter = aResList.begin(); - aResPredicate = *anIter; - anIter++; - for ( ; anIter != aResList.end(); ++anIter ) { - SMESH::LogicalBinary_ptr aBinaryPred = aFilterMgr->CreateLogicalOR(); - aBinaryPred->SetPredicate1( aResPredicate ); - aBinaryPred->SetPredicate2( *anIter ); - aResPredicate = aBinaryPred; + SMESH::Predicate_var anObj = myPredicate->_this(); + // if ( SMESH::Functor_i* fun = SMESH::DownCast( anObj )) + // TPythonDump() << fun << " = " << this << ".GetPredicate()"; + return anObj._retn(); } } - SetPredicate( aResPredicate ); - if ( !aResPredicate->_is_nil() ) - aResPredicate->UnRegister(); + //================================================================================ + /*! + * \brief Find groups it depends on + */ + //================================================================================ - return !aResPredicate->_is_nil(); -} - -//======================================================================= -// name : Filter_i::GetPredicate_i -// Purpose : Get implementation of predicate -//======================================================================= -Predicate_i* Filter_i::GetPredicate_i() -{ - return myPredicate; -} - -//======================================================================= -// name : Filter_i::GetPredicate -// Purpose : Get predicate -//======================================================================= -Predicate_ptr Filter_i::GetPredicate() -{ - if ( myPredicate == 0 ) - return SMESH::Predicate::_nil(); - else + void Filter_i::FindBaseObjects() { - SMESH::Predicate_var anObj = myPredicate->_this(); - // if ( SMESH::Functor_i* fun = SMESH::DownCast( anObj )) - // TPythonDump() << fun << " = " << this << ".GetPredicate()"; - return anObj._retn(); - } -} + // release current groups + for ( size_t i = 0; i < myBaseGroups.size(); ++i ) + if ( myBaseGroups[i] ) + { + myBaseGroups[i]->RemoveModifWaiter( this ); + myBaseGroups[i]->UnRegister(); + } -//================================================================================ -/*! - * \brief Find groups it depends on - */ -//================================================================================ - -void Filter_i::FindBaseObjects() -{ - // release current groups - for ( size_t i = 0; i < myBaseGroups.size(); ++i ) - if ( myBaseGroups[i] ) + // remember new groups + myBaseGroups.clear(); + if ( myPredicate ) { - myBaseGroups[i]->RemoveModifWaiter( this ); - myBaseGroups[i]->UnRegister(); + std::vector predicates; + getPrediacates( myPredicate, predicates ); + for ( size_t i = 0; i < predicates.size(); ++i ) + if ( BelongToMeshGroup_i* bmg = dynamic_cast< BelongToMeshGroup_i* >( predicates[i] )) + { + SMESH::SMESH_GroupBase_var g = bmg->GetGroup(); + SMESH_GroupBase_i* g_i = SMESH::DownCast< SMESH_GroupBase_i*>( g ); + if ( g_i ) + { + g_i->AddModifWaiter( this ); + g_i->Register(); + myBaseGroups.push_back( g_i ); + } + } + } + } + + //================================================================================ + /*! + * \brief When notified on removal of myBaseGroups[i], remove a reference to a + * group from a predicate + */ + //================================================================================ + + void Filter_i::OnBaseObjModified(NotifyerAndWaiter* group, bool removed) + { + if ( !removed ) + return; // a GroupOnFilter holding this filter is notified automatically + + if ( myPredicate ) + { + std::vector predicates; + getPrediacates( myPredicate, predicates ); + for ( size_t i = 0; i < predicates.size(); ++i ) + if ( BelongToMeshGroup_i* bmg = dynamic_cast< BelongToMeshGroup_i* >( predicates[i] )) + { + SMESH::SMESH_GroupBase_var g = bmg->GetGroup(); + SMESH_GroupBase_i* g_i = SMESH::DownCast< SMESH_GroupBase_i*>( g ); + if ( g_i == group ) + { + bmg->SetGroup( SMESH::SMESH_GroupBase::_nil() ); + bmg->SetGroupID( "" ); + } + } } - // remember new groups - myBaseGroups.clear(); - if ( myPredicate ) + FindBaseObjects(); // release and update myBaseGroups; + } + + /* + FILTER LIBRARY + */ + + #define ATTR_TYPE "type" + #define ATTR_COMPARE "compare" + #define ATTR_THRESHOLD "threshold" + #define ATTR_UNARY "unary" + #define ATTR_BINARY "binary" + #define ATTR_THRESHOLD_STR "threshold_str" + #define ATTR_TOLERANCE "tolerance" + #define ATTR_ELEMENT_TYPE "ElementType" + + //======================================================================= + // name : toString + // Purpose : Convert bool to LDOMString + //======================================================================= + static inline LDOMString toString( CORBA::Boolean val ) { - std::vector predicates; - getPrediacates( myPredicate, predicates ); - for ( size_t i = 0; i < predicates.size(); ++i ) - if ( BelongToMeshGroup_i* bmg = dynamic_cast< BelongToMeshGroup_i* >( predicates[i] )) + return val ? "logical not" : ""; + } + + //======================================================================= + // name : toBool + // Purpose : Convert LDOMString to bool + //======================================================================= + static inline bool toBool( const LDOMString& theStr ) + { + return theStr.equals( "logical not" ); + } + + //======================================================================= + // name : toString + // Purpose : Convert double to LDOMString + //======================================================================= + static inline LDOMString toString( CORBA::Double val ) + { + char a[ 255 ]; + sprintf( a, "%e", val ); + return LDOMString( a ); + } + + //======================================================================= + // name : toDouble + // Purpose : Convert LDOMString to double + //======================================================================= + static inline double toDouble( const LDOMString& theStr ) + { + return atof( theStr.GetString() ); + } + + //======================================================================= + // name : toString + // Purpose : Convert functor type to LDOMString + //======================================================================= + static inline LDOMString toString( CORBA::Long theType ) + { + switch ( theType ) + { + case FT_AspectRatio : return "Aspect ratio"; + case FT_Warping : return "Warping"; + case FT_MinimumAngle : return "Minimum angle"; + case FT_Taper : return "Taper"; + case FT_Skew : return "Skew"; + case FT_Area : return "Area"; + case FT_Volume3D : return "Volume3D"; + case FT_MaxElementLength2D : return "Max element length 2D"; + case FT_MaxElementLength3D : return "Max element length 3D"; + case FT_BelongToMeshGroup : return "Belong to Mesh Group"; + case FT_BelongToGeom : return "Belong to Geom"; + case FT_BelongToPlane : return "Belong to Plane"; + case FT_BelongToCylinder : return "Belong to Cylinder"; + case FT_BelongToGenSurface : return "Belong to Generic Surface"; + case FT_LyingOnGeom : return "Lying on Geom"; + case FT_BadOrientedVolume : return "Bad Oriented Volume"; + case FT_BareBorderVolume : return "Volumes with bare border"; + case FT_BareBorderFace : return "Faces with bare border"; + case FT_OverConstrainedVolume : return "Over-constrained Volumes"; + case FT_OverConstrainedFace : return "Over-constrained Faces"; + case FT_RangeOfIds : return "Range of IDs"; + case FT_FreeBorders : return "Free borders"; + case FT_FreeEdges : return "Free edges"; + case FT_FreeFaces : return "Free faces"; + case FT_FreeNodes : return "Free nodes"; + case FT_EqualNodes : return "Equal nodes"; + case FT_EqualEdges : return "Equal edges"; + case FT_EqualFaces : return "Equal faces"; + case FT_EqualVolumes : return "Equal volumes"; + case FT_MultiConnection : return "Borders at multi-connections"; + case FT_MultiConnection2D : return "Borders at multi-connections 2D"; + case FT_Length : return "Length"; + case FT_Length2D : return "Length 2D"; + case FT_Length3D : return "Length 3D"; + case FT_Deflection2D : return "Deflection 2D"; + case FT_LessThan : return "Less than"; + case FT_MoreThan : return "More than"; + case FT_EqualTo : return "Equal to"; + case FT_LogicalNOT : return "Not"; + case FT_LogicalAND : return "And"; + case FT_LogicalOR : return "Or"; + case FT_GroupColor : return "Color of Group"; + case FT_LinearOrQuadratic : return "Linear or Quadratic"; + case FT_ElemGeomType : return "Element geometry type"; + case FT_EntityType : return "Entity type"; + case FT_Undefined : return ""; + default : return ""; + } + } + + //======================================================================= + // name : toFunctorType + // Purpose : Convert LDOMString to functor type + //======================================================================= + static inline SMESH::FunctorType toFunctorType( const LDOMString& theStr ) + { + if ( theStr.equals( "Aspect ratio" ) ) return FT_AspectRatio; + else if ( theStr.equals( "Warping" ) ) return FT_Warping; + else if ( theStr.equals( "Minimum angle" ) ) return FT_MinimumAngle; + else if ( theStr.equals( "Taper" ) ) return FT_Taper; + else if ( theStr.equals( "Skew" ) ) return FT_Skew; + else if ( theStr.equals( "Area" ) ) return FT_Area; + else if ( theStr.equals( "Volume3D" ) ) return FT_Volume3D; + else if ( theStr.equals( "Max element length 2D" ) ) return FT_MaxElementLength2D; + else if ( theStr.equals( "Max element length 3D" ) ) return FT_MaxElementLength3D; + else if ( theStr.equals( "Belong to Mesh Group" ) ) return FT_BelongToMeshGroup; + else if ( theStr.equals( "Belong to Geom" ) ) return FT_BelongToGeom; + else if ( theStr.equals( "Belong to Plane" ) ) return FT_BelongToPlane; + else if ( theStr.equals( "Belong to Cylinder" ) ) return FT_BelongToCylinder; + else if ( theStr.equals( "Belong to Generic Surface" ) ) return FT_BelongToGenSurface; + else if ( theStr.equals( "Lying on Geom" ) ) return FT_LyingOnGeom; + else if ( theStr.equals( "Free borders" ) ) return FT_FreeBorders; + else if ( theStr.equals( "Free edges" ) ) return FT_FreeEdges; + else if ( theStr.equals( "Free faces" ) ) return FT_FreeFaces; + else if ( theStr.equals( "Free nodes" ) ) return FT_FreeNodes; + else if ( theStr.equals( "Equal nodes" ) ) return FT_EqualNodes; + else if ( theStr.equals( "Equal edges" ) ) return FT_EqualEdges; + else if ( theStr.equals( "Equal faces" ) ) return FT_EqualFaces; + else if ( theStr.equals( "Equal volumes" ) ) return FT_EqualVolumes; + else if ( theStr.equals( "Borders at multi-connections" ) ) return FT_MultiConnection; + // else if ( theStr.equals( "Borders at multi-connections 2D" ) ) return FT_MultiConnection2D; + else if ( theStr.equals( "Length" ) ) return FT_Length; + // else if ( theStr.equals( "Length2D" ) ) return FT_Length2D; + // else if ( theStr.equals( "Length3D" ) ) return FT_Length3D; + else if ( theStr.equals( "Deflection" ) ) return FT_Deflection2D; + else if ( theStr.equals( "Range of IDs" ) ) return FT_RangeOfIds; + else if ( theStr.equals( "Bad Oriented Volume" ) ) return FT_BadOrientedVolume; + else if ( theStr.equals( "Volumes with bare border" ) ) return FT_BareBorderVolume; + else if ( theStr.equals( "Faces with bare border" ) ) return FT_BareBorderFace; + else if ( theStr.equals( "Over-constrained Volumes" ) ) return FT_OverConstrainedVolume; + else if ( theStr.equals( "Over-constrained Faces" ) ) return FT_OverConstrainedFace; + else if ( theStr.equals( "Less than" ) ) return FT_LessThan; + else if ( theStr.equals( "More than" ) ) return FT_MoreThan; + else if ( theStr.equals( "Equal to" ) ) return FT_EqualTo; + else if ( theStr.equals( "Not" ) ) return FT_LogicalNOT; + else if ( theStr.equals( "And" ) ) return FT_LogicalAND; + else if ( theStr.equals( "Or" ) ) return FT_LogicalOR; + else if ( theStr.equals( "Color of Group" ) ) return FT_GroupColor; + else if ( theStr.equals( "Linear or Quadratic" ) ) return FT_LinearOrQuadratic; + else if ( theStr.equals( "Element geometry type" ) ) return FT_ElemGeomType; + else if ( theStr.equals( "Entity type" ) ) return FT_EntityType; + else if ( theStr.equals( "" ) ) return FT_Undefined; + else return FT_Undefined; + } + + //======================================================================= + // name : toFunctorType + // Purpose : Convert LDOMString to value of ElementType enumeration + //======================================================================= + static inline SMESH::ElementType toElementType( const LDOMString& theStr ) + { + if ( theStr.equals( "NODE" ) ) return SMESH::NODE; + else if ( theStr.equals( "EDGE" ) ) return SMESH::EDGE; + else if ( theStr.equals( "FACE" ) ) return SMESH::FACE; + else if ( theStr.equals( "VOLUME" ) ) return SMESH::VOLUME; + else return SMESH::ALL; + } + + //======================================================================= + // name : toString + // Purpose : Convert ElementType to string + //======================================================================= + static inline LDOMString toString( const SMESH::ElementType theType ) + { + switch ( theType ) + { + case SMESH::NODE : return "NODE"; + case SMESH::EDGE : return "EDGE"; + case SMESH::FACE : return "FACE"; + case SMESH::VOLUME : return "VOLUME"; + case SMESH::ALL : return "ALL"; + default : return ""; + } + } + + //======================================================================= + // name : findFilter + // Purpose : Find filter in document + //======================================================================= + static LDOM_Element findFilter( const char* theFilterName, + const LDOM_Document& theDoc, + LDOM_Node* theParent = 0 ) + { + LDOM_Element aRootElement = theDoc.getDocumentElement(); + if ( aRootElement.isNull() || !aRootElement.hasChildNodes() ) + return LDOM_Element(); + + for ( LDOM_Node aTypeNode = aRootElement.getFirstChild(); + !aTypeNode.isNull(); aTypeNode = aTypeNode.getNextSibling() ) + { + for ( LDOM_Node aFilter = aTypeNode.getFirstChild(); + !aFilter.isNull(); aFilter = aFilter.getNextSibling() ) { - SMESH::SMESH_GroupBase_var g = bmg->GetGroup(); - SMESH_GroupBase_i* g_i = SMESH::DownCast< SMESH_GroupBase_i*>( g ); - if ( g_i ) + LDOM_Element* anElem = ( LDOM_Element* )&aFilter; + if ( anElem->getTagName().equals( LDOMString( "filter" ) ) && + anElem->getAttribute( "name" ).equals( LDOMString( theFilterName ) ) ) { - g_i->AddModifWaiter( this ); - g_i->Register(); - myBaseGroups.push_back( g_i ); + if ( theParent != 0 ) + *theParent = aTypeNode; + return (LDOM_Element&)aFilter; } } - } -} - -//================================================================================ -/*! - * \brief When notified on removal of myBaseGroups[i], remove a reference to a - * group from a predicate - */ -//================================================================================ - -void Filter_i::OnBaseObjModified(NotifyerAndWaiter* group, bool removed) -{ - if ( !removed ) - return; // a GroupOnFilter holding this filter is notified automatically - - if ( myPredicate ) - { - std::vector predicates; - getPrediacates( myPredicate, predicates ); - for ( size_t i = 0; i < predicates.size(); ++i ) - if ( BelongToMeshGroup_i* bmg = dynamic_cast< BelongToMeshGroup_i* >( predicates[i] )) - { - SMESH::SMESH_GroupBase_var g = bmg->GetGroup(); - SMESH_GroupBase_i* g_i = SMESH::DownCast< SMESH_GroupBase_i*>( g ); - if ( g_i == group ) - { - bmg->SetGroup( SMESH::SMESH_GroupBase::_nil() ); - bmg->SetGroupID( "" ); - } - } - } - - FindBaseObjects(); // release and update myBaseGroups; -} - -/* - FILTER LIBRARY -*/ - -#define ATTR_TYPE "type" -#define ATTR_COMPARE "compare" -#define ATTR_THRESHOLD "threshold" -#define ATTR_UNARY "unary" -#define ATTR_BINARY "binary" -#define ATTR_THRESHOLD_STR "threshold_str" -#define ATTR_TOLERANCE "tolerance" -#define ATTR_ELEMENT_TYPE "ElementType" - -//======================================================================= -// name : toString -// Purpose : Convert bool to LDOMString -//======================================================================= -static inline LDOMString toString( CORBA::Boolean val ) -{ - return val ? "logical not" : ""; -} - -//======================================================================= -// name : toBool -// Purpose : Convert LDOMString to bool -//======================================================================= -static inline bool toBool( const LDOMString& theStr ) -{ - return theStr.equals( "logical not" ); -} - -//======================================================================= -// name : toString -// Purpose : Convert double to LDOMString -//======================================================================= -static inline LDOMString toString( CORBA::Double val ) -{ - char a[ 255 ]; - sprintf( a, "%e", val ); - return LDOMString( a ); -} - -//======================================================================= -// name : toDouble -// Purpose : Convert LDOMString to double -//======================================================================= -static inline double toDouble( const LDOMString& theStr ) -{ - return atof( theStr.GetString() ); -} - -//======================================================================= -// name : toString -// Purpose : Convert functor type to LDOMString -//======================================================================= -static inline LDOMString toString( CORBA::Long theType ) -{ - switch ( theType ) - { - case FT_AspectRatio : return "Aspect ratio"; - case FT_Warping : return "Warping"; - case FT_MinimumAngle : return "Minimum angle"; - case FT_Taper : return "Taper"; - case FT_Skew : return "Skew"; - case FT_Area : return "Area"; - case FT_Volume3D : return "Volume3D"; - case FT_MaxElementLength2D : return "Max element length 2D"; - case FT_MaxElementLength3D : return "Max element length 3D"; - case FT_BelongToMeshGroup : return "Belong to Mesh Group"; - case FT_BelongToGeom : return "Belong to Geom"; - case FT_BelongToPlane : return "Belong to Plane"; - case FT_BelongToCylinder : return "Belong to Cylinder"; - case FT_BelongToGenSurface : return "Belong to Generic Surface"; - case FT_LyingOnGeom : return "Lying on Geom"; - case FT_BadOrientedVolume : return "Bad Oriented Volume"; - case FT_BareBorderVolume : return "Volumes with bare border"; - case FT_BareBorderFace : return "Faces with bare border"; - case FT_OverConstrainedVolume : return "Over-constrained Volumes"; - case FT_OverConstrainedFace : return "Over-constrained Faces"; - case FT_RangeOfIds : return "Range of IDs"; - case FT_FreeBorders : return "Free borders"; - case FT_FreeEdges : return "Free edges"; - case FT_FreeFaces : return "Free faces"; - case FT_FreeNodes : return "Free nodes"; - case FT_EqualNodes : return "Equal nodes"; - case FT_EqualEdges : return "Equal edges"; - case FT_EqualFaces : return "Equal faces"; - case FT_EqualVolumes : return "Equal volumes"; - case FT_MultiConnection : return "Borders at multi-connections"; - case FT_MultiConnection2D : return "Borders at multi-connections 2D"; - case FT_Length : return "Length"; - case FT_Length2D : return "Length 2D"; - case FT_Length3D : return "Length 3D"; - case FT_Deflection2D : return "Deflection 2D"; - case FT_LessThan : return "Less than"; - case FT_MoreThan : return "More than"; - case FT_EqualTo : return "Equal to"; - case FT_LogicalNOT : return "Not"; - case FT_LogicalAND : return "And"; - case FT_LogicalOR : return "Or"; - case FT_GroupColor : return "Color of Group"; - case FT_LinearOrQuadratic : return "Linear or Quadratic"; - case FT_ElemGeomType : return "Element geometry type"; - case FT_EntityType : return "Entity type"; - case FT_Undefined : return ""; - default : return ""; - } -} - -//======================================================================= -// name : toFunctorType -// Purpose : Convert LDOMString to functor type -//======================================================================= -static inline SMESH::FunctorType toFunctorType( const LDOMString& theStr ) -{ - if ( theStr.equals( "Aspect ratio" ) ) return FT_AspectRatio; - else if ( theStr.equals( "Warping" ) ) return FT_Warping; - else if ( theStr.equals( "Minimum angle" ) ) return FT_MinimumAngle; - else if ( theStr.equals( "Taper" ) ) return FT_Taper; - else if ( theStr.equals( "Skew" ) ) return FT_Skew; - else if ( theStr.equals( "Area" ) ) return FT_Area; - else if ( theStr.equals( "Volume3D" ) ) return FT_Volume3D; - else if ( theStr.equals( "Max element length 2D" ) ) return FT_MaxElementLength2D; - else if ( theStr.equals( "Max element length 3D" ) ) return FT_MaxElementLength3D; - else if ( theStr.equals( "Belong to Mesh Group" ) ) return FT_BelongToMeshGroup; - else if ( theStr.equals( "Belong to Geom" ) ) return FT_BelongToGeom; - else if ( theStr.equals( "Belong to Plane" ) ) return FT_BelongToPlane; - else if ( theStr.equals( "Belong to Cylinder" ) ) return FT_BelongToCylinder; - else if ( theStr.equals( "Belong to Generic Surface" ) ) return FT_BelongToGenSurface; - else if ( theStr.equals( "Lying on Geom" ) ) return FT_LyingOnGeom; - else if ( theStr.equals( "Free borders" ) ) return FT_FreeBorders; - else if ( theStr.equals( "Free edges" ) ) return FT_FreeEdges; - else if ( theStr.equals( "Free faces" ) ) return FT_FreeFaces; - else if ( theStr.equals( "Free nodes" ) ) return FT_FreeNodes; - else if ( theStr.equals( "Equal nodes" ) ) return FT_EqualNodes; - else if ( theStr.equals( "Equal edges" ) ) return FT_EqualEdges; - else if ( theStr.equals( "Equal faces" ) ) return FT_EqualFaces; - else if ( theStr.equals( "Equal volumes" ) ) return FT_EqualVolumes; - else if ( theStr.equals( "Borders at multi-connections" ) ) return FT_MultiConnection; - // else if ( theStr.equals( "Borders at multi-connections 2D" ) ) return FT_MultiConnection2D; - else if ( theStr.equals( "Length" ) ) return FT_Length; - // else if ( theStr.equals( "Length2D" ) ) return FT_Length2D; - // else if ( theStr.equals( "Length3D" ) ) return FT_Length3D; - else if ( theStr.equals( "Deflection" ) ) return FT_Deflection2D; - else if ( theStr.equals( "Range of IDs" ) ) return FT_RangeOfIds; - else if ( theStr.equals( "Bad Oriented Volume" ) ) return FT_BadOrientedVolume; - else if ( theStr.equals( "Volumes with bare border" ) ) return FT_BareBorderVolume; - else if ( theStr.equals( "Faces with bare border" ) ) return FT_BareBorderFace; - else if ( theStr.equals( "Over-constrained Volumes" ) ) return FT_OverConstrainedVolume; - else if ( theStr.equals( "Over-constrained Faces" ) ) return FT_OverConstrainedFace; - else if ( theStr.equals( "Less than" ) ) return FT_LessThan; - else if ( theStr.equals( "More than" ) ) return FT_MoreThan; - else if ( theStr.equals( "Equal to" ) ) return FT_EqualTo; - else if ( theStr.equals( "Not" ) ) return FT_LogicalNOT; - else if ( theStr.equals( "And" ) ) return FT_LogicalAND; - else if ( theStr.equals( "Or" ) ) return FT_LogicalOR; - else if ( theStr.equals( "Color of Group" ) ) return FT_GroupColor; - else if ( theStr.equals( "Linear or Quadratic" ) ) return FT_LinearOrQuadratic; - else if ( theStr.equals( "Element geometry type" ) ) return FT_ElemGeomType; - else if ( theStr.equals( "Entity type" ) ) return FT_EntityType; - else if ( theStr.equals( "" ) ) return FT_Undefined; - else return FT_Undefined; -} - -//======================================================================= -// name : toFunctorType -// Purpose : Convert LDOMString to value of ElementType enumeration -//======================================================================= -static inline SMESH::ElementType toElementType( const LDOMString& theStr ) -{ - if ( theStr.equals( "NODE" ) ) return SMESH::NODE; - else if ( theStr.equals( "EDGE" ) ) return SMESH::EDGE; - else if ( theStr.equals( "FACE" ) ) return SMESH::FACE; - else if ( theStr.equals( "VOLUME" ) ) return SMESH::VOLUME; - else return SMESH::ALL; -} - -//======================================================================= -// name : toString -// Purpose : Convert ElementType to string -//======================================================================= -static inline LDOMString toString( const SMESH::ElementType theType ) -{ - switch ( theType ) - { - case SMESH::NODE : return "NODE"; - case SMESH::EDGE : return "EDGE"; - case SMESH::FACE : return "FACE"; - case SMESH::VOLUME : return "VOLUME"; - case SMESH::ALL : return "ALL"; - default : return ""; - } -} - -//======================================================================= -// name : findFilter -// Purpose : Find filter in document -//======================================================================= -static LDOM_Element findFilter( const char* theFilterName, - const LDOM_Document& theDoc, - LDOM_Node* theParent = 0 ) -{ - LDOM_Element aRootElement = theDoc.getDocumentElement(); - if ( aRootElement.isNull() || !aRootElement.hasChildNodes() ) + } return LDOM_Element(); - - for ( LDOM_Node aTypeNode = aRootElement.getFirstChild(); - !aTypeNode.isNull(); aTypeNode = aTypeNode.getNextSibling() ) - { - for ( LDOM_Node aFilter = aTypeNode.getFirstChild(); - !aFilter.isNull(); aFilter = aFilter.getNextSibling() ) - { - LDOM_Element* anElem = ( LDOM_Element* )&aFilter; - if ( anElem->getTagName().equals( LDOMString( "filter" ) ) && - anElem->getAttribute( "name" ).equals( LDOMString( theFilterName ) ) ) - { - if ( theParent != 0 ) - *theParent = aTypeNode; - return (LDOM_Element&)aFilter; - } - } } - return LDOM_Element(); -} -//======================================================================= -// name : getSectionName -// Purpose : Get name of section of filters -//======================================================================= -static const char* getSectionName( const ElementType theType ) -{ - switch ( theType ) + //======================================================================= + // name : getSectionName + // Purpose : Get name of section of filters + //======================================================================= + static const char* getSectionName( const ElementType theType ) { - case SMESH::NODE : return "Filters for nodes"; - case SMESH::EDGE : return "Filters for edges"; - case SMESH::FACE : return "Filters for faces"; - case SMESH::VOLUME : return "Filters for volumes"; - case SMESH::ALL : return "Filters for elements"; - default : return ""; - } -} - -//======================================================================= -// name : getSection -// Purpose : Create section for filters corresponding to the entity type -//======================================================================= -static LDOM_Node getSection( const ElementType theType, - LDOM_Document& theDoc, - const bool toCreate = false ) -{ - LDOM_Element aRootElement = theDoc.getDocumentElement(); - if ( aRootElement.isNull() ) - return LDOM_Node(); - - // Find section - bool anExist = false; - const char* aSectionName = getSectionName( theType ); - if ( strcmp( aSectionName, "" ) == 0 ) - return LDOM_Node(); - - LDOM_NodeList aSections = theDoc.getElementsByTagName( "section" ); - LDOM_Node aNode; - for ( int i = 0, n = aSections.getLength(); i < n; i++ ) - { - aNode = aSections.item( i ); - LDOM_Element& anItem = ( LDOM_Element& )aNode; - if ( anItem.getAttribute( "name" ).equals( LDOMString( aSectionName ) ) ) + switch ( theType ) { - anExist = true; - break; + case SMESH::NODE : return "Filters for nodes"; + case SMESH::EDGE : return "Filters for edges"; + case SMESH::FACE : return "Filters for faces"; + case SMESH::VOLUME : return "Filters for volumes"; + case SMESH::ALL : return "Filters for elements"; + default : return ""; } } - // Create new section if necessary - if ( !anExist ) + //======================================================================= + // name : getSection + // Purpose : Create section for filters corresponding to the entity type + //======================================================================= + static LDOM_Node getSection( const ElementType theType, + LDOM_Document& theDoc, + const bool toCreate = false ) { - if ( toCreate ) - { - LDOM_Element aNewItem = theDoc.createElement( "section" ); - aNewItem.setAttribute( "name", aSectionName ); - aRootElement.appendChild( aNewItem ); - return aNewItem; - } - else + LDOM_Element aRootElement = theDoc.getDocumentElement(); + if ( aRootElement.isNull() ) return LDOM_Node(); + + // Find section + bool anExist = false; + const char* aSectionName = getSectionName( theType ); + if ( strcmp( aSectionName, "" ) == 0 ) + return LDOM_Node(); + + LDOM_NodeList aSections = theDoc.getElementsByTagName( "section" ); + LDOM_Node aNode; + for ( int i = 0, n = aSections.getLength(); i < n; i++ ) + { + aNode = aSections.item( i ); + LDOM_Element& anItem = ( LDOM_Element& )aNode; + if ( anItem.getAttribute( "name" ).equals( LDOMString( aSectionName ) ) ) + { + anExist = true; + break; + } + } + + // Create new section if necessary + if ( !anExist ) + { + if ( toCreate ) + { + LDOM_Element aNewItem = theDoc.createElement( "section" ); + aNewItem.setAttribute( "name", aSectionName ); + aRootElement.appendChild( aNewItem ); + return aNewItem; + } + else + return LDOM_Node(); + } + return + aNode; } - return - aNode; -} -//======================================================================= -// name : createFilterItem -// Purpose : Create filter item or LDOM document -//======================================================================= -static LDOM_Element createFilterItem( const char* theName, - SMESH::Filter_ptr theFilter, - LDOM_Document& theDoc ) -{ - // create new filter in document - LDOM_Element aFilterItem = theDoc.createElement( "filter" ); - aFilterItem.setAttribute( "name", theName ); - - // save filter criterions - SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria; - - if ( !theFilter->GetCriteria( aCriteria ) ) - return LDOM_Element(); - - for ( CORBA::ULong i = 0, n = aCriteria->length(); i < n; i++ ) + //======================================================================= + // name : createFilterItem + // Purpose : Create filter item or LDOM document + //======================================================================= + static LDOM_Element createFilterItem( const char* theName, + SMESH::Filter_ptr theFilter, + LDOM_Document& theDoc ) { - LDOM_Element aCriterionItem = theDoc.createElement( "criterion" ); + // create new filter in document + LDOM_Element aFilterItem = theDoc.createElement( "filter" ); + aFilterItem.setAttribute( "name", theName ); + + // save filter criterions + SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria; + + if ( !theFilter->GetCriteria( aCriteria ) ) + return LDOM_Element(); + + for ( CORBA::ULong i = 0, n = aCriteria->length(); i < n; i++ ) + { + LDOM_Element aCriterionItem = theDoc.createElement( "criterion" ); - aCriterionItem.setAttribute( ATTR_TYPE , toString( aCriteria[ i ].Type) ); - aCriterionItem.setAttribute( ATTR_COMPARE , toString( aCriteria[ i ].Compare ) ); - aCriterionItem.setAttribute( ATTR_THRESHOLD , toString( aCriteria[ i ].Threshold ) ); - aCriterionItem.setAttribute( ATTR_UNARY , toString( aCriteria[ i ].UnaryOp ) ); - aCriterionItem.setAttribute( ATTR_BINARY , toString( aCriteria[ i ].BinaryOp ) ); + aCriterionItem.setAttribute( ATTR_TYPE , toString( aCriteria[ i ].Type) ); + aCriterionItem.setAttribute( ATTR_COMPARE , toString( aCriteria[ i ].Compare ) ); + aCriterionItem.setAttribute( ATTR_THRESHOLD , toString( aCriteria[ i ].Threshold ) ); + aCriterionItem.setAttribute( ATTR_UNARY , toString( aCriteria[ i ].UnaryOp ) ); + aCriterionItem.setAttribute( ATTR_BINARY , toString( aCriteria[ i ].BinaryOp ) ); - aCriterionItem.setAttribute( ATTR_THRESHOLD_STR, (const char*)aCriteria[ i ].ThresholdStr ); - aCriterionItem.setAttribute( ATTR_TOLERANCE , toString( aCriteria[ i ].Tolerance ) ); - aCriterionItem.setAttribute( ATTR_ELEMENT_TYPE , - toString( (SMESH::ElementType)aCriteria[ i ].TypeOfElement ) ); + aCriterionItem.setAttribute( ATTR_THRESHOLD_STR, (const char*)aCriteria[ i ].ThresholdStr ); + aCriterionItem.setAttribute( ATTR_TOLERANCE , toString( aCriteria[ i ].Tolerance ) ); + aCriterionItem.setAttribute( ATTR_ELEMENT_TYPE , + toString( (SMESH::ElementType)aCriteria[ i ].TypeOfElement ) ); - aFilterItem.appendChild( aCriterionItem ); - } - - return aFilterItem; -} - -//======================================================================= -// name : FilterLibrary_i::FilterLibrary_i -// Purpose : Constructor -//======================================================================= -FilterLibrary_i::FilterLibrary_i( const char* theFileName ) -{ - myFileName = CORBA::string_dup( theFileName ); - SMESH::FilterManager_i* aFilterMgr = new SMESH::FilterManager_i(); - myFilterMgr = aFilterMgr->_this(); - - LDOMParser aParser; - - // Try to use existing library file - bool anExists = false; - if ( !aParser.parse( myFileName ) ) - { - myDoc = aParser.getDocument(); - anExists = true; - } - // Create a new XML document if it doesn't exist - else - myDoc = LDOM_Document::createDocument( LDOMString() ); - - LDOM_Element aRootElement = myDoc.getDocumentElement(); - if ( aRootElement.isNull() ) - { - // If the existing document is empty --> try to create a new one - if ( anExists ) - myDoc = LDOM_Document::createDocument( LDOMString() ); - } -} - -//======================================================================= -// name : FilterLibrary_i::FilterLibrary_i -// Purpose : Constructor -//======================================================================= -FilterLibrary_i::FilterLibrary_i() -{ - myFileName = 0; - SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i(); - myFilterMgr = aFilter->_this(); - - myDoc = LDOM_Document::createDocument( LDOMString() ); -} - -FilterLibrary_i::~FilterLibrary_i() -{ - CORBA::string_free( myFileName ); - //TPythonDump()< aCriteria; - - for ( LDOM_Node aCritNode = aFilter.getFirstChild(); - !aCritNode.isNull() ; aCritNode = aCritNode.getNextSibling() ) - { - LDOM_Element* aCrit = (LDOM_Element*)&aCritNode; - - const char* aTypeStr = aCrit->getAttribute( ATTR_TYPE ).GetString(); - const char* aCompareStr = aCrit->getAttribute( ATTR_COMPARE ).GetString(); - const char* aUnaryStr = aCrit->getAttribute( ATTR_UNARY ).GetString(); - const char* aBinaryStr = aCrit->getAttribute( ATTR_BINARY ).GetString(); - const char* anElemTypeStr = aCrit->getAttribute( ATTR_ELEMENT_TYPE ).GetString(); - - SMESH::Filter::Criterion aCriterion = createCriterion(); - - aCriterion.Type = toFunctorType( aTypeStr ); - aCriterion.Compare = toFunctorType( aCompareStr ); - aCriterion.UnaryOp = toFunctorType( aUnaryStr ); - aCriterion.BinaryOp = toFunctorType( aBinaryStr ); - - aCriterion.TypeOfElement = toElementType( anElemTypeStr ); - - LDOMString str = aCrit->getAttribute( ATTR_THRESHOLD ); - int val = 0; - aCriterion.Threshold = str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val ) - ? val : atof( str.GetString() ); - - str = aCrit->getAttribute( ATTR_TOLERANCE ); - aCriterion.Tolerance = str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val ) - ? val : atof( str.GetString() ); - - str = aCrit->getAttribute( ATTR_THRESHOLD_STR ); - if ( str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val ) ) - { - char a[ 255 ]; - sprintf( a, "%d", val ); - aCriterion.ThresholdStr = CORBA::string_dup( a ); + aFilterItem.appendChild( aCriterionItem ); } + + return aFilterItem; + } + + //======================================================================= + // name : FilterLibrary_i::FilterLibrary_i + // Purpose : Constructor + //======================================================================= + FilterLibrary_i::FilterLibrary_i( const char* theFileName ) + { + myFileName = CORBA::string_dup( theFileName ); + SMESH::FilterManager_i* aFilterMgr = new SMESH::FilterManager_i(); + myFilterMgr = aFilterMgr->_this(); + + LDOMParser aParser; + + // Try to use existing library file + bool anExists = false; + if ( !aParser.parse( myFileName ) ) + { + myDoc = aParser.getDocument(); + anExists = true; + } + // Create a new XML document if it doesn't exist else - aCriterion.ThresholdStr = str.GetString(); + myDoc = LDOM_Document::createDocument( LDOMString() ); - aCriteria.push_back( aCriterion ); - } - - SMESH::Filter::Criteria_var aCriteriaVar = new SMESH::Filter::Criteria; - aCriteriaVar->length( aCriteria.size() ); - - CORBA::ULong i = 0; - std::list::iterator anIter = aCriteria.begin(); - - for( ; anIter != aCriteria.end(); ++anIter ) - aCriteriaVar[ i++ ] = *anIter; - - aRes = myFilterMgr->CreateFilter(); - aRes->SetCriteria( aCriteriaVar.inout() ); - - TPythonDump()<_is_nil() ) - return false; - - // get section corresponding to the filter type - ElementType anEntType = theFilter->GetElementType(); - - LDOM_Node aSection = getSection( anEntType, myDoc, true ); - if ( aSection.isNull() ) - return false; - - // create filter item - LDOM_Element aFilterItem = createFilterItem( theFilterName, theFilter, myDoc ); - if ( aFilterItem.isNull() ) - return false; - else - { - aSection.appendChild( aFilterItem ); - if(Filter_i* aFilter = DownCast(theFilter)) - TPythonDump()<CreateFilter(); - - LDOM_Element aFilterItem = createFilterItem( theFilterName, aFilter, myDoc ); - if ( aFilterItem.isNull() ) - return false; - else - { - aSection.appendChild( aFilterItem ); - TPythonDump()<_is_nil() ) - return false; - - LDOM_Element aNewItem = createFilterItem( theNewName, theFilter, myDoc ); - if ( aNewItem.isNull() ) - return false; - else - { - aFilterItem.ReplaceElement( aNewItem ); - if(Filter_i* aFilter = DownCast(theFilter)) - TPythonDump()<length(); -} - -//======================================================================= -// name : FilterLibrary_i::GetNames -// Purpose : Get names of filters from library -//======================================================================= -string_array* FilterLibrary_i::GetNames( ElementType theType ) -{ - string_array_var anArray = new string_array; - TColStd_SequenceOfHAsciiString aSeq; - - LDOM_Node aSection = getSection( theType, myDoc, false ); - - if ( !aSection.isNull() ) - { - for ( LDOM_Node aFilter = aSection.getFirstChild(); - !aFilter.isNull(); aFilter = aFilter.getNextSibling() ) + LDOM_Element aRootElement = myDoc.getDocumentElement(); + if ( aRootElement.isNull() ) { - LDOM_Element& anElem = ( LDOM_Element& )aFilter; - aSeq.Append( new TCollection_HAsciiString( - (Standard_CString)anElem.getAttribute( "name" ).GetString() ) ); + // If the existing document is empty --> try to create a new one + if ( anExists ) + myDoc = LDOM_Document::createDocument( LDOMString() ); } } - anArray->length( aSeq.Length() ); - for ( int i = 1, n = aSeq.Length(); i <= n; i++ ) - anArray[ i - 1 ] = CORBA::string_dup( aSeq( i )->ToCString() ); - - return anArray._retn(); -} - -//======================================================================= -// name : FilterLibrary_i::GetAllNames -// Purpose : Get names of filters from library -//======================================================================= -string_array* FilterLibrary_i::GetAllNames() -{ - string_array_var aResArray = new string_array; - for ( int type = SMESH::ALL; type <= SMESH::VOLUME; type++ ) + //======================================================================= + // name : FilterLibrary_i::FilterLibrary_i + // Purpose : Constructor + //======================================================================= + FilterLibrary_i::FilterLibrary_i() { - SMESH::string_array_var aNames = GetNames( (SMESH::ElementType)type ); + myFileName = 0; + SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i(); + myFilterMgr = aFilter->_this(); - int aPrevLength = aResArray->length(); - aResArray->length( aPrevLength + aNames->length() ); - for ( int i = 0, n = aNames->length(); i < n; i++ ) - aResArray[ aPrevLength + i ] = aNames[ i ]; + myDoc = LDOM_Document::createDocument( LDOMString() ); } - return aResArray._retn(); -} - -//================================================================================ -/*! - * \brief Return an array of strings corresponding to items of enum FunctorType - */ -//================================================================================ - -static const char** getFunctNames() -{ - static const char* functName[] = { - // IT's necessary to update this array according to enum FunctorType (SMESH_Filter.idl) - // The order is IMPORTANT !!! - "FT_AspectRatio", - "FT_AspectRatio3D", - "FT_Warping", - "FT_MinimumAngle", - "FT_Taper", - "FT_Skew", - "FT_Area", - "FT_Volume3D", - "FT_MaxElementLength2D", - "FT_MaxElementLength3D", - "FT_FreeBorders", - "FT_FreeEdges", - "FT_FreeNodes", - "FT_FreeFaces", - "FT_EqualNodes", - "FT_EqualEdges", - "FT_EqualFaces", - "FT_EqualVolumes", - "FT_MultiConnection", - "FT_MultiConnection2D", - "FT_Length", - "FT_Length2D", - "FT_Length3D", - "FT_Deflection2D", - "FT_NodeConnectivityNumber", - "FT_BelongToMeshGroup", - "FT_BelongToGeom", - "FT_BelongToPlane", - "FT_BelongToCylinder", - "FT_BelongToGenSurface", - "FT_LyingOnGeom", - "FT_RangeOfIds", - "FT_BadOrientedVolume", - "FT_BareBorderVolume", - "FT_BareBorderFace", - "FT_OverConstrainedVolume", - "FT_OverConstrainedFace", - "FT_LinearOrQuadratic", - "FT_GroupColor", - "FT_ElemGeomType", - "FT_EntityType", - "FT_CoplanarFaces", - "FT_BallDiameter", - "FT_ConnectedElements", - "FT_LessThan", - "FT_MoreThan", - "FT_EqualTo", - "FT_LogicalNOT", - "FT_LogicalAND", - "FT_LogicalOR", - "FT_Undefined"}; - -#ifdef _DEBUG_ - // check if functName is complete, compilation failure means that enum FunctorType changed - const int nbFunctors = sizeof(functName) / sizeof(const char*); - int _assert[( nbFunctors == SMESH::FT_Undefined + 1 ) ? 2 : -1 ]; _assert[0]=_assert[1]=0; -#endif - - return functName; -} - -//================================================================================ -/*! - * \brief Return a string corresponding to an item of enum FunctorType - */ -//================================================================================ - -const char* SMESH::FunctorTypeToString(SMESH::FunctorType ft) -{ - if ( ft < 0 || ft > SMESH::FT_Undefined ) - return "FT_Undefined"; - return getFunctNames()[ ft ]; -} - -//================================================================================ -/*! - * \brief Converts a string to FunctorType. This is reverse of FunctorTypeToString() - */ -//================================================================================ - -SMESH::FunctorType SMESH::StringToFunctorType(const char* str) -{ - std::string name( str + 3 ); // skip "FT_" - const char** functNames = getFunctNames(); - int ft = 0; - for ( ; ft < SMESH::FT_Undefined; ++ft ) - if ( name == ( functNames[ft] + 3 )) - break; - - //ASSERT( strcmp( str, FunctorTypeToString( SMESH::FunctorType( ft ))) == 0 ); - - return SMESH::FunctorType( ft ); -} - -//================================================================================ -/*! - * \brief calls OnBaseObjModified(), if who != this, and myWaiters[i]->Modified(who) - */ -//================================================================================ - -void NotifyerAndWaiter::Modified( bool removed, NotifyerAndWaiter* who ) -{ - if ( who != 0 && who != this ) - OnBaseObjModified( who, removed ); - else - who = this; - - std::list waiters = myWaiters; // myWaiters can be changed by Modified() - std::list::iterator i = waiters.begin(); - for ( ; i != waiters.end(); ++i ) - (*i)->Modified( removed, who ); -} - -//================================================================================ -/*! - * \brief Stores an object to be notified on change of predicate - */ -//================================================================================ - -void NotifyerAndWaiter::AddModifWaiter( NotifyerAndWaiter* waiter ) -{ - if ( waiter ) - myWaiters.push_back( waiter ); -} - -//================================================================================ -/*! - * \brief Removes an object to be notified on change of predicate - */ -//================================================================================ - -void NotifyerAndWaiter::RemoveModifWaiter( NotifyerAndWaiter* waiter ) -{ - myWaiters.remove( waiter ); -} - -//================================================================================ -/*! - * \brief Checks if a waiter is among myWaiters, maybe nested - */ -//================================================================================ - -bool NotifyerAndWaiter::ContainModifWaiter( NotifyerAndWaiter* waiter ) -{ - bool is = ( waiter == this ); - - std::list::iterator w = myWaiters.begin(); - for ( ; !is && w != myWaiters.end(); ++w ) - is = (*w)->ContainModifWaiter( waiter ); - - return is; + FilterLibrary_i::~FilterLibrary_i() + { + CORBA::string_free( myFileName ); + //TPythonDump()< aCriteria; + + for ( LDOM_Node aCritNode = aFilter.getFirstChild(); + !aCritNode.isNull() ; aCritNode = aCritNode.getNextSibling() ) + { + LDOM_Element* aCrit = (LDOM_Element*)&aCritNode; + + const char* aTypeStr = aCrit->getAttribute( ATTR_TYPE ).GetString(); + const char* aCompareStr = aCrit->getAttribute( ATTR_COMPARE ).GetString(); + const char* aUnaryStr = aCrit->getAttribute( ATTR_UNARY ).GetString(); + const char* aBinaryStr = aCrit->getAttribute( ATTR_BINARY ).GetString(); + const char* anElemTypeStr = aCrit->getAttribute( ATTR_ELEMENT_TYPE ).GetString(); + + SMESH::Filter::Criterion aCriterion = createCriterion(); + + aCriterion.Type = toFunctorType( aTypeStr ); + aCriterion.Compare = toFunctorType( aCompareStr ); + aCriterion.UnaryOp = toFunctorType( aUnaryStr ); + aCriterion.BinaryOp = toFunctorType( aBinaryStr ); + + aCriterion.TypeOfElement = toElementType( anElemTypeStr ); + + LDOMString str = aCrit->getAttribute( ATTR_THRESHOLD ); + int val = 0; + aCriterion.Threshold = str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val ) + ? val : atof( str.GetString() ); + + str = aCrit->getAttribute( ATTR_TOLERANCE ); + aCriterion.Tolerance = str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val ) + ? val : atof( str.GetString() ); + + str = aCrit->getAttribute( ATTR_THRESHOLD_STR ); + if ( str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val ) ) + { + char a[ 255 ]; + sprintf( a, "%d", val ); + aCriterion.ThresholdStr = CORBA::string_dup( a ); + } + else + aCriterion.ThresholdStr = str.GetString(); + + aCriteria.push_back( aCriterion ); + } + + SMESH::Filter::Criteria_var aCriteriaVar = new SMESH::Filter::Criteria; + aCriteriaVar->length( aCriteria.size() ); + + CORBA::ULong i = 0; + std::list::iterator anIter = aCriteria.begin(); + + for( ; anIter != aCriteria.end(); ++anIter ) + aCriteriaVar[ i++ ] = *anIter; + + aRes = myFilterMgr->CreateFilter(); + aRes->SetCriteria( aCriteriaVar.inout() ); + + TPythonDump()<_is_nil() ) + return false; + + // get section corresponding to the filter type + ElementType anEntType = theFilter->GetElementType(); + + LDOM_Node aSection = getSection( anEntType, myDoc, true ); + if ( aSection.isNull() ) + return false; + + // create filter item + LDOM_Element aFilterItem = createFilterItem( theFilterName, theFilter, myDoc ); + if ( aFilterItem.isNull() ) + return false; + else + { + aSection.appendChild( aFilterItem ); + if(Filter_i* aFilter = DownCast(theFilter)) + TPythonDump()<CreateFilter(); + + LDOM_Element aFilterItem = createFilterItem( theFilterName, aFilter, myDoc ); + if ( aFilterItem.isNull() ) + return false; + else + { + aSection.appendChild( aFilterItem ); + TPythonDump()<_is_nil() ) + return false; + + LDOM_Element aNewItem = createFilterItem( theNewName, theFilter, myDoc ); + if ( aNewItem.isNull() ) + return false; + else + { + aFilterItem.ReplaceElement( aNewItem ); + if(Filter_i* aFilter = DownCast(theFilter)) + TPythonDump()<length(); + } + + //======================================================================= + // name : FilterLibrary_i::GetNames + // Purpose : Get names of filters from library + //======================================================================= + string_array* FilterLibrary_i::GetNames( ElementType theType ) + { + string_array_var anArray = new string_array; + TColStd_SequenceOfHAsciiString aSeq; + + LDOM_Node aSection = getSection( theType, myDoc, false ); + + if ( !aSection.isNull() ) + { + for ( LDOM_Node aFilter = aSection.getFirstChild(); + !aFilter.isNull(); aFilter = aFilter.getNextSibling() ) + { + LDOM_Element& anElem = ( LDOM_Element& )aFilter; + aSeq.Append( new TCollection_HAsciiString( + (Standard_CString)anElem.getAttribute( "name" ).GetString() ) ); + } + } + + anArray->length( aSeq.Length() ); + for ( int i = 1, n = aSeq.Length(); i <= n; i++ ) + anArray[ i - 1 ] = CORBA::string_dup( aSeq( i )->ToCString() ); + + return anArray._retn(); + } + + //======================================================================= + // name : FilterLibrary_i::GetAllNames + // Purpose : Get names of filters from library + //======================================================================= + string_array* FilterLibrary_i::GetAllNames() + { + string_array_var aResArray = new string_array; + for ( int type = SMESH::ALL; type <= SMESH::VOLUME; type++ ) + { + SMESH::string_array_var aNames = GetNames( (SMESH::ElementType)type ); + + int aPrevLength = aResArray->length(); + aResArray->length( aPrevLength + aNames->length() ); + for ( int i = 0, n = aNames->length(); i < n; i++ ) + aResArray[ aPrevLength + i ] = aNames[ i ]; + } + + return aResArray._retn(); + } + + //================================================================================ + /*! + * \brief Return an array of strings corresponding to items of enum FunctorType + */ + //================================================================================ + + static const char** getFunctNames() + { + static const char* functName[] = { + // IT's necessary to update this array according to enum FunctorType (SMESH_Filter.idl) + // The order is IMPORTANT !!! + "FT_AspectRatio", + "FT_AspectRatio3D", + "FT_Warping", + "FT_MinimumAngle", + "FT_Taper", + "FT_Skew", + "FT_Area", + "FT_Volume3D", + "FT_MaxElementLength2D", + "FT_MaxElementLength3D", + "FT_FreeBorders", + "FT_FreeEdges", + "FT_FreeNodes", + "FT_FreeFaces", + "FT_EqualNodes", + "FT_EqualEdges", + "FT_EqualFaces", + "FT_EqualVolumes", + "FT_MultiConnection", + "FT_MultiConnection2D", + "FT_Length", + "FT_Length2D", + "FT_Length3D", + "FT_Deflection2D", + "FT_NodeConnectivityNumber", + "FT_BelongToMeshGroup", + "FT_BelongToGeom", + "FT_BelongToPlane", + "FT_BelongToCylinder", + "FT_BelongToGenSurface", + "FT_LyingOnGeom", + "FT_RangeOfIds", + "FT_BadOrientedVolume", + "FT_BareBorderVolume", + "FT_BareBorderFace", + "FT_OverConstrainedVolume", + "FT_OverConstrainedFace", + "FT_LinearOrQuadratic", + "FT_GroupColor", + "FT_ElemGeomType", + "FT_EntityType", + "FT_CoplanarFaces", + "FT_BallDiameter", + "FT_ConnectedElements", + "FT_LessThan", + "FT_MoreThan", + "FT_EqualTo", + "FT_LogicalNOT", + "FT_LogicalAND", + "FT_LogicalOR", + "FT_Undefined"}; + + #ifdef _DEBUG_ + // check if functName is complete, compilation failure means that enum FunctorType changed + const int nbFunctors = sizeof(functName) / sizeof(const char*); + int _assert[( nbFunctors == SMESH::FT_Undefined + 1 ) ? 2 : -1 ]; _assert[0]=_assert[1]=0; + #endif + + return functName; + } + + //================================================================================ + /*! + * \brief Return a string corresponding to an item of enum FunctorType + */ + //================================================================================ + + const char* FunctorTypeToString(FunctorType ft) + { + if ( ft < 0 || ft > SMESH::FT_Undefined ) + return "FT_Undefined"; + return getFunctNames()[ ft ]; + } + + //================================================================================ + /*! + * \brief Converts a string to FunctorType. This is reverse of FunctorTypeToString() + */ + //================================================================================ + + FunctorType StringToFunctorType(const char* str) + { + std::string name( str + 3 ); // skip "FT_" + const char** functNames = getFunctNames(); + int ft = 0; + for ( ; ft < SMESH::FT_Undefined; ++ft ) + if ( name == ( functNames[ft] + 3 )) + break; + + //ASSERT( strcmp( str, FunctorTypeToString( SMESH::FunctorType( ft ))) == 0 ); + + return SMESH::FunctorType( ft ); + } + + //================================================================================ + /*! + * \brief calls OnBaseObjModified(), if who != this, and myWaiters[i]->Modified(who) + */ + //================================================================================ + + void NotifyerAndWaiter::Modified( bool removed, NotifyerAndWaiter* who ) + { + if ( who != 0 && who != this ) + OnBaseObjModified( who, removed ); + else + who = this; + + std::list waiters = myWaiters; // myWaiters can be changed by Modified() + std::list::iterator i = waiters.begin(); + for ( ; i != waiters.end(); ++i ) + (*i)->Modified( removed, who ); + } + + //================================================================================ + /*! + * \brief Stores an object to be notified on change of predicate + */ + //================================================================================ + + void NotifyerAndWaiter::AddModifWaiter( NotifyerAndWaiter* waiter ) + { + if ( waiter ) + myWaiters.push_back( waiter ); + } + + //================================================================================ + /*! + * \brief Removes an object to be notified on change of predicate + */ + //================================================================================ + + void NotifyerAndWaiter::RemoveModifWaiter( NotifyerAndWaiter* waiter ) + { + myWaiters.remove( waiter ); + } + + //================================================================================ + /*! + * \brief Checks if a waiter is among myWaiters, maybe nested + */ + //================================================================================ + + bool NotifyerAndWaiter::ContainModifWaiter( NotifyerAndWaiter* waiter ) + { + bool is = ( waiter == this ); + + std::list::iterator w = myWaiters.begin(); + for ( ; !is && w != myWaiters.end(); ++w ) + is = (*w)->ContainModifWaiter( waiter ); + + return is; + } } diff --git a/src/SMESH_I/SMESH_Group_i.cxx b/src/SMESH_I/SMESH_Group_i.cxx index 9828ac984..357ae2aa3 100644 --- a/src/SMESH_I/SMESH_Group_i.cxx +++ b/src/SMESH_I/SMESH_Group_i.cxx @@ -43,8 +43,6 @@ #include "utilities.h" -using namespace SMESH; - //============================================================================= /*! * @@ -158,7 +156,7 @@ void SMESH_GroupBase_i::SetName( const char* theName ) aGen->SetName( anSO, theName ); // Update Python script - TPythonDump() << anSO << ".SetName( '" << theName << "' )"; + SMESH::TPythonDump() << anSO << ".SetName( '" << theName << "' )"; } } @@ -264,7 +262,7 @@ void SMESH_Group_i::Clear() myPreMeshInfo->FullLoadFromFile(); // Update Python script - TPythonDump() << SMESH::SMESH_Group_var(_this()) << ".Clear()"; + SMESH::TPythonDump() << SMESH::SMESH_Group_var(_this()) << ".Clear()"; // Clear the group SMESHDS_Group* aGroupDS = dynamic_cast( GetGroupDS() ); @@ -304,7 +302,7 @@ SMESH::smIdType SMESH_Group_i::Add( const SMESH::smIdType_array& theIDs ) myPreMeshInfo->FullLoadFromFile(); // Update Python script - TPythonDump() << "nbAdd = " << SMESH::SMESH_Group_var(_this()) << ".Add( " << theIDs << " )"; + SMESH::TPythonDump() << "nbAdd = " << SMESH::SMESH_Group_var(_this()) << ".Add( " << theIDs << " )"; // Add elements to the group SMESHDS_Group* aGroupDS = dynamic_cast( GetGroupDS() ); @@ -335,7 +333,7 @@ SMESH::smIdType SMESH_Group_i::Remove( const SMESH::smIdType_array& theIDs ) myPreMeshInfo->FullLoadFromFile(); // Update Python script - TPythonDump() << "nbDel = " << SMESH::SMESH_Group_var(_this()) + SMESH::TPythonDump() << "nbDel = " << SMESH::SMESH_Group_var(_this()) << ".Remove( " << theIDs << " )"; // Remove elements from the group @@ -364,10 +362,10 @@ SMESH::smIdType SMESH_Group_i::Remove( const SMESH::smIdType_array& theIDs ) typedef bool (SMESHDS_Group::*TFunChangeGroup)(const smIdType); CORBA::Long -ChangeByPredicate( SMESH::Predicate_i* thePredicate, - SMESHDS_GroupBase* theGroupBase, - NotifyerAndWaiter* theGroupImpl, - TFunChangeGroup theFun) +ChangeByPredicate( SMESH::Predicate_i* thePredicate, + SMESHDS_GroupBase* theGroupBase, + SMESH::NotifyerAndWaiter* theGroupImpl, + TFunChangeGroup theFun) { CORBA::Long aNb = 0; if(SMESHDS_Group* aGroupDS = dynamic_cast(theGroupBase)){ @@ -394,8 +392,8 @@ AddByPredicate( SMESH::Predicate_ptr thePredicate ) myPreMeshInfo->FullLoadFromFile(); if(SMESH::Predicate_i* aPredicate = SMESH::GetPredicate(thePredicate)){ - TPythonDump() << SMESH::SMESH_Group_var(_this()) - << ".AddByPredicate( " << aPredicate << " )"; + SMESH::TPythonDump() << SMESH::SMESH_Group_var(_this()) + << ".AddByPredicate( " << aPredicate << " )"; return ChangeByPredicate( aPredicate, GetGroupDS(), this, &SMESHDS_Group::Add ); } return 0; @@ -409,8 +407,8 @@ RemoveByPredicate( SMESH::Predicate_ptr thePredicate ) myPreMeshInfo->FullLoadFromFile(); if(SMESH::Predicate_i* aPredicate = SMESH::GetPredicate(thePredicate)){ - TPythonDump() << SMESH::SMESH_Group_var(_this()) - << ".RemoveByPredicate( " << aPredicate << " )"; + SMESH::TPythonDump() << SMESH::SMESH_Group_var(_this()) + << ".RemoveByPredicate( " << aPredicate << " )"; return ChangeByPredicate(aPredicate,GetGroupDS(),this, &SMESHDS_Group::Remove); } return 0; @@ -421,7 +419,7 @@ SMESH::smIdType SMESH_Group_i::AddFrom( SMESH::SMESH_IDSource_ptr theSource ) if ( myPreMeshInfo ) myPreMeshInfo->FullLoadFromFile(); - TPythonDump pd; + SMESH::TPythonDump pd; long prevNb = Size(); SMESHDS_Group* aGroupDS = dynamic_cast( GetGroupDS() ); if (aGroupDS) { @@ -475,7 +473,7 @@ SMESH::smIdType_array* SMESH_GroupBase_i::GetListOfID() smIdType aSize = aGroupDS->Extent(); aRes->length(aSize); SMDS_ElemIteratorPtr it = aGroupDS->GetElements(); - for (smIdType i = 0; it->more(); i++) + for (::smIdType i = 0; it->more(); i++) aRes[i] = it->next()->GetID(); if ( 0 < aSize && aSize < 100 ) // for comfortable testing ;) @@ -639,9 +637,9 @@ void SMESH_GroupBase_i::SetColor(const SALOMEDS::Color& color) if ( oldColor != aQColor ) { aGroupDS->SetColor(aQColor); - TPythonDump()<< SMESH::SMESH_GroupBase_var(_this()) - << ".SetColor( SALOMEDS.Color( " - <SetColorGroup(color); - TPythonDump()<GetGen()->HighLightInvalid( me, false ); - TPythonDump()<< me <<".SetFilter( "<< theFilter <<" )"; + SMESH::TPythonDump()<< me <<".SetFilter( "<< theFilter <<" )"; } //================================================================================ @@ -856,7 +854,7 @@ void SMESH_GroupOnFilter_i::SetFilter(SMESH::Filter_ptr theFilter) SMESH::Filter_ptr SMESH_GroupOnFilter_i::GetFilter() { SMESH::Filter_var f = myFilter; - TPythonDump() << f << " = " << SMESH::SMESH_GroupOnFilter_var(_this()) << ".GetFilter()"; + SMESH::TPythonDump() << f << " = " << SMESH::SMESH_GroupOnFilter_var(_this()) << ".GetFilter()"; return f._retn(); } @@ -938,7 +936,7 @@ SMESH::smIdType_array* SMESH_GroupOnFilter_i::GetMeshInfo() if ( g->GetType() != SMDSAbs_Node ) { - std::vector< SMESH::smIdType > nbElems = static_cast< SMESHDS_GroupOnFilter* >( g )->GetMeshInfo(); + std::vector< smIdType > nbElems = static_cast< SMESHDS_GroupOnFilter* >( g )->GetMeshInfo(); for ( size_t i = SMESH::Entity_Node; i < SMESH::Entity_Last; i++) if ( i < nbElems.size() ) aRes[i] = nbElems[ i ]; @@ -1039,7 +1037,7 @@ SMESH::Filter_ptr SMESH_GroupOnFilter_i::StringToFilter(const std::string& thePe } // create a filter - TPythonDump pd; + SMESH::TPythonDump pd; SMESH::FilterManager_i* aFilterMgr = new SMESH::FilterManager_i(); filter = aFilterMgr->CreateFilter(); filter->SetCriteria( criteria.inout() ); diff --git a/src/SMESH_I/SMESH_Measurements_i.cxx b/src/SMESH_I/SMESH_Measurements_i.cxx index f81c0573b..ce71af650 100644 --- a/src/SMESH_I/SMESH_Measurements_i.cxx +++ b/src/SMESH_I/SMESH_Measurements_i.cxx @@ -22,10 +22,6 @@ // File : SMESH_Measurements_i.cxx // Author : Pavel TELKOV, Open CASCADE S.A.S. (pavel.telkov@opencascade.com) -#ifdef WIN32 -#define NOMINMAX -#endif - #include "SMESH_Measurements_i.hxx" #include "SMDS_ElemIterator.hxx" @@ -40,7 +36,7 @@ #include -using namespace SMESH; +//using namespace SMESH; /** * this local function to avoid uninitialized fields @@ -80,7 +76,7 @@ SMESH::Measurements_ptr SMESH_Gen_i::CreateMeasurements() // name : Measurements_i // Purpose : Constructor //======================================================================= -Measurements_i::Measurements_i() +SMESH::Measurements_i::Measurements_i() : SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() ) { //Base class Salome_GenericObject do it inmplicitly by overriding PortableServer::POA_ptr _default_POA() method @@ -92,7 +88,7 @@ Measurements_i::Measurements_i() // name : ~Measurements_i // Purpose : Destructor //======================================================================= -Measurements_i::~Measurements_i() +SMESH::Measurements_i::~Measurements_i() { //TPythonDump()<GetMesh(); - SMESH_Mesh_i* anImplPtr = DownCast( mesh ); + SMESH_Mesh_i* anImplPtr = SMESH::DownCast( mesh ); if (anImplPtr) return anImplPtr->GetImpl().GetMeshDS(); } @@ -187,7 +183,7 @@ static double getNumericalValue(SMESH::SMESH_IDSource_ptr theSource, // name : MinDistance // Purpose : minimal distance between two given entities //======================================================================= -SMESH::Measure Measurements_i::MinDistance +SMESH::Measure SMESH::Measurements_i::MinDistance (SMESH::SMESH_IDSource_ptr theSource1, SMESH::SMESH_IDSource_ptr theSource2) { @@ -289,7 +285,7 @@ static void enlargeBoundingBox(const SMESH::SMESH_IDSource_ptr theObject, if ( !aMesh ) return; - if ( DownCast( theObject )) // theObject is mesh + if (SMESH::DownCast( theObject )) // theObject is mesh { for (SMDS_NodeIteratorPtr aNodeIter = aMesh->nodesIterator(); aNodeIter->more(); ) enlargeBoundingBox( aNodeIter->next(), theMeasure); @@ -318,7 +314,7 @@ static void enlargeBoundingBox(const SMESH::SMESH_IDSource_ptr theObject, // name : BoundingBox // Purpose : compute common bounding box of entities //======================================================================= -SMESH::Measure Measurements_i::BoundingBox (const SMESH::ListOfIDSources& theSources) +SMESH::Measure SMESH::Measurements_i::BoundingBox (const SMESH::ListOfIDSources& theSources) { SMESH::Measure aMeasure; initMeasure(aMeasure); @@ -334,7 +330,7 @@ SMESH::Measure Measurements_i::BoundingBox (const SMESH::ListOfIDSources& theSou // name : Length // Purpose : sum of length of 1D elements of the source //======================================================================= -double Measurements_i::Length(SMESH::SMESH_IDSource_ptr theSource) +double SMESH::Measurements_i::Length(SMESH::SMESH_IDSource_ptr theSource) { return getNumericalValue( theSource, SMESH::Controls::NumericalFunctorPtr(new SMESH::Controls::Length()) ); } @@ -343,7 +339,7 @@ double Measurements_i::Length(SMESH::SMESH_IDSource_ptr theSource) // name : Area // Purpose : sum of area of 2D elements of the source //======================================================================= -double Measurements_i::Area(SMESH::SMESH_IDSource_ptr theSource) +double SMESH::Measurements_i::Area(SMESH::SMESH_IDSource_ptr theSource) { return getNumericalValue( theSource, SMESH::Controls::NumericalFunctorPtr(new SMESH::Controls::Area()) ); } @@ -352,7 +348,7 @@ double Measurements_i::Area(SMESH::SMESH_IDSource_ptr theSource) // name : Volume // Purpose : sum of volume of 3D elements of the source //======================================================================= -double Measurements_i::Volume(SMESH::SMESH_IDSource_ptr theSource) +double SMESH::Measurements_i::Volume(SMESH::SMESH_IDSource_ptr theSource) { return getNumericalValue( theSource, SMESH::Controls::NumericalFunctorPtr(new SMESH::Controls::Volume()) ); } @@ -362,7 +358,7 @@ double Measurements_i::Volume(SMESH::SMESH_IDSource_ptr theSource) //purpose : return gravity center of the source: average coordinates of all nodes //======================================================================= -SMESH::PointStruct Measurements_i::GravityCenter(SMESH::SMESH_IDSource_ptr theSource) +SMESH::PointStruct SMESH::Measurements_i::GravityCenter(SMESH::SMESH_IDSource_ptr theSource) { SMESH::PointStruct grCenter = { 0.,0.,0. }; const SMESHDS_Mesh* mesh = getMesh( theSource ); @@ -404,9 +400,9 @@ SMESH::PointStruct Measurements_i::GravityCenter(SMESH::SMESH_IDSource_ptr theSo //purpose : Return angle in radians defined by 3 points <(p1,p2,p3) //======================================================================= -CORBA::Double Measurements_i::Angle(const SMESH::PointStruct& p1, - const SMESH::PointStruct& p2, - const SMESH::PointStruct& p3 ) +CORBA::Double SMESH::Measurements_i::Angle(const SMESH::PointStruct& p1, + const SMESH::PointStruct& p2, + const SMESH::PointStruct& p3 ) { gp_Vec v1( p1.x - p2.x, p1.y - p2.y, p1.z - p2.z ); gp_Vec v2( p3.x - p2.x, p3.y - p2.y, p3.z - p2.z ); diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index d96c5c99e..bc5073500 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -279,13 +279,13 @@ namespace MeshEditor_I { SMDS_MeshElement::Filter & filter = *aFilter; if ( aType == SMDSAbs_Node ) - for ( SMESH::smIdType i = 0; i < IDs.length(); i++ ) { + for ( CORBA::ULong i = 0; i < IDs.length(); i++ ) { const SMDS_MeshElement * elem = aMesh->FindNode( IDs[i] ); if ( filter( elem )) aMap.insert( aMap.end(), elem ); } else - for ( SMESH::smIdType i = 0; iFindElement( IDs[i] ); if ( filter( elem )) aMap.insert( aMap.end(), elem ); @@ -789,7 +789,7 @@ SMESH_MeshEditor_i::RemoveElements(const SMESH::smIdType_array & IDsOfElements) list< smIdType > IdList; - for ( SMESH::smIdType i = 0; i < IDsOfElements.length(); i++ ) + for ( CORBA::ULong i = 0; i < IDsOfElements.length(); i++ ) IdList.push_back( IDsOfElements[i] ); // Update Python script @@ -817,7 +817,7 @@ CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::smIdType_array & IDs initData(); list< smIdType > IdList; - for ( SMESH::smIdType i = 0; i < IDsOfNodes.length(); i++) + for ( CORBA::ULong i = 0; i < IDsOfNodes.length(); i++) IdList.push_back( IDsOfNodes[i] ); // Update Python script @@ -1578,7 +1578,7 @@ CORBA::Boolean SMESH_MeshEditor_i::Reorient(const SMESH::smIdType_array & IDsOfE SMESH_TRY; initData(); - for ( SMESH::smIdType i = 0; i < IDsOfElements.length(); i++ ) + for ( CORBA::ULong i = 0; i < IDsOfElements.length(); i++ ) { SMESH::smIdType index = IDsOfElements[i]; const SMDS_MeshElement * elem = getMeshDS()->FindElement(index); @@ -2252,7 +2252,7 @@ SMESH_MeshEditor_i::smooth(const SMESH::smIdType_array & IDsOfElements, arrayToSet(IDsOfElements, aMesh, elements, SMDSAbs_Face); set fixedNodes; - for ( SMESH::smIdType i = 0; i < IDsOfFixedNodes.length(); i++) { + for ( CORBA::ULong i = 0; i < IDsOfFixedNodes.length(); i++) { SMESH::smIdType index = IDsOfFixedNodes[i]; const SMDS_MeshNode * node = aMesh->FindNode(index); if ( node ) @@ -4342,7 +4342,7 @@ void SMESH_MeshEditor_i::MergeElements(const SMESH::array_of_long_array& theGrou if ( elemTypes->length() == 1 && elemTypes[0] == SMESH::NODE ) continue; SMESH::smIdType_array_var elementsId = theElementsToKeep[i]->GetIDs(); - for ( SMESH::smIdType j = 0; j < elementsId->length(); ++j ) + for ( CORBA::ULong j = 0; j < elementsId->length(); ++j ) idsToKeep.Add( elementsId[ j ]); } @@ -4353,7 +4353,7 @@ void SMESH_MeshEditor_i::MergeElements(const SMESH::array_of_long_array& theGrou const SMESH::long_array& anElemsIDGroup = theGroupsOfElementsID[ i ]; aListOfListOfElementsID.push_back( list< smIdType >() ); list< smIdType >& aListOfElemsID = aListOfListOfElementsID.back(); - for ( SMESH::smIdType j = 0; j < anElemsIDGroup.length(); j++ ) + for ( CORBA::ULong j = 0; j < anElemsIDGroup.length(); j++ ) { SMESH::smIdType id = anElemsIDGroup[ j ]; if ( idsToKeep.Contains( id )) aListOfElemsID.push_front( id ); diff --git a/src/SMESH_I/SMESH_MeshEditor_i.hxx b/src/SMESH_I/SMESH_MeshEditor_i.hxx index 2f152c334..69f62d539 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.hxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.hxx @@ -93,7 +93,7 @@ public: SMESH::SMESH_IDSource_ptr MakeIDSource(const SMESH::smIdType_array& IDsOfElements, SMESH::ElementType type); static bool IsTemporaryIDSource( SMESH::SMESH_IDSource_ptr& idSource ); - static SMESH::smIdType* GetTemporaryIDs( SMESH::SMESH_IDSource_ptr& idSource, smIdType& nbIds ); + static SMESH::smIdType* GetTemporaryIDs( SMESH::SMESH_IDSource_ptr& idSource, SMESH::smIdType& nbIds ); /*! * \brief Generates the unique group name diff --git a/src/StdMeshersGUI/StdMeshersGUI_DistrPreview.cxx b/src/StdMeshersGUI/StdMeshersGUI_DistrPreview.cxx index b3523818b..b2a4be767 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_DistrPreview.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_DistrPreview.cxx @@ -320,13 +320,8 @@ void StdMeshersGUI_DistrPreview::update() setAxisScale( myDensity->xAxis(), min_x, max_x ); setAxisScale( myDensity->yAxis(), -#ifdef WIN32 - min( 0.0, min_y ), - max( 0.0, max_y ) -#else std::min( 0.0, min_y ), std::max( 0.0, max_y ) -#endif ); myDensity->setSamples( x, y, size ); if( x ) From 8f903d5ee57f0e646cf05d68d85418c68d497053 Mon Sep 17 00:00:00 2001 From: rnv Date: Mon, 3 May 2021 20:06:34 +0300 Subject: [PATCH 15/17] bos #24228 [CEA 24217][Windows] cannot compile SMESH: additional fix. --- src/SMESHGUI/SMESHGUI.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index a68966e63..9f63eaf34 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -1226,7 +1226,7 @@ namespace SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast( aFunctor.get() ); if ( aNumFun ) { - std::vector elements; + std::vector elements; SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface(anIO); if ( mesh->_is_nil() ) { SMESH::SMESH_IDSource_var idSource = From 3f5860c39fdef2955dddc2640a9d746b1416e53d Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 5 May 2021 13:28:17 +0300 Subject: [PATCH 16/17] bos #24257 [CEA] Fatal error when creating a submesh if the mesh is on a sub-shape Adjust isSubshapeOk() for SHAPERSTUDY where GEOM_Gen::AddSubShape() not implemented --- src/Driver/Driver_Mesh.h | 2 -- src/SMESHGUI/SMESHGUI_MeshOp.cxx | 55 +++++++++++++++++++++----------- 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/src/Driver/Driver_Mesh.h b/src/Driver/Driver_Mesh.h index a1af52641..9eac8fc88 100644 --- a/src/Driver/Driver_Mesh.h +++ b/src/Driver/Driver_Mesh.h @@ -72,8 +72,6 @@ class MESHDRIVER_EXPORT Driver_Mesh virtual SMESH_ComputeErrorPtr GetError(); - //virtual bool CanExportMesh() const { return false; } //= 0; - // check if a mesh is too large to export it using IDTYPE; // check either max ID or number of elements template< typename IDTYPE > diff --git a/src/SMESHGUI/SMESHGUI_MeshOp.cxx b/src/SMESHGUI/SMESHGUI_MeshOp.cxx index 46293261d..68791630a 100644 --- a/src/SMESHGUI/SMESHGUI_MeshOp.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshOp.cxx @@ -43,6 +43,7 @@ // SALOME GEOM includes #include #include +#include #include #include #include @@ -318,10 +319,29 @@ SUIT_SelectionFilter* SMESHGUI_MeshOp::createFilter( const int theId ) const return 0; } +//================================================================================ +/*! + * \brief Return type of shape contained in a group + */ +//================================================================================ + +TopAbs_ShapeEnum getGroupType(const TopoDS_Shape& group) +{ + if ( group.ShapeType() != TopAbs_COMPOUND ) + return group.ShapeType(); + + // iterate on a compound + TopoDS_Iterator it( group ); + if ( it.More() ) + return getGroupType( it.Value() ); + + return TopAbs_SHAPE; +} + //================================================================================ /*! * \brief check if selected shape is a sub-shape of the shape to mesh - * \retval bool - check result + * \retval bool - check result */ //================================================================================ bool SMESHGUI_MeshOp::isSubshapeOk() const @@ -354,7 +374,8 @@ bool SMESHGUI_MeshOp::isSubshapeOk() const // check all selected shapes QStringList::const_iterator aSubShapesIter = aGEOMs.begin(); - for ( ; aSubShapesIter != aGEOMs.end(); aSubShapesIter++) { + for ( ; aSubShapesIter != aGEOMs.end(); aSubShapesIter++) + { QString aSubGeomEntry = (*aSubShapesIter); _PTR(SObject) pSubGeom = SMESH::getStudy()->FindObjectID(aSubGeomEntry.toUtf8().data()); if (!pSubGeom) return false; @@ -366,7 +387,8 @@ bool SMESHGUI_MeshOp::isSubshapeOk() const // skl for NPAL14695 - implementation of searching of mainObj GEOM::GEOM_Object_var mainObj = op->GetMainShape(aSubGeomVar); /* _var not _wrap as mainObj already exists! */ - while( !mainObj->_is_nil()) { + while( !mainObj->_is_nil()) + { CORBA::String_var entry1 = mainObj->GetEntry(); CORBA::String_var entry2 = mainGeom->GetEntry(); if (std::string( entry1.in() ) == entry2.in() ) @@ -382,21 +404,18 @@ bool SMESHGUI_MeshOp::isSubshapeOk() const GEOM::SHAPE,/*sorted=*/false); if ( ids->length() > 0 ) { - ids->length( 1 ); - GEOM::GEOM_Object_var compSub = geomGen->AddSubShape( aSubGeomVar, ids ); - if ( !compSub->_is_nil() ) - { - GEOM::ListOfGO_var shared = sop->GetSharedShapes( mainGeom, - compSub, - compSub->GetShapeType() ); - geomGen->RemoveObject( compSub ); - compSub->UnRegister(); - if ( shared->length() > 0 ) { - geomGen->RemoveObject( shared[0] ); - shared[0]->UnRegister(); - } - return ( shared->length() > 0 ); - } + GEOM_Client geomClient; + TopoDS_Shape subShape = geomClient.GetShape( geomGen, aSubGeomVar ); + TopoDS_Shape mainShape = geomClient.GetShape( geomGen, mainGeom ); + if ( subShape.IsNull() || mainShape.IsNull() ) + return false; + + TopAbs_ShapeEnum subType = getGroupType( subShape ); + TopTools_IndexedMapOfShape subMap; + TopExp::MapShapes( subShape, subType, subMap ); + for ( TopExp_Explorer exp( mainShape, subType ); exp.More(); exp.Next() ) + if ( subMap.Contains( exp.Current() )) + return true; } } } From d7de79b9dd07520d47215a609fb23be212357af6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rald=20NICOLAS?= Date: Mon, 10 May 2021 15:10:16 +0200 Subject: [PATCH 17/17] Traduction du panneau d'aide --- src/SMESHGUI/SMESH_msg_fr.ts | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/SMESHGUI/SMESH_msg_fr.ts b/src/SMESHGUI/SMESH_msg_fr.ts index b69f4650a..992eab2df 100644 --- a/src/SMESHGUI/SMESH_msg_fr.ts +++ b/src/SMESHGUI/SMESH_msg_fr.ts @@ -4795,7 +4795,7 @@ Il ne peut pas être supprimé. Generate mesh from CAD model or import mesh - Generate mesh from CAD model or import mesh + Créer un maillage à partir d'un modèle CAO ou par importation @@ -5151,7 +5151,7 @@ Ouvrez une fenêtre VTK et essayez de nouveau PREF_SELECTION_INCREMENT - Elements width increment + Incrément de largeur d'éléments PREF_OBJECT_COLOR @@ -5247,59 +5247,59 @@ Ouvrez une fenêtre VTK et essayez de nouveau INFO_WELCOME_TO_SMESH - Welcome to Mesh + Bienvenue dans le module Mesh INFO_GRP_CREATE_MESH - Create mesh + Créer un maillage INFO_DEFINE_ALGOS - Choose algorithms + Choisir les algorithmes INFO_DEFINE_HYPOS - Define hypotheses + Définir des hypothèses INFO_COMPUTE - Compute + Calculer INFO_REFINE - Add refinements + Ajouter des raffinements INFO_REFINE_LOCAL_SIZE - via local sizes with some hypotheses + via des tailles locales dans certaines hypothèses INFO_REFINE_SUBMESH - via sub-meshes + via des sous-maillages INFO_GRP_IMPORT_MESH - Import mesh + Importer un maillage INFO_AVAILABLE_FORMATS - Available formats + Formats disponibles INFO_GRP_CHECK_MESH - Check mesh quality + Contrôler la qualité du maillage INFO_DISPLAY - Display mesh + Afficher le maillage INFO_QUALITY_INFO - Display some quality criteria + Afficher des critères de qualité INFO_QUALITY_AREA - area + surface INFO_QUALITY_VOLUME @@ -5307,11 +5307,11 @@ Ouvrez une fenêtre VTK et essayez de nouveau INFO_QUALITY_ASPECT_RATION - aspect ration + Facteur de forme INFO_CLIPPING - Add clipping planes + Insérer un plan de coupe