From: GERALD NICOLAS Date: Fri, 29 Jan 2021 10:58:13 +0000 (+0100) Subject: Merge branch 'master' into gni/adaptation X-Git-Tag: V9_7_0a1~18^2~28 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5b9e6708a50563fd33f8d7543a879f9021b38c55;hp=b586ea5065bb78c57dcaee29097c6fd8df52d1d0;p=modules%2Fsmesh.git Merge branch 'master' into gni/adaptation --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 6796fcfe9..f93ed2749 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -191,6 +191,15 @@ IF(NOT WITH_SHAPER_STUDY AND SALOME_BUILD_TESTS) MESSAGE(WARNING "SHAPERSTUDY is not found; the corresponding tests will be omitted") ENDIF() +# Find MEDCoupling +# ================ +SET(MEDCOUPLING_ROOT_DIR $ENV{MEDCOUPLING_ROOT_DIR} CACHE PATH "Path to the MEDCoupling tool") +IF(EXISTS ${MEDCOUPLING_ROOT_DIR}) + FIND_PACKAGE(SalomeMEDCoupling REQUIRED) # will reload HDF5, MEDFile, XDR, etc ... +ELSE(EXISTS ${MEDCOUPLING_ROOT_DIR}) + MESSAGE(FATAL_ERROR "We absolutely need the MEDCoupling tool, please define MEDCOUPLING_ROOT_DIR !") +ENDIF(EXISTS ${MEDCOUPLING_ROOT_DIR}) + ## ## SMESH specifics ## @@ -276,6 +285,16 @@ MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED) MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC) MARK_AS_ADVANCED(SALOME_SMESH_INSTALL_RES_DATA SALOME_SMESH_INSTALL_PLUGINS) +# Specific to ADAPT: +# SET(SALOME_ADAPT_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/adapt" CACHE PATH +# "Install path: SALOME ADAPT specific data") +SET(SALOME_ADAPT_INSTALL_SAMPLES share/salome/adaptsamples CACHE PATH + "Install path: SALOME ADAPT samples") +SET(SALOME_ADAPT_INSTALL_TEST ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test CACHE PATH + "Install path: SALOME ADAPT Test files") +SET(SALOME_ADAPT_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/adapt" CACHE PATH + "Install path: SALOME ADAPT specific data") + # Accumulate environment variables for SMESH module SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS} ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON} @@ -315,6 +334,7 @@ SET(_${PROJECT_NAME}_exposed_targets SMDS SMESHimpl SMESHEngine SMESHClient SMESHDS SMESHUtils StdMeshers StdMeshersEngine MeshJobManagerEngine SPADDERPluginTesterEngine SalomeIDLSMESH SalomeIDLSPADDER + ADAPTEngine ADAPTFrontTrack ADAPTImpl ) IF(SALOME_SMESH_ENABLE_MEFISTO) @@ -324,7 +344,7 @@ ENDIF(SALOME_SMESH_ENABLE_MEFISTO) IF(SALOME_BUILD_GUI) LIST(APPEND _${PROJECT_NAME}_exposed_targets - SMESHObject SMESHFiltersSelection SMESH PluginUtils StdMeshersGUI + SMESHObject SMESHFiltersSelection SMESH PluginUtils StdMeshersGUI ADAPTGUI ) ENDIF(SALOME_BUILD_GUI) diff --git a/idl/ADAPT_Gen.idl b/idl/ADAPT_Gen.idl new file mode 100644 index 000000000..83114652e --- /dev/null +++ b/idl/ADAPT_Gen.idl @@ -0,0 +1,233 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef __ADAPT_GEN__ +#define __ADAPT_GEN__ + +#include "SALOME_Component.idl" +#include "SALOME_Exception.idl" +#include "SALOMEDS.idl" + +#include "HOMARD_Cas.idl" +#include "HOMARD_Hypothesis.idl" +#include "HOMARD_Iteration.idl" +#include "HOMARD_Zone.idl" +#include "HOMARD_Boundary.idl" +#include "HOMARD_YACS.idl" + +module ADAPT +{ + typedef sequence listeHypotheses; + typedef sequence listeZones; + typedef sequence listeIterations; + typedef sequence listeCases; + typedef sequence listeBoundarys; + typedef sequence listeYACSs; + + interface ADAPT_Gen : Engines::EngineComponent, SALOMEDS::Driver + { +// +// A. Les methodes qui suivent sont celles que l'on retrouvera dans +// le fichier resources/HOMARDCatalog.xml.in pour definir le composant HOMARD dans YACS +// A priori, ce sont les seules sont l'utilisateur doit connaitre l'existence. +// ATTENTION : si les noms des arguments changent dans les Createxxxx, il faudra les changer +// dans YACSDriver pour assurer la coherence +// +// A.1. Les creations +// + HOMARD_Boundary CreateBoundaryCAO (in string BoundaryName, in string FileName) + raises(SALOME::SALOME_Exception); + HOMARD_Boundary CreateBoundaryDi (in string BoundaryName, in string MeshName, in string FileName) + raises(SALOME::SALOME_Exception); + HOMARD_Boundary CreateBoundaryCylinder (in string BoundaryName, + in double Xcentre, in double Ycentre, in double Zcentre, + in double Xaxis, in double Yaxis, in double Zaxis, + in double Radius) + raises (SALOME::SALOME_Exception); + HOMARD_Boundary CreateBoundarySphere (in string BoundaryName, + in double Xcentre, in double Ycentre, in double Zcentre, + in double Radius) + raises(SALOME::SALOME_Exception); + HOMARD_Boundary CreateBoundaryConeR (in string BoundaryName, + in double Xcentre1, in double Ycentre1, in double Zcentre1, in double Radius1, + in double Xcentre2, in double Ycentre2, in double Zcentre2, in double Radius2) + raises(SALOME::SALOME_Exception); + HOMARD_Boundary CreateBoundaryConeA (in string BoundaryName, + in double Xaxis, in double Yaxis, in double Zaxis, in double Angle, + in double Xcentre, in double Ycentre, in double Zcentre) + raises(SALOME::SALOME_Exception); + HOMARD_Boundary CreateBoundaryTorus (in string BoundaryName, + in double Xcentre, in double Ycentre, in double Zcentre, + in double Xaxis, in double Yaxis, in double Zaxis, + in double RadiusRev, in double RadiusPri) + raises (SALOME::SALOME_Exception); + HOMARD_Cas CreateCase(in string CaseName, in string MeshName, in string FileName ) + raises(SALOME::SALOME_Exception); + HOMARD_Cas CreateCaseFromIteration(in string CaseName, in string DirNameStart ) + raises(SALOME::SALOME_Exception); + HOMARD_Cas CreateCaseFromCaseLastIteration(in string CaseName, in string DirNameStart ) + raises(SALOME::SALOME_Exception); + HOMARD_Cas CreateCaseFromCaseIteration(in string CaseName, in string DirNameStart, in long Number ) + raises(SALOME::SALOME_Exception); + HOMARD_Hypothesis CreateHypothesis(in string HypoName ) + raises(SALOME::SALOME_Exception); + HOMARD_Zone CreateZoneBox (in string ZoneName, + in double Xmini, in double Xmaxi, + in double Ymini, in double Ymaxi, + in double Zmini, in double Zmaxi) + raises(SALOME::SALOME_Exception); + HOMARD_Zone CreateZoneBox2D (in string ZoneName, + in double Umini, in double Umaxi, + in double Vmini, in double Vmaxi, + in long Orient) + raises(SALOME::SALOME_Exception); + HOMARD_Zone CreateZoneCylinder (in string ZoneName, + in double Xcentre, in double Ycentre, in double Zcentre, + in double Xaxis, in double Yaxis, in double Zaxis, + in double Radius, in double Height) + raises(SALOME::SALOME_Exception); + HOMARD_Zone CreateZoneDisk (in string ZoneName, + in double Ucentre, in double Vcentre, + in double Radius, in long Orient) + raises(SALOME::SALOME_Exception); + HOMARD_Zone CreateZoneDiskWithHole (in string ZoneName, + in double Ucentre, in double Vcentre, + in double Radius, in double InternalRadius, + in long Orient) + raises(SALOME::SALOME_Exception); + HOMARD_Zone CreateZonePipe (in string ZoneName, + in double Xcentre, in double Ycentre, in double Zcentre, + in double Xaxis, in double Yaxis, in double Zaxis, + in double Radius, in double Height, in double InternalRadius) + raises(SALOME::SALOME_Exception); + HOMARD_Zone CreateZoneSphere (in string ZoneName, + in double Xcentre, in double Ycentre, in double Zcentre, + in double Radius) + raises(SALOME::SALOME_Exception); +// +// A.2. Les informations +// + HOMARD_Boundary GetBoundary(in string BoundaryName) raises (SALOME::SALOME_Exception); + HOMARD_Cas GetCase(in string CaseName) raises (SALOME::SALOME_Exception); + HOMARD_Hypothesis GetHypothesis(in string HypoName) raises (SALOME::SALOME_Exception); + HOMARD_Iteration GetIteration(in string IterName) raises (SALOME::SALOME_Exception); + HOMARD_YACS GetYACS(in string YACSName) raises (SALOME::SALOME_Exception); + HOMARD_Zone GetZone(in string ZoneName) raises (SALOME::SALOME_Exception); + + listeBoundarys GetAllBoundarysName() raises (SALOME::SALOME_Exception); + listeCases GetAllCasesName() raises (SALOME::SALOME_Exception); + listeHypotheses GetAllHypothesesName() raises (SALOME::SALOME_Exception); + listeIterations GetAllIterationsName() raises (SALOME::SALOME_Exception); + listeYACSs GetAllYACSsName() raises (SALOME::SALOME_Exception); + listeZones GetAllZonesName() raises (SALOME::SALOME_Exception); + + void MeshInfo(in string CaseName, in string MeshName, in string FileName, in string DirName, in long Qual, in long Diam, in long Conn, in long Tail, in long Inte ) + raises(SALOME::SALOME_Exception); + + HOMARD_Iteration LastIteration(in string CaseName) raises (SALOME::SALOME_Exception); +// +// A.3. L'etude +// + void UpdateStudy() raises (SALOME::SALOME_Exception); +// +// A.4. Les caracteristiques generales +// + void SetLanguageShort (in string LanguageShort) raises (SALOME::SALOME_Exception); + string GetLanguageShort () raises (SALOME::SALOME_Exception); +// +// B. Les methodes qui suivent n'apparaissent pas dans le composant HOMARD dans YACS +// L'utilisateur ne devrait pas les connaitre (ni s'en servir, a fortiori) +// + HOMARD_Iteration CreateIteration(in string IterName, in string PreviousIterName ) + raises(SALOME::SALOME_Exception); +// + void InvalideBoundary (in string BoundaryName) raises (SALOME::SALOME_Exception); + void InvalideHypo (in string HypoName) raises (SALOME::SALOME_Exception); + void InvalideIter (in string IterName) raises (SALOME::SALOME_Exception); + void InvalideIterOption (in string IterName, in long Option) + raises(SALOME::SALOME_Exception); + void InvalideYACS (in string YacsName) raises (SALOME::SALOME_Exception); + void InvalideZone (in string ZoneName) raises (SALOME::SALOME_Exception); + + long DeleteBoundary (in string BoundaryName) raises (SALOME::SALOME_Exception); + long DeleteCase(in string CaseName, in long Option) + raises(SALOME::SALOME_Exception); + long DeleteHypo(in string HypoName) raises (SALOME::SALOME_Exception); + long DeleteIteration(in string IterName, in long Option) + raises(SALOME::SALOME_Exception); + long DeleteIterationOption(in string IterName, in long Option1, in long Option2) + raises(SALOME::SALOME_Exception); + long DeleteYACS(in string YacsName, in long Option) raises (SALOME::SALOME_Exception); + long DeleteZone (in string ZoneName) raises (SALOME::SALOME_Exception); +// + void AssociateIterHypo(in string IterName, in string HypoName) + raises(SALOME::SALOME_Exception); + +// + void AssociateHypoZone(in string HypoName, in string ZoneName, in long TypeUse) + raises(SALOME::SALOME_Exception); + void DissociateHypoZone(in string HypoName, in string ZoneName) + raises(SALOME::SALOME_Exception); + + long Compute (in string IterName, in long CleanOption, in long modeHOMARD, in long Option1, in long Option2) + raises(SALOME::SALOME_Exception); + +// + string CreateDirNameIter(in string NomDir, in long option ) + raises(SALOME::SALOME_Exception); + + string VerifieDir (in string NomDir) raises (SALOME::SALOME_Exception); + +// + void PublishFileUnderIteration(in string IterName, in string FileName, in string Comment) + raises(SALOME::SALOME_Exception); + void PublishBoundaryUnderCase(in string CaseName, in string BoundaryName) + raises(SALOME::SALOME_Exception); + void PublishResultInSmesh(in string FileName, in long Option) + raises(SALOME::SALOME_Exception); + void PublishMeshIterInSmesh (in string IterName) raises(SALOME::SALOME_Exception); + +// + +// +// La creation des schemas YACS + HOMARD_YACS CreateYACSSchema(in string YACSName, in string CaseName, in string ScriptFile, in string DirName, in string MeshFile) + raises(SALOME::SALOME_Exception); + long YACSWrite (in string YACSName) raises (SALOME::SALOME_Exception); + long YACSWriteOnFile (in string YACSName, in string YACSFile) + raises(SALOME::SALOME_Exception); + +// +// Les preferences + void SetPublisMesh (in long PublisMeshIN, in long PublisMeshOUT) + raises (SALOME::SALOME_Exception); + long GetPublisMeshIN () raises (SALOME::SALOME_Exception); + long GetPublisMeshOUT () raises (SALOME::SALOME_Exception); + void SetYACSMaximum(in long YACSMaxIter, in long YACSMaxNode, in long YACSMaxElem) + raises (SALOME::SALOME_Exception); + long GetYACSMaxIter() raises (SALOME::SALOME_Exception); + long GetYACSMaxNode() raises (SALOME::SALOME_Exception); + long GetYACSMaxElem() raises (SALOME::SALOME_Exception); + void SetYACSConvergenceType(in long TypeTest) raises (SALOME::SALOME_Exception); + long GetYACSConvergenceType() raises (SALOME::SALOME_Exception); + }; +}; + +#endif + diff --git a/idl/CMakeLists.txt b/idl/CMakeLists.txt index 7ab17aef9..4a67452e6 100644 --- a/idl/CMakeLists.txt +++ b/idl/CMakeLists.txt @@ -36,6 +36,14 @@ SET(SalomeIDLSMESH_IDLSOURCES SMESH_Pattern.idl SMESH_MeshEditor.idl SMESH_Measurements.idl + HOMARD_Boundary.idl + HOMARD_Cas.idl + ADAPT_Gen.idl + HOMARD_Hypothesis.idl + HOMARD_Iteration.idl + HOMARD_YACS.idl + HOMARD_Zone.idl + MG_ADAPT.idl ) SET(_idl_include_dirs diff --git a/idl/HOMARD_Boundary.idl b/idl/HOMARD_Boundary.idl new file mode 100644 index 000000000..aa7baea61 --- /dev/null +++ b/idl/HOMARD_Boundary.idl @@ -0,0 +1,99 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier +// + +#ifndef _HOMARD_Boundary_IDL +#define _HOMARD_Boundary_IDL + +#include "SALOME_Component.idl" +#include "SALOME_Exception.idl" +#include "SALOMEDS.idl" + +#include "HOMARD_Cas.idl" +#include "HOMARD_Zone.idl" + + +module ADAPT +{ + interface HOMARD_Boundary : Engines::EngineComponent + { +// Generalites + void SetName(in string Name) raises (SALOME::SALOME_Exception); + string GetName() raises (SALOME::SALOME_Exception); + + long Delete() raises (SALOME::SALOME_Exception); + + string GetDumpPython() raises (SALOME::SALOME_Exception); + +// Caracteristiques + void SetType (in long Type) raises (SALOME::SALOME_Exception); + long GetType() raises (SALOME::SALOME_Exception); + + void SetDataFile(in string DataFile) raises (SALOME::SALOME_Exception); + string GetDataFile() raises (SALOME::SALOME_Exception); + + void SetMeshName(in string MeshName) raises (SALOME::SALOME_Exception); + string GetMeshName() raises (SALOME::SALOME_Exception); + + void SetCylinder (in double Xcentre, in double Ycentre, in double Zcentre, + in double Xaxe, in double Yaxe, in double Zaxe, in double rayon) + raises (SALOME::SALOME_Exception); + + void SetSphere (in double Xcentre, in double Ycentre, in double Zcentre, in double rayon) + raises (SALOME::SALOME_Exception); + + void SetConeR (in double Xcentre1, in double Ycentre1, in double Zcentre1, in double Rayon1, + in double Xcentre2, in double Ycentre2, in double Zcentre2, in double Rayon2) + raises (SALOME::SALOME_Exception); + + void SetConeA(in double Xaxe,in double Yaxe,in double Zaxe,in double Angle, + in double Xcentre,in double Ycentre,in double ZCentre) + raises (SALOME::SALOME_Exception); + + void SetTorus (in double Xcentre, in double Ycentre, in double Zcentre, + in double Xaxe, in double Yaxe, in double Zaxe, in double rayonRev, in double rayonPri) + raises (SALOME::SALOME_Exception); + + + ADAPT::double_array GetCoords() raises (SALOME::SALOME_Exception); + + void SetLimit (in double Xincr, in double Yincr, in double Zincr) + raises (SALOME::SALOME_Exception); + ADAPT::double_array GetLimit() raises (SALOME::SALOME_Exception); + + void AddGroup(in string LeGroupe) raises (SALOME::SALOME_Exception); + void SetGroups(in ListGroupType ListGroup) raises (SALOME::SALOME_Exception); + ListGroupType GetGroups() raises (SALOME::SALOME_Exception); + +// Liens avec les autres iterations + void SetCaseCreation(in string NomCas) raises (SALOME::SALOME_Exception); + string GetCaseCreation() raises (SALOME::SALOME_Exception); + + }; +}; +#endif diff --git a/idl/HOMARD_Cas.idl b/idl/HOMARD_Cas.idl new file mode 100644 index 000000000..1e07cc69a --- /dev/null +++ b/idl/HOMARD_Cas.idl @@ -0,0 +1,107 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier +// + +#ifndef _HOMARD_CAS_IDL +#define _HOMARD_CAS_IDL + +#include "SALOME_Component.idl" +#include "SALOME_Exception.idl" +#include "SALOMEDS.idl" + +#include "HOMARD_Iteration.idl" +#include "HOMARD_YACS.idl" + +module ADAPT +{ + typedef sequence extrema ; + typedef sequence ListGroupType ; + typedef sequence ListBoundaryGroupType ; + + + interface HOMARD_Cas : Engines::EngineComponent + { +// Generalites + void SetName(in string Name) raises (SALOME::SALOME_Exception); + string GetName() raises (SALOME::SALOME_Exception); + + long Delete(in long Option) raises (SALOME::SALOME_Exception); + + string GetDumpPython() raises (SALOME::SALOME_Exception); + +// Caracteristiques + void SetDirName(in string NomDir) raises (SALOME::SALOME_Exception); + string GetDirName() raises (SALOME::SALOME_Exception); + + long GetState() raises (SALOME::SALOME_Exception); + + long GetNumberofIter() raises (SALOME::SALOME_Exception); + + void SetConfType(in long ConfType) raises (SALOME::SALOME_Exception); + long GetConfType() raises (SALOME::SALOME_Exception); + + void SetExtType(in long ExtType) raises (SALOME::SALOME_Exception); + long GetExtType() raises (SALOME::SALOME_Exception); + + void SetBoundingBox(in extrema LesExtremes) raises (SALOME::SALOME_Exception); + extrema GetBoundingBox() raises (SALOME::SALOME_Exception); + + void AddGroup(in string Group) raises (SALOME::SALOME_Exception); + void SetGroups(in ListGroupType ListGroup) raises (SALOME::SALOME_Exception); + ListGroupType GetGroups() raises (SALOME::SALOME_Exception); + + void AddBoundary(in string BoundaryName) raises (SALOME::SALOME_Exception); + void AddBoundaryGroup(in string BoundaryName, in string Group) + raises (SALOME::SALOME_Exception); + ListBoundaryGroupType GetBoundaryGroup() raises (SALOME::SALOME_Exception); + void SupprBoundaryGroup() raises (SALOME::SALOME_Exception); + + void SetPyram(in long Pyram) raises (SALOME::SALOME_Exception); + long GetPyram() raises (SALOME::SALOME_Exception); + + void MeshInfo(in long Qual, in long Diam, in long Conn, in long Tail, in long Inte) + raises (SALOME::SALOME_Exception); + +// Liens avec les autres structures + string GetIter0Name () raises (SALOME::SALOME_Exception); + HOMARD_Iteration GetIter0 () raises (SALOME::SALOME_Exception); + + HOMARD_Iteration NextIteration(in string IterName) raises (SALOME::SALOME_Exception); + + HOMARD_Iteration LastIteration() raises (SALOME::SALOME_Exception); + + void AddIteration (in string IterName) raises (SALOME::SALOME_Exception); + +// YACS + HOMARD_YACS CreateYACSSchema(in string YACSName, in string ScriptFile, in string DirName, in string MeshFile) + raises (SALOME::SALOME_Exception); + + + }; +}; +#endif diff --git a/idl/HOMARD_Hypothesis.idl b/idl/HOMARD_Hypothesis.idl new file mode 100644 index 000000000..2e8bd1190 --- /dev/null +++ b/idl/HOMARD_Hypothesis.idl @@ -0,0 +1,136 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier +// + +#ifndef _HOMARD_HYPOTHESIS_IDL +#define _HOMARD_HYPOTHESIS_IDL + +#include "SALOME_Component.idl" +#include "SALOME_Exception.idl" +#include "SALOMEDS.idl" + +#include "HOMARD_Cas.idl" + +module ADAPT +{ + typedef sequence listeZonesHypo ; + typedef sequence listeIters ; + typedef sequence listeComposantsHypo ; + typedef sequence listeTypes ; + typedef sequence listeFieldInterpsHypo ; + + struct InfosHypo + { + string FieldName; + long UsCmpI; + long UsField; + long TypeThR; + double ThreshR; + long TypeThC; + double ThreshC; + }; + + interface HOMARD_Hypothesis : Engines::EngineComponent + { +// Generalites + void SetName(in string Name) raises (SALOME::SALOME_Exception); + string GetName() raises (SALOME::SALOME_Exception); + + long Delete() raises (SALOME::SALOME_Exception); + + string GetDumpPython() raises (SALOME::SALOME_Exception); + +// Caracteristiques + void SetUnifRefinUnRef(in long RaffDera) raises (SALOME::SALOME_Exception); + listeTypes GetAdapRefinUnRef() raises (SALOME::SALOME_Exception); + long GetAdapType() raises (SALOME::SALOME_Exception); + long GetRefinType() raises (SALOME::SALOME_Exception); + long GetUnRefType() raises (SALOME::SALOME_Exception); + + void SetField(in string FieldName) raises (SALOME::SALOME_Exception); + string GetFieldName() raises (SALOME::SALOME_Exception); + void SetUseField(in long UsField) raises (SALOME::SALOME_Exception); + InfosHypo GetField() raises (SALOME::SALOME_Exception); + + void SetUseComp(in long UsCmpI) raises (SALOME::SALOME_Exception); + void AddComp(in string NomComp) raises (SALOME::SALOME_Exception); + void SupprComp(in string NomComp) raises (SALOME::SALOME_Exception); + void SupprComps() raises (SALOME::SALOME_Exception); + listeComposantsHypo GetComps() raises (SALOME::SALOME_Exception); + + void SetRefinThr(in long TypeThR, in double ThreshR) + raises (SALOME::SALOME_Exception); + long GetRefinThrType() raises (SALOME::SALOME_Exception); + void SetUnRefThr(in long TypeThC, in double ThreshC) + raises (SALOME::SALOME_Exception); + long GetUnRefThrType() raises (SALOME::SALOME_Exception); + + void SetNivMax(in long NivMax) raises (SALOME::SALOME_Exception); + long GetNivMax() raises (SALOME::SALOME_Exception); + + void SetDiamMin(in double DiamMin) raises (SALOME::SALOME_Exception); + double GetDiamMin() raises (SALOME::SALOME_Exception); + + void SetAdapInit(in long AdapInit) raises (SALOME::SALOME_Exception); + long GetAdapInit() raises (SALOME::SALOME_Exception); + + void SetExtraOutput(in long ExtraOutput) raises (SALOME::SALOME_Exception); + long GetExtraOutput() raises (SALOME::SALOME_Exception); + + void AddGroup(in string LeGroupe) raises (SALOME::SALOME_Exception); + void SupprGroup(in string LeGroupe) raises (SALOME::SALOME_Exception); + void SupprGroups() raises (SALOME::SALOME_Exception); + void SetGroups(in ListGroupType ListGroup) raises (SALOME::SALOME_Exception); + ListGroupType GetGroups() raises (SALOME::SALOME_Exception); + + void SetTypeFieldInterp(in long TypeFieldInterp) raises (SALOME::SALOME_Exception); + long GetTypeFieldInterp() raises (SALOME::SALOME_Exception); + void AddFieldInterp(in string FieldInterp) raises (SALOME::SALOME_Exception); + void AddFieldInterpType(in string FieldInterp, in long TypeInterp) + raises (SALOME::SALOME_Exception); + void SupprFieldInterp(in string FieldInterp) raises (SALOME::SALOME_Exception); + void SupprFieldInterps() raises (SALOME::SALOME_Exception); + listeFieldInterpsHypo GetFieldInterps() raises (SALOME::SALOME_Exception); + +// Liens avec les autres structures + void SetCaseCreation(in string NomCas) raises (SALOME::SALOME_Exception); + string GetCaseCreation() raises (SALOME::SALOME_Exception); + + void LinkIteration(in string NomIteration) raises (SALOME::SALOME_Exception); + void UnLinkIteration(in string NomIteration) raises (SALOME::SALOME_Exception); + listeIters GetIterations() raises (SALOME::SALOME_Exception); + + void AddZone(in string NomZone, in long TypeUse) raises (SALOME::SALOME_Exception); + void AddZone0(in string NomZone, in long TypeUse) raises (SALOME::SALOME_Exception); + void SupprZone(in string NomZone) raises (SALOME::SALOME_Exception); + void SupprZones() raises (SALOME::SALOME_Exception); + listeZonesHypo GetZones() raises (SALOME::SALOME_Exception); + + }; +}; +#endif diff --git a/idl/HOMARD_Iteration.idl b/idl/HOMARD_Iteration.idl new file mode 100644 index 000000000..67512a6a4 --- /dev/null +++ b/idl/HOMARD_Iteration.idl @@ -0,0 +1,130 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier +// + +#ifndef _HOMARD_ITERATION_IDL +#define _HOMARD_ITERATION_IDL + +#include "SALOME_Component.idl" +#include "SALOME_Exception.idl" +#include "SALOMEDS.idl" + +module ADAPT +{ + typedef sequence listeIterFilles ; + typedef sequence listeFieldInterpsIter ; + typedef sequence listeFieldInterpTSRsIter ; + + interface HOMARD_Iteration : Engines::EngineComponent + { +// Generalites + void SetName(in string Name) raises (SALOME::SALOME_Exception); + string GetName() raises (SALOME::SALOME_Exception); + + long Delete(in long Option) raises (SALOME::SALOME_Exception); + + string GetDumpPython() raises (SALOME::SALOME_Exception); + +// Caracteristiques + void SetDirNameLoc(in string NomDir) raises (SALOME::SALOME_Exception); + string GetDirNameLoc() raises (SALOME::SALOME_Exception); + + string GetDirName() raises (SALOME::SALOME_Exception); + + void SetNumber(in long NumIter) raises (SALOME::SALOME_Exception); + long GetNumber() raises (SALOME::SALOME_Exception); + + void SetState(in long State) raises (SALOME::SALOME_Exception); + long GetState() raises (SALOME::SALOME_Exception); + + void SetMeshName(in string NomMesh) raises (SALOME::SALOME_Exception); + string GetMeshName() raises (SALOME::SALOME_Exception); + + void SetMeshFile(in string MeshFile) raises (SALOME::SALOME_Exception); + string GetMeshFile() raises (SALOME::SALOME_Exception); + + void SetFieldFile(in string FieldFile) raises (SALOME::SALOME_Exception); + string GetFieldFile() raises (SALOME::SALOME_Exception); + +// Instants pour le champ de pilotage + void SetTimeStep(in long TimeStep) raises (SALOME::SALOME_Exception); + void SetTimeStepRank(in long TimeStep, in long Rank) + raises (SALOME::SALOME_Exception); + void SetTimeStepRankLast() raises (SALOME::SALOME_Exception); + long GetTimeStep() raises (SALOME::SALOME_Exception); + long GetRank() raises (SALOME::SALOME_Exception); + +// Instants pour un champ a interpoler + void SetFieldInterpTimeStep(in string FieldInterp, in long TimeStep) + raises (SALOME::SALOME_Exception); + void SetFieldInterpTimeStepRank(in string FieldInterp, in long TimeStep, in long Rank) + raises (SALOME::SALOME_Exception); + listeFieldInterpTSRsIter GetFieldInterpsTimeStepRank() raises (SALOME::SALOME_Exception); + void SetFieldInterp(in string FieldInterp) raises (SALOME::SALOME_Exception); + listeFieldInterpsIter GetFieldInterps() raises (SALOME::SALOME_Exception); + void SupprFieldInterps() raises (SALOME::SALOME_Exception); + +// Fichier des messages + void SetLogFile(in string LogFile) raises (SALOME::SALOME_Exception); + string GetLogFile() raises (SALOME::SALOME_Exception); + + long Compute(in long etatMenage, in long Option) raises (SALOME::SALOME_Exception); + + void MeshInfo(in long Qual, in long Diam, in long Conn, in long Tail, in long Inte) + raises (SALOME::SALOME_Exception); + void MeshInfoOption(in long Qual, in long Diam, in long Conn, in long Tail, in long Inte, in long Option) + raises (SALOME::SALOME_Exception); + + void SetFileInfo(in string FileInfo) raises (SALOME::SALOME_Exception); + string GetFileInfo() raises (SALOME::SALOME_Exception); + +// Liens avec les autres iterations + HOMARD_Iteration NextIteration(in string NomIter) raises (SALOME::SALOME_Exception); + + void LinkNextIteration(in string NomIter) raises (SALOME::SALOME_Exception); + void UnLinkNextIteration(in string NomIter) raises (SALOME::SALOME_Exception); + listeIterFilles GetIterations() raises (SALOME::SALOME_Exception); + + void SetIterParentName(in string NomIterParent) raises (SALOME::SALOME_Exception); + string GetIterParentName() raises (SALOME::SALOME_Exception); + HOMARD_Iteration GetIterParent() raises (SALOME::SALOME_Exception); + +// Liens avec les autres structures + void SetCaseName(in string NomCas) raises (SALOME::SALOME_Exception); + string GetCaseName() raises (SALOME::SALOME_Exception); + + void AssociateHypo(in string NomHypo) raises (SALOME::SALOME_Exception); + void SetHypoName(in string NomHypo) raises (SALOME::SALOME_Exception); + string GetHypoName() raises (SALOME::SALOME_Exception); + +// Divers + void SetInfoCompute(in long MessInfo) raises (SALOME::SALOME_Exception); + long GetInfoCompute() raises (SALOME::SALOME_Exception); + }; +}; +#endif diff --git a/idl/HOMARD_YACS.idl b/idl/HOMARD_YACS.idl new file mode 100644 index 000000000..538e0ec20 --- /dev/null +++ b/idl/HOMARD_YACS.idl @@ -0,0 +1,87 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier +// + +#ifndef _HOMARD_YACS_IDL +#define _HOMARD_YACS_IDL + +#include "SALOME_Component.idl" +#include "SALOME_Exception.idl" +#include "SALOMEDS.idl" + +module ADAPT +{ + interface HOMARD_YACS : Engines::EngineComponent + { +// Generalites + void SetName(in string Name) raises (SALOME::SALOME_Exception); + string GetName() raises (SALOME::SALOME_Exception); + + long Delete(in long Option) raises (SALOME::SALOME_Exception); + + string GetDumpPython() raises (SALOME::SALOME_Exception); + +// Caracteristiques + void SetType (in long Type) raises (SALOME::SALOME_Exception); + long GetType() raises (SALOME::SALOME_Exception); + + void SetMaxIter (in long MaxIter) raises (SALOME::SALOME_Exception); + long GetMaxIter() raises (SALOME::SALOME_Exception); + void SetMaxNode (in long MaxNode) raises (SALOME::SALOME_Exception); + long GetMaxNode() raises (SALOME::SALOME_Exception); + void SetMaxElem (in long MaxElem) raises (SALOME::SALOME_Exception); + long GetMaxElem() raises (SALOME::SALOME_Exception); + + void SetTestConvergence (in long TypeTest, in double VRef) + raises (SALOME::SALOME_Exception); + long GetTestConvergenceType() raises (SALOME::SALOME_Exception); + double GetTestConvergenceVRef() raises (SALOME::SALOME_Exception); + + void SetDirName(in string NomDir) raises (SALOME::SALOME_Exception); + string GetDirName() raises (SALOME::SALOME_Exception); + + void SetMeshFile(in string MeshFile) raises (SALOME::SALOME_Exception); + string GetMeshFile() raises (SALOME::SALOME_Exception); + + void SetScriptFile(in string ScriptFile) raises (SALOME::SALOME_Exception); + string GetScriptFile() raises (SALOME::SALOME_Exception); + + void SetXMLFile(in string XMLFile) raises (SALOME::SALOME_Exception); + string GetXMLFile() raises (SALOME::SALOME_Exception); + + long Write() raises (SALOME::SALOME_Exception); + long WriteOnFile( in string YACSFile ) raises (SALOME::SALOME_Exception); + +// Liens avec les autres structures + void SetCaseName(in string NomCas) raises (SALOME::SALOME_Exception); + string GetCaseName() raises (SALOME::SALOME_Exception); + +// Divers + }; +}; +#endif diff --git a/idl/HOMARD_Zone.idl b/idl/HOMARD_Zone.idl new file mode 100644 index 000000000..691246ea4 --- /dev/null +++ b/idl/HOMARD_Zone.idl @@ -0,0 +1,83 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier +// + +#ifndef _HOMARD_Zone_IDL +#define _HOMARD_Zone_IDL + +#include "SALOME_Component.idl" +#include "SALOME_Exception.idl" +#include "SALOMEDS.idl" + +module ADAPT +{ + typedef sequence double_array ; + typedef sequence listeHypo ; + + interface HOMARD_Zone : Engines::EngineComponent + { +// Generalites + void SetName(in string Name) raises (SALOME::SALOME_Exception); + string GetName() raises (SALOME::SALOME_Exception); + + long Delete() raises (SALOME::SALOME_Exception); + + string GetDumpPython() raises (SALOME::SALOME_Exception); + +// Caracteristiques + void SetType (in long Type) raises (SALOME::SALOME_Exception); + long GetType() raises (SALOME::SALOME_Exception); + + void SetBox (in double Xmini, in double Xmaxi, in double Ymini, + in double Ymaxi, in double Zmini, in double Zmaxi) + raises (SALOME::SALOME_Exception); + void SetCylinder (in double Xcentre, in double Ycentre, in double Zcentre, + in double Xaxis, in double Yaxis, in double Zaxis, + in double Rayon, in double Haut) + raises (SALOME::SALOME_Exception); + void SetPipe( in double Xcentre, in double Ycentre, in double ZCentre, + in double Xaxis, in double Yaxis, in double Zaxis, + in double Rayon, in double Haut, in double Rayonint ) + raises (SALOME::SALOME_Exception); + void SetSphere (in double Xcentre, in double Ycentre, in double Zcentre, in double rayon) + raises (SALOME::SALOME_Exception); + + double_array GetCoords() raises (SALOME::SALOME_Exception); + + void SetLimit (in double Xincr, in double Yincr, in double Zincr) + raises (SALOME::SALOME_Exception); + double_array GetLimit() raises (SALOME::SALOME_Exception); + +// Liens avec les autres structures + void AddHypo(in string NomHypo) raises (SALOME::SALOME_Exception); + listeHypo GetHypo() raises (SALOME::SALOME_Exception); + void SupprHypo(in string NomHypo) raises (SALOME::SALOME_Exception); + + }; +}; +#endif diff --git a/idl/MG_ADAPT.idl b/idl/MG_ADAPT.idl new file mode 100644 index 000000000..3a593fde7 --- /dev/null +++ b/idl/MG_ADAPT.idl @@ -0,0 +1,158 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ +// +// File : MG_ADAPT.hxx +// +#ifndef MG_ADAPT_IDL +#define MG_ADAPT_IDL + + +#include "SALOME_Component.idl" +#include "SALOME_Exception.idl" +#include "SALOME_GenericObj.idl" +#include "SALOMEDS.idl" +#include "SMESH_Mesh.idl" + +module SMESH{ + + typedef sequence str_array ; + struct MgAdaptHypothesisData + { + string myFileInDir, myMeshFileIn, myInMeshName, myMeshFileBackground, myOutMeshName, + myMeshFileOut, myFileOutDir, myFileSizeMapDir, myFieldName; + boolean fromMedFile; + boolean myPublish, myMeshOutMed; + boolean myUseLocalMap, myUseBackgroundMap, myUseConstantValue; + double myConstantValue; + long myRank, myTimeStep; + boolean myUseNoTimeStep, myUseLastTimeStep, myUseChosenTimeStep; + string myWorkingDir, myLogFile; + boolean myPrintLogInFile, myKeepFiles, myRemoveLogOnSuccess; + long myVerboseLevel; + + }; + + + interface MG_ADAPT : SALOME::GenericObj + { + //MG_ADAPT CreateMG_ADAPT(in PortableServer::POA_var poa); + void setData( inout MgAdaptHypothesisData data); + + void setMedFileIn(in string MedFileIn ); + string getMedFileIn(); + + void setMedFileOut(in string MedFileOut); + string getMedFileOut(); + + void setMeshName(in string s); + string getMeshName(); + + void setMeshNameOut(in string s); + string getMeshNameOut(); + + void setMeshOutMed(in boolean b); + boolean getMeshOutMed(); + + void setPublish(in boolean b); + boolean getPublish(); + + void setSizeMapFieldName(in string s); + string getSizeMapFieldName(); + + void setTimeStep(in long s); + long getTimeStep() ; + + void setTimeStepRank(in long s, in long f); + long getRank(); + + void setTimeStepRankLast(); + void setNoTimeStep(); + + void setLogFile(in string f); + string getLogFile(); + + void setVerbosityLevel(in long f); + long getVerbosityLevel(); + + void setRemoveOnSuccess(in boolean f); + boolean getRemoveOnSuccess(); + + MgAdaptHypothesisData getData(); + + void setUseLocalMap(in boolean f); + boolean getUseLocalMap(); + + void setUseBackgroundMap(in boolean f); + boolean getUseBackgroundMap(); + + void setUseConstantValue(in boolean f); + boolean getUseConstantValue(); + + void setConstantSize(in double f); + double getConstantSize() ; + + void setSizeMapFile(in string f); + string getSizeMapFile(); + + void setFromMedFile(in boolean f); + boolean isFromMedFile(); + + void setKeepWorkingFiles(in boolean f); + boolean getKeepWorkingFiles(); + + void setPrintLogInFile(in boolean f); + boolean getPrintLogInFile(); + + void setWorkingDir(in string f); + string getWorkingDir() ; + + void setSizeMapType(in string f); + boolean setAll(); + string getCommandToRun() ; + //long compute(out string errStr); + long compute(); + string getErrMsg(); + string getFileName() ; + string getExeName(); + void copyMgAdaptHypothesisData(in MgAdaptHypothesisData f ) ; + + //void checkDirPath(inout string f); + + + + boolean hasOptionDefined( in string optionName ) ; + void setOptionValue(in string optionName, + in string optionValue) raises (SALOME::SALOME_Exception); + string getOptionValue(in string optionName, + inout boolean isDefault) raises (SALOME::SALOME_Exception); + str_array getCustomOptionValuesStrVec() ; + str_array getOptionValuesStrVec() ; + }; + typedef MG_ADAPT MG_ADAPT_HYPOTHESIS; + interface MG_ADAPT_OBJECT : SALOME::GenericObj + { + void setMeshIn(in SMESH_Mesh theMesh ); + void setMEDFileIn(in string f); + void setMEDFileOut(in string f); + void setMEDFileBackground(in string f); + void AddHypothesis(in MG_ADAPT mg); + long Compute(in boolean Publish); + }; + +}; +#endif // MG_ADAPT_IDL diff --git a/idl/SMESH_Gen.idl b/idl/SMESH_Gen.idl index a7e4c5094..52295a43b 100644 --- a/idl/SMESH_Gen.idl +++ b/idl/SMESH_Gen.idl @@ -43,6 +43,8 @@ module SMESH interface FilterManager; interface SMESH_Pattern; interface Measurements; + interface MG_ADAPT; + interface MG_ADAPT_OBJECT; /*! * Tags definition @@ -136,7 +138,6 @@ module SMESH SMESH_Pattern GetPattern(); Measurements CreateMeasurements(); - /*! Set the current mode */ @@ -584,7 +585,10 @@ module SMESH in GEOM::GEOM_Object theGeom, in double theTolerance ); - + + MG_ADAPT CreateMG_ADAPT(); + MG_ADAPT_OBJECT Adaptation(in string adaptType); + MG_ADAPT CreateAdaptationHypothesis(); }; }; diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 1a5619a10..9bc947916 100644 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -22,6 +22,11 @@ SET(SMESH_RESOURCES_FILES ModuleMesh.png + adapt_hom_iter_next.png + adapt_hom_iter_poursuite.png + adapt_mg_adapt.png + adapt_ref_all.png + adapt_ref_homard.png advanced_mesh_info.png bare_border_face.png bare_border_volume.png diff --git a/resources/SalomeApp.xml.in b/resources/SalomeApp.xml.in index c69c4b578..1f4c5dee5 100644 --- a/resources/SalomeApp.xml.in +++ b/resources/SalomeApp.xml.in @@ -98,6 +98,17 @@ + + + + + + + + + + +
diff --git a/resources/adapt_hom_iter_next.png b/resources/adapt_hom_iter_next.png new file mode 100755 index 000000000..3bbcbd640 Binary files /dev/null and b/resources/adapt_hom_iter_next.png differ diff --git a/resources/adapt_hom_iter_poursuite.png b/resources/adapt_hom_iter_poursuite.png new file mode 100755 index 000000000..10ee5f7f6 Binary files /dev/null and b/resources/adapt_hom_iter_poursuite.png differ diff --git a/resources/adapt_mg_adapt.png b/resources/adapt_mg_adapt.png new file mode 100755 index 000000000..f2c1a93eb Binary files /dev/null and b/resources/adapt_mg_adapt.png differ diff --git a/resources/adapt_ref_all.png b/resources/adapt_ref_all.png new file mode 100755 index 000000000..21b2841d1 Binary files /dev/null and b/resources/adapt_ref_all.png differ diff --git a/resources/adapt_ref_homard.png b/resources/adapt_ref_homard.png new file mode 100755 index 000000000..d00710129 Binary files /dev/null and b/resources/adapt_ref_homard.png differ diff --git a/src/ADAPT/ADAPT_Gen.cxx b/src/ADAPT/ADAPT_Gen.cxx new file mode 100644 index 000000000..94e762ed5 --- /dev/null +++ b/src/ADAPT/ADAPT_Gen.cxx @@ -0,0 +1,41 @@ +// HOMARD HOMARD : implementation of HOMARD idl descriptions +// +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : ADAPT_Gen.cxx +// Author : Gerald NICOLAS, EDF +// Module : HOMARD + +#include "ADAPT_Gen.hxx" +#include "utilities.h" + +//============================================================================= +//============================================================================= +ADAPT_Gen::ADAPT_Gen() +{ + MESSAGE("ADAPT_Gen"); +} + +//============================================================================= +//============================================================================= +ADAPT_Gen::~ADAPT_Gen() +{ + MESSAGE("~ADAPT_Gen"); +} +//============================================================================= diff --git a/src/ADAPT/ADAPT_Gen.hxx b/src/ADAPT/ADAPT_Gen.hxx new file mode 100644 index 000000000..7a7d05098 --- /dev/null +++ b/src/ADAPT/ADAPT_Gen.hxx @@ -0,0 +1,37 @@ +// HOMARD HOMARD : implementation of HOMARD idl descriptions +// +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : ADAPT_Gen.hxx +// Author : Gerald NICOLAS, EDF +// Module : HOMARD + +#ifndef _ADAPT_GEN_HXX_ +#define _ADAPT_GEN_HXX_ + +#include "HOMARD.hxx" + +class HOMARDIMPL_EXPORT ADAPT_Gen +{ +public : + ADAPT_Gen(); + ~ADAPT_Gen(); +}; + +#endif diff --git a/src/ADAPT/CMakeLists.txt b/src/ADAPT/CMakeLists.txt new file mode 100644 index 000000000..cfaabe454 --- /dev/null +++ b/src/ADAPT/CMakeLists.txt @@ -0,0 +1,79 @@ +# Copyright (C) 2012-2020 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# --- options --- +# additional include directories +INCLUDE_DIRECTORIES( + ${KERNEL_INCLUDE_DIRS} + ${MEDCOUPLING_INCLUDE_DIRS} +) + +# additional preprocessor / compiler flags +ADD_DEFINITIONS( + ${KERNEL_DEFINITIONS} +) + +# libraries to link to +SET(_link_LIBRARIES + ${KERNEL_SALOMELocalTrace} + ${MEDCoupling_medloader} +) + +# --- headers --- + +# header files +SET(ADAPTImpl_HEADERS + HOMARD.hxx + HOMARD_Cas.hxx + HOMARD_Boundary.hxx + HOMARD_Hypothesis.hxx + HOMARD_Iteration.hxx + HOMARD_Zone.hxx + ADAPT_Gen.hxx + HOMARD_DriverTools.hxx + HOMARD_YACS.hxx + HomardDriver.hxx + YACSDriver.hxx + #~MG_ADAPT.hxx +) + +# --- sources --- + +# sources / static +SET(ADAPTImpl_SOURCES + HOMARD_Cas.cxx + HOMARD_Boundary.cxx + HOMARD_Hypothesis.cxx + HOMARD_Iteration.cxx + HOMARD_Zone.cxx + ADAPT_Gen.cxx + HOMARD_DriverTools.cxx + HOMARD_YACS.cxx + HomardDriver.cxx + YACSDriver.cxx + #~MG_ADAPT.cxx +) + +# --- rules --- + +ADD_LIBRARY(ADAPTImpl ${ADAPTImpl_SOURCES}) +TARGET_LINK_LIBRARIES(ADAPTImpl ${_link_LIBRARIES} ) +INSTALL(TARGETS ADAPTImpl EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +INSTALL(FILES ${ADAPTImpl_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) diff --git a/src/ADAPT/HOMARD.hxx b/src/ADAPT/HOMARD.hxx new file mode 100644 index 000000000..012f212b4 --- /dev/null +++ b/src/ADAPT/HOMARD.hxx @@ -0,0 +1,53 @@ +// HOMARD HOMARD : implementation of HOMARD idl descriptions +// +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : HOMARD.hxx +// Author : Gerald NICOLAS, EDF +// Module : HOMARD + +#ifndef _HOMARD_HXX_ +#define _HOMARD_HXX_ + +// C'est le ASSERT de SALOMELocalTrace/utilities.h dans KERNEL +#ifndef VERIFICATION +#define VERIFICATION(condition) \ + if (!(condition)){INTERRUPTION("CONDITION "<<#condition<<" NOT VERIFIED")} +#endif /* VERIFICATION */ + +#ifdef WIN32 + #if defined HOMARDIMPL_EXPORTS || defined HOMARDImpl_EXPORTS + #define HOMARDIMPL_EXPORT __declspec( dllexport ) + #else + #define HOMARDIMPL_EXPORT __declspec( dllimport ) + #endif +#else + #define HOMARDIMPL_EXPORT +#endif + +// La gestion des repertoires +#ifndef CHDIR + #ifdef WIN32 + #define CHDIR _chdir + #else + #define CHDIR chdir + #endif +#endif + +#endif diff --git a/src/ADAPT/HOMARD_Boundary.cxx b/src/ADAPT/HOMARD_Boundary.cxx new file mode 100644 index 000000000..0115278db --- /dev/null +++ b/src/ADAPT/HOMARD_Boundary.cxx @@ -0,0 +1,324 @@ +// HOMARD HOMARD : implementation of HOMARD idl descriptions +// +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : HOMARD_Boundary.cxx +// Author : Gerald NICOLAS, EDF +// Module : HOMARD +// +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier + +#include "HOMARD_Boundary.hxx" +#include "HOMARD.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * default constructor: + */ +//============================================================================= +HOMARD_Boundary::HOMARD_Boundary(): + _Name( "" ),_Type( 1 ), + _Xmin( 0 ), _Xmax( 0 ), _Ymin( 0 ), _Ymax( 0 ), _Zmin( 0 ), _Zmax( 0 ), + _Xaxe( 0 ), _Yaxe( 0 ), _Zaxe( 0 ), + _Xcentre( 0 ), _Ycentre( 0 ), _Zcentre( 0 ), _rayon( 0 ), + _Xincr( 0 ), _Yincr( 0 ), _Zincr( 0 ) +{ + MESSAGE("HOMARD_Boundary"); +} + +//============================================================================= +HOMARD_Boundary::~HOMARD_Boundary() +{ + MESSAGE("~HOMARD_Boundary"); +} +//============================================================================= +//============================================================================= +// Generalites +//============================================================================= +//============================================================================= +void HOMARD_Boundary::SetName( const char* Name ) +{ + _Name = std::string( Name ); +} +//============================================================================= +std::string HOMARD_Boundary::GetName() const +{ + return _Name; +} +//============================================================================= +std::string HOMARD_Boundary::GetDumpPython() const +{ + std::ostringstream aScript; + aScript << "\n# Creation of the "; +// + switch (_Type) + { + case -1: + { + aScript << "CAO boundary " << _Name << "\n"; + aScript << "\t" << _Name << " = homard.CreateBoundaryCAO(\"" << _Name << "\", "; + aScript << "\"" << _DataFile << "\")\n"; + break ; + } + case 0: + { + aScript << "discrete boundary " << _Name << "\n"; + aScript << "\t" << _Name << " = homard.CreateBoundaryDi(\"" << _Name << "\", "; + aScript << "\"" << _MeshName << "\", "; + aScript << "\"" << _DataFile << "\")\n"; + break ; + } + case 1: + { + aScript << "cylinder " << _Name << "\n"; + aScript << "\t" << _Name << " = homard.CreateBoundaryCylinder(\"" << _Name << "\", "; + aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _rayon << ")\n"; + break ; + } + case 2: + { + aScript << "sphere " << _Name << "\n"; + aScript << "\t" << _Name << " = homard.CreateBoundarySphere(\"" << _Name << "\", "; + aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _rayon << ")\n"; + break ; + } + case 3: + { + aScript << "cone " << _Name << "\n"; + aScript << "\t" << _Name << " = homard.CreateBoundaryConeA(\"" << _Name << "\", "; + aScript << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Angle << ", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ")\n"; + break ; + } + case 4: + { + aScript << "cone " << _Name << "\n"; + aScript << "\t" << _Name << " = homard.CreateBoundaryConeR(\"" << _Name << "\", "; + aScript << _Xcentre1 << ", " << _Ycentre1 << ", " << _Zcentre1 << ", " << _Rayon1 << ", " << _Xcentre2 << ", " << _Ycentre2 << ", " << _Zcentre2 << ", " << _Rayon2 << ")\n"; + break ; + } + case 5: + { + aScript << "tore " << _Name << "\n"; + aScript << "\t" << _Name << " = homard.CreateBoundaryTorus(\"" << _Name << "\", "; + aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Rayon1 << ", " << _Rayon2 << ")\n"; + break ; + } + } + + return aScript.str(); +} +//============================================================================= +//============================================================================= +// Caracteristiques +//============================================================================= +//============================================================================= +void HOMARD_Boundary::SetType( int Type ) +{ + _Type = Type; +} +//============================================================================= +int HOMARD_Boundary::GetType() const +{ + return _Type; +} +//============================================================================= +void HOMARD_Boundary::SetMeshName( const char* MeshName ) +{ + _MeshName = std::string( MeshName ); +} +//============================================================================= +std::string HOMARD_Boundary::GetMeshName() const +{ + return _MeshName; +} +//============================================================================= +void HOMARD_Boundary::SetDataFile( const char* DataFile ) +{ + _DataFile = std::string( DataFile ); +} +//============================================================================= +std::string HOMARD_Boundary::GetDataFile() const +{ + return _DataFile; +} +//======================================================================================= +void HOMARD_Boundary::SetCylinder( double X0, double X1, double X2, + double X3, double X4, double X5, double X6 ) +{ + _Xcentre = X0; _Ycentre = X1; _Zcentre = X2; + _Xaxe = X3; _Yaxe = X4; _Zaxe = X5; + _rayon = X6; +} +//====================================================================== +void HOMARD_Boundary::SetSphere( double X0, double X1, double X2, double X3 ) +{ + _Xcentre = X0; _Ycentre = X1; _Zcentre = X2; + _rayon = X3; +} +//====================================================================== +void HOMARD_Boundary::SetConeR( double Xcentre1, double Ycentre1, double Zcentre1, double Rayon1, + double Xcentre2, double Ycentre2, double Zcentre2, double Rayon2) +{ + _Xcentre1 = Xcentre1; _Ycentre1 = Ycentre1; _Zcentre1 = Zcentre1; + _Rayon1 = Rayon1; + _Xcentre2 = Xcentre2; _Ycentre2 = Ycentre2; _Zcentre2 = Zcentre2; + _Rayon2 = Rayon2; +} +//====================================================================== +void HOMARD_Boundary::SetConeA( double Xaxe, double Yaxe, double Zaxe, double Angle, + double Xcentre, double Ycentre, double Zcentre) +{ + _Xaxe = Xaxe; _Yaxe = Yaxe; _Zaxe = Zaxe; + _Angle = Angle; + _Xcentre = Xcentre; _Ycentre = Ycentre; _Zcentre = Zcentre; +} +//======================================================================================= +void HOMARD_Boundary::SetTorus( double X0, double X1, double X2, + double X3, double X4, double X5, double X6, double X7 ) +{ + _Xcentre = X0; _Ycentre = X1; _Zcentre = X2; + _Xaxe = X3; _Yaxe = X4; _Zaxe = X5; + _Rayon1 = X6; + _Rayon2 = X7; +} +//======================================================================================= +std::vector HOMARD_Boundary::GetCoords() const +{ + std::vector mesCoor; +// + switch (_Type) + { +// Cylindre + case 1: + { + mesCoor.push_back( _Xcentre ); + mesCoor.push_back( _Ycentre ); + mesCoor.push_back( _Zcentre ); + mesCoor.push_back( _Xaxe ); + mesCoor.push_back( _Yaxe ); + mesCoor.push_back( _Zaxe ); + mesCoor.push_back( _rayon ); + break ; + } +// Sphere + case 2: + { + mesCoor.push_back( _Xcentre ); + mesCoor.push_back( _Ycentre ); + mesCoor.push_back( _Zcentre ); + mesCoor.push_back( _rayon ); + break ; + } +// Cone defini par un axe et un angle + case 3: + { + mesCoor.push_back( _Xaxe ); + mesCoor.push_back( _Yaxe ); + mesCoor.push_back( _Zaxe ); + mesCoor.push_back( _Angle ); + mesCoor.push_back( _Xcentre ); + mesCoor.push_back( _Ycentre ); + mesCoor.push_back( _Zcentre ); + break ; + } +// Cone defini par les 2 rayons + case 4: + { + mesCoor.push_back( _Xcentre1 ); + mesCoor.push_back( _Ycentre1 ); + mesCoor.push_back( _Zcentre1 ); + mesCoor.push_back( _Rayon1 ); + mesCoor.push_back( _Xcentre2 ); + mesCoor.push_back( _Ycentre2 ); + mesCoor.push_back( _Zcentre2 ); + mesCoor.push_back( _Rayon2 ); + break ; + } +// Tore + case 5: + { + mesCoor.push_back( _Xcentre ); + mesCoor.push_back( _Ycentre ); + mesCoor.push_back( _Zcentre ); + mesCoor.push_back( _Xaxe ); + mesCoor.push_back( _Yaxe ); + mesCoor.push_back( _Zaxe ); + mesCoor.push_back( _Rayon1 ); + mesCoor.push_back( _Rayon2 ); + break ; + } + VERIFICATION( (_Type>=1) && (_Type<=5) ) ; + } + return mesCoor; +} +//====================================================================== +void HOMARD_Boundary::SetLimit( double X0, double X1, double X2 ) +{ + _Xincr = X0; _Yincr = X1; _Zincr = X2; +} +//======================================================================================= +std::vector HOMARD_Boundary::GetLimit() const +{ + std::vector mesLimit; + mesLimit.push_back( _Xincr ); + mesLimit.push_back( _Yincr ); + mesLimit.push_back( _Zincr ); + return mesLimit; +} +//============================================================================= +void HOMARD_Boundary::AddGroup( const char* Group) +{ + _ListGroupSelected.push_back(Group); +} +//============================================================================= +void HOMARD_Boundary::SetGroups( const std::list& ListGroup ) +{ + _ListGroupSelected.clear(); + std::list::const_iterator it = ListGroup.begin(); + while(it != ListGroup.end()) + _ListGroupSelected.push_back((*it++)); +} +//============================================================================= +const std::list& HOMARD_Boundary::GetGroups() const +{ + return _ListGroupSelected; +} +//============================================================================= +//============================================================================= +// Liens avec les autres structures +//============================================================================= +//============================================================================= +void HOMARD_Boundary::SetCaseCreation( const char* NomCasCreation ) +{ + _NomCasCreation = std::string( NomCasCreation ); +} +//============================================================================= +std::string HOMARD_Boundary::GetCaseCreation() const +{ + return _NomCasCreation; +} +//============================================================================= diff --git a/src/ADAPT/HOMARD_Boundary.hxx b/src/ADAPT/HOMARD_Boundary.hxx new file mode 100644 index 000000000..ddbffae6b --- /dev/null +++ b/src/ADAPT/HOMARD_Boundary.hxx @@ -0,0 +1,111 @@ +// HOMARD HOMARD : implementation of HOMARD idl descriptions +// +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : HOMARD_Boundary.hxx +// Author : Gerald NICOLAS, EDF +// Module : HOMARD +// +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier + +#ifndef _HOMARD_Boundary_HXX_ +#define _HOMARD_Boundary_HXX_ + +#include "HOMARD.hxx" + +#include +#include +#include + +#if defined WIN32 +#pragma warning ( disable: 4251 ) +#endif + +class HOMARDIMPL_EXPORT HOMARD_Boundary +{ +public: + HOMARD_Boundary(); + ~HOMARD_Boundary(); + +// Generalites + void SetName( const char* Name ); + std::string GetName() const; + + std::string GetDumpPython() const; + +// Caracteristiques + void SetType( int Type ); + int GetType() const; + + void SetMeshName( const char* MeshName ); + std::string GetMeshName() const; + + void SetDataFile( const char* DataFile ); + std::string GetDataFile() const; + + void SetCylinder( double X0, double X1, double X2, double X3, + double X4, double X5, double X6 ); + void SetSphere( double X0, double X1, double X2, double X3 ); + void SetConeR( double Xcentre1, double Ycentre1, double Zcentre1, double Rayon1, + double Xcentre2, double Ycentre2, double Zcentre2, double Rayon2); + void SetConeA( double Xaxe, double Yaxe, double Zaxe, double Angle, + double Xcentre, double Ycentre, double ZCentre); + void SetTorus( double X0, double X1, double X2, double X3, + double X4, double X5, double X6, double X7 ); + + std::vector GetCoords() const; + + void SetLimit( double X0, double X1, double X2 ); + std::vector GetLimit() const; + + void AddGroup( const char* LeGroupe); + void SetGroups(const std::list& ListGroup ); + const std::list& GetGroups() const; + +// Liens avec les autres structures + std::string GetCaseCreation() const; + void SetCaseCreation( const char* NomCasCreation ); + +private: + std::string _Name; + std::string _NomCasCreation; + std::string _DataFile; + std::string _MeshName; + int _Type; + double _Xmin, _Xmax, _Ymin, _Ymax, _Zmin, _Zmax; + double _Xaxe, _Yaxe, _Zaxe; + double _Xcentre, _Ycentre, _Zcentre, _rayon; + double _Xincr, _Yincr, _Zincr; + double _Xcentre1, _Ycentre1, _Zcentre1, _Rayon1; + double _Xcentre2, _Ycentre2, _Zcentre2, _Rayon2; + double _Angle; + + std::list _ListGroupSelected; + +}; + + +#endif diff --git a/src/ADAPT/HOMARD_Cas.cxx b/src/ADAPT/HOMARD_Cas.cxx new file mode 100644 index 000000000..1493c8ff1 --- /dev/null +++ b/src/ADAPT/HOMARD_Cas.cxx @@ -0,0 +1,283 @@ +// HOMARD HOMARD : implementation of HOMARD idl descriptions +// +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : HOMARD_Cas.cxx +// Author : Gerald NICOLAS, EDF +// Module : HOMARD +// +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier + +#include "HOMARD_Cas.hxx" +#include "utilities.h" +#include "HOMARD.hxx" +#include +#include + +#ifndef WIN32 +#include +#else +#include +#endif + +//============================================================================= +/*! + * default constructor: + * Par defaut, l'adaptation est conforme, sans suivi de frontiere + */ +//============================================================================= +HOMARD_Cas::HOMARD_Cas(): + _Name(""), _NomDir("/tmp"), _ConfType(0), _ExtType(0) +{ + MESSAGE("HOMARD_Cas"); +} +//============================================================================= +HOMARD_Cas::~HOMARD_Cas() +//============================================================================= +{ + MESSAGE("~HOMARD_Cas"); +} +//============================================================================= +//============================================================================= +// Generalites +//============================================================================= +//============================================================================= +void HOMARD_Cas::SetName( const char* Name ) +{ + _Name = std::string( Name ); +} +//============================================================================= +std::string HOMARD_Cas::GetName() const +{ + return _Name; +} +//============================================================================= +std::string HOMARD_Cas::GetDumpPython() const +{ + std::ostringstream aScript; + aScript << "\t" <<_Name << ".SetDirName(\""; + aScript << _NomDir << "\")\n"; + aScript << "\t" <<_Name << ".SetConfType("; + aScript << _ConfType << ")\n"; + aScript << "\t" <<_Name << ".SetExtType("; + aScript << _ExtType << ")\n"; +// Suivi de frontieres + std::list::const_iterator it = _ListBoundaryGroup.begin(); + while(it != _ListBoundaryGroup.end()) + { + aScript << "\t" <<_Name << ".AddBoundaryGroup(\""; + aScript << *it << "\", \""; + it++; + aScript << *it << "\")\n"; + it++; + } + if ( _Pyram > 0 ) + { + aScript << "\t" <<_Name << ".SetPyram("; + aScript << _Pyram << ")\n"; + } + + return aScript.str(); +} +//============================================================================= +//============================================================================= +// Caracteristiques +//============================================================================= +//============================================================================= +int HOMARD_Cas::SetDirName( const char* NomDir ) +{ +// MESSAGE("SetDirName, NomDir : "< 1 ) { erreur = 1 ; } + // Creation + if ( CHDIR(NomDir) == 0 ) + { _NomDir = std::string( NomDir ); } + else + { + +#ifndef WIN32 + if ( mkdir(NomDir, S_IRWXU|S_IRGRP|S_IXGRP) == 0 ) +#else + if ( _mkdir(NomDir) == 0 ) +#endif + { + if ( CHDIR(NomDir) == 0 ) { _NomDir = std::string( NomDir ); } + else { erreur = 2 ; } + } + else { erreur = 2 ; } + }; + return erreur ; +} +//============================================================================= +std::string HOMARD_Cas::GetDirName() const +{ + return _NomDir; +} +//============================================================================= +int HOMARD_Cas::GetNumberofIter() +{ + return _ListIter.size(); +} +// +// Le type de conformite ou non conformite +// +//============================================================================= +void HOMARD_Cas::SetConfType( int Conftype ) +{ +// VERIFICATION( (Conftype>=-2) && (Conftype<=3) ); + _ConfType = Conftype; +} +//============================================================================= +const int HOMARD_Cas::GetConfType() const +{ + return _ConfType; +} +// +// Le type exterieur +// +//============================================================================= +void HOMARD_Cas::SetExtType( int ExtType ) +{ +// VERIFICATION( (ExtType>=0) && (ExtType<=2) ); + _ExtType = ExtType; +} +//============================================================================= +const int HOMARD_Cas::GetExtType() const +{ + return _ExtType; +} +// +// La boite englobante +// +//============================================================================= +void HOMARD_Cas::SetBoundingBox( const std::vector& extremas ) +{ + _Boite.clear(); + _Boite.resize( extremas.size() ); + for ( int i = 0; i < extremas.size(); i++ ) + _Boite[i] = extremas[i]; +} +//============================================================================= +const std::vector& HOMARD_Cas::GetBoundingBox() const +{ + return _Boite; +} +// +// Les groupes +// +//============================================================================= +void HOMARD_Cas::AddGroup( const char* Group ) +{ + _ListGroup.push_back(Group); +} +//============================================================================= +void HOMARD_Cas::SetGroups( const std::list& ListGroup ) +{ + _ListGroup.clear(); + std::list::const_iterator it = ListGroup.begin(); + while(it != ListGroup.end()) + { + _ListGroup.push_back((*it++)); + } +} +//============================================================================= +const std::list& HOMARD_Cas::GetGroups() const +{ + return _ListGroup; +} +//============================================================================= +void HOMARD_Cas::SupprGroups() +{ + _ListGroup.clear(); +} +// +// Les frontieres +// +//============================================================================= +void HOMARD_Cas::AddBoundary( const char* Boundary ) +{ +// MESSAGE ( ". HOMARD_Cas::AddBoundary : Boundary = " << Boundary ); + const char* Group = ""; + AddBoundaryGroup( Boundary, Group ); +} +//============================================================================= +void HOMARD_Cas::AddBoundaryGroup( const char* Boundary, const char* Group ) +{ +// MESSAGE ( ". HOMARD_Cas::AddBoundaryGroup : Boundary = " << Boundary ); +// MESSAGE ( ". HOMARD_Cas::AddBoundaryGroup : Group = " << Group ); + _ListBoundaryGroup.push_back( Boundary ); + _ListBoundaryGroup.push_back( Group ); +} +//============================================================================= +const std::list& HOMARD_Cas::GetBoundaryGroup() const +{ + return _ListBoundaryGroup; +} +//============================================================================= +void HOMARD_Cas::SupprBoundaryGroup() +{ + _ListBoundaryGroup.clear(); +} +//============================================================================= +void HOMARD_Cas::SetPyram( int Pyram ) +{ + _Pyram = Pyram; +} +//============================================================================= +const int HOMARD_Cas::GetPyram() const +{ + return _Pyram; +} +//============================================================================= +//============================================================================= +// Liens avec les autres structures +//============================================================================= +//============================================================================= +std::string HOMARD_Cas::GetIter0Name() const +{ +// Par construction de la liste, l'iteration a ete mise en tete. + return (*(_ListIter.begin())); +} +//============================================================================= +void HOMARD_Cas::AddIteration( const char* NomIteration ) +{ + _ListIter.push_back( std::string( NomIteration ) ); +} +//============================================================================= +const std::list& HOMARD_Cas::GetIterations() const +{ + return _ListIter; +} +//============================================================================= +void HOMARD_Cas::SupprIterations() +{ + _ListIter.clear(); +} + + diff --git a/src/ADAPT/HOMARD_Cas.hxx b/src/ADAPT/HOMARD_Cas.hxx new file mode 100644 index 000000000..71127136e --- /dev/null +++ b/src/ADAPT/HOMARD_Cas.hxx @@ -0,0 +1,112 @@ +// HOMARD HOMARD : implementation of HOMARD idl descriptions +// +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : HOMARD_Cas.hxx +// Author : Gerald NICOLAS, EDF +// Module : HOMARD +// +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier + +#ifndef _HOMARD_CAS_HXX_ +#define _HOMARD_CAS_HXX_ + +#include "HOMARD.hxx" + +#include +#include +#include + +#if defined WIN32 +#pragma warning ( disable: 4251 ) +#endif + +class HOMARDIMPL_EXPORT HOMARD_Cas +{ +public: + HOMARD_Cas(); + ~HOMARD_Cas(); + +// Generalites + void SetName( const char* Name ); + std::string GetName() const; + + std::string GetDumpPython() const; + +// Caracteristiques + int SetDirName( const char* NomDir ); + std::string GetDirName() const; + + int GetNumberofIter(); + + void SetConfType( int ConfType ); + const int GetConfType() const; + + void SetExtType( int ExtType ); + const int GetExtType() const; + + void SetBoundingBox( const std::vector& extremas ); + const std::vector& GetBoundingBox() const; + + void AddGroup( const char* Group); + void SetGroups( const std::list& ListGroup ); + const std::list& GetGroups() const; + void SupprGroups(); + + void AddBoundary( const char* Boundary ); + void AddBoundaryGroup( const char* Boundary, const char* Group ); + const std::list& GetBoundaryGroup() const; + void SupprBoundaryGroup(); + + void SetPyram( int Pyram ); + const int GetPyram() const; + +// Liens avec les autres structures + std::string GetIter0Name() const; + + void AddIteration( const char* NomIteration ); + const std::list& GetIterations() const; + void SupprIterations(); + +private: + std::string _Name; + std::string _NomDir; + int _ConfType; + int _ExtType; + int _Etat; + + std::vector _Boite; // cf HomardQTCommun pour structure du vecteur + std::list _ListGroup; + std::list _ListBoundaryGroup; + + int _Pyram; + + typedef std::string IterName; + typedef std::list IterNames; + IterNames _ListIter; +}; + +#endif diff --git a/src/ADAPT/HOMARD_DriverTools.cxx b/src/ADAPT/HOMARD_DriverTools.cxx new file mode 100644 index 000000000..74ec51209 --- /dev/null +++ b/src/ADAPT/HOMARD_DriverTools.cxx @@ -0,0 +1,840 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : HOMARD_DriverTools.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// +// ---------------------------------------------------------------------------- + +#include "HOMARD_DriverTools.hxx" +#include "HOMARD_Boundary.hxx" +#include "HOMARD_Cas.hxx" +#include "HOMARD_Hypothesis.hxx" +#include "HOMARD_Iteration.hxx" +#include "HOMARD_Zone.hxx" +#include "HOMARD_YACS.hxx" +#include +#include +#include "utilities.h" + +namespace ADAPT +{ + + std::string SEPARATOR = "|" ; + + /*! + \brief Read next chunk of data from the string + \internal + + The function tries to read next chunk of the data from the input string \a str. + The parameter \a start specifies the start position of next chunk. If the operation + read the chunk successfully, after its completion this parameter will refer to the + start position of the next chunk. The function returns resulting chunk as a string. + The status of the operation is returned via \a ok parameter. + + \param str source data stream string + \param start start position to get next chunk + \param ok in this variable the status of the chunk reading operation is returned + \return next chunk read from the string + */ + static std::string getNextChunk( const std::string& str, std::string::size_type& start, bool& ok ) + { + std::string chunk = ""; + ok = false; + if ( start <= str.size() ) { + std::string::size_type end = str.find( separator(), start ); + chunk = str.substr( start, end == std::string::npos ? std::string::npos : end-start ); + start = end == std::string::npos ? str.size()+1 : end + separator().size(); + ok = true; + } + return chunk; + } + + /*! + \brief Get persistence signature + \param type persistence entity type + \return persistence signature + */ + std::string GetSignature( SignatureType type ) + { + std::string signature = ""; + switch ( type ) { + case Case: signature = "CASE"; break; + case Zone: signature = "ZONE"; break; + case Hypothesis: signature = "HYPO"; break; + case Iteration: signature = "ITER"; break; + case Boundary: signature = "BOUNDARY"; break; + case YACS: signature = "YACS"; break; + default: break; + } + signature += separator(); + return signature; + } + + /*! + \brief Get data separator + \return string that is used to separate data entities in the stream + */ + std::string separator() + { + return SEPARATOR ; + } + +// ======================= +// 1.1. Case +// ======================= + /*! + \brief Dump case to the string + \param cas case being dumped + \return string representation of the case + */ + std::string Dump( const HOMARD_Cas& cas ) + { + std::stringstream os; + std::string saux ; + // ... + MESSAGE( ". Sauvegarde du cas "< coor = cas.GetBoundingBox(); + os << separator() << coor.size(); + for ( int i = 0; i < coor.size(); i++ ) + os << separator() << coor[i]; + + std::list ListString = cas.GetIterations(); + os << separator() << ListString.size(); + std::list::const_iterator it; + for ( it = ListString.begin(); it != ListString.end(); ++it ) + os << separator() << *it; + + ListString = cas.GetGroups(); + os << separator() << ListString.size(); + for ( it = ListString.begin(); it != ListString.end(); ++it ) + os << separator() << *it; + ListString = cas.GetBoundaryGroup(); + os << separator() << ListString.size(); + for ( it = ListString.begin(); it != ListString.end(); ++it ) + os << separator() << *it; + + os << separator() << cas.GetPyram(); + + saux = os.str(); +// MESSAGE( ". Fin avec "< ListString = iteration.GetIterations(); + os << separator() << ListString.size(); + std::list::const_iterator it; + for ( it = ListString.begin(); it != ListString.end(); ++it ) + os << separator() << *it; + + os << separator() << iteration.GetHypoName(); + os << separator() << iteration.GetCaseName(); + os << separator() << iteration.GetDirNameLoc(); + + saux = os.str(); +// MESSAGE( ". Fin avec "< ListString = hypothesis.GetIterations(); + std::list::const_iterator it; + os << separator() << ListString.size(); + for ( it = ListString.begin(); it != ListString.end(); ++it ) + os << separator() << *it; + + ListString = hypothesis.GetZones(); + os << separator() << ListString.size(); + for ( it = ListString.begin(); it != ListString.end(); ++it ) + os << separator() << *it; + + ListString = hypothesis.GetComps(); + os << separator() << ListString.size(); + for ( it = ListString.begin(); it != ListString.end(); ++it ) + os << separator() << *it; + + ListString = hypothesis.GetGroups(); + os << separator() << ListString.size(); + for ( it = ListString.begin(); it != ListString.end(); ++it ) + os << separator() << *it; + + ListString = hypothesis.GetFieldInterps(); + os << separator() << ListString.size(); + for ( it = ListString.begin(); it != ListString.end(); ++it ) + os << separator() << *it; + + os << separator() << hypothesis.GetNivMax(); + os << separator() << hypothesis.GetDiamMin(); + os << separator() << hypothesis.GetAdapInit(); + os << separator() << hypothesis.GetExtraOutput(); + + saux = os.str(); +// MESSAGE( ". Fin avec "< coords = zone.GetCoords(); + for ( int i = 0; i < coords.size(); i++ ) + os << separator() << ( i < coords.size() ? coords[i] : 0. ); + + std::vector limit = zone.GetLimit(); + for ( int i = 0; i < 3; i++ ) + os << separator() << ( i < limit.size() ? limit[i] : 0. ); + + std::list hypos = zone.GetHypo(); + os << separator() << hypos.size(); + std::list::const_iterator it; + for ( it = hypos.begin(); it != hypos.end(); ++it ) + os << separator() << *it; + + saux = os.str(); +// MESSAGE( ". Fin avec "< coor = boundary.GetCoords() ; + for ( int i = 0; i < coor.size(); i++ ) + os << separator() << coor[i]; + std::vector limit = boundary.GetLimit(); + for ( int i = 0; i < limit.size(); i++ ) + os << separator() << limit[i]; + } + + std::list ListString = boundary.GetGroups(); + std::list::const_iterator it; + os << separator() << ListString.size(); + for ( it = ListString.begin(); it != ListString.end(); ++it ) + os << separator() << *it; + + saux = os.str(); +// MESSAGE( ". Fin avec "< boite; + boite.resize( size ); + for ( int i = 0; i < size; i++ ) { + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + boite[i] = strtod( chunk.c_str(), 0 ); + } + cas.SetBoundingBox( boite ); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + + size = atoi( chunk.c_str() ); + for ( int i = 0; i < size; i++ ) { + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + cas.AddIteration( chunk.c_str() ); + } + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + size = atoi( chunk.c_str() ); + for ( int i = 0; i < size; i++ ) + { + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + cas.AddGroup( chunk.c_str() ); + } + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + size = atoi( chunk.c_str() ); + for ( int i = 0; i < size; i++ ) { + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + i++; + chunkNext = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + cas.AddBoundaryGroup( chunk.c_str(), chunkNext.c_str() ); + } + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + cas.SetPyram( atoi( chunk.c_str() ) ); + + return true; + } +// +// ============== +// 2.2. Iteration +// ============== + /*! + \brief Restore iteration from the string + \param iteration iteration being restored + \param stream string representation of the iteration + \return \c true if iteration is correctly restored or \c false otherwise + */ + bool Restore( HOMARD_Iteration& iteration, const std::string& stream ) + { + std::string::size_type start = 0; + std::string chunk; + bool ok; + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + + iteration.SetName( chunk.c_str() ); + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + iteration.SetState( atoi( chunk.c_str() ) ); + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + iteration.SetNumber( atoi( chunk.c_str() ) ); + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + iteration.SetMeshFile( chunk.c_str() ); + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + iteration.SetLogFile( chunk.c_str() ); + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + iteration.SetMeshName( chunk.c_str() ); + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + iteration.SetFieldFile( chunk.c_str() ); + // . + int timestep, rank; + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + timestep = atoi( chunk.c_str() ); + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + rank = atoi( chunk.c_str() ); + iteration.SetTimeStepRank( timestep, rank ); + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + iteration.SetIterParentName( chunk.c_str() ); + // + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + int size = atoi( chunk.c_str() ); + for ( int i = 0; i < size; i++ ) { + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + iteration.LinkNextIteration( chunk.c_str() ); + } + // + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + iteration.SetHypoName( chunk.c_str() ); + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + iteration.SetCaseName( chunk.c_str() ); + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + iteration.SetDirNameLoc( chunk.c_str() ); + return true; + } + +// +// ============== +// 2.3. hypothese +// ============== + /*! + \brief Restore hypothesis from the string + \param hypothesis hypothesis being restored + \param stream string representation of the hypothesis + \return \c true if hypothesis is correctly restored or \c false otherwise + */ + bool Restore( HOMARD_Hypothesis& hypothesis, const std::string& stream ) + { + std::string::size_type start = 0; + std::string chunk, chunkNext; + bool ok; + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + hypothesis.SetName( chunk.c_str() ); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + hypothesis.SetCaseCreation( chunk.c_str() ); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + hypothesis.SetAdapType( atoi( chunk.c_str() ) ); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + int typeraff = atoi( chunk.c_str() ); + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + int typedera = atoi( chunk.c_str() ); + hypothesis.SetRefinTypeDera( typeraff, typedera ); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + hypothesis.SetField( chunk.c_str() ); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + int typethr = atoi( chunk.c_str() ); + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + double threshr = strtod( chunk.c_str(), 0 ); + hypothesis.SetRefinThr( typethr, threshr ); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + int typethc = atoi( chunk.c_str() ); + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + double threshc = strtod( chunk.c_str(), 0 ); + hypothesis.SetUnRefThr( typethc, threshc ); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + hypothesis.SetUseField(atoi(chunk.c_str())); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + hypothesis.SetUseComp(atoi(chunk.c_str())); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + hypothesis.SetTypeFieldInterp(atoi(chunk.c_str())); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + int size = atoi( chunk.c_str() ); + for ( int i = 0; i < size; i++ ) { + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + hypothesis.LinkIteration( chunk.c_str() ); + } + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + size = atoi( chunk.c_str() ); + for ( int i = 0; i < size; i++ ) { + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + i++; + chunkNext = getNextChunk( stream, start, ok ); + int typeuse = atoi( chunkNext.c_str() ); + if ( !ok ) return false; + hypothesis.AddZone( chunk.c_str(), typeuse ); + } + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + size = atoi( chunk.c_str() ); + for ( int i = 0; i < size; i++ ) { + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + hypothesis.AddComp( chunk.c_str() ); + } + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + size = atoi( chunk.c_str() ); + for ( int i = 0; i < size; i++ ) { + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + hypothesis.AddGroup( chunk.c_str() ); + } + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + size = atoi( chunk.c_str() ); + for ( int i = 0; i < size; i++ ) { + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + i++; + chunkNext = getNextChunk( stream, start, ok ); + int TypeInterp = atoi( chunkNext.c_str() ); + if ( !ok ) return false; + hypothesis.AddFieldInterpType( chunk.c_str(), TypeInterp ); + } + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + hypothesis.SetNivMax( atoi( chunk.c_str() ) ); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + hypothesis.SetDiamMin( strtod( chunk.c_str(), 0 ) ); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + hypothesis.SetAdapInit( strtod( chunk.c_str(), 0 ) ); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + hypothesis.SetExtraOutput( strtod( chunk.c_str(), 0 ) ); + + return true; + } + +// +// ========= +// 2.4. Zone +// ========= + /*! + \brief Restore zone from the string + \param zone zone being restored + \param stream string representation of the zone + \return \c true if zone is correctly restored or \c false otherwise + */ + bool Restore( HOMARD_Zone& zone, const std::string& stream ) + { + std::string::size_type start = 0; + std::string chunk; + bool ok; + // + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + zone.SetName( chunk.c_str() ); + // + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + int ZoneType = atoi( chunk.c_str() ) ; + zone.SetType( ZoneType ); + // Les coordonnees des zones : le nombre depend du type + std::vector coords; + int lgcoords ; + if ( ZoneType == 2 || ( ZoneType >= 11 && ZoneType <= 13 ) ) { lgcoords = 6 ; } + else if ( ZoneType == 4 ) { lgcoords = 4 ; } + else if ( ZoneType == 5 || ( ZoneType >= 31 && ZoneType <= 33 ) ) { lgcoords = 8 ; } + else if ( ZoneType == 7 || ( ZoneType >= 61 && ZoneType <= 63 ) ) { lgcoords = 9 ; } + else return false; + coords.resize( lgcoords ); + for ( int i = 0; i < lgcoords; i++ ) { + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + coords[i] = strtod( chunk.c_str(), 0 ); + } + if ( ZoneType == 2 || ( ZoneType >= 11 && ZoneType <= 13 ) ) + { zone.SetBox( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5] ); } + else if ( ZoneType == 4 ) + { zone.SetSphere( coords[0], coords[1], coords[2], coords[3] ); } + else if ( ZoneType == 5 || ( ZoneType >= 31 && ZoneType <= 33 ) ) + { zone.SetCylinder( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7] ); } + else if ( ZoneType == 7 || ( ZoneType >= 61 && ZoneType <= 63 ) ) + { zone.SetPipe( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7], coords[8] ); } + // Remarque : la taille de coords est suffisante pour les limites + for ( int i = 0; i < 3; i++ ) { + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + coords[i] = strtod( chunk.c_str(), 0 ); + } + zone.SetLimit( coords[0], coords[1], coords[2]); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + int size = atoi( chunk.c_str() ); + for ( int i = 0; i < size; i++ ) { + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + zone.AddHypo( chunk.c_str() ); + } + return true; + } + +// +// ================================= +// 2.5. Restauration d'une frontiere +// ================================= + + /*! + \brief Restore boundary from the string + \param boundary boundary being restored + \param stream string representation of the boundary + \return \c true if the boundary is correctly restored or \c false otherwise + */ + bool Restore( HOMARD_Boundary& boundary, const std::string& stream ) + { + std::string::size_type start = 0; + std::string chunk; + bool ok; + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + boundary.SetName( chunk.c_str() ); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + int BoundaryType = atoi( chunk.c_str() ) ; + boundary.SetType( BoundaryType ); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + boundary.SetCaseCreation( chunk.c_str() ); + + // Si analytique, les coordonnees des frontieres : le nombre depend du type + // Si discret, le maillage + // Si CAO, la géométrie + int lgcoords ; + if ( BoundaryType == -1 ) { lgcoords = -1 ; } + else if ( BoundaryType == 1 ) { lgcoords = 7 ; } + else if ( BoundaryType == 2 ) { lgcoords = 4 ; } + else { lgcoords = 0 ; } +// + if ( lgcoords == -1 ) + { + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + boundary.SetDataFile( chunk.c_str() ); + } + else if ( lgcoords == 0 ) + { + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + boundary.SetMeshName( chunk.c_str() ); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + boundary.SetDataFile( chunk.c_str() ); + } + else + { std::vector coords; + coords.resize( lgcoords ); + for ( int i = 0; i < lgcoords; i++ ) { + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + coords[i] = strtod( chunk.c_str(), 0 ); + } + if ( BoundaryType == 1 ) + { boundary.SetCylinder(coords[0],coords[1],coords[2],coords[3],coords[4],coords[5],coords[6]); } + else if ( BoundaryType == 2 ) + { boundary.SetSphere( coords[0], coords[1], coords[2], coords[3]); } + else if ( BoundaryType == 3 ) + { boundary.SetConeA( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6]); } + else if ( BoundaryType == 4 ) + { boundary.SetConeR( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7]); } + // Remarque : la taille de coords est suffisante pour les limites + for ( int i = 0; i < 3; i++ ) { + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + coords[i] = strtod( chunk.c_str(), 0 ); + } + boundary.SetLimit( coords[0], coords[1], coords[2]); + } + // Les groupes + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + int size = atoi( chunk.c_str() ); + for ( int i = 0; i < size; i++ ) { + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + boundary.AddGroup( chunk.c_str() ); + } + + return true; + } + +// +// ================================== +// 2.6. Restauration d'un schema YACS +// ================================== + + /*! + \brief Restore a schema YACS from the string + \param yacs yacs being restored + \param stream string representation of the schema yacs + \return \c true if yacs is correctly restored or \c false otherwise + */ + bool Restore( HOMARD_YACS& yacs, const std::string& stream ) + { + std::string::size_type start = 0; + std::string chunk; + bool ok; + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + yacs.SetName( chunk.c_str() ); + + chunk = getNextChunk( stream, start, ok ); + if ( !ok ) return false; + int YACSType = atoi( chunk.c_str() ) ; + yacs.SetType( YACSType ); + + return true; + } + +} // namespace ADAPT /end/ diff --git a/src/ADAPT/HOMARD_DriverTools.hxx b/src/ADAPT/HOMARD_DriverTools.hxx new file mode 100644 index 000000000..e7aff54f8 --- /dev/null +++ b/src/ADAPT/HOMARD_DriverTools.hxx @@ -0,0 +1,76 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : HOMARD_DriverTools.hxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// +// ---------------------------------------------------------------------------- + +#ifndef HOMARD_DRIVERTOOLS_H +#define HOMARD_DRIVERTOOLS_H + +#include "HOMARD.hxx" + +#include + +class HOMARD_Boundary; +class HOMARD_Cas; +class HOMARD_Iteration; +class HOMARD_Hypothesis; +class HOMARD_Zone; +class HOMARD_YACS; + +namespace ADAPT +{ + //! persistence entity type + typedef enum { Case, Zone, Hypothesis, Iteration, Boundary, YACS } SignatureType; + + //! get persistence signature + HOMARDIMPL_EXPORT std::string GetSignature( SignatureType type ); + + //! get data separator + HOMARDIMPL_EXPORT std::string separator(); + + //! dump boundary to the string + HOMARDIMPL_EXPORT std::string Dump( const ::HOMARD_Boundary& boundary ); + //! dump case to the string + HOMARDIMPL_EXPORT std::string Dump( const ::HOMARD_Cas& cas ); + //! dump iteration to the string + HOMARDIMPL_EXPORT std::string Dump( const ::HOMARD_Iteration& iteration ); + //! dump hypothesis to the string + HOMARDIMPL_EXPORT std::string Dump( const ::HOMARD_Hypothesis& hypothesis ); + //! dump zone to the string + HOMARDIMPL_EXPORT std::string Dump( const ::HOMARD_Zone& zone ); + //! dump yacs to the string + HOMARDIMPL_EXPORT std::string Dump( const ::HOMARD_YACS& yacs ); + + //! restore boundary from the string + HOMARDIMPL_EXPORT bool Restore( ::HOMARD_Boundary& boundary, const std::string& stream ); + //! restore case from the string + HOMARDIMPL_EXPORT bool Restore( ::HOMARD_Cas& cas, const std::string& stream ); + //! restore hypothesis from the string + HOMARDIMPL_EXPORT bool Restore( ::HOMARD_Hypothesis& hypothesis, const std::string& stream ); + //! restore iteration from the string + HOMARDIMPL_EXPORT bool Restore( ::HOMARD_Iteration& iteration, const std::string& stream ); + //! restore zone from the string + HOMARDIMPL_EXPORT bool Restore( ::HOMARD_Zone& zone, const std::string& stream ); + //! restore yacs from the string + HOMARDIMPL_EXPORT bool Restore( ::HOMARD_YACS& yacs, const std::string& stream ); +}; + +#endif // HOMARD_DRIVERTOOLS_H diff --git a/src/ADAPT/HOMARD_Hypothesis.cxx b/src/ADAPT/HOMARD_Hypothesis.cxx new file mode 100644 index 000000000..a957b57ba --- /dev/null +++ b/src/ADAPT/HOMARD_Hypothesis.cxx @@ -0,0 +1,524 @@ +// HOMARD HOMARD : implementation of HOMARD idl descriptions +// +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : HOMARD_Hypothesis.cxx +// Author : Gerald NICOLAS, EDF +// Module : HOMARD +// +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier + +#include "HOMARD_Hypothesis.hxx" +#include "HOMARD.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * default constructor: + */ +//============================================================================= +HOMARD_Hypothesis::HOMARD_Hypothesis(): + _Name(""), _NomCasCreation(""), + _TypeAdap(-1), _TypeRaff(0), _TypeDera(0), + _Field(""), + _TypeThR(0), _ThreshR(0), + _TypeThC(0), _ThreshC(0), + _UsField(0), _UsCmpI(0), _TypeFieldInterp(0) +{ + MESSAGE("HOMARD_Hypothesis"); +} + +//============================================================================= +/*! + */ +//============================================================================= +HOMARD_Hypothesis::~HOMARD_Hypothesis() +{ + MESSAGE("~HOMARD_Hypothesis"); +} +//============================================================================= +//============================================================================= +// Generalites +//============================================================================= +//============================================================================= +void HOMARD_Hypothesis::SetName( const char* Name ) +{ + _Name = std::string( Name ); +} +//============================================================================= +std::string HOMARD_Hypothesis::GetName() const +{ + return _Name; +} +//============================================================================= +std::string HOMARD_Hypothesis::GetDumpPython() const +{ + std::ostringstream aScript; + aScript << "\n# Creation of the hypothesis " << _Name << "\n" ; + aScript << "\t" << _Name << " = homard.CreateHypothesis(\"" << _Name << "\")\n"; + if ( _TypeAdap == -1 ) + { + int TypeRaffDera ; + if ( _TypeRaff == 1 ) { TypeRaffDera = 1 ; } + else { TypeRaffDera = -1 ; } + aScript << "\t" << _Name << ".SetUnifRefinUnRef(" << TypeRaffDera << ")\n"; + } + +// Raffinement selon des zones geometriques + std::list::const_iterator it = _ListZone.begin(); + int TypeUse ; + while(it != _ListZone.end()) + { + aScript << "\t" << _Name << ".AddZone(\"" << *it; + it++; + if ( *it == "1" ) { TypeUse = 1 ; } + else { TypeUse = -1 ; } + aScript << "\", " << TypeUse << ")\n"; + it++; + } + +// Raffinement selon un champ + if ( _TypeAdap == 1 ) + { + aScript << "\t" << _Name << ".SetField(\"" << _Field << "\")\n"; + aScript << "\t" << _Name << ".SetUseField(" << _UsField << ")\n"; + aScript << "\t" << _Name << ".SetUseComp(" << _UsCmpI << ")\n"; + std::list::const_iterator it_comp = _ListComp.begin(); + while(it_comp != _ListComp.end()) + { + aScript << "\t" << _Name << ".AddComp(\"" << *it_comp << "\")\n"; + it_comp++; + } + if ( _TypeRaff == 1 ) + { + aScript << "\t" << _Name << ".SetRefinThr(" << _TypeThR << ", " << _ThreshR << ")\n"; + } + if ( _TypeDera == 1 ) + { + aScript << "\t" << _Name << ".SetUnRefThr(" << _TypeThC << ", " << _ThreshC << ")\n"; + } + } + +// Filtrage du raffinement par des groupes + for ( it=_ListGroupSelected.begin(); it!=_ListGroupSelected.end();it++) + aScript << "\t" << _Name << ".AddGroup(\"" << (*it) << "\")\n" ; + +// Interpolation des champs + if ( _TypeFieldInterp == 2 ) + { + std::list::const_iterator it_champ = _ListFieldInterp.begin(); + while(it_champ != _ListFieldInterp.end()) + { + aScript << "\t" << _Name << ".AddFieldInterpType( \"" << *it_champ << "\" " ; + it_champ++; + aScript << ", " << *it_champ << ")\n"; + it_champ++; + } + } + else if ( _TypeFieldInterp != 0 ) + { + aScript << "\t" << _Name << ".SetTypeFieldInterp(" << _TypeFieldInterp << ")\n"; + } + if ( _NivMax > 0 ) + { + aScript << "\t" <<_Name << ".SetNivMax(" << _NivMax << ")\n"; + } + if ( _DiamMin > 0 ) + { + aScript << "\t" <<_Name << ".SetDiamMin(" << _DiamMin << ")\n"; + } + if ( _AdapInit != 0 ) + { + aScript << "\t" <<_Name << ".SetAdapInit(" << _AdapInit << ")\n"; + } + if ( _ExtraOutput != 1 ) + { + aScript << "\t" <<_Name << ".SetExtraOutput(" << _ExtraOutput << ")\n"; + } + + return aScript.str(); +} +//============================================================================= +//============================================================================= +// Caracteristiques +//============================================================================= +//============================================================================= +void HOMARD_Hypothesis::SetAdapType( int TypeAdap ) +{ + VERIFICATION( (TypeAdap>=-1) && (TypeAdap<=1) ); + _TypeAdap = TypeAdap; +} +//============================================================================= +int HOMARD_Hypothesis::GetAdapType() const +{ + return _TypeAdap; +} +//============================================================================= +void HOMARD_Hypothesis::SetRefinTypeDera( int TypeRaff, int TypeDera ) +{ + VERIFICATION( (TypeRaff>=-1) && (TypeRaff<=1) ); + _TypeRaff = TypeRaff; + VERIFICATION( (TypeDera>=-1) && (TypeDera<=1) ); + _TypeDera = TypeDera; +} +//============================================================================= +int HOMARD_Hypothesis::GetRefinType() const +{ + return _TypeRaff; +} +//============================================================================= +int HOMARD_Hypothesis::GetUnRefType() const +{ + return _TypeDera; +} +//============================================================================= +void HOMARD_Hypothesis::SetField( const char* FieldName ) +{ + _Field = std::string( FieldName ); + MESSAGE( "SetField : FieldName = " << FieldName ); +} +//============================================================================= +std::string HOMARD_Hypothesis::GetFieldName() const +{ + return _Field; +} +//============================================================================= +void HOMARD_Hypothesis::SetUseField( int UsField ) +{ + VERIFICATION( (UsField>=0) && (UsField<=1) ); + _UsField = UsField; +} +//============================================================================= +int HOMARD_Hypothesis::GetUseField() const +{ + return _UsField; +} +//============================================================================= +void HOMARD_Hypothesis::SetUseComp( int UsCmpI ) +{ + MESSAGE ("SetUseComp pour UsCmpI = "<=0) && (UsCmpI<=2) ); + _UsCmpI = UsCmpI; +} +//============================================================================= +int HOMARD_Hypothesis::GetUseComp() const +{ + return _UsCmpI; +} +//============================================================================= +void HOMARD_Hypothesis::AddComp( const char* NomComp ) +{ +// On commence par supprimer la composante au cas ou elle aurait deja ete inseree +// Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la +// definition de l'hypothese + SupprComp( NomComp ) ; +// Insertion veritable + _ListComp.push_back( std::string( NomComp ) ); +} +//============================================================================= +void HOMARD_Hypothesis::SupprComp( const char* NomComp ) +{ + MESSAGE ("SupprComp pour "<::iterator it = find( _ListComp.begin(), _ListComp.end(), NomComp ); + if ( it != _ListComp.end() ) { it = _ListComp.erase( it ); } +} +//============================================================================= +void HOMARD_Hypothesis::SupprComps() +{ + _ListComp.clear(); +} +//============================================================================= +const std::list& HOMARD_Hypothesis::GetComps() const +{ + return _ListComp; +} +//============================================================================= +void HOMARD_Hypothesis::SetRefinThr( int TypeThR, double ThreshR ) +{ + MESSAGE( "SetRefinThr : TypeThR = " << TypeThR << ", ThreshR = " << ThreshR ); + VERIFICATION( (TypeThR>=0) && (TypeThR<=4) ); + _TypeThR = TypeThR; + _ThreshR = ThreshR; +} +//============================================================================= +int HOMARD_Hypothesis::GetRefinThrType() const +{ + return _TypeThR; +} +//============================================================================= +double HOMARD_Hypothesis::GetThreshR() const +{ + return _ThreshR; +} +//============================================================================= +void HOMARD_Hypothesis::SetUnRefThr( int TypeThC, double ThreshC ) +{ + VERIFICATION( (TypeThC>=0) && (TypeThC<=4) ); + _TypeThC = TypeThC; + _ThreshC = ThreshC; +} +//============================================================================= +int HOMARD_Hypothesis::GetUnRefThrType() const +{ + return _TypeThC; +} +//============================================================================= +double HOMARD_Hypothesis::GetThreshC() const +{ + return _ThreshC; +} +//============================================================================= +void HOMARD_Hypothesis::SetNivMax( int NivMax ) +//============================================================================= +{ + _NivMax = NivMax; +} +//============================================================================= +const int HOMARD_Hypothesis::GetNivMax() const +//============================================================================= +{ + return _NivMax; +} +//============================================================================= +void HOMARD_Hypothesis::SetDiamMin( double DiamMin ) +//============================================================================= +{ + _DiamMin = DiamMin; +} +//============================================================================= +const double HOMARD_Hypothesis::GetDiamMin() const +//============================================================================= +{ + return _DiamMin; +} +//============================================================================= +void HOMARD_Hypothesis::SetAdapInit( int AdapInit ) +//============================================================================= +{ + _AdapInit = AdapInit; +} +//============================================================================= +const int HOMARD_Hypothesis::GetAdapInit() const +//============================================================================= +{ + return _AdapInit; +} +//============================================================================= +void HOMARD_Hypothesis::SetExtraOutput( int ExtraOutput ) +//============================================================================= +{ + _ExtraOutput = ExtraOutput; +} +//============================================================================= +const int HOMARD_Hypothesis::GetExtraOutput() const +//============================================================================= +{ + return _ExtraOutput; +} +//============================================================================= +void HOMARD_Hypothesis::AddGroup( const char* Group) +{ +// On commence par supprimer le groupe au cas ou il aurait deja ete insere +// Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la +// definition de l'hypothese + SupprGroup( Group ) ; +// Insertion veritable + _ListGroupSelected.push_back(Group); +} +//============================================================================= +void HOMARD_Hypothesis::SupprGroup( const char* Group ) +{ + MESSAGE ("SupprGroup pour "<::iterator it = find( _ListGroupSelected.begin(), _ListGroupSelected.end(), Group ); + if ( it != _ListGroupSelected.end() ) { it = _ListGroupSelected.erase( it ); } +} +//============================================================================= +void HOMARD_Hypothesis::SupprGroups() +{ + _ListGroupSelected.clear(); +} +//============================================================================= +void HOMARD_Hypothesis::SetGroups( const std::list& ListGroup ) +{ + _ListGroupSelected.clear(); + std::list::const_iterator it = ListGroup.begin(); + while(it != ListGroup.end()) + _ListGroupSelected.push_back((*it++)); +} +//============================================================================= +const std::list& HOMARD_Hypothesis::GetGroups() const +{ + return _ListGroupSelected; +} +//============================================================================= +// Type d'interpolation des champs : +// 0 : aucun champ n'est interpole +// 1 : tous les champs sont interpoles +// 2 : certains champs sont interpoles +void HOMARD_Hypothesis::SetTypeFieldInterp( int TypeFieldInterp ) +{ + VERIFICATION( (TypeFieldInterp>=0) && (TypeFieldInterp<=2) ); + _TypeFieldInterp = TypeFieldInterp; +} +//============================================================================= +int HOMARD_Hypothesis::GetTypeFieldInterp() const +{ + return _TypeFieldInterp; +} +//============================================================================= +void HOMARD_Hypothesis::AddFieldInterpType( const char* FieldInterp, int TypeInterp ) +{ + MESSAGE ("Dans AddFieldInterpType pour " << FieldInterp << " et TypeInterp = " << TypeInterp) ; +// On commence par supprimer le champ au cas ou il aurait deja ete insere +// Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la +// definition de l'hypothese + SupprFieldInterp( FieldInterp ) ; +// Insertion veritable +// . Nom du champ + _ListFieldInterp.push_back( std::string( FieldInterp ) ); +// . Usage du champ + std::stringstream saux1 ; + saux1 << TypeInterp ; + _ListFieldInterp.push_back( saux1.str() ); +// . Indication generale : certains champs sont a interpoler + SetTypeFieldInterp ( 2 ) ; +} +//============================================================================= +void HOMARD_Hypothesis::SupprFieldInterp( const char* FieldInterp ) +{ + MESSAGE ("Dans SupprFieldInterp pour " << FieldInterp) ; + std::list::iterator it = find( _ListFieldInterp.begin(), _ListFieldInterp.end(), FieldInterp ) ; +// Attention a supprimer le nom du champ et le type d'usage + if ( it != _ListFieldInterp.end() ) + { + it = _ListFieldInterp.erase( it ) ; + it = _ListFieldInterp.erase( it ) ; + } +// Decompte du nombre de champs restant a interpoler + it = _ListFieldInterp.begin() ; + int cpt = 0 ; + while(it != _ListFieldInterp.end()) + { + cpt += 1 ; + (*it++); + } + MESSAGE("Nombre de champ restants = "<& HOMARD_Hypothesis::GetFieldInterps() const +{ + return _ListFieldInterp; +} +//============================================================================= +//============================================================================= +// Liens avec les autres structures +//============================================================================= +//============================================================================= +void HOMARD_Hypothesis::SetCaseCreation( const char* NomCasCreation ) +{ + _NomCasCreation = std::string( NomCasCreation ); +} +//============================================================================= +std::string HOMARD_Hypothesis::GetCaseCreation() const +{ + return _NomCasCreation; +} +//============================================================================= +void HOMARD_Hypothesis::LinkIteration( const char* NomIteration ) +{ + _ListIter.push_back( std::string( NomIteration ) ); +} +//============================================================================= +void HOMARD_Hypothesis::UnLinkIteration( const char* NomIteration ) +{ + std::list::iterator it = find( _ListIter.begin(), _ListIter.end(), NomIteration ) ; + if ( it != _ListIter.end() ) + { + MESSAGE ("Dans UnLinkIteration pour " << NomIteration) ; + it = _ListIter.erase( it ) ; + } +} +//============================================================================= +void HOMARD_Hypothesis::UnLinkIterations() +{ + _ListIter.clear(); +} +//============================================================================= +const std::list& HOMARD_Hypothesis::GetIterations() const +{ + return _ListIter; +} +//============================================================================= +void HOMARD_Hypothesis::AddZone( const char* NomZone, int TypeUse ) +{ + MESSAGE ("Dans AddZone pour " << NomZone << " et TypeUse = " << TypeUse) ; +// On commence par supprimer la zone au cas ou elle aurait deja ete inseree +// Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la +// definition de l'hypothese + SupprZone( NomZone ) ; +// Insertion veritable +// . Nom de la zone + _ListZone.push_back( std::string( NomZone ) ); +// . Usage de la zone + std::stringstream saux1 ; + saux1 << TypeUse ; + _ListZone.push_back( saux1.str() ); +} +//============================================================================= +void HOMARD_Hypothesis::SupprZone( const char* NomZone ) +{ + MESSAGE ("Dans SupprZone pour " << NomZone) ; + std::list::iterator it = find( _ListZone.begin(), _ListZone.end(), NomZone ); +// Attention a supprimer le nom de zone et le type d'usage + if ( it != _ListZone.end() ) + { + it = _ListZone.erase( it ); + it = _ListZone.erase( it ); + } +} +//============================================================================= +void HOMARD_Hypothesis::SupprZones() +{ + _ListZone.clear(); +} +//============================================================================= +const std::list& HOMARD_Hypothesis::GetZones() const +{ + return _ListZone; +} diff --git a/src/ADAPT/HOMARD_Hypothesis.hxx b/src/ADAPT/HOMARD_Hypothesis.hxx new file mode 100644 index 000000000..8dd0492ab --- /dev/null +++ b/src/ADAPT/HOMARD_Hypothesis.hxx @@ -0,0 +1,157 @@ +// HOMARD HOMARD : implementation of HOMARD idl descriptions +// +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : HOMARD_Hypothesis.hxx +// Author : Gerald NICOLAS, EDF +// Module : HOMARD +// +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier + +#ifndef _HOMARD_HYPOTHESIS_HXX_ +#define _HOMARD_HYPOTHESIS_HXX_ + +#include "HOMARD.hxx" + +#include +#include + +#if defined WIN32 +#pragma warning ( disable: 4251 ) +#endif + +class HOMARDIMPL_EXPORT HOMARD_Hypothesis +{ +public: + HOMARD_Hypothesis(); + ~HOMARD_Hypothesis(); + +// Generalites + void SetName( const char* Name ); + std::string GetName() const; + + std::string GetDumpPython() const; + +// Caracteristiques + void SetAdapType( int TypeAdap ); + int GetAdapType() const; + void SetRefinTypeDera( int TypeRaff, int TypeDera ); + int GetRefinType() const; + int GetUnRefType() const; + + void SetField( const char* FieldName ); + std::string GetFieldName() const; + void SetUseField( int UsField ); + int GetUseField() const; + + void SetUseComp( int UsCmpI ); + int GetUseComp() const; + void AddComp( const char* NomComp ); + void SupprComp( const char* NomComp ); + void SupprComps(); + const std::list& GetComps() const; + + void SetRefinThr( int TypeThR, double ThreshR ); + int GetRefinThrType() const; + double GetThreshR() const; + void SetUnRefThr( int TypeThC, double ThreshC ); + int GetUnRefThrType() const; + double GetThreshC() const; + + void SetNivMax( int NivMax ); + const int GetNivMax() const; + + void SetDiamMin( double DiamMin ); + const double GetDiamMin() const; + + void SetAdapInit( int AdapInit ); + const int GetAdapInit() const; + + void SetExtraOutput( int ExtraOutput ); + const int GetExtraOutput() const; + + void AddGroup( const char* Group); + void SupprGroup( const char* Group ); + void SupprGroups(); + void SetGroups(const std::list& ListGroup ); + const std::list& GetGroups() const; + + void SetTypeFieldInterp( int TypeFieldInterp ); + int GetTypeFieldInterp() const; + void AddFieldInterpType( const char* FieldInterp, int TypeInterp ); + void SupprFieldInterp( const char* FieldInterp ); + void SupprFieldInterps(); + const std::list& GetFieldInterps() const; + +// Liens avec les autres structures + void SetCaseCreation( const char* NomCasCreation ); + std::string GetCaseCreation() const; + + void LinkIteration( const char* NomIter ); + void UnLinkIteration( const char* NomIter ); + void UnLinkIterations(); + const std::list& GetIterations() const; + + void AddZone( const char* NomZone, int TypeUse ); + void SupprZone( const char* NomZone ); + void SupprZones(); + const std::list& GetZones() const; + +private: + std::string _Name; + std::string _NomCasCreation; + + int _TypeAdap; // -1 pour une adapation Uniforme, + // 0 si l adaptation depend des zones, + // 1 pour des champs + + int _TypeRaff; + int _TypeDera; + + std::string _Field; + int _TypeThR; + int _TypeThC; + double _ThreshR; + double _ThreshC; + int _UsField; + int _UsCmpI; + int _TypeFieldInterp; // 0 pour aucune interpolation, + // 1 pour interpolation de tous les champs, + // 2 pour une liste + int _NivMax; + double _DiamMin; + int _AdapInit; + int _ExtraOutput; + + std::list _ListIter; + std::list _ListZone; + std::list _ListComp; + std::list _ListGroupSelected; + std::list _ListFieldInterp; + +}; + +#endif diff --git a/src/ADAPT/HOMARD_Iteration.cxx b/src/ADAPT/HOMARD_Iteration.cxx new file mode 100644 index 000000000..713a6b066 --- /dev/null +++ b/src/ADAPT/HOMARD_Iteration.cxx @@ -0,0 +1,394 @@ +// HOMARD HOMARD : implementation of HOMARD idl descriptions +// +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : HOMARD_Iteration.cxx +// Author : Gerald NICOLAS, EDF +// Module : HOMARD +// +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier + +#include "HOMARD_Iteration.hxx" +#include "HOMARD.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * default constructor: + */ +//============================================================================= +HOMARD_Iteration::HOMARD_Iteration(): + _Name( "" ), _Etat( 0 ), + _NumIter( -1 ), + _NomMesh( "" ), _MeshFile( "" ), + _FieldFile( "" ), _TimeStep( -1 ), _Rank( -1 ), + _LogFile( "" ), + _IterParent( "" ), + _NomHypo( "" ), _NomCas( "" ), _NomDir( "" ), + _FileInfo( "" ), + _MessInfo( 1 ) +{ + MESSAGE("HOMARD_Iteration"); +} +//============================================================================= +/*! + * + */ +//============================================================================= +HOMARD_Iteration::~HOMARD_Iteration() +{ + MESSAGE("~HOMARD_Iteration"); +} +//============================================================================= +//============================================================================= +// Generalites +//============================================================================= +//============================================================================= +void HOMARD_Iteration::SetName( const char* Name ) +{ + _Name = std::string( Name ); +} +//============================================================================= +std::string HOMARD_Iteration::GetName() const +{ + return _Name; +} +//============================================================================= +std::string HOMARD_Iteration::GetDumpPython() const +{ + if (_IterParent == "") return std::string(" ") ; // Pas de creation explicite de iteration 0"; + + MESSAGE (". Ecriture de l iteration " << _Name ); + std::ostringstream aScript; + aScript << "\n# Creation of the iteration " << _Name << "\n"; + if( _NumIter == 1 ) + { + aScript << "\t" << _Name << " = " << _NomCas << ".NextIteration(\"" << _Name << "\")\n"; + } + else + { + aScript << "\t" << _Name << " = " << _IterParent << ".NextIteration(\"" << _Name << "\")\n"; + } +// L'hypothese (doit etre au debut) + aScript << "\t" << _Name << ".AssociateHypo(\"" << _NomHypo << "\")\n"; +// Le nom du maillage produit +// MESSAGE (".. maillage produit " << _NomMesh ); + aScript << "\t" << _Name << ".SetMeshName(\"" << _NomMesh << "\")\n" ; +// Le fichier du maillage produit + aScript << "\t" << _Name << ".SetMeshFile(\"" << _MeshFile << "\")\n"; +// Le fichier des champs + if ( _FieldFile != "" ) + { + aScript << "\t" << _Name << ".SetFieldFile(\"" << _FieldFile << "\")\n"; + } +// Si champ de pilotage, valeurs de pas de temps + MESSAGE (". champ de pilotage : _TimeStep = " << _TimeStep << ", _Rank : " << _Rank); + if ( _TimeStep != -1 ) + { + if ( _TimeStep == -2 ) { + aScript << "\t" << _Name << ".SetTimeStepRankLast()\n"; + } + else + { + if ( _TimeStep != -1 ) + { + if ( _Rank == -1 ) + { + aScript << "\t" << _Name << ".SetTimeStep( " << _TimeStep << " )\n"; + } + else + { + aScript << "\t" << _Name << ".SetTimeStepRank( " << _TimeStep << ", " << _Rank << " )\n"; + } + } + } + } +// Les instants d'interpolation + MESSAGE (". instants d'interpolation "); + std::list::const_iterator it = _ListFieldInterpTSR.begin() ; + while(it != _ListFieldInterpTSR.end()) + { + std::string FieldName = std::string((*it)) ; +// MESSAGE ("... FieldName = "<< FieldName); + (*it++); + std::string TimeStepstr = std::string((*it)) ; +// MESSAGE ("... TimeStepstr = "<< TimeStepstr); + (*it++); + std::string Rankstr = std::string((*it)) ; +// MESSAGE ("... Rankstr = "<< Rankstr); + (*it++); + aScript << "\t" << _Name << ".SetFieldInterpTimeStepRank( \"" << FieldName << "\"" ; + aScript << ", " << TimeStepstr ; + aScript << ", " << Rankstr << " )\n" ; + } + +// Compute + MESSAGE (". Compute "); + if ( _Etat == 2 ) { aScript << "\tcodret = " <<_Name << ".Compute(1, 1)\n"; } + else { aScript << "\t#codret = " <<_Name << ".Compute(1, 1)\n"; } +// MESSAGE (". Fin de l ecriture de l iteration " << _Name ); + + return aScript.str(); +} +//============================================================================= +//============================================================================= +// Caracteristiques +//============================================================================= +//============================================================================= +void HOMARD_Iteration::SetDirNameLoc( const char* NomDir ) +{ + _NomDir = std::string( NomDir ); +} +//============================================================================= +std::string HOMARD_Iteration::GetDirNameLoc() const +{ + return _NomDir; +} +//============================================================================= +void HOMARD_Iteration::SetNumber( int NumIter ) +{ + _NumIter = NumIter; +} +//============================================================================= +int HOMARD_Iteration::GetNumber() const +{ + return _NumIter; +} +//============================================================================= +void HOMARD_Iteration::SetState( int etat ) +{ + _Etat = etat; +} +//============================================================================= +int HOMARD_Iteration::GetState() const +{ + return _Etat; +} +//============================================================================= +void HOMARD_Iteration::SetMeshName( const char* NomMesh ) +{ + _NomMesh = std::string( NomMesh ); +} +//============================================================================= +std::string HOMARD_Iteration::GetMeshName() const +{ + return _NomMesh; +} +//============================================================================= +void HOMARD_Iteration::SetMeshFile( const char* MeshFile ) +{ + _MeshFile = std::string( MeshFile ); +} +//============================================================================= +std::string HOMARD_Iteration::GetMeshFile() const +{ + return _MeshFile; +} +//============================================================================= +void HOMARD_Iteration::SetFieldFile( const char* FieldFile ) +{ + _FieldFile = std::string( FieldFile ); +} +//============================================================================= +std::string HOMARD_Iteration::GetFieldFile() const +{ + return _FieldFile; +} +//============================================================================= +// Instants pour le champ de pilotage +//============================================================================= +void HOMARD_Iteration::SetTimeStep( int TimeStep ) +{ + _TimeStep = TimeStep; +} +//============================================================================= +void HOMARD_Iteration::SetTimeStepRank( int TimeStep, int Rank ) +{ + _TimeStep = TimeStep; + _Rank = Rank; +} +//============================================================================= +void HOMARD_Iteration::SetTimeStepRankLast() +{ + _TimeStep = -2; +} +//============================================================================= +int HOMARD_Iteration::GetTimeStep() const +{ + return _TimeStep; +} +//============================================================================= +int HOMARD_Iteration::GetRank() const +{ + return _Rank; +} +//============================================================================= +// Instants pour un champ a interpoler +//============================================================================= +void HOMARD_Iteration::SetFieldInterpTimeStep( const char* FieldInterp, int TimeStep ) +{ + SetFieldInterpTimeStepRank( FieldInterp, TimeStep, TimeStep ) ; +} +//============================================================================= +void HOMARD_Iteration::SetFieldInterpTimeStepRank( const char* FieldInterp, int TimeStep, int Rank ) +{ + MESSAGE("Champ " << FieldInterp << ", hypothese " << _NomHypo ) +// Verification de la presence du champ dans l'hypothese + std::list::iterator it = find( _ListFieldInterp.begin(), _ListFieldInterp.end(), FieldInterp ); + if ( it == _ListFieldInterp.end() ) + { + INFOS("Champ " << FieldInterp << " ; hypothese " << _NomHypo ) + VERIFICATION("Le champ est inconnu dans l'hypothese associee a cette iteration." == 0); + } + +// . Nom du champ + _ListFieldInterpTSR.push_back( std::string( FieldInterp ) ); +// . Pas de temps + std::stringstream saux1 ; + saux1 << TimeStep ; + _ListFieldInterpTSR.push_back( saux1.str() ); +// . Numero d'ordre + std::stringstream saux2 ; + saux2 << Rank ; + _ListFieldInterpTSR.push_back( saux2.str() ); +} +//============================================================================= +const std::list& HOMARD_Iteration::GetFieldInterpsTimeStepRank() const +{ + return _ListFieldInterpTSR; +} +//============================================================================= +void HOMARD_Iteration::SetFieldInterp( const char* FieldInterp ) +{ + _ListFieldInterp.push_back( std::string( FieldInterp ) ); +} +//============================================================================= +const std::list& HOMARD_Iteration::GetFieldInterps() const +{ + return _ListFieldInterp; +} +//============================================================================= +void HOMARD_Iteration::SupprFieldInterps() +{ + _ListFieldInterp.clear(); +} +//============================================================================= +void HOMARD_Iteration::SetLogFile( const char* LogFile ) +{ + _LogFile = std::string( LogFile ); +} +//============================================================================= +std::string HOMARD_Iteration::GetLogFile() const +{ + return _LogFile; +} +//============================================================================= +void HOMARD_Iteration::SetFileInfo( const char* FileInfo ) +{ + _FileInfo = std::string( FileInfo ); +} +//============================================================================= +std::string HOMARD_Iteration::GetFileInfo() const +{ + return _FileInfo; +} +//============================================================================= +//============================================================================= +// Liens avec les autres iterations +//============================================================================= +//============================================================================= +void HOMARD_Iteration::LinkNextIteration( const char* NomIteration ) +{ + _mesIterFilles.push_back( std::string( NomIteration ) ); +} +//============================================================================= +void HOMARD_Iteration::UnLinkNextIteration( const char* NomIteration ) +{ + std::list::iterator it = find( _mesIterFilles.begin(), _mesIterFilles.end(), NomIteration ) ; + if ( it != _mesIterFilles.end() ) + { + MESSAGE ("Dans UnLinkNextIteration pour " << NomIteration) ; + it = _mesIterFilles.erase( it ) ; + } +} +//============================================================================= +void HOMARD_Iteration::UnLinkNextIterations() +{ + _mesIterFilles.clear(); +} +//============================================================================= +const std::list& HOMARD_Iteration::GetIterations() const +{ + return _mesIterFilles; +} +//============================================================================= +void HOMARD_Iteration::SetIterParentName( const char* IterParent ) +{ + _IterParent = IterParent; +} +//============================================================================= +std::string HOMARD_Iteration::GetIterParentName() const +{ + return _IterParent; +} +//============================================================================= +//============================================================================= +// Liens avec les autres structures +//============================================================================= +//============================================================================= +void HOMARD_Iteration::SetCaseName( const char* NomCas ) +{ + _NomCas = std::string( NomCas ); +} +//============================================================================= +std::string HOMARD_Iteration::GetCaseName() const +{ + return _NomCas; +} +//============================================================================= +void HOMARD_Iteration::SetHypoName( const char* NomHypo ) +{ + _NomHypo = std::string( NomHypo ); +} +//============================================================================= +std::string HOMARD_Iteration::GetHypoName() const +{ + return _NomHypo; +} +//============================================================================= +//============================================================================= +// Divers +//============================================================================= +//============================================================================= +void HOMARD_Iteration::SetInfoCompute( int MessInfo ) +{ + _MessInfo = MessInfo; +} +//============================================================================= +int HOMARD_Iteration::GetInfoCompute() const +{ + return _MessInfo; +} diff --git a/src/ADAPT/HOMARD_Iteration.hxx b/src/ADAPT/HOMARD_Iteration.hxx new file mode 100644 index 000000000..cb0e3c72d --- /dev/null +++ b/src/ADAPT/HOMARD_Iteration.hxx @@ -0,0 +1,139 @@ +// HOMARD HOMARD : implementation of HOMARD idl descriptions +// +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : HOMARD_Iteration.hxx +// Author : Gerald NICOLAS, EDF +// Module : HOMARD +// +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier + +#ifndef _HOMARD_ITER_HXX_ +#define _HOMARD_ITER_HXX_ + +#include "HOMARD.hxx" + +#include +#include + +#if defined WIN32 +#pragma warning ( disable: 4251 ) +#endif + +class HOMARDIMPL_EXPORT HOMARD_Iteration +{ +public: + HOMARD_Iteration(); + ~HOMARD_Iteration(); + +// Generalites + void SetName( const char* Name ); + std::string GetName() const; + + std::string GetDumpPython() const; + +// Caracteristiques + void SetDirNameLoc( const char* NomDir ); + std::string GetDirNameLoc() const; + + void SetNumber( int NumIter ); + int GetNumber() const; + + void SetState( int etat ); + int GetState() const; + + void SetMeshName( const char* NomMesh ); + std::string GetMeshName() const; + + void SetMeshFile( const char* MeshFile ); + std::string GetMeshFile() const; + + void SetFieldFile( const char* FieldFile ); + std::string GetFieldFile() const; +// Instants pour le champ de pilotage + void SetTimeStep( int TimeStep ); + void SetTimeStepRank( int TimeStep, int Rank ); + void SetTimeStepRankLast(); + int GetTimeStep() const; + int GetRank() const; +// Instants pour un champ a interpoler + void SetFieldInterpTimeStep( const char* FieldInterp, int TimeStep ); + void SetFieldInterpTimeStepRank( const char* FieldInterp, int TimeStep, int Rank ); + const std::list& GetFieldInterpsTimeStepRank() const; + void SetFieldInterp( const char* FieldInterp ); + const std::list& GetFieldInterps() const; + void SupprFieldInterps(); + + void SetLogFile( const char* LogFile ); + std::string GetLogFile() const; + + void SetFileInfo( const char* FileInfo ); + std::string GetFileInfo() const; + +// Liens avec les autres iterations + void LinkNextIteration( const char* NomIteration ); + void UnLinkNextIteration( const char* NomIteration ); + void UnLinkNextIterations(); + const std::list& GetIterations() const; + + void SetIterParentName( const char* iterParent ); + std::string GetIterParentName() const; + +// Liens avec les autres structures + void SetCaseName( const char* NomCas ); + std::string GetCaseName() const; + + void SetHypoName( const char* NomHypo ); + std::string GetHypoName() const; + +// Divers + void SetInfoCompute( int MessInfo ); + int GetInfoCompute() const; + +private: + std::string _Name; + int _Etat; + int _NumIter; + std::string _NomMesh; + std::string _MeshFile; + std::string _FieldFile; + int _TimeStep; + int _Rank; + std::string _LogFile; + std::string _IterParent; + std::string _NomHypo; + std::string _NomCas; + std::string _NomDir; + std::list _mesIterFilles; + std::string _FileInfo; + int _MessInfo; + // La liste des champs retenus par l'hypothese + std::list _ListFieldInterp; + // La liste des triplets (champs, pas de temps, numero d'ordre) retenus par l'iteration + std::list _ListFieldInterpTSR; +}; + +#endif diff --git a/src/ADAPT/HOMARD_YACS.cxx b/src/ADAPT/HOMARD_YACS.cxx new file mode 100644 index 000000000..69c2a8189 --- /dev/null +++ b/src/ADAPT/HOMARD_YACS.cxx @@ -0,0 +1,219 @@ +// HOMARD HOMARD : implementation of HOMARD idl descriptions +// +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : HOMARD_YACS.cxx +// Author : Gerald NICOLAS, EDF +// Module : HOMARD +// +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier + +#include "HOMARD_YACS.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * default constructor: + */ +//============================================================================= +HOMARD_YACS::HOMARD_YACS(): + _Name( "" ), + _NomCas( "" ), + _NomDir( "" ), + _MeshFile( "" ), + _ScriptFile( "" ) +{ + MESSAGE("HOMARD_YACS"); +} +//============================================================================= +/*! + * + */ +//============================================================================= +HOMARD_YACS::~HOMARD_YACS() +{ + MESSAGE("~HOMARD_YACS"); +} +//============================================================================= +//============================================================================= +// Generalites +//============================================================================= +//============================================================================= +void HOMARD_YACS::SetName( const char* Name ) +{ + _Name = std::string( Name ); +} +//============================================================================= +std::string HOMARD_YACS::GetName() const +{ + return _Name; +} +//============================================================================= +std::string HOMARD_YACS::GetDumpPython() const +{ + MESSAGE (". Ecriture du schema " << _Name ); + std::ostringstream aScript; + aScript << "\n# Creation of the schema " << _Name << "\n"; +// Creation du schema + aScript << "\t" << _Name << " = " << _NomCas << ".CreateYACSSchema(\"" << _Name << "\", \"" << _ScriptFile << "\", \"" << _NomDir << "\", \"" << _MeshFile << "\")\n"; +// Le type de schema + aScript << "\t" << _Name << ".SetType(" << _Type << ")\n"; +// Les controles de convergences + if ( _MaxIter > 0 ) { aScript << "\t" << _Name << ".SetMaxIter(" << _MaxIter << ")\n"; } + if ( _MaxNode > 0 ) { aScript << "\t" << _Name << ".SetMaxNode(" << _MaxNode << ")\n"; } + if ( _MaxElem > 0 ) { aScript << "\t" << _Name << ".SetMaxElem(" << _MaxElem << ")\n"; } + +// L'ecriture du schema + aScript << "\tcodret = " << _Name << ".Write()\n"; + + MESSAGE (". Fin de l ecriture du schema " << _Name ); + + return aScript.str(); +} +//============================================================================= +//============================================================================= +// Caracteristiques de la convergence +//============================================================================= +//============================================================================= +void HOMARD_YACS::SetType( int Type ) +{ + _Type = Type; +} +//============================================================================= +int HOMARD_YACS::GetType() const +{ + return _Type; +} +//============================================================================= +void HOMARD_YACS::SetMaxIter( int MaxIter ) +{ + _MaxIter = MaxIter; +} +//============================================================================= +int HOMARD_YACS::GetMaxIter() const +{ + return _MaxIter; +} +//============================================================================= +void HOMARD_YACS::SetMaxNode( int MaxNode ) +{ + _MaxNode = MaxNode; +} +//============================================================================= +int HOMARD_YACS::GetMaxNode() const +{ + return _MaxNode; +} +//============================================================================= +void HOMARD_YACS::SetMaxElem( int MaxElem ) +{ + _MaxElem = MaxElem; +} +//============================================================================= +int HOMARD_YACS::GetMaxElem() const +{ + return _MaxElem; +} +//============================================================================= +void HOMARD_YACS::SetTestConvergence( int TypeTest, double VRef ) +{ + _TypeTest = TypeTest; + _VRef = VRef; +} +//============================================================================= +int HOMARD_YACS::GetTestConvergenceType() const +{ + return _TypeTest; +} +//============================================================================= +double HOMARD_YACS::GetTestConvergenceVRef() const +{ + return _VRef; +} +//============================================================================= +//============================================================================= +// Repertoire et fichiers +//============================================================================= +//============================================================================= +//============================================================================= +void HOMARD_YACS::SetDirName( const char* NomDir ) +{ + _NomDir = std::string( NomDir ); +} +//============================================================================= +std::string HOMARD_YACS::GetDirName() const +{ + return _NomDir; +} +//============================================================================= +void HOMARD_YACS::SetMeshFile( const char* MeshFile ) +{ + _MeshFile = std::string( MeshFile ); +} +//============================================================================= +std::string HOMARD_YACS::GetMeshFile() const +{ + return _MeshFile; +} +//============================================================================= +void HOMARD_YACS::SetScriptFile( const char* ScriptFile ) +{ + _ScriptFile = std::string( ScriptFile ); +} +//============================================================================= +std::string HOMARD_YACS::GetScriptFile() const +{ + return _ScriptFile; +} +//============================================================================= +void HOMARD_YACS::SetXMLFile( const char* XMLFile ) +{ + _XMLFile = std::string( XMLFile ); +} +//============================================================================= +std::string HOMARD_YACS::GetXMLFile() const +{ + return _XMLFile; +} +//============================================================================= +//============================================================================= +// Liens avec les autres structures +//============================================================================= +//============================================================================= +void HOMARD_YACS::SetCaseName( const char* NomCas ) +{ + _NomCas = std::string( NomCas ); +} +//============================================================================= +std::string HOMARD_YACS::GetCaseName() const +{ + return _NomCas; +} +//============================================================================= +//============================================================================= +// Divers +//============================================================================= +//============================================================================= diff --git a/src/ADAPT/HOMARD_YACS.hxx b/src/ADAPT/HOMARD_YACS.hxx new file mode 100644 index 000000000..5f9141997 --- /dev/null +++ b/src/ADAPT/HOMARD_YACS.hxx @@ -0,0 +1,103 @@ +// HOMARD HOMARD : implementation of HOMARD idl descriptions +// +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : HOMARD_YACS.hxx +// Author : Gerald NICOLAS, EDF +// Module : HOMARD +// +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier + +#ifndef _HOMARD_YACS_HXX_ +#define _HOMARD_YACS_HXX_ + +#include "HOMARD.hxx" + +#include +#include + +class HOMARDIMPL_EXPORT HOMARD_YACS +{ +public: + HOMARD_YACS(); + ~HOMARD_YACS(); + +// Generalites + void SetName( const char* Name ); + std::string GetName() const; + + std::string GetDumpPython() const; + +// Caracteristiques + void SetType( int Type ); + int GetType() const; + + void SetMaxIter( int MaxIter ); + int GetMaxIter() const; + void SetMaxNode( int MaxNode ); + int GetMaxNode() const; + void SetMaxElem( int MaxElem ); + int GetMaxElem() const; + + void SetTestConvergence( int TypeTest, double VRef ); + int GetTestConvergenceType() const; + double GetTestConvergenceVRef() const; + + void SetDirName( const char* NomDir ); + std::string GetDirName() const; + + void SetMeshFile( const char* MeshFile ); + std::string GetMeshFile() const; + + void SetScriptFile( const char* ScriptFile ); + std::string GetScriptFile() const; + + void SetXMLFile( const char* XMLFile ); + std::string GetXMLFile() const; + +// Liens avec les autres structures + void SetCaseName( const char* NomCas ); + std::string GetCaseName() const; + + +// Divers + +private: + std::string _Name; + std::string _NomCas; + std::string _NomDir; + std::string _MeshFile; + std::string _ScriptFile; + int _Type; + int _MaxIter; + int _MaxNode; + int _MaxElem; + int _TypeTest; + double _VRef; + std::string _XMLFile; +}; + +#endif diff --git a/src/ADAPT/HOMARD_Zone.cxx b/src/ADAPT/HOMARD_Zone.cxx new file mode 100644 index 000000000..0d938a53b --- /dev/null +++ b/src/ADAPT/HOMARD_Zone.cxx @@ -0,0 +1,325 @@ +// HOMARD HOMARD : implementation of HOMARD idl descriptions +// +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : HOMARD_Zone.cxx +// Author : Gerald NICOLAS, EDF +// Module : HOMARD +// +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier + +#include "HOMARD_Zone.hxx" +#include "HOMARD.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * default constructor: + */ +//============================================================================= +HOMARD_Zone::HOMARD_Zone(): + _Name( "" ),_Type( 2 ), + _Xmin( 0 ), _Xmax( 0 ), _Ymin( 0 ), _Ymax( 0 ), _Zmin( 0 ), _Zmax( 0 ), + _Xcentre( 0 ), _Ycentre( 0 ), _Zcentre( 0 ), _Rayon( 0 ), + _Xaxe( 0 ), _Yaxe( 0 ), _Zaxe( 0 ), _Haut( 0 ), + _Xincr( 0 ), _Yincr( 0 ), _Zincr( 0 ) +{ + MESSAGE("HOMARD_Zone") ; +} + +//============================================================================= +HOMARD_Zone::~HOMARD_Zone() +{ + MESSAGE("~HOMARD_Zone") ; +} +//============================================================================= +//============================================================================= +// Generalites +//============================================================================= +//============================================================================= +void HOMARD_Zone::SetName( const char* Name ) +{ + _Name = std::string( Name ); +} +//============================================================================= +std::string HOMARD_Zone::GetName() const +{ + return _Name; +} +//============================================================================= +std::string HOMARD_Zone::GetDumpPython() const +{ +// MESSAGE("GetDumpPython avec _Type " << _Type) ; +// MESSAGE("GetDumpPython avec _Name " << _Name) ; + std::ostringstream aScript; + aScript << "\n# Creation of the "; + if ( _Type >= 11 && _Type <= 13 ) { aScript << "rectangle " ; } + else if ( _Type == 2 ) { aScript << "box " ;} + else if ( _Type >= 31 && _Type <= 33 ) { aScript << "disk " ;} + else if ( _Type == 4 ) { aScript << "sphere " ; } + else if ( _Type == 5 ) { aScript << "cylinder " ; } + else if ( _Type >= 61 && _Type <= 63 ) { aScript << "disk with hole " ;} + else if ( _Type == 7 ) { aScript << "pipe " ; } + aScript << _Name << "\n" ; +// + aScript << "\t" << _Name << " = homard.CreateZone" ; +// + switch (_Type) + { + case 11: + { aScript << "Box2D( \"" << _Name << "\", " << _Xmin << ", " << _Xmax << ", " << _Ymin << ", " << _Ymax << ", 1 )\n"; + break ; + } + case 12: + { aScript << "Box2D( \"" << _Name << "\", " << _Ymin << ", " << _Ymax << ", " << _Zmin << ", " << _Zmax << ", 2 )\n"; + break ; + } + case 13: + { aScript << "Box2D( \"" << _Name << "\", " << _Zmin << ", " << _Zmax << ", " << _Xmin << ", " << _Xmax << ", 3 )\n"; + break ; + } + case 2: + { aScript << "Box( \"" << _Name << "\", " << _Xmin << ", " << _Xmax << ", " << _Ymin << ", " << _Ymax << ", " << _Zmin << ", " << _Zmax << ")\n"; + break ; + } + + case 4: + { aScript << "Sphere( \"" << _Name << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Rayon << ")\n"; + break ; + } + + case 31: + { aScript << "Disk( \"" << _Name << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Rayon << ", 1 )\n"; + break ; + } + case 32: + { aScript << "Disk( \"" << _Name << "\", " << _Ycentre << ", " << _Zcentre << ", " << _Rayon << ", 2 )\n"; + break ; + } + case 33: + { aScript << "Disk( \"" << _Name << "\", " << _Zcentre << ", " << _Xcentre << ", " << _Rayon << ", 3 )\n"; + break ; + } + case 5: + { aScript << "Cylinder( \"" << _Name << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Rayon << ", " << _Haut << ")\n"; + break ; + } + + case 61: + { aScript << "DiskWithHole( \"" << _Name << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Rayon << ", " << _Rayonint << ", 1 )\n"; + break ; + } + case 62: + { aScript << "DiskWithHole( \"" << _Name << "\", " << _Ycentre << ", " << _Zcentre << ", " << _Rayon << ", " << _Rayonint << ", 2 )\n"; + break ; + } + case 63: + { aScript << "DiskWithHole( \"" << _Name << "\", " << _Zcentre << ", " << _Xcentre << ", " << _Rayon << ", " << _Rayonint << ", 3 )\n"; + break ; + } + case 7: + { aScript << "Pipe( \"" << _Name << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Rayon << ", " << _Haut << ", " << _Rayonint << ")\n"; + break ; + } + } + + return aScript.str() ; +} +//============================================================================= +//============================================================================= +// Caracteristiques +//============================================================================= +//============================================================================= +void HOMARD_Zone::SetType( int Type ) +{ + _Type = Type; +} +//============================================================================= +int HOMARD_Zone::GetType() const +{ + return _Type; +} +//======================================================================================= +void HOMARD_Zone::SetBox( double X0, double X1, double X2, double X3, double X4, double X5 ) +{ + _Xmin = X0; _Xmax = X1; + _Ymin = X2; _Ymax = X3; + _Zmin = X4; _Zmax = X5; +} +//======================================================================================= +void HOMARD_Zone::SetCylinder( double X0, double X1, double X2, + double X3, double X4, double X5, double X6, double X7 ) +{ + _Xcentre = X0; + _Ycentre = X1; + _Zcentre = X2; + _Xaxe = X3; + _Yaxe = X4; + _Zaxe = X5; + _Rayon = X6; + _Haut = X7; +} +//======================================================================================= +void HOMARD_Zone::SetPipe( double X0, double X1, double X2, + double X3, double X4, double X5, double X6, double X7, double X8 ) +{ + _Xcentre = X0; + _Ycentre = X1; + _Zcentre = X2; + _Xaxe = X3; + _Yaxe = X4; + _Zaxe = X5; + _Rayon = X6; + _Haut = X7; + _Rayonint = X8; +} +//====================================================================== +void HOMARD_Zone::SetSphere( double X0, double X1, double X2, double X3 ) +{ + _Xcentre = X0; + _Ycentre = X1; + _Zcentre = X2; + _Rayon = X3; +} +//======================================================================================= +std::vector HOMARD_Zone::GetCoords() const +{ + std::vector mesCoor; +// + switch (_Type) + { +// Rectangle ou parallelepipede + case 11: + { } + case 12: + { } + case 13: + { } + case 2: + { + mesCoor.push_back( _Xmin ) ; + mesCoor.push_back( _Xmax ) ; + mesCoor.push_back( _Ymin ) ; + mesCoor.push_back( _Ymax ) ; + mesCoor.push_back( _Zmin ) ; + mesCoor.push_back( _Zmax ) ; + break ; + } +// Sphere + case 4: + { + mesCoor.push_back( _Xcentre ) ; + mesCoor.push_back( _Ycentre ) ; + mesCoor.push_back( _Zcentre ) ; + mesCoor.push_back( _Rayon ) ; + break ; + } +// Disque ou cylindre + case 31: + { } + case 32: + { } + case 33: + { } + case 5: + { + mesCoor.push_back( _Xcentre ) ; + mesCoor.push_back( _Ycentre ) ; + mesCoor.push_back( _Zcentre ) ; + mesCoor.push_back( _Xaxe ) ; + mesCoor.push_back( _Yaxe ) ; + mesCoor.push_back( _Zaxe ) ; + mesCoor.push_back( _Rayon ) ; + mesCoor.push_back( _Haut ) ; + break ; + } +// Disque avec trou ou tuyau + case 61: + { } + case 62: + { } + case 63: + { } + case 7: + { + mesCoor.push_back( _Xcentre ) ; + mesCoor.push_back( _Ycentre ) ; + mesCoor.push_back( _Zcentre ) ; + mesCoor.push_back( _Xaxe ) ; + mesCoor.push_back( _Yaxe ) ; + mesCoor.push_back( _Zaxe ) ; + mesCoor.push_back( _Rayon ) ; + mesCoor.push_back( _Haut ) ; + mesCoor.push_back( _Rayonint ) ; + break ; + } + VERIFICATION ( ( (_Type>10) && (_Type<14) ) || (_Type==2) || ( (_Type>30) && (_Type<34) ) || (_Type==4) || (_Type==5) || ( (_Type>60) && (_Type<64) ) || (_Type==7) ) ; + } + return mesCoor; +} +//====================================================================== +void HOMARD_Zone::SetLimit( double X0, double X1, double X2 ) +{ + _Xincr = X0; _Yincr = X1; _Zincr = X2; +} +//======================================================================================= +std::vector HOMARD_Zone::GetLimit() const +{ + std::vector mesLimit; + mesLimit.push_back( _Xincr ) ; + mesLimit.push_back( _Yincr ) ; + mesLimit.push_back( _Zincr ) ; + return mesLimit; +} +//============================================================================= +//============================================================================= +// Liens avec les autres structures +//============================================================================= +//============================================================================= +void HOMARD_Zone::AddHypo( const char* NomHypo ) +{ + _ListHypo.push_back( std::string( NomHypo ) ) ; +} +//============================================================================= +const std::list& HOMARD_Zone::GetHypo() const +{ + return _ListHypo; +} +//============================================================================= +void HOMARD_Zone::SupprHypo( const char* NomHypo ) +{ + std::list::iterator it = find( _ListHypo.begin(), _ListHypo.end(), NomHypo ) ; + if ( it != _ListHypo.end() ) + { + MESSAGE ("Dans SupprHypo pour " << NomHypo) ; + it = _ListHypo.erase( it ) ; + } +} +//============================================================================= +void HOMARD_Zone::SupprHypos() +{ + _ListHypo.clear() ; +} diff --git a/src/ADAPT/HOMARD_Zone.hxx b/src/ADAPT/HOMARD_Zone.hxx new file mode 100644 index 000000000..ace77905d --- /dev/null +++ b/src/ADAPT/HOMARD_Zone.hxx @@ -0,0 +1,95 @@ +// HOMARD HOMARD : implementation of HOMARD idl descriptions +// +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : HOMARD_Zone.hxx +// Author : Gerald NICOLAS, EDF +// Module : HOMARD +// +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier + +#ifndef _HOMARD_Zone_HXX_ +#define _HOMARD_Zone_HXX_ + +#include "HOMARD.hxx" + +#include +#include +#include + +#if defined WIN32 +#pragma warning ( disable: 4251 ) +#endif + +class HOMARDIMPL_EXPORT HOMARD_Zone +{ +public: + HOMARD_Zone(); + ~HOMARD_Zone(); + +// Generalites + void SetName( const char* Name ); + std::string GetName() const; + + std::string GetDumpPython() const; + +// Caracteristiques + void SetType( int Type ); + int GetType() const; + + void SetBox( double X0, double X1, double X2, + double X3, double X4, double X5 ); + + void SetCylinder( double X0, double X1, double X2, double X3, + double X4, double X5, double X6, double X7 ); + + void SetPipe( double X0, double X1, double X2, double X3, + double X4, double X5, double X6, double X7, double X8 ); + + void SetSphere( double X0, double X1, double X2, double X3 ); + + std::vector GetCoords() const; + + void SetLimit( double X0, double X1, double X2 ); + std::vector GetLimit() const; + +// Liens avec les autres structures + void AddHypo( const char* NomHypo ); + const std::list& GetHypo() const; + void SupprHypo( const char* NomHypo ); + void SupprHypos(); + +private: + std::string _Name; + int _Type; + std::list _ListHypo; + double _Xmin, _Xmax, _Ymin, _Ymax, _Zmin, _Zmax; + double _Xcentre, _Ycentre, _Zcentre, _Rayon, _Rayonint; + double _Xaxe, _Yaxe, _Zaxe, _Haut; + double _Xincr, _Yincr, _Zincr; +}; + +#endif diff --git a/src/ADAPT/HomardDriver.cxx b/src/ADAPT/HomardDriver.cxx new file mode 100644 index 000000000..f11b7a5e7 --- /dev/null +++ b/src/ADAPT/HomardDriver.cxx @@ -0,0 +1,1106 @@ +// HOMARD HOMARD : implementation of HOMARD idl descriptions +// +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Pilote l'ecriture du fichier de configuration pour lancer l'execution de HOMARD + +#include +#ifndef WIN32 +#include +#endif +#include + +#include "HomardDriver.hxx" +#include "Utils_SALOME_Exception.hxx" +#include "utilities.h" + +//============================================================================= +//============================================================================= +HomardDriver::HomardDriver(const std::string siter, const std::string siterp1): + _HOMARD_Exec( "" ), _NomDir( "" ), _NomFichierConfBase( "HOMARD.Configuration" ), + _NomFichierConf( "" ), _NomFichierDonn( "" ), _siter( "" ), _siterp1( "" ), + _Texte( "" ), _bLu( false ) +{ + MESSAGE("siter = "< _HOMARD_Exec ="<<_HOMARD_Exec) ; +// + _siter = siter ; + _siterp1 = siterp1 ; +} +//============================================================================= +//============================================================================= +HomardDriver::~HomardDriver() +{ +} +//=============================================================================== +// A. Generalites +//=============================================================================== +void HomardDriver::TexteInit( const std::string DirCompute, const std::string LogFile, const std::string Langue ) +{ + MESSAGE("TexteInit, DirCompute ="<0 signifie que l'on raffinera les mailles contenues dans la zone, +// <0 signifie que l'on deraffinera +// + int ZoneTypeHOMARD ; + if ( ZoneType >= 11 && ZoneType <= 13 ) { ZoneTypeHOMARD = 1 ; } + else if ( ZoneType >= 31 && ZoneType <= 33 ) { ZoneTypeHOMARD = 3 ; } + else if ( ZoneType >= 61 && ZoneType <= 63 ) { ZoneTypeHOMARD = 6 ; } + else { ZoneTypeHOMARD = ZoneType ; } +// + if ( TypeUse < 0 ) { ZoneTypeHOMARD = -ZoneTypeHOMARD ; } +// + std::stringstream saux1 ; + saux1 << NumeZone ; + saux = "#\n# Zone numero " + saux1.str() + "\n" ; +// + { std::stringstream saux1 ; + saux1 << NumeZone << " " << ZoneTypeHOMARD ; + saux += "ZoRaType " + saux1.str() + "\n" ; + } +// +// Cas du rectangle +// + if ( ZoneType == 11 ) // Z est constant X Homard <=> X Salome +// Y Homard <=> Y Salome + { + saux += "#Rectangle\n" ; + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x0 ; + saux += "ZoRaXmin " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x1 ; + saux += "ZoRaXmax " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x2 ; + saux += "ZoRaYmin " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x3 ; + saux += "ZoRaYmax " + saux1.str() + "\n" ; + } + } +// + else if ( ZoneType == 12 ) // X est constant X Homard <=> Y Salome +// Y Homard <=> Z Salome + { + saux += "#Rectangle\n" ; + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x2 ; + saux += "ZoRaXmin " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x3 ; + saux += "ZoRaXmax " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x4 ; + saux += "ZoRaYmin " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x5 ; + saux += "ZoRaYmax " + saux1.str() + "\n" ; + } + } +// + else if ( ZoneType == 13 ) // Y est constant X Homard <=> X Salome +// Y Homard <=> Z Salome + { + saux += "#Rectangle\n" ; + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x0 ; + saux += "ZoRaXmin " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x1 ; + saux += "ZoRaXmax " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x4 ; + saux += "ZoRaYmin " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x5 ; + saux += "ZoRaYmax " + saux1.str() + "\n" ; + } + } +// +// Cas du parallelepipede +// + else if ( ZoneType == 2 ) + { + saux += "# Boite\n" ; + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x0 ; + saux += "ZoRaXmin " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x1 ; + saux += "ZoRaXmax " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x2 ; + saux += "ZoRaYmin " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x3 ; + saux += "ZoRaYmax " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x4 ; + saux += "ZoRaZmin " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x5 ; + saux += "ZoRaZmax " + saux1.str() + "\n" ; + } + } +// +// Cas du disque +// + else if ( ZoneType == 31 || ZoneType == 61 ) + { + saux += "# Sphere\n" ; + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x0 ; + saux += "ZoRaXCen " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x1 ; + saux += "ZoRaYCen " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x6 ; + saux2 = saux1.str() ; + if ( ZoneType == 61 ) { saux += "ZoRaRayE " + saux2 + "\n" ; } + else { saux += "ZoRaRayo " + saux2 + "\n" ; } + } + if ( ZoneType == 61 ) + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x8 ; + saux += "ZoRaRayI " + saux1.str() + "\n" ; + } + } + else if ( ZoneType == 32 || ZoneType == 62 ) + { + saux += "# Sphere\n" ; + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x1 ; + saux += "ZoRaXCen " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x2 ; + saux += "ZoRaYCen " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x6 ; + saux2 = saux1.str() ; + if ( ZoneType == 62 ) { saux += "ZoRaRayE " + saux2 + "\n" ; } + else { saux += "ZoRaRayo " + saux2 + "\n" ; } + } + if ( ZoneType == 62 ) + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x8 ; + saux += "ZoRaRayI " + saux1.str() + "\n" ; + } + } + else if ( ZoneType == 33 || ZoneType == 63 ) + { + saux += "# Sphere\n" ; + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x0 ; + saux += "ZoRaXCen " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x2 ; + saux += "ZoRaYCen " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x6 ; + saux2 = saux1.str() ; + if ( ZoneType == 63 ) { saux += "ZoRaRayE " + saux2 + "\n" ; } + else { saux += "ZoRaRayo " + saux2 + "\n" ; } + } + if ( ZoneType == 63 ) + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x8 ; + saux += "ZoRaRayI " + saux1.str() + "\n" ; + } + } +// +// Cas de la sphere +// + else if ( ZoneType == 4 ) + { + saux += "# Sphere\n" ; + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x0 ; + saux += "ZoRaXCen " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x1 ; + saux += "ZoRaYCen " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x2 ; + saux += "ZoRaZCen " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x3 ; + saux += "ZoRaRayo " + saux1.str() + "\n" ; + } + } +// +// Cas du cylindre ou du tuyau +// + else if ( ZoneType == 5 || ZoneType == 7 ) + { + if ( ZoneType == 5 ) { saux += "# Cylindre\n" ; } + else { saux += "# Tuyau\n" ; } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x0 ; + saux += "ZoRaXBas " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x1 ; + saux += "ZoRaYBas " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x2 ; + saux += "ZoRaZBas " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x3 ; + saux += "ZoRaXAxe " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x4 ; + saux += "ZoRaYAxe " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x5 ; + saux += "ZoRaZAxe " + saux1.str() + "\n" ; + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x6 ; + saux2 = saux1.str() ; + if ( ZoneType == 5 ) { saux += "ZoRaRayo " + saux2 + "\n" ; } + else { saux += "ZoRaRayE " + saux2 + "\n" ; } + } + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x7 ; + saux += "ZoRaHaut " + saux1.str() + "\n" ; + } + if ( ZoneType == 7 ) + { std::stringstream saux1 ; + saux1 << NumeZone << " " << x8 ; + saux += "ZoRaRayI " + saux1.str() + "\n" ; + } + } +// + _Texte += saux + "#\n" ; +// +// MESSAGE("A la fin de HomardDriver::TexteZone, _Texte ="<<_Texte); +} +//=============================================================================== +void HomardDriver::TexteField( const std::string FieldName, const std::string FieldFile, int TimeStep, int Rank, + int TypeThR, double ThreshR, int TypeThC, double ThreshC, + int UsField, int UsCmpI ) +{ + MESSAGE("TexteField, FieldName = "<= 0 ) + { + { + std::stringstream saux1 ; + saux1 << TimeStep ; + saux2 = saux1.str() ; + _Texte += "CCNumPTI " + saux2 + "\n" ; + } + if ( Rank >= 0 ) + { + std::stringstream saux1 ; + saux1 << Rank ; + saux2 = saux1.str() ; + _Texte += "CCNumOrI " + saux2 + "\n" ; + } + } +// + saux = " " ; + if ( TypeThR == 1 ) + { saux = "Hau" ; } + if ( TypeThR == 2 ) + { saux = "HRe" ; } + if ( TypeThR == 3 ) + { saux = "HPE" ; } + if ( TypeThR == 4 ) + { saux = "HMS" ; } + if ( saux != " " ) + { + std::stringstream saux1 ; + saux1 << ThreshR ; + _Texte += "Seuil" + saux + " " + saux1.str() + "\n" ; + } +// + saux = " " ; + if ( TypeThC == 1 ) + { saux = "Bas" ; } + if ( TypeThC == 2 ) + { saux = "BRe" ; } + if ( TypeThC == 3 ) + { saux = "BPE" ; } + if ( TypeThC == 4 ) + { saux = "BMS" ; } + if ( saux != " " ) + { + std::stringstream saux1 ; + saux1 << ThreshC ; + _Texte += "Seuil" + saux + " " + saux1.str() + "\n" ; + } +// + saux = " " ; + if ( UsField == 0 ) + { saux = "MAILLE" ; } + if ( UsField == 1 ) + { saux = "SAUT" ; } + if ( saux != " " ) + { + _Texte += "CCModeFI " + saux + "\n" ; + } +// + saux = " " ; + if ( UsCmpI == 0 ) + { saux = "L2" ; } + if ( UsCmpI == 1 ) + { saux = "INFINI" ; } + if ( UsCmpI == 2 ) + { saux = "RELATIF" ; } + if ( saux != " " ) + { + _Texte += "CCUsCmpI " + saux + "\n" ; + } +} +//=============================================================================== +void HomardDriver::TexteGroup( const std::string GroupName ) +{ + MESSAGE("TexteGroup, GroupName = "<0 si pas de precision) +// Rank : numero d'ordre retenu +// +void HomardDriver::TexteFieldInterpNameType( int NumeChamp, const std::string FieldName, const std::string TypeInterp, int TimeStep, int Rank) +{ + MESSAGE("TexteFieldInterpNameType, NumeChamp = "<= 0 ) + { + { + std::stringstream saux1 ; + saux1 << TimeStep ; + _Texte += "CCChaPdT " + saux + " " + saux1.str() + "\n" ; + } + { + std::stringstream saux1 ; + saux1 << Rank ; + _Texte += "CCChaNuO " + saux + " " + saux1.str() + "\n" ; + } + } +} +//=============================================================================== +// F. Les options avancees +//=============================================================================== +void HomardDriver::TexteAdvanced( int Pyram, int NivMax, double DiamMin, int AdapInit, int ExtraOutput ) +{ + MESSAGE("TexteAdvanced, Pyram ="< 0 ) + { + _Texte += "# Niveaux extremes\n" ; + { std::stringstream saux1 ; + saux1 << NivMax ; + _Texte += "NiveauMa " + saux1.str() + "\n" ; + } + } + if ( DiamMin > 0 ) + { + _Texte += "# Diametre minimal\n" ; + { std::stringstream saux1 ; + saux1 << DiamMin ; + _Texte += "DiametMi " + saux1.str() + "\n" ; + } + } + if ( AdapInit != 0 ) + { + if ( AdapInit > 0 ) + { _Texte += "# Raffinement" ; } + else + { _Texte += "# Deraffinement" ; } + _Texte += " des regions sans indicateur\n" ; + { std::stringstream saux1 ; + saux1 << AdapInit ; + _Texte += "AdapInit " + saux1.str() + "\n" ; + } + } + if ( ExtraOutput % 2 == 0 ) + { + _Texte += "# Sortie des niveaux de raffinement\n" ; + _Texte += "NCNiveau NIVEAU\n" ; + } + if ( ExtraOutput % 3 == 0 ) + { + _Texte += "# Sortie des qualités des mailles\n" ; + _Texte += "NCQualit QUAL\n" ; + } + if ( ExtraOutput % 5 == 0 ) + { + _Texte += "# Sortie des diamètres des mailles\n" ; + _Texte += "NCDiamet DIAM\n" ; + } + if ( ExtraOutput % 7 == 0 ) + { + _Texte += "# Sortie des parents des mailles\n" ; + _Texte += "NCParent PARENT\n" ; + } + if ( ExtraOutput % 11 == 0 ) + { + _Texte += "# Volumes voisins par recollement\n" ; + _Texte += "NCVoisRc Voisin-Recollement\n" ; + } +} +//=============================================================================== +// G. Les messages +//=============================================================================== +void HomardDriver::TexteInfoCompute( int MessInfo ) +{ + MESSAGE("TexteAdvanced, MessInfo ="< +#include + +class HOMARDIMPL_EXPORT HomardDriver +{ +public: + HomardDriver(const std::string siter, const std::string siterp1); + ~HomardDriver(); + // + void TexteInit( const std::string DirCompute, const std::string LogFile, const std::string Langue ); + void TexteInfo( int TypeBila, int NumeIter ); + void TexteMajCoords( int NumeIter ); + void CreeFichierDonn(); + void TexteAdap( int ExtType ); + void CreeFichier(); + void TexteMaillage( const std::string NomMesh, const std::string MeshFile, int apres ); + void TexteMaillageHOMARD( const std::string Dir, const std::string liter, int apres ); + void TexteConfRaffDera( int ConfType, int TypeAdap, int TypeRaff, int TypeDera ); + void TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8 ); + void TexteGroup( const std::string GroupName ); + void TexteField( const std::string FieldName, const std::string FieldFile, + int TimeStep, int Rank, + int TypeThR, double ThreshR, int TypeThC, double ThreshC, + int UsField, int UsCmpI ); + void TexteCompo( int NumeComp, const std::string NomCompo); + + void TexteBoundaryOption( int BoundaryOption ); + void TexteBoundaryCAOGr( const std::string GroupName ); + void TexteBoundaryDi( const std::string MeshName, const std::string MeshFile ); + void TexteBoundaryDiGr( const std::string GroupName ); + void TexteBoundaryAn( const std::string NameBoundary, int NumeBoundary, int BoundaryType, double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7 ); + void TexteBoundaryAnGr( const std::string NameBoundary, int NumeBoundary, const std::string GroupName ); + + void TexteFieldInterp( const std::string FieldFile, const std::string MeshFile ); + void TexteFieldInterpAll(); + void TexteFieldInterpNameType( int NumeChamp, const std::string FieldName, const std::string TypeInterp, int TimeStep, int Rank ); + void TexteAdvanced( int Pyram, int NivMax, double DiamMin, int AdapInit, int LevelOutput ); + void TexteInfoCompute( int MessInfo ); + // + int ExecuteHomard(int option); + // + +public: + int _modeHOMARD; + std::string _HOMARD_Exec; + std::string _NomDir; + std::string _NomFichierConfBase; + std::string _NomFichierConf; + std::string _NomFichierDonn; + std::string _siter; + std::string _siterp1; + std::string _Texte; + int _TimeStep; + int _Rank; + bool _bLu; + +}; + +# endif /* # ifndef _HOMARDDRIVER_HXX_ */ diff --git a/src/ADAPT/YACSDriver.cxx b/src/ADAPT/YACSDriver.cxx new file mode 100644 index 000000000..864803db8 --- /dev/null +++ b/src/ADAPT/YACSDriver.cxx @@ -0,0 +1,684 @@ +// HOMARD HOMARD : implementation of HOMARD idl descriptions +// +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Pilote l'ecriture du fichier xml pour lancer un schema YACS + +#include +#ifndef WIN32 +#include +#endif +#include + +#include "YACSDriver.hxx" +#include "HOMARD.hxx" +#include "Utils_SALOME_Exception.hxx" +#include "utilities.h" + +//============================================================================= +//============================================================================= +YACSDriver::YACSDriver(const std::string XMLFile, const std::string DirName, const std::string LangueShort): + _XMLFile( "" ), _DirName( "" ), + _Texte( "" ), + _Texte_parametres( "" ), + _noeud_1( "CreateCase" ), + _LangueShort( "" ), + _bLu( false ) +{ + MESSAGE("XMLFile = "<" ; + _Texte += Meshfile ; + _Texte += "\n" ; +// +} +//=============================================================================== +// Le repertoire de calcul +// Le script de lancement +//=============================================================================== +void YACSDriver::Texte_Alternance_Calcul_HOMARD_Calcul( const std::string FileName ) +{ + MESSAGE("Texte_Alternance_Calcul_HOMARD_Calcul, FileName : "<\n" ; + INFOS("_LangueShort = "<<_LangueShort ); + if ( _LangueShort == "fr" ) { motcle = "Etude_Initialisation" ; } + else { motcle = "Study_Initialisation" ; } + INFOS("motcle = "<\n" ; + _Texte += " " + methode + "\n" ; +// 4. Les inports +// 4.1. Le nom de la zone + _Texte += Texte_inport( "string", "ZoneName" ) ; + TexteParametre( node, "ZoneName", "string", ZoneName ) ; +// 4.2. Les valeurs numeriques +// ATTENTION : les noms doivent etre les memes que dans Gen.xml, donc ADAPT_Gen.idl +// 4.2.1. Decodage des valeurs +// La chaine pythonStructure est de ce genre : +// CreateZoneBox( "Zone_1", 0.144, 0.216, 0.096, 0.1464, 0.076, 0.12) + std::string ligne = pythonStructure ; +// On commence par ne garder que ce qui suit la premiere virgule + ligne = GetStringInTexte( ligne, ",", 1 ); +// On boucle pour isoler toutes les chaines dans les virgules + std::string lignebis ; + std::string x0, x1, x2, x3, x4, x5, x6, x7, x8 ; + int iaux = 0 ; + while ( ligne != lignebis ) + { + lignebis = GetStringInTexte ( ligne, ",", 0 ) ; +// MESSAGE("lignebis = "< 10 ) && ( ZoneType < 14 ) ) + { + _Texte += Texte_inport( "double", "Umini" ) ; + _Texte += Texte_inport( "double", "Umaxi" ) ; + _Texte += Texte_inport( "double", "Vmini" ) ; + _Texte += Texte_inport( "double", "Vmaxi" ) ; + _Texte += Texte_inport( "long", "Orient" ) ; + TexteParametre( node, "Umini", "double", x0 ) ; + TexteParametre( node, "Umaxi", "double", x1 ) ; + TexteParametre( node, "Vmini", "double", x2 ) ; + TexteParametre( node, "Vmaxi", "double", x3 ) ; + TexteParametre( node, "Orient", "int", x8 ) ; + } +// +// 4.2.4. Cas du disque (31, 32, 33) ou du disque perce (61, 62, 63) + else if ( ( ( ZoneType > 30 ) && ( ZoneType < 34 ) ) || ( ( ZoneType > 60 ) && ( ZoneType < 64 ) ) ) + { + _Texte += Texte_inport( "double", "Ucentre" ) ; + _Texte += Texte_inport( "double", "Vcentre" ) ; + _Texte += Texte_inport( "double", "Radius" ) ; + TexteParametre( node, "Ucentre", "double", x0 ) ; + TexteParametre( node, "Vcentre", "double", x1 ) ; + TexteParametre( node, "Radius", "double", x2 ) ; + if ( ZoneType > 60 ) + { + _Texte += Texte_inport( "double", "InternalRadius" ) ; + TexteParametre( node, "InternalRadius", "double", x3 ) ; + } + _Texte += Texte_inport( "long", "Orient" ) ; + TexteParametre( node, "Orient", "int", x8 ) ; + } +// +// 4.2.5. Cas de la sphere (4) + else if ( ZoneType == 4 ) + { + _Texte += Texte_inport( "double", "Xcentre" ) ; + _Texte += Texte_inport( "double", "Ycentre" ) ; + _Texte += Texte_inport( "double", "Zcentre" ) ; + _Texte += Texte_inport( "double", "Radius" ) ; + TexteParametre( node, "Xcentre", "double", x0 ) ; + TexteParametre( node, "Ycentre", "double", x1 ) ; + TexteParametre( node, "Zcentre", "double", x2 ) ; + TexteParametre( node, "Radius", "double", x8 ) ; + } +// +// 4.2.6. Cas du cylindre (5) ou du tuyau (7) + else if ( ZoneType == 5 || ZoneType == 7 ) + { + _Texte += Texte_inport( "double", "Xcentre" ) ; + _Texte += Texte_inport( "double", "Ycentre" ) ; + _Texte += Texte_inport( "double", "Zcentre" ) ; + _Texte += Texte_inport( "double", "Xaxis" ) ; + _Texte += Texte_inport( "double", "Yaxis" ) ; + _Texte += Texte_inport( "double", "Zaxis" ) ; + _Texte += Texte_inport( "double", "Radius" ) ; + _Texte += Texte_inport( "double", "Height" ) ; + TexteParametre( node, "Xcentre", "double", x0 ) ; + TexteParametre( node, "Ycentre", "double", x1 ) ; + TexteParametre( node, "Zcentre", "double", x2 ) ; + TexteParametre( node, "Xaxis", "double", x3 ) ; + TexteParametre( node, "Yaxis", "double", x4 ) ; + TexteParametre( node, "Zaxis", "double", x5 ) ; + TexteParametre( node, "Radius", "double", x6 ) ; + if ( ZoneType == 5 ) + { + TexteParametre( node, "Height", "double", x8 ) ; + } + else + { + _Texte += Texte_inport( "double", "InternalRadius" ) ; + TexteParametre( node, "Height", "double", x7 ) ; + TexteParametre( node, "InternalRadius", "double", x8 ) ; + } + } +// +// 4.2.7. Erreur + else + { VERIFICATION("Type de zone inconnu." == 0); } + +// +// 5. La fin + _Texte += " \n" ; + _Texte += " \n" ; +// + return texte_control ; +// +} +//=============================================================================== +// La description des frontieres +// BoundaryType : le type de la frontiere +// pythonStructure : le python correspondant a la frontiere +// methode : methode associee a la creation de la frontiere +// BoundaryName : nom de la frontiere +// MeshName : nom du maillage dans le cas d'une frontiere discrete +// MeshFile : nom du fichier du maillage dans le cas d'une frontiere discrete +//=============================================================================== +std::string YACSDriver::Texte_Iter_1_Boundary( int BoundaryType, const std::string pythonStructure, const std::string methode, const std::string BoundaryName, const std::string MeshName, const std::string MeshFile ) +{ + MESSAGE("Texte_Iter_1_Boundary, BoundaryType = "<\n" ; + if ( _LangueShort == "fr" ) { motcle = "Etude_Initialisation" ; } + else { motcle = "Study_Initialisation" ; } + _Texte += " " + motcle + ".UpdateStudy\n" ; + _Texte += " " + methode + "\n" ; +// 4. Les inports +// ATTENTION : les noms doivent etre les memes que dans Gen.xml, donc ADAPT_Gen.idl +// 4.1. Le nom de la frontiere + _Texte += Texte_inport( "string", "BoundaryName" ) ; + TexteParametre( node, "BoundaryName", "string", BoundaryName ) ; +// 4.2. Cas d une frontiere discrete + if (BoundaryType == 0) + { + _Texte += Texte_inport( "string", "MeshName" ) ; + TexteParametre( node, "MeshName", "string", MeshName ) ; + _Texte += Texte_inport( "string", "FileName" ) ; + TexteParametre( node, "FileName", "string", MeshFile ) ; + } +// 4.3. Cas d'une frontiere analytique : les valeurs numeriques + else + { +// 4.3.1. Decodage des valeurs +// La chaine pythonStructure est de ce genre : +// CreateBoundaryCylinder('cyl_2', 17.5, -2.5, -12.5, -100., -75., -25., 50.) +// CreateBoundaryDi("intersection", "PIQUAGE", "/scratch/D68518/Salome/script/sfr_2d_piquage.fr.med") + std::string ligne = pythonStructure ; +// On commence par ne garder que ce qui suit la premiere virgule + ligne = GetStringInTexte( ligne, ",", 1 ); +// On boucle pour isoler toutes les chaines dans les virgules + std::string lignebis ; + std::string x0, x1, x2, x3, x4, x5, x6, x7 ; + int iaux = 0 ; + while ( ligne != lignebis ) + { + lignebis = GetStringInTexte ( ligne, ",", 0 ) ; +// MESSAGE("lignebis = "<\n" ; + _Texte += " \n" ; +// + return texte_control ; +// +} +//=============================================================================== +// Fin du controle des enchainements de noeud dans le noeud Iter_1 +//=============================================================================== + std::string YACSDriver::Texte_Iter_1_control() +{ + MESSAGE("Texte_Iter_1_control"); +// + std::string texte ; + texte = Texte_control (_noeud_1, "CreateHypothesis", 1) ; + texte += Texte_control ("CreateHypothesis", "Case_Options", 0) ; +// + return texte ; +// +} +//=============================================================================== +// Controle des enchainements de noeuds +// noeud_1 : noeud de depart +// noeud_2 : noeud d'arrivee +// option : 0 : sans caractere de saut de ligne a la fin +// 1 : avec caractere de saut de ligne a la fin +//=============================================================================== + std::string YACSDriver::Texte_control( const std::string noeud_1, const std::string noeud_2, int option ) +{ + MESSAGE("Texte_control, noeud_1 = "< " ; + texte += "" + noeud_1 + "" ; + texte += " " + noeud_2 + "" ; + texte += " " ; + if ( option == 1 ) { texte += "\n" ; } + + return texte ; +// +} +//=============================================================================== +// Inport +// inport_type : type de la donnee a importer +// inport_nom : nom de la donnee a importer +//=============================================================================== + std::string YACSDriver::Texte_inport( const std::string inport_type, const std::string inport_nom ) +{ +// MESSAGE("Texte_inport, inport_type = "< indice ) + { + int position = ligne.find_first_of( "." ) ; + MESSAGE("\nposition : "<< position); + if ( position > 0 ) + { + ligne_bis = ligne.substr( position ); + MESSAGE("\nligne_bis : "<< ligne_bis); + _Texte += concept + ligne_bis + "\n" ; + } + } + cptr += 1 ; + } +// +} +//=============================================================================== +// Manipulation des instructions python - 2 +// pythonTexte : le texte des instructions python a manipuler +// mot_cle : mot-cle dans les lignes a inserer +// concept : nom du concept a inserer +//=============================================================================== +void YACSDriver::Texte_python_2( const std::string pythonTexte, const std::string mot_cle, const std::string concept ) +{ + MESSAGE("Texte_python_2, pythonTexte\n"< 0 ) + { + int position = ligne.find_first_of( "." ) ; +// MESSAGE("\nposition : "<< position); + if ( position > 0 ) + { + ligne_bis = ligne.substr( position ); +// MESSAGE("\nligne_bis : "<< ligne_bis); + _Texte += concept + ligne_bis + "\n" ; + } + } + } +// +} +//=============================================================================== +// Parametres de tests de convergence +//=============================================================================== +void YACSDriver::TexteAnalyse_Test_Convergence( int MaxIter, int MaxNode, int MaxElem ) +{ +// +// MESSAGE("TexteAnalyse_Test_Convergence"); + std::string chaine ; + std::ostringstream oss1; + oss1 << MaxIter; + chaine = oss1.str(); + _Texte += "MaxIter = " + chaine + "\n" ; + std::ostringstream oss2; + oss2 << MaxNode; + chaine = oss2.str(); + _Texte += "MaxNode = " + chaine + "\n" ; + std::ostringstream oss3; + oss3 << MaxElem; + chaine = oss3.str(); + _Texte += "MaxElem = " + chaine + "\n" ; +// +} +//=============================================================================== +// Creation d'un parametre +//=============================================================================== +void YACSDriver::TexteParametre( const std::string node, const std::string port, const std::string type_value, const std::string value ) +{ +// +// MESSAGE("TexteParametre"); + _Texte_parametres += " \n" ; + _Texte_parametres += " " + node + "" ; + _Texte_parametres += "" + port + "\n" ; + _Texte_parametres += " <" + type_value + ">" + value + "\n" ; + _Texte_parametres += " \n" ; +// +} +//=============================================================================== +// Ajout des parametres +//=============================================================================== +void YACSDriver::TexteAddParametres( ) +{ +// + MESSAGE("TexteAddParametres"); + TexteAdd(_Texte_parametres) ; +// +} +//=============================================================================== +void YACSDriver::CreeFichier( ) +{ +// + MESSAGE("CreeFichier sur le fichier "<<_XMLFile); + std::ofstream Fic(_XMLFile.c_str(), std::ios::out ) ; + if (Fic.is_open() == true) { Fic << _Texte << std::endl ; } + Fic.close() ; +// +} +//=============================================================================== +// REMARQUE : on devrait utiliser le GetStringInTexte de ADAPT_Gen_i mais je ne sais pas +// comment l'appeler. ALors je clone. +// Recuperation de la chaine de caracteres par rapport l'apparition d'un texte +// ligne : la ligne a manipuler +// texte : le texte a reperer +// option : 0 : la chaine avant le texte +// 1 : la chaine apres le texte +// Si le texte est absent, on retourne la chaine totale +//=============================================================================== +std::string YACSDriver::GetStringInTexte( const std::string ligne, const std::string texte, int option ) +{ +// MESSAGE("GetStringInTexte, recherche de '"< +#include + +class HOMARDIMPL_EXPORT YACSDriver +{ +public: + YACSDriver(const std::string XMLFile, const std::string DirName, const std::string LangueShort) ; + ~YACSDriver() ; + // + void TexteAdd( const std::string ligne ) ; + void Texte_DataInit_MeshFile( const std::string Meshfile ) ; + void Texte_Alternance_Calcul_HOMARD_Calcul( const std::string FileName ) ; + void Texte_Iter_1_Case_Options( const std::string pythonCas ) ; + std::string Texte_Iter_1_Boundary( int BoundaryType, const std::string pythonStructure, const std::string methode, const std::string BoundaryName, const std::string MeshName, const std::string MeshFile ) ; + std::string Texte_Iter_1_Zone( int ZoneType, const std::string pythonStructure, const std::string methode, const std::string ZoneName ) ; + std::string Texte_Iter_1_control() ; + std::string Texte_control( const std::string noeud_1, const std::string noeud_2, int option ) ; + std::string Texte_inport( const std::string inport_type, const std::string inport_nom ) ; + void Texte_HOMARD_Exec_DirName( ) ; + void Texte_HOMARD_Exec_MeshName( const std::string MeshName ) ; + void Texte_python_1( const std::string pythonTexte, int indice, const std::string concept ) ; + void Texte_python_2( const std::string pythonTexte, const std::string mot_cle, const std::string concept ) ; + void TexteParametre( const std::string node, const std::string port, const std::string type_value, const std::string value ) ; + void TexteAnalyse_Test_Convergence( int MaxIter, int MaxNode, int MaxElem ) ; + void TexteAddParametres( ) ; + void CreeFichier() ; + // + +public: + std::string _XMLFile ; + std::string _DirName ; + std::string _Texte ; + std::string _Texte_parametres ; + std::string _noeud_1 ; + std::string _LangueShort ; + bool _bLu; + +private : + std::string GetStringInTexte( const std::string Texte, const std::string String, int option ) ; +}; + +# endif /* # ifndef __YACSDRIVER_H__ */ diff --git a/src/ADAPTFrontTrack/CMakeLists.txt b/src/ADAPTFrontTrack/CMakeLists.txt new file mode 100644 index 000000000..b19d068e7 --- /dev/null +++ b/src/ADAPTFrontTrack/CMakeLists.txt @@ -0,0 +1,73 @@ +# Copyright (C) 2017-2020 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# --- options --- +# additional include directories +INCLUDE_DIRECTORIES( + ${OpenCASCADE_INCLUDE_DIR} + ${GEOM_INCLUDE_DIRS} + ${MEDFILE_INCLUDE_DIRS} + ${MEDCOUPLING_INCLUDE_DIRS} + ${TBB_INCLUDE_DIRS} +) + +# additional preprocessor / compiler flags +ADD_DEFINITIONS( + ${OpenCASCADE_DEFINITIONS} +) + +IF(ADAPTFRONTTRACK_USE_TBB) + SET(TBB_LIBS ${TBB_LIBRARIES}) +ENDIF(ADAPTFRONTTRACK_USE_TBB) + +# libraries to link to +SET(_link_LIBRARIES + ${OpenCASCADE_FoundationClasses_LIBRARIES} + ${OpenCASCADE_ModelingAlgorithms_LIBRARIES} + ${OpenCASCADE_ModelingData_LIBRARIES} + ${GEOM_XAO} + ${MEDCoupling_medloader} + ${TBB_LIBS} +) + +# --- headers --- + +# header files +SET(ADAPTFRONTTRACK_HEADERS + FrontTrack.hxx +) + +# --- sources --- + +# sources / static +SET(ADAPTFRONTTRACK_SOURCES + FrontTrack.cxx + FrontTrack_NodeGroups.cxx + FrontTrack_NodesOnGeom.cxx + FrontTrack_Projector.cxx + FrontTrack_Utils.cxx +) + +# --- rules --- + +ADD_LIBRARY(ADAPTFrontTrack ${ADAPTFRONTTRACK_SOURCES}) +TARGET_LINK_LIBRARIES(ADAPTFrontTrack ${_link_LIBRARIES} ) +INSTALL(TARGETS ADAPTFrontTrack EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +INSTALL(FILES ${ADAPTFRONTTRACK_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) diff --git a/src/ADAPTFrontTrack/FrontTrack.cxx b/src/ADAPTFrontTrack/FrontTrack.cxx new file mode 100644 index 000000000..91eb4b606 --- /dev/null +++ b/src/ADAPTFrontTrack/FrontTrack.cxx @@ -0,0 +1,164 @@ +// Copyright (C) 2017-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : FrontTrack.cxx +// Created : Tue Apr 25 17:20:28 2017 +// Author : Edward AGAPOV (eap) + +#include "FrontTrack.hxx" +#include "FrontTrack_NodeGroups.hxx" +#include "FrontTrack_Utils.hxx" + +#include +#include +#include + +#include +#include + +#include + +#include + +/*! + * \brief Relocate nodes to lie on geometry + * \param [in] theInputMedFile - a MED file holding a mesh including nodes that will be + * moved onto the geometry + * \param [in] theOutputMedFile - a MED file to create, that will hold a modified mesh + * \param [in] theInputNodeFiles - an array of names of files describing groups of nodes that + * will be moved onto the geometry + * \param [in] theXaoFileName - a path to a file in XAO format holding the geometry and + * the geometrical groups. + * \param [in] theIsParallel - if \c true, all processors are used to treat boundary shapes + * in parallel. + */ +void FrontTrack::track( const std::string& theInputMedFile, + const std::string& theOutputMedFile, + const std::vector< std::string > & theInputNodeFiles, + const std::string& theXaoFileName, + bool theIsParallel ) +{ + // check arguments +#ifdef _DEBUG_ + std::cout << "FrontTrack::track" << std::endl; +#endif + + if ( theInputNodeFiles.empty() ) + return; + +#ifdef _DEBUG_ + std::cout << "Input MED file: " << theInputMedFile << std::endl; +#endif + if ( !FT_Utils::fileExists( theInputMedFile )) + throw std::invalid_argument( "Input MED file does not exist: " + theInputMedFile ); + +#ifdef _DEBUG_ + std::cout << "Output MED file: " << theOutputMedFile << std::endl; +#endif + if ( !FT_Utils::canWrite( theOutputMedFile )) + throw std::invalid_argument( "Can't create the output MED file: " + theOutputMedFile ); + + std::vector< std::string > theNodeFiles ; + for ( size_t i = 0; i < theInputNodeFiles.size(); ++i ) + { +#ifdef _DEBUG_ + std::cout << "Initial input node file #"<1 + // keep only files with more than 1 line: + std::ifstream fichier(theInputNodeFiles[i].c_str()); + std::string s; + unsigned int nb_lines = 0; + while(std::getline(fichier,s)) ++nb_lines; +// std::cout << ". nb_lines: " << nb_lines << std::endl; + if ( nb_lines >= 2 ) { theNodeFiles.push_back( theInputNodeFiles[i] ); } + } +#ifdef _DEBUG_ + for ( size_t i = 0; i < theNodeFiles.size(); ++i ) + { std::cout << "Valid input node file #"< + mfMesh( MEDCoupling::MEDFileUMesh::New( theInputMedFile )); + if ( mfMesh.isNull() ) + throw std::invalid_argument( "Failed to read the input MED file: " + theInputMedFile ); + + MEDCoupling::DataArrayDouble * nodeCoords = mfMesh->getCoords(); + if ( !nodeCoords || nodeCoords->empty() ) + throw std::invalid_argument( "No nodes in the input mesh" ); + + + // read a geometry + +#ifdef _DEBUG_ + std::cout << "Lecture de la geometrie" << std::endl; +#endif + XAO::Xao xao; + if ( !xao.importXAO( theXaoFileName ) || !xao.getGeometry() ) + throw std::invalid_argument( "Failed to read the XAO input file: " + theXaoFileName ); + +#ifdef _DEBUG_ + std::cout << "Conversion en BREP" << std::endl; +#endif + XAO::BrepGeometry* xaoGeom = dynamic_cast( xao.getGeometry() ); + if ( !xaoGeom || xaoGeom->getTopoDS_Shape().IsNull() ) + throw std::invalid_argument( "Failed to get a BREP shape from the XAO input file" ); + + + // read groups of nodes and associate them with boundary shapes using names (no projection so far) + +#ifdef _DEBUG_ + std::cout << "Lecture des groupes" << std::endl; +#endif + FT_NodeGroups nodeGroups; + nodeGroups.read( theNodeFiles, &xao, nodeCoords ); +#ifdef _DEBUG_ + std::cout << "Nombre de groupes : " << nodeGroups.nbOfGroups() << std::endl; +#endif + + // project nodes to the boundary shapes and change their coordinates + +#ifdef _DEBUG_ + std::cout << "Projection des noeuds, theIsParallel=" << theIsParallel << std::endl; +#endif + OSD_Parallel::For( 0, nodeGroups.nbOfGroups(), nodeGroups, !theIsParallel ); + + // save the modified mesh + +#ifdef _DEBUG_ + std::cout << "Ecriture du maillage" << std::endl; +#endif + const int erase = 2; + mfMesh->write( theOutputMedFile, /*mode=*/erase ); + + if ( !nodeGroups.isOK() ) + throw std::runtime_error("Unable to project some nodes"); +} diff --git a/src/ADAPTFrontTrack/FrontTrack.hxx b/src/ADAPTFrontTrack/FrontTrack.hxx new file mode 100644 index 000000000..fa033161c --- /dev/null +++ b/src/ADAPTFrontTrack/FrontTrack.hxx @@ -0,0 +1,54 @@ +// Copyright (C) 2017-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : FrontTrack.hxx +// Created : Tue Apr 25 17:08:52 2017 +// Author : Edward AGAPOV (eap) + + +#ifndef __FrontTrack_HXX__ +#define __FrontTrack_HXX__ + +#include +#include + +class FrontTrack +{ +public: + + /*! + * \brief Relocate nodes to lie on geometry + * \param [in] theInputMedFile - a MED file holding a mesh including nodes that will be + * moved onto the geometry + * \param [in] theOutputMedFile - a MED file to create, that will hold a modified mesh + * \param [in] theInputNodeFiles - an array of names of files describing groups of nodes that + * will be moved onto the geometry + * \param [in] theXaoFileName - a path to a file in XAO format holding the geometry and + * the geometrical groups. + * \param [in] theIsParallel - if \c true, all processors are used to treat boundary shapes + * in parallel. + */ + void track( const std::string& theInputMedFile, + const std::string& theOutputMedFile, + const std::vector< std::string > & theInputNodeFiles, + const std::string& theXaoFileName, + bool theIsParallel=true); + +}; + +#endif diff --git a/src/ADAPTFrontTrack/FrontTrack_NodeGroups.cxx b/src/ADAPTFrontTrack/FrontTrack_NodeGroups.cxx new file mode 100644 index 000000000..247def290 --- /dev/null +++ b/src/ADAPTFrontTrack/FrontTrack_NodeGroups.cxx @@ -0,0 +1,134 @@ +// Copyright (C) 2017-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : FrontTrack_NodeGroups.cxx +// Created : Tue Apr 25 19:17:47 2017 +// Author : Edward AGAPOV (eap) + +#include "FrontTrack_NodeGroups.hxx" +#include "FrontTrack_Projector.hxx" +#include "FrontTrack_Utils.hxx" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace +{ + //================================================================================ + /*! + * \brief Initialize FT_Projector's with all sub-shapes of given type + * \param [in] theMainShape - the shape to explore + * \param [in] theSubType - the type of sub-shapes + * \param [out] theProjectors - the projectors + */ + //================================================================================ + + void getProjectors( const TopoDS_Shape& theMainShape, + const TopAbs_ShapeEnum theSubType, + std::vector< FT_Projector > & theProjectors ) + { + TopTools_IndexedMapOfShape subShapes; + TopExp::MapShapes( theMainShape, theSubType, subShapes ); +#ifdef _DEBUG_ + std::cout << ". Nombre de subShapes : " << subShapes.Size() << std::endl; +#endif + + theProjectors.resize( subShapes.Size() ); + for ( int i = 1; i <= subShapes.Size(); ++i ) + theProjectors[ i-1 ].setBoundaryShape( subShapes( i )); + } +} + +//================================================================================ +/*! + * \brief Load node groups from files + * \param [in] theNodeFiles - an array of names of files describing groups of nodes that + * will be moved onto geometry + * \param [in] theXaoGeom - the whole geometry to project on + * \param [inout] theNodeCoords - array of node coordinates + */ +//================================================================================ + +void FT_NodeGroups::read( const std::vector< std::string >& theNodeFiles, + const XAO::Xao* theXao, + MEDCoupling::DataArrayDouble* theNodeCoords ) +{ + // get projectors for all boundary sub-shapes; + // index of a projector in the vector corresponds to a XAO index of a sub-shape + XAO::BrepGeometry* xaoGeom = dynamic_cast( theXao->getGeometry() ); + getProjectors( xaoGeom->getTopoDS_Shape(), TopAbs_EDGE, _projectors[0] ); + getProjectors( xaoGeom->getTopoDS_Shape(), TopAbs_FACE, _projectors[1] ); + + _nodesOnGeom.resize( theNodeFiles.size() ); + + // read node IDs and look for projectors to boundary sub-shapes by group name + FT_Utils::XaoGroups xaoGroups( theXao ); + for ( size_t i = 0; i < theNodeFiles.size(); ++i ) + { + _nodesOnGeom[i].read( theNodeFiles[i], xaoGroups, theNodeCoords, _projectors ); + } +} + +//================================================================================ +/*! + * \brief Project and move nodes of a given group of nodes + */ +//================================================================================ + +void FT_NodeGroups::projectAndMove( const int groupIndex ) +{ + _nodesOnGeom[ groupIndex ].projectAndMove(); +} + +//================================================================================ +/*! + * \brief Return true if all nodes were successfully relocated + */ +//================================================================================ + +bool FT_NodeGroups::isOK() const +{ + for ( size_t i = 0; i < _nodesOnGeom.size(); ++i ) + if ( ! _nodesOnGeom[ i ].isOK() ) + return false; + + return true; +} + +//================================================================================ +/*! + * \brief Print some statistics on node groups + */ +//================================================================================ + +void FT_NodeGroups::dumpStat() const +{ + for ( size_t i = 0; i < _nodesOnGeom.size(); ++i ) + { + std::cout << _nodesOnGeom[i].getShapeDim() << "D " + << _nodesOnGeom[i].nbNodes() << " nodes" << std::endl; + } +} diff --git a/src/ADAPTFrontTrack/FrontTrack_NodeGroups.hxx b/src/ADAPTFrontTrack/FrontTrack_NodeGroups.hxx new file mode 100644 index 000000000..9204ac8af --- /dev/null +++ b/src/ADAPTFrontTrack/FrontTrack_NodeGroups.hxx @@ -0,0 +1,76 @@ +// Copyright (C) 2017-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : FrontTrack_NodeGroups.hxx +// Created : Tue Apr 25 19:02:49 2017 +// Author : Edward AGAPOV (eap) + +#ifndef __FrontTrack_NodeGroups_HXX__ +#define __FrontTrack_NodeGroups_HXX__ + +#include "FrontTrack_NodesOnGeom.hxx" +#include "FrontTrack_Projector.hxx" + +#include +#include + +namespace MEDCoupling { + class DataArrayDouble; +} +namespace XAO { + class Xao; +} + +/*! + * \brief Container of node groups. + */ +class FT_NodeGroups +{ +public: + + // Load node groups from files + void read( const std::vector< std::string >& nodeFiles, + const XAO::Xao* xaoGeom, + MEDCoupling::DataArrayDouble* nodeCoords ); + + // return number of groups of nodes to move + int nbOfGroups() const { return _nodesOnGeom.size(); } + + // Move nodes of a group in parallel mode + void operator() ( const int groupIndex ) const + { + const_cast< FT_NodeGroups* >( this )->projectAndMove( groupIndex ); + } + + // Project and move nodes of a given group of nodes + void projectAndMove( const int groupIndex ); + + // return true if all nodes were successfully relocated + bool isOK() const; + + // print some statistics on node groups + void dumpStat() const; + +private: + + std::vector< FT_NodesOnGeom > _nodesOnGeom; + std::vector< FT_Projector > _projectors[2]; // curves and surfaces separately + +}; + +#endif diff --git a/src/ADAPTFrontTrack/FrontTrack_NodesOnGeom.cxx b/src/ADAPTFrontTrack/FrontTrack_NodesOnGeom.cxx new file mode 100644 index 000000000..16422348e --- /dev/null +++ b/src/ADAPTFrontTrack/FrontTrack_NodesOnGeom.cxx @@ -0,0 +1,511 @@ +// Copyright (C) 2017-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : FrontTrack_NodesOnGeom.cxx +// Created : Tue Apr 25 20:48:23 2017 +// Author : Edward AGAPOV (eap) + +#include "FrontTrack_NodesOnGeom.hxx" +#include "FrontTrack_Utils.hxx" + +#include + +#include +#include +#include +#include + +namespace +{ + /*! + * \brief Close a file at destruction + */ + struct FileCloser + { + FILE * _file; + + FileCloser( FILE * file ): _file( file ) {} + ~FileCloser() { if ( _file ) ::fclose( _file ); } + }; +} + +//================================================================================ +/*! + * \brief Read node ids from a file and find shapes for projection + * \param [in] theNodeFile - a name of file holding IDs of nodes that + * will be moved onto geometry + * \param [in] theXaoGroups - a tool returning FT_Projector's by XAO group name + * \param [inout] theNodeCoords - array of node coordinates + * \param [in] theAllProjectorsByDim - all projectors of 2 dimensions, ordered so that + * a vector index corresponds to a XAO sub-shape ID + */ +//================================================================================ + +void FT_NodesOnGeom::read( const std::string& theNodeFile, + const FT_Utils::XaoGroups& theXaoGroups, + MEDCoupling::DataArrayDouble* theNodeCoords, + std::vector< FT_Projector > * theAllProjectorsByDim ) +{ + _nodeCoords = theNodeCoords; + + FILE * file = ::fopen( theNodeFile.c_str(), "r" ); + if ( !file ) + throw std::invalid_argument( "Can't open an input node file: " + theNodeFile ); + + FileCloser fileCloser( file ); + + // ------------------------------------- + // get shape dimension by the file name + // ------------------------------------- + + // hope the file name is something like "frnD.**" with n in (1,2) + int dimPos = theNodeFile.size() - 5; + if ( theNodeFile[ dimPos ] == '2' ) + _shapeDim = 2; + else if ( theNodeFile[ dimPos ] == '1' ) + _shapeDim = 1; + else + throw std::invalid_argument( "Can't define dimension by node file name " + theNodeFile ); +#ifdef _DEBUG_ + std::cout << ". Dimension of the file " << theNodeFile << ": " << _shapeDim << std::endl; +#endif + + // ------------------------------------- + // read geom group names; several lines + // ------------------------------------- + + std::vector< std::string > geomNames; + + const int maxLineLen = 256; + char line[ maxLineLen ]; + + long int pos = ::ftell( file ); + while ( ::fgets( line, maxLineLen, file )) // read a line + { + if ( ::feof( file )) + { + return; // no nodes in the file + } + + // check if the line describes node ids in format 3I10 (e.g. " 120 1 43\n") + size_t lineLen = strlen( line ); + if ( lineLen >= 31 && + ::isdigit( line[9] ) && + line[10] == ' ' && + ::isdigit( line[19] ) && + line[20] == ' ' && + ::isdigit( line[29] ) && + ::isspace( line[30] )) + break; + + geomNames.push_back( line + 1 ); // skip the 1st white space + + pos = ::ftell( file ); // remember the position to return if the next line holds node ids + } + + ::fseek( file, pos, SEEK_SET ); // return to the 1st line holding nodes ids + + + // -------------- + // read node ids + // -------------- + + FT_NodeToMove nodeIds; + std::vector< int > ids; + + const int nbNodes = theNodeCoords->getNumberOfTuples(); // to check validity of node IDs + + while ( ::fgets( line, maxLineLen, file )) // read a line + { + // find node ids in the line + + char *beg = line, *end = 0; + long int id; + + ids.clear(); + while (( id = ::strtol( beg, &end, 10 )) && + ( beg != end )) + { + ids.push_back( id ); + if ( id > nbNodes ) + throw std::invalid_argument( "Too large node ID: " + FT_Utils::toStr( id )); + beg = end; + } + + if ( ids.size() >= 3 ) + { + std::vector< int >::iterator i = ids.begin(); + nodeIds._nodeToMove = *i; + nodeIds._neighborNodes.assign( ++i, ids.end() ); + + _nodes.push_back( nodeIds ); + } + + if ( ::feof( file )) + break; + } + + // ----------------------------------------------------------------- + // try to find FT_Projector's to boundary sub-shapes by group names + // ----------------------------------------------------------------- + + _allProjectors = & theAllProjectorsByDim[ _shapeDim - 1 ]; + + _projectors.reserve( geomNames.size() ); + std::vector< const FT_Projector* > projectors; + + for ( size_t i = 0; i < geomNames.size(); ++i ) + { + std::string & groupName = geomNames[i]; +#ifdef _DEBUG_ + std::cout << ". Group name: " << groupName << std::endl; +#endif + + // remove trailing white spaces + for ( int iC = groupName.size() - 1; iC >= 0; --iC ) + { + if ( ::isspace( groupName[iC] ) ) + groupName.resize( iC ); + else + break; + } + if ( groupName.empty() ) + continue; + + _groupNames.push_back( groupName ); // keep _groupNames for easier debug :) + + // get projectors by group name + theXaoGroups.getProjectors( groupName, _shapeDim, + theAllProjectorsByDim[ _shapeDim-1 ], projectors ); + } + + // ------------------------------ + // check the found FT_Projector's + // ------------------------------ + + if ( projectors.size() == 1 ) + { + _projectors.push_back( *projectors[ 0 ]); + } + else + { + Bnd_Box nodesBox; + for ( size_t i = 0; i < _nodes.size(); ++i ) + nodesBox.Add( getPoint( _nodes[i]._nodeToMove )); + + if ( projectors.size() > 1 ) + { + // more than one boundary shape; + // try to filter off unnecessary projectors using a bounding box of nodes + for ( size_t i = 0; i < projectors.size(); ++i ) + if ( !nodesBox.IsOut( projectors[ i ]->getBoundingBox() )) + _projectors.push_back( *projectors[ i ]); + } + + if ( _projectors.empty() ) + { + // select projectors using a bounding box of nodes + std::vector< FT_Projector > & allProjectors = *_allProjectors; + for ( size_t i = 0; i < allProjectors.size(); ++i ) + if ( !nodesBox.IsOut( allProjectors[ i ].getBoundingBox() )) + _projectors.push_back( allProjectors[ i ]); + + if ( _projectors.empty() && !_nodes.empty() ) + throw std::runtime_error("No boundary shape found for nodes in file " + theNodeFile ); + } + } + + // prepare for projection - create real projectors + for ( size_t i = 0; i < _projectors.size(); ++i ) + _projectors[ i ].prepareForProjection(); + +} + +//================================================================================ +/*! + * \brief Project nodes to the shapes and move them to new positions + */ +//================================================================================ + +void FT_NodesOnGeom::projectAndMove() +{ + _OK = true; +// +// 1. Préalables +// + // check if all the shapes are planar + bool isAllPlanar = true; + for ( size_t i = 0; i < _projectors.size() && isAllPlanar; ++i ) + isAllPlanar = _projectors[i].isPlanarBoundary(); + if ( isAllPlanar ) + return; + + // set nodes in the order suitable for optimal projection + putNodesInOrder(); + + // project and move nodes + + std::vector< FT_NodeToMove* > notProjectedNodes; + size_t iP, iProjector; + gp_Pnt newXyz; + +#ifdef _DEBUG_ + std::cout << ".. _projectors.size() = " << _projectors.size() << std::endl; + std::cout << ".. _nodesOrder.size() = " << _nodesOrder.size() << std::endl; +#endif +// +// 2. Calculs +// 2.1. Avec plusieurs shapes +// + if ( _projectors.size() > 1 ) + { + // the nodes are to be projected onto several boundary shapes; + // in addition to the projecting, classification on a shape is necessary + // in order to find out on which of the shapes a node is to be projected + + iProjector = 0; + for ( size_t i = 0; i < _nodesOrder.size(); ++i ) + { + FT_NodeToMove& nn = _nodes[ _nodesOrder[ i ]]; + gp_Pnt xyz = getPoint( nn._nodeToMove ); + gp_Pnt xyz1 = getPoint( nn._neighborNodes[0] ); + gp_Pnt xyz2 = getPoint( nn._neighborNodes[1] ); + double maxDist2 = xyz1.SquareDistance( xyz2 ) / 4.; + if ( _projectors[ iProjector ].projectAndClassify( xyz, maxDist2, newXyz, + nn._params, nn._nearParams )) + { + moveNode( nn._nodeToMove, newXyz ); + } + else // a node is not on iProjector-th shape, find the shape it is on + { + for ( iP = 1; iP < _projectors.size(); ++iP ) // check _projectors other than iProjector + { + iProjector = ( iProjector + 1 ) % _projectors.size(); + if ( _projectors[ iProjector ].projectAndClassify( xyz, maxDist2, newXyz, + nn._params, nn._nearParams )) + { + moveNode( nn._nodeToMove, newXyz ); + break; + } + } + if ( iP == _projectors.size() ) + { + notProjectedNodes.push_back( &nn ); + +#ifdef _DEBUG_ + std::cerr << "Warning: no shape found for node " << nn._nodeToMove << std::endl; + if ( !_groupNames.empty() ) + std::cerr << "Warning: group -- " << _groupNames[0] << std::endl; +#endif + } + } + } + } +// +// 2.2. Avec une seule shape +// + else // one shape + { + for ( size_t i = 0; i < _nodesOrder.size(); ++i ) + { + FT_NodeToMove& nn = _nodes[ _nodesOrder[ i ]]; + gp_Pnt xyz = getPoint( nn._nodeToMove ); + gp_Pnt xyz1 = getPoint( nn._neighborNodes[0] ); + gp_Pnt xyz2 = getPoint( nn._neighborNodes[1] ); + +// maxDist2 : le quart du carré de la distance entre les deux voisins du noeud à bouger + double maxDist2 = xyz1.SquareDistance( xyz2 ) / 4.; +#ifdef _DEBUG_ + std::cout << "\n.. maxDist2 = " << maxDist2 << " entre " << nn._neighborNodes[0] << " et " << nn._neighborNodes[1] << " - milieu " << nn._nodeToMove << " - d/2 = " << sqrt(maxDist2) << " - d = " << sqrt(xyz1.SquareDistance( xyz2 )) << std::endl; +#endif + if ( _projectors[ 0 ].project( xyz, maxDist2, newXyz, + nn._params, nn._nearParams )) + moveNode( nn._nodeToMove, newXyz ); + else + notProjectedNodes.push_back( &nn ); + } + } +// +// 3. Bilan +// + if ( !notProjectedNodes.empty() ) + { + // project nodes that are not projected by any of _projectors; + // a proper projector is selected by evaluation of a distance between neighbor nodes + // and a shape + + std::vector< FT_Projector > & projectors = *_allProjectors; + + iProjector = 0; + for ( size_t i = 0; i < notProjectedNodes.size(); ++i ) + { + FT_NodeToMove& nn = *notProjectedNodes[ i ]; + gp_Pnt xyz = getPoint( nn._nodeToMove ); + gp_Pnt xyz1 = getPoint( nn._neighborNodes[0] ); + gp_Pnt xyz2 = getPoint( nn._neighborNodes[1] ); + double maxDist2 = xyz1.SquareDistance( xyz2 ) / 4.; + double tol2 = 1e-6 * maxDist2; + + bool ok; + for ( iP = 0; iP < projectors.size(); ++iP ) + { + projectors[ iProjector ].prepareForProjection(); + projectors[ iProjector ].tryWithoutPrevSolution( true ); + + if (( ok = projectors[ iProjector ].isOnShape( xyz1, tol2, nn._params, nn._nearParams )) && + ( ok = projectors[ iProjector ].isOnShape( xyz2, tol2, nn._params, nn._params ))) + { + if ( nn._neighborNodes.size() == 4 ) + { + gp_Pnt xyz1 = getPoint( nn._neighborNodes[2] ); + gp_Pnt xyz2 = getPoint( nn._neighborNodes[3] ); + if (( ok = projectors[ iProjector ].isOnShape( xyz1, tol2, nn._params, nn._params ))) + ok = projectors[ iProjector ].isOnShape( xyz2, tol2, nn._params, nn._params ); + } + } + + if ( ok && projectors[iProjector].project( xyz, maxDist2, newXyz, nn._params, nn._params )) + { + moveNode( nn._nodeToMove, newXyz ); + break; + } + iProjector = ( iProjector + 1 ) % projectors.size(); + } + if ( iP == projectors.size() ) + { + _OK = false; + + std::cerr << "Error: not projected node " << nn._nodeToMove << std::endl; + } + } + } +} + +//================================================================================ +/*! + * \brief Put nodes in the order for optimal projection and set FT_NodeToMove::_nearParams + * to point to a FT_NodeToMove::_params of a node that will be projected earlier + */ +//================================================================================ + +void FT_NodesOnGeom::putNodesInOrder() +{ + if ( !_nodesOrder.empty() ) + return; + + // check if any of projectors can use parameters of a previously projected node on a shape + // to speed up projection + + bool isPrevSolutionUsed = false; + for ( size_t i = 0; i < _projectors.size() && !isPrevSolutionUsed; ++i ) + isPrevSolutionUsed = _projectors[i].canUsePrevSolution(); + + if ( !isPrevSolutionUsed ) + { + _nodesOrder.resize( _nodes.size() ); + for ( size_t i = 0; i < _nodesOrder.size(); ++i ) + _nodesOrder[ i ] = i; + return; + } + + // make a map to find a neighbor projected node + + // map of { FT_NodeToMove::_neighborNodes[i] } to { FT_NodeToMove* }; + // here we call FT_NodeToMove a 'link' as this data links a _neighborNodes[i] node to other nodes + typedef NCollection_DataMap< int, std::vector< FT_NodeToMove* > > TNodeIDToLinksMap; + TNodeIDToLinksMap neigborsMap; + + int mapSize = ( _shapeDim == 1 ) ? _nodes.size() + 1 : _nodes.size() * 3; + neigborsMap.Clear(); + neigborsMap.ReSize( mapSize ); + + std::vector< FT_NodeToMove* > linkVec, *linkVecPtr; + const int maxNbLinks = ( _shapeDim == 1 ) ? 2 : 6; // usual nb of links + + for ( size_t i = 0; i < _nodes.size(); ++i ) + { + FT_NodeToMove& nn = _nodes[i]; + for ( size_t iN = 0; iN < nn._neighborNodes.size(); ++iN ) + { + if ( !( linkVecPtr = neigborsMap.ChangeSeek( nn._neighborNodes[ iN ] ))) + { + linkVecPtr = neigborsMap.Bound( nn._neighborNodes[ iN ], linkVec ); + linkVecPtr->reserve( maxNbLinks ); + } + linkVecPtr->push_back( & nn ); + } + } + + // fill in _nodesOrder + + _nodesOrder.reserve( _nodes.size() ); + + std::list< FT_NodeToMove* > queue; + queue.push_back( &_nodes[0] ); + _nodes[0]._nearParams = _nodes[0]._params; // to avoid re-adding to the queue + + while ( !queue.empty() ) + { + FT_NodeToMove* nn = queue.front(); + queue.pop_front(); + + _nodesOrder.push_back( nn - & _nodes[0] ); + + // add neighbors to the queue and set their _nearParams = nn->_params + for ( size_t iN = 0; iN < nn->_neighborNodes.size(); ++iN ) + { + std::vector< FT_NodeToMove* >& linkVec = neigborsMap( nn->_neighborNodes[ iN ]); + for ( size_t iL = 0; iL < linkVec.size(); ++iL ) + { + FT_NodeToMove* nnn = linkVec[ iL ]; + if ( nnn != nn && nnn->_nearParams == 0 ) + { + nnn->_nearParams = nn->_params; + queue.push_back( nnn ); + } + } + } + } + _nodes[0]._nearParams = 0; // reset +} + +//================================================================================ +/*! + * \brief Get node coordinates. Node IDs count from a unit + */ +//================================================================================ + +gp_Pnt FT_NodesOnGeom::getPoint( const int nodeID ) +{ + const size_t dim = _nodeCoords->getNumberOfComponents(); + const double * xyz = _nodeCoords->getConstPointer() + ( dim * ( nodeID - 1 )); + return gp_Pnt( xyz[0], xyz[1], dim == 2 ? 0 : xyz[2] ); +} + +//================================================================================ +/*! + * \brief change node coordinates + */ +//================================================================================ + +void FT_NodesOnGeom::moveNode( const int nodeID, const gp_Pnt& newXyz ) +{ + const size_t dim = _nodeCoords->getNumberOfComponents(); + double z, *xyz = _nodeCoords->getPointer() + ( dim * ( nodeID - 1 )); + newXyz.Coord( xyz[0], xyz[1], dim == 2 ? z : xyz[2] ); +} diff --git a/src/ADAPTFrontTrack/FrontTrack_NodesOnGeom.hxx b/src/ADAPTFrontTrack/FrontTrack_NodesOnGeom.hxx new file mode 100644 index 000000000..08db0e1de --- /dev/null +++ b/src/ADAPTFrontTrack/FrontTrack_NodesOnGeom.hxx @@ -0,0 +1,117 @@ +// Copyright (C) 2017-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : FrontTrack_NodesOnGeom.hxx +// Created : Tue Apr 25 19:12:25 2017 +// Author : Edward AGAPOV (eap) + + +#ifndef __FrontTrack_NodesOnGeom_HXX__ +#define __FrontTrack_NodesOnGeom_HXX__ + +#include "FrontTrack_Projector.hxx" + +#include +#include +#include +#include + +#include +#include + +namespace FT_Utils { + struct XaoGroups; +} +namespace MEDCoupling { + class DataArrayDouble; +} +namespace XAO { + class BrepGeometry; +} + + //-------------------------------------------------------------------------------------------- +/*! + * \brief Node group and geometry to project onto + */ +class FT_NodesOnGeom +{ +public: + + // read node IDs form a file and try to find a boundary sub-shape by name + void read( const std::string& nodesFile, + const FT_Utils::XaoGroups& xaoGroups, + MEDCoupling::DataArrayDouble* nodeCoords, + std::vector< FT_Projector > * allProjectorsByDim); + + // chose boundary shapes by evaluating distance between nodes and shapes + //void choseShape( const std::vector< FT_Utils::ShapeAndBndBox >& shapeAndBoxList ); + + // project nodes to the shapes and move them to new positions + void projectAndMove(); + + // return true if all nodes were successfully relocated + bool isOK() const { return _OK; } + + // return dimension of boundary shapes + int getShapeDim() const { return _shapeDim; } + + // return nb of nodes to move + int nbNodes() const { return _nodes.size(); } + + +private: + + // put nodes in the order for optimal projection + void putNodesInOrder(); + + // get node coordinates + gp_Pnt getPoint( const int nodeID ); + + // change node coordinates + void moveNode( const int nodeID, const gp_Pnt& xyz ); + + + // Ids of a node to move and its 2 or 4 neighbors + struct FT_NodeToMove + { + int _nodeToMove; + std::vector< int > _neighborNodes; + + double _params[2]; // parameters on shape (U or UV) found by projection + double *_nearParams; // _params of a neighbor already projected node + + FT_NodeToMove(): _nearParams(0) {} + }; + + std::vector< std::string > _groupNames; + int _shapeDim; // dimension of boundary shapes + std::vector< FT_NodeToMove > _nodes; // ids of nodes to move and their neighbors + std::vector< FT_Projector > _projectors; // FT_Projector's initialized with boundary shapes + std::vector< FT_Projector > * _allProjectors; // FT_Projector's for all shapes of _shapeDim + MEDCoupling::DataArrayDouble* _nodeCoords; + bool _OK; // projecting is successful + + // map of { FT_NodeToMove::_neighborNodes[i] } to { FT_NodeToMove* } + // this map is used to find neighbor nodes + typedef NCollection_DataMap< int, std::vector< FT_NodeToMove* > > TNodeIDToLinksMap; + TNodeIDToLinksMap _neigborsMap; + std::vector _nodesOrder; + +}; + +#endif diff --git a/src/ADAPTFrontTrack/FrontTrack_Projector.cxx b/src/ADAPTFrontTrack/FrontTrack_Projector.cxx new file mode 100644 index 000000000..a3bbfc614 --- /dev/null +++ b/src/ADAPTFrontTrack/FrontTrack_Projector.cxx @@ -0,0 +1,947 @@ +// Copyright (C) 2017-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : FrontTrack_Projector.cxx +// Created : Wed Apr 26 20:33:55 2017 +// Author : Edward AGAPOV (eap) + +#include "FrontTrack_Projector.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +//----------------------------------------------------------------------------- +/*! + * \brief Root class of a projector of a point to a boundary shape + */ +struct FT_RealProjector +{ + virtual ~FT_RealProjector() {} + + /*! + * \brief Project a point to a boundary shape + * \param [in] point - the point to project + * \param [out] newSolution - position on the shape (U or UV) found during the projection + * \param [in] prevSolution - position already found during the projection of a neighbor point + * \return gp_Pnt - the projection point + */ + virtual gp_Pnt project( const gp_Pnt& point, + double* newSolution, + const double* prevSolution = 0) = 0; + + /*! + * \brief Project a point to a boundary shape and check if the projection is within + * the shape boundary + * \param [in] point - the point to project + * \param [in] maxDist2 - the maximal allowed square distance between point and projection + * \param [out] projection - the projection point + * \param [out] newSolution - position on the shape (U or UV) found during the projection + * \param [in] prevSolution - position already found during the projection of a neighbor point + * \return bool - false if the projection point lies out of the shape boundary or + the distance the point and the projection is more than sqrt(maxDist2) + */ + virtual bool projectAndClassify( const gp_Pnt& point, + const double maxDist2, + gp_Pnt& projection, + double* newSolution, + const double* prevSolution = 0) = 0; + + // return true if a previously found solution can be used to speed up the projection + + virtual bool canUsePrevSolution() const { return false; } + + + double _dist; // distance between the point being projected and its projection +}; + +namespace // actual projection algorithms +{ + const double theEPS = 1e-12; + + //================================================================================ + /*! + * \brief Projector to any curve + */ + //================================================================================ + + struct CurveProjector : public FT_RealProjector + { + BRepAdaptor_Curve _curve; + double _tol; + ShapeAnalysis_Curve _projector; + double _uRange[2]; + + //----------------------------------------------------------------------------- + CurveProjector( const TopoDS_Edge& e, const double tol ): + _curve( e ), _tol( tol ) + { + BRep_Tool::Range( e, _uRange[0], _uRange[1] ); + } + + //----------------------------------------------------------------------------- + // project a point to the curve + virtual gp_Pnt project( const gp_Pnt& P, + double* newSolution, + const double* prevSolution = 0) + { +#ifdef _DEBUG_ + std::cout << ".. project a point to the curve prevSolution = " << prevSolution << std::endl; +#endif + gp_Pnt proj; + Standard_Real param; + + if ( prevSolution ) + { + _dist = _projector.NextProject( prevSolution[0], _curve, P, _tol, proj, param ); + } + else + { + _dist = _projector.Project( _curve, P, _tol, proj, param, false ); + } +#ifdef _DEBUG_ + std::cout << ".. _dist : " << _dist << std::endl; +#endif + proj = _curve.Value( param ); + + newSolution[0] = param; + + return proj; + } + + //----------------------------------------------------------------------------- + // project a point to a curve and check if the projection is within the curve boundary + virtual bool projectAndClassify( const gp_Pnt& point, + const double maxDist2, + gp_Pnt& projection, + double* newSolution, + const double* prevSolution = 0) + { +#ifdef _DEBUG_ + std::cout << ".. project a point to a curve and check " << std::endl; +#endif + projection = project( point, newSolution, prevSolution ); + return ( _uRange[0] < newSolution[0] && newSolution[0] < _uRange[1] && + _dist * _dist < maxDist2 ); + } + + //----------------------------------------------------------------------------- + // return true if a previously found solution can be used to speed up the projection + virtual bool canUsePrevSolution() const { return true; } + }; + + //================================================================================ + /*! + * \brief Projector to a straight curve. Don't project, classify only + */ + //================================================================================ + + struct LineProjector : public FT_RealProjector + { + gp_Pnt _p0, _p1; + + //----------------------------------------------------------------------------- + LineProjector( TopoDS_Edge e ) + { + e.Orientation( TopAbs_FORWARD ); + _p0 = BRep_Tool::Pnt( TopExp::FirstVertex( e )); + _p1 = BRep_Tool::Pnt( TopExp::LastVertex ( e )); + } + + //----------------------------------------------------------------------------- + // does nothing + virtual gp_Pnt project( const gp_Pnt& P, + double* newSolution, + const double* prevSolution = 0) + { + return P; + } + //----------------------------------------------------------------------------- + // check if a point lies within the line segment + virtual bool projectAndClassify( const gp_Pnt& point, + const double maxDist2, + gp_Pnt& projection, + double* newSolution, + const double* prevSolution = 0) + { + gp_Vec edge( _p0, _p1 ); + gp_Vec p0p ( _p0, point ); + double u = ( edge * p0p ) / edge.SquareMagnitude(); // param [0,1] on the edge + projection = ( 1. - u ) * _p0.XYZ() + u * _p1.XYZ(); // projection of the point on the edge + if ( u < 0 || 1 < u ) + return false; + + // check distance + return point.SquareDistance( projection ) < theEPS * theEPS; + } + }; + + //================================================================================ + /*! + * \brief Projector to a circular edge + */ + //================================================================================ + + struct CircleProjector : public FT_RealProjector + { + gp_Circ _circle; + double _uRange[2]; + + //----------------------------------------------------------------------------- + CircleProjector( const gp_Circ& c, const double f, const double l ): + _circle( c ) + { + _uRange[0] = f; + _uRange[1] = l; + } + + //----------------------------------------------------------------------------- + // project a point to the circle + virtual gp_Pnt project( const gp_Pnt& P, + double* newSolution, + const double* prevSolution = 0) + { + // assume that P is already on the the plane of circle, since + // it is in the middle of two points lying on the circle + + // move P to the circle + const gp_Pnt& O = _circle.Location(); + gp_Vec radiusVec( O, P ); + double radius = radiusVec.Magnitude(); + if ( radius < std::numeric_limits::min() ) + return P; // P in on the axe + + gp_Pnt proj = O.Translated( radiusVec.Multiplied( _circle.Radius() / radius )); + + _dist = _circle.Radius() - radius; + + return proj; + } + + //----------------------------------------------------------------------------- + // project and check if a projection lies within the circular edge + virtual bool projectAndClassify( const gp_Pnt& point, + const double maxDist2, + gp_Pnt& projection, + double* newSolution, + const double* prevSolution = 0) + { + _dist = -1; + projection = project( point, newSolution ); + if ( _dist < 0 || // ? + _dist * _dist > maxDist2 ) + return false; + + newSolution[0] = ElCLib::Parameter( _circle, projection ); + return ( _uRange[0] < newSolution[0] && newSolution[0] < _uRange[1] ); + } + }; + + //================================================================================ + /*! + * \brief Projector to any surface + */ + //================================================================================ + + struct SurfaceProjector : public FT_RealProjector + { + ShapeAnalysis_Surface _projector; + double _tol; + BRepTopAdaptor_FClass2d* _classifier; + + //----------------------------------------------------------------------------- + SurfaceProjector( const TopoDS_Face& face, const double tol, BRepTopAdaptor_FClass2d* cls ): + _projector( BRep_Tool::Surface( face )), + _tol( tol ), + _classifier( cls ) + { + } + //----------------------------------------------------------------------------- + // delete _classifier + ~SurfaceProjector() + { + delete _classifier; + } + + //----------------------------------------------------------------------------- + // project a point to a surface + virtual gp_Pnt project( const gp_Pnt& P, + double* newSolution, + const double* prevSolution = 0) + { + gp_Pnt2d uv; + + if ( prevSolution ) + { + gp_Pnt2d prevUV( prevSolution[0], prevSolution[1] ); + uv = _projector.NextValueOfUV( prevUV, P, _tol ); + } + else + { + uv = _projector.ValueOfUV( P, _tol ); + } + + uv.Coord( newSolution[0], newSolution[1] ); + + gp_Pnt proj = _projector.Value( uv ); + + _dist = _projector.Gap(); + + return proj; + } + + //----------------------------------------------------------------------------- + // project a point to a surface and check if the projection is within the surface boundary + virtual bool projectAndClassify( const gp_Pnt& point, + const double maxDist2, + gp_Pnt& projection, + double* newSolution, + const double* prevSolution = 0) + { + projection = project( point, newSolution, prevSolution ); + return ( _dist * _dist < maxDist2 ) && classify( newSolution ); + } + + //----------------------------------------------------------------------------- + // check if the projection is within the shape boundary + bool classify( const double* newSolution ) + { + TopAbs_State state = _classifier->Perform( gp_Pnt2d( newSolution[0], newSolution[1]) ); + return ( state != TopAbs_OUT ); + } + + //----------------------------------------------------------------------------- + // return true if a previously found solution can be used to speed up the projection + virtual bool canUsePrevSolution() const { return true; } + }; + + //================================================================================ + /*! + * \brief Projector to a plane. Don't project, classify only + */ + //================================================================================ + + struct PlaneProjector : public SurfaceProjector + { + gp_Pln _plane; + bool _isRealPlane; // false means that a surface is planar but parametrization is different + + //----------------------------------------------------------------------------- + PlaneProjector( const gp_Pln& pln, + const TopoDS_Face& face, + BRepTopAdaptor_FClass2d* cls, + bool isRealPlane=true): + SurfaceProjector( face, 0, cls ), + _plane( pln ), + _isRealPlane( isRealPlane ) + {} + + //----------------------------------------------------------------------------- + // does nothing + virtual gp_Pnt project( const gp_Pnt& P, + double* newSolution, + const double* prevSolution = 0) + { + return P; + } + //----------------------------------------------------------------------------- + // check if a point lies within the boundry of the planar face + virtual bool projectAndClassify( const gp_Pnt& point, + const double maxDist2, + gp_Pnt& projection, + double* newSolution, + const double* prevSolution = 0) + { + if ( _isRealPlane ) + { + ElSLib::PlaneParameters( _plane.Position(), point, newSolution[0], newSolution[1]); + projection = ElSLib::PlaneValue ( newSolution[0], newSolution[1], _plane.Position() ); + if ( projection.SquareDistance( point ) > theEPS * theEPS ) + return false; + + return SurfaceProjector::classify( newSolution ); + } + else + { + return SurfaceProjector::projectAndClassify( point, maxDist2, projection, + newSolution, prevSolution ); + } + } + //----------------------------------------------------------------------------- + // return true if a previously found solution can be used to speed up the projection + virtual bool canUsePrevSolution() const { return false; } + }; + + //================================================================================ + /*! + * \brief Projector to a cylinder + */ + //================================================================================ + + struct CylinderProjector : public SurfaceProjector + { + gp_Cylinder _cylinder; + + //----------------------------------------------------------------------------- + CylinderProjector( const gp_Cylinder& c, + const TopoDS_Face& face, + BRepTopAdaptor_FClass2d* cls ): + SurfaceProjector( face, 0, cls ), + _cylinder( c ) + {} + + //----------------------------------------------------------------------------- + // project a point to the cylinder + virtual gp_Pnt project( const gp_Pnt& P, + double* newSolution, + const double* prevSolution = 0) + { + // project the point P to the cylinder axis -> Pp + const gp_Pnt& O = _cylinder.Position().Location(); + const gp_Dir& axe = _cylinder.Position().Direction(); + gp_Vec trsl = gp_Vec( axe ).Multiplied( gp_Vec( O, P ).Dot( axe )); + gp_Pnt Pp = O.Translated( trsl ); + + // move Pp to the cylinder + gp_Vec radiusVec( Pp, P ); + double radius = radiusVec.Magnitude(); + if ( radius < std::numeric_limits::min() ) + return P; // P in on the axe + + gp_Pnt proj = Pp.Translated( radiusVec.Multiplied( _cylinder.Radius() / radius )); + + _dist = _cylinder.Radius() - radius; + + return proj; + } + //----------------------------------------------------------------------------- + // project a point to the cylinder and check if the projection is within the surface boundary + virtual bool projectAndClassify( const gp_Pnt& point, + const double maxDist2, + gp_Pnt& projection, + double* newSolution, + const double* prevSolution = 0) + { + ElSLib::CylinderParameters( _cylinder.Position(), _cylinder.Radius(), point, + newSolution[0], newSolution[1]); + projection = ElSLib::CylinderValue( newSolution[0], newSolution[1], + _cylinder.Position(), _cylinder.Radius() ); + + return ( _dist * _dist < maxDist2 ) && SurfaceProjector::classify( newSolution ); + } + //----------------------------------------------------------------------------- + // return true if a previously found solution can be used to speed up the projection + virtual bool canUsePrevSolution() const { return false; } + }; + + //================================================================================ + /*! + * \brief Projector to a cone + */ + //================================================================================ + + struct ConeProjector : public SurfaceProjector + { + gp_Cone _cone; + + //----------------------------------------------------------------------------- + ConeProjector( const gp_Cone& c, + const TopoDS_Face& face, + BRepTopAdaptor_FClass2d* cls ): + SurfaceProjector( face, 0, cls ), + _cone( c ) + {} + + //----------------------------------------------------------------------------- + // project a point to the cone + virtual gp_Pnt project( const gp_Pnt& point, + double* newSolution, + const double* prevSolution = 0) + { + ElSLib::ConeParameters( _cone.Position(), _cone.RefRadius(), _cone.SemiAngle(), + point, newSolution[0], newSolution[1]); + gp_Pnt proj = ElSLib::ConeValue( newSolution[0], newSolution[1], + _cone.Position(), _cone.RefRadius(), _cone.SemiAngle() ); + _dist = point.Distance( proj ); + + return proj; + } + + //----------------------------------------------------------------------------- + // project a point to the cone and check if the projection is within the surface boundary + virtual bool projectAndClassify( const gp_Pnt& point, + const double maxDist2, + gp_Pnt& projection, + double* newSolution, + const double* prevSolution = 0) + { + projection = project( point, newSolution, prevSolution ); + + return ( _dist * _dist < maxDist2 ) && SurfaceProjector::classify( newSolution ); + } + //----------------------------------------------------------------------------- + // return true if a previously found solution can be used to speed up the projection + virtual bool canUsePrevSolution() const { return false; } + }; + + //================================================================================ + /*! + * \brief Projector to a sphere + */ + //================================================================================ + + struct SphereProjector : public SurfaceProjector + { + gp_Sphere _sphere; + + //----------------------------------------------------------------------------- + SphereProjector( const gp_Sphere& s, + const TopoDS_Face& face, + BRepTopAdaptor_FClass2d* cls ): + SurfaceProjector( face, 0, cls ), + _sphere( s ) + {} + + //----------------------------------------------------------------------------- + // project a point to the sphere + virtual gp_Pnt project( const gp_Pnt& P, + double* newSolution, + const double* prevSolution = 0) + { + // move Pp to the Sphere + const gp_Pnt& O = _sphere.Location(); + gp_Vec radiusVec( O, P ); + double radius = radiusVec.Magnitude(); + if ( radius < std::numeric_limits::min() ) + return P; // P is on O + + gp_Pnt proj = O.Translated( radiusVec.Multiplied( _sphere.Radius() / radius )); + + _dist = _sphere.Radius() - radius; + + return proj; + } + + //----------------------------------------------------------------------------- + // project a point to the sphere and check if the projection is within the surface boundary + virtual bool projectAndClassify( const gp_Pnt& point, + const double maxDist2, + gp_Pnt& projection, + double* newSolution, + const double* prevSolution = 0) + { + ElSLib::SphereParameters( _sphere.Position(), _sphere.Radius(), point, + newSolution[0], newSolution[1]); + projection = ElSLib::SphereValue( newSolution[0], newSolution[1], + _sphere.Position(), _sphere.Radius() ); + + return ( _dist * _dist < maxDist2 ) && SurfaceProjector::classify( newSolution ); + } + //----------------------------------------------------------------------------- + // return true if a previously found solution can be used to speed up the projection + virtual bool canUsePrevSolution() const { return false; } + }; + + //================================================================================ + /*! + * \brief Projector to a torus + */ + //================================================================================ + + struct TorusProjector : public SurfaceProjector + { + gp_Torus _torus; + + //----------------------------------------------------------------------------- + TorusProjector( const gp_Torus& t, + const TopoDS_Face& face, + BRepTopAdaptor_FClass2d* cls ): + SurfaceProjector( face, 0, cls ), + _torus( t ) + {} + + //----------------------------------------------------------------------------- + // project a point to the torus + virtual gp_Pnt project( const gp_Pnt& point, + double* newSolution, + const double* prevSolution = 0) + { + ElSLib::TorusParameters( _torus.Position(), _torus.MajorRadius(), _torus.MinorRadius(), + point, newSolution[0], newSolution[1]); + gp_Pnt proj = ElSLib::TorusValue( newSolution[0], newSolution[1], + _torus.Position(), _torus.MajorRadius(), _torus.MinorRadius() ); + _dist = point.Distance( proj ); + + return proj; + } + + //----------------------------------------------------------------------------- + // project a point to the torus and check if the projection is within the surface boundary + virtual bool projectAndClassify( const gp_Pnt& point, + const double maxDist2, + gp_Pnt& projection, + double* newSolution, + const double* prevSolution = 0) + { + projection = project( point, newSolution, prevSolution ); + + return ( _dist * _dist < maxDist2 ) && SurfaceProjector::classify( newSolution ); + } + //----------------------------------------------------------------------------- + // return true if a previously found solution can be used to speed up the projection + virtual bool canUsePrevSolution() const { return false; } + }; + + //================================================================================ + /*! + * \brief Check if a curve can be considered straight + */ + //================================================================================ + + bool isStraight( const GeomAdaptor_Curve& curve, const double tol ) + { + // rough check: evaluate how far from a straight line connecting the curve ends + // stand several internal points of the curve + + const double f = curve.FirstParameter(); + const double l = curve.LastParameter(); + const gp_Pnt pf = curve.Value( f ); + const gp_Pnt pl = curve.Value( l ); + const gp_Vec lineVec( pf, pl ); + const double lineLen2 = lineVec.SquareMagnitude(); + if ( lineLen2 < std::numeric_limits< double >::min() ) + return false; // E seems closed + + const double nbSamples = 7; + for ( int i = 0; i < nbSamples; ++i ) + { + const double r = ( i + 1 ) / nbSamples; + const gp_Pnt pi = curve.Value( f * r + l * ( 1 - r )); + const gp_Vec vi( pf, pi ); + const double h2 = lineVec.Crossed( vi ).SquareMagnitude() / lineLen2; + if ( h2 > tol * tol ) + return false; + } + + // thorough check + GCPnts_UniformDeflection divider( curve, tol ); + return ( divider.IsDone() && divider.NbPoints() < 3 ); + } +} + +//================================================================================ +/*! + * \brief Initialize with a boundary shape + */ +//================================================================================ + +FT_Projector::FT_Projector(const TopoDS_Shape& shape) +{ + _realProjector = 0; + setBoundaryShape( shape ); + _tryWOPrevSolution = false; +} + +//================================================================================ +/*! + * \brief Copy another projector + */ +//================================================================================ + +FT_Projector::FT_Projector(const FT_Projector& other) +{ + _realProjector = 0; + _shape = other._shape; + _bndBox = other._bndBox; + _tryWOPrevSolution = false; +} + +//================================================================================ +/*! + * \brief Destructor. Delete _realProjector + */ +//================================================================================ + +FT_Projector::~FT_Projector() +{ + delete _realProjector; +} + +//================================================================================ +/*! + * \brief Initialize with a boundary shape. Compute the bounding box + */ +//================================================================================ + +void FT_Projector::setBoundaryShape(const TopoDS_Shape& shape) +{ + delete _realProjector; _realProjector = 0; + _shape = shape; + if ( shape.IsNull() ) + return; + + BRepBndLib::Add( shape, _bndBox ); + _bndBox.Enlarge( 1e-5 * sqrt( _bndBox.SquareExtent() )); +} + +//================================================================================ +/*! + * \brief Create a real projector + */ +//================================================================================ + +void FT_Projector::prepareForProjection() +{ + if ( _shape.IsNull() || _realProjector ) + return; + + if ( _shape.ShapeType() == TopAbs_EDGE ) + { + const TopoDS_Edge& edge = TopoDS::Edge( _shape ); + + double tol = 1e-6 * sqrt( _bndBox.SquareExtent() ); + + double f,l; + Handle(Geom_Curve) curve = BRep_Tool::Curve( edge, f,l ); + if ( curve.IsNull() ) + return; // degenerated edge + + GeomAdaptor_Curve acurve( curve, f, l ); + switch ( acurve.GetType() ) + { + case GeomAbs_Line: + _realProjector = new LineProjector( edge ); + break; + case GeomAbs_Circle: + _realProjector = new CircleProjector( acurve.Circle(), f, l ); + break; + case GeomAbs_BezierCurve: + case GeomAbs_BSplineCurve: + case GeomAbs_OffsetCurve: + case GeomAbs_OtherCurve: + if ( isStraight( acurve, tol )) + { + _realProjector = new LineProjector( edge ); + break; + } + case GeomAbs_Ellipse: + case GeomAbs_Hyperbola: + case GeomAbs_Parabola: + _realProjector = new CurveProjector( edge, tol ); + } + } + else if ( _shape.ShapeType() == TopAbs_FACE ) + { + TopoDS_Face face = TopoDS::Face( _shape ); + + Handle(Geom_Surface) surface = BRep_Tool::Surface( face ); + if ( surface.IsNull() ) + return; + + GeomAdaptor_Surface asurface( surface ); + Standard_Real tol = BRep_Tool::Tolerance( face ); + Standard_Real toluv = Min( asurface.UResolution( tol ), asurface.VResolution( tol )); + BRepTopAdaptor_FClass2d* classifier = new BRepTopAdaptor_FClass2d( face, toluv ); + + switch ( asurface.GetType() ) + { + case GeomAbs_Plane: + _realProjector = new PlaneProjector( asurface.Plane(), face, classifier ); + break; + case GeomAbs_Cylinder: + _realProjector = new CylinderProjector( asurface.Cylinder(), face, classifier ); + break; + case GeomAbs_Sphere: + _realProjector = new SphereProjector( asurface.Sphere(), face, classifier ); + break; + case GeomAbs_Cone: + _realProjector = new ConeProjector( asurface.Cone(), face, classifier ); + break; + case GeomAbs_Torus: + _realProjector = new TorusProjector( asurface.Torus(), face, classifier ); + break; + case GeomAbs_BezierSurface: + case GeomAbs_BSplineSurface: + case GeomAbs_SurfaceOfRevolution: + case GeomAbs_SurfaceOfExtrusion: + case GeomAbs_OffsetSurface: + case GeomAbs_OtherSurface: + GeomLib_IsPlanarSurface isPlaneCheck( surface, tol ); + if ( isPlaneCheck.IsPlanar() ) + { + _realProjector = new PlaneProjector( isPlaneCheck.Plan(), face, classifier, + /*isRealPlane=*/false); + } + else + { + _realProjector = new SurfaceProjector( face, tol, classifier ); + } + break; + } + + if ( !_realProjector ) + delete classifier; + } +} + +//================================================================================ +/*! + * \brief Return true if projection is not needed + */ +//================================================================================ + +bool FT_Projector::isPlanarBoundary() const +{ + return ( dynamic_cast< LineProjector* >( _realProjector ) || + dynamic_cast< PlaneProjector* >( _realProjector ) ); +} + +//================================================================================ +/*! + * \brief Check if a point lies on the boundary shape + * \param [in] point - the point to check + * \param [in] tol2 - a square tolerance allowing to decide whether a point is on the shape + * \param [in] newSolution - position on the shape (U or UV) of the point found + * during projecting + * \param [in] prevSolution - position on the shape (U or UV) of a neighbor point + * \return bool - \c true if the point lies on the boundary shape + * + * This method is used to select a shape by checking if all neighbor nodes of a node to move + * lie on a shape. + */ +//================================================================================ + +bool FT_Projector::isOnShape( const gp_Pnt& point, + const double tol2, + double* newSolution, + const double* prevSolution) +{ + if ( _bndBox.IsOut( point ) || !_realProjector ) + return false; + + gp_Pnt proj; + if ( isPlanarBoundary() ) + return projectAndClassify( point, tol2, proj, newSolution, prevSolution ); + + return project( point, tol2, proj, newSolution, prevSolution ); +} + +//================================================================================ +/*! + * \brief Project a point to the boundary shape + * \param [in] point - the point to project + * \param [in] maxDist2 - the maximal square distance between the point and the projection + * \param [out] projection - the projection + * \param [out] newSolution - position on the shape (U or UV) of the point found + * during projecting + * \param [in] prevSolution - already found position on the shape (U or UV) of a neighbor point + * \return bool - false if the distance between the point and the projection + * is more than sqrt(maxDist2) + * + * This method is used to project a node in the case where only one shape is found by name + */ +//================================================================================ + +bool FT_Projector::project( const gp_Pnt& point, + const double maxDist2, + gp_Pnt& projection, + double* newSolution, + const double* prevSolution) +{ + if ( !_realProjector ) + return false; + + _realProjector->_dist = 1e100; + projection = _realProjector->project( point, newSolution, prevSolution ); + + bool ok = ( _realProjector->_dist * _realProjector->_dist < maxDist2 ); + if ( !ok && _tryWOPrevSolution && prevSolution ) + { + projection = _realProjector->project( point, newSolution ); + ok = ( _realProjector->_dist * _realProjector->_dist < maxDist2 ); + } + return ok; +} + +//================================================================================ +/*! + * \brief Project a point to the boundary shape and check if the projection lies within + * the shape boundary + * \param [in] point - the point to project + * \param [in] maxDist2 - the maximal square distance between the point and the projection + * \param [out] projection - the projection + * \param [out] newSolution - position on the shape (U or UV) of the point found + * during projecting + * \param [in] prevSolution - already found position on the shape (U or UV) of a neighbor point + * \return bool - false if the projection point lies out of the shape boundary or + * the distance between the point and the projection is more than sqrt(maxDist2) + * + * This method is used to project a node in the case where several shapes are selected for + * projection of a node group + */ +//================================================================================ + +bool FT_Projector::projectAndClassify( const gp_Pnt& point, + const double maxDist2, + gp_Pnt& projection, + double* newSolution, + const double* prevSolution) +{ + if ( _bndBox.IsOut( point ) || !_realProjector ) + return false; + + bool ok = _realProjector->projectAndClassify( point, maxDist2, projection, + newSolution, prevSolution ); + if ( !ok && _tryWOPrevSolution && prevSolution ) + ok = _realProjector->projectAndClassify( point, maxDist2, projection, newSolution ); + + return ok; +} + +//================================================================================ +/*! + * \brief Return true if a previously found solution can be used to speed up the projection + */ +//================================================================================ + +bool FT_Projector::canUsePrevSolution() const +{ + return ( _realProjector && _realProjector->canUsePrevSolution() ); +} diff --git a/src/ADAPTFrontTrack/FrontTrack_Projector.hxx b/src/ADAPTFrontTrack/FrontTrack_Projector.hxx new file mode 100644 index 000000000..82578e252 --- /dev/null +++ b/src/ADAPTFrontTrack/FrontTrack_Projector.hxx @@ -0,0 +1,95 @@ +// Copyright (C) 2017-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : FrontTrack_Projector.hxx +// Created : Wed Apr 26 20:12:13 2017 +// Author : Edward AGAPOV (eap) + +#ifndef __FrontTrack_Projector_HXX__ +#define __FrontTrack_Projector_HXX__ + +#include +#include + +struct FT_RealProjector; + +/*! + * \brief Projector of a point to a boundary shape. Wrapper of a real projection algo + */ +class FT_Projector +{ +public: + + FT_Projector(const TopoDS_Shape& shape = TopoDS_Shape()); + FT_Projector(const FT_Projector& other); + ~FT_Projector(); + + // initialize with a boundary shape, compute the bounding box + void setBoundaryShape(const TopoDS_Shape& shape); + + // return the boundary shape + const TopoDS_Shape& getShape() const { return _shape; } + + // return the bounding box + const Bnd_Box getBoundingBox() const { return _bndBox; } + + + // create a real projector + void prepareForProjection(); + + // return true if a previously found solution can be used to speed up the projection + bool canUsePrevSolution() const; + + // return true if projection is not needed + bool isPlanarBoundary() const; + + + // switch a mode of usage of prevSolution. + // If projection fails, to try to project without usage of prevSolution. + // By default this mode is off + void tryWithoutPrevSolution( bool toTry ) { _tryWOPrevSolution = toTry; } + + // project a point to the boundary shape + bool project( const gp_Pnt& point, + const double maxDist2, + gp_Pnt& projection, + double* newSolution, + const double* prevSolution = 0); + + // project a point to the boundary shape and check if the projection is within the shape boundary + bool projectAndClassify( const gp_Pnt& point, + const double maxDist2, + gp_Pnt& projection, + double* newSolution, + const double* prevSolution = 0); + + // check if a point lies on the boundary shape + bool isOnShape( const gp_Pnt& point, + const double tol2, + double* newSolution, + const double* prevSolution = 0); + +private: + + FT_RealProjector* _realProjector; + Bnd_Box _bndBox; + TopoDS_Shape _shape; + bool _tryWOPrevSolution; +}; + +#endif diff --git a/src/ADAPTFrontTrack/FrontTrack_Utils.cxx b/src/ADAPTFrontTrack/FrontTrack_Utils.cxx new file mode 100644 index 000000000..e74072ac0 --- /dev/null +++ b/src/ADAPTFrontTrack/FrontTrack_Utils.cxx @@ -0,0 +1,164 @@ +// Copyright (C) 2017-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : FrontTrack_Utils.cxx +// Created : Tue Apr 25 17:28:58 2017 +// Author : Edward AGAPOV (eap) + +#include "FrontTrack_Utils.hxx" + +#include +#include + +#include +#include + +namespace boofs = boost::filesystem; + +//================================================================================ +/* + * \brief Check if a file exists + */ +//================================================================================ + +bool FT_Utils::fileExists( const std::string& path ) +{ + if ( path.empty() ) + return false; + + boost::system::error_code err; + bool res = boofs::exists( path, err ); + + return err ? false : res; +} + +//================================================================================ +/*! + * \brief Check if a file can be created/overwritten + */ +//================================================================================ + +bool FT_Utils::canWrite( const std::string& path ) +{ + if ( path.empty() ) + return false; + + bool can = false; +#ifdef WIN32 + + HANDLE file = CreateFile( path.c_str(), // name of the write + GENERIC_WRITE, // open for writing + 0, // do not share + NULL, // default security + OPEN_ALWAYS, // CREATE NEW or OPEN EXISTING + FILE_ATTRIBUTE_NORMAL, // normal file + NULL); // no attr. template + can = ( file != INVALID_HANDLE_VALUE ); + CloseHandle( file ); + +#else + + int file = ::open( path.c_str(), + O_WRONLY | O_CREAT, + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ); // rw-r--r-- + can = ( file >= 0 ); + +#endif + + return can; +} + +//================================================================================ +/*! + * \brief Make a map of XAO groups + */ +//================================================================================ + +FT_Utils::XaoGroups::XaoGroups( const XAO::Xao* theXao ) +{ + XAO::Xao* xao = const_cast< XAO::Xao* >( theXao ); + + for ( int iG = 0; iG < theXao->countGroups(); ++iG ) + { + XAO::Group* group = xao->getGroup( iG ); + + if ( group->getDimension() == 1 ) + + _xaoGroups[ 0 ].insert( std::make_pair( group->getName(), group )); + + else if ( group->getDimension() == 2 ) + + _xaoGroups[ 1 ].insert( std::make_pair( group->getName(), group )); + } +} + +//================================================================================ +/*! + * \brief Return FT_Projector's by a group name + * \param [in] groupName - the group name + * \param [in] dim - the group dimension + * \param [in] allProjectors - the projector of all shapes of \a dim dimension + * \param [out] groupProjectors - projectors to shapes of the group + * \return int - number of found shapes + */ +//================================================================================ + +int FT_Utils::XaoGroups::getProjectors( const std::string& groupName, + const int dim, + const std::vector< FT_Projector > & allProjectors, + std::vector< const FT_Projector* > & groupProjectors) const +{ + // get namesake groups + + const TGroupByNameMap* groupMap = 0; + if ( dim == 1 ) + groupMap = &_xaoGroups[ 0 ]; + else if ( dim == 2 ) + groupMap = &_xaoGroups[ 1 ]; + else + return 0; + + TGroupByNameMap::const_iterator name2gr = groupMap->find( groupName ); + if ( name2gr == groupMap->end() ) + return 0; + + std::vector< XAO::Group* > groups; + groups.push_back( name2gr->second ); + + for ( ++name2gr; name2gr != groupMap->end(); ++name2gr ) + { + if ( name2gr->second->getName() == groupName ) + groups.push_back( name2gr->second ); + else + break; + } + + // get projectors + + int nbFound = 0; + for ( size_t i = 0; i < groups.size(); ++i ) + { + // IDs in XAO correspond to indices of allProjectors + std::set::iterator id = groups[i]->begin(), end = groups[i]->end(); + for ( ; id != end; ++id, ++nbFound ) + if ( *id < (int) allProjectors.size() ) + groupProjectors.push_back ( & allProjectors[ *id ]); + } + + return nbFound; +} diff --git a/src/ADAPTFrontTrack/FrontTrack_Utils.hxx b/src/ADAPTFrontTrack/FrontTrack_Utils.hxx new file mode 100644 index 000000000..38817cb59 --- /dev/null +++ b/src/ADAPTFrontTrack/FrontTrack_Utils.hxx @@ -0,0 +1,72 @@ +// Copyright (C) 2017-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : FrontTrack_Utils.hxx +// Created : Tue Apr 25 17:23:33 2017 +// Author : Edward AGAPOV (eap) + +#ifndef __FrontTrack_Utils_HXX__ +#define __FrontTrack_Utils_HXX__ + +#include "FrontTrack_Projector.hxx" + +#include +#include +#include + +namespace XAO { + class Xao; + class Group; +} + +namespace FT_Utils +{ + // Check if a file exists + bool fileExists( const std::string& path ); + + // Check if a file can be created/overwritten + bool canWrite( const std::string& path ); + + // Transform anything printable to a string + template< typename T> std::string toStr( const T& t ) + { + std::ostringstream s; + s << t; + return s.str(); + } + + //-------------------------------------------------------------------------------------------- + /*! + * \brief Return projectors by group name + */ + struct XaoGroups + { + XaoGroups( const XAO::Xao* xao ); + + int getProjectors( const std::string& groupName, + const int dim, + const std::vector< FT_Projector > & allProjectors, + std::vector< const FT_Projector* > & groupProjectors ) const; + private: + + typedef std::multimap< std::string, XAO::Group* > TGroupByNameMap; + TGroupByNameMap _xaoGroups[ 2 ]; // by dim + }; +} + +#endif diff --git a/src/ADAPTFrontTrack_SWIG/CMakeLists.txt b/src/ADAPTFrontTrack_SWIG/CMakeLists.txt new file mode 100644 index 000000000..5b9a4a901 --- /dev/null +++ b/src/ADAPTFrontTrack_SWIG/CMakeLists.txt @@ -0,0 +1,83 @@ +# Copyright (C) 2017-2020 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +INCLUDE(${SWIG_USE_FILE}) + +# --- options --- +# additional include directories +INCLUDE_DIRECTORIES( + ${PYTHON_INCLUDE_DIRS} + ${PTHREAD_INCLUDE_DIR} # pthread dependancy due to python2.7 library + ${CMAKE_CURRENT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR}/src/ADAPTFrontTrack +) + +# additional preprocessor / compiler flags +ADD_DEFINITIONS( + ${PYTHON_DEFINITIONS} +) + +# libraries to link to +SET(_link_LIBRARIES + ${PYTHON_LIBRARIES} + ${PLATFORM_LIBS} + ADAPTFrontTrack +) + +# --- headers --- + +# header files / to be processed by moc +SET(ADAPTFrontTrack_Swig_HEADERS + FrontTrack.i +) + +# --- sources --- + +# sources / static +SET(ADAPTFrontTrack_Swig_SOURCES + ${ADAPTFrontTrack_Swig_HEADERS} +) + +# swig flags +SET_SOURCE_FILES_PROPERTIES(FrontTrack.i PROPERTIES CPLUSPLUS ON) +SET_SOURCE_FILES_PROPERTIES(FrontTrack.i PROPERTIES SWIG_DEFINITIONS "-shadow") + +# --- scripts --- + +# scripts / swig wrappings +SET(_swig_SCRIPTS + ${CMAKE_CURRENT_BINARY_DIR}/FrontTrack.py +) + +# --- rules --- +IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") + SWIG_ADD_MODULE(FrontTrack_Swig python ${ADAPTFrontTrack_Swig_SOURCES}) +ELSE() + SWIG_ADD_LIBRARY(FrontTrack_Swig LANGUAGE python SOURCES ${ADAPTFrontTrack_Swig_SOURCES}) +ENDIF() + +SWIG_LINK_LIBRARIES(FrontTrack_Swig ${_link_LIBRARIES}) +SWIG_CHECK_GENERATION(FrontTrack_Swig) +IF(WIN32) + SET_TARGET_PROPERTIES(_FrontTrack_Swig PROPERTIES DEBUG_OUTPUT_NAME _FrontTrack_Swig_d) +ENDIF(WIN32) + +INSTALL(TARGETS ${SWIG_MODULE_FrontTrack_Swig_REAL_NAME} DESTINATION ${SALOME_INSTALL_PYTHON}) + +SALOME_INSTALL_SCRIPTS("${_swig_SCRIPTS}" ${SALOME_INSTALL_PYTHON} EXTRA_DPYS "${SWIG_MODULE_FrontTrack_Swig_REAL_NAME}") diff --git a/src/ADAPTFrontTrack_SWIG/FrontTrack.i b/src/ADAPTFrontTrack_SWIG/FrontTrack.i new file mode 100644 index 000000000..50c6c2066 --- /dev/null +++ b/src/ADAPTFrontTrack_SWIG/FrontTrack.i @@ -0,0 +1,67 @@ +// Copyright (C) 2017-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : FrontTrack.i +// Created : Fri Apr 28 17:36:20 2017 +// Author : Edward AGAPOV (eap) + +%module FrontTrack + +%{ +#include "FrontTrack.hxx" +#include +#include +#include + +static PyObject* setOCCException(Standard_Failure& ex) +{ + std::string msg(ex.DynamicType()->Name()); + if ( ex.GetMessageString() && strlen( ex.GetMessageString() )) { + msg += ": "; + msg += ex.GetMessageString(); + } + PyErr_SetString(PyExc_Exception, msg.c_str() ); + return NULL; +} + +%} + + +%exception +{ + try { + OCC_CATCH_SIGNALS; + $action } + catch (Standard_Failure& ex) { + return setOCCException(ex); + } + catch (std::exception& ex) { + PyErr_SetString(PyExc_Exception, ex.what() ); + return NULL; + } +} + +%include +%include + +%template(svec) std::vector; + +//%feature("autodoc", "1"); +//%feature("docstring"); + +%include "FrontTrack.hxx" diff --git a/src/ADAPTGUI/ADAPT_msg_en.ts b/src/ADAPTGUI/ADAPT_msg_en.ts new file mode 100644 index 000000000..1567033d6 --- /dev/null +++ b/src/ADAPTGUI/ADAPT_msg_en.ts @@ -0,0 +1,415 @@ + + + + + @default + + HOM_MEN_HOMARD + HOMARD + + + HOM_MEN_MODIFICATION + Modification + + + HOM_MEN_INFORMATION + Information + + + HOM_MEN_YACS + YACS + + + HOM_MEN_NEW_CASE + New case + + + HOM_MEN_NEW_ITERATION + Next iteration + + + HOM_MEN_PURSUE_ITERATION + Case: pursuit of a stored iteration + + + HOM_MEN_COMPUTE + Compute + + + HOM_MEN_COMPUTE_PUBLISH + Compute and publish + + + HOM_MEN_EDIT + Edit + + + HOM_MEN_DELETE + Delete + + + HOM_MEN_MESH_INFO + Mesh analysis + + + HOM_MEN_MESH_PUBLICATION + Mesh publication + + + HOM_MEN_EDIT_MESS_FILE + Show the file + + + HOM_MEN_WRITE + Write + + + HOM_TOP_HOMARD + HOMARD + + + HOM_TOP_NEW_CASE + New case + + + HOM_TOP_NEW_ITERATION + Next iteration + + + HOM_TOP_PURSUE_ITERATION + Case: pursuit of a stored iteration + + + HOM_TOP_COMPUTE + Compute + + + HOM_TOP_COMPUTE_PUBLISH + Compute and publish + + + HOM_TOP_EDIT + Edit + + + HOM_TOP_DELETE + Delete + + + HOM_TOP_EDIT_MESS_FILE + Show the file + + + HOM_STB_HOMARD + HOMARD + + + HOM_STB_NEW_CASE + New case + + + HOM_STB_NEW_ITERATION + Next iteration + + + HOM_STB_PURSUE_ITERATION + Case: pursuit of a stored iteration + + + HOM_STB_COMPUTE + Compute + + + HOM_STB_COMPUTE_PUBLISH + Compute and publish + + + HOM_STB_EDIT + Edit + + + HOM_STB_DELETE + Delete + + + HOM_STB_EDIT_MESS_FILE + Show the file + + + HOM_WARNING + Warning + + + HOM_ERROR + Error + + + HOM_INACTIVE_BUTTON + Inactive button + + + HOM_SELECT_OBJECT_1 + Select an object. + + + HOM_SELECT_OBJECT_2 + Select only one object. + + + HOM_SELECT_OBJECT_3 + Select an object with type %1. + + + HOM_SELECT_OBJECT_4 + The name of the object is already selected. Modify it or cancel. + + + HOM_SELECT_FILE_0 + File selection + + + HOM_SELECT_FILE_1 + Select a file. + + + HOM_SELECT_FILE_2 + Select only one file. + + + HOM_SELECT_FILE_3 + This file cannot be opened. + + + HOM_SCRIPT_FILE + A script file must be given. + + + HOM_MED_FILE_1 + This MED file cannot be read. + + + HOM_MED_FILE_2 + No mesh in this MED file. + + + HOM_MED_FILE_3 + More than one mesh in this MED file. + + + HOM_MED_FILE_4 + The mesh in this MED file cannot be read. + + + HOM_MED_FILE_5 + No field in this MED file. + + + HOM_MED_FILE_6 + The field(s) in this MED file cannot be read. + + + HOM_SELECT_STUDY + Select a study object with associated MED file \n or select a MED file. + + + HOM_CASE_NAME + The case must be named. + + + HOM_CASE_DIRECTORY_1 + A directory for the case must be selected. + + + HOM_CASE_DIRECTORY_2 + This directory is already used by the case + + + HOM_CASE_DIRECTORY_3 + A valid directory for the case must be selected. + + + HOM_CASE_DIRECTORY_4 + A directory for the computation must be selected. + + + HOM_START_DIRECTORY_1 + A starting directory for the pursuit must be selected. + + + HOM_START_DIRECTORY_3 + A valid directory for the pursuit must be selected. + + + HOM_CASE_MESH + The file of the initial mesh must be selected. + + + HOM_CASE_GROUP + The group "%1" cannot be given for more than 1 boundary. + + + HOM_CASE_EDIT_WINDOW_TITLE + Edition of a case + + + HOM_CASE_EDIT_STATE_0 + Initial mesh. + + + HOM_CASE_EDIT_STATE + Pursuit of an iteration. + + + HOM_CASE_PURSUE_WINDOW_TITLE + Case: pursuit of a stored iteration + + + HOM_ITER_NAME + The iteration must be named. + + + HOM_ITER_STARTING_POINT + The previous iteration must be given. + + + HOM_ITER_MESH + Give a name for the final mesh. + + + HOM_ITER_HYPO + A hypothesis must be selected. + + + HOM_ITER_FIELD_FILE + With this hypothesis, a file for the field must be given. + + + HOM_ITER_STARTING_POINT_0 + Mesh + + + HOM_ITER_STARTING_POINT_1 + First iteration of the case. + + + HOM_ITER_STARTING_POINT_2 + First iteration of the case for the pursuit. + + + HOM_ITER_EDIT_WINDOW_TITLE + Edition of an iteration + + + HOM_HYPO_NAME + The hypothesis must be named. + + + HOM_HYPO_FIELD_FILE + A file for the field must be given. + + + HOM_HYPO_ZONE_1 + A zone must be selected. + + + HOM_HYPO_ZONE_2 + At least, one zone must be selected. + + + HOM_HYPO_ZONE_3 + Either refinement or coarsening, but not both. + + + HOM_HYPO_NORM_L2 + L2 norm + + + HOM_HYPO_NORM_INF + Infinite norm + + + HOM_HYPO_NORM_ABS + Absolute + + + HOM_HYPO_NORM_REL + Relative + + + HOM_HYPO_COMP + At least, one component must be selected. + + + HOM_HYPO_EDIT_WINDOW_TITLE + Edition of a hypothesis + + + HOM_ZONE_NAME + The zone must be named. + + + HOM_ZONE_LIMIT + %1 maxi must be greater than %1 mini. + + + HOM_ZONE_RAYON + The external radius must be greater than the internal radius. + + + HOM_ZONE_EDIT_WINDOW_TITLE + Edition of a zone + + + HOM_BOUN_NAME + The boundary must be named. + + + HOM_BOUN_MESH + The file for the mesh of the boundary must be selected. + + + HOM_BOUN_CAO + The file for the CAO must be selected. + + + HOM_BOUN_CASE + The meshfile of the case is unknown. + + + HOM_AXE + The axis must be a non 0 vector. + + + HOM_BOUN_C_EDIT_WINDOW_TITLE + Edition of a CAO based boundary + + + HOM_BOUN_A_EDIT_WINDOW_TITLE + Edition of an analytical boundary + + + HOM_BOUN_D_EDIT_WINDOW_TITLE + Edition of a discrete boundary + + + HOM_GROU_EDIT_WINDOW_TITLE + Selected groups + + + HOM_MESH_INFO_0 + Mesh analysis + + + HOM_MESH_INFO_1 + Select at least one option. + + + HOM_MESH_INFO_2 + Analysis in the object browser, file + + + HOM_YACS_EDIT_WINDOW_TITLE + Edition of a schema YACS + + + diff --git a/src/ADAPTGUI/ADAPT_msg_fr.ts b/src/ADAPTGUI/ADAPT_msg_fr.ts new file mode 100644 index 000000000..f36da7b24 --- /dev/null +++ b/src/ADAPTGUI/ADAPT_msg_fr.ts @@ -0,0 +1,1127 @@ + + + + + @default + + HOM_MEN_HOMARD + HOMARD + + + HOM_MEN_MODIFICATION + Modification + + + HOM_MEN_INFORMATION + Information + + + HOM_MEN_YACS + YACS + + + HOM_MEN_NEW_CASE + Nouveau cas + + + HOM_MEN_NEW_ITERATION + Itération suivante + + + HOM_MEN_PURSUE_ITERATION + Cas de poursuite d'une itération + + + HOM_MEN_COMPUTE + Calculer + + + HOM_MEN_COMPUTE_PUBLISH + Calculer et publier + + + HOM_MEN_EDIT + Editer + + + HOM_MEN_DELETE + Supprimer + + + HOM_MEN_MESH_INFO + Analyse de maillage + + + HOM_MEN_MESH_PUBLICATION + Publication du maillage + + + HOM_MEN_EDIT_MESS_FILE + Afficher le fichier + + + HOM_MEN_WRITE + Ecrire + + + HOM_TOP_HOMARD + HOMARD + + + HOM_TOP_NEW_CASE + Nouveau cas + + + HOM_TOP_NEW_ITERATION + Itération suivante + + + HOM_TOP_PURSUE_ITERATION + Cas de poursuite d'une itération + + + HOM_TOP_COMPUTE + Calculer + + + HOM_TOP_COMPUTE_PUBLISH + Calculer et publier + + + HOM_TOP_EDIT + Editer + + + HOM_TOP_DELETE + Supprimer + + + HOM_TOP_EDIT_MESS_FILE + Afficher le fichier + + + HOM_STB_HOMARD + HOMARD + + + HOM_STB_NEW_CASE + Nouveau cas + + + HOM_STB_NEW_ITERATION + Itération suivante + + + HOM_STB_PURSUE_ITERATION + Cas de poursuite d'une itération + + + HOM_STB_COMPUTE + Calculer + + + HOM_STB_COMPUTE_PUBLISH + Calculer et publier + + + HOM_STB_EDIT + Editer + + + HOM_STB_DELETE + Supprimer + + + HOM_STB_EDIT_MESS_FILE + Afficher le fichier + + + HOM_WARNING + Avertissement + + + HOM_ERROR + Erreur + + + HOM_INACTIVE_BUTTON + Bouton inactif + + + OK + Appliquer et fermer + + + Apply + Appliquer + + + Cancel + Annuler + + + Help + Aide + + + New + Nouveau + + + Edit + Editer + + + Quit + Quitter + + + Name + Nom + + + Directory + Répertoire + + + Mesh + Maillage + + + Selection + Sélection + + + None + Aucun + + + All + Tout + + + HOM_SELECT_OBJECT_1 + Sélectionner un objet. + + + HOM_SELECT_OBJECT_2 + Sélectionner un seul objet. + + + HOM_SELECT_OBJECT_3 + Sélectionner un objet de type %1. + + + HOM_SELECT_OBJECT_4 + Le nom est déjà choisi. Modifiez le ou annulez la saisie. + + + HOM_SELECT_FILE_0 + Choix de fichier + + + HOM_SELECT_FILE_1 + Sélectionner un fichier. + + + HOM_SELECT_FILE_2 + Sélectionner un seul fichier. + + + HOM_SELECT_FILE_3 + Impossible d'ouvrir ce fichier. + + + HOM_SCRIPT_FILE + Il faut donner un fichier pour le script python. + + + HOM_MED_FILE_1 + Ce fichier MED est illisible. + + + HOM_MED_FILE_2 + Ce fichier MED ne contient aucun maillage. + + + HOM_MED_FILE_3 + Ce fichier MED contient plus d'un maillage. + + + HOM_MED_FILE_4 + Impossible de lire le maillage de ce fichier MED. + + + HOM_MED_FILE_5 + Ce fichier MED ne contient aucun champ. + + + HOM_MED_FILE_6 + Impossible de lire le(s) champ(s) de ce fichier MED. + + + HOM_SELECT_STUDY + Sélectionner une étude avec un fichier MED associé\n ou sélectionner un fichier MED. + + + Create a case + Création d'un cas + + + HOM_CASE_NAME + Il faut donner un nom au cas. + + + HOM_CASE_DIRECTORY_1 + Il faut choisir un répertoire de travail pour le cas. + + + HOM_CASE_DIRECTORY_2 + Ce répertoire est déjà utilisé par le cas + + + HOM_CASE_DIRECTORY_3 + Un répertoire valide doit être choisi. + + + HOM_CASE_DIRECTORY_4 + Il faut choisir un répertoire de travail pour le calcul. + + + HOM_START_DIRECTORY_1 + Il faut choisir un répertoire contenant l'itération à poursuivre. + + + HOM_START_DIRECTORY_3 + Un répertoire valide contenant l'itération à poursuivre doit être choisi. + + + HOM_CASE_MESH + Il faut choisir le maillage initial. + + + HOM_CASE_GROUP + Le groupe "%1" ne peut pas être attribué à plus d'une frontière. + + + HOM_CASE_EDIT_WINDOW_TITLE + Edition d'un cas + + + HOM_CASE_EDIT_STATE_0 + Maillage initial. + + + HOM_CASE_EDIT_STATE + Poursuite d'une itération. + + + HOM_CASE_PURSUE_WINDOW_TITLE + Cas de poursuite d'une itération + + + The configuration file cannot be found. + Le fichier de configuration de HOMARD est introuvable. + + + The configuration file cannot be read. + Le fichier de configuration de HOMARD est illisible. + + + The HOMARD mesh file cannot be found. + Le fichier de maillage de HOMARD est introuvable. + + + HOM_ITER_NAME + Il faut donner un nom à l'itération. + + + HOM_ITER_STARTING_POINT + Il faut désigner l'itération précédente. + + + HOM_ITER_MESH + Donner le nom du maillage final. + + + HOM_ITER_HYPO + Choisir une hypothèse. + + + HOM_ITER_FIELD_FILE + Avec cette hypothèse, il faut fournir le fichier du champ. + + + HOM_ITER_STARTING_POINT_0 + Maillage + + + HOM_ITER_STARTING_POINT_1 + Itération initiale du cas. + + + HOM_ITER_STARTING_POINT_2 + Itération initiale du cas pour la poursuite. + + + HOM_ITER_EDIT_WINDOW_TITLE + Edition d'une itération + + + Boundary type + Type de frontière + + + No boundary + Pas de frontière + + + Non CAO + Autre que CAO + + + Discrete boundary + Frontière discrète + + + Analytical boundary + Frontière analytique + + + Conformity type + Type de conformité + + + Conformal + Conforme + + + Non conformal + Non conforme + + + Non conformal option + Option de non conformité + + + Conformity + + Conformité + + + + Free + Libre + + + 1 hanging node per mesh + 1 noeud pendant par maille + + + 1 node per edge + 1 noeud pendant par arête + + + Advanced options + Options avancées + + + Authorized pyramids + Pyramides autorisées + + + Minimal diameter + Diamètre minimal + + + Initialization of adaptation + Initialisation de l'adaptation + + + Maximal level + Niveau maximal + + + Output of the level of refinement + Sortie du niveau de raffinement + + + Output of the qualities + Sortie des qualités + + + Output of the diameters + Sortie des diamètres + + + Output of the parents + Sortie des parents + + + Output of the neighbours + Sortie des voisins + + + Create an iteration + Création d'une itération + + + Iteration Name + Nom de l'itération + + + Previous iteration + Itération précédente + + + Invalid boundary + Frontière non valable + + + Invalid case + Cas non valable + + + Invalid case context + Cas contextuel non valable + + + Invalid hypothesis + Hypothèse non valable + + + Invalid iteration + Itération non valable + + + Invalid zone + Zone non valable + + + This boundary has already been defined. + Cette frontière est déjà définie. + + + This case has already been defined. + Ce cas est déjà défini. + + + This hypothesis has already been defined. + Cette hypothèse est déjà définie. + + + This iteration has already been defined. + Cette itération est déjà définie. + + + This zone has already been defined. + Cette zone est déjà définie. + + + The parent iteration is not defined. + L'itération parent n'est pas définie. + + + Unable to create the iteration. + Impossible de créer l'itération. + + + The directory for the computation cannot be created. + Impossible de créer le répertoire pour le calcul de l'itération. + + + This iteration is the first of the case and cannot be computed. + Cette itération définit le point de départ du cas. Elle ne peut pas être calculée. + + + This iteration does not have any associated hypothesis. + Cette itération n'est associée à aucune hypothèse. + + + The mesh file does not exist. + Le fichier du maillage n'existe pas. + + + The mesh file cannot be deleted. + Impossible de supprimer le fichier du maillage. + + + Mesh n + Maillage n + + + Mesh n+1 + Maillage n+1 + + + Field information + Information sur les champs + + + Field file + Fichier des champs + + + No time step + Sans pas de temps + + + Last time step + Dernier pas de temps + + + Chosen time step + Pas de temps choisi + + + Time step + Pas de temps + + + Rank + Numéro d'ordre + + + Hypothesis + Hypothèse + + + Create a hypothesis + Création d'une hypothèse + + + HOM_HYPO_NAME + Il faut donner un nom à l'hypothèse. + + + HOM_HYPO_FIELD_FILE + Il faut fournir le fichier du champ. + + + HOM_HYPO_ZONE_1 + Choisir une zone. + + + HOM_HYPO_ZONE_2 + Il faut choisir au moins une zone. + + + HOM_HYPO_ZONE_3 + Raffinement ou déraffinement, mais pas les deux. + + + HOM_HYPO_NORM_L2 + Norme L2 + + + HOM_HYPO_NORM_INF + Norme infinie + + + HOM_HYPO_NORM_ABS + Absolu + + + HOM_HYPO_NORM_REL + Relatif + + + HOM_HYPO_COMP + Il faut choisir au moins une composante. + + + HOM_HYPO_EDIT_WINDOW_TITLE + Edition d'une hypothèse + + + Type of adaptation + Type d'adaptation + + + Uniform + Uniforme + + + Driven by a field + Pilotage par un champ + + + With geometrical zones + Selon des zones géométriques + + + Uniform adaptation + Adaptation uniforme + + + Coarsening + Déraffinement + + + Refinement + Raffinement + + + Nothing + Rien + + + File of the fields + Fichier des champs + + + Governing field for the adaptation + Champ pilotant l'adaptation + + + Field name + Nom du champ + + + Jump between elements + Saut entre éléments + + + Component + Composante + + + Refinement threshold + Seuil de raffinement + + + Coarsening threshold + Seuil de déraffinement + + + Percentage of meshes + Pourcentage de mailles + + + Mean + n*(std deviation) + Moyenne + n*(ecart-type) + + + No refinement + Sans raffinement + + + Mean - n*(std deviation) + Moyenne - n*(ecart-type) + + + No coarsening + Sans déraffinement + + + Zone management + Gestion des zones + + + Zone name + Nom de la zone + + + Field Interpolation + Interpolation des champs + + + Chosen + Choisi + + + Create a zone + Création d'une zone + + + HOM_ZONE_NAME + Il faut donner un nom à la zone. + + + HOM_ZONE_LIMIT + %1 maxi doit être plus grand que %1 mini. + + + HOM_ZONE_RAYON + Le rayon externe doit être supérieur au rayon interne. + + + HOM_ZONE_EDIT_WINDOW_TITLE + Edition d'une zone + + + Type of zone + Type de la zone + + + Box + Boîte + + + Sphere + Sphère + + + Cylinder + Cylindre + + + Disk + Disque + + + Disk with hole + Disque avec trou + + + Pipe + Tuyau + + + Coordinates + Coordonnées + + + Get CAO + Acquisition de la CAO + + + Create an analytical boundary + Création d'une frontière analytique + + + Create a discrete boundary + Création d'une frontière discrète + + + Type of boundary + Type de la frontière + + + Torus + Tore + + + Radius + Rayon + + + Radius 1 + Rayon 1 + + + Radius 2 + Rayon 2 + + + External radius + Rayon externe + + + Internal radius + Rayon interne + + + Height + Hauteur + + + X axis + X axe + + + Y axis + Y axe + + + Z axis + Z axe + + + R revolution + R révolution + + + Primary R + R primaire + + + HOM_BOUN_NAME + Il faut donner un nom à la frontière. + + + HOM_BOUN_MESH + Il faut choisir le fichier qui contient le maillage de la frontière discrète. + + + HOM_BOUN_CAO + Il faut choisir le fichier qui contient la CAO. + + + HOM_BOUN_CASE + Le fichier du maillage du cas est inconnu. + + + HOM_AXE + L'axe doit être un vecteur non nul. + + + HOM_BOUN_C_EDIT_WINDOW_TITLE + Edition d'une frontière basée sur une CAO + + + HOM_BOUN_A_EDIT_WINDOW_TITLE + Edition d'une frontière analytique + + + HOM_BOUN_D_EDIT_WINDOW_TITLE + Edition d'une frontière discrète + + + HOM_GROU_EDIT_WINDOW_TITLE + Groupes choisis + + + The height must be positive. + La hauteur doit être positive. + + + The radius must be positive. + Un rayon doit être positif. + + + The axis must be a non 0 vector. + L'axe doit être un vecteur non nul. + + + The angle must be included higher than 0 degree and lower than 90 degrees. + L'angle doit être compris entre 0 et 90 degrés. + + + The radius must be different. + Les rayons doivent être différents. + + + The centers must be different. + Les centres doivent être différents. + + + The external radius must be higher than the internal radius. + Le rayon externe doit être supérieur au rayon interne. + + + The X coordinates are not coherent. + Les coordonnées en X ne sont pas cohérentes. + + + The Y coordinates are not coherent. + Les coordonnées en Y ne sont pas cohérentes. + + + The Z coordinates are not coherent. + Les coordonnées en Z ne sont pas cohérentes. + + + The first coordinates are not coherent. + Les premières coordonnées ne sont pas cohérentes. + + + The second coordinates are not coherent. + Les secondes coordonnées ne sont pas cohérentes. + + + The orientation must be 1, 2 or 3. + L'orientation vaut 1, 2 ou 3. + + + HOM_MESH_INFO_0 + Analyse de maillage + + + HOM_MESH_INFO_1 + Choisir au moins une option. + + + HOM_MESH_INFO_2 + Bilan de l'analyse dans l'arbre d'études, fichier + + + Filtering with groups + Filtrage par les groupes + + + Selection of groups + Choix des groupes + + + Selected groups + Groupes choisis + + + Group + Groupe + + + Information on a mesh + Analyse d'un maillage + + + Group size + Taille des domaines + + + Quality + Qualité + + + Connection + Connexité + + + Diametre + Diamètre + + + Entanglement + Interpénétration + + + No change is allowed in a boundary. Ask for evolution. + Impossible de changer une donnée dans une frontière. Demander une évolution. + + + This boundary is used in a case and cannot be deleted. + Cette frontière est utilisée dans un cas ; elle ne peut pas être détruite. + + + This hypothesis is used and cannot be deleted. + Cette hypothèse est utilisée dans une itération ; elle ne peut pas être détruite. + + + This iteration cannot be deleted. + Cette itération ne peut pas être détruite. + + + This zone is used in a hypothesis and cannot be deleted. + Cette zone est utilisée dans une hypothèse ; elle ne peut pas être détruite. + + + The directory for the calculation cannot be cleared. + Menage du repertoire de calcul impossible + + + Starting point + Point de départ + + + From an iteration + A partir d'une itération + + + From a case + A partir d'un cas + + + Iteration into the case + Choix d'une itération dans le cas + + + Last iteration + A partir de la dernière itération + + + Iteration number + A partir d'une itération numérotée + + + The directory of the case does not exist. + Le répertoire du cas n'existe pas. + + + The directory for the case cannot be modified because some iterations are already defined. + Impossible de changer le répertoire du cas car des itérations ont déjà été définies. + + + The directory for the case cannot be reached. + Impossible d'atteindre ce répertoire pour le cas. + + + The starting point for the case cannot be copied into the working directory. + Impossible de copier le point de départ du cas dans le répertoire de travail. + + + The starting point for the case cannot be moved into the new directory. + Impossible de déplacer le point de départ du cas dans le nouveau répertoire. + + + The directory of the case for the pursuit does not exist. + Le répertoire du cas de reprise n'existe pas. + + + The directory of the iteration does not exist. + Le répertoire de l'itération de reprise n'existe pas. + + + The number of iteration must be positive. + Le numéro de l'itération doit etre positif. + + + Number of iteration + Numéro de l'itération + + + Case + Cas + + + Mesh file + Maillage initial + + + Constant + Constant + + + Variable + Variable + + + Type of schema + Type de schema + + + Maximum of ... + Maximum de ... + + + Iterations + Itérations + + + Nodes + Noeuds + + + Elements + Eléments + + + Test of convergence + Test de convergence + + + Edit a file + Affichage d'un fichier + + + Print + Imprimer + + + Invalid study context + Etude contextuelle non valable + + + HOM_YACS_EDIT_WINDOW_TITLE + Edition d'un schéma YACS + + + diff --git a/src/ADAPTGUI/ADAPT_msg_ja.ts b/src/ADAPTGUI/ADAPT_msg_ja.ts new file mode 100644 index 000000000..e60a20c76 --- /dev/null +++ b/src/ADAPTGUI/ADAPT_msg_ja.ts @@ -0,0 +1,1148 @@ + + + + + @default + + HOM_MEN_HOMARD + ロブスター + + + HOM_MEN_MODIFICATION + 変更 + + + HOM_MEN_INFORMATION + 情報 + + + HOM_MEN_YACS + YACS + + + HOM_MEN_NEW_CASE + 新しいケース + + + HOM_MEN_NEW_ITERATION + 新しいイテレーション + + + HOM_MEN_PURSUE_ITERATION + イテレーションの追跡 + + + HOM_MEN_COMPUTE + 計算します。 + + + HOM_MEN_COMPUTE_PUBLISH + 計算と発行 + + + HOM_MEN_EDIT + 編集(&E) + + + HOM_MEN_DELETE + 削除 + + + HOM_MEN_MESH_INFO + メッシュの解析 + + + HOM_MEN_MESH_PUBLICATION + メッシュ発行 + + + HOM_MEN_EDIT_MESS_FILE + ファイルを表示します。 + + + HOM_MEN_WRITE + 書き込み + + + HOM_TOP_HOMARD + ロブスター + + + HOM_TOP_NEW_CASE + 新しいケース + + + HOM_TOP_NEW_ITERATION + 新しいイテレーション + + + HOM_TOP_PURSUE_ITERATION + イテレーションの追跡 + + + HOM_TOP_COMPUTE + 計算します。 + + + HOM_TOP_COMPUTE_PUBLISH + 計算と発行 + + + HOM_TOP_EDIT + 編集 + + + HOM_TOP_DELETE + 削除 + + + HOM_TOP_EDIT_MESS_FILE + ファイルを表示します。 + + + HOM_STB_HOMARD + ロブスター + + + HOM_STB_NEW_CASE + 新しいケース + + + HOM_STB_NEW_ITERATION + 新しいイテレーション + + + HOM_STB_PURSUE_ITERATION + イテレーションの追跡 + + + HOM_STB_COMPUTE + 計算 + + + HOM_STB_COMPUTE_PUBLISH + 計算と発行 + + + HOM_STB_EDIT + 編集 + + + HOM_STB_DELETE + 削除 + + + HOM_STB_EDIT_MESS_FILE + ファイルを表示します。 + + + HOM_WARNING + 警告 + + + HOM_ERROR + エラー + + + HOM_INACTIVE_BUTTON + アクティブでないボタン + + + OK + Ok + + + Apply + 適用 + + + Cancel + キャンセル + + + Help + ヘルプ + + + New + 新規 + + + Edit + 編集 + + + Quit + 終了 + + + Name + 名前 + + + Directory + ディレクトリ + + + Mesh + メッシュ + + + Selection + 選択 + + + None + なし + + + All + 全て + + + HOM_SELECT_OBJECT_1 + オブジェクトを選択します。 + + + HOM_SELECT_OBJECT_2 + 1 つのオブジェクトを選択します。 + + + HOM_SELECT_OBJECT_3 + 型 %1 のオブジェクトを選択します。 + + + HOM_SELECT_OBJECT_4 + The name of the object is already selected. Modify it or cancel. + + + HOM_SELECT_FILE_0 + ファイル選択 + + + HOM_SELECT_FILE_1 + ファイルを選択します。 + + + HOM_SELECT_FILE_2 + 1 つのファイルを選択します。 + + + HOM_SELECT_FILE_3 + このファイルを開くことができません。 + + + HOM_SCRIPT_FILE + 我々 は python スクリプトにファイルを与える必要があります。 + + + HOM_MED_FILE_1 + この医学ファイルは読み取り不可能です。 + + + HOM_MED_FILE_2 + この医学のファイルには、メッシュが含まれていません。 + + + HOM_MED_FILE_3 + この医学のファイルにはよりも 1 つのメッシュが含まれています。 + + + HOM_MED_FILE_4 + 音楽配信マック & ファイルのメッシュを読み取れませんでした。 + + + HOM_MED_FILE_5 + この医学のファイルには、フィールドが含まれていません。 + + + HOM_MED_FILE_6 + 医学ファイル (秒) (秒) フィールドを読み取ることができません。 + + + HOM_SELECT_STUDY + 研究医 associe + のファイルを選択または医学ファイルを選択します。 + + + Create a case + ケースの作成 + + + HOM_CASE_NAME + 場合に名前を付ける必要があります。 + + + HOM_CASE_DIRECTORY_1 + 1 つの場合を動作するようにディレクトリを選択する必要があります。 + + + HOM_CASE_DIRECTORY_2 + このディレクトリは、既に使用中です。 + + + HOM_CASE_DIRECTORY_3 + 有効なディレクトリを選択する必要があります。 + + + HOM_CASE_DIRECTORY_4 + 計算のための作業ディレクトリを選択する必要があります。 + + + HOM_START_DIRECTORY_1 + 追跡のため開始点を選択する必要があります。 + + + HOM_START_DIRECTORY_3 + 追跡のため有効な方向を選択する必要があります。 + + + HOM_CASE_MESH + 1 つは、初期のメッシュを選択する必要があります。 + + + HOM_CASE_GROUP + グループ"%1"は、以上の境界線に割り当てることはできません。 + + + HOM_CASE_EDIT_WINDOW_TITLE + 場合の編集 + + + HOM_CASE_EDIT_STATE_0 + 初期メッシュ。 + + + HOM_CASE_EDIT_STATE + イテレーションの継続。 + + + HOM_CASE_PURSUE_WINDOW_TITLE + イテレーションの追跡 + + + The configuration file cannot be found. + コンフィギュレーションファイルが見つかりません。 + + + The configuration file cannot be read. + コンフィギュレーションファイルが読み込めません。 + + + The HOMARD mesh file cannot be found. + HOMARDメッシュファイルが見つかりません。 + + + HOM_ITER_NAME + 名前を反復処理する必要があります。 + + + HOM_ITER_STARTING_POINT + これは、前のイテレーションを指定する必要があります。 + + + HOM_ITER_MESH + 最終的なメッシュの名前。 + + + HOM_ITER_HYPO + 仮説を選択します。 + + + HOM_ITER_FIELD_FILE + この前提には、ファイルのフィールドを指定する必要があります。 + + + HOM_ITER_STARTING_POINT_0 + メッシュ + + + HOM_ITER_STARTING_POINT_1 + ケースの最初のイテレーションです。 + + + HOM_ITER_STARTING_POINT_2 + 検察側の事件の最初のイテレーションです。 + + + HOM_ITER_EDIT_WINDOW_TITLE + イテレーションの編集 + + + Discrete boundary + 離散境界 + + + Analytical boundary + 解析的境界 + + + Conformity type + 適合タイプ + + + Conformal + 等角 + + + Non conformal + 非共形 + + + Non conformal option + 非共形オプション + + + Conformity + + 適合性 + + + + Free + Free + + + 1 hanging node per mesh + メッシュあたりの1接続節点 + + + 1 node per edge + エッジ辺りの1節点 + + + Advanced options + 詳細オプション + + + Authorized pyramids + 認定済みピラミッド + + + Minimal diameter + 最小径 + + + Initialization of adaptation + 適応の初期化 + + + Maximal level + 最大レベル + + + Output of the level of refinement + リファインレベルの出力 + + + Output of the qualities + 品質の出力 + + + Output of the diameters + 直径の出力 + + + Output of the parents + 親直径の出力 + + + Output of the neighbours + 隣の直径の出力 + + + Create an iteration + イテレーションの作成 + + + Iteration Name + イテレーションの名前 + + + Previous iteration + 以前のイテレーション + + + Invalid boundary + 無効な境界 + + + Invalid case + 無効なケース + + + Invalid case context + ケースの内容が無効です + + + Invalid hypothesis + 無効なhypothesis + + + Invalid iteration + 無効なイテレーション + + + Invalid zone + 無効なゾーン + + + This boundary has already been defined. + この境界は既に定義されています。 + + + This case has already been defined. + このケースは既に定義されています。 + + + This hypothesis has already been defined. + このhypothesisは既に定義されています。 + + + This iteration has already been defined. + このイテレーションは既に定義されています。 + + + This zone has already been defined. + このゾーンは既に定義されています。 + + + The parent iteration is not defined. + 親イテレーションは、定義されていません。 + + + Unable to create the iteration. + イテレーションを作成することができません。 + + + The directory for the computation cannot be created. + 計算のためのディレクトリを作成できません。 + + + This iteration is the first of the case and cannot be computed. + このイタレーションはケースの最初であり、計算できません。 + + + This iteration does not have any associated hypothesis. + このイタレーションは関連した hypothesis がありません。 + + + The mesh file does not exist. + メッシュ ファイルは存在しません。 + + + The mesh file cannot be deleted. + メッシュ ファイルを削除できません。 + + + Mesh n + メッシュ n + + + Mesh n+1 + メッシュ n + 1 + + + Field information + フィールド情報 + + + Field file + フィールド ファイル + + + No time step + タイムステップなし + + + Last time step + 最終タイムステップ + + + Chosen time step + 選択されたタイムステップ + + + Time step + タイムステップ + + + Rank + ランク + + + Hypothesis + Hypothesis + + + Create a hypothesis + hypothesis の作成 + + + HOM_HYPO_NAME + 仮説に名前を付ける必要があります。 + + + HOM_HYPO_FIELD_FILE + それはフィールドのファイルを提供する必要があります。 + + + HOM_HYPO_ZONE_1 + ゾーンを選択します。 + + + HOM_HYPO_ZONE_2 + 1 つは、少なくとも 1 つのゾーンを選択する必要があります。 + + + HOM_HYPO_ZONE_3 + 洗練された、または deraffinement、両方ではないです。 + + + HOM_HYPO_NORM_L2 + 標準の L2 + + + HOM_HYPO_NORM_INF + 無限の標準 + + + HOM_HYPO_NORM_ABS + 絶対値 + + + HOM_HYPO_NORM_REL + 関係 + + + HOM_HYPO_COMP + 1 つ以上のコンポーネントを選択する必要があります。 + + + HOM_HYPO_EDIT_WINDOW_TITLE + 仮説の編集 + + + Type of adaptation + 適合のタイプ + + + Uniform + 均一 + + + Driven by a field + フィールドによって駆動 + + + With geometrical zones + 幾何学的ゾーン使用 + + + Uniform adaptation + 均一な適応 + + + Coarsening + 粗大化 + + + Refinement + リファインメント + + + Nothing + なし + + + File of the fields + フィールドファイル + + + Governing field for the adaptation + 適合のためにフィールドを管理 + + + Field name + フィールド名 + + + Jump between elements + 要素間ジャンプ + + + Component + コンポーネント + + + Refinement threshold + リファインメント閾値 + + + Coarsening threshold + 粗大化閾値 + + + Percentage of meshes + メッシュの割合 + + + Mean + n*(std deviation) + 平均 + n * (標準偏差) + + + No refinement + リファインメントなし + + + Mean - n*(std deviation) + 平均 - n * (標準偏差) + + + No coarsening + 粗大化なし + + + Zone management + ゾーン管理 + + + Zone name + ゾーン名 + + + Field Interpolation + フィールド補間 + + + Chosen + 選択済み + + + Create a zone + ゾーンの作成 + + + HOM_ZONE_NAME + 領域に名前を必要があります。 + + + HOM_ZONE_LIMIT + 最大 %1 は %1 のミニよりも大きい必要があります。 + + + HOM_ZONE_RAYON + 外側の半径は、内側の半径よりも大きい必要があります。 + + + HOM_ZONE_EDIT_WINDOW_TITLE + 領域の編集 + + + Type of zone + ゾーンのタイプ + + + Box + Box + + + Sphere + 球 + + + Cylinder + 円筒 + + + Disk + 円盤 + + + Disk with hole + 穴付き円盤 + + + Pipe + パイプ + + + Coordinates + 座標 + + + Create an analytical boundary + 分析境界の作成 + + + Create a discrete boundary + 離散境界の作成 + + + Type of boundary + 境界のタイプ + + + Torus + 環状体 + + + Radius + 半径 + + + Radius 1 + 半径1 + + + Radius 2 + 半径2 + + + External radius + 外半径 + + + Internal radius + 内半径 + + + Height + 高さ + + + X axis + X 軸 + + + Y axis + Y 軸 + + + Z axis + Z 軸 + + + R revolution + R 回転 + + + Primary R + 主 R + + + HOM_BOUN_NAME + 名前の国境に与えする必要があります。 + + + HOM_BOUN_MESH + 1 つの枠を含むメッシュを選択する必要があります。 + + + HOM_BOUN_CASE + 場合ファイルのメッシュが知られています。 + + + HOM_AXE + 軸は、ゼロ以外のベクトルでなければなりません。 + + + HOM_BOUN_A_EDIT_WINDOW_TITLE + 分析のフロンティアの編集 + + + HOM_BOUN_D_EDIT_WINDOW_TITLE + 離散境界の編集 + + + HOM_GROU_EDIT_WINDOW_TITLE + 選択したグループ + + + The height must be positive. + 高さは正でなければなりません。 + + + The radius must be positive. + 半径は正でなければなりません。 + + + The axis must be a non 0 vector. + 軸は非 0 のベクトルでなければなりません。 + + + The angle must be included higher than 0 degree and lower than 90 degrees. + 角度は0 °よりも大きく 90 °未満である必要があります。 + + + The radius must be different. + 半径が異なる必要があります。 + + + The centers must be different. + 中心が異なる必要があります。 + + + The external radius must be higher than the internal radius. + 外部の半径は内部の半径より大きい必要があります。 + + + The X coordinates are not coherent. + X座標は論理上問題があります。 + + + The Y coordinates are not coherent. + Y座標は論理上問題があります。 + + + The Z coordinates are not coherent. + Z座標は論理上問題があります。 + + + The first coordinates are not coherent. + 最初の座標に論理上問題があります。 + + + The second coordinates are not coherent. + 2番目の座標に論理上問題があります。 + + + The orientation must be 1, 2 or 3. + 方向は1、2、3のどれかにする必要があります。 + + + HOM_MESH_INFO_0 + メッシュの解析 + + + HOM_MESH_INFO_1 + 少なくとも 1 つのオプションを選択します。 + + + HOM_MESH_INFO_2 + バランス シート分析結果をスタディ ツリーで、ファイル + + + Filtering with groups + グループでフィルタリング + + + Selection of groups + グループの選択 + + + Selected groups + 選択されたグループ + + + Group + グループ : + + + Information on a mesh + メッシュに関する情報 + + + Group size + グループのサイズ + + + Quality + 品質 + + + Connection + 接続 + + + Diametre + 直径 + + + Entanglement + 縺れ合い + + + No change is allowed in a boundary. Ask for evolution. + 境界内に許可された変更はありません。旋回について尋ねます。 + + + This boundary is used in a case and cannot be deleted. + この境界はケースで使用されており、削除できません。 + + + This hypothesis is used and cannot be deleted. + このhypothesisは使用されており、削除できません。 + + + This iteration cannot be deleted. + このイテレーションは削除できません。 + + + This zone is used in a hypothesis and cannot be deleted. + このゾーンはhypothesisで使用されており、削除できません。 + + + The directory for the calculation cannot be cleared. + 計算用ディレクトリは削除できません。 + + + Starting point + 始点 + + + From an iteration + イテレーションから + + + From a case + ケースから + + + Iteration into the case + ケースへのイテレーション + + + Last iteration + 最後のイテレーション + + + Iteration number + イテレーション数 + + + The directory of the case does not exist. + ケースのディレクトリは存在しません。 + + + The directory for the case cannot be modified because some iterations are already defined. + いくつかのイテレーションが既に定義されているため、ケースのディレクトリを変更できません。 + + + The directory for the case cannot be reached. + ケースのディレクトリに到達できません。 + + + The starting point for the case cannot be copied into the working directory. + ケースの開始点は作業ディレクトリにコピーできません。 + + + The starting point for the case cannot be moved into the new directory. + ケースの開始点は新しいディレクトリに移動できません。 + + + The directory of the case for the pursuit does not exist. + 追跡用ケースのディレクトリは存在しません。 + + + The directory of the iteration does not exist. + イテレーションのディレクトリが存在しません。 + + + The number of iteration must be positive. + イテレーション数は正である必要があります。 + + + Number of iteration + イテレーション数 + + + Case + ケース + + + Mesh file + メッシュファイル + + + Constant + 定数 + + + Variable + 変数 + + + Type of schema + スキーマタイプ + + + Maximum of ... + 最大の... + + + Iterations + イテレーション + + + Nodes + 節点 + + + Elements + 要素 + + + Test of convergence + 収束テスト + + + Edit a file + ファイルの編集 + + + Print + 印刷 + + + Invalid study context + 無効なスタディの内容 + + + HOM_YACS_EDIT_WINDOW_TITLE + YACS スキーマ編集スキーマへんしゅう + + + PREF_TAB_GENERAL + 一般的な + + + PREF_PUBLICATION + 発行 + + + PREF_PUBLICATION_MAILLAGE_IN + メッシュ入力 + + + PREF_PUBLICATION_MAILLAGE_OUT + メッシュ出力 + + + PREF_YACS + YACS + + + PREF_YACS_MAX + 最大の数 + + + PREF_YACS_MAX_ITER + 繰り返し + + + PREF_YACS_MAX_NODE + 節点 + + + PREF_YACS_MAX_ELEM + 要素 + + + PREF_YACS_CONVERGENCE + 収束 + + + PREF_YACS_TYPE_TEST + テストタイプ + + + diff --git a/src/ADAPTGUI/CMakeLists.txt b/src/ADAPTGUI/CMakeLists.txt new file mode 100644 index 000000000..6499859d3 --- /dev/null +++ b/src/ADAPTGUI/CMakeLists.txt @@ -0,0 +1,183 @@ +# Copyright (C) 2012-2020 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +INCLUDE(UseQtExt) +INCLUDE(UsePyQt) + +# --- options --- + +# additional include directories +INCLUDE_DIRECTORIES( + ${QT_INCLUDES} + ${OpenCASCADE_INCLUDE_DIR} + ${PYTHON_INCLUDE_DIRS} + ${MEDFILE_INCLUDE_DIRS} + ${HDF5_INCLUDE_DIRS} + ${OMNIORB_INCLUDE_DIR} + ${KERNEL_INCLUDE_DIRS} + ${GUI_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${PROJECT_BINARY_DIR} + ${PROJECT_BINARY_DIR}/idl + ${PROJECT_BINARY_DIR}/adm_local/unix + ${PROJECT_SOURCE_DIR}/src/ADAPT + ${PROJECT_SOURCE_DIR}/src/ADAPT_I + ${PROJECT_SOURCE_DIR}/src/SMESH_I + ${PROJECT_SOURCE_DIR}/src/SMESH + ${MEDCOUPLING_INCLUDE_DIRS} +) + +# additional preprocessor / compiler flags +ADD_DEFINITIONS( + ${OMNIORB_DEFINITIONS} + ${OpenCASCADE_DEFINITIONS} + ${KERNEL_DEFINITIONS} +) + +# libraries to link to +SET(_link_LIBRARIES + ${MEDFILE_C_LIBRARIES} + ${KERNEL_SalomeLifeCycleCORBA} + ${KERNEL_SalomeDS} + ${GUI_SalomeApp} + ${SMESH_SalomeIDLSMESH} + ${SMESH_SMESHEngine} + ADAPTEngine + ${MEDCoupling_medloader} + SMESHimpl +) + +# --- resources --- + +# resource files / to be processed by lrelease +SET(_ts_RESOURCES + ADAPT_msg_en.ts + ADAPT_msg_fr.ts + ADAPT_msg_ja.ts +) + +# resource files / to be processed by uic +SET(_uic_FILES + CreateBoundaryCAO.ui + CreateBoundaryAn.ui + CreateBoundaryDi.ui + CreateCase.ui + CreateHypothesis.ui + CreateIteration.ui + CreateListGroup.ui + CreateYACS.ui + CreateZone.ui + EditFile.ui + IterInfo.ui + MeshInfo.ui + PursueIteration.ui +) + +# --- headers --- + +# header files / to be processed by moc +SET(_moc_HEADERS + MonCreateBoundaryCAO.h + MonCreateBoundaryAn.h + MonCreateBoundaryDi.h + MonEditBoundaryCAO.h + MonEditBoundaryAn.h + MonEditBoundaryDi.h + MonCreateCase.h + MonEditCase.h + MonCreateZone.h + MonEditZone.h + MonCreateHypothesis.h + MonEditHypothesis.h + MonCreateListGroup.h + MonCreateListGroupCAO.h + MonEditListGroup.h + MonEditListGroupCAO.h + MonCreateIteration.h + MonEditIteration.h + MonPursueIteration.h + MonMeshInfo.h + MonIterInfo.h + MonCreateYACS.h + MonEditYACS.h + MonEditFile.h + #~MG_ADAPTGUI.hxx +) + +# header files / uic wrappings +QT_WRAP_UIC(_uic_HEADERS ${_uic_FILES}) + +# header files / static +SET(_other_HEADERS + HOMARDGUI_Utils.h + HomardQtCommun.h + HOMARDGUI_Exports.hxx +) + +# header files / to install +SET(ADAPT_HEADERS ${_other_HEADERS} ${_moc_HEADERS} ${_uic_HEADERS}) + +# --- sources --- + +# sources / moc wrappings +QT_WRAP_MOC(_moc_SOURCES ${_moc_HEADERS}) + +# sources / static +SET(_other_SOURCES + HOMARDGUI_Utils.cxx + MonCreateBoundaryCAO.cxx + MonCreateBoundaryAn.cxx + MonCreateBoundaryDi.cxx + MonEditBoundaryCAO.cxx + MonEditBoundaryAn.cxx + MonEditBoundaryDi.cxx + MonCreateCase.cxx + MonEditCase.cxx + MonCreateHypothesis.cxx + MonEditHypothesis.cxx + MonCreateListGroup.cxx + MonCreateListGroupCAO.cxx + MonEditListGroup.cxx + MonEditListGroupCAO.cxx + MonCreateIteration.cxx + MonEditIteration.cxx + MonPursueIteration.cxx + MonCreateZone.cxx + MonEditZone.cxx + MonMeshInfo.cxx + MonIterInfo.cxx + MonCreateYACS.cxx + MonEditYACS.cxx + MonEditFile.cxx + HomardQtCommun.cxx + #~MG_ADAPTGUI.cxx +) + +# sources / to compile +SET(ADAPT_SOURCES ${_other_SOURCES} ${_moc_SOURCES} ${_uic_HEADERS}) + +# --- rules --- + +ADD_LIBRARY(ADAPTGUI ${ADAPT_SOURCES}) +TARGET_LINK_LIBRARIES(ADAPTGUI ${_link_LIBRARIES} ) +INSTALL(TARGETS ADAPTGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +INSTALL(FILES ${ADAPT_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) +QT_INSTALL_TS_RESOURCES("${_ts_RESOURCES}" "${SALOME_ADAPT_INSTALL_RES_DATA}") diff --git a/src/ADAPTGUI/CreateBoundaryAn.ui b/src/ADAPTGUI/CreateBoundaryAn.ui new file mode 100644 index 000000000..ac291082d --- /dev/null +++ b/src/ADAPTGUI/CreateBoundaryAn.ui @@ -0,0 +1,1107 @@ + + + CreateBoundaryAn + + + + 0 + 0 + 522 + 835 + + + + Create an analytical boundary + + + true + + + true + + + + + + Name + + + + + + + 32 + + + + + + + + 0 + 0 + + + + + 340 + 0 + + + + Type of boundary + + + + + + Cylinder + + + + ../../resources/cylinderpointvector.png../../resources/cylinderpointvector.png + + + true + + + true + + + + + + + Sphere + + + + ../../resources/zone_spherepoint.png../../resources/zone_spherepoint.png + + + + + + + Cone + + + + ../../resources/cone.png../../resources/cone.png + + + + + + + Torus + + + + ../../resources/toruspointvector.png../../resources/toruspointvector.png + + + true + + + false + + + + + + + + + + + 0 + 0 + + + + Coordinates + + + + 9 + + + 6 + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + X centre + + + false + + + + + + + 5 + + + 1000000000.000000000000000 + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Radius + + + false + + + + + + + + 0 + 0 + + + + Z centre + + + false + + + + + + + + 0 + 0 + + + + Y centre + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + X axis + + + false + + + + + + + + 0 + 0 + + + + Y axis + + + false + + + + + + + + 0 + 0 + + + + Z axis + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + + + + 0 + 0 + + + + Coordinates + + + + 9 + + + 6 + + + + + 5 + + + 0.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Radius + + + false + + + + + + + + 0 + 0 + + + + Z centre + + + false + + + + + + + + 0 + 0 + + + + Y centre + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + X centre + + + false + + + + + + + + + + + 0 + 0 + + + + Coordinates + + + + + + Definition + + + + + + Radius + + + + ../../resources/conedxyz.png../../resources/conedxyz.png + + + true + + + + + + + Angle + + + + ../../resources/conepointvector.png../../resources/conepointvector.png + + + + + + + + + + + 0 + 0 + + + + X 1 + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + X 2 + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Y 1 + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Y 2 + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Z 1 + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Z 2 + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + V 1 + + + false + + + + + + + 5 + + + 1000000000.000000000000000 + + + + + + + + 0 + 0 + + + + V 2 + + + false + + + + + + + 5 + + + 1000000000.000000000000000 + + + + + + + + + + + 0 + 0 + + + + Coordinates + + + + + + + 0 + 0 + + + + X centre + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + X axis + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Y centre + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Y axis + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Z centre + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Z axis + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + R revolution + + + false + + + + + + + 5 + + + 1000000000.000000000000000 + + + + + + + + 0 + 0 + + + + Primary R + + + false + + + + + + + 5 + + + 1000000000.000000000000000 + + + + + + + + + + + 0 + 0 + + + + + + + + 9 + + + 6 + + + + + Help + + + + + + + Cancel + + + + + + + Apply + + + + + + + OK + + + + + + + + + + + diff --git a/src/ADAPTGUI/CreateBoundaryCAO.ui b/src/ADAPTGUI/CreateBoundaryCAO.ui new file mode 100644 index 000000000..c74c60122 --- /dev/null +++ b/src/ADAPTGUI/CreateBoundaryCAO.ui @@ -0,0 +1,133 @@ + + + CreateBoundaryCAO + + + + 0 + 0 + 566 + 195 + + + + + 0 + 0 + + + + Get CAO + + + true + + + true + + + + 9 + + + 6 + + + + + + + + + 9 + + + 6 + + + + + Help + + + + + + + Cancel + + + + + + + Apply + + + + + + + OK + + + + + + + + + + Filtering with groups + + + + + + + + 370 + 21 + + + + + + + + + + + + + + + XAO + + + + + + + + 382 + 21 + + + + 32 + + + + + + + Name + + + + + + + + diff --git a/src/ADAPTGUI/CreateBoundaryDi.ui b/src/ADAPTGUI/CreateBoundaryDi.ui new file mode 100644 index 000000000..b505ff869 --- /dev/null +++ b/src/ADAPTGUI/CreateBoundaryDi.ui @@ -0,0 +1,133 @@ + + + CreateBoundaryDi + + + + 0 + 0 + 566 + 169 + + + + + 0 + 0 + + + + Create a discrete boundary + + + true + + + true + + + + 9 + + + 6 + + + + + + + + + 9 + + + 6 + + + + + Help + + + + + + + Cancel + + + + + + + Apply + + + + + + + OK + + + + + + + + + + Filtering with groups + + + + + + + + 370 + 21 + + + + + + + + + + + + + + + Mesh + + + + + + + + 382 + 21 + + + + 32 + + + + + + + Name + + + + + + + + diff --git a/src/ADAPTGUI/CreateCase.ui b/src/ADAPTGUI/CreateCase.ui new file mode 100644 index 000000000..14fe44db9 --- /dev/null +++ b/src/ADAPTGUI/CreateCase.ui @@ -0,0 +1,777 @@ + + + CreateCase + + + + 0 + 0 + 600 + 1150 + + + + + 0 + 0 + + + + + 600 + 320 + + + + + 1 + 1 + + + + + 600 + 320 + + + + Create a case + + + true + + + + + + + + + Name + + + + + + + + + + + + + Qt::Horizontal + + + + 199 + 20 + + + + + + + + 6 + + + 0 + + + + + Directory + + + + + + + + + + false + + + + + + + + 382 + 21 + + + + + + + + + + Qt::Vertical + + + + 20 + 18 + + + + + + + + 6 + + + 0 + + + + + Mesh + + + + + + + + + + false + + + + + + + + 382 + 21 + + + + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + Conformity type + + + + 6 + + + 9 + + + + + Conformal + + + true + + + + + + + Non conformal + + + + + + + + + + Boundary type + + + + 6 + + + 9 + + + + + No boundary + + + true + + + + + + + CAO + + + false + + + + + + + Non CAO + + + + + + + + + + Qt::Vertical + + + + 20 + 1 + + + + + + + + 6 + + + 0 + + + + + Discrete boundary + + + + + + + Analytical boundary + + + + + + + + + + 0 + 0 + + + + CAO + + + + 9 + + + 6 + + + + + Edit + + + false + + + + + + + Help + + + false + + + + + + + -1 + + + QComboBox::AdjustToContents + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 13 + + + + + + + + New + + + false + + + + + + + + + + Qt::Vertical + + + + 20 + 2 + + + + + + + + + 0 + 0 + + + + Discrete boundary + + + + 9 + + + 6 + + + + + -1 + + + QComboBox::AdjustToContents + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 13 + + + + + + + + Edit + + + false + + + + + + + Help + + + false + + + + + + + New + + + false + + + + + + + + + + + 548 + 200 + + + + Analytical boundary + + + + + + QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked + + + true + + + 0 + + + 1 + + + + a_virer + + + + + + + + 0 + + + 6 + + + + + Edit + + + false + + + + + + + New + + + false + + + + + + + Help + + + false + + + + + + + + + + + + Qt::Vertical + + + + 239 + 41 + + + + + + + + Advanced options + + + + + + + Advanced options + + + + + + Authorized pyramids + + + + + + + Conformity + + + + + + + + + Standard + + + true + + + + + + + Box + + + false + + + + + + + 1 node per edge + + + + + + + Free + + + + + + + + + Format + + + + + + MED + + + true + + + + + + + Saturne + + + + + + + Saturne 2D + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 128 + 13 + + + + + + + + Qt::Vertical + + + + 239 + 41 + + + + + + + + No comment. + + + + + + + Qt::Vertical + + + + 20 + 35 + + + + + + + + + + + + 9 + + + 6 + + + + + Help + + + false + + + + + + + Apply + + + false + + + + + + + OK + + + false + + + + + + + Cancel + + + false + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 128 + 25 + + + + + + WName + GBTypeConf + GBBoundaryD + GBBoundaryA + CBAdvanced + GBAdvancedOptions + Comment + GroupButtons + GBBoundaryC + GBTypeBoun + + + + diff --git a/src/ADAPTGUI/CreateHypothesis.ui b/src/ADAPTGUI/CreateHypothesis.ui new file mode 100644 index 000000000..53698b548 --- /dev/null +++ b/src/ADAPTGUI/CreateHypothesis.ui @@ -0,0 +1,1111 @@ + + + CreateHypothesis + + + + 0 + 0 + 848 + 1650 + + + + + 0 + 0 + + + + + 800 + 600 + + + + + 1 + 1 + + + + + 800 + 1200 + + + + Create a hypothesis + + + true + + + + + 0 + 0 + 844 + 1646 + + + + true + + + + + + + + + Name + + + + + + + + 282 + 31 + + + + + + + + + + + Qt::Horizontal + + + + 224 + 20 + + + + + + + + Type of adaptation + + + + 6 + + + 9 + + + + + Uniform + + + true + + + + + + + Driven by a field + + + + + + + With geometrical zones + + + + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + Filtering with groups + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Uniform adaptation + + + + 9 + + + 6 + + + + + Coarsening + + + + + + + Refinement + + + true + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + 9 + + + 6 + + + + + File of the fields + + + + + + + + 282 + 31 + + + + + + + + + + + + 0 + 0 + + + + Governing field for the adaptation + + + + 9 + + + 6 + + + + + 6 + + + 0 + + + + + Field name + + + + + + + + 0 + 0 + + + + false + + + QComboBox::AdjustToContents + + + + + + + Qt::Horizontal + + + + 48 + 20 + + + + + + + + + + 6 + + + 0 + + + + + QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked + + + true + + + 0 + + + 2 + + + + Selection + + + + + Component + + + + + + + + Qt::Horizontal + + + + 60 + 20 + + + + + + + + 6 + + + 0 + + + + + 6 + + + 0 + + + + + L2 norm + + + true + + + + + + + Infinite norm + + + false + + + + + + + + + Jump between elements + + + + + + + + + + + 6 + + + 0 + + + + + + 0 + 0 + + + + Refinement threshold + + + + 9 + + + 6 + + + + + Percentage of meshes + + + true + + + true + + + + + + + % + + + 3 + + + 100.000000000000000 + + + 0.100000000000000 + + + 2.000000000000000 + + + + + + + Relative + + + + + + + false + + + % + + + 3 + + + 100.000000000000000 + + + 0.100000000000000 + + + + + + + Absolute + + + + + + + false + + + 8 + + + -1000000000000.000000000000000 + + + 1000000000000.000000000000000 + + + 0.100000000000000 + + + + + + + Mean + n*(std deviation) + + + + + + + false + + + 8 + + + -1000000000000.000000000000000 + + + 1000000000000.000000000000000 + + + 0.100000000000000 + + + 3.000000000000000 + + + + + + + No refinement + + + + + + + + + + Coarsening threshold + + + + 9 + + + 6 + + + + + Percentage of meshes + + + true + + + false + + + + + + + false + + + % + + + 3 + + + 100.000000000000000 + + + 0.100000000000000 + + + + + + + Relative + + + + + + + false + + + % + + + 3 + + + 100.000000000000000 + + + 0.100000000000000 + + + + + + + Absolute + + + + + + + false + + + 8 + + + -1000000000000.000000000000000 + + + 1000000000000.000000000000000 + + + 0.100000000000000 + + + + + + + Mean - n*(std deviation) + + + + + + + false + + + 8 + + + -1000000000000.000000000000000 + + + 1000000000000.000000000000000 + + + 0.100000000000000 + + + 4.000000000000000 + + + + + + + No coarsening + + + true + + + + + + + + + + + + + + + + 0 + 0 + + + + Zone management + + + + + + + 400 + 0 + + + + QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked + + + true + + + 0 + + + 3 + + + + Refinement + + + + + Coarsening + + + + + Zone name + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 6 + + + 0 + + + + + 6 + + + 0 + + + + + New + + + + + + + Edit + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 48 + + + + + + + + + + + + + Field Interpolation + + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + None + + + true + + + + + + + All + + + false + + + + + + + Chosen + + + false + + + + + + + + + + Selection + + + + + Field Name + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Advanced options + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Advanced options + + + + + + + 0 + 0 + + + + Minimal diameter + + + false + + + + + + + 7 + + + + + + + + 0 + 0 + + + + Maximal level + + + false + + + + + + + 99 + + + + + + + Initialization of adaptation + + + + + + Nothing + + + true + + + + + + + Refinement + + + + + + + Coarsening + + + + + + + + + + Output of the level of refinement + + + + + + + Output of the qualities + + + + + + + Output of the diameters + + + + + + + Output of the parents + + + + + + + Output of the neighbours + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + 9 + + + 6 + + + + + OK + + + + + + + Apply + + + + + + + Cancel + + + + + + + Help + + + + + + + + + + + + diff --git a/src/ADAPTGUI/CreateIteration.ui b/src/ADAPTGUI/CreateIteration.ui new file mode 100644 index 000000000..2cc2827c6 --- /dev/null +++ b/src/ADAPTGUI/CreateIteration.ui @@ -0,0 +1,600 @@ + + + CreateIteration + + + + 0 + 0 + 777 + 668 + + + + + 0 + 0 + + + + + 750 + 400 + + + + + 1 + 1 + + + + + 750 + 400 + + + + Create an iteration + + + true + + + + + 0 + 0 + 773 + 664 + + + + true + + + + + + Iteration Name + + + + + + + Qt::Horizontal + + + + 117 + 20 + + + + + + + + + 290 + 21 + + + + 64 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Previous iteration + + + + + + + true + + + + 50 + 27 + + + + + + + + + + + + 0 + 21 + + + + 64 + + + true + + + + + + + Mesh n + + + + + + + Qt::Horizontal + + + + 117 + 20 + + + + + + + + + 290 + 21 + + + + 64 + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Mesh n+1 + + + + + + + Qt::Horizontal + + + + 117 + 20 + + + + + + + + + 290 + 21 + + + + 64 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Vertical + + + + 20 + 62 + + + + + + + + Field information + + + + 9 + + + 6 + + + + + + 282 + 21 + + + + + + + + Qt::Vertical + + + + 138 + 18 + + + + + + + + Chosen time step + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 255 + 13 + + + + + + + + -1 + + + 1010000 + + + -1 + + + + + + + Rank + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 13 + + + + + + + + -2 + + + 100000 + + + -1 + + + + + + + Time step + + + + + + + Qt::Vertical + + + + 138 + 28 + + + + + + + + Last time step + + + + + + + No time step + + + true + + + true + + + + + + + + + + + + + + Field file + + + + + + + + + + Qt::Horizontal + + + + 69 + 20 + + + + + + + + Qt::Vertical + + + + 20 + 22 + + + + + + + + Hypothesis + + + + 9 + + + 6 + + + + + -1 + + + QComboBox::AdjustToContents + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 13 + + + + + + + + Edit + + + + + + + New + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Vertical + + + + 20 + 21 + + + + + + + + + + + + 9 + + + 6 + + + + + OK + + + false + + + false + + + + + + + Apply + + + + + + + Cancel + + + + + + + Help + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 139 + 20 + + + + + + + + + + diff --git a/src/ADAPTGUI/CreateListGroup.ui b/src/ADAPTGUI/CreateListGroup.ui new file mode 100644 index 000000000..06c606110 --- /dev/null +++ b/src/ADAPTGUI/CreateListGroup.ui @@ -0,0 +1,121 @@ + + CreateListGroup + + + + 0 + 0 + 717 + 600 + + + + + 0 + 0 + 0 + 0 + + + + Selection of groups + + + true + + + true + + + + 9 + + + 6 + + + + + + + + + 9 + + + 6 + + + + + Help + + + + + + + Cancel + + + + + + + Apply + + + + + + + OK + + + + + + + + + + Selected groups + + + + 9 + + + 6 + + + + + true + + + 0 + + + 2 + + + + Selection + + + + + Group + + + + + + + + + + + + diff --git a/src/ADAPTGUI/CreateYACS.ui b/src/ADAPTGUI/CreateYACS.ui new file mode 100644 index 000000000..0e8f76c25 --- /dev/null +++ b/src/ADAPTGUI/CreateYACS.ui @@ -0,0 +1,526 @@ + + + CreateYACS + + + + 0 + 0 + 684 + 649 + + + + + 0 + 0 + + + + + 600 + 500 + + + + + 1 + 1 + + + + + 600 + 500 + + + + Create YACS + + + true + + + + + 0 + 0 + 680 + 645 + + + + true + + + + + + + + + Name + + + + + + + 32 + + + + + + + + + + Qt::Horizontal + + + + 131 + 20 + + + + + + + + + + Case + + + + + + + true + + + + 50 + 27 + + + + + + + + + + + + 382 + 21 + + + + + + + + + + 6 + + + 0 + + + + + Script + + + + + + + + + + false + + + + + + + + 382 + 21 + + + + + + + + + + 6 + + + 0 + + + + + Directory + + + + + + + + + + false + + + + + + + + 382 + 21 + + + + + + + + + + 6 + + + 0 + + + + + Mesh file + + + + + + + + + + false + + + + + + + + 382 + 21 + + + + + + + + + + Type of schema + + + + 6 + + + 9 + + + + + Constant + + + true + + + + + + + Variable + + + + + + + + + + Maximum of ... + + + + + + + 0 + 0 + + + + Iterations + + + false + + + + + + + 0 + + + 999999999 + + + 0 + + + + + + + + 0 + 0 + + + + Nodes + + + false + + + + + + + 0 + + + 999999999 + + + 1000 + + + 0 + + + + + + + + 0 + 0 + + + + Elements + + + false + + + + + + + 0 + + + 999999999 + + + 1000 + + + 0 + + + + + + + + + + Qt::Horizontal + + + + 269 + 20 + + + + + + + + Test of convergence + + + + + + None + + + true + + + + + + + Vtest > Vref + + + + + + + Vtest < Vref + + + + + + + Vref + + + + + + + 4 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + + + + + + + + Qt::Horizontal + + + + 269 + 20 + + + + + + + + + + + + 9 + + + 6 + + + + + Help + + + false + + + + + + + Apply + + + false + + + + + + + OK + + + false + + + + + + + Cancel + + + false + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 128 + 25 + + + + + + + + + + diff --git a/src/ADAPTGUI/CreateZone.ui b/src/ADAPTGUI/CreateZone.ui new file mode 100644 index 000000000..84a607516 --- /dev/null +++ b/src/ADAPTGUI/CreateZone.ui @@ -0,0 +1,1139 @@ + + + CreateZone + + + + 0 + 0 + 545 + 778 + + + + + 1 + 1 + + + + + 550 + 400 + + + + Create a zone + + + true + + + true + + + + + + Name + + + + + + + 32 + + + + + + + Qt::Horizontal + + + + 142 + 20 + + + + + + + + + 0 + 0 + + + + + 340 + 0 + + + + Type of zone + + + + 9 + + + 6 + + + + + Sphere + + + + ../../resources/zone_spherepoint.png../../resources/zone_spherepoint.png + + + + + + + Pipe + + + + ../../resources/pipe.png../../resources/pipe.png + + + + + + + Cylinder + + + + ../../resources/cylinderpointvector.png../../resources/cylinderpointvector.png + + + + + + + Box + + + + ../../resources/zone_boxdxyz.png../../resources/zone_boxdxyz.png + + + true + + + true + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Coordinates + + + + 9 + + + 6 + + + + + + 0 + 0 + + + + X mini + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Y mini + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Z mini + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + X maxi + + + false + + + + + + + + 0 + 0 + + + + Z maxi + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Y maxi + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + + + + 0 + 0 + + + + Coordinates + + + + 9 + + + 6 + + + + + + 0 + 0 + + + + X centre + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Y centre + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Radius + + + false + + + + + + + 5 + + + 0.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Z centre + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + + + + 0 + 0 + + + + Qt::TabFocus + + + Coordinates + + + + 9 + + + 6 + + + + + 5 + + + 1000000000.000000000000000 + + + + + + + + 0 + 0 + + + + Height + + + false + + + + + + + + 0 + 0 + + + + Radius + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Z axis + + + false + + + + + + + + 0 + 0 + + + + Y axis + + + false + + + + + + + + 0 + 0 + + + + X axis + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Y base + + + false + + + + + + + + 0 + 0 + + + + Z base + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + 5 + + + 1000000000.000000000000000 + + + + + + + + 0 + 0 + + + + X base + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + + + + 0 + 0 + + + + Coordinates + + + + 9 + + + 6 + + + + + + 0 + 0 + + + + Height + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + X base + + + false + + + + + + + 5 + + + 1000000000.000000000000000 + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Internal radius + + + false + + + + + + + + 0 + 0 + + + + Z base + + + false + + + + + + + + 0 + 0 + + + + Y base + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + X axis + + + false + + + + + + + + 0 + 0 + + + + Y axis + + + false + + + + + + + + 0 + 0 + + + + Z axis + + + false + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + 5 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.000000000000000 + + + + + + + 5 + + + 1000000000.000000000000000 + + + + + + + + 0 + 0 + + + + External radius + + + false + + + + + + + 5 + + + 1000000000.000000000000000 + + + + + + + + + + + 0 + 0 + + + + + + + + 9 + + + 6 + + + + + Help + + + + + + + Cancel + + + + + + + Apply + + + + + + + OK + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + diff --git a/src/ADAPTGUI/EditFile.ui b/src/ADAPTGUI/EditFile.ui new file mode 100644 index 000000000..bfccdc178 --- /dev/null +++ b/src/ADAPTGUI/EditFile.ui @@ -0,0 +1,115 @@ + + + EditFile + + + + 0 + 0 + 675 + 901 + + + + Edit a file + + + + 9 + + + 6 + + + + + Qt::Horizontal + + + + 331 + 49 + + + + + + + + + + + + 9 + + + 6 + + + + + Print + + + false + + + false + + + false + + + + + + + Quit + + + false + + + true + + + false + + + + + + + + + + Qt::Vertical + + + + 20 + 14 + + + + + + + + + 530 + 800 + + + + + Courier New + + + + + + + + + diff --git a/src/ADAPTGUI/HOMARDGUI_Exports.hxx b/src/ADAPTGUI/HOMARDGUI_Exports.hxx new file mode 100644 index 000000000..193b8124b --- /dev/null +++ b/src/ADAPTGUI/HOMARDGUI_Exports.hxx @@ -0,0 +1,35 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef _HOMARDGUI_EXPORTS_H_ +#define _HOMARDGUI_EXPORTS_H_ + +#ifdef WIN32 + #if defined HOMARD_EXPORTS || defined Homard_EXPORTS + #define HOMARD_EXPORT __declspec( dllexport ) + #else + #define HOMARD_EXPORT __declspec( dllimport ) + #endif +#else + #define HOMARD_EXPORT +#endif + + +#endif //_HOMARDGUI_EXPORTS_H_ + diff --git a/src/ADAPTGUI/HOMARDGUI_Utils.cxx b/src/ADAPTGUI/HOMARDGUI_Utils.cxx new file mode 100644 index 000000000..b89e4e743 --- /dev/null +++ b/src/ADAPTGUI/HOMARDGUI_Utils.cxx @@ -0,0 +1,277 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + + +#include "HOMARDGUI_Utils.h" + +#include "OB_Browser.h" + +#include "SUIT_Desktop.h" +#include "SUIT_Application.h" +#include "SUIT_Session.h" + +#include "LightApp_SelectionMgr.h" +#include "SalomeApp_Application.h" +#include "SalomeApp_Module.h" +#include "SalomeApp_Study.h" + +#include "SALOME_ListIO.hxx" + +#include "SALOMEconfig.h" +#include "utilities.h" +#include + + +#include +#include +#include +#ifndef WIN32 +#include +#endif + +SALOME_ListIO HOMARD_UTILS::mySelected; + +//================================================================ +// Function : GetActiveStudy +// Returne un pointeur sur l'etude active +//================================================================ +SUIT_Study* HOMARD_UTILS::GetActiveStudy() +{ + SUIT_Application* app = SUIT_Session::session()->activeApplication(); + if (app) + return app->activeStudy(); + else + return NULL; +} + +//================================================================ +// Function : getStudy +// Returne un pointeur sur l'etude active +//================================================================ +_PTR(Study) HOMARD_UTILS::getStudy() +{ + static _PTR(Study) _study; + if(!_study) + _study = SalomeApp_Application::getStudy(); + return _study; +} + +//================================================================ +// Function : updateObjBrowser +// Purpose : met a jour l arbre d 'etude pour Homard +//================================================================ +void HOMARD_UTILS::updateObjBrowser() +{ + SalomeApp_Application* app = dynamic_cast(SUIT_Session::session()->activeApplication()); + if (app) { + // Le nom identifiant doit etre la valeur du parametre + // name de la section HOMARD du fichier SalomeApp.xml + CAM_Module* module = app->module("Homard" ); + SalomeApp_Module* appMod = dynamic_cast( module ); + if ( appMod ) { + app->updateObjectBrowser(); + appMod->updateObjBrowser( true ); + } + else + MESSAGE( "--- ADAPT::updateObjBrowser: appMod = NULL"); + } +} + +//================================================================ +// Function : selectedIO +// Return the list of selected SALOME_InteractiveObject's +//================================================================ +const SALOME_ListIO& HOMARD_UTILS::selectedIO() +{ + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* > ( SUIT_Session::session()->activeApplication() ); + LightApp_SelectionMgr* aSelectionMgr = app->selectionMgr(); + if( aSelectionMgr ) + { + aSelectionMgr->selectedObjects( mySelected ); + for (SALOME_ListIteratorOfListIO it (mySelected); it.More(); it.Next()) + SCRUTE(it.Value()->getEntry()); + }; + return mySelected; +} + +//================================================================ +// Function : IObjectCount +// Return the number of selected objects +//================================================================ +int HOMARD_UTILS::IObjectCount() +{ + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + LightApp_SelectionMgr* aSelectionMgr = app->selectionMgr(); + if( aSelectionMgr ) + { + aSelectionMgr->selectedObjects( mySelected ); + SCRUTE(mySelected.Extent()); + return mySelected.Extent(); + } + return 0; +} + +//================================================================ +// Function : firstIObject +// Purpose : Return the first selected object in the selected object list +//================================================================ +Handle(SALOME_InteractiveObject) HOMARD_UTILS::firstIObject() +{ + const SALOME_ListIO& aList = selectedIO(); + return aList.Extent() > 0 ? aList.First() : Handle(SALOME_InteractiveObject)(); +} + +//================================================================ +// Function : lastIObject +// Return the last selected object in the selected object list +//================================================================ +Handle(SALOME_InteractiveObject) HOMARD_UTILS::lastIObject() +{ + const SALOME_ListIO& aList = selectedIO(); + return aList.Extent() > 0 ? aList.Last() : Handle(SALOME_InteractiveObject)(); +} + +//================================================================ +// Retourne vrai si l'objet est du type voulu +// . Dans le cas d'un cas, d'une hypothese, d'une zone, on se contente +// d'une comparaison simple entre le type stocke et TypeObject. +// . Pour l'iteration, le type stocke en attribut est sous la forme +// "IterationHomard" + le nom de l'iteration precedente. +// Il faut donc regarder si la chaine commence par TypeObject. +// . Idem pour le fichier de messages : "Mess " + numero d'iteration +// +// On filtre ce genre de situation avec option : +// -1 : comparaison totale +// 0 : comparaison sur le debut de la chaine +//================================================================ +bool HOMARD_UTILS::isObject(_PTR(SObject) MonObj, QString TypeObject, int option) +{ +// MESSAGE("isObject, TypeObject = "<Value().c_str()); +// MESSAGE("Type = "<moduleName(aHomardGUI->moduleName()) : QString("") ; +// // WARNING/ATTENTION : si on savait recuperer la langue depuis les preferences, on ne ferait pas le passage par argument +// // SUIT_ResourceMgr* resMgr = getApp()->resourceMgr(); +// // SUIT_ResourceMgr* resMgr = myModule->getApp()->resourceMgr(); +// // QString langue = resMgr->stringValue("language", "language", "en"); +// // QString langue = "fr" ; +// MESSAGE(". LanguageShort " << LanguageShort.toStdString().c_str()) ; +// // Complement du fichier +// QString fichier = QString(LanguageShort+"/"+monFichierAide) ; +// MESSAGE(". Appel de onHelpContextModule avec :"); +// MESSAGE(" rep = "<< rep.toStdString().c_str()); +// MESSAGE(" fichier = "<< fichier.toStdString().c_str()); +// MESSAGE(" contexte = "<< contexte.toStdString().c_str()); +// +// app->onHelpContextModule(rep, fichier, contexte); +// } +} +//========================================================================================================= diff --git a/src/ADAPTGUI/HOMARDGUI_Utils.h b/src/ADAPTGUI/HOMARDGUI_Utils.h new file mode 100644 index 000000000..a2f24a6e2 --- /dev/null +++ b/src/ADAPTGUI/HOMARDGUI_Utils.h @@ -0,0 +1,90 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HOMARD_H_UTILS +#define HOMARD_H_UTILS + +#include "HOMARDGUI_Exports.hxx" + +#include + +#include +#include CORBA_CLIENT_HEADER(HOMARD_Cas) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) + +#include "SALOMEDSClient_definitions.hxx" +#include "SALOME_InteractiveObject.hxx" +#include "LightApp_DataOwner.h" +#include "SalomeApp_Application.h" +#include + +class QString; +class QStringList; + +class SUIT_ViewWindow; +class SUIT_Desktop; +class SUIT_Study; +class SUIT_ResourceMgr; + +class CAM_Module; + +class SALOMEDSClient_Study; +class SALOMEDSClient_SObject; + +class SalomeApp_Study; +class SalomeApp_Module; +class LightApp_SelectionMgr; + +namespace HOMARD_UTILS { + + HOMARD_EXPORT SUIT_Study* GetActiveStudy(); + HOMARD_EXPORT _PTR(Study) getStudy(); + + HOMARD_EXPORT void updateObjBrowser(); + + HOMARD_EXPORT const SALOME_ListIO& selectedIO(); // Function returns a list of SALOME_InteractiveObject's from + // selection manager in GUI + + HOMARD_EXPORT int IObjectCount() ; // Function returns the number of selected objects + + HOMARD_EXPORT Handle(SALOME_InteractiveObject) firstIObject() ; + // Function returns the first selected object in the list + // of selected objects + + HOMARD_EXPORT Handle(SALOME_InteractiveObject) lastIObject() ; + // Function returns the last selected object in the list + // of selected objects + + HOMARD_EXPORT bool isBoundaryCAO(_PTR(SObject) MonObj); + HOMARD_EXPORT bool isBoundaryAn(_PTR(SObject) MonObj); + HOMARD_EXPORT bool isBoundaryDi(_PTR(SObject) MonObj); + HOMARD_EXPORT bool isCase(_PTR(SObject) MonObj); + HOMARD_EXPORT bool isHypo(_PTR(SObject) MonObj); + HOMARD_EXPORT bool isIter(_PTR(SObject) MonObj); + HOMARD_EXPORT bool isYACS(_PTR(SObject) MonObj); + HOMARD_EXPORT bool isZone(_PTR(SObject) MonObj); + HOMARD_EXPORT bool isFileType(_PTR(SObject) MonObj, QString TypeFile); + HOMARD_EXPORT bool isObject(_PTR(SObject) MonObj, QString TypeObject, int option ); + + HOMARD_EXPORT void PushOnHelp(QString monFichierAide, QString contexte, QString LanguageShort); + + extern SALOME_ListIO mySelected; +} + +#endif // ifndef HOMARD_H_UTILS diff --git a/src/ADAPTGUI/HomardQtCommun.cxx b/src/ADAPTGUI/HomardQtCommun.cxx new file mode 100644 index 000000000..a5762d03f --- /dev/null +++ b/src/ADAPTGUI/HomardQtCommun.cxx @@ -0,0 +1,453 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "HomardQtCommun.h" +#include "HOMARDGUI_Utils.h" + +#include + +#include +#include +#include +#include +#include +#ifndef WIN32 +#include +#endif +#include + + +#include "SalomeApp_Tools.h" + +using namespace std; + +#include + +// ============================================================================ +QString HOMARD_QT_COMMUN::SelectionArbreEtude(QString commentaire, int option ) +// ============================================================================ +// Retourne l'objet selectionne dans l'arbre d'etudes +// commentaire : +// . si le commentaire est une chaine vide, on ne tient pas compte du type de l'objet +// et on retourne le nom de cet objet +// . sinon : +// . si l'objet est du type defini par commentaire, retourne le nom de cet objet +// . sinon on retourne une QString("") +// option : +// . Si option = 0, ce n'est pas grave de ne rien trouver ; aucun message n'est emis +// . Si option = 1, ce n'est pas grave de ne rien trouver mais on emet un message +{ +// MESSAGE("SelectionArbreEtude : commentaire = " << commentaire.toStdString().c_str() << " et option = " << option); + int nbSel = HOMARD_UTILS::IObjectCount() ; + if ( nbSel == 0 ) + { + if ( option == 1 ) + { + QMessageBox::warning( 0, QObject::tr("HOM_WARNING"), + QObject::tr("HOM_SELECT_OBJECT_1") ); + } + return QString(""); + } + if ( nbSel > 1 ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_SELECT_OBJECT_2") ); + return QString(""); + } +// + Handle(SALOME_InteractiveObject) aIO = HOMARD_UTILS::firstIObject(); + if ( aIO->hasEntry() ) + { +// MESSAGE("aIO->getEntry() = " << aIO->getEntry()); + _PTR(Study) aStudy = HOMARD_UTILS::getStudy(); + _PTR(SObject) aSO ( aStudy->FindObjectID( aIO->getEntry() ) ); + _PTR(GenericAttribute) anAttr; + if (aSO->FindAttribute(anAttr, "AttributeComment") ) + { + if ( commentaire != "" ) + { + _PTR(AttributeComment) attributComment = anAttr; + QString aComment= QString(attributComment->Value().data()); +// MESSAGE("... aComment = " << aComment.toStdString().c_str()); + int iaux = aComment.lastIndexOf(commentaire); +// MESSAGE("... iaux = " << iaux); + if ( iaux !=0 ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_SELECT_OBJECT_3").arg(commentaire) ); + return QString(""); + } + } + if (aSO->FindAttribute(anAttr, "AttributeName") ) + { + _PTR(AttributeName) attributName = anAttr; + QString aName= QString(attributName->Value().data()); + return aName; + } + } + } +// + return QString(""); +} + +// ======================================================================= +QString HOMARD_QT_COMMUN::SelectionCasEtude() +// ======================================================================= +{ + QString aName = QString(""); + int nbSel = HOMARD_UTILS::IObjectCount() ; + if ( nbSel == 0 ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_SELECT_OBJECT_1") ); + return QString(""); + } + if ( nbSel > 1 ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_SELECT_OBJECT_2") ); + return QString(""); + } + Handle(SALOME_InteractiveObject) aIO = HOMARD_UTILS::firstIObject(); + if ( aIO->hasEntry() ) + { + _PTR(Study) aStudy = HOMARD_UTILS::getStudy(); + _PTR(SObject) aSO ( aStudy->FindObjectID( aIO->getEntry() ) ); + _PTR(SObject) aSObjCas = aSO->GetFather(); + _PTR(GenericAttribute) anAttr; + if (aSObjCas->FindAttribute(anAttr, "AttributeName") ) + { + _PTR(AttributeName) attributName = anAttr; + aName= QString(attributName->Value().data()); + } + return aName; + } + return QString(""); +} + +// ======================================================================= +QString HOMARD_QT_COMMUN::PushNomFichier(bool avertir, QString TypeFichier) +// ======================================================================= +// Gestion les boutons qui permettent de +// 1) retourne le nom d'un fichier par une fenetre de dialogue si aucun +// objet est selectionne dans l arbre d etude +// 2) retourne le nom du fichier asocie a l objet +// selectionne dans l arbre d etude +{ +// MESSAGE("PushNomFichier avec avertir "<hasEntry() ) + { + _PTR(Study) aStudy = HOMARD_UTILS::getStudy(); + _PTR(SObject) aSO ( aStudy->FindObjectID( aIO->getEntry() ) ); + _PTR(GenericAttribute) anAttr; + _PTR(AttributeFileType) aFileType; + _PTR(AttributeExternalFileDef) aFileName; + if (aSO) { + if (aSO->FindAttribute(anAttr, "AttributeFileType") ) { + aFileType=anAttr; + QString fileType=QString(aFileType->Value().data()); + if ( fileType==QString("FICHIERMED")) { + if (aSO->FindAttribute(anAttr,"AttributeExternalFileDef")) { + aFileName=anAttr; + aFile= QString(aFileName->Value().data()); } + } + } + } + } + + if ( aFile==QString::null ) + { + if ( avertir ) { + QMessageBox::warning( 0, QObject::tr("HOM_WARNING"), + QObject::tr("HOM_SELECT_STUDY") ); + } + aFile = QFileDialog::getOpenFileName(0, QObject::tr("HOM_SELECT_FILE_0"), QString(""), filtre ); + } + } + // B.3. Bizarre + else + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_SELECT_FILE_2") ); + } + + return aFile; +} +// ======================================================================= +med_idt HOMARD_QT_COMMUN::OuvrirFichier(QString aFile) +// ======================================================================= +// renvoie le medId associe au fichier Med apres ouverture +{ + med_idt medIdt = MEDfileOpen(aFile.toStdString().c_str(),MED_ACC_RDONLY); + if (medIdt <0) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_MED_FILE_1") ); + } + return medIdt; +} + +// ====================================================== +QString HOMARD_QT_COMMUN::LireNomMaillage(QString aFile) +// ======================================================== +{ + QString nomMaillage = "" ; + int erreur = 0 ; + med_idt medIdt ; + while ( erreur == 0 ) + { + // Ouverture du fichier + medIdt = HOMARD_QT_COMMUN::OuvrirFichier(aFile); + if ( medIdt < 0 ) + { + erreur = 1 ; + break ; + } + med_int numberOfMeshes = MEDnMesh(medIdt) ; + if (numberOfMeshes == 0 ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_MED_FILE_2") ); + erreur = 2 ; + break ; + } + if (numberOfMeshes > 1 ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_MED_FILE_3") ); + erreur = 3 ; + break ; + } + + nomMaillage = HOMARD_QT_COMMUN::LireNomMaillage2(medIdt,1); + break ; + } + // Fermeture du fichier + if ( medIdt > 0 ) MEDfileClose(medIdt); + + return nomMaillage; +} +// ======================================================================= +QString HOMARD_QT_COMMUN::LireNomMaillage2(med_idt medIdt ,int meshId) +// ======================================================================= +{ + QString NomMaillage=QString::null; + char meshname[MED_NAME_SIZE+1]; + med_int spacedim,meshdim; + med_mesh_type meshtype; + char descriptionription[MED_COMMENT_SIZE+1]; + char dtunit[MED_SNAME_SIZE+1]; + med_sorting_type sortingtype; + med_int nstep; + med_axis_type axistype; + int naxis = MEDmeshnAxis(medIdt,1); + char *axisname=new char[naxis*MED_SNAME_SIZE+1]; + char *axisunit=new char[naxis*MED_SNAME_SIZE+1]; + med_err aRet = MEDmeshInfo(medIdt, + meshId, + meshname, + &spacedim, + &meshdim, + &meshtype, + descriptionription, + dtunit, + &sortingtype, + &nstep, + &axistype, + axisname, + axisunit); + + if ( aRet < 0 ) { QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), \ + QObject::tr("HOM_MED_FILE_4") ); } + else { NomMaillage=QString(meshname); } + + delete[] axisname ; + delete[] axisunit ; + + return NomMaillage; +} + + +// ======================================================================= +std::list HOMARD_QT_COMMUN::GetListeChamps(QString aFile) +// ======================================================================= +{ +// Il faut voir si plusieurs maillages + + MESSAGE("GetListeChamps"); + std::list ListeChamp ; + + med_err erreur = 0 ; + med_idt medIdt ; + + while ( erreur == 0 ) + { + // Ouverture du fichier + SCRUTE(aFile.toStdString()); + medIdt = HOMARD_QT_COMMUN::OuvrirFichier(aFile); + if ( medIdt < 0 ) + { + erreur = 1 ; + break ; + } + // Lecture du nombre de champs + med_int ncha = MEDnField(medIdt) ; + if (ncha < 1 ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_MED_FILE_5") ); + erreur = 2 ; + break ; + } + // Lecture des caracteristiques des champs + for (int i=0; i< ncha; i++) + { +// Lecture du nombre de composantes + med_int ncomp = MEDfieldnComponent(medIdt,i+1); +// Lecture du type du champ, des noms des composantes et du nom de l'unite + char nomcha [MED_NAME_SIZE+1]; + char meshname[MED_NAME_SIZE+1]; + char * comp = (char*) malloc(ncomp*MED_SNAME_SIZE+1); + char * unit = (char*) malloc(ncomp*MED_SNAME_SIZE+1); + char dtunit[MED_SNAME_SIZE+1]; + med_bool local; + med_field_type typcha; + med_int nbofcstp; + erreur = MEDfieldInfo(medIdt,i+1,nomcha,meshname,&local,&typcha,comp,unit,dtunit,&nbofcstp) ; + free(comp); + free(unit); + if ( erreur < 0 ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_MED_FILE_6") ); + break ; + } + ListeChamp.push_back(QString(nomcha)); + } + break ; + } + // Fermeture du fichier + if ( medIdt > 0 ) MEDfileClose(medIdt); + + return ListeChamp; +} + +// ====================================================================================== +std::list HOMARD_QT_COMMUN::GetListeComposants(QString aFile, QString aChamp) +// ====================================================================================== +{ + MESSAGE ( "GetListeComposants pour le fichier " << aFile.toStdString().c_str()); + MESSAGE ( "GetListeComposants pour le champ " << aChamp.toStdString().c_str()); + + std::list ListeComposants; + + med_err erreur = 0 ; + med_idt medIdt ; + + while ( erreur == 0 ) + { + // Ouverture du fichier + SCRUTE(aFile.toStdString()); + medIdt = HOMARD_QT_COMMUN::OuvrirFichier(aFile); + if ( medIdt < 0 ) + { + erreur = 1 ; + break ; + } + // Lecture du nombre de champs + med_int ncha = MEDnField(medIdt) ; + if (ncha < 1 ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_MED_FILE_5") ); + erreur = 2 ; + break ; + } + // Lecture des caracteristiques des champs + for (int i=0; i< ncha; i++) + { +// Lecture du nombre de composantes + med_int ncomp = MEDfieldnComponent(medIdt,i+1); +// Lecture du type du champ, des noms des composantes et du nom de l'unite + char nomcha [MED_NAME_SIZE+1]; + char meshname[MED_NAME_SIZE+1]; + char * comp = (char*) malloc(ncomp*MED_SNAME_SIZE+1); + char * unit = (char*) malloc(ncomp*MED_SNAME_SIZE+1); + char dtunit[MED_SNAME_SIZE+1]; + med_bool local; + med_field_type typcha; + med_int nbofcstp; + erreur = MEDfieldInfo(medIdt,i+1,nomcha,meshname,&local,&typcha,comp,unit,dtunit,&nbofcstp) ; + free(unit); + if ( erreur < 0 ) + { + free(comp); + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_MED_FILE_6") ); + break ; + } + // Lecture des composantes si c'est le bon champ + if ( QString(nomcha) == aChamp ) + { + for (int j = 0; j 0 ) MEDfileClose(medIdt); + + return ListeComposants; +} diff --git a/src/ADAPTGUI/HomardQtCommun.h b/src/ADAPTGUI/HomardQtCommun.h new file mode 100644 index 000000000..32f32deff --- /dev/null +++ b/src/ADAPTGUI/HomardQtCommun.h @@ -0,0 +1,58 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HOMARDQTCOMMUN_H +#define HOMARDQTCOMMUN_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include "SALOME_Selection.h" +#include + +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) +#include CORBA_CLIENT_HEADER(HOMARD_Cas) + +#include +#include +#include + +class QComboBox; + + +namespace HOMARD_QT_COMMUN +{ + HOMARD_EXPORT QString PushNomFichier(bool avertir, QString TypeFichier=""); + HOMARD_EXPORT QString LireNomMaillage(QString aFile); + HOMARD_EXPORT QString LireNomMaillage2(med_idt Medidt,int MeshId); + + HOMARD_EXPORT med_idt OuvrirFichier(QString aFile); + + HOMARD_EXPORT std::list GetListeChamps(QString aFile); + HOMARD_EXPORT std::list GetListeComposants(QString aFile, QString aChamp); + + HOMARD_EXPORT QString SelectionArbreEtude(QString commentaire, int grave ); + HOMARD_EXPORT QString SelectionCasEtude(); + +}; + +#endif // HOMARDQTCOMMUN_H diff --git a/src/ADAPTGUI/IterInfo.ui b/src/ADAPTGUI/IterInfo.ui new file mode 100644 index 000000000..04b2664ae --- /dev/null +++ b/src/ADAPTGUI/IterInfo.ui @@ -0,0 +1,129 @@ + + + IterInfo + + + + 0 + 0 + 420 + 220 + + + + + 0 + 0 + + + + Information on a mesh + + + true + + + + + + Options + + + + + + Quality + + + + + + + Connection + + + + + + + Diametre + + + + + + + Group size + + + + + + + Entanglement + + + + + + + + + + + + + + 9 + + + 6 + + + + + Help + + + false + + + + + + + Apply + + + false + + + + + + + OK + + + false + + + + + + + Cancel + + + false + + + + + + + + + + + diff --git a/src/ADAPTGUI/MeshInfo.ui b/src/ADAPTGUI/MeshInfo.ui new file mode 100644 index 000000000..c3e55aa07 --- /dev/null +++ b/src/ADAPTGUI/MeshInfo.ui @@ -0,0 +1,285 @@ + + + MeshInfo + + + + 0 + 0 + 536 + 372 + + + + + 0 + 0 + + + + Information on a mesh + + + true + + + + + + 6 + + + 0 + + + + + Name + + + + + + + + 382 + 21 + + + + + + + + + + 6 + + + 0 + + + + + Directory + + + + + + + + + + false + + + + + + + + 382 + 21 + + + + + + + + + + Qt::Vertical + + + + 20 + 18 + + + + + + + + 6 + + + 0 + + + + + Mesh + + + + + + + + + + false + + + + + + + + 382 + 21 + + + + + + + + + + Qt::Vertical + + + + 20 + 1 + + + + + + + + Options + + + + + + Quality + + + + + + + Connection + + + + + + + Diametre + + + + + + + Group size + + + + + + + Entanglement + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + 9 + + + 6 + + + + + Help + + + false + + + + + + + Apply + + + false + + + + + + + OK + + + false + + + + + + + Cancel + + + false + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 128 + 25 + + + + + + + + + diff --git a/src/ADAPTGUI/MonCreateBoundaryAn.cxx b/src/ADAPTGUI/MonCreateBoundaryAn.cxx new file mode 100644 index 000000000..c7f79c436 --- /dev/null +++ b/src/ADAPTGUI/MonCreateBoundaryAn.cxx @@ -0,0 +1,809 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonCreateBoundaryAn.h" +#include "MonCreateCase.h" + +#include +#include + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include + +#include +#include +#include +#include +#include + +#include "math.h" +#define PI 3.141592653589793 + +using namespace std; + +// ------------------------------------------------------------------------------------------------------------------------ +MonCreateBoundaryAn::MonCreateBoundaryAn(MonCreateCase* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen0, + QString caseName) : +// ------------------------------------------------------------------------------------------------------------------------------ +/* Constructs a MonCreateBoundaryAn + appele pour une vraie creation + initialise un cylindre et non une sphere +*/ + QDialog(0), Ui_CreateBoundaryAn(), + _parent(parent), + _Name (""), + _aCaseName(caseName), + _Xmin(0), _Xmax(0), _Xincr(0), _Ymin(0), _Ymax(0), _Yincr(0), _Zmin(0), _Zmax(0), _Zincr(0), _DMax(0), + _Type(1), + _BoundaryAnXcentre(0), _BoundaryAnYcentre(0), _BoundaryAnZcentre(0), _BoundaryAnRayon(0), + _BoundaryAnXaxis(0), _BoundaryAnYaxis(0), _BoundaryAnZaxis(0), + _Xcentre(0), _Ycentre(0), _Zcentre(0), _Rayon(0), + _BoundaryAnXcone1(0), _BoundaryAnYcone1(0), _BoundaryAnZcone1(0), _BoundaryAnRayon1(0), + _BoundaryAnXcone2(0), _BoundaryAnYcone2(0), _BoundaryAnZcone2(0), _BoundaryAnRayon2(0), + _BoundaryAnXaxisCone(0), _BoundaryAnYaxisCone(0), _BoundaryAnZaxisCone(0), + _BoundaryAngle(0), + _BoundaryAnToreXcentre(0), _BoundaryAnToreYcentre(0), _BoundaryAnToreZcentre(0), + _BoundaryAnToreXaxe(0), _BoundaryAnToreYaxe(0), _BoundaryAnToreZaxe(0), + _BoundaryAnToreRRev(0), _BoundaryAnToreRPri(0), + Chgt (false) + { + MESSAGE("Constructeur") ; + myAdaptGen=ADAPT::ADAPT_Gen::_duplicate(myAdaptGen0); + setupUi(this); + setModal(modal); + + // Gestion des icones + QPixmap pix ; + QIcon IS ; + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + pix = resMgr->loadPixmap( "HOMARD", "spherepoint.png" ); + IS=QIcon(pix); + RBSphere->setIcon(IS); + pix = resMgr->loadPixmap( "HOMARD", "cylinderpointvector.png" ); + IS=QIcon(pix); + RBCylindre->setIcon(IS); + pix = resMgr->loadPixmap( "HOMARD", "cone.png" ); + IS=QIcon(pix); + RBCone->setIcon(IS); + pix = resMgr->loadPixmap( "HOMARD", "conepointvector.png" ); + IS=QIcon(pix); + RB_Def_angle->setIcon(IS); + pix = resMgr->loadPixmap( "HOMARD", "conedxyz.png" ); + IS=QIcon(pix); + RB_Def_radius->setIcon(IS); + pix = resMgr->loadPixmap( "HOMARD", "toruspointvector.png" ); + IS=QIcon(pix); + RBTore->setIcon(IS); + + InitConnect( ); + + SetNewName() ; + InitValBoundaryAn(); // Cherche les valeurs de la boite englobante le maillage + InitMinMax(); // Initialise les bornes des boutons + SetCylinder(); // Propose un cylindre en premier choix + } +// -------------------------------------------------------------------------------------------------------------- +MonCreateBoundaryAn::MonCreateBoundaryAn(MonCreateCase* parent, + ADAPT::ADAPT_Gen_var myAdaptGen0, + QString caseName): +// -------------------------------------------------------------------------------------------------------------- +// + QDialog(0), Ui_CreateBoundaryAn(), + myAdaptGen(myAdaptGen0), + _parent(parent), + _Name (""), + _aCaseName(caseName), + _Type(1), + _BoundaryAnXcentre(0), _BoundaryAnYcentre(0), _BoundaryAnZcentre(0), _BoundaryAnRayon(0), + _BoundaryAnXaxis(0), _BoundaryAnYaxis(0), _BoundaryAnZaxis(0), + // Pour affichage lors de l edition d une BoundaryAn sans nom de Cas + _Xcentre(0), _Ycentre(0), _Zcentre(0), _Rayon(0), + _Xmin(1), _Xmax(1), _Xincr(1), _Ymin(1), _Ymax(1), _Yincr(1), _Zmin(1), _Zmax(1), _Zincr(1), _DMax(1), + Chgt (false) + { + // MESSAGE("Debut de MonCreateBoundaryAn") + setupUi(this); + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + QPixmap pix = resMgr->loadPixmap( "HOMARD", "spherepoint.png" ); + QIcon IS=QIcon(pix); + RBSphere->setIcon(IS); + QPixmap pix2 = resMgr->loadPixmap( "HOMARD", "cylinderpointvector.png" ); + QIcon IS2=QIcon(pix2); + RBCylindre->setIcon(IS2); + QPixmap pix3 = resMgr->loadPixmap( "HOMARD", "cone.png" ); + QIcon IS3=QIcon(pix3); + RBCone->setIcon(IS3); + QPixmap pix4 = resMgr->loadPixmap( "HOMARD", "conepointvector.png" ); + QIcon IS4=QIcon(pix4); + RB_Def_angle->setIcon(IS4); + QPixmap pix5 = resMgr->loadPixmap( "HOMARD", "conedxyz.png" ); + QIcon IS5=QIcon(pix5); + RB_Def_radius->setIcon(IS5); + setModal(true); + InitConnect(); + } + +// ------------------------------------------------------------------------ +MonCreateBoundaryAn::~MonCreateBoundaryAn() +// ------------------------------------------------------------------------ +{ + // no need to delete child widgets, Qt does it all for us +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryAn::InitConnect() +// ------------------------------------------------------------------------ +{ + connect( RBCylindre, SIGNAL(clicked()) , this, SLOT(SetCylinder()) ) ; + connect( RBSphere, SIGNAL(clicked()) , this, SLOT(SetSphere()) ) ; + connect( RBCone, SIGNAL(clicked()) , this, SLOT(SetCone()) ) ; + connect( RB_Def_radius, SIGNAL(clicked()) , this, SLOT(SetConeR()) ); + connect( RB_Def_angle, SIGNAL(clicked()) , this, SLOT(SetConeA()) ); + connect( RBTore, SIGNAL(clicked()) , this, SLOT(SetTore()) ) ; + connect( buttonOk, SIGNAL( pressed() ), this, SLOT( PushOnOK() ) ); + connect( buttonApply, SIGNAL( pressed() ), this, SLOT( PushOnApply() ) ); + connect( buttonCancel, SIGNAL( pressed() ), this, SLOT( close() ) ); + connect( buttonHelp, SIGNAL( pressed() ), this, SLOT( PushOnHelp() ) ); +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryAn::InitValBoundaryAn() +// ------------------------------------------------------------------------ +{ +// +// 1. Les coordonnees extremes du maillage +// + if (_aCaseName == QString("")) { return; } + + ADAPT::HOMARD_Cas_var aCas = myAdaptGen->GetCase(_aCaseName.toStdString().c_str()); + ADAPT::extrema_var MesExtremes = aCas->GetBoundingBox(); + int num = MesExtremes->length() ; + ASSERT(num == 10); + _Xmin=MesExtremes[0]; _Xmax=MesExtremes[1]; _Xincr=MesExtremes[2]; + _Ymin=MesExtremes[3]; _Ymax=MesExtremes[4]; _Yincr=MesExtremes[5]; + _Zmin=MesExtremes[6]; _Zmax=MesExtremes[7]; _Zincr=MesExtremes[8]; + _DMax=MesExtremes[9]; + MESSAGE ("_Xmin : " << _Xmin << " _Xmax : " << _Xmax << " _Xincr : " << _Xincr ) ; + MESSAGE ("_Ymin : " << _Ymin << " _Ymax : " << _Ymax << " _Yincr : " << _Yincr ) ; + MESSAGE ("_Zmin : " << _Zmin << " _Zmax : " << _Zmax << " _Zincr : " << _Zincr) ; + MESSAGE ("_DMax : " << _DMax); + +// 2. Caracteristiques des frontieres +// en X + _Xcentre=(_Xmin + _Xmax)/2.; +// en Y + _Ycentre=(_Ymin + _Ymax)/2.; +// en Z + _Zcentre=(_Zmin + _Zmax)/2.; +// Rayon + _Rayon= _DMax/4.; +} + +// ------------------------------------------------------------------------ +void MonCreateBoundaryAn::InitMinMax() +// ------------------------------------------------------------------------ +{ + // Cylindre + // . X du centre + SpinBox_Xcent->setValue(_Xcentre); + SpinBox_Xcent->setSingleStep(_Xincr); + // . Y du centre + SpinBox_Ycent->setValue(_Ycentre); + SpinBox_Ycent->setSingleStep(_Yincr); + // . Z du centre + SpinBox_Zcent->setValue(_Zcentre); + SpinBox_Zcent->setSingleStep(_Zincr); + // . X de l'axe + SpinBox_Xaxis->setValue(0.); + SpinBox_Xaxis->setSingleStep(0.1); + // . Y de l'axe + SpinBox_Yaxis->setValue(0.); + SpinBox_Yaxis->setSingleStep(0.1); + // . Z de l'axe + SpinBox_Zaxis->setValue(1.); + SpinBox_Zaxis->setSingleStep(0.1); + // . Rayon + SpinBox_Radius->setValue(_Rayon); + SpinBox_Radius->setSingleStep(_Rayon/10.); + + // Sphere + // . X du centre + SpinBox_Xcentre->setValue(_Xcentre); + SpinBox_Xcentre->setSingleStep(_Xincr); + // . Y du centre + SpinBox_Ycentre->setValue(_Ycentre); + SpinBox_Ycentre->setSingleStep(_Yincr); + // . Z du centre + SpinBox_Zcentre->setValue(_Zcentre); + SpinBox_Zcentre->setSingleStep(_Zincr); + // . Rayon + SpinBox_Rayon->setValue(_Rayon); + SpinBox_Rayon->setSingleStep(_Rayon/10.); + + // Cone en rayons + // . X des centres + _BoundaryAnXcone1 = _Xcentre ; + SpinBox_Cone_X1->setSingleStep(_Xincr); + _BoundaryAnXcone2 = _Xcentre ; + SpinBox_Cone_X2->setSingleStep(_Xincr); + // . Y des centres + _BoundaryAnYcone1 = _Ycentre ; + SpinBox_Cone_Y1->setSingleStep(_Yincr); + _BoundaryAnYcone2 = _Ycentre ; + SpinBox_Cone_Y2->setSingleStep(_Yincr); + // . Z des centres + _BoundaryAnZcone1 = _Zmin ; + SpinBox_Cone_Z1->setSingleStep(_Zincr); + _BoundaryAnZcone2 = _Zmax ; + SpinBox_Cone_Z2->setSingleStep(_Zincr); + // . Rayons/Angles + _BoundaryAnRayon1 = 0. ; + _BoundaryAnRayon2 = _Rayon ; + SpinBox_Cone_V2->setSingleStep(_Rayon/10.); + + // Cone en angle + convertRayonAngle(1) ; + SpinBox_Cone_X1->setValue(_BoundaryAnXaxisCone); + SpinBox_Cone_Y1->setValue(_BoundaryAnYaxisCone); + SpinBox_Cone_Z1->setValue(_BoundaryAnZaxisCone); + SpinBox_Cone_V1->setValue(_BoundaryAngle); + SpinBox_Cone_X2->setValue(_BoundaryAnXorigCone); + SpinBox_Cone_Y2->setValue(_BoundaryAnYorigCone); + SpinBox_Cone_Z2->setValue(_BoundaryAnZorigCone); + + // Tore + // . X du centre + SpinBoxToreXcent->setValue(_Xcentre); + SpinBoxToreXcent->setSingleStep(_Xincr); + // . Y du centre + SpinBoxToreYcent->setValue(_Ycentre); + SpinBoxToreYcent->setSingleStep(_Yincr); + // . Z du centre + SpinBoxToreZcent->setValue(_Zcentre); + SpinBoxToreZcent->setSingleStep(_Zincr); + // . X de l'axe + SpinBoxToreXaxe->setValue(0.); + SpinBoxToreXaxe->setSingleStep(0.1); + // . Y de l'axe + SpinBoxToreYaxe->setValue(0.); + SpinBoxToreYaxe->setSingleStep(0.1); + // . Z de l'axe + SpinBoxToreZaxe->setValue(1.); + SpinBoxToreZaxe->setSingleStep(0.1); + // . Rayon de revolution + SpinBoxToreRRev->setValue(_Rayon); + SpinBoxToreRRev->setSingleStep(_Rayon/10.); + // . Rayon primaire + SpinBoxToreRPri->setValue(_Rayon/3.); + SpinBoxToreRPri->setSingleStep(_Rayon/20.); +} +// ------------------------------------------------------------------------ +bool MonCreateBoundaryAn::PushOnApply() +// ------------------------------------------------------------------------ +// Appele lorsque l'un des boutons Ok ou Apply est presse +// +{ + if (LEName->text().trimmed()=="") + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_BOUN_NAME") ); + return false; + } + + switch (_Type) + { + case 1 : // il s agit d un cylindre + { + if ((_BoundaryAnXcentre != SpinBox_Xcent->value()) || + (_BoundaryAnYcentre != SpinBox_Ycent->value()) || + (_BoundaryAnZcentre != SpinBox_Zcent->value()) || + (_BoundaryAnRayon != SpinBox_Radius->value()) || + (_BoundaryAnXaxis != SpinBox_Xaxis->value()) || + (_BoundaryAnYaxis != SpinBox_Yaxis->value()) || + (_BoundaryAnZaxis != SpinBox_Zaxis->value()) ) + { + Chgt = true; + _BoundaryAnXaxis= SpinBox_Xaxis->value(); + _BoundaryAnYaxis= SpinBox_Yaxis->value(); + _BoundaryAnZaxis= SpinBox_Zaxis->value(); + _BoundaryAnXcentre=SpinBox_Xcent->value(); + _BoundaryAnYcentre=SpinBox_Ycent->value(); + _BoundaryAnZcentre=SpinBox_Zcent->value(); + _BoundaryAnRayon=SpinBox_Radius->value(); + } + break; + } + + case 2 : // il s agit d une sphere + { + if ((_BoundaryAnXcentre != SpinBox_Xcentre->value()) || + (_BoundaryAnYcentre != SpinBox_Ycentre->value()) || + (_BoundaryAnZcentre != SpinBox_Zcentre->value()) || + (_BoundaryAnRayon != SpinBox_Rayon->value()) ) + { + Chgt = true; + _BoundaryAnXcentre=SpinBox_Xcentre->value(); + _BoundaryAnYcentre=SpinBox_Ycentre->value(); + _BoundaryAnZcentre=SpinBox_Zcentre->value(); + _BoundaryAnRayon=SpinBox_Rayon->value(); + } + break; + } + + case 3 : // il s agit d un cone defini par un axe et un angle + { + if ((_BoundaryAnXaxisCone != SpinBox_Cone_X1->value()) || + (_BoundaryAnYaxisCone != SpinBox_Cone_Y1->value()) || + (_BoundaryAnZaxisCone != SpinBox_Cone_Z1->value()) || + (_BoundaryAnXorigCone != SpinBox_Cone_X2->value()) || + (_BoundaryAnYorigCone != SpinBox_Cone_Y2->value()) || + (_BoundaryAnZorigCone != SpinBox_Cone_Z2->value()) || + (_BoundaryAngle != SpinBox_Cone_V1->value()) ) + { + Chgt = true; + _BoundaryAnXaxisCone = SpinBox_Cone_X1->value() ; + _BoundaryAnYaxisCone = SpinBox_Cone_Y1->value() ; + _BoundaryAnZaxisCone = SpinBox_Cone_Z1->value() ; + _BoundaryAnXorigCone = SpinBox_Cone_X2->value() ; + _BoundaryAnYorigCone = SpinBox_Cone_Y2->value() ; + _BoundaryAnZorigCone = SpinBox_Cone_Z2->value() ; + _BoundaryAngle = SpinBox_Cone_V1->value() ; + } + break; + } + + case 4 : // il s agit d un cone defini par les 2 rayons + { + if ((_BoundaryAnXcone1 != SpinBox_Cone_X1->value()) || + (_BoundaryAnYcone1 != SpinBox_Cone_Y1->value()) || + (_BoundaryAnZcone1 != SpinBox_Cone_Z1->value()) || + (_BoundaryAnRayon1 != SpinBox_Cone_V1->value()) || + (_BoundaryAnXcone2 != SpinBox_Cone_X2->value()) || + (_BoundaryAnYcone2 != SpinBox_Cone_Y2->value()) || + (_BoundaryAnZcone2 != SpinBox_Cone_Z2->value()) || + (_BoundaryAnRayon2 != SpinBox_Cone_V2->value()) ) + { + Chgt = true; + _BoundaryAnXcone1 = SpinBox_Cone_X1->value() ; + _BoundaryAnYcone1 = SpinBox_Cone_Y1->value() ; + _BoundaryAnZcone1 = SpinBox_Cone_Z1->value() ; + _BoundaryAnRayon1 = SpinBox_Cone_V1->value() ; + _BoundaryAnXcone2 = SpinBox_Cone_X2->value() ; + _BoundaryAnYcone2 = SpinBox_Cone_Y2->value() ; + _BoundaryAnZcone2 = SpinBox_Cone_Z2->value() ; + _BoundaryAnRayon2 = SpinBox_Cone_V2->value() ; + } + break; + } + case 5 : // il s agit d un tore + { + if ((_BoundaryAnToreXcentre != SpinBoxToreXcent->value()) || + (_BoundaryAnToreYcentre != SpinBoxToreYcent->value()) || + (_BoundaryAnToreZcentre != SpinBoxToreZcent->value()) || + (_BoundaryAnToreRRev != SpinBoxToreRRev->value()) || + (_BoundaryAnToreRPri != SpinBoxToreRPri->value()) || + (_BoundaryAnToreXaxe != SpinBoxToreXaxe->value()) || + (_BoundaryAnToreYaxe != SpinBoxToreYaxe->value()) || + (_BoundaryAnToreZaxe != SpinBoxToreZaxe->value()) ) + { + Chgt = true; + _BoundaryAnToreXcentre= SpinBoxToreXcent->value(); + _BoundaryAnToreYcentre= SpinBoxToreYcent->value(); + _BoundaryAnToreZcentre= SpinBoxToreZcent->value(); + _BoundaryAnToreRRev=SpinBoxToreRRev->value(); + _BoundaryAnToreRPri=SpinBoxToreRPri->value(); + _BoundaryAnToreXaxe=SpinBoxToreXaxe->value(); + _BoundaryAnToreYaxe=SpinBoxToreYaxe->value(); + _BoundaryAnToreZaxe=SpinBoxToreZaxe->value(); + } + break; + } + + } + +// Controles +// L'axe pour un cylindre + if ( _Type == 5 ) + { + double daux = _BoundaryAnXaxis*_BoundaryAnXaxis + _BoundaryAnYaxis*_BoundaryAnYaxis + _BoundaryAnZaxis*_BoundaryAnZaxis ; + if ( daux < 0.0000001 ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_AXE") ); + return false; + } + } + +// +// Création ou mise à jour de la frontière +// + bool bOK = CreateOrUpdateBoundaryAn(); + + if ( bOK ) { HOMARD_UTILS::updateObjBrowser() ; } + + return bOK; + +} +// --------------------------------------------------- +bool MonCreateBoundaryAn::CreateOrUpdateBoundaryAn() +//---------------------------------------------------- +// Creation de l'objet boundary +{ + MESSAGE("Debut de CreateOrUpdateBoundaryAn avec _Type ="<<_Type<<", _Name ="<<_Name.toStdString().c_str()<<" et LEName ="<text().trimmed().toStdString().c_str()); +// + if (_Name != LEName->text().trimmed()) + { + _Name = LEName->text().trimmed() ; + try + { + switch (_Type) + { + case 1 : // il s agit d un cylindre + { aBoundaryAn = myAdaptGen->CreateBoundaryCylinder(CORBA::string_dup(_Name.toStdString().c_str()), \ + _BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnXaxis, _BoundaryAnYaxis, _BoundaryAnZaxis, _BoundaryAnRayon ); + break; + } + case 2 : // il s agit d une sphere + { aBoundaryAn = myAdaptGen->CreateBoundarySphere(CORBA::string_dup(_Name.toStdString().c_str()), \ + _BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnRayon); + break; + } + case 3 : // il s agit d un cone defini par un axe et un angle + { aBoundaryAn = myAdaptGen->CreateBoundaryConeA(CORBA::string_dup(_Name.toStdString().c_str()), \ + _BoundaryAnXaxisCone, _BoundaryAnYaxisCone, _BoundaryAnZaxisCone, _BoundaryAngle, \ + _BoundaryAnXorigCone, _BoundaryAnYorigCone, _BoundaryAnYorigCone); + break; + } + case 4 : // il s agit d un cone defini par les 2 rayons + { aBoundaryAn = myAdaptGen->CreateBoundaryConeR(CORBA::string_dup(_Name.toStdString().c_str()), \ + _BoundaryAnXcone1, _BoundaryAnYcone1, _BoundaryAnZcone1, _BoundaryAnRayon1, \ + _BoundaryAnXcone2, _BoundaryAnYcone2, _BoundaryAnZcone2, _BoundaryAnRayon2); + break; + } + case 5 : // il s agit d un tore + { aBoundaryAn = myAdaptGen->CreateBoundaryTorus(CORBA::string_dup(_Name.toStdString().c_str()), \ + _BoundaryAnToreXcentre, _BoundaryAnToreYcentre, _BoundaryAnToreZcentre, _BoundaryAnToreXaxe, _BoundaryAnToreYaxe, _BoundaryAnToreZaxe, _BoundaryAnToreRRev, _BoundaryAnToreRPri ); + break; + } + } + } + catch( SALOME::SALOME_Exception& S_ex ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr(CORBA::string_dup(S_ex.details.text)) ); + return false ; + } + _parent->AddBoundaryAn(_Name); + + return true; + } + else { + QMessageBox::warning( 0, QObject::tr("HOM_WARNING"), + QObject::tr("HOM_SELECT_OBJECT_4") ); + return false ; + } + MESSAGE("Fin de CreateOrUpdateBoundaryAn"); +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryAn::PushOnOK() +// ------------------------------------------------------------------------ +{ + if (PushOnApply()) this->close(); +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryAn::PushOnHelp() +// ------------------------------------------------------------------------ +{ + std::string LanguageShort = myAdaptGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("un-cylindre"), QString(LanguageShort.c_str())); +} + +// ----------------------------------- +void MonCreateBoundaryAn::SetNewName() +// ----------------------------------- +{ +// Recherche d'un nom par defaut qui n'existe pas encore + + ADAPT::listeBoundarys_var MyObjects = myAdaptGen->GetAllBoundarysName(); + int num = 0; QString aName=""; + while (aName=="" ) + { + aName.setNum(num+1) ; + aName.insert(0, QString("Boun_")) ; + for ( int i=0; ilength(); i++) + { + if ( aName == QString(MyObjects[i])) + { + num ++ ; + aName = "" ; + break ; + } + } + } + LEName->setText(aName); +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryAn::SetCylinder() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetCylinder") + gBCylindre->setVisible(1); + gBSphere->setVisible(0); + gBCone->setVisible(0); + gBTore->setVisible(0); +// + _Type=1; +// + adjustSize(); +// MESSAGE("Fin de SetCylinder") +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryAn::SetSphere() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetSphere") + gBCylindre->setVisible(0); + gBSphere->setVisible(1); + gBCone->setVisible(0); + gBTore->setVisible(0); +// + _Type=2; +// + adjustSize(); +// MESSAGE("Fin de SetSphere") +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryAn::SetConeR() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetConeR") +// +// Stockage et conversion des valeurs si elles ont change + if ((_BoundaryAnXaxisCone != SpinBox_Cone_X1->value()) || + (_BoundaryAnYaxisCone != SpinBox_Cone_Y1->value()) || + (_BoundaryAnZaxisCone != SpinBox_Cone_Z1->value()) || + (_BoundaryAnXorigCone != SpinBox_Cone_X2->value()) || + (_BoundaryAnYorigCone != SpinBox_Cone_Y2->value()) || + (_BoundaryAnZorigCone != SpinBox_Cone_Z2->value()) || + (_BoundaryAngle != SpinBox_Cone_V1->value()) ) + { + MESSAGE("Stockage et conversion") + _BoundaryAnXaxisCone = SpinBox_Cone_X1->value() ; + _BoundaryAnYaxisCone = SpinBox_Cone_Y1->value() ; + _BoundaryAnZaxisCone = SpinBox_Cone_Z1->value() ; + _BoundaryAnXorigCone = SpinBox_Cone_X2->value() ; + _BoundaryAnYorigCone = SpinBox_Cone_Y2->value() ; + _BoundaryAnZorigCone = SpinBox_Cone_Z2->value() ; + _BoundaryAngle = SpinBox_Cone_V1->value() ; + convertRayonAngle(-1) ; + } +// + _Type=4; +// + TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X centre 1", 0)); + SpinBox_Cone_X1->setValue(_BoundaryAnXcone1); + TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y centre 1", 0)); + SpinBox_Cone_Y1->setValue(_BoundaryAnYcone1); + TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z centre 1", 0)); + SpinBox_Cone_Z1->setValue(_BoundaryAnZcone1); +// + TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Radius 1", 0)); + SpinBox_Cone_V1->setSingleStep(_Rayon/10.); + SpinBox_Cone_V1->setMaximum(100000.*_DMax); + SpinBox_Cone_V1->setValue(_BoundaryAnRayon1); +// + TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre 2", 0)); + SpinBox_Cone_X2->setValue(_BoundaryAnXcone2); + TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre 2", 0)); + SpinBox_Cone_Y2->setValue(_BoundaryAnYcone2); + TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre 2", 0)); + SpinBox_Cone_Z2->setValue(_BoundaryAnZcone2); +// + TLCone_V2->setVisible(1); + SpinBox_Cone_V2->setVisible(1); + TLCone_V2->setText(QApplication::translate("CreateBoundaryAn", "Radius 2", 0)); + SpinBox_Cone_V2->setValue(_BoundaryAnRayon2); +// +// MESSAGE("Fin de SetConeR") +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryAn::SetConeA() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetConeA") +// Stockage et conversion des valeurs si elles ont change + if ((_BoundaryAnXcone1 != SpinBox_Cone_X1->value()) || + (_BoundaryAnYcone1 != SpinBox_Cone_Y1->value()) || + (_BoundaryAnZcone1 != SpinBox_Cone_Z1->value()) || + (_BoundaryAnRayon1 != SpinBox_Cone_V1->value()) || + (_BoundaryAnXcone2 != SpinBox_Cone_X2->value()) || + (_BoundaryAnYcone2 != SpinBox_Cone_Y2->value()) || + (_BoundaryAnZcone2 != SpinBox_Cone_Z2->value()) || + (_BoundaryAnRayon2 != SpinBox_Cone_V2->value()) ) + { + MESSAGE("Stockage et conversion") + _BoundaryAnXcone1 = SpinBox_Cone_X1->value() ; + _BoundaryAnYcone1 = SpinBox_Cone_Y1->value() ; + _BoundaryAnZcone1 = SpinBox_Cone_Z1->value() ; + _BoundaryAnRayon1 = SpinBox_Cone_V1->value() ; + _BoundaryAnXcone2 = SpinBox_Cone_X2->value() ; + _BoundaryAnYcone2 = SpinBox_Cone_Y2->value() ; + _BoundaryAnZcone2 = SpinBox_Cone_Z2->value() ; + _BoundaryAnRayon2 = SpinBox_Cone_V2->value() ; + convertRayonAngle(1) ; + } +// + _Type=3; +// + TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X axis", 0)); + SpinBox_Cone_X1->setValue(_BoundaryAnXaxisCone); + TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y axis", 0)); + SpinBox_Cone_Y1->setValue(_BoundaryAnYaxisCone); + TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z axis", 0)); + SpinBox_Cone_Z1->setValue(_BoundaryAnZaxisCone); +// + TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre", 0)); + SpinBox_Cone_X2->setValue(_BoundaryAnXorigCone); + TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre", 0)); + SpinBox_Cone_Y2->setValue(_BoundaryAnYorigCone); + TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre", 0)); + SpinBox_Cone_Z2->setValue(_BoundaryAnZorigCone); +// + TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Angle", 0)); + SpinBox_Cone_V1->setValue(_BoundaryAngle); + SpinBox_Cone_V1->setSingleStep(1.); + SpinBox_Cone_V1->setMaximum(90.); +// + TLCone_V2->setVisible(0); + SpinBox_Cone_V2->setVisible(0); +// MESSAGE("Fin de SetConeA") +} + + +// ------------------------------------------------------------------------ +void MonCreateBoundaryAn::SetCone() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetCone") + gBCylindre->setVisible(0); + gBSphere->setVisible(0); + gBCone->setVisible(1); + gBTore->setVisible(0); +// + if ( RB_Def_radius->isChecked() ) + { + SetConeR(); + } + else + { + SetConeA(); + } +// + adjustSize(); +// MESSAGE("Fin de SetCone") +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryAn::SetTore() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetTore") + gBCylindre->setVisible(0); + gBSphere->setVisible(0); + gBCone->setVisible(0); + gBTore->setVisible(1); +// + _Type=5; +// + adjustSize(); +// MESSAGE("Fin de SetTore") +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryAn::convertRayonAngle(int option) +// ------------------------------------------------------------------------ +// Conversion entre les deux formulations du cone : +// par deux rayons ou avec un axe et un angle. +// Voir sfcoi1 de HOMARD +{ + MESSAGE("Debut de convertRayonAngle, option = "< BO = AB*RB/(RA-RB) +// Angle : tg(alpha) = RA/AO +// + double daux ; +// De rayon vers angle : + if ( option == 1 ) + { + double xa, ya, za, ra ; + double xb, yb, zb, rb ; +// Positionnement de A vers B, avec RA>RB + if ( _BoundaryAnRayon1 > _BoundaryAnRayon2 ) + { + xa = _BoundaryAnXcone1 ; + ya = _BoundaryAnYcone1 ; + za = _BoundaryAnZcone1 ; + ra = _BoundaryAnRayon1 ; + xb = _BoundaryAnXcone2 ; + yb = _BoundaryAnYcone2 ; + zb = _BoundaryAnZcone2 ; + rb = _BoundaryAnRayon2 ; + } + else + { + xa = _BoundaryAnXcone2 ; + ya = _BoundaryAnYcone2 ; + za = _BoundaryAnZcone2 ; + ra = _BoundaryAnRayon2 ; + xb = _BoundaryAnXcone1 ; + yb = _BoundaryAnYcone1 ; + zb = _BoundaryAnZcone1 ; + rb = _BoundaryAnRayon1 ; + } +// Axe : relie les deux centres, de A vers B. L'axe est normalise + _BoundaryAnXaxisCone = xb - xa ; + _BoundaryAnYaxisCone = yb - ya ; + _BoundaryAnZaxisCone = zb - za ; + daux = sqrt ( _BoundaryAnXaxisCone*_BoundaryAnXaxisCone + _BoundaryAnYaxisCone*_BoundaryAnYaxisCone + _BoundaryAnZaxisCone*_BoundaryAnZaxisCone ) ; + _BoundaryAnXaxisCone = _BoundaryAnXaxisCone/daux ; + _BoundaryAnYaxisCone = _BoundaryAnYaxisCone/daux ; + _BoundaryAnZaxisCone = _BoundaryAnZaxisCone/daux ; +// Origine + daux = daux * rb / (ra-rb) ; + _BoundaryAnXorigCone = xb + daux*_BoundaryAnXaxisCone ; + _BoundaryAnYorigCone = yb + daux*_BoundaryAnYaxisCone ; + _BoundaryAnZorigCone = zb + daux*_BoundaryAnZaxisCone ; +// Angle en degre + daux = ra / sqrt((_BoundaryAnXorigCone-xa)*(_BoundaryAnXorigCone-xa) + (_BoundaryAnYorigCone-ya)*(_BoundaryAnYorigCone-ya) + (_BoundaryAnZorigCone-za)*(_BoundaryAnZorigCone-za) ) ; + _BoundaryAngle = atan(daux)*180./PI ; + } +// D'angle vers rayon : + else + { + double xax, yax, zax ; +// L'axe est normalise + daux = sqrt ( _BoundaryAnXaxisCone*_BoundaryAnXaxisCone + _BoundaryAnYaxisCone*_BoundaryAnYaxisCone + _BoundaryAnZaxisCone*_BoundaryAnZaxisCone ) ; + xax = _BoundaryAnXaxisCone/daux ; + yax = _BoundaryAnYaxisCone/daux ; + zax = _BoundaryAnZaxisCone/daux ; +// Centre 1 : l'origine + _BoundaryAnXcone1 = _BoundaryAnXorigCone ; + _BoundaryAnYcone1 = _BoundaryAnYorigCone ; + _BoundaryAnZcone1 = _BoundaryAnZorigCone ; +// Rayon 1 : nul + _BoundaryAnRayon1 = 0. ; +// Centre 2 : l'origine decalee d'une longueur arbitraire le long de l'axe + _BoundaryAnXcone2 = _BoundaryAnXorigCone + _DMax*xax ; + _BoundaryAnYcone2 = _BoundaryAnYorigCone + _DMax*yax ; + _BoundaryAnZcone2 = _BoundaryAnZorigCone + _DMax*zax ; +// Rayon 2 : a calculer + _BoundaryAnRayon2 = _DMax*tan(_BoundaryAngle*PI/180.) ; + } +// MESSAGE("Fin de convertRayonAngle") +} + + diff --git a/src/ADAPTGUI/MonCreateBoundaryAn.h b/src/ADAPTGUI/MonCreateBoundaryAn.h new file mode 100644 index 000000000..daadd6560 --- /dev/null +++ b/src/ADAPTGUI/MonCreateBoundaryAn.h @@ -0,0 +1,96 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_CREATEBOUNDARYAN_H +#define MON_CREATEBOUNDARYAN_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) +#include CORBA_CLIENT_HEADER(HOMARD_Boundary) + +#include "ui_CreateBoundaryAn.h" +#include + +class MonCreateCase; +class HOMARD_EXPORT MonCreateBoundaryAn : public QDialog, public Ui_CreateBoundaryAn +{ + Q_OBJECT + +public: + MonCreateBoundaryAn( MonCreateCase* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString caseName); + virtual ~MonCreateBoundaryAn(); + +protected : + MonCreateBoundaryAn( MonCreateCase* parent, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString caseName); + + MonCreateCase * _parent; + + QString _Name; + QString _aCaseName; + + int _Type; + double _BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnRayon; + double _BoundaryAnXaxis, _BoundaryAnYaxis, _BoundaryAnZaxis; + double _Xcentre, _Ycentre, _Zcentre, _Rayon ; + double _Xmin, _Xmax, _Xincr, _Ymin, _Ymax, _Yincr, _Zmin, _Zmax, _Zincr, _DMax ; + double _BoundaryAnXcone1, _BoundaryAnYcone1, _BoundaryAnZcone1, _BoundaryAnRayon1; + double _BoundaryAnXcone2, _BoundaryAnYcone2, _BoundaryAnZcone2, _BoundaryAnRayon2; + double _BoundaryAnXaxisCone, _BoundaryAnYaxisCone, _BoundaryAnZaxisCone; + double _BoundaryAnXorigCone, _BoundaryAnYorigCone, _BoundaryAnZorigCone; + double _BoundaryAngle; + double _BoundaryAnToreXcentre, _BoundaryAnToreYcentre, _BoundaryAnToreZcentre; + double _BoundaryAnToreXaxe, _BoundaryAnToreYaxe, _BoundaryAnToreZaxe; + double _BoundaryAnToreRRev, _BoundaryAnToreRPri; + + + bool Chgt; + + ADAPT::HOMARD_Boundary_var aBoundaryAn ; + ADAPT::ADAPT_Gen_var myAdaptGen; + + virtual void InitConnect(); + virtual void InitValBoundaryAn(); + virtual void InitMinMax(); + virtual void SetNewName(); + virtual bool CreateOrUpdateBoundaryAn(); + virtual void convertRayonAngle(int option); + +public slots: + virtual void SetCylinder(); + virtual void SetSphere(); + virtual void SetCone(); + virtual void SetConeR(); + virtual void SetConeA(); + virtual void SetTore(); + virtual void PushOnOK(); + virtual bool PushOnApply(); + virtual void PushOnHelp(); + +}; + +#endif // MON_CREATEBOUNDARYAN_H diff --git a/src/ADAPTGUI/MonCreateBoundaryCAO.cxx b/src/ADAPTGUI/MonCreateBoundaryCAO.cxx new file mode 100644 index 000000000..aa3246e43 --- /dev/null +++ b/src/ADAPTGUI/MonCreateBoundaryCAO.cxx @@ -0,0 +1,202 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonCreateBoundaryCAO.h" +#include "MonCreateListGroupCAO.h" +#include "MonCreateCase.h" + +#include +#include + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include + +using namespace std; + +// ------------------------------------------------------------------------------- +MonCreateBoundaryCAO::MonCreateBoundaryCAO(MonCreateCase* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen0, + QString caseName, QString aName) +// --------------------------------------------------------------------------------- +/* Constructs a MonCreateBoundaryCAO */ + : + QDialog(0), Ui_CreateBoundaryCAO(), + _parent(parent), _aName(aName), + myAdaptGen(ADAPT::ADAPT_Gen::_duplicate(myAdaptGen0)), + _aCaseName(caseName) + { + MESSAGE("Constructeur") ; + setupUi(this); + setModal(modal); + InitConnect(); + + if ( _aName == QString("") ) {SetNewName();}; + } + +// ------------------------------------------------------------------------ +MonCreateBoundaryCAO::~MonCreateBoundaryCAO() +// ------------------------------------------------------------------------ +{ + // no need to delete child widgets, Qt does it all for us +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryCAO::InitConnect() +// ------------------------------------------------------------------------ +{ + connect( PushFichier, SIGNAL(pressed()), this, SLOT(SetCAOFile())); + connect( buttonOk, SIGNAL(pressed()), this, SLOT( PushOnOK())); + connect( buttonApply, SIGNAL(pressed()), this, SLOT( PushOnApply())); + connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close())); + connect( buttonHelp, SIGNAL(pressed()), this, SLOT( PushOnHelp())); + connect( CBGroupe, SIGNAL(stateChanged(int)), this, SLOT( SetFiltrage())); +} + +// ------------------------------------------------------------------------ +bool MonCreateBoundaryCAO::PushOnApply() +// ------------------------------------------------------------------------ +// Appele lorsque l'un des boutons Ok ou Apply est presse +// +{ +// Verifications + + QString aName=LEName->text().trimmed(); + if (aName=="") { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_BOUN_NAME") ); + return false; + } + +// La CAO + QString aCAOFile=LEFileName->text().trimmed(); + if (aCAOFile ==QString("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_BOUN_CAO") ); + return false; + } + +// Creation de l'objet CORBA si ce n'est pas deja fait sous le meme nom + if ( _aName != aName ) + { + try + { + _aName=aName; + aBoundary=myAdaptGen->CreateBoundaryCAO(CORBA::string_dup(_aName.toStdString().c_str()), aCAOFile.toStdString().c_str()); + _parent->AddBoundaryCAO(_aName); + aBoundary->SetCaseCreation(_aCaseName.toStdString().c_str()); + } + catch( SALOME::SALOME_Exception& S_ex ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr(CORBA::string_dup(S_ex.details.text)) ); + return false; + } + } + +// Les groupes + AssocieLesGroupes(); + + HOMARD_UTILS::updateObjBrowser(); + return true; +} + + +// ------------------------------------------------------------------------ +void MonCreateBoundaryCAO::PushOnOK() +// ------------------------------------------------------------------------ +{ + if (PushOnApply()) this->close(); + if ( _parent ) { _parent->raise(); _parent->activateWindow(); }; +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryCAO::PushOnHelp() +// ------------------------------------------------------------------------ +{ + std::string LanguageShort = myAdaptGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("CAO"), QString(LanguageShort.c_str())); +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryCAO::AssocieLesGroupes() +// ------------------------------------------------------------------------ +{ + ADAPT::ListGroupType_var aSeqGroupe = new ADAPT::ListGroupType; + aSeqGroupe->length(_listeGroupesBoundary.size()); + QStringList::const_iterator it; + int i=0; + for (it = _listeGroupesBoundary.constBegin(); it != _listeGroupesBoundary.constEnd(); it++) + aSeqGroupe[i++]=(*it).toStdString().c_str(); + aBoundary->SetGroups(aSeqGroupe); + +} + +// ------------------------------------------------- +void MonCreateBoundaryCAO::SetNewName() +// -------------------------------------------------- +{ + + ADAPT::listeBoundarys_var MyObjects = myAdaptGen->GetAllBoundarysName(); + int num = 0; QString aName=""; + while (aName == QString("") ) + { + aName.setNum(num+1) ; + aName.insert(0, QString("Boun_")) ; + for ( int i=0; ilength(); i++) + { + if ( aName == QString(MyObjects[i])) + { + num ++ ; + aName = "" ; + break ; + } + } + } + LEName->setText(aName); +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryCAO::SetCAOFile() +// ------------------------------------------------------------------------ +{ + QString aCAOFile = HOMARD_QT_COMMUN::PushNomFichier( false, QString("xao") ); + if (!(aCAOFile.isEmpty())) LEFileName->setText(aCAOFile); +} + +// ------------------------------------------------------------------------ +void MonCreateBoundaryCAO::setGroups (QStringList listGroup) +// ------------------------------------------------------------------------ +{ + _listeGroupesBoundary = listGroup; +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryCAO::SetFiltrage() +// // ------------------------------------------------------------------------ +{ + if (!CBGroupe->isChecked()) return; + if (_aCaseName.toStdString().c_str() == QString()) { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_BOUN_CASE") ); + return; + } + + MonCreateListGroupCAO *aDlg = new MonCreateListGroupCAO(NULL, this, true, ADAPT::ADAPT_Gen::_duplicate(myAdaptGen), + _aCaseName, _listeGroupesBoundary) ; + aDlg->show(); +} + diff --git a/src/ADAPTGUI/MonCreateBoundaryCAO.h b/src/ADAPTGUI/MonCreateBoundaryCAO.h new file mode 100644 index 000000000..26b11f883 --- /dev/null +++ b/src/ADAPTGUI/MonCreateBoundaryCAO.h @@ -0,0 +1,73 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_CREATEBOUNDARYCAO_H +#define MON_CREATEBOUNDARYCAO_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) +#include CORBA_CLIENT_HEADER(HOMARD_Boundary) + +#include "ui_CreateBoundaryCAO.h" +#include + +class MonCreateCase; +class HOMARD_EXPORT MonCreateBoundaryCAO : public QDialog, public Ui_CreateBoundaryCAO +{ + Q_OBJECT + +public: + MonCreateBoundaryCAO( MonCreateCase* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString caseName, QString BoundaryName ); + ~MonCreateBoundaryCAO(); + virtual void setGroups (QStringList listGroup); + +protected : + + MonCreateCase *_parent; + + QString _aName; + QString _aCaseName; + + + ADAPT::HOMARD_Boundary_var aBoundary; + ADAPT::ADAPT_Gen_var myAdaptGen; + + QStringList _listeGroupesBoundary; + + virtual void AssocieLesGroupes(); + virtual void InitConnect(); + virtual void SetNewName(); + +public slots: + + virtual void SetCAOFile(); + virtual void SetFiltrage(); + virtual void PushOnOK(); + virtual bool PushOnApply(); + virtual void PushOnHelp(); +}; + +#endif // MON_CREATEBOUNDARYCAO_H diff --git a/src/ADAPTGUI/MonCreateBoundaryDi.cxx b/src/ADAPTGUI/MonCreateBoundaryDi.cxx new file mode 100644 index 000000000..5d551a1e5 --- /dev/null +++ b/src/ADAPTGUI/MonCreateBoundaryDi.cxx @@ -0,0 +1,211 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonCreateBoundaryDi.h" +#include "MonCreateListGroup.h" +#include "MonCreateCase.h" + +#include +#include + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include + +using namespace std; + +// ------------------------------------------------------------------------------- +MonCreateBoundaryDi::MonCreateBoundaryDi(MonCreateCase* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen0, + QString caseName, QString aName) +// --------------------------------------------------------------------------------- +/* Constructs a MonCreateBoundaryDi */ + : + QDialog(0), Ui_CreateBoundaryDi(), + _parent(parent), _aName(aName), + myAdaptGen(ADAPT::ADAPT_Gen::_duplicate(myAdaptGen0)), + _aCaseName(caseName) + { + MESSAGE("Constructeur") ; + setupUi(this); + setModal(modal); + InitConnect(); + + if ( _aName == QString("") ) {SetNewName();}; + } + +// ------------------------------------------------------------------------ +MonCreateBoundaryDi::~MonCreateBoundaryDi() +// ------------------------------------------------------------------------ +{ + // no need to delete child widgets, Qt does it all for us +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryDi::InitConnect() +// ------------------------------------------------------------------------ +{ + connect( PushFichier, SIGNAL(pressed()), this, SLOT(SetMeshFile())); + connect( buttonOk, SIGNAL(pressed()), this, SLOT( PushOnOK())); + connect( buttonApply, SIGNAL(pressed()), this, SLOT( PushOnApply())); + connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close())); + connect( buttonHelp, SIGNAL(pressed()), this, SLOT( PushOnHelp())); + connect( CBGroupe, SIGNAL(stateChanged(int)), this, SLOT( SetFiltrage())); +} + +// ------------------------------------------------------------------------ +bool MonCreateBoundaryDi::PushOnApply() +// ------------------------------------------------------------------------ +// Appele lorsque l'un des boutons Ok ou Apply est presse +// +{ +// Verifications + + QString aName=LEName->text().trimmed(); + if (aName=="") { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_BOUN_NAME") ); + return false; + } + +// Le maillage de la frontiere discrete + QString aMeshFile=LEFileName->text().trimmed(); + if (aMeshFile ==QString("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_BOUN_MESH") ); + return false; + } + +// Le nom du maillage de la frontiere discrete + QString aMeshName = HOMARD_QT_COMMUN::LireNomMaillage(aMeshFile); + if (aMeshName == "" ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_MED_FILE_2") ); + return false; + } + +// Creation de l'objet CORBA si ce n'est pas deja fait sous le meme nom + if ( _aName != aName ) + { + try + { + _aName=aName; + aBoundary=myAdaptGen->CreateBoundaryDi(CORBA::string_dup(_aName.toStdString().c_str()), aMeshName.toStdString().c_str(), aMeshFile.toStdString().c_str()); + _parent->AddBoundaryDi(_aName); + aBoundary->SetCaseCreation(_aCaseName.toStdString().c_str()); + } + catch( SALOME::SALOME_Exception& S_ex ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr(CORBA::string_dup(S_ex.details.text)) ); + return false; + } + } + +// Les groupes + AssocieLesGroupes(); + + HOMARD_UTILS::updateObjBrowser(); + return true; +} + + +// ------------------------------------------------------------------------ +void MonCreateBoundaryDi::PushOnOK() +// ------------------------------------------------------------------------ +{ + if (PushOnApply()) this->close(); + if ( _parent ) { _parent->raise(); _parent->activateWindow(); }; +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryDi::PushOnHelp() +// ------------------------------------------------------------------------ +{ + std::string LanguageShort = myAdaptGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("frontiere-discrete"), QString(LanguageShort.c_str())); +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryDi::AssocieLesGroupes() +// ------------------------------------------------------------------------ +{ + ADAPT::ListGroupType_var aSeqGroupe = new ADAPT::ListGroupType; + aSeqGroupe->length(_listeGroupesBoundary.size()); + QStringList::const_iterator it; + int i=0; + for (it = _listeGroupesBoundary.constBegin(); it != _listeGroupesBoundary.constEnd(); it++) + aSeqGroupe[i++]=(*it).toStdString().c_str(); + aBoundary->SetGroups(aSeqGroupe); + +} + +// ------------------------------------------------- +void MonCreateBoundaryDi::SetNewName() +// -------------------------------------------------- +{ + + ADAPT::listeBoundarys_var MyObjects = myAdaptGen->GetAllBoundarysName(); + int num = 0; QString aName=""; + while (aName == QString("") ) + { + aName.setNum(num+1) ; + aName.insert(0, QString("Boun_")) ; + for ( int i=0; ilength(); i++) + { + if ( aName == QString(MyObjects[i])) + { + num ++ ; + aName = "" ; + break ; + } + } + } + LEName->setText(aName); +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryDi::SetMeshFile() +// ------------------------------------------------------------------------ +{ + QString aMeshFile = HOMARD_QT_COMMUN::PushNomFichier( false, QString("med") ); + if (!(aMeshFile.isEmpty())) LEFileName->setText(aMeshFile); +} + +// ------------------------------------------------------------------------ +void MonCreateBoundaryDi::setGroups (QStringList listGroup) +// ------------------------------------------------------------------------ +{ + _listeGroupesBoundary = listGroup; +} +// ------------------------------------------------------------------------ +void MonCreateBoundaryDi::SetFiltrage() +// // ------------------------------------------------------------------------ +{ + if (!CBGroupe->isChecked()) return; + if (_aCaseName.toStdString().c_str() == QString()) { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_BOUN_CASE") ); + return; + } + + MonCreateListGroup *aDlg = new MonCreateListGroup(NULL, this, true, ADAPT::ADAPT_Gen::_duplicate(myAdaptGen), + _aCaseName, _listeGroupesBoundary) ; + aDlg->show(); +} + diff --git a/src/ADAPTGUI/MonCreateBoundaryDi.h b/src/ADAPTGUI/MonCreateBoundaryDi.h new file mode 100644 index 000000000..b26496321 --- /dev/null +++ b/src/ADAPTGUI/MonCreateBoundaryDi.h @@ -0,0 +1,73 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_CREATEBOUNDARYDI_H +#define MON_CREATEBOUNDARYDI_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) +#include CORBA_CLIENT_HEADER(HOMARD_Boundary) + +#include "ui_CreateBoundaryDi.h" +#include + +class MonCreateCase; +class HOMARD_EXPORT MonCreateBoundaryDi : public QDialog, public Ui_CreateBoundaryDi +{ + Q_OBJECT + +public: + MonCreateBoundaryDi( MonCreateCase* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString caseName, QString BoundaryName ); + ~MonCreateBoundaryDi(); + virtual void setGroups (QStringList listGroup); + +protected : + + MonCreateCase *_parent; + + QString _aName; + QString _aCaseName; + + + ADAPT::HOMARD_Boundary_var aBoundary; + ADAPT::ADAPT_Gen_var myAdaptGen; + + QStringList _listeGroupesBoundary; + + virtual void AssocieLesGroupes(); + virtual void InitConnect(); + virtual void SetNewName(); + +public slots: + + virtual void SetMeshFile(); + virtual void SetFiltrage(); + virtual void PushOnOK(); + virtual bool PushOnApply(); + virtual void PushOnHelp(); +}; + +#endif // MON_CREATEBOUNDARYDI_H diff --git a/src/ADAPTGUI/MonCreateCase.cxx b/src/ADAPTGUI/MonCreateCase.cxx new file mode 100644 index 000000000..65e3f4adf --- /dev/null +++ b/src/ADAPTGUI/MonCreateCase.cxx @@ -0,0 +1,694 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonCreateCase.h" +#include "MonCreateBoundaryCAO.h" +#include "MonEditBoundaryCAO.h" +#include "MonCreateBoundaryAn.h" +#include "MonEditBoundaryAn.h" +#include "MonCreateBoundaryDi.h" +#include "MonEditBoundaryDi.h" +#include "HOMARD.hxx" + +#include +#include + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include + +#ifdef WIN32 +#include +#endif + +using namespace std; + +// ----------------------------------------------------------------------------------------- +/* Constructs a MonCreateCase + * Inherits from CasHomard + * Sets attributes to default values + */ +// ----------------------------------------------------------------------------------------- +MonCreateCase::MonCreateCase( bool modal, ADAPT::ADAPT_Gen_var myAdaptGen0 ) + : + Ui_CreateCase(), + _aCaseName(""),_aDirName(""), + _ConfType(0), + _ExtType(0), + _Pyram(0) +{ + MESSAGE("Debut du constructeur de MonCreateCase"); + myAdaptGen=ADAPT::ADAPT_Gen::_duplicate(myAdaptGen0); + setupUi(this); + setModal(modal); + InitConnect(); + + SetNewName() ; + + GBBoundaryC->setVisible(0); + GBBoundaryA->setVisible(0); + GBBoundaryD->setVisible(0); + + CBBoundaryA->setVisible(0); + CBBoundaryD->setVisible(0); + + GBAdvancedOptions->setVisible(0); + Comment->setVisible(0); + CBPyramid->setChecked(false); +// + adjustSize(); + +// MESSAGE("Fin du constructeur de MonCreateCase"); +} +// ------------------------------------------------------------------------ +MonCreateCase::~MonCreateCase() +// ------------------------------------------------------------------------ +{ + // no need to delete child widgets, Qt does it all for us +} +// ------------------------------------------------------------------------ +void MonCreateCase::InitConnect() +// ------------------------------------------------------------------------ +{ + connect( LEName, SIGNAL(textChanged(QString)), this, SLOT(CaseNameChanged())); + connect( PushDir, SIGNAL(pressed()), this, SLOT(SetDirName())); + connect( PushFichier, SIGNAL(pressed()), this, SLOT(SetFileName())); + + connect( RBConforme, SIGNAL(clicked()), this, SLOT(SetConforme())); + connect( RBNonConforme, SIGNAL(clicked()), this, SLOT(SetNonConforme())); + + connect( RBBoundaryNo, SIGNAL(clicked()), this, SLOT(SetBoundaryNo())); + connect( RBBoundaryCAO, SIGNAL(clicked()), this, SLOT(SetBoundaryCAO())); + connect( RBBoundaryNonCAO, SIGNAL(clicked()), this, SLOT(SetBoundaryNonCAO())); + + connect( PBBoundaryCAONew, SIGNAL(pressed()), this, SLOT(PushBoundaryCAONew())); + connect( PBBoundaryCAOEdit, SIGNAL(pressed()), this, SLOT(PushBoundaryCAOEdit()) ); + connect( PBBoundaryCAOHelp, SIGNAL(pressed()), this, SLOT(PushBoundaryCAOHelp()) ); + connect( CBBoundaryD, SIGNAL(stateChanged(int)), this, SLOT(SetBoundaryD())); + connect( PBBoundaryDiNew, SIGNAL(pressed()), this, SLOT(PushBoundaryDiNew())); + connect( PBBoundaryDiEdit, SIGNAL(pressed()), this, SLOT(PushBoundaryDiEdit()) ); + connect( PBBoundaryDiHelp, SIGNAL(pressed()), this, SLOT(PushBoundaryDiHelp()) ); + connect( CBBoundaryA, SIGNAL(stateChanged(int)), this, SLOT(SetBoundaryA())); + connect( PBBoundaryAnNew, SIGNAL(pressed()), this, SLOT(PushBoundaryAnNew())); + connect( PBBoundaryAnEdit, SIGNAL(pressed()), this, SLOT(PushBoundaryAnEdit()) ); + connect( PBBoundaryAnHelp, SIGNAL(pressed()), this, SLOT(PushBoundaryAnHelp()) ); + + connect( CBAdvanced, SIGNAL(stateChanged(int)), this, SLOT(SetAdvanced())); + connect( RBStandard, SIGNAL(clicked()), this, SLOT(SetStandard())); + connect( RBBox, SIGNAL(clicked()), this, SLOT(SetBox())); + connect( RBNC1NpA, SIGNAL(clicked()), this, SLOT(SetNC1NpA())); + connect( RBNCQuelconque, SIGNAL(clicked()), this, SLOT(SetNCQuelconque())); + + connect( RBMED, SIGNAL(clicked()), this, SLOT(SetMED())); + connect( RBSaturne, SIGNAL(clicked()), this, SLOT(SetSaturne())); + connect( RBSaturne2D, SIGNAL(clicked()), this, SLOT(SetSaturne2D())); + + connect( buttonOk, SIGNAL(pressed()), this, SLOT(PushOnOK())); + connect( buttonApply, SIGNAL(pressed()), this, SLOT(PushOnApply(0))); + connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close())); + connect( buttonHelp, SIGNAL(pressed()), this, SLOT(PushOnHelp())); +} +// ------------------------------------------------------------------------ +void MonCreateCase::InitBoundarys() +// ------------------------------------------------------------------------ +// Initialisation des menus avec les frontieres deja enregistrees +{ + MESSAGE("InitBoundarys"); +// Pour les frontieres analytiques : la colonne des groupes + ADAPT::ListGroupType_var _listeGroupesCas = aCase->GetGroups(); + QTableWidgetItem *__colItem = new QTableWidgetItem(); + __colItem->setText(QApplication::translate("CreateCase", "", 0)); + TWBoundary->setHorizontalHeaderItem(0, __colItem); + for ( int i = 0; i < _listeGroupesCas->length(); i++ ) + { + TWBoundary->insertRow(i); + TWBoundary->setItem( i, 0, new QTableWidgetItem(QString((_listeGroupesCas)[i]).trimmed())); + TWBoundary->item( i, 0 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable ); + } +// Pour les frontieres CAO : la liste a saisir +// Pour les frontieres discretes : la liste a saisir +// Pour les frontieres analytiques : les colonnes de chaque frontiere + ADAPT::HOMARD_Boundary_var myBoundary ; + ADAPT::listeBoundarys_var mesBoundarys = myAdaptGen->GetAllBoundarysName(); +// MESSAGE("Nombre de frontieres enregistrees : "<length()); + for (int i=0; ilength(); i++) + { + myBoundary = myAdaptGen->GetBoundary(mesBoundarys[i]); + int type_obj = myBoundary->GetType() ; + if ( type_obj==-1 ) { CBBoundaryCAO->addItem(QString(mesBoundarys[i])); } + else if ( type_obj==0 ) { CBBoundaryDi->addItem(QString(mesBoundarys[i])); } + else { AddBoundaryAn(QString(mesBoundarys[i])); } + } +// Ajustement + TWBoundary->resizeColumnsToContents(); + TWBoundary->resizeRowsToContents(); + TWBoundary->clearSelection(); +} +// ------------------------------- +bool MonCreateCase::PushOnApply(int option) +// -------------------------------- +{ + MESSAGE("PushOnApply"); + QString aCaseName=LEName->text().trimmed(); + if ( aCaseName == "" ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_CASE_NAME") ); + return false; + } + + QString aDirName=LEDirName->text().trimmed(); + if (aDirName == QString("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_CASE_DIRECTORY_1") ); + return false; + } + + if ( aDirName != _aDirName) + { QString CaseNameDir = myAdaptGen->VerifieDir( aDirName.toStdString().c_str()) ; + if ( ( CaseNameDir != "" ) & ( CaseNameDir != aCaseName ) ) + { + QString texte ; + texte = QObject::tr("HOM_CASE_DIRECTORY_2") + CaseNameDir ; + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + texte ); + return false; + } + } + if (CHDIR(aDirName.toStdString().c_str()) != 0) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_CASE_DIRECTORY_3") ); + return false; + } + + QString aFileName=LEFileName->text().trimmed(); + if (aFileName ==QString("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_CASE_MESH") ); + return false; + } + + QString aMeshName = HOMARD_QT_COMMUN::LireNomMaillage(aFileName); + if (aMeshName == "" ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_MED_FILE_2") ); + return false; + } + +// On verifie qu'un groupe n'est pas associe a deux frontieres differentes + if (CBBoundaryA->isChecked()) + { + QStringList ListeGroup ; + QString NomGroup ; + int nbcol = TWBoundary->columnCount(); + int nbrow = TWBoundary->rowCount(); + for ( int col=1; col< nbcol; col++) + { + for ( int row=0; row< nbrow; row++) + { + if ( TWBoundary->item( row, col )->checkState() == Qt::Checked ) + { +// Nom du groupe + NomGroup = QString(TWBoundary->item(row, 0)->text()) ; +// MESSAGE("NomGroup "<CreateCase( \ + CORBA::string_dup(_aCaseName.toStdString().c_str()), \ + CORBA::string_dup(aMeshName.toStdString().c_str()), \ + CORBA::string_dup(aFileName.toStdString().c_str()) ); + } + catch( SALOME::SALOME_Exception& S_ex ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr(CORBA::string_dup(S_ex.details.text)) ); + return false; + } + LEFileName->setReadOnly(true); + PushFichier->hide(); + InitBoundarys(); + } + +// Repertoire et type + aCase->SetDirName(aDirName.toStdString().c_str()); + _aDirName=aDirName; + aCase->SetConfType(_ConfType); + aCase->SetExtType(_ExtType); + +// Menage des eventuelles frontieres deja enregistrees + aCase->SupprBoundaryGroup() ; + + // Enregistrement et publication dans l'arbre d'etudes a la sortie definitive + if ( option > 0 ) + { + if (RBBoundaryCAO->isChecked()) + { + QString monBoundaryCAOName=CBBoundaryCAO->currentText(); + if (monBoundaryCAOName != "" ) + { + aCase->AddBoundary(monBoundaryCAOName.toStdString().c_str()); + } + } + if (CBBoundaryD->isChecked()) + { + QString monBoundaryDiName=CBBoundaryDi->currentText(); + if (monBoundaryDiName != "" ) + { + aCase->AddBoundary(monBoundaryDiName.toStdString().c_str()); + } + } + if (CBBoundaryA->isChecked()) + { + QString NomGroup ; + int nbcol = TWBoundary->columnCount(); + int nbrow = TWBoundary->rowCount(); + for ( int col=1; col< nbcol; col++) + { + for ( int row=0; row< nbrow; row++) + { + if ( TWBoundary->item( row, col )->checkState() == Qt::Checked ) + { + // Nom du groupe + NomGroup = QString(TWBoundary->item(row, 0)->text()) ; + // Nom de la frontiere + QTableWidgetItem *__colItem = new QTableWidgetItem(); + __colItem = TWBoundary->horizontalHeaderItem(col); + aCase->AddBoundaryGroup(QString(__colItem->text()).toStdString().c_str(), NomGroup.toStdString().c_str()); + } + } + } + } + } + + +// Options avancees + if (CBAdvanced->isChecked()) + { +// Autorisation des pyramides + if (CBPyramid->isChecked()) { _Pyram = 1 ; } + } + aCase->SetPyram(_Pyram); + + HOMARD_UTILS::updateObjBrowser(); + + return true; +} +// --------------------------- +void MonCreateCase::PushOnOK() +// --------------------------- +{ + bool bOK = PushOnApply(1); + if ( bOK ) this->close(); +} +//------------------------------ +void MonCreateCase::PushOnHelp() +//------------------------------- +{ + std::string LanguageShort = myAdaptGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_case.html"), QString(""), QString(LanguageShort.c_str())); +} +// --------------------------------- +void MonCreateCase::SetNewName() +// ------------------------------ +{ + ADAPT::listeCases_var MyCases = myAdaptGen->GetAllCasesName(); + int num = 0; QString aCaseName=""; + while (aCaseName=="" ) + { + aCaseName.setNum(num+1) ; + aCaseName.insert(0, QString("Case_")) ; + for ( int i=0; ilength(); i++) + { + if ( aCaseName == QString((MyCases)[i])) + { + num ++ ; + aCaseName = "" ; + break ; + } + } + } + LEName->clear() ; + LEName->insert(aCaseName); +} + +// ------------------------------------------------------------------------ +void MonCreateCase::SetDirName() +// ------------------------------------------------------------------------ +{ + QString aDirName=QFileDialog::getExistingDirectory (); + if (!(aDirName.isEmpty()))LEDirName->setText(aDirName); +} +// ------------------------------------------------------------------------ +void MonCreateCase::SetFileName() +// ------------------------------------------------------------------------ +{ + QString fileName0 = LEFileName->text().trimmed(); + QString fileName = HOMARD_QT_COMMUN::PushNomFichier( false, QString("med") ) ; + if (fileName.isEmpty()) fileName = fileName0 ; + LEFileName->setText(fileName); +} +// ------------------------------------------------------------------------ +void MonCreateCase::SetConforme() +// ------------------------------------------------------------------------ +{ +// + _ConfType=0; + RBNC1NpA->setVisible(0); + RBNCQuelconque->setVisible(0); +// + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonCreateCase::SetNonConforme() +// ------------------------------------------------------------------------ +{ +// + _ConfType=1; + RBNC1NpA->setVisible(1); + RBNCQuelconque->setVisible(1); +// + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonCreateCase::SetStandard() +// ------------------------------------------------------------------------ +{ + if ( ( _ConfType == 0 ) || ( _ConfType == -1 ) ) { _ConfType = 0 ; } + else { _ConfType = 1 ; } + RBStandard->setChecked(true); +} +// ------------------------------------------------------------------------ +void MonCreateCase::SetBox() +// ------------------------------------------------------------------------ +{ + if ( ( _ConfType == 0 ) || ( _ConfType == -1 ) ) { _ConfType = -1 ; } + else { _ConfType = -2 ; } +} +// ------------------------------------------------------------------------ +void MonCreateCase::SetNC1NpA() +// ------------------------------------------------------------------------ +{ + _ConfType = 2; +} +// ------------------------------------------------------------------------ +void MonCreateCase::SetNCQuelconque() +// ------------------------------------------------------------------------ +{ + _ConfType = 3; +} +// ------------------------------------------------------------------------ +void MonCreateCase::SetMED() +// ------------------------------------------------------------------------ +{ + _ExtType = 0 ; + RBMED->setChecked(true); +} +// ------------------------------------------------------------------------ +void MonCreateCase::SetSaturne() +// ------------------------------------------------------------------------ +{ + _ExtType = 1 ; + RBSaturne->setChecked(true); +} +// ------------------------------------------------------------------------ +void MonCreateCase::SetSaturne2D() +// ------------------------------------------------------------------------ +{ + _ExtType = 2 ; + RBSaturne2D->setChecked(true); +} +// ------------------------------------------------------------------------ +void MonCreateCase::SetBoundaryNo() +// ------------------------------------------------------------------------ +{ +// + GBBoundaryC->setVisible(0); + GBBoundaryA->setVisible(0); + GBBoundaryD->setVisible(0); + CBBoundaryD->setVisible(0); + CBBoundaryA->setVisible(0); +// + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonCreateCase::SetBoundaryCAO() +// ------------------------------------------------------------------------ +{ +// + GBBoundaryC->setVisible(1); + GBBoundaryA->setVisible(0); + GBBoundaryD->setVisible(0); + CBBoundaryD->setVisible(0); + CBBoundaryA->setVisible(0); +// + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonCreateCase::SetBoundaryNonCAO() +// ------------------------------------------------------------------------ +{ +// + GBBoundaryC->setVisible(0); + CBBoundaryD->setVisible(1); + CBBoundaryA->setVisible(1); +// + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonCreateCase::AddBoundaryCAO(QString newBoundary) +// ------------------------------------------------------------------------ +{ + CBBoundaryCAO->insertItem(0,newBoundary); + CBBoundaryCAO->setCurrentIndex(0); +} +// ------------------------------------------------------------------------ +void MonCreateCase::PushBoundaryCAONew() +// ------------------------------------------------------------------------ +{ + MonCreateBoundaryCAO *BoundaryDlg = new MonCreateBoundaryCAO(this, true, + ADAPT::ADAPT_Gen::_duplicate(myAdaptGen), _aCaseName, "") ; + BoundaryDlg->show(); +} +// ------------------------------------------------------------------------ +void MonCreateCase::PushBoundaryCAOEdit() +// ------------------------------------------------------------------------ +{ + if (CBBoundaryCAO->currentText() == QString("")) return; + MonEditBoundaryCAO *BoundaryDlg = new MonEditBoundaryCAO(this, true, + ADAPT::ADAPT_Gen::_duplicate(myAdaptGen), _aCaseName, CBBoundaryCAO->currentText() ) ; + BoundaryDlg->show(); +} +// ------------------------------------------------------------------------ +void MonCreateCase::PushBoundaryCAOHelp() +// ------------------------------------------------------------------------ +{ + std::string LanguageShort = myAdaptGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("CAO"), QString(LanguageShort.c_str())); +} +// ------------------------------------------------------------------------ +void MonCreateCase::SetBoundaryD() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetBoundaryD "); + if (CBBoundaryD->isChecked()) + { + bool bOK = PushOnApply(0); + if (bOK) { GBBoundaryD->setVisible(1); } + else { GBBoundaryD->setVisible(0); + CBBoundaryD->setChecked(0); + CBBoundaryD->setCheckState(Qt::Unchecked); } + } + else { GBBoundaryD->setVisible(0); } +// + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonCreateCase::AddBoundaryDi(QString newBoundary) +// ------------------------------------------------------------------------ +{ + CBBoundaryDi->insertItem(0,newBoundary); + CBBoundaryDi->setCurrentIndex(0); +} +// ------------------------------------------------------------------------ +void MonCreateCase::PushBoundaryDiNew() +// ------------------------------------------------------------------------ +{ + MonCreateBoundaryDi *BoundaryDlg = new MonCreateBoundaryDi(this, true, + ADAPT::ADAPT_Gen::_duplicate(myAdaptGen), _aCaseName, "") ; + BoundaryDlg->show(); +} +// ------------------------------------------------------------------------ +void MonCreateCase::PushBoundaryDiEdit() +// ------------------------------------------------------------------------ +{ + if (CBBoundaryDi->currentText() == QString("")) return; + MonEditBoundaryDi *BoundaryDlg = new MonEditBoundaryDi(this, true, + ADAPT::ADAPT_Gen::_duplicate(myAdaptGen), _aCaseName, CBBoundaryDi->currentText() ) ; + BoundaryDlg->show(); +} +// ------------------------------------------------------------------------ +void MonCreateCase::PushBoundaryDiHelp() +// ------------------------------------------------------------------------ +{ + std::string LanguageShort = myAdaptGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("frontiere-discrete"), QString(LanguageShort.c_str())); +} +// ------------------------------------------------------------------------ +void MonCreateCase::SetBoundaryA() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetBoundaryA "); + if (CBBoundaryA->isChecked()) + { + bool bOK = PushOnApply(0); + if (bOK) { GBBoundaryA->setVisible(1); } + else { GBBoundaryA->setVisible(0); + CBBoundaryA->setChecked(0); + CBBoundaryA->setCheckState(Qt::Unchecked); } + } + else { GBBoundaryA->setVisible(0); } +// + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonCreateCase::AddBoundaryAn(QString newBoundary) +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de AddBoundaryAn "); +// Ajout d'une nouvelle colonne + int nbcol = TWBoundary->columnCount(); +// MESSAGE("nbcol " << nbcol); + nbcol += 1 ; + TWBoundary->setColumnCount ( nbcol ) ; + QTableWidgetItem *__colItem = new QTableWidgetItem(); + __colItem->setText(QApplication::translate("CreateCase", newBoundary.toStdString().c_str(), 0)); + TWBoundary->setHorizontalHeaderItem(nbcol-1, __colItem); +/* TWBoundary->horizontalHeaderItem(nbcol-1)->setFlags( Qt::ItemIsSelectable|Qt::ItemIsEnabled );*/ +// Chaque case est a cocher + int nbrow = TWBoundary->rowCount(); +// MESSAGE("nbrow " << nbrow); + for ( int i = 0; i < nbrow; i++ ) + { + TWBoundary->setItem( i, nbcol-1, new QTableWidgetItem( QString ("") ) ); + TWBoundary->item( i, nbcol-1 )->setFlags( 0 ); + TWBoundary->item( i, nbcol-1 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled ); + TWBoundary->item( i, nbcol-1 )->setCheckState( Qt::Unchecked ); + } + TWBoundary->resizeColumnToContents(nbcol-1); +// TWBoundary->resizeRowsToContents(); +// MESSAGE("Fin de AddBoundaryAn "); +} +// ------------------------------------------------------------------------ +void MonCreateCase::PushBoundaryAnNew() +// ------------------------------------------------------------------------ +{ + MonCreateBoundaryAn *BoundaryDlg = new MonCreateBoundaryAn(this, true, + ADAPT::ADAPT_Gen::_duplicate(myAdaptGen), _aCaseName) ; + BoundaryDlg->show(); +} +// ------------------------------------------------------------------------ +void MonCreateCase::PushBoundaryAnEdit() +// ------------------------------------------------------------------------ +{ + QString nom=""; + int nbcol = TWBoundary->columnCount(); + for ( int i = 1; i < nbcol; i++ ) + { + QTableWidgetItem *__colItem = new QTableWidgetItem(); + __colItem = TWBoundary->horizontalHeaderItem(i); + nom = QString(__colItem->text()) ; + MESSAGE("nom "<show(); } + } +} +// ------------------------------------------------------------------------ +void MonCreateCase::PushBoundaryAnHelp() +// ------------------------------------------------------------------------ +{ + std::string LanguageShort = myAdaptGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("frontiere-analytique"), QString(LanguageShort.c_str())); +} +// ------------------------------------------------------------------------ +void MonCreateCase::CaseNameChanged() +// ------------------------------------------------------------------------ +{ + if (_aCaseName != LEName->text().trimmed()) + { + LEFileName->setReadOnly(false); + PushFichier->show(); + } +} +// ------------------------------------------------------------------------ +void MonCreateCase::SetAdvanced() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetAdvanced "); + if (CBAdvanced->isChecked()) + { GBAdvancedOptions->setVisible(1); + GBConforme->setVisible(1); + RBStandard->setVisible(1); + RBBox->setVisible(1); + if ( ( _ConfType == 0 ) || ( _ConfType == -1 ) ) + { RBNC1NpA->setVisible(0); + RBNCQuelconque->setVisible(0);} + else + { RBNC1NpA->setVisible(1); + RBNCQuelconque->setVisible(1);} + GBFormat->setVisible(1); + RBMED->setVisible(1); + RBSaturne2D->setVisible(1); + } + else + { GBAdvancedOptions->setVisible(0); + CBPyramid->setChecked(false); + _Pyram = 0 ; + SetStandard() ; + SetMED() ; + } +// + adjustSize(); +} diff --git a/src/ADAPTGUI/MonCreateCase.h b/src/ADAPTGUI/MonCreateCase.h new file mode 100644 index 000000000..36f01b884 --- /dev/null +++ b/src/ADAPTGUI/MonCreateCase.h @@ -0,0 +1,102 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_CREATECASE_H +#define MON_CREATECASE_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) +#include CORBA_CLIENT_HEADER(HOMARD_Cas) + +#include "ui_CreateCase.h" +#include + +class HOMARD_EXPORT MonCreateCase : public QDialog, public Ui_CreateCase +{ + Q_OBJECT + +public: + MonCreateCase( bool modal, ADAPT::ADAPT_Gen_var myAdaptGen ); + ~MonCreateCase(); + + void AddBoundaryCAO(QString newBoundary); + void AddBoundaryAn(QString newBoundary); + void AddBoundaryDi(QString newBoundary); + +protected : + QString _aCaseName; + QString _aDirName; + + int _ConfType; + int _ExtType; + + int _Pyram; + + ADAPT::HOMARD_Cas_var aCase ; + ADAPT::ADAPT_Gen_var myAdaptGen; + + virtual void InitConnect(); + virtual void InitBoundarys(); + virtual void SetNewName(); + +public slots: + virtual void SetDirName(); + virtual void SetFileName(); + + virtual void SetConforme(); + virtual void SetNonConforme(); + virtual void SetStandard(); + virtual void SetBox(); + virtual void SetNC1NpA(); + virtual void SetNCQuelconque(); + + virtual void SetMED(); + virtual void SetSaturne(); + virtual void SetSaturne2D(); + + virtual void SetBoundaryNo(); + virtual void SetBoundaryCAO(); + virtual void SetBoundaryNonCAO(); + virtual void PushBoundaryCAONew(); + virtual void PushBoundaryCAOEdit(); + virtual void PushBoundaryCAOHelp(); + virtual void SetBoundaryD(); + virtual void PushBoundaryDiNew(); + virtual void PushBoundaryDiEdit(); + virtual void PushBoundaryDiHelp(); + virtual void SetBoundaryA(); + virtual void PushBoundaryAnNew(); + virtual void PushBoundaryAnEdit(); + virtual void PushBoundaryAnHelp(); + + virtual void SetAdvanced(); + + virtual void PushOnOK(); + virtual bool PushOnApply(int option); + virtual void PushOnHelp(); + + virtual void CaseNameChanged(); +}; + +#endif // MON_CREATECASE_H diff --git a/src/ADAPTGUI/MonCreateHypothesis.cxx b/src/ADAPTGUI/MonCreateHypothesis.cxx new file mode 100644 index 000000000..6c87eb011 --- /dev/null +++ b/src/ADAPTGUI/MonCreateHypothesis.cxx @@ -0,0 +1,945 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonCreateHypothesis.h" +#include "MonCreateListGroup.h" +#include "MonCreateIteration.h" +#include "MonCreateZone.h" +#include "MonEditZone.h" + +#include +#include + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include + +using namespace std; + +// ------------------------------------------------------------------------------- +MonCreateHypothesis::MonCreateHypothesis(MonCreateIteration* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen0, + QString Name, + QString caseName, QString aFieldFile) +// --------------------------------------------------------------------------------- +/* Constructs a MonCreateHypothesis */ + : + QScrollArea(0), Ui_CreateHypothesis(), + _parent(parent), _Name(Name), + _aCaseName(caseName), _aFieldFile(aFieldFile), + _aFieldName(""), + _aTypeAdap(-2), _aTypeRaff(1), _aTypeDera(0), + _TypeThR(3), _ThreshR(0), + _TypeThC(0), _ThreshC(0), + _UsField(0), _UsCmpI(0), _TypeFieldInterp(0), + _NivMax(-1), + _DiamMin(-1.), + _AdapInit(0), + _ExtraOutput(1) + +{ + MESSAGE("Constructeur") ; + myAdaptGen=ADAPT::ADAPT_Gen::_duplicate(myAdaptGen0); + setupUi(this); + if ( modal ) { setWindowModality(Qt::WindowModal); } + else { setWindowModality(Qt::NonModal); } + setWindowFlags( Qt::WindowStaysOnTopHint ) ; + InitConnect(); + + SetNewName(); + if (_aFieldFile != QString("")) + { RBChamp->setChecked(1); + SetChamp(); + } + else + { RBUniforme->setChecked(1); + SetUniforme(); + } + SetFieldNo(); + GBAdvancedOptions->setVisible(0); + CBOutputLevel->setChecked(false); + CBOutputQuality->setChecked(false); + CBOutputDiameter->setChecked(false); + CBOutputParent->setChecked(false); + CBOutputVoisins->setChecked(false); + _ExtraOutput = 1 ; +// + adjustSize(); +} + +// ------------------------------------------------------------------------ +MonCreateHypothesis::~MonCreateHypothesis() +// ------------------------------------------------------------------------ +{ + // no need to delete child widgets, Qt does it all for us +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::InitConnect() +// ------------------------------------------------------------------------ +{ + connect( RBUniforme, SIGNAL(clicked()), this, SLOT(SetUniforme())); + connect( RBChamp, SIGNAL(clicked()), this, SLOT(SetChamp())); + connect( RBZone, SIGNAL(clicked()), this, SLOT(SetZone())); + connect( RBUniRaff, SIGNAL(clicked()), this, SLOT(SetUniRaff())); + connect( RBUniDera, SIGNAL(clicked()), this, SLOT(SetUniDera())); + + connect( CBFieldName, SIGNAL(activated(int)), this, SLOT( SetFieldName())); + connect( RBRPE, SIGNAL(clicked()), this, SLOT(SetRPE())); + connect( RBRRel, SIGNAL(clicked()), this, SLOT(SetRRel())); + connect( RBRMuSigma, SIGNAL(clicked()), this, SLOT(SetRMS())); + connect( RBRAbs, SIGNAL(clicked()), this, SLOT(SetRAbs())); + connect( RBRNo, SIGNAL(clicked()), this, SLOT(SetRNo())); + connect( RBCPE, SIGNAL(clicked()), this, SLOT(SetCPE())); + connect( RBCRel, SIGNAL(clicked()), this, SLOT(SetCRel())); + connect( RBCMuSigma, SIGNAL(clicked()), this, SLOT(SetCMS())); + connect( RBCAbs, SIGNAL(clicked()), this, SLOT(SetCAbs())); + connect( RBCNo, SIGNAL(clicked()), this, SLOT(SetCNo())); + connect( RBL2, SIGNAL(clicked()), this, SLOT(SetUCL2())); + connect( RBInf, SIGNAL(clicked()), this, SLOT(SetUCInf())); + connect( CBJump, SIGNAL(stateChanged(int)), this, SLOT(SetUseField())); + connect( PBZoneNew, SIGNAL(pressed()), this, SLOT(PushZoneNew())); + connect( PBZoneEdit, SIGNAL(pressed()), this, SLOT(PushZoneEdit()) ); + connect( PBZoneDelete, SIGNAL(pressed()), this, SLOT(PushZoneDelete()) ); + connect( CBGroupe, SIGNAL(stateChanged(int)), this, SLOT(SetFiltrage())); + + connect( RBFieldNo, SIGNAL(clicked()), this, SLOT(SetFieldNo())); + connect( RBFieldAll, SIGNAL(clicked()), this, SLOT(SetFieldAll())); + connect( RBFieldChosen,SIGNAL(clicked()), this, SLOT(SetFieldChosen())); + + connect( CBAdvanced, SIGNAL(stateChanged(int)), this, SLOT(SetAdvanced())); + connect( RBAIN, SIGNAL(clicked()), this, SLOT(SetAIN())); + connect( RBAIR, SIGNAL(clicked()), this, SLOT(SetAIR())); + connect( RBAID, SIGNAL(clicked()), this, SLOT(SetAID())); + + connect( buttonOk, SIGNAL(pressed()), this, SLOT( PushOnOK())); + connect( buttonApply, SIGNAL(pressed()), this, SLOT( PushOnApply())); + connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close())); + connect( buttonHelp, SIGNAL(pressed()), this, SLOT( PushOnHelp())); +} + +// ------------------------------------------------------------------------ +bool MonCreateHypothesis::PushOnApply() +// ------------------------------------------------------------------------ +// Appele lorsque l'un des boutons Ok ou Apply est presse +// +{ +// Verifications + + + if (LEName->text().trimmed()=="") { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_HYPO_NAME") ); + return false; + } + + if (VerifieZone() == false) return false; + if (VerifieComposant() == false) return false; + +// Creation de l'objet CORBA si ce n'est pas deja fait sous le meme nom + if (LEName->text().trimmed() != _Name) + { + _Name=LEName->text().trimmed(); + try + { + aHypothesis=myAdaptGen->CreateHypothesis(CORBA::string_dup(_Name.toStdString().c_str()) ); + _parent->addHypothese(_Name); + } + catch( SALOME::SALOME_Exception& S_ex ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QString(CORBA::string_dup(S_ex.details.text)) ); + return false; + } + } + +// Mise en place des attributs + if ( _aTypeAdap == -1 ) + { + int TypeRaffDera ; + if ( _aTypeRaff == 1 ) { TypeRaffDera = 1 ; } + else { TypeRaffDera = -1 ; } + aHypothesis->SetUnifRefinUnRef(TypeRaffDera); + } + aHypothesis->SetTypeFieldInterp(_TypeFieldInterp); + aHypothesis->SetCaseCreation(_aCaseName.toStdString().c_str()); + + AssocieLesZones(); + AssocieComposants(); + AssocieLesGroupes(); + AssocieFieldInterp(); + +// Options avancees + if (CBAdvanced->isChecked()) + { +// Enregistrement du niveau maximal + _NivMax = SpinBoxNivMax->value() ; + aHypothesis->SetNivMax(_NivMax); +// Enregistrement du diametre minimal + _DiamMin = doubleSpinBoxDiamMin->value() ; + aHypothesis->SetDiamMin(_DiamMin); +// Enregistrement de l'intialisation de l'adaptation + aHypothesis->SetAdapInit(_AdapInit); +// Sortie optionnelle des niveaux de raffinement, des diametres, des qualites + _ExtraOutput = 1 ; + if (CBOutputLevel->isChecked()) { _ExtraOutput = 2 ; } + if (CBOutputQuality->isChecked()) { _ExtraOutput = 3*_ExtraOutput ; } + if (CBOutputDiameter->isChecked()) { _ExtraOutput = 5*_ExtraOutput ; } + if (CBOutputParent->isChecked()) { _ExtraOutput = 7*_ExtraOutput ; } + if (CBOutputVoisins->isChecked()) { _ExtraOutput = 11*_ExtraOutput ; } + aHypothesis->SetExtraOutput(_ExtraOutput); + } + + HOMARD_UTILS::updateObjBrowser() ; + + return true; +} + + +// ------------------------------------------------------------------------ +void MonCreateHypothesis::PushOnOK() +// ------------------------------------------------------------------------ +{ + if (PushOnApply()) this->close(); + if ( _parent ) { _parent->raise(); _parent->activateWindow(); }; +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::PushOnHelp() +// ------------------------------------------------------------------------ +{ + std::string LanguageShort = myAdaptGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_hypothese.html"), QString(""), QString(LanguageShort.c_str())); +} +// ------------------------------------------------- +void MonCreateHypothesis::SetNewName() +// -------------------------------------------------- +{ + + ADAPT::listeHypotheses_var MyObjects = myAdaptGen->GetAllHypothesesName(); + int num = 0;// + QString aName=""; + while (aName=="" ) + { + aName.setNum(num+1) ; + aName.insert(0, QString("Hypo_")) ; + for ( int i=0; ilength(); i++) + { + if ( aName == QString(MyObjects[i])) + { + num ++ ; + aName = "" ; + break ; + } + } + } + LEName->setText(aName); +} + +// +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetUniforme() +// ------------------------------------------------------------------------ +{ + GBFieldManagement->setVisible(0); + if ( _TypeFieldInterp == 0 ) { GBFieldFile->setVisible(0); } + else { GBFieldFile->setVisible(1); } + GBAreaManagement->setVisible(0); + GBUniform->setVisible(1); + + _aTypeAdap = -1 ; +// + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetChamp() +// ------------------------------------------------------------------------ +{ + if (_aFieldFile == QString("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_HYPO_FIELD_FILE") ); + close(); + if ( _parent ) { _parent->raise(); _parent->activateWindow(); }; + return; + } + LEFieldFile->setText(_aFieldFile); + LEFieldFile->setReadOnly(1); + InitFields(); + GBUniform->setVisible(0); + GBAreaManagement->setVisible(0); + GBFieldManagement->setVisible(1); + GBFieldFile->setVisible(1); + + GBUniform->adjustSize(); + GBAreaManagement->adjustSize(); + GBFieldManagement->adjustSize(); + GBFieldFile->adjustSize(); + + _aTypeAdap = 1 ; +// + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetZone() +// ------------------------------------------------------------------------ +{ + GetAllZones(); + GBUniform->setVisible(0); + GBFieldManagement->setVisible(0); + if ( _TypeFieldInterp == 0 ) { GBFieldFile->setVisible(0); } + else { GBFieldFile->setVisible(1); } + GBAreaManagement->setVisible(1); + + _aTypeRaff = 1 ; + _aTypeDera = 0 ; + _aTypeAdap = 0 ; +// + adjustSize(); +} + +// ------------------------------------------------------------------------ +void MonCreateHypothesis::PushZoneNew() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de MonCreateHypothesis::PushZoneNew") + MonCreateZone *aDlg = new MonCreateZone(this, true, ADAPT::ADAPT_Gen::_duplicate(myAdaptGen), _aCaseName) ; + aDlg->show(); +} + +// ------------------------------------------------------------------------ +void MonCreateHypothesis::PushZoneEdit() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de MonCreateHypothesis::PushZoneEdit") + int colonne = TWZone->currentColumn(); + QTableWidgetItem * monItem = TWZone->currentItem(); + if (colonne !=2 || monItem == NULL) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_HYPO_ZONE_1") ); + return; + } + QString zoneName = monItem->text().trimmed(); + MonEditZone *aDlg = new MonEditZone(this, true, ADAPT::ADAPT_Gen::_duplicate(myAdaptGen), _aCaseName, zoneName) ; + aDlg->show(); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::PushZoneDelete() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de MonCreateHypothesis::PushZoneDelete") + QMessageBox::warning( 0, QObject::tr("HOM_WARNING"), + QObject::tr("HOM_INACTIVE_BUTTON") ); + return; +} + +// ------------------------------------------------------------------------ +void MonCreateHypothesis::GetAllZones() +// ------------------------------------------------------------------------ +// Recuperation de toutes les zones enregistrees dans l'arbre d'etude +// et affichage dans le tableau +// Par defaut, aucune n'est selectionnee +{ + MESSAGE("Debut de GetAllZones") ; + ADAPT::listeZones_var mesZones = myAdaptGen->GetAllZonesName(); + int nbrow=TWZone->rowCount(); + for ( int row=0; row< nbrow; row++) + { + TWZone->removeRow(row); + } + TWZone->setRowCount(0); + int row=0; + for (int i=0; ilength(); i++) + { + TWZone->insertRow(row); +// + TWZone->setItem( row, 0, new QTableWidgetItem( QString ("") ) ); + TWZone->item( row, 0 )->setFlags( 0 ); + TWZone->item( row, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled ); + TWZone->item( row, 0 )->setCheckState( Qt::Unchecked ); +// + TWZone->setItem( row, 1, new QTableWidgetItem( QString ("") ) ); + TWZone->item( row, 1 )->setFlags( 0 ); + TWZone->item( row, 1 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled ); + TWZone->item( row, 1 )->setCheckState( Qt::Unchecked ); +// + TWZone->setItem( row, 2, new QTableWidgetItem(QString(mesZones[i]).trimmed())); + TWZone->item( row, 2 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable ); +// + row += 1; + } + TWZone->resizeColumnsToContents(); + TWZone->resizeRowsToContents(); + TWZone->clearSelection(); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::addZoneinTWZone(QString newZone) +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de addZoneinTWZone") ; + int row = TWZone->rowCount() ; +// Par defaut, on suppose qu'une nouvelle zone est destinee au raffinement + TWZone->setRowCount( row+1 ); +// + TWZone->setItem( row, 0, new QTableWidgetItem( QString ("") ) ); + TWZone->item( row, 0 )->setFlags( Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled ); + TWZone->item( row, 0 )->setCheckState( Qt::Checked ); +// + TWZone->setItem( row, 1, new QTableWidgetItem( QString ("") ) ); + TWZone->item( row, 1 )->setFlags( Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled ); + TWZone->item( row, 1 )->setCheckState( Qt::Unchecked ); +// + TWZone->setItem( row, 2, new QTableWidgetItem( newZone ) ); + TWZone->scrollToItem( TWZone->item( row, 2 ) ); +// + TWZone->resizeRowsToContents(); + TWZone->resizeColumnToContents(1); + TWZone->clearSelection(); +// + TWZone->item( row, 2 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable ); +} +// ------------------------------------------------------------------------ +QStringList MonCreateHypothesis::GetZonesChecked() +// ------------------------------------------------------------------------ +// Retourne les zones enregistrees +{ + MESSAGE("Debut de GetZonesChecked") ; + QStringList ListeZone ; +// On ne peut pas avoir selectionne les deux options + int Pbm = 0 ; + for ( int row=0; row< TWZone->rowCount(); row++) + { + if ( ( TWZone->item( row, 0 )->checkState() == Qt::Checked ) && ( TWZone->item( row, 1 )->checkState() == Qt::Checked ) ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_HYPO_ZONE_3") ); + Pbm = 1 ; + } + } +// Si tout va bien, on affecte +// Attention, on insere en tete, donc on commence d'inserer le type, psui le nom de la zone + if ( Pbm == 0 ) + { + QString Raff = "1" ; + QString Dera = "-1" ; + for ( int row=0; row< TWZone->rowCount(); row++) + { +// MESSAGE ("row "<item(row, 2)->text().toStdString()); +// En raffinement : + if ( TWZone->item(row,0)->checkState() == Qt::Checked ) + { ListeZone.insert(0, Raff) ; + ListeZone.insert(0, QString(TWZone->item(row, 2)->text()) ) ; } +// En deraffinement : + if ( TWZone->item(row,1)->checkState() == Qt::Checked ) + { ListeZone.insert(0, Dera) ; + ListeZone.insert(0, QString(TWZone->item(row, 2)->text()) ) ; } + } + MESSAGE("Fin de GetZonesChecked ; longueur de ListeZone : "<rowCount(); row++) + if ( TWCMP->item( row, 0 )->checkState() == Qt::Checked ) + ListeComposant.insert(0, QString(TWCMP->item(row, 1)->text()) ) ; + // Choix du texte des radio-boutons selon 1 ou plusieurs composantes + if ( ListeComposant.count() < 2 ) + { RBL2->setText(QObject::tr("HOM_HYPO_NORM_ABS")); + RBInf->setText(QObject::tr("HOM_HYPO_NORM_REL")); + } + else + { RBL2->setText(QObject::tr("HOM_HYPO_NORM_L2")); + RBInf->setText(QObject::tr("HOM_HYPO_NORM_INF")); + } + return ListeComposant ; +// +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::AssocieFieldInterp() +// ------------------------------------------------------------------------ +{ + if ( _TypeFieldInterp != 2 ) return; + for ( int row=0; row< TWField->rowCount(); row++) + { + if ( TWField->item( row, 0 )->checkState() == Qt::Checked ) + { + aHypothesis->AddFieldInterp(TWField->item(row, 1)->text().toStdString().c_str()); + } + } +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetUniRaff() +// ------------------------------------------------------------------------ +{ + _aTypeRaff = 1 ; + _aTypeDera = 0 ; +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetUniDera() +// ------------------------------------------------------------------------ +{ + _aTypeRaff = 0 ; + _aTypeDera = 1 ; +} + +// ------------------------------------------------------------------------ +void MonCreateHypothesis::InitFields() +// ------------------------------------------------------------------------ +{ + CBFieldName->clear(); + std::list listeChamp = HOMARD_QT_COMMUN::GetListeChamps(QString(_aFieldFile) ); + // Mise en place de la liste dans le menu pour l'indicateur d'erreur + std:: list::const_iterator it; + for ( it=listeChamp.begin() ; it != listeChamp.end(); it++) + { + CBFieldName->insertItem(0,QString(*it)); + } + SetFieldName(); +} +// --------------------------------------- +void MonCreateHypothesis::SetFieldName() +// ------------------------------------------- +{ + MESSAGE("Debut de SetFieldName"); + _aFieldName=CBFieldName->currentText(); + if (QString(_aFieldFile) == QString("") || QString(_aFieldName) == QString("") ) { return; } + + int nbrow= TWCMP->rowCount() ; + for ( int row=0; row < nbrow ; row++) + { + TWCMP->removeRow(row); + } + TWCMP->setRowCount(0); + //TWCMP->resizeRowsToContents(); + + std::list maListe =HOMARD_QT_COMMUN::GetListeComposants(_aFieldFile, _aFieldName); + std::list::const_iterator it; + for ( it=maListe.begin() ; it != maListe.end(); it++) + { + TWCMP->insertRow(0); + TWCMP->setItem( 0, 0, new QTableWidgetItem( QString ("") ) ); + TWCMP->item( 0, 0 )->setFlags( 0 ); + TWCMP->item( 0, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled ); + TWCMP->item( 0, 0 )->setCheckState( Qt::Checked ); + TWCMP->setItem( 0, 1, new QTableWidgetItem(QString((*it)).trimmed())); + TWCMP->item( 0, 1 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable ); + } + TWCMP->resizeColumnsToContents(); + TWCMP->resizeRowsToContents(); + TWCMP->clearSelection(); + // Choix du texte des radio-boutons selon 1 ou plusieurs composantes + if ( TWCMP->rowCount() == 1 ) + { RBL2->setText(QObject::tr("HOM_HYPO_NORM_ABS")); + RBInf->setText(QObject::tr("HOM_HYPO_NORM_REL")); + } + else + { RBL2->setText(QObject::tr("HOM_HYPO_NORM_L2")); + RBInf->setText(QObject::tr("HOM_HYPO_NORM_INF")); + } + // Par defaut, on propose la valeur absolue / norme L2 + SetUCL2(); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetRPE() +// ------------------------------------------------------------------------ +{ + _aTypeRaff = 1 ; + _TypeThR = 3 ; + RBRPE->setChecked(true); + SpinBox_RPE->setEnabled(true); + SpinBox_RRel->setEnabled(false); + SpinBox_RAbs->setEnabled(false); + SpinBox_RMuSigma->setEnabled(false); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetRRel() +// ------------------------------------------------------------------------ +{ + _aTypeRaff = 1 ; + _TypeThR = 2 ; + RBRRel->setChecked(true); + SpinBox_RPE->setEnabled(false); + SpinBox_RRel->setEnabled(true); + SpinBox_RAbs->setEnabled(false); + SpinBox_RMuSigma->setEnabled(false); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetRAbs() +// ------------------------------------------------------------------------ +{ + _aTypeRaff = 1 ; + _TypeThR = 1 ; + RBRAbs->setChecked(true); + SpinBox_RPE->setEnabled(false); + SpinBox_RRel->setEnabled(false); + SpinBox_RAbs->setEnabled(true); + SpinBox_RMuSigma->setEnabled(false); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetRMS() +// ------------------------------------------------------------------------ +{ + _aTypeRaff = 1 ; + _TypeThR = 4 ; + RBRMuSigma->setChecked(true); + SpinBox_RPE->setEnabled(false); + SpinBox_RRel->setEnabled(false); + SpinBox_RAbs->setEnabled(false); + SpinBox_RMuSigma->setEnabled(true); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetRNo() +// ------------------------------------------------------------------------ +{ + _aTypeRaff = 0 ; + _TypeThR = 0; + RBRNo->setChecked(true); + SpinBox_RPE->setEnabled(false); + SpinBox_RRel->setEnabled(false); + SpinBox_RAbs->setEnabled(false); + SpinBox_RMuSigma->setEnabled(false); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetCPE() +// ------------------------------------------------------------------------ +{ + _aTypeDera = 1 ; + _TypeThC = 3 ; + RBCPE->setChecked(true); + SpinBox_CPE->setEnabled(true); + SpinBox_CRel->setEnabled(false); + SpinBox_CAbs->setEnabled(false); + SpinBox_CMuSigma->setEnabled(false); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetCRel() +// ------------------------------------------------------------------------ +{ + _aTypeDera = 1 ; + _TypeThC = 2 ; + RBCRel->setChecked(true); + SpinBox_CPE->setEnabled(false); + SpinBox_CRel->setEnabled(true); + SpinBox_CAbs->setEnabled(false); + SpinBox_CMuSigma->setEnabled(false); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetCAbs() +// ------------------------------------------------------------------------ +{ + _aTypeDera = 1 ; + _TypeThC = 1 ; + RBCAbs->setChecked(true); + SpinBox_CPE->setEnabled(false); + SpinBox_CRel->setEnabled(false); + SpinBox_CAbs->setEnabled(true); + SpinBox_CMuSigma->setEnabled(false); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetCMS() +// ------------------------------------------------------------------------ +{ + _aTypeDera = 1 ; + _TypeThC = 4 ; + RBCMuSigma->setChecked(true); + SpinBox_CPE->setEnabled(false); + SpinBox_CRel->setEnabled(false); + SpinBox_CAbs->setEnabled(false); + SpinBox_CMuSigma->setEnabled(true); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetCNo() +// ------------------------------------------------------------------------ +{ + _aTypeDera = 0 ; + _TypeThC = 0; + RBCNo->setChecked(true); + SpinBox_CPE->setEnabled(false); + SpinBox_CRel->setEnabled(false); + SpinBox_CAbs->setEnabled(false); + SpinBox_CMuSigma->setEnabled(false); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetUCL2() +// ------------------------------------------------------------------------ +{ + _UsCmpI = 0 ; + RBL2->setChecked(true); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetUCInf() +// ------------------------------------------------------------------------ +{ + if ( TWCMP->rowCount() == 1 ) { _UsCmpI = 2 ; } + else { _UsCmpI = 1 ; } + RBInf->setChecked(true); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetUseField() +// ------------------------------------------------------------------------ +{ + if ( CBJump->isChecked() ) { _UsField = 1 ; } + else { _UsField = 0 ; } +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetFiltrage() +// ------------------------------------------------------------------------ +{ + if (!CBGroupe->isChecked()) return; + MonCreateListGroup *aDlg = new MonCreateListGroup(this, NULL, true, ADAPT::ADAPT_Gen::_duplicate(myAdaptGen),_aCaseName, _aListeGroupes) ; + aDlg->show(); +} + +// ------------------------------------------------------------------------ +void MonCreateHypothesis::setGroups(QStringList listGroup) +// ------------------------------------------------------------------------ +{ + _aListeGroupes=listGroup; +} +// ------------------------------------------------------------------------ +bool MonCreateHypothesis::VerifieZone() +// ------------------------------------------------------------------------ +{ + if ( _aTypeAdap != 0 ) return true; + MESSAGE("Debut de VerifieZone") ; + _aListeZone = GetZonesChecked() ; + MESSAGE(". Longueur de _aListeZone : "<<_aListeZone.count()) ; + if (_aListeZone.count() == 0) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_HYPO_ZONE_2") ); + return false; + } + MESSAGE("Fin de VerifieZone") ; + return true; +} +// ------------------------------------------------------------------------ +bool MonCreateHypothesis::VerifieComposant() +// ------------------------------------------------------------------------ +{ + if ( _aTypeAdap != 1 ) return true; + _aListeComposant = GetListCompChecked() ; + if (_aListeComposant.count() == 0) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_HYPO_COMP") ); + return false; + } + return true; +} + +// ------------------------------------------------------------------------ +void MonCreateHypothesis::AssocieLesZones() +// ------------------------------------------------------------------------ +{ + MESSAGE( "Debut de AssocieLesZones" ); + if ( _aTypeAdap != 0 ) return; + _aListeZone = GetZonesChecked() ; + MESSAGE(". Longueur de _aListeZone : "<<_aListeZone.count()) ; + QString Raff = "1" ; + int TypeUse ; + for ( int i=0 ; i< _aListeZone.count() ; i++ ) + { if ( _aListeZone[i+1] == Raff ) { TypeUse = 1 ; } + else { TypeUse = -1 ; } + aHypothesis->AddZone(_aListeZone[i].toStdString().c_str(), TypeUse); + i += 1 ; + } + MESSAGE( "Fin de AssocieLesZones" ); +}; +// ------------------------------------------------------------------------ +void MonCreateHypothesis::AssocieComposants() +// ------------------------------------------------------------------------ +{ + if ( _aTypeAdap != 1 ) return; + MESSAGE( "Dans AssocieComposants, _TypeThC : " << _TypeThC ); + MESSAGE( "Dans AssocieComposants, _TypeThR : " << _TypeThR ); + + _ThreshR = 0; + if ( _TypeThR == 1 ) { _ThreshR = SpinBox_RAbs->value();} + if ( _TypeThR == 2 ) { _ThreshR = SpinBox_RRel->value();} + if ( _TypeThR == 3 ) { _ThreshR = SpinBox_RPE->value(); } + if ( _TypeThR == 4 ) { _ThreshR = SpinBox_RMuSigma->value(); } + + _ThreshC = 0; + if ( _TypeThC == 1 ) { _ThreshC = SpinBox_CAbs->value();} + if ( _TypeThC == 2 ) { _ThreshC = SpinBox_CRel->value();} + if ( _TypeThC == 3 ) { _ThreshC = SpinBox_CPE->value(); } + if ( _TypeThC == 4 ) { _ThreshC = SpinBox_CMuSigma->value(); } + + _aFieldName=CBFieldName->currentText(); + aHypothesis->SetField(CORBA::string_dup(_aFieldName.toStdString().c_str()) ) ; + if ( _TypeThR > 0 ) { aHypothesis->SetRefinThr( _TypeThR, _ThreshR ) ; } + if ( _TypeThC > 0 ) { aHypothesis->SetUnRefThr( _TypeThC, _ThreshC ) ; } + aHypothesis->SetUseField( _UsField ) ; + aHypothesis->SetUseComp( _UsCmpI ) ; + _aListeComposant = GetListCompChecked() ; + for ( int i=0 ; i< _aListeComposant.count() ; i++ ) + { aHypothesis->AddComp(_aListeComposant[i].toStdString().c_str()); } +}; +// ------------------------------------------------------------------------ +void MonCreateHypothesis::AssocieLesGroupes() +// ------------------------------------------------------------------------ +{ + ADAPT::ListGroupType_var aSeqGroupe = new ADAPT::ListGroupType; + aSeqGroupe->length(_aListeGroupes.size()); + QStringList::const_iterator it; + int i=0; + for (it = _aListeGroupes.constBegin(); it != _aListeGroupes.constEnd(); it++) + aSeqGroupe[i++]=(*it).toStdString().c_str(); + aHypothesis->SetGroups(aSeqGroupe); + +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetFieldNo() +// ------------------------------------------------------------------------ +// Par defaut, on n'interpole rien +{ + if ( _aTypeAdap == 1 ) { GBFieldFile->setVisible(1); } + else { GBFieldFile->setVisible(0); } + TWField->setVisible(0); +// + _TypeFieldInterp = 0 ; +// + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetFieldAll() +// ------------------------------------------------------------------------ +// Par defaut, on interpole tout +{ + if (_aFieldFile == QString("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_HYPO_FIELD_FILE") ); + close(); + if ( _parent ) { _parent->raise(); _parent->activateWindow(); }; + return; + } + LEFieldFile->setText(_aFieldFile); + LEFieldFile->setReadOnly(1); + GBFieldFile->setVisible(1); + TWField->setVisible(0); +// + _TypeFieldInterp = 1 ; +// + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetFieldChosen() +// ------------------------------------------------------------------------ +{ + if (_aFieldFile == QString("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_HYPO_FIELD_FILE") ); + close(); + if ( _parent ) { _parent->raise(); _parent->activateWindow(); }; + return; + } + LEFieldFile->setText(_aFieldFile); + LEFieldFile->setReadOnly(1); + GBFieldFile->setVisible(1); + // Recuperation de la liste des champs contenus dans le fichier _aFieldFile + std::list listeChamp = HOMARD_QT_COMMUN::GetListeChamps(QString(_aFieldFile) ); + + // Initialisation de la table + TWField->clear(); + int nbrow=TWField->rowCount(); + for ( int row=0; row< nbrow; row++) + { + TWField->removeRow(row); + } + TWField->setRowCount(0); + std:: list::const_iterator it; + int row=0; + for ( it=listeChamp.begin() ; it != listeChamp.end(); it++) + { + TWField->insertRow(row); + TWField->setItem( row, 0, new QTableWidgetItem( QString ("") ) ); + TWField->item( row, 0 )->setFlags( 0 ); + TWField->item( row, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled ); + TWField->item( row, 0 )->setCheckState( Qt::Unchecked ); + TWField->setItem( row, 1, new QTableWidgetItem(QString(*it).trimmed())); + TWField->item( row, 1 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable ); + row=row+1; + } + TWField->resizeColumnsToContents(); + TWField->resizeRowsToContents(); + TWField->clearSelection(); + TWField->setVisible(1); + + _TypeFieldInterp = 2 ; +// + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetAdvanced() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetAdvanced "); + if (CBAdvanced->isChecked()) + { GBAdvancedOptions->setVisible(1); + if (_aFieldFile != QString("")) { GBAdapInit->setVisible(1) ; } + else { GBAdapInit->setVisible(0) ; } + } + else + { GBAdvancedOptions->setVisible(0); + _NivMax = -1 ; + _DiamMin = -1. ; + _AdapInit = 0 ; + CBOutputLevel->setChecked(false); + CBOutputQuality->setChecked(false); + CBOutputDiameter->setChecked(false); + CBOutputParent->setChecked(false); + CBOutputVoisins->setChecked(false); + _ExtraOutput = 1 ; + } +// + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetAIN() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetAIN "); + _AdapInit = 0 ; +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetAIR() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetAIR "); + _AdapInit = 1 ; +} +// ------------------------------------------------------------------------ +void MonCreateHypothesis::SetAID() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetAID "); + _AdapInit = -1 ; +} diff --git a/src/ADAPTGUI/MonCreateHypothesis.h b/src/ADAPTGUI/MonCreateHypothesis.h new file mode 100644 index 000000000..42f41f1ef --- /dev/null +++ b/src/ADAPTGUI/MonCreateHypothesis.h @@ -0,0 +1,138 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_CREATEHYPOTHESIS_H +#define MON_CREATEHYPOTHESIS_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) +#include CORBA_CLIENT_HEADER(HOMARD_Hypothesis) + +#include "ui_CreateHypothesis.h" +#include + +class MonCreateIteration; +class HOMARD_EXPORT MonCreateHypothesis : public QScrollArea, public Ui_CreateHypothesis +{ + Q_OBJECT + +public: + MonCreateHypothesis( MonCreateIteration* parent, bool modal, ADAPT::ADAPT_Gen_var myAdaptGen, + QString aHypotheseName, QString caseName, QString aFieldFile); + ~MonCreateHypothesis(); + + virtual void addZoneinTWZone(QString newZone); + virtual void setGroups(QStringList listGroup); + +protected : + // MonCreateHypothesis( MonCreateIteration* parent, ADAPT::ADAPT_Gen_var myAdaptGen, + // QString caseName, QString aFieldFile); + + MonCreateIteration *_parent; + + QString _Name; + QString _aFieldFile ; + QString _aFieldName; + QString _aCaseName; + + int _aTypeAdap; + int _aTypeRaff; + int _aTypeDera; + + int _TypeThR; + double _ThreshR; + int _TypeThC; + double _ThreshC; + + int _UsField; + int _UsCmpI; + int _TypeFieldInterp; + + int _NivMax; + double _DiamMin; + int _AdapInit; + int _ExtraOutput; + + ADAPT::HOMARD_Hypothesis_var aHypothesis; + ADAPT::ADAPT_Gen_var myAdaptGen; + + QStringList _aListeZone; + QStringList _aListeComposant; + QStringList _aListeGroupes; + + virtual void InitConnect(); + virtual void InitFields(); + virtual void GetAllZones(); + virtual void SetNewName(); + + virtual void AssocieFieldInterp(); + virtual void AssocieLesZones(); + virtual void AssocieComposants(); + virtual void AssocieLesGroupes(); + virtual bool VerifieZone(); + virtual bool VerifieComposant(); + + virtual QStringList GetZonesChecked(); + virtual QStringList GetListCompChecked(); + +public slots: + + virtual void SetUniforme(); + virtual void SetChamp(); + virtual void SetZone(); + virtual void SetUniRaff(); + virtual void SetUniDera(); + virtual void SetFieldName(); + virtual void SetRPE(); + virtual void SetRAbs(); + virtual void SetRRel(); + virtual void SetRMS(); + virtual void SetRNo(); + virtual void SetCPE(); + virtual void SetCAbs(); + virtual void SetCRel(); + virtual void SetCMS(); + virtual void SetCNo(); + virtual void SetUCL2(); + virtual void SetUCInf(); + virtual void SetUseField(); + virtual void PushZoneNew(); + virtual void PushZoneEdit(); + virtual void PushZoneDelete(); + virtual void SetFiltrage(); + virtual void SetFieldNo(); + virtual void SetFieldAll(); + virtual void SetFieldChosen(); + + virtual void SetAdvanced(); + virtual void SetAIN(); + virtual void SetAIR(); + virtual void SetAID(); + + virtual void PushOnOK(); + virtual bool PushOnApply(); + virtual void PushOnHelp(); +}; + +#endif // MON_CREATEHYPOTHESIS_H diff --git a/src/ADAPTGUI/MonCreateIteration.cxx b/src/ADAPTGUI/MonCreateIteration.cxx new file mode 100644 index 000000000..27befda2d --- /dev/null +++ b/src/ADAPTGUI/MonCreateIteration.cxx @@ -0,0 +1,339 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonCreateIteration.h" +#include "MonCreateHypothesis.h" +#include "MonEditHypothesis.h" + +#include +#include + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include + +using namespace std; + +// ----------------------------------------------------------------------------------------------------- +MonCreateIteration::MonCreateIteration(QWidget* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen0, QString IterParentName ): +// ----------------------------------------------------------------------------------------------------- +/* Constructs a MonCreateIteration + * Inherits from CasHomard + * Sets attributes to default values + */ + QScrollArea(0), + Ui_CreateIteration(), + _Name(""), + _IterParentName(IterParentName), + _CaseName("") + { + MESSAGE("Constructeur"); + myAdaptGen=ADAPT::ADAPT_Gen::_duplicate(myAdaptGen0); + setupUi(this); + if ( modal ) { setWindowModality(Qt::WindowModal); } + else { setWindowModality(Qt::NonModal); } + InitConnect(); + + SetNewName(); + GetHypotheses(); + if (_IterParentName != QString("")) { SetIterParentName(); } + else { setWindowModality(Qt::NonModal) ; /* permet selection de l'iteration dans l arbre d etude */} + SetTSNo(); +// + adjustSize(); + } +// ------------------------------------------------------------------------ +MonCreateIteration::~MonCreateIteration() +// ------------------------------------------------------------------------ +{ + // no need to delete child widgets, Qt does it all for us +} +// ------------------------------------------------------------------------ +void MonCreateIteration::InitConnect() +// ------------------------------------------------------------------------ +{ + connect( PBIterParent, SIGNAL(pressed()), this, SLOT( SetIterParentName())); + connect( PBHypoEdit, SIGNAL(pressed()), this, SLOT( PushHypoEdit() ) ); + connect( PBHypoNew, SIGNAL(pressed()), this, SLOT( PushHypoNew() ) ); + connect( PushFieldFile, SIGNAL(pressed()), this, SLOT( SetFieldFile() ) ); + connect( RBNo, SIGNAL(clicked()), this, SLOT( SetTSNo())); + connect( RBLast, SIGNAL(clicked()), this, SLOT( SetTSLast())); + connect( RBChosen, SIGNAL(clicked()), this, SLOT( SetTSChosen())); + + connect( buttonOk, SIGNAL(pressed()), this, SLOT( PushOnOK() ) ); + connect( buttonApply, SIGNAL(pressed()), this, SLOT( PushOnApply() ) ); + connect( buttonCancel, SIGNAL(pressed()), this, SLOT( close() ) ); + connect( buttonHelp, SIGNAL(pressed()), this, SLOT( PushOnHelp() ) ); +} +// ------------------------------------------------------------------------ +void MonCreateIteration::GetHypotheses() +// ------------------------------------------------------------------------ +{ + ADAPT::listeHypotheses_var mesHypotheses = myAdaptGen->GetAllHypothesesName(); + for (int i=0; ilength(); i++) + { + CBHypothese->addItem(QString(mesHypotheses[i])); + } +} +// ------------------------------------------------------------------------ +bool MonCreateIteration::PushOnApply() +// ------------------------------------------------------------------------ +// Appele lorsque l'un des boutons Ok ou Apply est presse +{ + MESSAGE("PushOnApply"); +// + QString aName = LEName->text().trimmed(); + if ( aName == QString ("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_ITER_NAME") ); + return false; + } + + if ( _IterParentName == QString ("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_ITER_STARTING_POINT") ); + return false; + } + QString aMeshName_np1=LEMeshName_np1->text().trimmed(); + if (aMeshName_np1 == "" ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_ITER_MESH") ); + return false; + } + QString monHypoName=CBHypothese->currentText(); + if (monHypoName == "" ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_ITER_HYPO") ); + return false; + } + ADAPT::HOMARD_Hypothesis_var _myHypothesis = myAdaptGen->GetHypothesis(monHypoName.toStdString().c_str()); + ADAPT::listeTypes_var ListTypes (_myHypothesis->GetAdapRefinUnRef()); + int TypeAdap = ListTypes[0]; + if ( TypeAdap == 1 && LEFieldFile->text().trimmed() == QString("") ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_ITER_FIELD_FILE") ); + return false; + } + + MESSAGE ("aMeshName_np1.toStdString " << aMeshName_np1.toStdString()); + MESSAGE ("_CaseName.toStdString " << _CaseName.toStdString() ); + MESSAGE ("_IterParentName.toStdString " << _IterParentName.toStdString() ); + +// Creation de l'objet CORBA si ce n'est pas deja fait sous le meme nom + if (_Name != aName) + { + try + { + _Name = aName; + std::cerr << _Name.toStdString() << std::endl; + aIter = myAdaptGen->CreateIteration( \ + CORBA::string_dup(_Name.toStdString().c_str()), + CORBA::string_dup(_IterParentName.toStdString().c_str())); + } + catch( SALOME::SALOME_Exception& S_ex ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr(CORBA::string_dup(S_ex.details.text)) ); + return false; + } + } +// Mise en place des attributs + std::string IterName = aIter->GetName() ; + + if ( LEFieldFile->text().trimmed() != QString("")) + { + QString FieldFile=LEFieldFile->text().trimmed(); + aIter->SetFieldFile(CORBA::string_dup(FieldFile.toStdString().c_str())); + int rank = SpinBox_Rank->value(); + int step = SpinBox_TimeStep->value(); + if ( step == -2 ) { aIter->SetTimeStepRankLast(); } + else { aIter->SetTimeStepRank(step,rank); } + } + myAdaptGen->AssociateIterHypo (IterName.c_str(), monHypoName.toStdString().c_str()); + aIter->SetMeshName(CORBA::string_dup(aMeshName_np1.toStdString().c_str())); + + HOMARD_UTILS::updateObjBrowser() ; + + return true; +} +// ------------------------------------------------------------------------ +void MonCreateIteration::PushOnOK() +// ------------------------------------------------------------------------ +{ + bool bOK = PushOnApply(); + if ( bOK ) this->close(); +} +// ------------------------------------------------------------------------ +void MonCreateIteration::PushOnHelp() +// ------------------------------------------------------------------------ +{ + std::string LanguageShort = myAdaptGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_iteration.html"), QString(""), QString(LanguageShort.c_str())); +} +// ------------------------------------------------------------------------ +void MonCreateIteration::SetIterParentName() +// ------------------------------------------------------------------------ +{ + if (_IterParentName == QString("")) { + _IterParentName=HOMARD_QT_COMMUN::SelectionArbreEtude(QString("IterationHomard"), 1); + if (_IterParentName == QString("")) { raise();return;}; + } + _CaseName=HOMARD_QT_COMMUN::SelectionCasEtude(); + ADAPT::HOMARD_Iteration_var aIterParent = myAdaptGen->GetIteration(_IterParentName.toStdString().c_str()) ; + QString MeshName = aIterParent->GetMeshName(); + + LEMeshName_n->setText(MeshName); + LEMeshName_n->setReadOnly(1); + LEMeshName_np1->setText(MeshName); + + LEIterationParentName->setText(_IterParentName); +} +// ------------------------------------------------- +void MonCreateIteration::SetNewName() +// -------------------------------------------------- +{ +// Recherche d'un nom par defaut qui n'existe pas encore + + ADAPT::listeIterations_var MyObjects=myAdaptGen->GetAllIterationsName(); + int num = 0;// + QString aName=""; + while (aName=="" ) + { + aName.setNum(num+1) ; + aName.insert(0, QString("Iter_")); + for ( int i=0; i< MyObjects->length(); i++) + { + if ( aName == QString((MyObjects)[i])) + { + num ++ ; + aName = "" ; + break ; + } + } + } + LEName->setText(aName); +} +// ------------------------------------------------------------------------ +void MonCreateIteration::PushHypoEdit() +// ------------------------------------------------------------------------ +{ + if (CBHypothese->currentText() == QString("")) return; + if (_IterParentName == QString("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_ITER_STARTING_POINT") ); + raise(); + return; + } + QString aFieldFile=LEFieldFile->text().trimmed(); + MonEditHypothesis *HypoDlg = new MonEditHypothesis(this, true, ADAPT::ADAPT_Gen::_duplicate(myAdaptGen),CBHypothese->currentText(), _CaseName, aFieldFile) ; + HypoDlg->show(); +} + +// ------------------------------------------------------------------------ +void MonCreateIteration::addHypothese(QString newHypothese) +// ------------------------------------------------------------------------ +{ + CBHypothese->insertItem(0,newHypothese); + CBHypothese->setCurrentIndex(0); +} +// ------------------------------------------------------------------------ +void MonCreateIteration::PushHypoNew() +// ------------------------------------------------------------------------ +{ + if (_IterParentName == QString("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_ITER_STARTING_POINT") ); + raise(); + return; + } + if ( _CaseName == QString("")) + { + ADAPT::HOMARD_Iteration_var aIterParent = myAdaptGen->GetIteration(_IterParentName.toStdString().c_str()) ; + _CaseName = aIterParent->GetCaseName(); + } + QString aFieldFile=LEFieldFile->text().trimmed(); + MonCreateHypothesis *HypoDlg = new MonCreateHypothesis(this, true, ADAPT::ADAPT_Gen::_duplicate(myAdaptGen), QString(""), _CaseName, aFieldFile) ; + HypoDlg->show(); +} +// ------------------------------------------------------------------------ +void MonCreateIteration::SetFieldFile() +// ------------------------------------------------------------------------ +{ + QString fileName0 = LEFieldFile->text().trimmed(); + QString fileName = HOMARD_QT_COMMUN::PushNomFichier( false, QString("med") ) ; + if (fileName.isEmpty()) fileName = fileName0 ; + LEFieldFile->setText(fileName); + raise(); +} +// ------------------------------------------------------------------------ +void MonCreateIteration::SetTSNo() +// ------------------------------------------------------------------------ +// Si on ne tient pas compte du pas de temps, on declare que le pas de temps +// vaut -1, valeur par defaut de med +{ + Rank->setVisible(0); + SpinBox_Rank->setVisible(0); + SpinBox_Rank->setValue(-1); + + TimeStep->setVisible(0); + SpinBox_TimeStep->setVisible(0); + SpinBox_TimeStep->setValue(-1); +// + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonCreateIteration::SetTSLast() +// ------------------------------------------------------------------------ +// Si on choisit le dernier instant, on declare que le pas de temps vaut -2 +{ + Rank->setVisible(0); + SpinBox_Rank->setVisible(0); + SpinBox_Rank->setValue(-2); + + TimeStep->setVisible(0); + SpinBox_TimeStep->setVisible(0); + SpinBox_TimeStep->setValue(-2); +// + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonCreateIteration::SetTSChosen() +// ------------------------------------------------------------------------ +// Si choisit un instant, on prepositionne a 0 +{ + Rank->setVisible(1); + SpinBox_Rank->setVisible(1); + SpinBox_Rank->setValue(0); + + TimeStep->setVisible(1); + SpinBox_TimeStep->setVisible(1); + SpinBox_TimeStep->setValue(0); +// + adjustSize(); +} + diff --git a/src/ADAPTGUI/MonCreateIteration.h b/src/ADAPTGUI/MonCreateIteration.h new file mode 100644 index 000000000..383110d5c --- /dev/null +++ b/src/ADAPTGUI/MonCreateIteration.h @@ -0,0 +1,78 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_CREATEITERATION_H +#define MON_CREATEITERATION_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) +#include CORBA_CLIENT_HEADER(HOMARD_Cas) + +#include "ui_CreateIteration.h" +#include + +class HOMARD_EXPORT MonCreateIteration : public QScrollArea, public Ui_CreateIteration +{ + Q_OBJECT + +public: + MonCreateIteration( QWidget* parent, bool modal, ADAPT::ADAPT_Gen_var myAdaptGen, QString IterParentName ); + ~MonCreateIteration(); + + void addHypothese(QString newHypothese); + + +protected : + MonCreateIteration( QWidget* parent, ADAPT::ADAPT_Gen_var myAdaptGen, QString IterParentName ); + + QString _Name; + QString _IterParentName; + QString _CaseName; + + + ADAPT::HOMARD_Iteration_var aIter ; + ADAPT::HOMARD_Iteration_var aIterParent ; + ADAPT::HOMARD_Cas_var aCas ; + ADAPT::ADAPT_Gen_var myAdaptGen; + + + virtual void InitConnect(); + virtual void GetHypotheses(); + virtual void SetNewName(); + +public slots: + virtual void SetIterParentName(); + virtual void PushHypoEdit(); + virtual void PushHypoNew(); + virtual void PushOnOK(); + virtual bool PushOnApply(); + virtual void PushOnHelp(); + virtual void SetFieldFile(); + virtual void SetTSNo(); + virtual void SetTSLast(); + virtual void SetTSChosen(); + +}; + +#endif // MON_CREATEITERATION_H diff --git a/src/ADAPTGUI/MonCreateListGroup.cxx b/src/ADAPTGUI/MonCreateListGroup.cxx new file mode 100644 index 000000000..3c4ef4c48 --- /dev/null +++ b/src/ADAPTGUI/MonCreateListGroup.cxx @@ -0,0 +1,153 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonCreateListGroup.h" +#include "MonCreateHypothesis.h" +#include "MonCreateBoundaryDi.h" + +#include + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include + +#include +#include +#include +#include +#include + +using namespace std; + +// -------------------------------------------------------------------------------------------------------------- +MonCreateListGroup::MonCreateListGroup(MonCreateHypothesis* parentHyp, MonCreateBoundaryDi* parentBound, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen0, QString aCaseName, QStringList listeGroupesHypo) : +// -------------------------------------------------------------------------------------------------------------- +// + QDialog(0), Ui_CreateListGroup(), + _aCaseName (aCaseName), + _listeGroupesHypo (listeGroupesHypo), + _parentHyp(parentHyp), + _parentBound(parentBound) +{ + MESSAGE("Debut de MonCreateListGroup") + myAdaptGen=ADAPT::ADAPT_Gen::_duplicate(myAdaptGen0); + setupUi(this); + setModal(modal); + InitConnect(); + InitGroupes(); +} +// -------------------------------------------------------------------------------------------------------------- +MonCreateListGroup::MonCreateListGroup(MonCreateHypothesis* parentHyp, MonCreateBoundaryDi* parentBound, + ADAPT::ADAPT_Gen_var myAdaptGen, QString aCaseName, QStringList listeGroupesHypo) : +// -------------------------------------------------------------------------------------------------------------- +// + QDialog(0), Ui_CreateListGroup(), + _aCaseName (aCaseName), + _listeGroupesHypo (listeGroupesHypo), + _parentHyp(parentHyp), + _parentBound(parentBound) +{ + myAdaptGen=ADAPT::ADAPT_Gen::_duplicate(myAdaptGen); + setupUi(this); + InitConnect(); +} + +// ------------------------------------------------------------------------ +MonCreateListGroup::~MonCreateListGroup() +// ------------------------------------------------------------------------ +{ + // no need to delete child widgets, Qt does it all for us +} +// ------------------------------------------------------------------------ +void MonCreateListGroup::InitConnect() +// ------------------------------------------------------------------------ +{ + connect( buttonOk, SIGNAL( pressed() ), this, SLOT( PushOnOK() ) ); + connect( buttonApply, SIGNAL( pressed() ), this, SLOT( PushOnApply() ) ); + connect( buttonCancel, SIGNAL( pressed() ), this, SLOT( close() ) ); + connect( buttonHelp, SIGNAL( pressed() ), this, SLOT( PushOnHelp() ) ); +} +// ------------------------------------------------------------------------ +bool MonCreateListGroup::PushOnApply() +// ------------------------------------------------------------------------ +// Appele lorsque l'un des boutons Ok ou Apply est presse +// +{ + QStringList ListeGroup ; + for ( int row=0; row< TWGroupe->rowCount(); row++) + { + if ( TWGroupe->item( row, 0 )->checkState() == Qt::Checked ) + ListeGroup.insert(0, QString(TWGroupe->item(row, 1)->text()) ); + } + if ( _parentHyp ) { _parentHyp->setGroups(ListeGroup);}; + if ( _parentBound ) { _parentBound->setGroups(ListeGroup);}; + return true; +} + + +// ------------------------------------------------------------------------ +void MonCreateListGroup::PushOnOK() +// ------------------------------------------------------------------------ +{ + if (PushOnApply()) + { + this->close(); + if ( _parentHyp ) { _parentHyp->raise(); _parentHyp->activateWindow(); }; + if ( _parentBound ) { _parentBound->raise(); _parentBound->activateWindow(); }; + } +} +// ------------------------------------------------------------------------ +void MonCreateListGroup::PushOnHelp() +// ------------------------------------------------------------------------ +{ + std::string LanguageShort = myAdaptGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_hypothese.html"), QString(""), QString(LanguageShort.c_str())); +} +// ------------------------------------------------------------------------ +void MonCreateListGroup::InitGroupes() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de MonCreateListGroup::InitGroupes "); + for ( int row=0; row< TWGroupe->rowCount(); row++) + TWGroupe->removeRow(row); + TWGroupe->setRowCount(0); + if (_aCaseName == QString("")) { return; }; + ADAPT::HOMARD_Cas_var monCas= myAdaptGen->GetCase(_aCaseName.toStdString().c_str()); + ADAPT::ListGroupType_var _listeGroupesCas = monCas->GetGroups(); + for ( int i = 0; i < _listeGroupesCas->length(); i++ ) + { + TWGroupe->insertRow(i); + TWGroupe->setItem( i, 0, new QTableWidgetItem( QString ("") ) ); + TWGroupe->item( i, 0 )->setFlags( 0 ); + TWGroupe->item( i, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled ); + if (_listeGroupesHypo.contains (QString((_listeGroupesCas)[i]))) + {TWGroupe->item( i, 0 )->setCheckState( Qt::Checked );} + else + {TWGroupe->item( i, 0 )->setCheckState( Qt::Unchecked );} + TWGroupe->setItem( i, 1, new QTableWidgetItem(QString((_listeGroupesCas)[i]).trimmed())); + TWGroupe->item( i, 1 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable ); + } + TWGroupe->resizeColumnsToContents(); + TWGroupe->resizeRowsToContents(); + TWGroupe->clearSelection(); +// MESSAGE("Fin de MonCreateListGroup::InitGroupes "); +} + diff --git a/src/ADAPTGUI/MonCreateListGroup.h b/src/ADAPTGUI/MonCreateListGroup.h new file mode 100644 index 000000000..9422e8be2 --- /dev/null +++ b/src/ADAPTGUI/MonCreateListGroup.h @@ -0,0 +1,64 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_CREATELISTGROUP_H +#define MON_CREATELISTGROUP_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) + +#include "ui_CreateListGroup.h" +#include + +class MonCreateHypothesis; +class MonCreateBoundaryDi; +class HOMARD_EXPORT MonCreateListGroup : public QDialog, public Ui_CreateListGroup +{ + Q_OBJECT + +public: + MonCreateListGroup( MonCreateHypothesis* parentHyp, MonCreateBoundaryDi* parentBound, bool modal, ADAPT::ADAPT_Gen_var myAdaptGen, QString aCaseName, QStringList listeGroupesHypo); + MonCreateListGroup( MonCreateHypothesis* parentHyp, MonCreateBoundaryDi* parentBound, ADAPT::ADAPT_Gen_var myAdaptGen, QString aCaseName, QStringList listeGroupesHypo); + virtual ~MonCreateListGroup(); + +protected : + + ADAPT::ADAPT_Gen_var myAdaptGen; + + MonCreateHypothesis * _parentHyp; + MonCreateBoundaryDi * _parentBound; + QString _aCaseName; + QStringList _listeGroupesHypo; + + virtual void InitConnect(); + virtual void InitGroupes(); + +public slots: + virtual void PushOnOK(); + virtual bool PushOnApply(); + virtual void PushOnHelp(); + +}; + +#endif // MON_CREATELISTGROUP_H diff --git a/src/ADAPTGUI/MonCreateListGroupCAO.cxx b/src/ADAPTGUI/MonCreateListGroupCAO.cxx new file mode 100644 index 000000000..5df4690dd --- /dev/null +++ b/src/ADAPTGUI/MonCreateListGroupCAO.cxx @@ -0,0 +1,150 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonCreateListGroupCAO.h" +#include "MonCreateHypothesis.h" +#include "MonCreateBoundaryCAO.h" + +#include + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include + +#include +#include +#include +#include +#include + +using namespace std; + +// -------------------------------------------------------------------------------------------------------------- +MonCreateListGroupCAO::MonCreateListGroupCAO(MonCreateHypothesis* parentHyp, MonCreateBoundaryCAO* parentBound, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen0, QString aCaseName, QStringList listeGroupesHypo) : +// -------------------------------------------------------------------------------------------------------------- +// + QDialog(0), Ui_CreateListGroup(), + _aCaseName (aCaseName), + _listeGroupesHypo (listeGroupesHypo), + _parentHyp(parentHyp), + _parentBound(parentBound) +{ + MESSAGE("Debut de MonCreateListGroupCAO") + myAdaptGen=ADAPT::ADAPT_Gen::_duplicate(myAdaptGen0); + setupUi(this); + setModal(modal); + InitConnect(); + InitGroupes(); +} +// -------------------------------------------------------------------------------------------------------------- +MonCreateListGroupCAO::MonCreateListGroupCAO(MonCreateHypothesis* parentHyp, MonCreateBoundaryCAO* parentBound, + ADAPT::ADAPT_Gen_var myAdaptGen, QString aCaseName, QStringList listeGroupesHypo) : +// -------------------------------------------------------------------------------------------------------------- +// + QDialog(0), Ui_CreateListGroup(), + _aCaseName (aCaseName), + _listeGroupesHypo (listeGroupesHypo), + _parentHyp(parentHyp), + _parentBound(parentBound) +{ + myAdaptGen=ADAPT::ADAPT_Gen::_duplicate(myAdaptGen); + setupUi(this); + InitConnect(); +} + +// ------------------------------------------------------------------------ +MonCreateListGroupCAO::~MonCreateListGroupCAO() +// ------------------------------------------------------------------------ +{ + // no need to delete child widgets, Qt does it all for us +} +// ------------------------------------------------------------------------ +void MonCreateListGroupCAO::InitConnect() +// ------------------------------------------------------------------------ +{ + connect( buttonOk, SIGNAL( pressed() ), this, SLOT( PushOnOK() ) ); + connect( buttonApply, SIGNAL( pressed() ), this, SLOT( PushOnApply() ) ); + connect( buttonCancel, SIGNAL( pressed() ), this, SLOT( close() ) ); + connect( buttonHelp, SIGNAL( pressed() ), this, SLOT( PushOnHelp() ) ); +} +// ------------------------------------------------------------------------ +bool MonCreateListGroupCAO::PushOnApply() +// ------------------------------------------------------------------------ +// Appele lorsque l'un des boutons Ok ou Apply est presse +// +{ + QStringList ListeGroup ; + for ( int row=0; row< TWGroupe->rowCount(); row++) + { + if ( TWGroupe->item( row, 0 )->checkState() == Qt::Checked ) + ListeGroup.insert(0, QString(TWGroupe->item(row, 1)->text()) ); + } + if ( _parentHyp ) { _parentHyp->setGroups(ListeGroup);}; + if ( _parentBound ) { _parentBound->setGroups(ListeGroup);}; + return true; +} + + +// ------------------------------------------------------------------------ +void MonCreateListGroupCAO::PushOnOK() +// ------------------------------------------------------------------------ +{ + if (PushOnApply()) this->close(); + if ( _parentHyp ) { _parentHyp->raise(); _parentHyp->activateWindow(); }; + if ( _parentBound ) { _parentBound->raise(); _parentBound->activateWindow(); }; +} +// ------------------------------------------------------------------------ +void MonCreateListGroupCAO::PushOnHelp() +// ------------------------------------------------------------------------ +{ + std::string LanguageShort = myAdaptGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_hypothese.html"), QString(""), QString(LanguageShort.c_str())); +} +// ------------------------------------------------------------------------ +void MonCreateListGroupCAO::InitGroupes() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de MonCreateListGroupCAO::InitGroupes "); + for ( int row=0; row< TWGroupe->rowCount(); row++) + TWGroupe->removeRow(row); + TWGroupe->setRowCount(0); + if (_aCaseName == QString("")) { return; }; + ADAPT::HOMARD_Cas_var monCas= myAdaptGen->GetCase(_aCaseName.toStdString().c_str()); + ADAPT::ListGroupType_var _listeGroupesCas = monCas->GetGroups(); + for ( int i = 0; i < _listeGroupesCas->length(); i++ ) + { + TWGroupe->insertRow(i); + TWGroupe->setItem( i, 0, new QTableWidgetItem( QString ("") ) ); + TWGroupe->item( i, 0 )->setFlags( 0 ); + TWGroupe->item( i, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled ); + if (_listeGroupesHypo.contains (QString((_listeGroupesCas)[i]))) + {TWGroupe->item( i, 0 )->setCheckState( Qt::Checked );} + else + {TWGroupe->item( i, 0 )->setCheckState( Qt::Unchecked );} + TWGroupe->setItem( i, 1, new QTableWidgetItem(QString((_listeGroupesCas)[i]).trimmed())); + TWGroupe->item( i, 1 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable ); + } + TWGroupe->resizeColumnsToContents(); + TWGroupe->resizeRowsToContents(); + TWGroupe->clearSelection(); +// MESSAGE("Fin de MonCreateListGroupCAO::InitGroupes "); +} + diff --git a/src/ADAPTGUI/MonCreateListGroupCAO.h b/src/ADAPTGUI/MonCreateListGroupCAO.h new file mode 100644 index 000000000..1e291d331 --- /dev/null +++ b/src/ADAPTGUI/MonCreateListGroupCAO.h @@ -0,0 +1,64 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_CREATELISTGROUPCAO_H +#define MON_CREATELISTGROUPCAO_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) + +#include "ui_CreateListGroup.h" +#include + +class MonCreateHypothesis; +class MonCreateBoundaryCAO; +class HOMARD_EXPORT MonCreateListGroupCAO : public QDialog, public Ui_CreateListGroup +{ + Q_OBJECT + +public: + MonCreateListGroupCAO( MonCreateHypothesis* parentHyp, MonCreateBoundaryCAO* parentBound, bool modal, ADAPT::ADAPT_Gen_var myAdaptGen, QString aCaseName, QStringList listeGroupesHypo); + MonCreateListGroupCAO( MonCreateHypothesis* parentHyp, MonCreateBoundaryCAO* parentBound, ADAPT::ADAPT_Gen_var myAdaptGen, QString aCaseName, QStringList listeGroupesHypo); + virtual ~MonCreateListGroupCAO(); + +protected : + + ADAPT::ADAPT_Gen_var myAdaptGen; + + MonCreateHypothesis * _parentHyp; + MonCreateBoundaryCAO * _parentBound; + QString _aCaseName; + QStringList _listeGroupesHypo; + + virtual void InitConnect(); + virtual void InitGroupes(); + +public slots: + virtual void PushOnOK(); + virtual bool PushOnApply(); + virtual void PushOnHelp(); + +}; + +#endif // MON_CREATELISTGROUPCAO_H diff --git a/src/ADAPTGUI/MonCreateYACS.cxx b/src/ADAPTGUI/MonCreateYACS.cxx new file mode 100644 index 000000000..e0ae6fda1 --- /dev/null +++ b/src/ADAPTGUI/MonCreateYACS.cxx @@ -0,0 +1,342 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonCreateYACS.h" +#include "HOMARD.hxx" + +#include +#include + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include + +#ifdef WIN32 +#include +#endif +using namespace std; + +// ---------------------------------------------------------------------- +MonCreateYACS::MonCreateYACS (bool modal, ADAPT::ADAPT_Gen_var myAdaptGen0, QString CaseName ): +// ---------------------------------------------------------------------- +/* Constructs a MonCreateYACS + * Sets attributes to default values + */ +// ---------------------------------------------------------------------- + Ui_CreateYACS(), + _aCaseName(CaseName), + _aScriptFile(""), + _aDirName(""), + _aMeshFile(""), + _Type(1) + // Les valeurs de _Type, _MaxIter, _MaxNode, _MaxElem doivent etre les memes que celles dans ADAPT_Gen_i::CreateYACSSchema + // et doivent correspondre aux defauts des boutons + { +// MESSAGE("Debut du constructeur de MonCreateYACS"); + myAdaptGen=ADAPT::ADAPT_Gen::_duplicate(myAdaptGen0); + setupUi(this); + if ( modal ) { setWindowModality(Qt::WindowModal); } + else { setWindowModality(Qt::NonModal); } + + InitConnect(); + + SetNewName() ; + + if (_aCaseName != QString("")) { SetCaseName(); } + else { setWindowModality(Qt::NonModal); /* permet selection du cas dans l arbre d etude */} +// +// Les valeurs definies dans les preferences + _MaxIter = myAdaptGen->GetYACSMaxIter(); + _MaxNode = myAdaptGen->GetYACSMaxNode(); + _MaxElem = myAdaptGen->GetYACSMaxElem(); + MESSAGE ("Valeur par defaut de MaxIter = " << _MaxIter<<", MaxNode = "<< _MaxNode<<", MaxElem = "<< _MaxElem); + SpinBoxMaxIter->setValue(_MaxIter) ; + SpinBoxMaxNode->setValue(_MaxNode) ; + SpinBoxMaxElem->setValue(_MaxElem) ; +// + adjustSize(); + } + +// ---------------------------------------------------------------------- +MonCreateYACS::MonCreateYACS(ADAPT::ADAPT_Gen_var myAdaptGen0, + QString caseName): +// ---------------------------------------------------------------------- +// Constructeur appele par MonEditYACS +// +myAdaptGen(myAdaptGen0), +_Name (""), +Chgt (false) +{ +// MESSAGE("Debut du constructeur de MonCreateYACS appele par MonEditYACS"); + setupUi(this) ; + + setWindowModality(Qt::WindowModal); + InitConnect() ; +// + adjustSize(); +} +// ------------------------------------------------------------------------ +MonCreateYACS::~MonCreateYACS() +// ------------------------------------------------------------------------ +{ + // no need to delete child widgets, Qt does it all for us +} +// ------------------------------------------------------------------------ +void MonCreateYACS::InitConnect() +// ------------------------------------------------------------------------ +{ + connect( PBCaseName, SIGNAL(pressed()), this, SLOT(SetCaseName())); + connect( PBScriptFile, SIGNAL(pressed()), this, SLOT(SetScriptFile())); + connect( PBDir, SIGNAL(pressed()), this, SLOT(SetDirName())); + connect( PBMeshFile, SIGNAL(pressed()), this, SLOT(SetMeshFile())); + + connect( RBConstant, SIGNAL(clicked()), this, SLOT(SetConstant())); + connect( RBVariable, SIGNAL(clicked()), this, SLOT(SetVariable())); + + connect( buttonOk, SIGNAL(pressed()), this, SLOT(PushOnOK())); + connect( buttonApply, SIGNAL(pressed()), this, SLOT(PushOnApply())); + connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close())); + connect( buttonHelp, SIGNAL(pressed()), this, SLOT(PushOnHelp())); +} +// ------------------------------- +bool MonCreateYACS::PushOnApply() +// -------------------------------- +{ + MESSAGE("PushOnApply"); + +// Le fichier du script + QString aFileName=LEScriptFile->text().trimmed(); + if (aFileName ==QString("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_SCRIPT_FILE") ); + return false; + } + +// Le repertoire de calcul + QString aDirName=LEDirName->text().trimmed(); + if (aDirName == QString("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_CASE_DIRECTORY_4") ); + return false; + } + if ( aDirName != _aDirName) + { QString CaseNameDir = myAdaptGen->VerifieDir( aDirName.toStdString().c_str()) ; + if ( CaseNameDir != "" ) + { + QString texte ; + texte = QObject::tr("HOM_CASE_DIRECTORY_2") + CaseNameDir ; + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + texte ); + return false; + } + } + if (CHDIR(aDirName.toStdString().c_str()) != 0) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_CASE_DIRECTORY_3") ); + return false; + } + +// Le fichier du tout premier maillage + aFileName=LEMeshFile->text().trimmed(); + if (aFileName ==QString("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_CASE_MESH") ); + return false; + } + QString aMeshName = HOMARD_QT_COMMUN::LireNomMaillage(aFileName); + if (aMeshName == "" ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_MED_FILE_2") ); + return false; + } + + bool bOK = CreateOrUpdate() ; + + if ( bOK ) { HOMARD_UTILS::updateObjBrowser() ; } + + return bOK; +} +// --------------------------------------------------- +bool MonCreateYACS:: CreateOrUpdate() +//---------------------------------------------------- +// Creation ou modification du schema +{ + MESSAGE("CreateOrUpdate"); + bool bOK = true ; + + // 1. Verification des donnees + // 1.1. Le cas + if ( _aCaseName == QString ("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_CASE_NAME") ); + return false; + } + // 1.2. Les donnees + QString aScriptFile=LEScriptFile->text().trimmed(); + if ( aScriptFile != _aScriptFile ) + { + _aScriptFile = aScriptFile ; + Chgt = true ; + } + QString aDirName=LEDirName->text().trimmed(); + if ( aDirName != _aDirName ) + { + _aDirName = aDirName ; + Chgt = true ; + } + QString aMeshFile=LEMeshFile->text().trimmed(); + if ( aMeshFile != _aMeshFile ) + { + _aMeshFile = aMeshFile ; + Chgt = true ; + } + + // 2. Creation de l'objet CORBA + try + { + _Name=LEName->text().trimmed(); + aYACS=myAdaptGen->CreateYACSSchema(CORBA::string_dup(_Name.toStdString().c_str()), CORBA::string_dup(_aCaseName.toStdString().c_str()), CORBA::string_dup(_aScriptFile.toStdString().c_str()), CORBA::string_dup(_aDirName.toStdString().c_str()), CORBA::string_dup(_aMeshFile.toStdString().c_str())); + } + catch( SALOME::SALOME_Exception& S_ex ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr(CORBA::string_dup(S_ex.details.text)) ); + bOK = false; + } + + // 3. Options + if ( bOK ) + { + // 3.1. Le type du schema + aYACS->SetType(_Type) ; + + // 3.2. Les maximums + _MaxIter = SpinBoxMaxIter->value() ; + aYACS->SetMaxIter(_MaxIter) ; + + _MaxNode = SpinBoxMaxNode->value() ; + aYACS->SetMaxNode(_MaxNode) ; + + _MaxElem = SpinBoxMaxElem->value() ; + aYACS->SetMaxElem(_MaxElem) ; + + } + + // 4. Ecriture du fichier + if ( bOK ) + { + int codret = aYACS->Write() ; + if ( codret != 0 ) { bOK = false ; } + } + + return bOK; +} +// --------------------------- +void MonCreateYACS::PushOnOK() +// --------------------------- +{ + bool bOK = PushOnApply(); + if ( bOK ) this->close(); +} +//------------------------------ +void MonCreateYACS::PushOnHelp() +//------------------------------- +{ + std::string LanguageShort = myAdaptGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("yacs.html"), QString(""), QString(LanguageShort.c_str())); +} +// ------------------------------------------------- +void MonCreateYACS::SetNewName() +// -------------------------------------------------- +{ + + ADAPT::listeYACSs_var MyObjects = myAdaptGen->GetAllYACSsName(); + int num = 0; QString aName=""; + while (aName == QString("") ) + { + aName.setNum(num+1) ; + aName.insert(0, QString("YACS_")) ; + for ( int i=0; ilength(); i++) + { + if ( aName == QString(MyObjects[i])) + { + num ++ ; + aName = "" ; + break ; + } + } + } + LEName->setText(aName); +} +// ------------------------------------------------------------------------ +void MonCreateYACS::SetCaseName() +// ------------------------------------------------------------------------ +{ + MESSAGE ("SetCaseName avec _aCaseName = " << _aCaseName.toStdString() ); + if (_aCaseName == QString("")) + { + _aCaseName=HOMARD_QT_COMMUN::SelectionArbreEtude(QString("CasHomard"), 1); + if (_aCaseName == QString("")) { raise();return;}; + } + LECaseName->setText(_aCaseName); +} +// ------------------------------------------------------------------------ +void MonCreateYACS::SetDirName() +// ------------------------------------------------------------------------ +{ + QString aDirName=QFileDialog::getExistingDirectory (); + if (!(aDirName.isEmpty()))LEDirName->setText(aDirName); +} +// ------------------------------------------------------------------------ +void MonCreateYACS::SetScriptFile() +// ------------------------------------------------------------------------ +{ + QString fileName0 = LEScriptFile->text().trimmed(); + QString fileName = HOMARD_QT_COMMUN::PushNomFichier( false, QString("py") ) ; + if (fileName.isEmpty()) fileName = fileName0 ; + LEScriptFile->setText(fileName); +} +// ------------------------------------------------------------------------ +void MonCreateYACS::SetMeshFile() +// ------------------------------------------------------------------------ +{ + QString fileName0 = LEMeshFile->text().trimmed(); + QString fileName = HOMARD_QT_COMMUN::PushNomFichier( false, QString("med") ) ; + if (fileName.isEmpty()) fileName = fileName0 ; + LEMeshFile->setText(fileName); +} +// ------------------------------------------------------------------------ +void MonCreateYACS::SetConstant() +// ------------------------------------------------------------------------ +{ + _Type = 1 ; +} +// ------------------------------------------------------------------------ +void MonCreateYACS::SetVariable() +// ------------------------------------------------------------------------ +{ + _Type = 2 ; +} diff --git a/src/ADAPTGUI/MonCreateYACS.h b/src/ADAPTGUI/MonCreateYACS.h new file mode 100644 index 000000000..ea93be821 --- /dev/null +++ b/src/ADAPTGUI/MonCreateYACS.h @@ -0,0 +1,84 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_CREATEYACS_H +#define MON_CREATEYACS_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) +#include CORBA_CLIENT_HEADER(HOMARD_Cas) + +#include "ui_CreateYACS.h" +#include + +class HOMARD_EXPORT MonCreateYACS : public QScrollArea, public Ui_CreateYACS +{ + Q_OBJECT + + public: + MonCreateYACS( bool modal, ADAPT::ADAPT_Gen_var myAdaptGen, QString CaseName); + virtual ~MonCreateYACS(); + + protected : + MonCreateYACS( ADAPT::ADAPT_Gen_var myAdaptGen, QString CaseName); + + QString _Name; + QString _aCaseName; + QString _aScriptFile; + QString _aDirName; + QString _aMeshFile; + + int _Type; + int _MaxIter; + int _MaxNode; + int _MaxElem; + + bool Chgt; + + ADAPT::HOMARD_YACS_var aYACS; + ADAPT::ADAPT_Gen_var myAdaptGen; + + virtual void InitConnect(); + virtual bool CreateOrUpdate(); + + public slots: + virtual void SetNewName(); + + virtual void SetCaseName(); + virtual void SetDirName(); + + virtual void SetScriptFile(); + virtual void SetMeshFile(); + +// virtual void SetType(int Type); + virtual void SetConstant(); + virtual void SetVariable(); + + virtual void PushOnOK(); + virtual bool PushOnApply(); + virtual void PushOnHelp(); + +}; + +#endif // MON_CREATEYACS_H diff --git a/src/ADAPTGUI/MonCreateZone.cxx b/src/ADAPTGUI/MonCreateZone.cxx new file mode 100644 index 000000000..aeb3b6ac9 --- /dev/null +++ b/src/ADAPTGUI/MonCreateZone.cxx @@ -0,0 +1,713 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonCreateZone.h" +#include "MonCreateHypothesis.h" + +#include +#include + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include + +#include +#include +#include +#include +#include + +using namespace std; + +// ---------------------------------------------------------------------- +MonCreateZone::MonCreateZone(MonCreateHypothesis* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen0, + QString caseName) : +// ---------------------------------------------------------------------- +/* Constructs a MonCreateZone + appele pour une vraie creation + initialise une boite et non une sphere +*/ + QDialog(0), Ui_CreateZone(), + _parent(parent), + _Name (""), + _aCaseName(caseName), + _Orient(0), + _Type(2), + _Xcentre(0), _Ycentre(0), _Zcentre(0), _Rayon(0), + _ZoneXcentre(0), _ZoneYcentre(0), _ZoneZcentre(0), _ZoneRayon(0), + _Xmin(0), _Xmax(0), _Xincr(0), _Ymin(0), _Ymax(0), _Yincr(0), _Zmin(0), _Zmax(0), _Zincr(0), + _ZoneXmin(0), _ZoneXmax(0), _ZoneYmin(0), _ZoneYmax(0), _ZoneZmin(0), _ZoneZmax(0), + _Xaxis(0), _Yaxis(0), _Zaxis(0), _RayonInt(0), _Haut(0), + _ZoneXaxis(0), _ZoneYaxis(0), _ZoneZaxis(0), _ZoneRayonInt(0), _ZoneHaut(0), + _DMax(0), + Chgt (false) + { + MESSAGE("Constructeur") ; + myAdaptGen=ADAPT::ADAPT_Gen::_duplicate(myAdaptGen0) ; + setupUi(this) ; + setModal(modal) ; + InitConnect( ) ; + + SetNewName() ; + InitValZone() ; // Cherche les valeurs de la boite englobante le maillage + InitMinMax() ; // Initialise les bornes des boutons + SetBox() ; // Propose une boite en premier choix + + } +// ---------------------------------------------------------------------- +MonCreateZone::MonCreateZone(MonCreateHypothesis* parent, + ADAPT::ADAPT_Gen_var myAdaptGen0, + QString caseName): +// ---------------------------------------------------------------------- +// Constructeur appele par MonEditZone +// + QDialog(0), Ui_CreateZone(), + myAdaptGen(myAdaptGen0), + _parent(parent), + _Name (""), + _aCaseName(caseName), + _Orient(0), + _Type(2), + _Xcentre(0), _Ycentre(0), _Zcentre(0), _Rayon(0), + _ZoneXcentre(0), _ZoneYcentre(0), _ZoneZcentre(0), _ZoneRayon(0), + _ZoneXmin(0), _ZoneXmax(0), _ZoneYmin(0), _ZoneYmax(0), _ZoneZmin(0), _ZoneZmax(0), + _Xaxis(0), _Yaxis(0), _Zaxis(0), _RayonInt(0), _Haut(0), + _ZoneXaxis(0), _ZoneYaxis(0), _ZoneZaxis(0), _ZoneRayonInt(0), _ZoneHaut(0), + // Pour affichage lors de l edition d une Zone sans nom de Cas + _Xmin(1), _Xmax(1), _Xincr(1), _Ymin(1), _Ymax(1), _Yincr(1), _Zmin(1), _Zmax(1), _Zincr(1), + _DMax(1), + Chgt (false) + { + // MESSAGE("Debut de MonCreateZone") + setupUi(this) ; + + setModal(true) ; + InitConnect() ; + } + +// ------------------------------------------------------------------------ +MonCreateZone::~MonCreateZone() +// ------------------------------------------------------------------------ +{ + // no need to delete child widgets, Qt does it all for us +} +// ------------------------------------------------------------------------ +void MonCreateZone::InitConnect() +// ------------------------------------------------------------------------ +{ + connect( RBBox, SIGNAL(clicked()) , this, SLOT(SetBox()) ) ; + connect( RBSphere, SIGNAL(clicked()) , this, SLOT(SetSphere()) ) ; + connect( RBCylinder, SIGNAL(clicked()) , this, SLOT(SetCylinder()) ) ; + connect( RBPipe, SIGNAL(clicked()) , this, SLOT(SetPipe()) ) ; + connect( buttonOk, SIGNAL( pressed() ), this, SLOT( PushOnOK() ) ) ; + connect( buttonApply, SIGNAL( pressed() ), this, SLOT( PushOnApply() ) ) ; + connect( buttonCancel, SIGNAL( pressed() ), this, SLOT( close() ) ) ; + connect( buttonHelp, SIGNAL( pressed() ), this, SLOT( PushOnHelp() ) ) ; +} +// ------------------------------------------------------------------------ +void MonCreateZone::InitValZone() +// ------------------------------------------------------------------------ +{ +// +// 1. Les coordonnees extremes du maillage +// + if (_aCaseName == QString("")) { return; } + + ADAPT::HOMARD_Cas_var aCas = myAdaptGen->GetCase(_aCaseName.toStdString().c_str()) ; + ADAPT::extrema_var MesExtremes = aCas->GetBoundingBox() ; + int num = MesExtremes->length() ; + ASSERT(num == 10) ; + _Xmin=MesExtremes[0]; _Xmax=MesExtremes[1]; _Xincr=MesExtremes[2]; + _Ymin=MesExtremes[3]; _Ymax=MesExtremes[4]; _Yincr=MesExtremes[5]; + _Zmin=MesExtremes[6]; _Zmax=MesExtremes[7]; _Zincr=MesExtremes[8]; + _DMax=MesExtremes[9]; + if ( _Xincr < 0 ) { _Orient = 2 ; } + else if ( _Yincr < 0 ) { _Orient = 3 ; } + else if ( _Zincr < 0 ) { _Orient = 1 ; } + MESSAGE ("_Xmin : " << _Xmin << " _Xmax : " << _Xmax << " _Xincr : " << _Xincr ) ; + MESSAGE ("_Ymin : " << _Ymin << " _Ymax : " << _Ymax << " _Yincr : " << _Yincr ) ; + MESSAGE ("_Zmin : " << _Zmin << " _Zmax : " << _Zmax << " _Zincr : " << _Zincr) ; + MESSAGE ("_DMax : " << _DMax) ; + MESSAGE ("_Orient : " << _Orient) ; +// 2. Caracteristiques des zones +// en X + if ( _Xincr < 0 ) + { + _ZoneXmin = _Xmin; + _ZoneXmax = _Xmax; + } + else + { + _ZoneXmin = _Xmin - _Xincr; + _ZoneXmax = _Xmax + _Xincr; + } + _Xcentre=(_Xmin + _Xmax)/2.; +// en Y + if ( _Yincr < 0 ) + { + _ZoneYmin = _Ymin; + _ZoneYmax = _Ymax; + } + else + { + _ZoneYmin = _Ymin - _Yincr; + _ZoneYmax = _Ymax + _Yincr; + } + _Ycentre=(_Ymin + _Ymax)/2.; +// en Z + if ( _Zincr < 0 ) + { + _ZoneZmin = _Zmin; + _ZoneZmax = _Zmax; + } + else + { + _ZoneZmin = _Zmin - _Zincr; + _ZoneZmax = _Zmax + _Zincr; + } + _Zcentre=(_Zmin + _Zmax)/2.; +// Rayons + _Rayon= _DMax/4.; + _RayonInt= _DMax/8.; +// Axe et hauteur pour cylindre et tuyau + _Haut= _DMax/2.; +// 3. Gestion des icones + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr() ; + QPixmap pix = resMgr->loadPixmap( "HOMARD", "boxdxyz.png" ) ; + if ( _Orient == 0 ) { pix = resMgr->loadPixmap( "HOMARD", "boxdxyz.png" ) ; } + else { pix = resMgr->loadPixmap( "HOMARD", "boxdxy.png" ) ; } + QIcon IS=QIcon(pix) ; + RBBox->setIcon(IS) ; + + if ( _Orient == 0 ) { pix = resMgr->loadPixmap( "HOMARD", "cylinderpointvector.png" ) ; } + else { pix = resMgr->loadPixmap( "HOMARD", "disk.png" ) ; + RBCylinder->setText(QApplication::translate("CreateZone", "Disk", 0)); + TLXbase->setText(QApplication::translate("CreateZone", "X centre", 0)); + TLYbase->setText(QApplication::translate("CreateZone", "Y centre", 0)); + TLZbase->setText(QApplication::translate("CreateZone", "Z centre", 0)); } + IS=QIcon(pix) ; + RBCylinder->setIcon(IS) ; + + if ( _Orient == 0 ) { pix = resMgr->loadPixmap( "HOMARD", "pipe.png" ) ; } + else { pix = resMgr->loadPixmap( "HOMARD", "diskwithhole.png" ) ; + RBPipe->setText(QApplication::translate("CreateZone", "Disk with hole", 0)); + TLXbase_p->setText(QApplication::translate("CreateZone", "X centre", 0)); + TLYbase_p->setText(QApplication::translate("CreateZone", "Y centre", 0)); + TLZbase_p->setText(QApplication::translate("CreateZone", "Z centre", 0)); } + IS=QIcon(pix) ; + RBPipe->setIcon(IS) ; + + if ( _Orient == 0 ) { pix = resMgr->loadPixmap( "HOMARD", "spherepoint.png" ) ; + IS=QIcon(pix) ; + RBSphere->setIcon(IS) ; } + else { RBSphere->setVisible(0) ; } +} + +// ------------------------------------------------------------------------ +void MonCreateZone::InitMinMax() +// ------------------------------------------------------------------------ +{ +// en X + if ( _Xincr > 0) { + SpinBox_Xmini->setRange(_ZoneXmin,_ZoneXmax) ; + SpinBox_Xmaxi->setRange(_ZoneXmin,_ZoneXmax) ; + SpinBox_Xmini->setSingleStep(_Xincr) ; + SpinBox_Xmaxi->setSingleStep(_Xincr) ; + SpinBox_Xcentre->setSingleStep(_Xincr) ; + } + else { + SpinBox_Xmini->setValue(_ZoneXmin) ; + SpinBox_Xmaxi->setValue(_ZoneXmax) ; + SpinBox_Xcentre->setValue(_Xcentre) ; + SpinBox_Xbase->setValue(_Xcentre) ; + SpinBox_Xbase_p->setValue(_Xcentre) ; + SpinBox_Xmini->setEnabled(false) ; + SpinBox_Xmaxi->setEnabled(false) ; + SpinBox_Xcentre->setEnabled(false) ; + SpinBox_Xbase->setEnabled(false) ; + SpinBox_Xbase_p->setEnabled(false) ; + } +// en Y + if ( _Yincr > 0) { + SpinBox_Ymini->setRange(_ZoneYmin,_ZoneYmax) ; + SpinBox_Ymaxi->setRange(_ZoneYmin,_ZoneYmax) ; + SpinBox_Ymini->setSingleStep(_Yincr) ; + SpinBox_Ymaxi->setSingleStep(_Yincr) ; + SpinBox_Ycentre->setSingleStep(_Yincr) ; + } + else { + SpinBox_Ymini->setValue(_ZoneYmin) ; + SpinBox_Ymaxi->setValue(_ZoneYmax) ; + SpinBox_Ycentre->setValue(_Ycentre) ; + SpinBox_Ybase->setValue(_Ycentre) ; + SpinBox_Ybase_p->setValue(_Ycentre) ; + SpinBox_Ymini->setEnabled(false) ; + SpinBox_Ymaxi->setEnabled(false) ; + SpinBox_Ycentre->setEnabled(false) ; + SpinBox_Ybase->setEnabled(false) ; + SpinBox_Ybase_p->setEnabled(false) ; + } +// en Z + if ( _Zincr > 0) { + SpinBox_Zmini->setRange(_ZoneZmin,_ZoneZmax) ; + SpinBox_Zmaxi->setRange(_ZoneZmin,_ZoneZmax) ; + SpinBox_Zmini->setSingleStep(_Zincr) ; + SpinBox_Zmaxi->setSingleStep(_Zincr) ; + SpinBox_Zcentre->setSingleStep(_Zincr) ; + } + else { + SpinBox_Zmini->setValue(_ZoneZmin) ; + SpinBox_Zmaxi->setValue(_ZoneZmax) ; + SpinBox_Zcentre->setValue(_Zcentre) ; + SpinBox_Zbase->setValue(_Zcentre) ; + SpinBox_Zbase_p->setValue(_Zcentre) ; + SpinBox_Zmini->setEnabled(false) ; + SpinBox_Zmaxi->setEnabled(false) ; + SpinBox_Zcentre->setEnabled(false) ; + SpinBox_Zbase->setEnabled(false) ; + SpinBox_Zbase_p->setEnabled(false) ; + } +// Rayons + SpinBox_Rayon->setSingleStep(_Rayon/10.) ; + SpinBox_Radius->setSingleStep(_Rayon/10.) ; + SpinBox_Radius_int->setSingleStep(_Rayon/20.) ; + SpinBox_Radius_ext->setSingleStep(_Rayon/10.) ; +// Axe et hauteur +// Si une coordonnee est constante, inutile de demander l'axe et la hauteur + if ( _Orient > 0) { + SpinBox_Xaxis->setVisible(0) ; + SpinBox_Yaxis->setVisible(0) ; + SpinBox_Zaxis->setVisible(0) ; + SpinBox_Haut->setVisible(0) ; + TLXaxis->setVisible(0) ; + TLYaxis->setVisible(0) ; + TLZaxis->setVisible(0) ; + TLHaut->setVisible(0) ; + SpinBox_Xaxis_p->setVisible(0) ; + SpinBox_Yaxis_p->setVisible(0) ; + SpinBox_Zaxis_p->setVisible(0) ; + SpinBox_Haut_p->setVisible(0) ; + TLXaxis_p->setVisible(0) ; + TLYaxis_p->setVisible(0) ; + TLZaxis_p->setVisible(0) ; + TLHaut_p->setVisible(0) ; + } + else { + SpinBox_Haut->setSingleStep(_Rayon/10.) ; + SpinBox_Haut_p->setSingleStep(_Rayon/10.) ; + } +} +// ------------------------------------------------------------------------ +bool MonCreateZone::PushOnApply() +// ------------------------------------------------------------------------ +// Appele lorsque l'un des boutons Ok ou Apply est presse +// +{ + if (LEName->text().trimmed()=="") + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_ZONE_NAME") ) ; + return false; + } + + switch (_Type) + { + case 11 : // il s agit d un rectangle + { } + case 12 : // il s agit d un rectangle + { } + case 13 : // il s agit d un rectangle + { } + case 2 : // il s agit d un parallelipipede rectangle + { + if ( (_ZoneXmin != SpinBox_Xmini->value()) || + (_ZoneXmax != SpinBox_Xmaxi->value()) || + (_ZoneYmin != SpinBox_Ymini->value()) || + (_ZoneYmax != SpinBox_Ymaxi->value()) || + (_ZoneZmin != SpinBox_Zmini->value()) || + (_ZoneZmax != SpinBox_Zmaxi->value()) ) + { + Chgt = true; + _ZoneXmin= SpinBox_Xmini->value() ; _ZoneXmax= SpinBox_Xmaxi->value() ; + _ZoneYmin= SpinBox_Ymini->value() ; _ZoneYmax= SpinBox_Ymaxi->value() ; + _ZoneZmin= SpinBox_Zmini->value() ; _ZoneZmax= SpinBox_Zmaxi->value() ; + } + break ; + } + case 4 : // il s agit d une sphere + { + if ( (_ZoneXcentre != SpinBox_Xcentre->value()) || + (_ZoneYcentre != SpinBox_Ycentre->value()) || + (_ZoneZcentre != SpinBox_Zbase->value()) || + (_ZoneRayon != SpinBox_Rayon->value()) ) + { + Chgt = true; + _ZoneXcentre=SpinBox_Xcentre->value() ; + _ZoneYcentre=SpinBox_Ycentre->value() ; + _ZoneZcentre=SpinBox_Zcentre->value() ; + _ZoneRayon=SpinBox_Rayon->value() ; + } + break ; + } + case 31 : // il s agit d un disque issu d'un cylindre + { } + case 32 : // il s agit d un disque issu d'un cylindre + { } + case 33 : // il s agit d un disque issu d'un cylindre + { } + case 5 : // il s agit d un cylindre + { + if ( (_ZoneXcentre != SpinBox_Xbase->value()) || + (_ZoneYcentre != SpinBox_Ybase->value()) || + (_ZoneZcentre != SpinBox_Zbase->value()) || + (_ZoneRayon != SpinBox_Radius->value()) || + (_ZoneHaut != SpinBox_Haut->value()) || + (_ZoneXaxis != SpinBox_Xaxis->value()) || + (_ZoneYaxis != SpinBox_Yaxis->value()) || + (_ZoneZaxis != SpinBox_Zaxis->value()) ) + { + Chgt = true; + _ZoneXcentre=SpinBox_Xbase->value() ; + _ZoneYcentre=SpinBox_Ybase->value() ; + _ZoneZcentre=SpinBox_Zbase->value() ; + _ZoneXaxis=SpinBox_Xaxis->value() ; + _ZoneYaxis=SpinBox_Yaxis->value() ; + _ZoneZaxis=SpinBox_Zaxis->value() ; + _ZoneRayon=SpinBox_Radius->value() ; + _ZoneHaut=SpinBox_Haut->value() ; + } + break ; + } + case 61 : // il s agit d un disque avec trou + { } + case 62 : // il s agit d un disque avec trou + { } + case 63 : // il s agit d un disque avec trou + { } + case 7 : // il s agit d un tuyau + { + if ( (_ZoneXcentre != SpinBox_Xbase_p->value()) || + (_ZoneYcentre != SpinBox_Ybase_p->value()) || + (_ZoneZcentre != SpinBox_Zbase_p->value()) || + (_ZoneRayonInt != SpinBox_Radius_int->value()) || + (_ZoneRayon != SpinBox_Radius_ext->value()) || + (_ZoneHaut != SpinBox_Haut_p->value()) || + (_ZoneXaxis != SpinBox_Xaxis_p->value()) || + (_ZoneYaxis != SpinBox_Yaxis_p->value()) || + (_ZoneZaxis != SpinBox_Zaxis_p->value()) ) + { + Chgt = true; + _ZoneXcentre=SpinBox_Xbase_p->value() ; + _ZoneYcentre=SpinBox_Ybase_p->value() ; + _ZoneZcentre=SpinBox_Zbase_p->value() ; + _ZoneXaxis=SpinBox_Xaxis_p->value() ; + _ZoneYaxis=SpinBox_Yaxis_p->value() ; + _ZoneZaxis=SpinBox_Zaxis_p->value() ; + _ZoneRayonInt=SpinBox_Radius_int->value() ; + _ZoneRayon=SpinBox_Radius_ext->value() ; + _ZoneHaut=SpinBox_Haut_p->value() ; + } + break ; + } + } + +// Controles +// Pour un rectangle ou un parallelepipede : + if ( ( _Type >= 11 && _Type <= 13 ) || _Type == 2 ) + { + if ((_ZoneXmin >= _ZoneXmax) && (_Xincr > 0)) { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_ZONE_LIMIT").arg("X") ) ; + return false; } + + if ((_ZoneYmin >= _ZoneYmax) && (_Yincr > 0)) { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_ZONE_LIMIT").arg("Y") ) ; + return false; } + + if ((_ZoneZmin >= _ZoneZmax) && (_Zincr > 0)) { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_ZONE_LIMIT").arg("Z") ) ; + return false; } + } +// L'axe pour un cylindre ou un tuyau : + if ( _Type == 5 || _Type == 7 ) + { + double daux = _ZoneXaxis*_ZoneXaxis + _ZoneYaxis*_ZoneYaxis + _ZoneZaxis*_ZoneZaxis ; + if ( daux < 0.0000001 ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_AXE") ); + return false; + } + } +// Rayons pour disque avec trou ou un tuyau : + if ( ( _Type >= 61 && _Type <= 63 ) || _Type == 7 ) + { + if ( _ZoneRayonInt >= _ZoneRayon ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_ZONE_RAYON") ); + return false; + } + } +// +// Création ou mise à jour de la zone +// + bool bOK = CreateOrUpdateZone() ; + + if ( bOK ) { HOMARD_UTILS::updateObjBrowser() ; } + + return bOK; + +} +// --------------------------------------------------- +bool MonCreateZone::CreateOrUpdateZone() +//---------------------------------------------------- +// Creation de la zone +{ + MESSAGE("Debut de CreateOrUpdateZone avec _Type ="<<_Type<<", _Name ="<<_Name.toStdString().c_str()<<" et LEName ="<text().trimmed().toStdString().c_str()); +// + if (_Name != LEName->text().trimmed()) + { + _Name = LEName->text().trimmed() ; + try + { + switch (_Type) + { + case 11 : // il s agit d un rectangle, dans le plan (X,Y) + { aZone = myAdaptGen->CreateZoneBox2D(CORBA::string_dup(_Name.toStdString().c_str()), \ + _ZoneXmin, _ZoneXmax, _ZoneYmin, _ZoneYmax, _Orient ); + break; + } + case 12 : // il s agit d un rectangle, dans le plan (Y,Z) + { aZone = myAdaptGen->CreateZoneBox2D(CORBA::string_dup(_Name.toStdString().c_str()), \ + _ZoneYmin, _ZoneYmax, _ZoneZmin, _ZoneZmax, _Orient ); + break; + } + case 13 : // il s agit d un rectangle, dans le plan (Z,X) + { aZone = myAdaptGen->CreateZoneBox2D(CORBA::string_dup(_Name.toStdString().c_str()), \ + _ZoneZmin, _ZoneZmax, _ZoneXmin, _ZoneXmax, _Orient ); + break; + } + case 2 : // il s agit d un parallelepipede + { aZone = myAdaptGen->CreateZoneBox(CORBA::string_dup(_Name.toStdString().c_str()), \ + _ZoneXmin, _ZoneXmax, _ZoneYmin, _ZoneYmax, _ZoneZmin, _ZoneZmax ); + break; + } + case 4 : // il s agit d une sphere + { aZone = myAdaptGen->CreateZoneSphere(CORBA::string_dup(_Name.toStdString().c_str()), \ + _ZoneXcentre, _ZoneYcentre, _ZoneZcentre, _ZoneRayon ); + break; + } + case 31 : // il s agit d un disque issu d'un cylindre, dans le plan (X,Y) + { aZone = myAdaptGen->CreateZoneDisk(CORBA::string_dup(_Name.toStdString().c_str()), \ + _ZoneXcentre, _ZoneYcentre, _ZoneRayon, _Orient ); + break; + } + case 32 : // il s agit d un disque issu d'un cylindre, dans le plan (Y,Z) + { aZone = myAdaptGen->CreateZoneDisk(CORBA::string_dup(_Name.toStdString().c_str()), \ + _ZoneYcentre, _ZoneZcentre, _ZoneRayon, _Orient ); + break; + } + case 33 : // il s agit d un disque issu d'un cylindre, dans le plan (Z,X) + { aZone = myAdaptGen->CreateZoneDisk(CORBA::string_dup(_Name.toStdString().c_str()), \ + _ZoneZcentre, _ZoneXcentre, _ZoneRayon, _Orient ); + break; + } + case 5 : // il s agit d un cylindre + { aZone = myAdaptGen->CreateZoneCylinder(CORBA::string_dup(_Name.toStdString().c_str()), \ + _ZoneXcentre, _ZoneYcentre, _ZoneZcentre, _ZoneXaxis, _ZoneYaxis, _ZoneZaxis, _ZoneRayon, _ZoneHaut ); + break; + } + case 61 : // il s agit d un disque avec trou, dans le plan (X,Y) + { aZone = myAdaptGen->CreateZoneDiskWithHole(CORBA::string_dup(_Name.toStdString().c_str()), \ + _ZoneXcentre, _ZoneYcentre, _ZoneRayon, _ZoneRayonInt, _Orient ); + break; + } + case 62 : // il s agit d un disque avec trou, dans le plan (Y,Z) + { aZone = myAdaptGen->CreateZoneDiskWithHole(CORBA::string_dup(_Name.toStdString().c_str()), \ + _ZoneYcentre, _ZoneZcentre, _ZoneRayon, _ZoneRayonInt, _Orient ); + break; + } + case 63 : // il s agit d un disque avec trou, dans le plan (Z,X) + { aZone = myAdaptGen->CreateZoneDiskWithHole(CORBA::string_dup(_Name.toStdString().c_str()), \ + _ZoneZcentre, _ZoneXcentre, _ZoneRayon, _ZoneRayonInt, _Orient ); + break; + } + case 7 : // il s agit d un tuyau + { aZone = myAdaptGen->CreateZonePipe(CORBA::string_dup(_Name.toStdString().c_str()), \ + _ZoneXcentre, _ZoneYcentre, _ZoneZcentre, _ZoneXaxis, _ZoneYaxis, _ZoneZaxis, _ZoneRayon, _ZoneHaut, _ZoneRayonInt ); + break; + } + } + } + catch( SALOME::SALOME_Exception& S_ex ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr(CORBA::string_dup(S_ex.details.text)) ); + return false ; + } + _parent->addZoneinTWZone(_Name) ; +// Mise en place des attributs + aZone->SetLimit(_Xincr, _Yincr, _Zincr) ; + + return true; + } + else { + QMessageBox::warning( 0, QObject::tr("HOM_WARNING"), + QObject::tr("HOM_SELECT_OBJECT_4") ); + return false ; + } + MESSAGE("Fin de CreateOrUpdateZone"); +} +// ------------------------------------------------------------------------ +void MonCreateZone::PushOnOK() +// ------------------------------------------------------------------------ +{ + if (PushOnApply()) this->close() ; +} +// ------------------------------------------------------------------------ +void MonCreateZone::PushOnHelp() +// ------------------------------------------------------------------------ +{ + std::string LanguageShort = myAdaptGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_zone.html"), QString(""), QString(LanguageShort.c_str())); +} + +// ----------------------------------- +void MonCreateZone::SetNewName() +// ----------------------------------- +{ + MESSAGE("SetNewName"); +// Recherche d'un nom par defaut qui n'existe pas encore + + ADAPT::listeZones_var MyObjects = myAdaptGen->GetAllZonesName() ; + int num = 0; QString aName=""; + while (aName=="" ) + { + aName.setNum(num+1) ; + aName.insert(0, QString("Zone_")) ; + for ( int i=0; ilength() ; i++) + { + if ( aName == QString(MyObjects[i])) + { + num ++ ; + aName = "" ; + break ; + } + } + } + LEName->setText(aName); + MESSAGE("SetNewName aName ="<setVisible(1) ; + gBSphere->setVisible(0) ; + gBCylindre->setVisible(0) ; + gBPipe->setVisible(0) ; + adjustSize() ; + _Type=2; +// Sachant que l'increment est le 1/100eme de l'ecart (min/max), cela revient +// a initialiser la boite sur une boite 'centrale' comprise entre 2/5 et 3/5 + if ( _Xincr > 0 ) { SpinBox_Xmini->setValue(_Xcentre-10*_Xincr) ; + SpinBox_Xmaxi->setValue(_Xcentre+10*_Xincr) ; } + else { _Type=12 ; } + if ( _Yincr > 0 ) { SpinBox_Ymini->setValue(_Ycentre-10*_Yincr) ; + SpinBox_Ymaxi->setValue(_Ycentre+10*_Yincr) ; } + else { _Type=13 ; } + if ( _Zincr > 0 ) { SpinBox_Zmini->setValue(_Zcentre-10*_Zincr) ; + SpinBox_Zmaxi->setValue(_Zcentre+10*_Zincr) ; } + else { _Type=11 ; } + MESSAGE("Fin de SetBox") +} +// ------------------------------------------------------------------------ +void MonCreateZone::SetSphere() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetSphere") + gBBox->setVisible(0) ; + gBSphere->setVisible(1) ; + gBCylindre->setVisible(0) ; + gBPipe->setVisible(0) ; + adjustSize() ; + _Type=4; + SpinBox_Xcentre->setValue(_Xcentre) ; + SpinBox_Ycentre->setValue(_Ycentre) ; + SpinBox_Zcentre->setValue(_Zcentre) ; + SpinBox_Rayon->setValue(_Rayon) ; + MESSAGE("Fin de SetSphere") +} +// ------------------------------------------------------------------------ +void MonCreateZone::SetCylinder() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetCylinder") + gBBox->setVisible(0) ; + gBSphere->setVisible(0) ; + gBCylindre->setVisible(1) ; + gBPipe->setVisible(0) ; + adjustSize() ; + _Type=5; + if ( _Xincr > 0 ) { SpinBox_Xbase->setValue(_Xcentre) ; + SpinBox_Xaxis->setValue(0.) ; } + else { _Type=32 ; } + if ( _Yincr > 0 ) { SpinBox_Ybase->setValue(_Ycentre) ; + SpinBox_Yaxis->setValue(0.) ; } + else { _Type=33 ; } + if ( _Zincr > 0 ) { SpinBox_Zbase->setValue(_Zcentre) ; + SpinBox_Zaxis->setValue(1.) ; } + else { _Type=31 ; } + SpinBox_Radius->setValue(_Rayon) ; + SpinBox_Haut->setValue(_Haut) ; + MESSAGE("Fin de SetCylinder") +} +// ------------------------------------------------------------------------ +void MonCreateZone::SetPipe() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetPipe") + gBBox->setVisible(0) ; + gBSphere->setVisible(0) ; + gBCylindre->setVisible(0) ; + gBPipe->setVisible(1) ; + adjustSize() ; + _Type=7; + if ( _Xincr > 0 ) { SpinBox_Xbase_p->setValue(_Xcentre) ; + SpinBox_Xaxis_p->setValue(0.) ; } + else { _Type=62 ; } + if ( _Yincr > 0 ) { SpinBox_Ybase_p->setValue(_Ycentre) ; + SpinBox_Yaxis_p->setValue(0.) ; } + else { _Type=63 ; } + if ( _Zincr > 0 ) { SpinBox_Zbase_p->setValue(_Zcentre) ; + SpinBox_Zaxis_p->setValue(1.) ; } + else { _Type=61 ; } + SpinBox_Radius_int->setValue(_RayonInt) ; + SpinBox_Radius_ext->setValue(_Rayon) ; + SpinBox_Haut_p->setValue(_Haut) ; + MESSAGE("Fin de SetPipe") +} + + diff --git a/src/ADAPTGUI/MonCreateZone.h b/src/ADAPTGUI/MonCreateZone.h new file mode 100644 index 000000000..4eb700a43 --- /dev/null +++ b/src/ADAPTGUI/MonCreateZone.h @@ -0,0 +1,87 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_CREATEZONE_H +#define MON_CREATEZONE_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) + +#include "ui_CreateZone.h" +#include + +class MonCreateHypothesis; +class HOMARD_EXPORT MonCreateZone : public QDialog, public Ui_CreateZone +{ + Q_OBJECT + +public: + MonCreateZone( MonCreateHypothesis* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString caseName); + virtual ~MonCreateZone(); + +protected : + MonCreateZone( MonCreateHypothesis* parent, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString caseName); + + MonCreateHypothesis * _parent; + + QString _Name; + QString _aCaseName; + + int _Orient; + int _Type; + double _Xcentre, _Ycentre, _Zcentre, _Rayon ; + double _Xmin, _Xmax, _Xincr, _Ymin, _Ymax, _Yincr, _Zmin, _Zmax, _Zincr ; + double _ZoneXcentre, _ZoneYcentre, _ZoneZcentre, _ZoneRayon ; + double _ZoneXmin, _ZoneXmax, _ZoneYmin, _ZoneYmax, _ZoneZmin, _ZoneZmax ; + double _Xaxis, _Yaxis, _Zaxis, _RayonInt, _Haut ; + double _ZoneXaxis, _ZoneYaxis, _ZoneZaxis, _ZoneRayonInt, _ZoneHaut ; + double _DMax ; + + bool Chgt; + + ADAPT::HOMARD_Zone_var aZone ; + ADAPT::ADAPT_Gen_var myAdaptGen; + + virtual void InitConnect(); + virtual void InitValZone(); + virtual void InitMinMax(); + virtual void SetNewName(); + virtual bool CreateOrUpdateZone(); + +public slots: + virtual void SetBox(); + virtual void SetSphere(); + virtual void SetCylinder(); + virtual void SetPipe(); + virtual void PushOnOK(); + virtual bool PushOnApply(); + virtual void PushOnHelp(); + +}; + +#endif // MON_CREATEZONE_H diff --git a/src/ADAPTGUI/MonEditBoundaryAn.cxx b/src/ADAPTGUI/MonEditBoundaryAn.cxx new file mode 100644 index 000000000..03ceaf4bb --- /dev/null +++ b/src/ADAPTGUI/MonEditBoundaryAn.cxx @@ -0,0 +1,399 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonEditBoundaryAn.h" + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include + +using namespace std; + +// ------------------------------------------------------------------------ +MonEditBoundaryAn::MonEditBoundaryAn( MonCreateCase* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString caseName, QString Name ): +// ------------------------------------------------------------------------ +/* Constructs a MonEditBoundaryAn + herite de MonCreateBoundaryAn +*/ + MonCreateBoundaryAn(parent, myAdaptGen, caseName) +{ + MESSAGE("Debut de MonEditBoundaryAn pour " << Name.toStdString().c_str()); + setWindowTitle(QObject::tr("HOM_BOUN_A_EDIT_WINDOW_TITLE")); + _Name=Name; + aBoundaryAn = myAdaptGen->GetBoundary(_Name.toStdString().c_str()); + InitValEdit(); +} +// ------------------------------------------------------------------------ +MonEditBoundaryAn::~MonEditBoundaryAn() +// ------------------------------------------------------------------------ +{ + // no need to delete child widgets, Qt does it all for us +} +// ------------------------------------------------------------------------ +void MonEditBoundaryAn::InitValEdit() +// ------------------------------------------------------------------------ +{ + LEName->setText(_Name); + LEName->setReadOnly(true); + _Type = aBoundaryAn->GetType(); + MESSAGE("_Type : "<<_Type); + InitValBoundaryAnLimit(); + if (_aCaseName != QString("")) InitValBoundaryAn(); + switch (_Type) + { + case 1 : // il s agit d un cylindre + { + InitValBoundaryAnCylindre(); + SetCylinder(); + break; + } + case 2: // il s agit d une sphere + { + InitValBoundaryAnSphere(); + SetSphere(); + break; + } + case 3: // il s agit d un cone defini par un axe et un angle + { + InitValBoundaryAnConeA(); + SetConeA(); + break; + } + case 4: // il s agit d un cone defini par les 2 rayons + { + InitValBoundaryAnConeR(); + SetConeR(); + break; + } + case 5: // il s agit d un tore + { + InitValBoundaryAnTore(); + SetTore(); + break; + } + }; +} +// ------------------------------------------------------------------------ +void MonEditBoundaryAn::InitValBoundaryAnLimit() +// ------------------------------------------------------------------------ +{ + ADAPT::double_array_var mesCoordLimits = aBoundaryAn->GetLimit(); + ASSERT(mesCoordLimits->length() == 3 ); + _Xincr=mesCoordLimits[0]; + _Yincr=mesCoordLimits[1]; + _Zincr=mesCoordLimits[2]; +} +// ------------------------------------------------------------------------ +void MonEditBoundaryAn::InitValBoundaryAnCylindre() +// ------------------------------------------------------------------------ +{ + ADAPT::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords(); + ASSERT(mesCoordBoundary->length() == 7 ); + _BoundaryAnXcentre=mesCoordBoundary[0]; + _BoundaryAnYcentre=mesCoordBoundary[1]; + _BoundaryAnZcentre=mesCoordBoundary[2]; + _BoundaryAnXaxis=mesCoordBoundary[3]; + _BoundaryAnYaxis=mesCoordBoundary[4]; + _BoundaryAnZaxis=mesCoordBoundary[5]; + _BoundaryAnRayon=mesCoordBoundary[6]; +} +// ------------------------------------------------------------------------ +void MonEditBoundaryAn::InitValBoundaryAnSphere() +// ------------------------------------------------------------------------ +{ + ADAPT::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords(); + ASSERT(mesCoordBoundary->length() == 4 ); + _BoundaryAnXcentre=mesCoordBoundary[0]; + _BoundaryAnYcentre=mesCoordBoundary[1]; + _BoundaryAnZcentre=mesCoordBoundary[2]; + _BoundaryAnRayon=mesCoordBoundary[3]; +} +// ------------------------------------------------------------------------ +void MonEditBoundaryAn::InitValBoundaryAnConeA() +// ------------------------------------------------------------------------ +{ + ADAPT::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords(); + ASSERT(mesCoordBoundary->length() == 7 ); + _BoundaryAnXaxisCone=mesCoordBoundary[0]; + _BoundaryAnYaxisCone=mesCoordBoundary[1]; + _BoundaryAnZaxisCone=mesCoordBoundary[2]; + _BoundaryAngle=mesCoordBoundary[3]; + _BoundaryAnXorigCone=mesCoordBoundary[4]; + _BoundaryAnYorigCone=mesCoordBoundary[5]; + _BoundaryAnZorigCone=mesCoordBoundary[6]; + convertRayonAngle(-1) ; +} +// ------------------------------------------------------------------------ +void MonEditBoundaryAn::InitValBoundaryAnConeR() +// ------------------------------------------------------------------------ +{ + ADAPT::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords(); + ASSERT(mesCoordBoundary->length() == 8 ); + _BoundaryAnXcone1=mesCoordBoundary[0]; + _BoundaryAnYcone1=mesCoordBoundary[1]; + _BoundaryAnZcone1=mesCoordBoundary[2]; + _BoundaryAnRayon1=mesCoordBoundary[3]; + _BoundaryAnXcone2=mesCoordBoundary[4]; + _BoundaryAnYcone2=mesCoordBoundary[5]; + _BoundaryAnZcone2=mesCoordBoundary[6]; + _BoundaryAnRayon2=mesCoordBoundary[7]; + convertRayonAngle(1) ; +} +// ------------------------------------------------------------------------ +void MonEditBoundaryAn::InitValBoundaryAnTore() +// ------------------------------------------------------------------------ +{ + ADAPT::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords(); + ASSERT(mesCoordBoundary->length() == 8 ); + _BoundaryAnXcentre=mesCoordBoundary[0]; + _BoundaryAnYcentre=mesCoordBoundary[1]; + _BoundaryAnZcentre=mesCoordBoundary[2]; + _BoundaryAnXaxis=mesCoordBoundary[3]; + _BoundaryAnYaxis=mesCoordBoundary[4]; + _BoundaryAnZaxis=mesCoordBoundary[5]; + _BoundaryAnRayon1=mesCoordBoundary[6]; + _BoundaryAnRayon2=mesCoordBoundary[7]; +} +// ------------------------------------------------------------------------ +void MonEditBoundaryAn::SetCylinder() +// ------------------------------------------------------------------------ +{ + gBCylindre->setVisible(1); + gBSphere->setVisible(0); + gBCone->setVisible(0); + gBTore->setVisible(0); + RBCylindre->setChecked(1); + _Type=1; + RBSphere->setDisabled(true); + RBCone->setDisabled(true); + RBTore->setDisabled(true); + + SpinBox_Xcent->setValue(_BoundaryAnXcentre); + SpinBox_Ycent->setValue(_BoundaryAnYcentre); + SpinBox_Zcent->setValue(_BoundaryAnZcentre); + + SpinBox_Xaxis->setValue(_BoundaryAnXaxis); + SpinBox_Yaxis->setValue(_BoundaryAnYaxis); + SpinBox_Zaxis->setValue(_BoundaryAnZaxis); + + + SpinBox_Xaxis->setSingleStep(0.1); + SpinBox_Xcentre->setSingleStep(_Xincr); + SpinBox_Yaxis->setSingleStep(0.1); + SpinBox_Ycentre->setSingleStep(_Yincr); + SpinBox_Zaxis->setSingleStep(0.1); + SpinBox_Zcentre->setSingleStep(_Zincr); +// Rayon + SpinBox_Radius->setValue(_BoundaryAnRayon); + SpinBox_Radius->setSingleStep(_BoundaryAnRayon/10.); +// + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonEditBoundaryAn::SetSphere() +// ------------------------------------------------------------------------ +{ + gBCylindre->setVisible(0); + gBSphere->setVisible(1); + RBSphere->setChecked(1); + gBCone->setVisible(0); + gBTore->setVisible(0); + RBCylindre->setDisabled(true); + RBCone->setDisabled(true); + RBTore->setDisabled(true); + _Type=2 ; + + SpinBox_Xcentre->setValue(_BoundaryAnXcentre); + if ( _Xincr > 0) { SpinBox_Xcentre->setSingleStep(_Xincr); } + else { SpinBox_Xcentre->setSingleStep(1) ; } + + SpinBox_Ycentre->setValue(_BoundaryAnYcentre); + if ( _Yincr > 0) { SpinBox_Ycentre->setSingleStep(_Yincr); } + else { SpinBox_Ycentre->setSingleStep(1) ; } + + SpinBox_Zcentre->setValue(_BoundaryAnZcentre); + if ( _Zincr > 0) { SpinBox_Zcentre->setSingleStep(_Zincr); } + else { SpinBox_Zcentre->setSingleStep(1);} + + SpinBox_Rayon->setValue(_BoundaryAnRayon); +// + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonEditBoundaryAn::SetConeA() +// ------------------------------------------------------------------------ +{ + gBCylindre->setVisible(0); + gBSphere->setVisible(0); + gBCone->setVisible(1); + RBCone->setChecked(1); + gBTore->setVisible(0); + RB_Def_angle->setChecked(1); + RBCylindre->setDisabled(true); + RBSphere->setDisabled(true); + RBTore->setDisabled(true); + _Type=3; +// + TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X axis", 0)); + SpinBox_Cone_X1->setValue(_BoundaryAnXaxisCone); + TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y axis", 0)); + SpinBox_Cone_Y1->setValue(_BoundaryAnYaxisCone); + TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z axis", 0)); + SpinBox_Cone_Z1->setValue(_BoundaryAnZaxisCone); +// + TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre", 0)); + SpinBox_Cone_X2->setValue(_BoundaryAnXorigCone); + TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre", 0)); + SpinBox_Cone_Y2->setValue(_BoundaryAnYorigCone); + TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre", 0)); + SpinBox_Cone_Z2->setValue(_BoundaryAnZorigCone); +// + TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Angle", 0)); + SpinBox_Cone_V1->setValue(_BoundaryAngle); + SpinBox_Cone_V1->setSingleStep(1.); + SpinBox_Cone_V1->setMaximum(90.); +// + TLCone_V2->setVisible(0); + SpinBox_Cone_V2->setVisible(0); +// + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonEditBoundaryAn::SetConeR() +// ------------------------------------------------------------------------ +{ + gBCylindre->setVisible(0); + gBSphere->setVisible(0); + gBCone->setVisible(1); + gBTore->setVisible(0); + RBCone->setChecked(1); + RB_Def_radius->setChecked(1); + RBCylindre->setDisabled(true); + RBSphere->setDisabled(true); + RBTore->setDisabled(true); + _Type=4; +// + TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X centre 1", 0)); + SpinBox_Cone_X1->setValue(_BoundaryAnXcone1); + TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y centre 1", 0)); + SpinBox_Cone_Y1->setValue(_BoundaryAnYcone1); + TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z centre 1", 0)); + SpinBox_Cone_Z1->setValue(_BoundaryAnZcone1); +// + TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Radius 1", 0)); + SpinBox_Cone_V1->setSingleStep(_Rayon/10.); + SpinBox_Cone_V1->setMaximum(100000.*_DMax); + SpinBox_Cone_V1->setValue(_BoundaryAnRayon1); +// + TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre 2", 0)); + SpinBox_Cone_X2->setValue(_BoundaryAnXcone2); + TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre 2", 0)); + SpinBox_Cone_Y2->setValue(_BoundaryAnYcone2); + TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre 2", 0)); + SpinBox_Cone_Z2->setValue(_BoundaryAnZcone2); +// + TLCone_V2->setVisible(1); + SpinBox_Cone_V2->setVisible(1); + TLCone_V2->setText(QApplication::translate("CreateBoundaryAn", "Radius 2", 0)); + SpinBox_Cone_V2->setValue(_BoundaryAnRayon2); +// + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonEditBoundaryAn::SetTore() +// ------------------------------------------------------------------------ +{ + gBCylindre->setVisible(0); + gBSphere->setVisible(0); + gBCone->setVisible(0); + gBTore->setVisible(1); + RBTore->setChecked(1); + _Type=5; + RBCylindre->setDisabled(true); + RBSphere->setDisabled(true); + RBCone->setDisabled(true); + + SpinBoxToreXcent->setValue(_BoundaryAnXcentre); + SpinBoxToreYcent->setValue(_BoundaryAnYcentre); + SpinBoxToreZcent->setValue(_BoundaryAnZcentre); + + SpinBoxToreXaxe->setValue(_BoundaryAnXaxis); + SpinBoxToreYaxe->setValue(_BoundaryAnYaxis); + SpinBoxToreZaxe->setValue(_BoundaryAnZaxis); + + + SpinBoxToreXaxe->setSingleStep(0.1); + SpinBoxToreXcent->setSingleStep(_Xincr); + SpinBoxToreYaxe->setSingleStep(0.1); + SpinBoxToreYcent->setSingleStep(_Yincr); + SpinBoxToreZaxe->setSingleStep(0.1); + SpinBoxToreZcent->setSingleStep(_Zincr); +// Rayon de revolution + SpinBoxToreRRev->setValue(_BoundaryAnRayon1); + SpinBoxToreRRev->setSingleStep(_BoundaryAnRayon1/10.); +// Rayon primaire + SpinBoxToreRPri->setValue(_BoundaryAnRayon2); + SpinBoxToreRPri->setSingleStep(_BoundaryAnRayon2/10.); +// + adjustSize(); +} +// --------------------------------------------------- +bool MonEditBoundaryAn::CreateOrUpdateBoundaryAn() +//---------------------------------------------------- +// Mise a jour des attributs de la BoundaryAn +{ + switch (_Type) + { + case 1 : // il s agit d un cylindre + { + aBoundaryAn->SetCylinder(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnXaxis, _BoundaryAnYaxis, _BoundaryAnZaxis, _BoundaryAnRayon ); + break; + } + case 2 : // il s agit d une sphere + { + aBoundaryAn->SetSphere(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnRayon); + break; + } + case 3 : // il s agit d un cone defini par un axe et un angle + { + aBoundaryAn = myAdaptGen->CreateBoundaryConeA(CORBA::string_dup(_Name.toStdString().c_str()), \ + _BoundaryAnXaxisCone, _BoundaryAnYaxisCone, _BoundaryAnZaxisCone, _BoundaryAngle, \ + _BoundaryAnXorigCone, _BoundaryAnYorigCone, _BoundaryAnYorigCone); + break; + } + case 4 : // il s agit d un cone defini par les 2 rayons + { + aBoundaryAn = myAdaptGen->CreateBoundaryConeR(CORBA::string_dup(_Name.toStdString().c_str()), \ + _BoundaryAnXcone1, _BoundaryAnYcone1, _BoundaryAnZcone1, _BoundaryAnRayon1, \ + _BoundaryAnXcone2, _BoundaryAnYcone2, _BoundaryAnZcone2, _BoundaryAnRayon2); + break; + } + case 5 : // il s agit d un tore + { + aBoundaryAn->SetTorus(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnXaxis, _BoundaryAnYaxis, _BoundaryAnZaxis, _BoundaryAnRayon1, _BoundaryAnRayon2 ); + break; + } + } + if (Chgt) myAdaptGen->InvalideBoundary(_Name.toStdString().c_str()); + HOMARD_UTILS::updateObjBrowser(); + return true; +} + diff --git a/src/ADAPTGUI/MonEditBoundaryAn.h b/src/ADAPTGUI/MonEditBoundaryAn.h new file mode 100644 index 000000000..fcc9167f7 --- /dev/null +++ b/src/ADAPTGUI/MonEditBoundaryAn.h @@ -0,0 +1,61 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_EDITBOUNDARYAN_H +#define MON_EDITBOUNDARYAN_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) + +#include + +class HOMARD_EXPORT MonEditBoundaryAn : public MonCreateBoundaryAn +{ + Q_OBJECT +public: + MonEditBoundaryAn( MonCreateCase* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString caseName, QString Name); + virtual ~MonEditBoundaryAn(); + +protected : + bool CreateOrUpdateBoundaryAn(); + void InitValEdit(); + void InitValBoundaryAnLimit(); + void SetCylinder(); + void SetSphere(); + void SetConeR(); + void SetConeA(); + void SetTore(); + void InitValBoundaryAnCylindre(); + void InitValBoundaryAnSphere(); + void InitValBoundaryAnConeR(); + void InitValBoundaryAnConeA(); + void InitValBoundaryAnTore(); + +public slots: + +}; + +#endif // MON_EDITZONE_H diff --git a/src/ADAPTGUI/MonEditBoundaryCAO.cxx b/src/ADAPTGUI/MonEditBoundaryCAO.cxx new file mode 100644 index 000000000..a0c6abb28 --- /dev/null +++ b/src/ADAPTGUI/MonEditBoundaryCAO.cxx @@ -0,0 +1,105 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonEditBoundaryCAO.h" +#include "MonEditListGroupCAO.h" + +#include + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include + +using namespace std; + +// ------------------------------------------------------------------------------------------------------------------------------------- +MonEditBoundaryCAO::MonEditBoundaryCAO( MonCreateCase* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString caseName, QString Name): +// ------------------------------------------------------------------------------------------------------------------------------------- +/* Constructs a MonEditBoundaryCAO + herite de MonCreateBoundaryCAO +*/ + MonCreateBoundaryCAO(parent, modal, myAdaptGen, caseName, Name) +{ + MESSAGE("Debut de Boundary pour " << Name.toStdString().c_str()); + setWindowTitle(QObject::tr("HOM_BOUN_C_EDIT_WINDOW_TITLE")); + try + { + aBoundary=myAdaptGen->GetBoundary(CORBA::string_dup(_aName.toStdString().c_str())); + if (caseName==QString("")) { _aCaseName=aBoundary->GetCaseCreation();} + InitValEdit(); + } + catch( SALOME::SALOME_Exception& S_ex ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr(CORBA::string_dup(S_ex.details.text)) ); + return; + } + + ADAPT::ListGroupType_var maListe = aBoundary->GetGroups(); + for ( int i = 0; i < maListe->length(); i++ ) + _listeGroupesBoundary << QString(maListe[i]); + +} +// ------------------------------ +MonEditBoundaryCAO::~MonEditBoundaryCAO() +// ------------------------------ +{ +} +// ------------------------------ +void MonEditBoundaryCAO::InitValEdit() +// ------------------------------ +{ + LEName->setText(_aName); + LEName->setReadOnly(true); + + QString aDataFile = aBoundary->GetDataFile(); + LEFileName->setText(aDataFile); + LEFileName->setReadOnly(1); + PushFichier->setVisible(0); +// + adjustSize(); +} +// ------------------------------ +bool MonEditBoundaryCAO::PushOnApply() +// ------------------------------ +{ + return true; +} +// ------------------------------------------------------------------------ +void MonEditBoundaryCAO::SetFiltrage() +// // ------------------------------------------------------------------------ +{ + if (!CBGroupe->isChecked()) return; + if (_aCaseName.toStdString().c_str() == QString()) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_BOUN_CASE") ); + return; + } + ADAPT::HOMARD_Cas_var monCas= myAdaptGen->GetCase(_aCaseName.toStdString().c_str()); + ADAPT::ListGroupType_var _listeGroupesCas = monCas->GetGroups(); + + MonEditListGroupCAO *aDlg = new MonEditListGroupCAO(NULL, this, true, ADAPT::ADAPT_Gen::_duplicate(myAdaptGen), + _aCaseName, _listeGroupesBoundary) ; + aDlg->show(); +} + diff --git a/src/ADAPTGUI/MonEditBoundaryCAO.h b/src/ADAPTGUI/MonEditBoundaryCAO.h new file mode 100644 index 000000000..802727623 --- /dev/null +++ b/src/ADAPTGUI/MonEditBoundaryCAO.h @@ -0,0 +1,51 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_EDITBOUNDARYCAO_H +#define MON_EDITBOUNDARYCAO_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) + +#include + +class HOMARD_EXPORT MonEditBoundaryCAO : public MonCreateBoundaryCAO +{ + Q_OBJECT +public: + MonEditBoundaryCAO( MonCreateCase* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString caseName, QString Name ); + virtual ~MonEditBoundaryCAO(); + +protected : + virtual void InitValEdit(); + virtual bool PushOnApply(); + virtual void SetFiltrage(); + +public slots: + +}; + +#endif diff --git a/src/ADAPTGUI/MonEditBoundaryDi.cxx b/src/ADAPTGUI/MonEditBoundaryDi.cxx new file mode 100644 index 000000000..afbe926b4 --- /dev/null +++ b/src/ADAPTGUI/MonEditBoundaryDi.cxx @@ -0,0 +1,105 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonEditBoundaryDi.h" +#include "MonEditListGroup.h" + +#include + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include + +using namespace std; + +// ------------------------------------------------------------------------------------------------------------------------------------- +MonEditBoundaryDi::MonEditBoundaryDi( MonCreateCase* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString caseName, QString Name): +// ------------------------------------------------------------------------------------------------------------------------------------- +/* Constructs a MonEditBoundaryDi + herite de MonCreateBoundaryDi +*/ + MonCreateBoundaryDi(parent, modal, myAdaptGen, caseName, Name) +{ + MESSAGE("Debut de Boundary pour " << Name.toStdString().c_str()); + setWindowTitle(QObject::tr("HOM_BOUN_D_EDIT_WINDOW_TITLE")); + try + { + aBoundary=myAdaptGen->GetBoundary(CORBA::string_dup(_aName.toStdString().c_str())); + if (caseName==QString("")) { _aCaseName=aBoundary->GetCaseCreation();} + InitValEdit(); + } + catch( SALOME::SALOME_Exception& S_ex ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr(CORBA::string_dup(S_ex.details.text)) ); + return; + } + + ADAPT::ListGroupType_var maListe = aBoundary->GetGroups(); + for ( int i = 0; i < maListe->length(); i++ ) + _listeGroupesBoundary << QString(maListe[i]); + +} +// ------------------------------ +MonEditBoundaryDi::~MonEditBoundaryDi() +// ------------------------------ +{ +} +// ------------------------------ +void MonEditBoundaryDi::InitValEdit() +// ------------------------------ +{ + LEName->setText(_aName); + LEName->setReadOnly(true); + + QString aDataFile = aBoundary->GetDataFile(); + LEFileName->setText(aDataFile); + LEFileName->setReadOnly(1); + PushFichier->setVisible(0); +// + adjustSize(); +} +// ------------------------------ +bool MonEditBoundaryDi::PushOnApply() +// ------------------------------ +{ + return true; +} +// ------------------------------------------------------------------------ +void MonEditBoundaryDi::SetFiltrage() +// // ------------------------------------------------------------------------ +{ + if (!CBGroupe->isChecked()) return; + if (_aCaseName.toStdString().c_str() == QString()) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_BOUN_CASE") ); + return; + } + ADAPT::HOMARD_Cas_var monCas= myAdaptGen->GetCase(_aCaseName.toStdString().c_str()); + ADAPT::ListGroupType_var _listeGroupesCas = monCas->GetGroups(); + + MonEditListGroup *aDlg = new MonEditListGroup(NULL, this, true, ADAPT::ADAPT_Gen::_duplicate(myAdaptGen), + _aCaseName, _listeGroupesBoundary) ; + aDlg->show(); +} + diff --git a/src/ADAPTGUI/MonEditBoundaryDi.h b/src/ADAPTGUI/MonEditBoundaryDi.h new file mode 100644 index 000000000..635a7b084 --- /dev/null +++ b/src/ADAPTGUI/MonEditBoundaryDi.h @@ -0,0 +1,51 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_EDITBOUNDARYDI_H +#define MON_EDITBOUNDARYDI_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) + +#include + +class HOMARD_EXPORT MonEditBoundaryDi : public MonCreateBoundaryDi +{ + Q_OBJECT +public: + MonEditBoundaryDi( MonCreateCase* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString caseName, QString Name ); + virtual ~MonEditBoundaryDi(); + +protected : + virtual void InitValEdit(); + virtual bool PushOnApply(); + virtual void SetFiltrage(); + +public slots: + +}; + +#endif diff --git a/src/ADAPTGUI/MonEditCase.cxx b/src/ADAPTGUI/MonEditCase.cxx new file mode 100644 index 000000000..c68c22811 --- /dev/null +++ b/src/ADAPTGUI/MonEditCase.cxx @@ -0,0 +1,269 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonEditCase.h" + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include + +using namespace std; + +// ------------------------------------------------------------- +/* Constructs a MonEditCase + herite de MonCreateCase +*/ +// ------------------------------------------------------------- +MonEditCase::MonEditCase ( bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString CaseName ): + MonCreateCase(modal, myAdaptGen) +{ + MESSAGE("Debut de MonEditCase" << CaseName.toStdString().c_str()); + setWindowTitle(QObject::tr("HOM_CASE_EDIT_WINDOW_TITLE")); + _aCaseName = CaseName; + aCase = myAdaptGen->GetCase(_aCaseName.toStdString().c_str()); + InitValEdit(); +} +// ------------------------------ +MonEditCase::~MonEditCase() +// ------------------------------ +{ +} +// ------------------------------ +void MonEditCase::InitValEdit() +// ------------------------------ +{ + MESSAGE("InitValEdit"); + LEName->setText(_aCaseName); + LEName->setReadOnly(true); + + QString aDirName = aCase->GetDirName(); + LEDirName->setText(aDirName); + LEDirName->setReadOnly(true); + PushDir->setVisible(0); + + QString _aitername=aCase->GetIter0Name(); + ADAPT::HOMARD_Iteration_var aIter = myAdaptGen->GetIteration(_aitername.toStdString().c_str()); + QString aFileName = aIter->GetMeshFile(); + LEFileName->setText(aFileName); + LEFileName->setReadOnly(true); + PushFichier->setVisible(0); + + int ConfType=aCase->GetConfType(); + if ( ( ConfType == 0 ) || ( ConfType == -1 ) ) { RBConforme->setChecked(true); } + else { RBNonConforme->setChecked(true); }; + RBConforme->setEnabled(false); + RBNonConforme->setEnabled(false); + int ExtType=aCase->GetExtType(); + + +// Suivi de frontiere +// A priori, aucun affichage + GBTypeBoun->setVisible(0); + CBBoundaryD->setVisible(0); + CBBoundaryA->setVisible(0); + GBBoundaryC->setVisible(0); + GBBoundaryD->setVisible(0); + GBBoundaryA->setVisible(0); +// On passe en revue tous les couples (frontiere,groupe) du cas + ADAPT::ListBoundaryGroupType_var mesBoundarys = aCase->GetBoundaryGroup(); + if (mesBoundarys->length()>0) + { + QStringList ListeFron ; + QString NomFron ; + bool BounCAO = false ; + bool BounDi = false ; + bool BounAn = false ; + for (int i=0; ilength(); i++) + { +// Nom de la frontiere + NomFron = mesBoundarys[i++]; + MESSAGE("NomFron "<GetBoundary(NomFron.toStdString().c_str()); + int type_obj = myBoundary->GetType() ; + MESSAGE("type_obj "<addItem(NomFron); + } +// C'est une frontiere discrete +// Rermarque : on ne gere pas les groupes + else if ( type_obj==0 ) + { + BounDi = true ; + CBBoundaryDi->addItem(NomFron); + } +// C'est une frontiere analytique + else + { + BounAn = true ; + int nbcol = TWBoundary->columnCount(); +// On ajoute une ligne pour le groupe + TWBoundary->insertRow(0); +// La colonne 0 comporte le nom du groupe + TWBoundary->setItem( 0, 0, new QTableWidgetItem(QString(mesBoundarys[i]).trimmed())); +// TWBoundary->item( 0, 0 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable ); +// Chacune des colonnes suivantes est associé a une frontiere deja presente : on y met une +// case non cochee + for ( int j = 1; j < nbcol; j++ ) + { + TWBoundary->setItem( 0, j, new QTableWidgetItem( QString ("") ) ); + TWBoundary->item( 0, j )->setFlags( 0 ); + TWBoundary->item( 0, j )->setFlags( Qt::ItemIsUserCheckable ); + TWBoundary->item( 0, j )->setCheckState( Qt::Unchecked ); + } +// On cherche si la frontiere en cours d'examen a deja ete rencontree : +// si oui, on stocke son numero de colonne + int ok = -1 ; + for ( int nufr = 0 ; nufritem( 0, ok )->setCheckState( Qt::Checked ); + } + } + MESSAGE("BounCAO "<setVisible(1); + if ( BounCAO ) + { RBBoundaryCAO->setChecked(true); + GBBoundaryC->setVisible(1); + CBBoundaryCAO->setDisabled(true); + PBBoundaryCAONew->setVisible(0); + PBBoundaryCAOHelp->setVisible(0); } + if ( BounDi ) + { RBBoundaryNonCAO->setChecked(true); + GBBoundaryD->setVisible(1); + CBBoundaryDi->setDisabled(true); + PBBoundaryDiNew->setVisible(0); + PBBoundaryDiHelp->setVisible(0); } + if ( BounAn ) + { RBBoundaryNonCAO->setChecked(true); + GBBoundaryA->setVisible(1); +// On rend les cases non modifiables. +// On ne peut pas le faire pour tout le tableau sinon on perd l'ascenseur ! + int nbcol = TWBoundary->columnCount(); + int nbrow = TWBoundary->rowCount(); + for ( int i = 0; i < nbrow; i++ ) + { for ( int j = 0; j < nbcol; j++ ) TWBoundary->item( i, j )->setFlags( Qt::ItemIsSelectable ); } +// on met un nom blanc au coin + QTableWidgetItem *__colItem = new QTableWidgetItem(); + __colItem->setText(QApplication::translate("CreateCase", "", 0)); + TWBoundary->setHorizontalHeaderItem(0, __colItem); +// on cache les boutons inutiles + PBBoundaryAnNew->setVisible(0); + PBBoundaryAnHelp->setVisible(0); + } + RBBoundaryNo->setEnabled(false); + RBBoundaryCAO->setEnabled(false); + RBBoundaryNonCAO->setEnabled(false); + } +// +// Les options avancees (non modifiables) + CBAdvanced->setVisible(0) ; + CBAdvanced->setEnabled(false) ; + int Pyram = aCase->GetPyram(); + MESSAGE("Pyram "< 0 ) || ( ConfType < 0 ) || ( ConfType > 1 ) || ( ExtType > 0 ) ) + { GBAdvancedOptions->setVisible(1); +// + if ( Pyram > 0 ) + { CBPyramid->setChecked(true); + CBPyramid->setVisible(1); + } + else + { CBPyramid->setChecked(false); + CBPyramid->setVisible(0); + } + CBPyramid->setEnabled(false); +// + if ( ( ConfType == 0 ) || ( ConfType == -1 ) ) + { if ( ConfType == 0 ) { RBStandard->setChecked(true); } + else { RBBox->setChecked(true); } + RBStandard->setVisible(1); + RBBox->setVisible(1); + RBNC1NpA->setVisible(0); + RBNCQuelconque->setVisible(0); + } + else + { if (ConfType==-2) { RBBox->setChecked(true);}; + if (ConfType==1) { RBStandard->setChecked(true);}; + if (ConfType==2) { RBNC1NpA->setChecked(true);}; + if (ConfType==3) { RBNCQuelconque->setChecked(true);}; + RBStandard->setVisible(1); + RBBox->setVisible(1); + RBNC1NpA->setVisible(1); + RBNCQuelconque->setVisible(1); + } + RBStandard->setEnabled(false); + RBBox->setEnabled(false); + RBNC1NpA->setEnabled(false); + RBNCQuelconque->setEnabled(false); +// + if ( ExtType == 0 ) + { GBFormat->setVisible(0); + RBMED->setChecked(true); + } + else + { GBFormat->setVisible(1); + RBMED->setVisible(1); + RBSaturne->setVisible(1); + RBSaturne2D->setVisible(1); + if ( ExtType == 1 ) { RBSaturne->setChecked(true); } + else { RBSaturne2D->setChecked(true); } + } + RBMED->setEnabled(false); + RBSaturne->setEnabled(false); + RBSaturne2D->setEnabled(false); + } + else + { GBAdvancedOptions->setVisible(0); + CBPyramid->setChecked(false); + RBStandard->setChecked(true); + RBMED->setChecked(true); + } +// +// L'etat + int etat = aCase->GetState(); + MESSAGE("etat "<setText(QApplication::translate("CreateCase", "HOM_CASE_EDIT_STATE_0", 0)); } + else { Comment->setText(QApplication::translate("CreateCase", "HOM_CASE_EDIT_STATE", 0)); } + + Comment->setVisible(1); +// + adjustSize(); +} + +// ------------------------------------- +bool MonEditCase::PushOnApply() +// ------------------------------------- +{ + return true ; +}; diff --git a/src/ADAPTGUI/MonEditCase.h b/src/ADAPTGUI/MonEditCase.h new file mode 100644 index 000000000..70625cb6b --- /dev/null +++ b/src/ADAPTGUI/MonEditCase.h @@ -0,0 +1,50 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_EDITCASE_H +#define MON_EDITCASE_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) + +#include + +class HOMARD_EXPORT MonEditCase : public MonCreateCase +{ + Q_OBJECT +public: + MonEditCase( bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString Name ); + virtual ~MonEditCase(); + +protected : + virtual void InitValEdit(); + virtual bool PushOnApply(); + +public slots: + +}; + +#endif diff --git a/src/ADAPTGUI/MonEditFile.cxx b/src/ADAPTGUI/MonEditFile.cxx new file mode 100644 index 000000000..623b3c33c --- /dev/null +++ b/src/ADAPTGUI/MonEditFile.cxx @@ -0,0 +1,119 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonEditFile.h" + +#include +#include +#include + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include + +using namespace std; + +/* --------------------------------------------------------- + * MonEditFile classe derivee de EditFile + * elle meme generee par uic + * Ouvre le fichier passe en parametre + * et affiche le texte correspondant dans la fenetre de log + * --------------------------------------------------------- + */ + +/* --------------------------------------------------------- + * MonEditFile Constructeur + * --------------------------------------------------------- + */ +MonEditFile::MonEditFile( QWidget* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString aFileName, int option): +// QWidget(0), + Ui_EditFile(), + _aFileName (aFileName), + _option (option), + _codret (0) +{ + MESSAGE("Debut de MonEditFile " << aFileName.toStdString().c_str()); + setupUi(this); + InitConnect(); + EditText(); +} +/* + * Destroys the object and frees any allocated resources + */ +MonEditFile::~MonEditFile() +{ + MESSAGE("Destructeur de ~MonEditFile"); +} +// ------------------------------------------------------------------------ +void MonEditFile::InitConnect() +// ------------------------------------------------------------------------ +{ + connect( buttonQuit, SIGNAL(pressed()), this, SLOT(close())); + connect( buttonPrint, SIGNAL(pressed()), this, SLOT(PushOnPrint())); +} +// ------------------------------------------------------------------------ +void MonEditFile::EditText() +// ------------------------------------------------------------------------ +{ +// Creation de l'objet fichier QT associe + QFile file( _aFileName ); +// Ouverture + bool bOpen = file.open( QIODevice::ReadOnly | QIODevice::Text ) ; +// + if ( bOpen ) + { +// Lecture +// Remarque : il serait plus clair de tout lire d'un coup mais cela ne marche pas ! +// alors on fait ligne par ligne et on cumule en ajoutant un saut de ligne. + QTextStream stream( &file ); + QString tout; + while ( !stream.atEnd() ) + { + tout = tout + stream.readLine() + "\n" ; + } +// tout = stream.readAll() ; + QTBEditFile->setPlainText( tout ); + } + else + { + // Option = 0 : emission d'un message d'erreur + if ( _option == 0 ) + { + MESSAGE( "EditText " << _aFileName.toStdString().c_str() << " est impossible a ouvrir "); + QMessageBox::warning( 0, QObject::tr("HOM_WARNING"), + QObject::tr("HOM_SELECT_FILE_3") ); + } + // Sinon : rien + _codret = 1 ; + } +} +// ------------------------------------------------------------------------ +void MonEditFile::PushOnPrint() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de MonEditFile::PushOnPrint") + QMessageBox::warning( 0, QObject::tr("HOM_WARNING"), + QObject::tr("HOM_INACTIVE_BUTTON") ); + return; +} + + diff --git a/src/ADAPTGUI/MonEditFile.h b/src/ADAPTGUI/MonEditFile.h new file mode 100644 index 000000000..e60071080 --- /dev/null +++ b/src/ADAPTGUI/MonEditFile.h @@ -0,0 +1,64 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_EDITFILE_H +#define MON_EDITFILE_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include "SALOME_Selection.h" +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) +#include CORBA_CLIENT_HEADER(HOMARD_Cas) + +#include "ui_EditFile.h" +#include + +class QListBox; +class QDialog; + +class HOMARD_EXPORT MonEditFile : public QWidget, public Ui_EditFile +{ + Q_OBJECT + +public: + MonEditFile( QWidget* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString FileName, int option ); + ~MonEditFile(); + int _codret ; + +protected : + + ADAPT::ADAPT_Gen_var myAdaptGen; + QString _aFileName ; + int _option ; + + virtual void InitConnect(); + virtual void EditText(); + +public slots: + virtual void PushOnPrint(); + +}; + +#endif // MON_EDITFILE_H diff --git a/src/ADAPTGUI/MonEditHypothesis.cxx b/src/ADAPTGUI/MonEditHypothesis.cxx new file mode 100644 index 000000000..997667b81 --- /dev/null +++ b/src/ADAPTGUI/MonEditHypothesis.cxx @@ -0,0 +1,463 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonEditHypothesis.h" +#include "MonEditListGroup.h" + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include "HOMARD.hxx" +#include + +using namespace std; + +// ---------------------------------------------------------------------------- +MonEditHypothesis::MonEditHypothesis( MonCreateIteration* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString Name, + QString caseName, QString aFieldFile ): +// ---------------------------------------------------------------------------- +/* Constructs a MonEditHypothesis + herite de MonCreateHypothesis +*/ + MonCreateHypothesis(parent, modal,myAdaptGen, Name, caseName, aFieldFile) +{ + MESSAGE("Hypothese " << Name.toStdString().c_str()); + setWindowTitle(QObject::tr("HOM_HYPO_EDIT_WINDOW_TITLE")); + aHypothesis = myAdaptGen->GetHypothesis(_Name.toStdString().c_str()); + if (caseName == QString("") ){ _aCaseName = aHypothesis->GetCaseCreation();} + InitValEdit(); + InitGroupes(); +} +// ------------------------------ +MonEditHypothesis::~MonEditHypothesis() +// ------------------------------ +{ +} +// ------------------------------ +void MonEditHypothesis::InitGroupes() +// ------------------------------ +{ + ADAPT::ListGroupType_var maListe = aHypothesis->GetGroups(); + for ( int i = 0; i < maListe->length(); i++ ) + _aListeGroupes << QString(maListe[i]); + + if (maListe->length() == 0) { CBGroupe->hide();} +} + +// ------------------------------ +void MonEditHypothesis::InitValEdit() +// ------------------------------ +{ + MESSAGE("Debut de InitValEdit"); + LEName->setText(_Name); + LEName->setReadOnly(true); + ADAPT::listeTypes_var ListTypes (aHypothesis->GetAdapRefinUnRef()); + ASSERT( ListTypes->length()==3) ; + _aTypeAdap = ListTypes[0]; + _aTypeRaff = ListTypes[1]; + _aTypeDera = ListTypes[2]; + + if (_aTypeAdap == -1) InitAdaptUniforme(); + if (_aTypeAdap == 0) InitAdaptZone(); + if (_aTypeAdap == 1) InitAdaptChamps(); + + RBUniDera->setDisabled(true); + RBUniRaff->setDisabled(true); + + InitFieldInterp(); + + if (_aTypeAdap == 1 || _TypeFieldInterp >= 1 ) + { + if (_aFieldFile == QString("")) { GBFieldFile->setVisible(0); } + else + { + GBFieldFile->setVisible(1); + LEFieldFile->setText(_aFieldFile); + LEFieldFile->setReadOnly(1); + } + } + else + { + GBFieldFile->setVisible(0); + } +// Les options avancees (non modifiables) + CBAdvanced->setVisible(0) ; + int NivMax = aHypothesis->GetNivMax(); + double DiamMin = aHypothesis->GetDiamMin(); + int AdapInit = aHypothesis->GetAdapInit(); + int ExtraOutput = aHypothesis->GetExtraOutput(); + if ( NivMax > 0 || DiamMin > 0 || AdapInit != 0 || ExtraOutput != 1 ) + { GBAdvancedOptions->setVisible(1); + if ( NivMax > 0 ) + { SpinBoxNivMax->setValue(NivMax); + SpinBoxNivMax->setDisabled(true); } + else + { TLMaximalLevel->setVisible(0); + SpinBoxNivMax->setVisible(0); } + if ( DiamMin > 0 ) + { doubleSpinBoxDiamMin->setValue(DiamMin); + doubleSpinBoxDiamMin->setDisabled(true); } + else + { TLMinimalDiameter->setVisible(0); + doubleSpinBoxDiamMin->setVisible(0); } + if ( AdapInit != 0 ) + { + if ( AdapInit > 0 ) + { RBAIR->setChecked(true); } + else + { RBAID->setChecked(true); } + RBAIN->setEnabled(false); + RBAIR->setEnabled(false); + RBAID->setEnabled(false); + } + else + { GBAdapInit->setVisible(0) ; + } + if ( ExtraOutput % 2 == 0 ) + { + CBOutputLevel->setChecked(true); + CBOutputLevel->setEnabled(false); + } + else { CBOutputLevel->setVisible(0) ; } + if ( ExtraOutput % 3 == 0 ) + { + CBOutputQuality->setChecked(true); + CBOutputQuality->setEnabled(false); + } + else { CBOutputQuality->setVisible(0) ; } + if ( ExtraOutput % 5 == 0 ) + { + CBOutputDiameter->setChecked(true); + CBOutputDiameter->setEnabled(false); + } + else { CBOutputDiameter->setVisible(0) ; } + if ( ExtraOutput % 7 == 0 ) + { + CBOutputParent->setChecked(true); + CBOutputParent->setEnabled(false); + } + else { CBOutputParent->setVisible(0) ; } + if ( ExtraOutput % 11 == 0 ) + { + CBOutputVoisins->setChecked(true); + CBOutputVoisins->setEnabled(false); + } + else { CBOutputVoisins->setVisible(0) ; } + } + else + { GBAdvancedOptions->setVisible(0); } +// +} +// ---------------------------------------- +void MonEditHypothesis::InitAdaptUniforme() +// ---------------------------------------- +// Affichage des informations pour une adaptation uniforme +{ +// Choix des options generales + GBFieldManagement->setVisible(0); + GBAreaManagement->setVisible(0); + GBUniform->setVisible(1); + RBUniforme->setChecked(true); + RBUniforme->setEnabled(false); + RBChamp->setEnabled(false); + RBZone->setEnabled(false); +// +// Raffinement ou deraffinement ? + if (_aTypeDera == 0) + { + VERIFICATION(_aTypeRaff==1); + RBUniDera->setChecked(false); + RBUniRaff->setChecked(true); + } + if (_aTypeDera == 1) + { + VERIFICATION(_aTypeRaff==0); + RBUniDera->setChecked(true); + RBUniRaff->setChecked(false); + } +// + adjustSize(); +// +} +// ------------------------------------- +void MonEditHypothesis::InitAdaptZone() +// ------------------------------------- +// Affichage des informations pour une adaptation selon des zones : +{ + MESSAGE ("Debut de InitAdaptZone"); +// Choix des options generales + GBUniform->setVisible(0); + GBFieldManagement->setVisible(0); + GBAreaManagement->setVisible(1); + RBZone->setChecked(true); + RBChamp->setEnabled(false); + RBUniforme->setEnabled(false); + RBZone->setEnabled(false); + +// Recuperation de toutes les zones decrites et notation de celles retenues + GetAllZones(); + ADAPT::listeZonesHypo_var mesZonesAvant = aHypothesis->GetZones(); + for (int i=0; ilength(); i++) + { + MESSAGE ("i"<rowCount(); j++) + { + MESSAGE (". j"<item(j,2)->text().toStdString()); + if ( TWZone->item(j,2)->text().toStdString() == string(mesZonesAvant[i]) ) + { + MESSAGE ("OK avec "<item( j,0 )->setCheckState( Qt::Checked ); + TWZone->item( j,1 )->setCheckState( Qt::Unchecked ); } + else + { + MESSAGE ("... DERA"); + TWZone->item( j,0 )->setCheckState( Qt::Unchecked ); + TWZone->item( j,1 )->setCheckState( Qt::Checked ); } + break; + } + } + i += 1 ; + } +// +// Inactivation des choix + for ( int j =0 ; j < TWZone->rowCount(); j++) + { + TWZone->item( j, 0 )->setFlags(0); + TWZone->item( j, 1 )->setFlags(0); + } + PBZoneNew->setVisible(0); +// + adjustSize(); +// +} +// ------------------------------------- +void MonEditHypothesis::InitAdaptChamps() +// ------------------------------------- +// Affichage des informations pour une adaptation selon un champ : +// . Nom du champ +// . Composantes +// . Seuils +// . Absolu/relatif +{ + MESSAGE ("Debut de InitAdaptChamps"); +// Choix des options generales + GBUniform->setVisible(0); + GBAreaManagement->setVisible(0); + GBFieldManagement->setVisible(1); + RBChamp->setChecked(true); + RBUniforme->setEnabled(false); + RBChamp->setEnabled(false); + RBZone->setEnabled(false); + + ADAPT::InfosHypo_var aInfosHypo = aHypothesis->GetField(); + _aFieldName = aInfosHypo->FieldName; + _TypeThR = aInfosHypo->TypeThR; + _ThreshR = aInfosHypo->ThreshR; + _TypeThC = aInfosHypo->TypeThC; + _ThreshC = aInfosHypo->ThreshC; + _UsField = aInfosHypo->UsField; + _UsCmpI = aInfosHypo->UsCmpI; + + CBFieldName->insertItem(0,_aFieldName); + CBFieldName->setCurrentIndex(0); + CBFieldName->setEnabled(false); + //SetFieldName(Qt::Unchecked); + + ADAPT::listeComposantsHypo_var mesComposantsAvant = aHypothesis->GetComps(); + TWCMP->clear(); + TWCMP->setRowCount(0); + TWCMP->resizeRowsToContents(); + for (int i=0; ilength(); i++) + { + TWCMP->insertRow(0); + TWCMP->setItem( 0, 0, new QTableWidgetItem( QString ("") ) ); + TWCMP->item( 0, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled); + TWCMP->item( 0, 0 )->setCheckState(Qt::Checked ); + TWCMP->item( 0, 0 )->setFlags( 0 ); + TWCMP->setItem( 0, 1, new QTableWidgetItem(QString(mesComposantsAvant[i]).trimmed())); + TWCMP->item( 0, 1 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable ); + } + TWCMP->resizeColumnsToContents(); + TWCMP->resizeRowsToContents(); + TWCMP->clearSelection(); + + // Les seuils de raffinement + RBRAbs->setEnabled(false) ; + RBRRel->setEnabled(false) ; + RBRPE->setEnabled(false) ; + RBRMuSigma->setEnabled(false) ; + RBRNo->setEnabled(false) ; + if (_aTypeRaff== 0 ) + { + SetRNo(); + RBRNo->setEnabled(true) ; + } + else + { + if ( _TypeThR == 1 ) { SpinBox_RAbs->setValue(_ThreshR); SetRAbs(); RBRAbs->setEnabled(true);} + if ( _TypeThR == 2 ) { SpinBox_RRel->setValue(_ThreshR); SetRRel(); RBRRel->setEnabled(true);} + if ( _TypeThR == 3 ) { SpinBox_RPE->setValue(_ThreshR); SetRPE(); RBRPE->setEnabled(true);} + if ( _TypeThR == 4 ) { SpinBox_RMuSigma->setValue(_ThreshR); SetRMS(); RBRMuSigma->setEnabled(true);} + } + + // Les seuils de deraffinement + RBCAbs->setEnabled(false) ; + RBCRel->setEnabled(false) ; + RBCPE->setEnabled(false) ; + RBCMuSigma->setEnabled(false) ; + RBCNo->setEnabled(false) ; + if (_aTypeDera== 0 ) + { + SetCNo(); + RBCNo->setEnabled(true) ; + } + else + { + if ( _TypeThC == 1 ) { SpinBox_CAbs->setValue(_ThreshC); SetCAbs(); RBCAbs->setEnabled(true);} + if ( _TypeThC == 2 ) { SpinBox_CRel->setValue(_ThreshC); SetCRel(); RBCRel->setEnabled(true);} + if ( _TypeThC == 3 ) { SpinBox_CPE->setValue(_ThreshC); SetCPE(); RBCPE->setEnabled(true);} + if ( _TypeThC == 4 ) { SpinBox_CMuSigma->setValue(_ThreshC); SetCMS(); RBCMuSigma->setEnabled(true);} + } + // Le choix de la prise en compte des composantes + if ( TWCMP->rowCount() == 1 ) + { RBL2->setText(QObject::tr("HOM_HYPO_NORM_ABS")); + RBInf->setText(QObject::tr("HOM_HYPO_NORM_REL")); + } + else + { RBL2->setText(QObject::tr("HOM_HYPO_NORM_L2")); + RBInf->setText(QObject::tr("HOM_HYPO_NORM_INF")); + } + if ( _UsField == 0 ) { CBJump->hide(); } + else + { + CBJump->setChecked(true); + CBJump->setEnabled(false); + } + if ( _UsCmpI == 0 ) + { + RBL2->setChecked(true); + RBL2->setEnabled(true); + RBInf->setEnabled(false) ; + } + else + { + RBL2->setEnabled(false) ; + RBInf->setChecked(true); + RBInf->setEnabled(true); + } +// + adjustSize(); +} +// ------------------------------------- +void MonEditHypothesis::InitFieldInterp() +// ------------------------------------- +// Affichage des informations pour les interpolations +{ + MESSAGE ("Debut de InitFieldInterp"); +// Choix des options generales + _TypeFieldInterp = aHypothesis->GetTypeFieldInterp(); + MESSAGE ("_TypeFieldInterp = " << _TypeFieldInterp); +// +// Aucune interpolation + if ( _TypeFieldInterp == 0 ) + { + RBFieldNo->setChecked(true); + TWField->setVisible(0); + } +// Interpolation de tous les champs + if ( _TypeFieldInterp == 1 ) + { + RBFieldAll->setChecked(true); + TWField->setVisible(0); + } +// Interpolation de champs choisis + if ( _TypeFieldInterp == 2 ) + { + RBFieldChosen->setChecked(true); +// + TWField->setVisible(1); + ADAPT::listeFieldInterpsHypo_var mesChampsAvant = aHypothesis->GetFieldInterps(); + TWField->clear(); + TWField->setRowCount(0); + TWField->resizeRowsToContents(); + for (int iaux=0; iauxlength(); iaux++) + { + TWField->insertRow(0); + TWField->setItem( 0, 0, new QTableWidgetItem( QString ("") ) ); + TWField->item( 0, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled); + TWField->item( 0, 0 )->setCheckState(Qt::Checked ); + TWField->item( 0, 0 )->setFlags( 0 ); + TWField->setItem( 0, 1, new QTableWidgetItem(QString(mesChampsAvant[iaux]).trimmed())); + TWField->item( 0, 1 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable ); + iaux++; + } + TWField->resizeColumnsToContents(); + TWField->resizeRowsToContents(); + TWField->clearSelection(); + } + RBFieldNo->setEnabled(false) ; + RBFieldAll->setEnabled(false) ; + RBFieldChosen->setEnabled(false) ; +} + +// ------------------------------------- +bool MonEditHypothesis::PushOnApply() +// ------------------------------------- +{ +// Pour du raffinement selon un champ, les seuils ont-ils change ? + if ( _aTypeAdap == 1 ) + { + if (_aTypeRaff!= 0 ) + { + if (_TypeThR == 1) { _ThreshR = SpinBox_RAbs->value(); } + if (_TypeThR == 2) { _ThreshR = SpinBox_RRel->value(); } + if (_TypeThR == 3) { _ThreshR = SpinBox_RPE->value(); } + if (_TypeThR == 4) { _ThreshR = SpinBox_RMuSigma->value(); } + aHypothesis->SetRefinThr(_TypeThR, _ThreshR) ; + } + if (_aTypeDera!= 0 ) + { + if (_TypeThC == 1) { _ThreshC = SpinBox_CAbs->value() ; } + if (_TypeThC == 2) { _ThreshC = SpinBox_CRel->value() ; } + if (_TypeThC == 3) { _ThreshC = SpinBox_CPE->value() ; } + if (_TypeThC == 4) { _ThreshC = SpinBox_CMuSigma->value() ; } + aHypothesis->SetUnRefThr(_TypeThC, _ThreshC) ; + } + + myAdaptGen->InvalideHypo(_Name.toStdString().c_str()); + HOMARD_UTILS::updateObjBrowser(); + } + return true; +}; +// ------------------------------------------------------------------------ +void MonEditHypothesis::SetFiltrage() +// ------------------------------------------------------------------------ +{ + if (CBGroupe->isChecked()) + { + MonEditListGroup *aDlg = new MonEditListGroup(this, NULL, true, ADAPT::ADAPT_Gen::_duplicate(myAdaptGen),_aCaseName, _aListeGroupes) ; + aDlg->show(); + } +} + diff --git a/src/ADAPTGUI/MonEditHypothesis.h b/src/ADAPTGUI/MonEditHypothesis.h new file mode 100644 index 000000000..ef5a3e592 --- /dev/null +++ b/src/ADAPTGUI/MonEditHypothesis.h @@ -0,0 +1,56 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_EDITHYPOTHESIS_H +#define MON_EDITHYPOTHESIS_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) + +#include + +class HOMARD_EXPORT MonEditHypothesis : public MonCreateHypothesis +{ + Q_OBJECT +public: + MonEditHypothesis( MonCreateIteration* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString caseName, QString Name, QString aFieldFile ); + virtual ~MonEditHypothesis(); + +protected : + virtual void InitValEdit(); + virtual void InitAdaptUniforme(); + virtual void InitAdaptZone(); + virtual void InitAdaptChamps(); + virtual void InitGroupes(); + virtual void InitFieldInterp(); + virtual void SetFiltrage(); + virtual bool PushOnApply(); + +public slots: + +}; + +#endif diff --git a/src/ADAPTGUI/MonEditIteration.cxx b/src/ADAPTGUI/MonEditIteration.cxx new file mode 100644 index 000000000..8e75e0f6e --- /dev/null +++ b/src/ADAPTGUI/MonEditIteration.cxx @@ -0,0 +1,186 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonEditIteration.h" + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include + +using namespace std; + +// ------------------------------------------------------------------------------------------------------------------------------------- +MonEditIteration::MonEditIteration ( QWidget* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString IterParentName, QString IterName ): +// ------------------------------------------------------------------------------------------------------------------------------------- +/* Constructs a MonEditIteration + herite de MonCreateIteration +*/ + MonCreateIteration(parent, modal, myAdaptGen, IterParentName), + _rank(-1), _step(-1), _IterationName(""), _FieldFile(""),_aTypeAdap() +{ + MESSAGE("Debut de MonEditIteration" << IterName.toStdString().c_str()); + setWindowTitle(QObject::tr("HOM_ITER_EDIT_WINDOW_TITLE")); + _IterationName = IterName; + aIter = myAdaptGen->GetIteration(_IterationName.toStdString().c_str()); + +// Attention au cas ou c'est une iteration initiale : il faut inhiber l'essentiel + int etat = aIter->GetState() ; + if ( etat <= 0 ) { InitValEdit0(etat); } + else { InitValEdit(); } +} +// ------------------------------ +MonEditIteration::~MonEditIteration() +// ------------------------------ +{ +} + +// ------------------------------ +void MonEditIteration::InitValEdit0(int etat) +// ------------------------------ +// Cas d'une iteration initiale d'un cas (initial ou poursuite) +{ +// + LEName->setText(_IterationName); + LEName->setReadOnly(true); + +// Invisibilite de l'iteration parent + Iter_Parent->setVisible(0); + PBIterParent->setVisible(0); + LEIterationParentName->setVisible(0); + +// Affichage bloque du nom du maillage de l'iteration courante + QString MeshName = aIter->GetMeshName(); + Mesh_n->setText(QObject::tr("HOM_ITER_STARTING_POINT_0")); + LEMeshName_n->setText(MeshName); + LEMeshName_n->setReadOnly(1); + +// Message general + if ( etat == 0 ) { Mesh_np1->setText(QObject::tr("HOM_ITER_STARTING_POINT_1")) ; } + else { Mesh_np1->setText(QObject::tr("HOM_ITER_STARTING_POINT_2")) ; } + LEMeshName_np1->setVisible(0); +// +// Invisibilite des hypotheses et des champs + Hypothese->setVisible(0); + GBField->setVisible(0); +// +} +// ------------------------------ +void MonEditIteration::InitValEdit() +// ------------------------------ +// Cas d'une iteration courante +{ +// Affichage bloque du nom de l'iteration + LEName->setText(_IterationName); + LEName->setReadOnly(true); + + // Affichage bloque du nom de l'iteration parent + _IterParentName = aIter->GetIterParentName(); + LEIterationParentName->setText(_IterParentName); + LEIterationParentName->setReadOnly(true); + PBIterParent->setEnabled(false); + PBIterParent->setVisible(0); + + // Affichage bloque du nom du maillage de l'iteration parent + aIterParent = myAdaptGen->GetIteration(_IterParentName.toStdString().c_str()); + QString MeshNameParent = aIterParent->GetMeshName(); + LEMeshName_n->setText(MeshNameParent); + LEMeshName_n->setReadOnly(1); + + // Affichage bloque du nom du maillage de l'iteration courante + QString MeshName = aIter->GetMeshName(); + LEMeshName_np1->setText(MeshName); + LEMeshName_np1->setReadOnly(1); + + // Affichage de la bonne hypothese + QString HypoName = aIter->GetHypoName(); + CBHypothese->insertItem(0,HypoName); + CBHypothese->setCurrentIndex(0); + CBHypothese->setEnabled(false); + PBHypoNew->setVisible(0); + + // Pour une adaptation selon un champ + ADAPT::HOMARD_Hypothesis_var myHypo = myAdaptGen->GetHypothesis(HypoName.toStdString().c_str()) ; + _aTypeAdap = myHypo->GetAdapType() ; + if ( _aTypeAdap == 1 ) + { + _FieldFile = aIter->GetFieldFile(); + LEFieldFile->setText(_FieldFile); + _step = aIter->GetTimeStep() ; + SpinBox_TimeStep->setValue(_step); + _rank = aIter->GetRank() ; + SpinBox_Rank->setValue(_rank); + + // Cas ou on prend le dernier pas de temps ou sans pas de temps + if ( _step <= -1 ) + { + Rank->setVisible(0); + SpinBox_Rank->setVisible(0); + TimeStep->setVisible(0); + SpinBox_TimeStep->setVisible(0); + + if ( _step == -2 ) { RBLast->setChecked(true); } + else { RBNo->setChecked(true); } + } + + // Cas avec pas de temps + else + { + Rank->setVisible(1); + SpinBox_Rank->setVisible(1); + TimeStep->setVisible(1); + SpinBox_TimeStep->setVisible(1); + RBChosen->setChecked(true); + } + } + else + { + GBField->setVisible(0); + } +// + adjustSize(); +// +} + +// ------------------------------------- +bool MonEditIteration::PushOnApply() +// ------------------------------------- +{ + if ( _aTypeAdap == 1) + { +// Pour du raffinement selon un champ, les instants ont-ils change ? + if ( (_FieldFile != LEFieldFile->text().trimmed()) || + ( _rank != SpinBox_Rank->value()) || + ( _step != SpinBox_TimeStep->value())) + { + _FieldFile = LEFieldFile->text().trimmed(); + aIter->SetFieldFile(CORBA::string_dup(_FieldFile.toStdString().c_str())); + _rank = SpinBox_Rank->value(); + _step = SpinBox_TimeStep->value(); + if ( _step == -2 ) { aIter->SetTimeStepRankLast(); } + else { aIter->SetTimeStepRank(_step, _rank); } + myAdaptGen->InvalideIter(_IterationName.toStdString().c_str()); + HOMARD_UTILS::updateObjBrowser(); + } + } + return true; + +}; diff --git a/src/ADAPTGUI/MonEditIteration.h b/src/ADAPTGUI/MonEditIteration.h new file mode 100644 index 000000000..76abc6025 --- /dev/null +++ b/src/ADAPTGUI/MonEditIteration.h @@ -0,0 +1,57 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_EDITITERATION_H +#define MON_EDITITERATION_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) + +#include + +class HOMARD_EXPORT MonEditIteration : public MonCreateIteration +{ + Q_OBJECT +public: + MonEditIteration( QWidget* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString IterParentName, QString Name ); + virtual ~MonEditIteration(); + +protected : + QString _FieldFile ; + QString _IterationName ; + int _aTypeAdap ; + int _rank ; + int _step ; + + virtual void InitValEdit(); + virtual void InitValEdit0(int etat); + virtual bool PushOnApply(); + +public slots: + +}; + +#endif diff --git a/src/ADAPTGUI/MonEditListGroup.cxx b/src/ADAPTGUI/MonEditListGroup.cxx new file mode 100644 index 000000000..c931c7ba7 --- /dev/null +++ b/src/ADAPTGUI/MonEditListGroup.cxx @@ -0,0 +1,61 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonEditListGroup.h" +#include + +using namespace std; +//--------------------------------------------------------------------- +MonEditListGroup::MonEditListGroup( MonCreateHypothesis* parentHyp, + MonCreateBoundaryDi* parentBound, + bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString aCaseName, + QStringList listeGroupesHypo): +//--------------------------------------------------------------------- +MonCreateListGroup(parentHyp,parentBound,myAdaptGen,aCaseName,listeGroupesHypo) +{ + MESSAGE("Debut de MonEditListGroup"); + setWindowTitle(QObject::tr("HOM_GROU_EDIT_WINDOW_TITLE")); + setModal(true); + InitGroupes(); +} + +//------------------------------------ +MonEditListGroup:: ~MonEditListGroup() +//------------------------------------ +{ +} +// ------------------------------------- +void MonEditListGroup:: InitGroupes() +// ------------------------------------- +{ + for (int i = 0; i < _listeGroupesHypo.size(); i++ ) + { + std::cerr << _listeGroupesHypo[i].toStdString().c_str() << std::endl; + TWGroupe->insertRow(i); + TWGroupe->setItem( i, 0, new QTableWidgetItem( QString ("") ) ); + TWGroupe->item( i, 0 )->setFlags( 0 ); + TWGroupe->item( i, 0 )->setCheckState( Qt::Checked ); + TWGroupe->setItem( i, 1, new QTableWidgetItem(_listeGroupesHypo[i])); + } + TWGroupe->resizeRowsToContents(); +} + + diff --git a/src/ADAPTGUI/MonEditListGroup.h b/src/ADAPTGUI/MonEditListGroup.h new file mode 100644 index 000000000..0e90cf837 --- /dev/null +++ b/src/ADAPTGUI/MonEditListGroup.h @@ -0,0 +1,49 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_EDITLISTGROUP_H +#define MON_EDITLISTGROUP_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) + +#include + +class MonCreateHypothesis; +class MonCreateBoundaryDi; +class HOMARD_EXPORT MonEditListGroup : public MonCreateListGroup +{ + Q_OBJECT + +public: + MonEditListGroup( MonCreateHypothesis* parentHyp, MonCreateBoundaryDi* parentBound, bool modal, ADAPT::ADAPT_Gen_var myAdaptGen, QString aCaseName, QStringList listeGroupesHypo); + virtual ~MonEditListGroup(); + +protected : + + virtual void InitGroupes(); + +}; + +#endif // MON_EDITLISTGROUP_H diff --git a/src/ADAPTGUI/MonEditListGroupCAO.cxx b/src/ADAPTGUI/MonEditListGroupCAO.cxx new file mode 100644 index 000000000..c29d2288c --- /dev/null +++ b/src/ADAPTGUI/MonEditListGroupCAO.cxx @@ -0,0 +1,61 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonEditListGroupCAO.h" +#include + +using namespace std; +//--------------------------------------------------------------------- +MonEditListGroupCAO::MonEditListGroupCAO( MonCreateHypothesis* parentHyp, + MonCreateBoundaryCAO* parentBound, + bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString aCaseName, + QStringList listeGroupesHypo): +//--------------------------------------------------------------------- +MonCreateListGroupCAO(parentHyp,parentBound,myAdaptGen,aCaseName,listeGroupesHypo) +{ + MESSAGE("Debut de MonEditListGroupCAO"); + setWindowTitle(QObject::tr("HOM_GROU_EDIT_WINDOW_TITLE")); + setModal(true); + InitGroupes(); +} + +//------------------------------------ +MonEditListGroupCAO:: ~MonEditListGroupCAO() +//------------------------------------ +{ +} +// ------------------------------------- +void MonEditListGroupCAO:: InitGroupes() +// ------------------------------------- +{ + for (int i = 0; i < _listeGroupesHypo.size(); i++ ) + { + std::cerr << _listeGroupesHypo[i].toStdString().c_str() << std::endl; + TWGroupe->insertRow(i); + TWGroupe->setItem( i, 0, new QTableWidgetItem( QString ("") ) ); + TWGroupe->item( i, 0 )->setFlags( 0 ); + TWGroupe->item( i, 0 )->setCheckState( Qt::Checked ); + TWGroupe->setItem( i, 1, new QTableWidgetItem(_listeGroupesHypo[i])); + } + TWGroupe->resizeRowsToContents(); +} + + diff --git a/src/ADAPTGUI/MonEditListGroupCAO.h b/src/ADAPTGUI/MonEditListGroupCAO.h new file mode 100644 index 000000000..a32d87402 --- /dev/null +++ b/src/ADAPTGUI/MonEditListGroupCAO.h @@ -0,0 +1,49 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_EDITLISTGROUPCAO_H +#define MON_EDITLISTGROUPCAO_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) + +#include + +class MonCreateHypothesis; +class MonCreateBoundaryCAO; +class HOMARD_EXPORT MonEditListGroupCAO : public MonCreateListGroupCAO +{ + Q_OBJECT + +public: + MonEditListGroupCAO( MonCreateHypothesis* parentHyp, MonCreateBoundaryCAO* parentBound, bool modal, ADAPT::ADAPT_Gen_var myAdaptGen, QString aCaseName, QStringList listeGroupesHypo); + virtual ~MonEditListGroupCAO(); + +protected : + + virtual void InitGroupes(); + +}; + +#endif // MON_EDITLISTGROUPCAO_H diff --git a/src/ADAPTGUI/MonEditYACS.cxx b/src/ADAPTGUI/MonEditYACS.cxx new file mode 100644 index 000000000..3b346ed2d --- /dev/null +++ b/src/ADAPTGUI/MonEditYACS.cxx @@ -0,0 +1,148 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonEditYACS.h" + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include + +using namespace std; + +// ------------------------------------------------------------- +/* Constructs a MonEditYACS + herite de MonCreateYACS +*/ +// ------------------------------------------------------------- +MonEditYACS::MonEditYACS ( bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString Name ): + MonCreateYACS(myAdaptGen, Name) +{ + MESSAGE("Debut de MonEditYACS" << Name.toStdString().c_str()); + setWindowTitle(QObject::tr("HOM_YACS_EDIT_WINDOW_TITLE")); + _Name = Name; + aYACS = myAdaptGen->GetYACS(_Name.toStdString().c_str()); + InitValEdit(); +} +// ------------------------------ +MonEditYACS::~MonEditYACS() +// ------------------------------ +{ +} +// ------------------------------ +void MonEditYACS::InitValEdit() +// ------------------------------ +{ + MESSAGE("InitValEdit"); + LEName->setText(_Name); + LEName->setReadOnly(true); + + _aCaseName = aYACS->GetCaseName(); + LECaseName->setText(_aCaseName); + LECaseName->setReadOnly(true); + PBCaseName->setVisible(0); + + _aScriptFile = aYACS->GetScriptFile(); + LEScriptFile->setText(_aScriptFile); + + _aDirName = aYACS->GetDirName(); + LEDirName->setText(_aDirName); + LEDirName->setReadOnly(true); + + _aMeshFile = aYACS->GetMeshFile(); + LEMeshFile->setText(_aMeshFile); + + _Type=aYACS->GetType(); + if(_Type==1) { RBConstant->setChecked(true); } + else { RBVariable->setChecked(true); }; + RBConstant->setEnabled(false); + RBVariable->setEnabled(false); + + _MaxIter = aYACS->GetMaxIter(); + SpinBoxMaxIter->setValue(_MaxIter) ; + _MaxNode = aYACS->GetMaxNode(); + SpinBoxMaxNode->setValue(_MaxNode) ; + _MaxElem = aYACS->GetMaxElem(); + SpinBoxMaxElem->setValue(_MaxElem) ; +// +} + +// --------------------------------------------------- +bool MonEditYACS:: CreateOrUpdate() +//---------------------------------------------------- +// Edition/modification du schema +{ + MESSAGE("CreateOrUpdate"); + bool chgt = false ; + int valeur_i ; + // A. Recuperation et comparaison des valeurs + // A.1. Le script de lancement + QString aScriptFile=LEScriptFile->text().trimmed(); + if ( aScriptFile != _aScriptFile ) + { +// MESSAGE("modification de ScriptFile : "<<_aScriptFile.toStdString()<<" devient "<SetScriptFile(CORBA::string_dup(_aScriptFile.toStdString().c_str())) ; + chgt = true ; + } + // A.2. Le maillage initial + QString aMeshFile=LEMeshFile->text().trimmed(); + if ( aMeshFile != _aMeshFile ) + { +// MESSAGE("modification de aMeshFile : "<<_aMeshFile.toStdString()<<" devient "<SetMeshFile(CORBA::string_dup(_aMeshFile.toStdString().c_str())) ; + chgt = true ; + } + // A.3. La convergence + valeur_i = SpinBoxMaxIter->value() ; + if ( valeur_i != _MaxIter ) + { +// MESSAGE("modification de MaxIter : "<<_MaxIter<<" devient "<SetMaxIter(_MaxIter) ; + chgt = true ; + } + valeur_i = SpinBoxMaxNode->value() ; + if ( valeur_i != _MaxNode ) + { +// MESSAGE("modification de MaxNode : "<<_MaxNode<<" devient "<SetMaxNode(_MaxNode) ; + chgt = true ; + } + valeur_i = SpinBoxMaxElem->value() ; + if ( valeur_i != _MaxElem ) + { +// MESSAGE("modification de MaxElem : "<<_MaxElem<<" devient "<SetMaxElem(_MaxElem) ; + chgt = true ; + } +// B. Si changement + if ( chgt ) + { + myAdaptGen->InvalideYACS(_Name.toStdString().c_str()); + } + + HOMARD_UTILS::updateObjBrowser(); + return true ; +} diff --git a/src/ADAPTGUI/MonEditYACS.h b/src/ADAPTGUI/MonEditYACS.h new file mode 100644 index 000000000..ddb1b5dcc --- /dev/null +++ b/src/ADAPTGUI/MonEditYACS.h @@ -0,0 +1,50 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_EDITYACS_H +#define MON_EDITYACS_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) + +#include + +class HOMARD_EXPORT MonEditYACS : public MonCreateYACS +{ + Q_OBJECT +public: + MonEditYACS( bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString Name ); + virtual ~MonEditYACS(); + +protected : + virtual void InitValEdit(); + virtual bool CreateOrUpdate(); + +public slots: + +}; + +#endif diff --git a/src/ADAPTGUI/MonEditZone.cxx b/src/ADAPTGUI/MonEditZone.cxx new file mode 100644 index 000000000..c2ec454f7 --- /dev/null +++ b/src/ADAPTGUI/MonEditZone.cxx @@ -0,0 +1,432 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonEditZone.h" + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include +#include +#include +#include +#include +#include + +using namespace std; + +// ------------------------------------------------------------------------ +MonEditZone::MonEditZone( MonCreateHypothesis* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString caseName, QString Name ): +// ------------------------------------------------------------------------ +/* Constructs a MonEditZone + herite de MonCreateZone +*/ + MonCreateZone(parent, myAdaptGen, caseName) +{ + MESSAGE("Debut de MonEditZone pour " << Name.toStdString().c_str()); + setWindowTitle(QObject::tr("HOM_ZONE_EDIT_WINDOW_TITLE")); + _Name=Name; + aZone = myAdaptGen->GetZone(_Name.toStdString().c_str()); + InitValEdit(); +} +// ------------------------------------------------------------------------ +MonEditZone::~MonEditZone() +// ------------------------------------------------------------------------ +{ + // no need to delete child widgets, Qt does it all for us +} +// ------------------------------------------------------------------------ +void MonEditZone::InitValEdit() +// ------------------------------------------------------------------------ +{ + MESSAGE("InitValEdit "); + LEName->setText(_Name); + LEName->setReadOnly(true); + _Type = aZone->GetType(); + MESSAGE("InitValEdit _Type ="<<_Type); + InitValZoneLimit(); + if (_aCaseName != QString("")) InitValZone(); + switch (_Type) + { + case 11 : // il s agit d un rectangle + { } + case 12 : // il s agit d un rectangle + { } + case 13 : // il s agit d un rectangle + { } + case 2 : // il s agit d une boite + { + InitValZoneBox(); + SetBox(); + break; + } + case 4 : // il s agit d une sphere + { + InitValZoneSphere(); + SetSphere(); + break; + } + case 31 : // il s agit d un cercle issu d'un cylindre + { } + case 32 : // il s agit d un cercle issu d'un cylindre + { } + case 33 : // il s agit d un cercle issu d'un cylindre + { } + case 5 : // il s agit d un cylindre + { + InitValZoneCylinder(); + SetCylinder(); + break; + } + case 61 : // il s agit d un disque avec trou issu d'un tuyau + { } + case 62 : // il s agit d un disque avec trou issu d'un tuyau + { } + case 63 : // il s agit d un disque avec trou issu d'un tuyau + { } + case 7 : // il s agit d un tuyau + { + InitValZonePipe(); + SetPipe(); + break; + } + }; +} +// ------------------------------------------------------------------------ +void MonEditZone::InitValZoneLimit() +// ------------------------------------------------------------------------ +{ + ADAPT::double_array_var mesCoordLimits = aZone->GetLimit(); + ASSERT(mesCoordLimits->length() == 3 ); + _Xincr=mesCoordLimits[0]; + _Yincr=mesCoordLimits[1]; + _Zincr=mesCoordLimits[2]; +} +// ------------------------------------------------------------------------ +void MonEditZone::InitValZoneBox() +// ------------------------------------------------------------------------ +{ + ADAPT::double_array_var mesCoordZones = aZone->GetCoords(); + ASSERT(mesCoordZones->length() == 6 ); + _ZoneXmin=mesCoordZones[0]; + _ZoneXmax=mesCoordZones[1]; + _ZoneYmin=mesCoordZones[2]; + _ZoneYmax=mesCoordZones[3]; + _ZoneZmin=mesCoordZones[4]; + _ZoneZmax=mesCoordZones[5]; +} +// ------------------------------------------------------------------------ +void MonEditZone::InitValZoneSphere() +// ------------------------------------------------------------------------ +{ + ADAPT::double_array_var mesCoordZones = aZone->GetCoords(); + ASSERT(mesCoordZones->length() == 4 ); + _ZoneXcentre=mesCoordZones[0]; + _ZoneYcentre=mesCoordZones[1]; + _ZoneZcentre=mesCoordZones[2]; + _ZoneRayon=mesCoordZones[3]; + +} +// ------------------------------------------------------------------------ +void MonEditZone::InitValZoneCylinder() +// ------------------------------------------------------------------------ +{ + ADAPT::double_array_var mesCoordZones = aZone->GetCoords(); + ASSERT(mesCoordZones->length() == 8 ); + _ZoneXcentre=mesCoordZones[0]; + _ZoneYcentre=mesCoordZones[1]; + _ZoneZcentre=mesCoordZones[2]; + _ZoneXaxis=mesCoordZones[3]; + _ZoneYaxis=mesCoordZones[4]; + _ZoneZaxis=mesCoordZones[5]; + _ZoneRayon=mesCoordZones[6]; + _ZoneHaut=mesCoordZones[7]; +} +// ------------------------------------------------------------------------ +void MonEditZone::InitValZonePipe() +// ------------------------------------------------------------------------ +{ + ADAPT::double_array_var mesCoordZones = aZone->GetCoords(); + ASSERT(mesCoordZones->length() == 9 ); + _ZoneXcentre=mesCoordZones[0]; + _ZoneYcentre=mesCoordZones[1]; + _ZoneZcentre=mesCoordZones[2]; + _ZoneXaxis=mesCoordZones[3]; + _ZoneYaxis=mesCoordZones[4]; + _ZoneZaxis=mesCoordZones[5]; + _ZoneRayon=mesCoordZones[6]; + _ZoneHaut=mesCoordZones[7]; + _ZoneRayonInt=mesCoordZones[8]; +} +// ------------------------------------------------------------------------ +void MonEditZone::SetBox() +// ------------------------------------------------------------------------ +{ + MESSAGE("SetBox "); + gBBox->setVisible(1); + gBSphere->setVisible(0); + gBCylindre->setVisible(0) ; + gBPipe->setVisible(0) ; + RBBox->setChecked(1); + adjustSize(); + RBCylinder->setDisabled(true); + RBPipe->setDisabled(true); + if ( _Type == 2 ) { RBSphere->setDisabled(true); } + else { RBSphere->setVisible(0); + RBPipe->setText(QApplication::translate("CreateZone", "Disk with hole", 0)); + RBCylinder->setText(QApplication::translate("CreateZone", "Disk", 0)); + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr() ; + QPixmap pix = resMgr->loadPixmap( "HOMARD", "boxdxy.png" ) ; + QIcon IS=QIcon(pix) ; + RBBox->setIcon(IS) ; } + adjustSize(); + + SpinBox_Xmini->setValue(_ZoneXmin); + SpinBox_Xmaxi->setValue(_ZoneXmax); + + double incr ; + if ( _Xincr > 0 ) {incr=_Xincr;} else{incr=1.;} + SpinBox_Xmini->setSingleStep(incr); + SpinBox_Xmaxi->setSingleStep(incr); + + SpinBox_Ymini->setValue(_ZoneYmin); + SpinBox_Ymaxi->setValue(_ZoneYmax); + if ( _Yincr > 0 ) {incr=_Yincr;} else{incr=1.;} + SpinBox_Ymini->setSingleStep(incr); + SpinBox_Ymaxi->setSingleStep(incr); + + SpinBox_Zmini->setValue(_ZoneZmin); + SpinBox_Zmaxi->setValue(_ZoneZmax); + if ( _Zincr > 0 ) {incr=_Zincr;} else{incr=1.;} + SpinBox_Zmini->setSingleStep(incr); + SpinBox_Zmaxi->setSingleStep(incr); + + if ( _Type == 12 ) { SpinBox_Xmini->setDisabled(true) ; + SpinBox_Xmaxi->setDisabled(true) ; } + else if ( _Type == 13 ) { SpinBox_Ymini->setDisabled(true) ; + SpinBox_Ymaxi->setDisabled(true) ; } + else if ( _Type == 11 ) { SpinBox_Zmini->setDisabled(true) ; + SpinBox_Zmaxi->setDisabled(true) ; } + +} +// ------------------------------------------------------------------------ +void MonEditZone::SetSphere() +// ------------------------------------------------------------------------ +{ + gBBox->setVisible(0); + gBSphere->setVisible(1); + gBCylindre->setVisible(0) ; + gBPipe->setVisible(0) ; + RBSphere->setChecked(1); + RBBox->setDisabled(true); + RBCylinder->setDisabled(true); + RBPipe->setDisabled(true); + adjustSize(); + + SpinBox_Xcentre->setValue(_ZoneXcentre); + if ( _Xincr > 0) { SpinBox_Xcentre->setSingleStep(_Xincr); } + else { SpinBox_Xcentre->setSingleStep(1) ; } + + SpinBox_Ycentre->setValue(_ZoneYcentre); + if ( _Yincr > 0) { SpinBox_Ycentre->setSingleStep(_Yincr); } + else { SpinBox_Ycentre->setSingleStep(1) ; } + + SpinBox_Zcentre->setValue(_ZoneZcentre); + if ( _Zincr > 0) { SpinBox_Zcentre->setSingleStep(_Zincr); } + else { SpinBox_Zcentre->setSingleStep(1);} + + SpinBox_Rayon->setValue(_ZoneRayon); +} +// ------------------------------------------------------------------------ +void MonEditZone::SetCylinder() +// ------------------------------------------------------------------------ +{ + MESSAGE("SetCylinder _Xincr ="<<_Xincr<< " _Yincr ="<<_Yincr<< " _Zincr ="<<_Zincr); + gBBox->setVisible(0); + gBSphere->setVisible(0); + gBCylindre->setVisible(1) ; + gBPipe->setVisible(0) ; + RBCylinder->setChecked(1); + RBBox->setDisabled(true); + RBPipe->setDisabled(true); + if ( _Type == 5 ) { RBSphere->setDisabled(true); } + else { RBSphere->setVisible(0); + RBPipe->setText(QApplication::translate("CreateZone", "Disk with hole", 0)); + RBCylinder->setText(QApplication::translate("CreateZone", "Disk", 0)); + TLXbase->setText(QApplication::translate("CreateZone", "X centre", 0)); + TLYbase->setText(QApplication::translate("CreateZone", "Y centre", 0)); + TLZbase->setText(QApplication::translate("CreateZone", "Z centre", 0)); + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr() ; + QPixmap pix = resMgr->loadPixmap( "HOMARD", "disk.png" ) ; + QIcon IS=QIcon(pix) ; + RBCylinder->setIcon(IS) ; } + adjustSize(); + + SpinBox_Xbase->setValue(_ZoneXcentre); + if ( _Xincr > 0) { SpinBox_Xbase->setSingleStep(_Xincr); } + else { SpinBox_Xbase->setSingleStep(1) ; } + + SpinBox_Ybase->setValue(_ZoneYcentre); + if ( _Yincr > 0) { SpinBox_Ybase->setSingleStep(_Yincr); } + else { SpinBox_Ybase->setSingleStep(1) ; } + + SpinBox_Zbase->setValue(_ZoneZcentre); + if ( _Zincr > 0) { SpinBox_Zbase->setSingleStep(_Zincr); } + else { SpinBox_Zbase->setSingleStep(1) ;} + + SpinBox_Radius->setValue(_ZoneRayon); + + if ( _Type == 5 ) + { SpinBox_Xaxis->setValue(_ZoneXaxis) ; + SpinBox_Yaxis->setValue(_ZoneYaxis) ; + SpinBox_Zaxis->setValue(_ZoneZaxis) ; + SpinBox_Haut->setValue(_ZoneHaut) ; + } + else + { SpinBox_Xaxis->setVisible(0) ; + SpinBox_Yaxis->setVisible(0) ; + SpinBox_Zaxis->setVisible(0) ; + SpinBox_Haut->setVisible(0) ; + TLXaxis->setVisible(0) ; + TLYaxis->setVisible(0) ; + TLZaxis->setVisible(0) ; + TLHaut->setVisible(0) ; + if ( _Type == 32 ) { SpinBox_Xbase->setDisabled(true) ; } + else if ( _Type == 33 ) { SpinBox_Ybase->setDisabled(true) ; } + else if ( _Type == 31 ) { SpinBox_Zbase->setDisabled(true) ; } + } +} +// ------------------------------------------------------------------------ +void MonEditZone::SetPipe() +// ------------------------------------------------------------------------ +{ + MESSAGE("SetPipe _Xincr ="<<_Xincr<< " _Yincr ="<<_Yincr<< " _Zincr ="<<_Zincr); + gBBox->setVisible(0); + gBSphere->setVisible(0); + gBCylindre->setVisible(0) ; + gBPipe->setVisible(1) ; + RBPipe->setChecked(1); + RBBox->setDisabled(true); + RBCylinder->setDisabled(true); + if ( _Type == 7 ) { RBSphere->setDisabled(true); } + else { RBSphere->setVisible(0); + RBPipe->setText(QApplication::translate("CreateZone", "Disk with hole", 0)); + RBCylinder->setText(QApplication::translate("CreateZone", "Disk", 0)); + TLXbase_p->setText(QApplication::translate("CreateZone", "X centre", 0)); + TLYbase_p->setText(QApplication::translate("CreateZone", "Y centre", 0)); + TLZbase_p->setText(QApplication::translate("CreateZone", "Z centre", 0)); + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr() ; + QPixmap pix = resMgr->loadPixmap( "HOMARD", "diskwithhole.png" ) ; + QIcon IS=QIcon(pix) ; + RBPipe->setIcon(IS) ; } + adjustSize(); + + SpinBox_Xbase_p->setValue(_ZoneXcentre); + if ( _Xincr > 0) { SpinBox_Xbase_p->setSingleStep(_Xincr); } + else { SpinBox_Xbase_p->setSingleStep(1) ; } + + SpinBox_Ybase_p->setValue(_ZoneYcentre); + if ( _Yincr > 0) { SpinBox_Ybase_p->setSingleStep(_Yincr); } + else { SpinBox_Ybase_p->setSingleStep(1) ; } + + SpinBox_Zbase_p->setValue(_ZoneZcentre); + if ( _Zincr > 0) { SpinBox_Zbase_p->setSingleStep(_Zincr); } + else { SpinBox_Zbase_p->setSingleStep(1) ;} + + SpinBox_Radius_int->setValue(_ZoneRayonInt); + SpinBox_Radius_ext->setValue(_ZoneRayon); + + if ( _Type == 7 ) + { SpinBox_Xaxis_p->setValue(_ZoneXaxis) ; + SpinBox_Yaxis_p->setValue(_ZoneYaxis) ; + SpinBox_Zaxis_p->setValue(_ZoneZaxis) ; + SpinBox_Haut_p->setValue(_ZoneHaut) ; + } + else + { SpinBox_Xaxis_p->setVisible(0) ; + SpinBox_Yaxis_p->setVisible(0) ; + SpinBox_Zaxis_p->setVisible(0) ; + SpinBox_Haut_p->setVisible(0) ; + TLXaxis_p->setVisible(0) ; + TLYaxis_p->setVisible(0) ; + TLZaxis_p->setVisible(0) ; + TLHaut_p->setVisible(0) ; + if ( _Type == 62 ) { SpinBox_Xbase_p->setDisabled(true) ; } + else if ( _Type == 63 ) { SpinBox_Ybase_p->setDisabled(true) ; } + else if ( _Type == 61 ) { SpinBox_Zbase_p->setDisabled(true) ; } + } +} + + +// --------------------------------------------------- +bool MonEditZone::CreateOrUpdateZone() +//---------------------------------------------------- +// Pas de Creation de la zone +// Mise a jour des attributs de la Zone +{ + try + { + switch (_Type) + { + case 11 : // il s agit d un rectangle + { } + case 12 : // il s agit d un rectangle + { } + case 13 : // il s agit d un rectangle + { } + case 2 : // il s agit d un parallelepipede + { aZone->SetBox( _ZoneXmin, _ZoneXmax, _ZoneYmin, _ZoneYmax, _ZoneZmin, _ZoneZmax ); + break; + } + case 4 : // il s agit d une sphere + { aZone->SetSphere( _ZoneXcentre, _ZoneYcentre, _ZoneZcentre, _ZoneRayon ); + break; + } + case 31 : // il s agit d un disque issu d'un cylindre + { } + case 32 : // il s agit d un disque issu d'un cylindre + { } + case 33 : // il s agit d un disque issu d'un cylindre + { } + case 5 : // il s agit d un cylindre + { aZone->SetCylinder( _ZoneXcentre, _ZoneYcentre, _ZoneZcentre, _ZoneXaxis, _ZoneYaxis, _ZoneZaxis, _ZoneRayon, _ZoneHaut ); + break; + } + case 61 : // il s agit d un disque issu d'un cylindre + { } + case 62 : // il s agit d un disque issu d'un cylindre + { } + case 63 : // il s agit d un disque issu d'un cylindre + { } + case 7 : // il s agit d un tuyau + { aZone->SetPipe( _ZoneXcentre, _ZoneYcentre, _ZoneZcentre, _ZoneXaxis, _ZoneYaxis, _ZoneZaxis, _ZoneRayon, _ZoneHaut, _ZoneRayonInt ); + break; + } + } + if (Chgt) myAdaptGen->InvalideZone(_Name.toStdString().c_str()); + HOMARD_UTILS::updateObjBrowser(); + } + catch( const SALOME::SALOME_Exception& S_ex ) { + SalomeApp_Tools::QtCatchCorbaException( S_ex ); + return false; + } + return true; +} + diff --git a/src/ADAPTGUI/MonEditZone.h b/src/ADAPTGUI/MonEditZone.h new file mode 100644 index 000000000..c561f14d1 --- /dev/null +++ b/src/ADAPTGUI/MonEditZone.h @@ -0,0 +1,59 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_EDITZONE_H +#define MON_EDITZONE_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) + +#include + +class HOMARD_EXPORT MonEditZone : public MonCreateZone +{ + Q_OBJECT +public: + MonEditZone( MonCreateHypothesis* parent, bool modal, + ADAPT::ADAPT_Gen_var myAdaptGen, + QString caseName, QString Name); + virtual ~MonEditZone(); + +protected : + void SetBox(); + void SetSphere(); + void SetCylinder(); + void SetPipe(); + bool CreateOrUpdateZone(); + void InitValEdit(); + void InitValZoneLimit(); + void InitValZoneBox(); + void InitValZoneSphere(); + void InitValZoneCylinder(); + void InitValZonePipe(); + +public slots: + +}; + +#endif // MON_EDITZONE_H diff --git a/src/ADAPTGUI/MonIterInfo.cxx b/src/ADAPTGUI/MonIterInfo.cxx new file mode 100644 index 000000000..8d922f887 --- /dev/null +++ b/src/ADAPTGUI/MonIterInfo.cxx @@ -0,0 +1,175 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonIterInfo.h" + +#include +#include +#include +#include + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include "MonEditFile.h" +#include + +using namespace std; + +// ----------------------------------------------------------------------------------------- +MonIterInfo::MonIterInfo(QWidget* parent, bool modal, ADAPT::ADAPT_Gen_var myAdaptGen0, QString IterName) +// ----------------------------------------------------------------------------------------- +/* Constructs a MonIterInfo + * Inherits from CasHomard + * Sets attributes to default values + */ + : + Ui_IterInfo(), + _IterName(IterName), + _aCaseName(""), + _BlockSize(0), + _Connection(0), + _Diametre(0), + _Entanglement(0), + _Quality(0), + _Option(-1) +{ + MESSAGE("appel de _duplicate"); + myAdaptGen=ADAPT::ADAPT_Gen::_duplicate(myAdaptGen0); + setupUi(this); + setModal(modal); + InitConnect(); + + adjustSize(); +} + +// ------------------------------------------------------------------------ +MonIterInfo::~MonIterInfo() +// ------------------------------------------------------------------------ +{ + // no need to delete child widgets, Qt does it all for us +} +// ------------------------------------------------------------------------ +void MonIterInfo::InitConnect() +// ------------------------------------------------------------------------ +{ + MESSAGE("InitConnect"); + connect( CBBlockSize, SIGNAL(stateChanged(int)), this, SLOT(SetBlockSize())); + connect( CBConnection, SIGNAL(stateChanged(int)), this, SLOT(SetConnection())); + connect( CBDiametre, SIGNAL(stateChanged(int)), this, SLOT(SetDiametre())); + connect( CBEntanglement, SIGNAL(stateChanged(int)), this, SLOT(SetEntanglement())); + connect( CBQuality, SIGNAL(stateChanged(int)), this, SLOT(SetQuality())); + + connect( buttonOk, SIGNAL(pressed()), this, SLOT(PushOnOK())); + connect( buttonApply, SIGNAL(pressed()), this, SLOT(PushOnApply())); + connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close())); + connect( buttonHelp, SIGNAL(pressed()), this, SLOT(PushOnHelp())); +} +// ------------------------------- +bool MonIterInfo::PushOnApply() +// -------------------------------- +{ + MESSAGE("PushOnApply"); + + // Au moins une option a ete choisie + if ( ( _Quality == 0 ) && ( _Diametre == 0 ) && ( _Connection == 0 ) && ( _BlockSize == 0 ) && ( _Entanglement == 0 ) ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_MESH_INFO_1") ); + return false; + } + + // Recuperation de l'iteration + aIter = myAdaptGen->GetIteration(_IterName.toStdString().c_str()) ; + + // Lancement de l'analyse + try + { + aIter->MeshInfoOption( _Quality, _Diametre, _Connection, _BlockSize, _Entanglement, _Option ); + } + catch( SALOME::SALOME_Exception& S_ex ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr(CORBA::string_dup(S_ex.details.text)) ); + return false; + } + + // Le bilan de l'analyse a afficher + QString aFileName = aIter->GetFileInfo() ; + MonEditFile *aDlg = new MonEditFile( 0, true, ADAPT::ADAPT_Gen::_duplicate(myAdaptGen), aFileName, 0 ) ; + if ( aDlg->_codret == 0 ) { aDlg->show(); } + + + HOMARD_UTILS::updateObjBrowser(); + return true; +} +// --------------------------- +void MonIterInfo::PushOnOK() +// --------------------------- +{ + bool bOK = PushOnApply(); + if ( bOK ) this->close(); +} +//------------------------------ +void MonIterInfo::PushOnHelp() +//------------------------------- +{ + std::string LanguageShort = myAdaptGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_mesh_info.html"), QString(""), QString(LanguageShort.c_str())); +} +// ------------------------------------------------------------------------ +void MonIterInfo::SetBlockSize() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetBlockSize "); + if ( CBBlockSize->isChecked() ) { _BlockSize = 1 ; } + else { _BlockSize = 0 ; } +} +// ------------------------------------------------------------------------ +void MonIterInfo::SetConnection() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetConnection "); + if ( CBConnection->isChecked() ) { _Connection = 1 ; } + else { _Connection = 0 ; } +} +// ------------------------------------------------------------------------ +void MonIterInfo::SetDiametre() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetDiametre "); + if ( CBDiametre->isChecked() ) { _Diametre = 1 ; } + else { _Diametre = 0 ; } +} +// ------------------------------------------------------------------------ +void MonIterInfo::SetEntanglement() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetEntanglement "); + if ( CBEntanglement->isChecked() ) { _Entanglement = 1 ; } + else { _Entanglement = 0 ; } +} +// ------------------------------------------------------------------------ +void MonIterInfo::SetQuality() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetQuality "); + if ( CBQuality->isChecked() ) { _Quality = 1 ; } + else { _Quality = 0 ; } +} diff --git a/src/ADAPTGUI/MonIterInfo.h b/src/ADAPTGUI/MonIterInfo.h new file mode 100644 index 000000000..8627efbd4 --- /dev/null +++ b/src/ADAPTGUI/MonIterInfo.h @@ -0,0 +1,78 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_ITERINFO_H +#define MON_ITERINFO_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) +#include CORBA_CLIENT_HEADER(HOMARD_Cas) + +#include "ui_IterInfo.h" +#include +#include + +class QListBox; + +class HOMARD_EXPORT MonIterInfo : public QDialog, public Ui_IterInfo +{ + Q_OBJECT + +public: + MonIterInfo( QWidget* parent, bool modal, ADAPT::ADAPT_Gen_var myAdaptGen, QString IterName); + ~MonIterInfo(); + +protected : + MonIterInfo( QWidget* parent, ADAPT::ADAPT_Gen_var myAdaptGen, QString IterName ); + + QString _IterName; + QString _aCaseName; + + int _BlockSize; + int _Connection; + int _Diametre; + int _Entanglement; + int _Quality; + int _Option; + + ADAPT::HOMARD_Iteration_var aIter ; + ADAPT::ADAPT_Gen_var myAdaptGen; + + virtual void InitConnect(); + +public slots: + + virtual void SetBlockSize(); + virtual void SetConnection(); + virtual void SetEntanglement(); + virtual void SetDiametre(); + virtual void SetQuality(); + + virtual void PushOnOK(); + virtual bool PushOnApply(); + virtual void PushOnHelp(); + +}; + +#endif // MON_ITERINFO_H diff --git a/src/ADAPTGUI/MonMeshInfo.cxx b/src/ADAPTGUI/MonMeshInfo.cxx new file mode 100644 index 000000000..3589c5f9a --- /dev/null +++ b/src/ADAPTGUI/MonMeshInfo.cxx @@ -0,0 +1,281 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonMeshInfo.h" +#include "HOMARD.hxx" + +#include +#include + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include "MonEditFile.h" +#include + +#ifdef WIN32 +#include +#endif + +using namespace std; + +// ----------------------------------------------------------------------------------------- +MonMeshInfo::MonMeshInfo(QWidget* parent, bool modal, ADAPT::ADAPT_Gen_var myAdaptGen0) +// ----------------------------------------------------------------------------------------- +/* Constructs a MonMeshInfo + * Inherits from CasHomard + * Sets attributes to default values + */ + : + Ui_MeshInfo(), + _aCaseName(""),_aDirName(""), + _BlockSize(0), + _Connection(0), + _Diametre(0), + _Entanglement(0), + _Quality(0) +{ + myAdaptGen=ADAPT::ADAPT_Gen::_duplicate(myAdaptGen0); + setupUi(this); + setModal(modal); + InitConnect(); + + SetNewCaseName() ; + adjustSize(); +} + +// ------------------------------------------------------------------------ +MonMeshInfo::~MonMeshInfo() +// ------------------------------------------------------------------------ +{ + // no need to delete child widgets, Qt does it all for us +} +// ------------------------------------------------------------------------ +void MonMeshInfo::InitConnect() +// ------------------------------------------------------------------------ +{ + connect( LECaseName, SIGNAL(textChanged(QString)), this, SLOT(CaseNameChanged())); + connect( PushDir, SIGNAL(pressed()), this, SLOT(SetDirName())); + connect( PushFichier, SIGNAL(pressed()), this, SLOT(SetFileName())); + + connect( CBBlockSize, SIGNAL(stateChanged(int)), this, SLOT(SetBlockSize())); + connect( CBConnection, SIGNAL(stateChanged(int)), this, SLOT(SetConnection())); + connect( CBDiametre, SIGNAL(stateChanged(int)), this, SLOT(SetDiametre())); + connect( CBEntanglement, SIGNAL(stateChanged(int)), this, SLOT(SetEntanglement())); + connect( CBQuality, SIGNAL(stateChanged(int)), this, SLOT(SetQuality())); + + connect( buttonOk, SIGNAL(pressed()), this, SLOT(PushOnOK())); + connect( buttonApply, SIGNAL(pressed()), this, SLOT(PushOnApply())); + connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close())); + connect( buttonHelp, SIGNAL(pressed()), this, SLOT(PushOnHelp())); +} +// ------------------------------- +bool MonMeshInfo::PushOnApply() +// -------------------------------- +{ + MESSAGE("PushOnApply"); + QString aCaseName=LECaseName->text().trimmed(); + if ( aCaseName == "" ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_CASE_NAME") ); + return false; + } + + QString aDirName=LEDirName->text().trimmed(); + if (aDirName == QString("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_CASE_DIRECTORY_1") ); + return false; + } + if ( aDirName != _aDirName) + { QString CaseNameDir = myAdaptGen->VerifieDir( aDirName.toStdString().c_str()) ; + if ( CaseNameDir != "" ) + { + QString texte ; + texte = QObject::tr("HOM_CASE_DIRECTORY_2") + CaseNameDir ; + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + texte ); + return false; + } + } + if (CHDIR(aDirName.toStdString().c_str()) != 0) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_CASE_DIRECTORY_3") ); + return false; + } + + QString aFileName=LEFileName->text().trimmed(); + if (aFileName ==QString("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_CASE_MESH") ); + return false; + } + + QString aMeshName = HOMARD_QT_COMMUN::LireNomMaillage(aFileName); + if (aMeshName == "" ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_MED_FILE_2") ); + return false; + } + if ( ( _Quality == 0 ) && ( _Diametre == 0 ) && ( _Connection == 0 ) && ( _BlockSize == 0 ) && ( _Entanglement == 0 ) ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_MESH_INFO") ); + return false; + } + + if (aCaseName != _aCaseName ) + { + _aCaseName = aCaseName; + try + { + myAdaptGen->MeshInfo( \ + CORBA::string_dup(_aCaseName.toStdString().c_str()), \ + CORBA::string_dup(aMeshName.toStdString().c_str()), \ + CORBA::string_dup(aFileName.toStdString().c_str()), \ + CORBA::string_dup(aDirName.toStdString().c_str()), \ + _Quality, _Diametre, _Connection, _BlockSize, _Entanglement ); + } + catch( SALOME::SALOME_Exception& S_ex ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr(CORBA::string_dup(S_ex.details.text)) ); + return false; + } + } + + // Le bilan de l'analyse a afficher + aCase = myAdaptGen->GetCase(_aCaseName.toStdString().c_str()); + string iter0 = aCase->GetIter0Name(); + ADAPT::HOMARD_Iteration_var aIter = myAdaptGen->GetIteration(iter0.c_str()); + aFileName = aIter->GetFileInfo() ; + MonEditFile *aDlg = new MonEditFile( 0, true, ADAPT::ADAPT_Gen::_duplicate(myAdaptGen), aFileName, 1 ) ; + if ( aDlg->_codret == 0 ) { aDlg->show(); } + +HOMARD_UTILS::updateObjBrowser(); + return true; +} +// --------------------------- +void MonMeshInfo::PushOnOK() +// --------------------------- +{ + bool bOK = PushOnApply(); + if ( bOK ) this->close(); +} +//------------------------------ +void MonMeshInfo::PushOnHelp() +//------------------------------- +{ + std::string LanguageShort = myAdaptGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_case.html"), QString(""), QString(LanguageShort.c_str())); +} +// --------------------------------- +void MonMeshInfo::SetNewCaseName() +// ------------------------------ +{ + ADAPT::listeCases_var MyCases = myAdaptGen->GetAllCasesName(); + int num = 0; QString aCaseName=""; + while (aCaseName=="" ) + { + aCaseName.setNum(num+1) ; + aCaseName.insert(0, QString("Case_")) ; + for ( int i=0; ilength(); i++) + { + if ( aCaseName == QString((MyCases)[i]) ) + { + num ++ ; + aCaseName = "" ; + break ; + } + } + } + LECaseName->clear() ; + LECaseName->insert(aCaseName); +} +// ------------------------------------------------------------------------ +void MonMeshInfo::SetDirName() +// ------------------------------------------------------------------------ +{ + QString aDirName=QFileDialog::getExistingDirectory (); + if (!(aDirName.isEmpty()))LEDirName->setText(aDirName); +} +// ------------------------------------------------------------------------ +void MonMeshInfo::SetFileName() +// ------------------------------------------------------------------------ +{ + QString fileName0 = LEFileName->text().trimmed(); + QString fileName = HOMARD_QT_COMMUN::PushNomFichier( false, QString("med") ) ; + if (fileName.isEmpty()) fileName = fileName0 ; + LEFileName->setText(fileName); +} +// ------------------------------------------------------------------------ +void MonMeshInfo::CaseNameChanged() +// ------------------------------------------------------------------------ +{ + if (_aCaseName != LECaseName->text().trimmed()) + { + LEFileName->setReadOnly(false); + PushFichier->show(); + } +} +// ------------------------------------------------------------------------ +void MonMeshInfo::SetBlockSize() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetBlockSize "); + if ( CBBlockSize->isChecked() ) { _BlockSize = 1 ; } + else { _BlockSize = 0 ; } +} +// ------------------------------------------------------------------------ +void MonMeshInfo::SetConnection() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetConnection "); + if ( CBConnection->isChecked() ) { _Connection = 1 ; } + else { _Connection = 0 ; } +} +// ------------------------------------------------------------------------ +void MonMeshInfo::SetDiametre() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetDiametre "); + if ( CBDiametre->isChecked() ) { _Diametre = 1 ; } + else { _Diametre = 0 ; } +} +// ------------------------------------------------------------------------ +void MonMeshInfo::SetEntanglement() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetEntanglement "); + if ( CBEntanglement->isChecked() ) { _Entanglement = 1 ; } + else { _Entanglement = 0 ; } +} +// ------------------------------------------------------------------------ +void MonMeshInfo::SetQuality() +// ------------------------------------------------------------------------ +{ + MESSAGE("Debut de SetQuality "); + if ( CBQuality->isChecked() ) { _Quality = 1 ; } + else { _Quality = 0 ; } +} diff --git a/src/ADAPTGUI/MonMeshInfo.h b/src/ADAPTGUI/MonMeshInfo.h new file mode 100644 index 000000000..ec29de706 --- /dev/null +++ b/src/ADAPTGUI/MonMeshInfo.h @@ -0,0 +1,76 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_MESHINFO_H +#define MON_MESHINFO_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) +#include CORBA_CLIENT_HEADER(HOMARD_Cas) + +#include "ui_MeshInfo.h" +#include + +class HOMARD_EXPORT MonMeshInfo : public QDialog, public Ui_MeshInfo +{ + Q_OBJECT + +public: + MonMeshInfo( QWidget* parent, bool modal, ADAPT::ADAPT_Gen_var myAdaptGen); + ~MonMeshInfo(); + +protected : + QString _aCaseName; + QString _aDirName; + + int _BlockSize; + int _Connection; + int _Diametre; + int _Entanglement; + int _Quality; + + ADAPT::HOMARD_Cas_var aCase ; + ADAPT::ADAPT_Gen_var myAdaptGen; + + virtual void InitConnect(); + virtual void SetNewCaseName(); + +public slots: + virtual void SetDirName(); + virtual void SetFileName(); + + virtual void SetBlockSize(); + virtual void SetConnection(); + virtual void SetEntanglement(); + virtual void SetDiametre(); + virtual void SetQuality(); + + virtual void PushOnOK(); + virtual bool PushOnApply(); + virtual void PushOnHelp(); + + virtual void CaseNameChanged(); +}; + +#endif // MON_MESHINFO_H diff --git a/src/ADAPTGUI/MonPursueIteration.cxx b/src/ADAPTGUI/MonPursueIteration.cxx new file mode 100644 index 000000000..ebecd5fa6 --- /dev/null +++ b/src/ADAPTGUI/MonPursueIteration.cxx @@ -0,0 +1,288 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MonPursueIteration.h" +#include "HOMARD.hxx" + +#include +#include + +#include "SalomeApp_Tools.h" +#include "HOMARDGUI_Utils.h" +#include "HomardQtCommun.h" +#include + +#ifdef WIN32 +#include +#endif + +using namespace std; + +// ----------------------------------------------------------------------------------------- +/* Constructs a MonPursueIteration + * Sets attributes to default values + */ +// ----------------------------------------------------------------------------------------- +MonPursueIteration::MonPursueIteration ( bool modal, ADAPT::ADAPT_Gen_var myAdaptGen0 ) + : + Ui_PursueIteration(), + _aCaseName(""), _aDirName(""), _aDirNameStart("") +{ + MESSAGE("Debut du constructeur de MonPursueIteration"); + myAdaptGen=ADAPT::ADAPT_Gen::_duplicate(myAdaptGen0); + setupUi(this); + setModal(modal); + + InitConnect(); + + SetNewCaseName() ; + _Type = 1 ; + GBIterationintoCase->setVisible(0); + SpinBoxNumber->setVisible(0); + + adjustSize(); + MESSAGE("Fin du constructeur de MonPursueIteration"); +} + +// ------------------------------------------------------------------------ +MonPursueIteration::~MonPursueIteration() +// ------------------------------------------------------------------------ +{ + // no need to delete child widgets, Qt does it all for us +} +// ------------------------------------------------------------------------ +void MonPursueIteration::InitConnect() +// ------------------------------------------------------------------------ +{ + connect( PushDir, SIGNAL(pressed()), this, SLOT(SetDirName())); + + connect( RBIteration, SIGNAL(clicked()), this, SLOT(FromIteration())); + connect( RBCase, SIGNAL(clicked()), this, SLOT(FromCase())); + connect( PushDirStart, SIGNAL(pressed()), this, SLOT(SetDirNameStart())); + + connect( RBCaseLastIteration, SIGNAL(clicked()), this, SLOT(CaseLastIteration())); + connect( RBCaseNIteration, SIGNAL(clicked()), this, SLOT(CaseNIteration())); + + connect( buttonOk, SIGNAL(pressed()), this, SLOT(PushOnOK())); + connect( buttonApply, SIGNAL(pressed()), this, SLOT(PushOnApply())); + connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close())); + connect( buttonHelp, SIGNAL(pressed()), this, SLOT(PushOnHelp())); +} +// ------------------------------- +bool MonPursueIteration::PushOnApply() +// -------------------------------- +{ + MESSAGE("PushOnApply"); +// 1. Enregistrement du repertoire du cas + QString aDirName=LEDirName->text().trimmed(); + if (aDirName == QString("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_CASE_DIRECTORY_1") ); + return false; + } + if ( aDirName != _aDirName) + { QString CaseNameDir = myAdaptGen->VerifieDir( aDirName.toStdString().c_str()) ; + if ( CaseNameDir != "" ) + { + QString texte ; + texte = QObject::tr("HOM_CASE_DIRECTORY_2") + CaseNameDir ; + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + texte ); + return false; + } + } + if (CHDIR(aDirName.toStdString().c_str()) != 0) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_CASE_DIRECTORY_3") ); + return false; + } +// 2. Enregistrement du repertoire de depart + QString aDirNameStart=LEDirNameStart->text().trimmed(); + if (aDirNameStart == QString("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_START_DIRECTORY_1") ); + return false; + } + if (CHDIR(aDirNameStart.toStdString().c_str()) != 0) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_START_DIRECTORY_3") ); + return false; + } + +// 3. Enregistrement du numero d'iteration + int Number ; + if ( _Type == 3 ) { Number = SpinBoxNumber->value() ; } + +// 4. Creation du cas + QString _aCaseName=LECaseName->text().trimmed(); + _aDirNameStart=aDirNameStart; + + MESSAGE("_aCaseName = "<<_aCaseName.toStdString().c_str()); + MESSAGE("_aDirNameStart = "<<_aDirNameStart.toStdString().c_str()); + MESSAGE("_Type = "<<_Type); + switch (_Type) + { + case 1 : // Poursuite a partir d'une iteration + { + try + { + MESSAGE("Poursuite a partir d'une iteration"); + aCase = myAdaptGen->CreateCaseFromIteration( \ + CORBA::string_dup(_aCaseName.toStdString().c_str()), \ + CORBA::string_dup(_aDirNameStart.toStdString().c_str()) ); + } + catch( SALOME::SALOME_Exception& S_ex ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr(CORBA::string_dup(S_ex.details.text)) ); + return false ; + } + break; + } + case 2 : // Poursuite a partir de la derniere iteration dans un cas + { + try + { + MESSAGE("Poursuite a partir de la derniere iteration dans un cas"); + aCase = myAdaptGen->CreateCaseFromCaseLastIteration( \ + CORBA::string_dup(_aCaseName.toStdString().c_str()), \ + CORBA::string_dup(_aDirNameStart.toStdString().c_str()) ); + } + catch( SALOME::SALOME_Exception& S_ex ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr(CORBA::string_dup(S_ex.details.text)) ); + return false ; + } + break; + } + case 3 : // Poursuite a partir d'une iteration dans un cas + { + try + { + MESSAGE("Poursuite a partir d'une iteration dans un cas"); + aCase = myAdaptGen->CreateCaseFromCaseIteration( \ + CORBA::string_dup(_aCaseName.toStdString().c_str()), \ + CORBA::string_dup(_aDirNameStart.toStdString().c_str()), \ + Number ); + } + catch( SALOME::SALOME_Exception& S_ex ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr(CORBA::string_dup(S_ex.details.text)) ); + return false ; + } + break; + } + } + + aCase->SetDirName(aDirName.toStdString().c_str()); + _aDirName=aDirName; + + HOMARD_UTILS::updateObjBrowser(); + + return true; +} +// --------------------------- +void MonPursueIteration::PushOnOK() +// --------------------------- +{ + bool bOK = PushOnApply(); + if ( bOK ) this->close(); +} +//------------------------------ +void MonPursueIteration::PushOnHelp() +//------------------------------- +{ + std::string LanguageShort = myAdaptGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_case.html"), QString(""), QString(LanguageShort.c_str())); +} +// --------------------------------- +void MonPursueIteration::SetNewCaseName() +// ------------------------------ +{ + ADAPT::listeCases_var MyCases = myAdaptGen->GetAllCasesName(); + int num = 0; QString aCaseName=""; + while (aCaseName=="" ) + { + aCaseName.setNum(num+1) ; + aCaseName.insert(0, QString("Case_")) ; + for ( int i=0; ilength(); i++) + { + if ( aCaseName == QString((MyCases)[i])) + { + num ++ ; + aCaseName = "" ; + break ; + } + } + } + LECaseName->clear() ; + LECaseName->insert(aCaseName); +} +// ------------------------------------------------------------------------ +void MonPursueIteration::SetDirName() +// ------------------------------------------------------------------------ +{ + QString aDirName=QFileDialog::getExistingDirectory (); + if (!(aDirName.isEmpty()))LEDirName->setText(aDirName); +} +// ------------------------------------------------------------------------ +void MonPursueIteration::SetDirNameStart() +// ------------------------------------------------------------------------ +{ + QString aDirName=QFileDialog::getExistingDirectory (); + if (!(aDirName.isEmpty()))LEDirNameStart->setText(aDirName); +} +// ------------------------------------------------------------------------ +void MonPursueIteration::FromIteration() +// ------------------------------------------------------------------------ +{ + GBIterationintoCase->setVisible(0); + SpinBoxNumber->setVisible(0); + _Type = 1 ; + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonPursueIteration::FromCase() +// ------------------------------------------------------------------------ +{ + GBIterationintoCase->setVisible(1); + CaseLastIteration(); +} +// ------------------------------------------------------------------------ +void MonPursueIteration::CaseLastIteration() +// ------------------------------------------------------------------------ +{ + SpinBoxNumber->setVisible(0); + _Type = 2 ; + adjustSize(); +} +// ------------------------------------------------------------------------ +void MonPursueIteration::CaseNIteration() +// ------------------------------------------------------------------------ +{ + SpinBoxNumber->setVisible(1); + _Type = 3 ; + adjustSize(); +} diff --git a/src/ADAPTGUI/MonPursueIteration.h b/src/ADAPTGUI/MonPursueIteration.h new file mode 100644 index 000000000..00dd62015 --- /dev/null +++ b/src/ADAPTGUI/MonPursueIteration.h @@ -0,0 +1,72 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef MON_PURSUEITERATION_H +#define MON_PURSUEITERATION_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include CORBA_CLIENT_HEADER(ADAPT_Gen) +#include CORBA_CLIENT_HEADER(HOMARD_Cas) + +#include "ui_PursueIteration.h" +#include + +class HOMARD_EXPORT MonPursueIteration : public QDialog, public Ui_PursueIteration +{ + Q_OBJECT + + public: + MonPursueIteration( bool modal, ADAPT::ADAPT_Gen_var myAdaptGen ); + virtual ~MonPursueIteration(); + + protected : + QString _aCaseName; + QString _aDirName; + QString _aDirNameStart; + + int _Type ; + + ADAPT::HOMARD_Cas_var aCase ; + ADAPT::ADAPT_Gen_var myAdaptGen; + + virtual void InitConnect(); + virtual void SetNewCaseName(); + + public slots: + virtual void SetDirName(); + + virtual void FromIteration(); + virtual void FromCase(); + virtual void SetDirNameStart(); + + virtual void CaseLastIteration(); + virtual void CaseNIteration(); + + virtual void PushOnOK(); + virtual bool PushOnApply(); + virtual void PushOnHelp(); + +}; + +#endif // MON_PURSUEITERATION_H diff --git a/src/ADAPTGUI/PursueIteration.ui b/src/ADAPTGUI/PursueIteration.ui new file mode 100644 index 000000000..ad3de2352 --- /dev/null +++ b/src/ADAPTGUI/PursueIteration.ui @@ -0,0 +1,252 @@ + + + PursueIteration + + + + 0 + 0 + 601 + 300 + + + + + 0 + 0 + + + + Pursue an iteration + + + true + + + + + + 6 + + + 0 + + + + + Name + + + + + + + + 382 + 21 + + + + + + + + + + 6 + + + 0 + + + + + Directory + + + + + + + + + + false + + + + + + + + 382 + 21 + + + + + + + + + + From an iteration + + + true + + + + + + + From a case + + + + + + + 6 + + + 0 + + + + + Directory + + + + + + + + + + false + + + + + + + + 382 + 21 + + + + + + + + + + Iteration into the case + + + + + + Last iteration + + + true + + + + + + + Iteration number + + + + + + + 1789 + + + + + + + + + + + + + + 9 + + + 6 + + + + + Help + + + false + + + + + + + Apply + + + false + + + + + + + OK + + + false + + + + + + + Cancel + + + false + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 128 + 25 + + + + + + + + + diff --git a/src/ADAPT_I/ADAPT_Gen_i.cxx b/src/ADAPT_I/ADAPT_Gen_i.cxx new file mode 100644 index 000000000..eb58aeee3 --- /dev/null +++ b/src/ADAPT_I/ADAPT_Gen_i.cxx @@ -0,0 +1,5432 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "ADAPT_Gen_i.hxx" +#include "HOMARD_Cas_i.hxx" +#include "HOMARD_Hypothesis_i.hxx" +#include "HOMARD_Iteration_i.hxx" +#include "HOMARD_Boundary_i.hxx" +#include "HOMARD_Zone_i.hxx" +#include "HOMARD_YACS_i.hxx" +#include "HomardDriver.hxx" +#include "HOMARD_DriverTools.hxx" +#include "HomardMedCommun.h" +#include "YACSDriver.hxx" +#include "HOMARD.hxx" + +#include "FrontTrack.hxx" + +#include "SMESH_version.h" + +#include "utilities.h" +#include "Basics_Utils.hxx" +#include "Basics_DirUtils.hxx" +#include "Utils_SINGLETON.hxx" +#include "Utils_CorbaException.hxx" +#include "SALOMEDS_Tool.hxx" +#include "SALOME_LifeCycleCORBA.hxx" +#include "SALOMEconfig.h" +#include +#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog) +#include CORBA_CLIENT_HEADER(SMESH_Gen) + +#include +#include +#include +#ifndef WIN32 +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef WIN32 +#include +#endif + +using namespace std; + +//============================================================================= +//functions +//============================================================================= +std::string RemoveTabulation( std::string theScript ) +{ + std::string::size_type aPos = 0; + while( aPos < theScript.length() ) + { + aPos = theScript.find( "\n\t", aPos ); + if( aPos == std::string::npos ) + break; + theScript.replace( aPos, 2, "\n" ); + aPos++; + } + return theScript; +} +//============================================================================= +/*! + * standard constructor + */ +//============================================================================= +ADAPT_Gen_i::ADAPT_Gen_i( CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) : +Engines_Component_i(orb, poa, contId, instanceName, interfaceName) +{ + MESSAGE("constructor"); + _thisObj = this; + _id = _poa->activate_object(_thisObj); + + myHomard = new ::ADAPT_Gen(); + _NS = SINGLETON_::Instance(); + ASSERT(SINGLETON_::IsAlreadyExisting()); + _NS->init_orb(_orb); + + myStudy = SALOMEDS::Study::_duplicate( SMESH_Gen_i::getStudyServant() ); + + _tag_gene = 0 ; + _tag_boun = 0 ; + _tag_hypo = 0 ; + _tag_yacs = 0 ; + _tag_zone = 0 ; + + SetPreferences( ) ; +} +//================================= +/*! + * standard destructor + */ +//================================ +ADAPT_Gen_i::~ADAPT_Gen_i() +{ +} +//============================================================================= +//============================================================================= +// Utilitaires pour l'étude +//============================================================================= +//============================================================================= +void ADAPT_Gen_i::UpdateStudy() +{ + ASSERT(!CORBA::is_nil(myStudy)); + SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder(); + + // Create SComponent labelled 'homard' if it doesn't already exit + SALOMEDS::SComponent_var homardFather = myStudy->FindComponent(ComponentDataType()); + if (CORBA::is_nil(homardFather)) + { + myBuilder->NewCommand(); + MESSAGE("Add Component HOMARD"); + + bool aLocked = myStudy->GetProperties()->IsLocked(); + if (aLocked) myStudy->GetProperties()->SetLocked(false); + + homardFather = myBuilder->NewComponent(ComponentDataType()); + SALOMEDS::GenericAttribute_var anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributeName"); + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + CORBA::Object_var objVarN = _NS->Resolve("/Kernel/ModulCatalog"); + SALOME_ModuleCatalog::ModuleCatalog_var Catalogue = + SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN); + SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent(ComponentDataType()); + if (!Comp->_is_nil()) + { + aName->SetValue(ComponentDataType()); + } + + anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributePixMap"); + SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap("HOMARD_2.png"); + myBuilder->DefineComponentInstance(homardFather, ADAPT_Gen::_this()); + + if (aLocked) myStudy->GetProperties()->SetLocked(true); + myBuilder->CommitCommand(); + } +} + +//============================================================================= +//============================================================================= +// Utilitaires pour l'iteration +//============================================================================= +//============================================================================= +void ADAPT_Gen_i::SetEtatIter(const char* nomIter, const CORBA::Long Etat) +//===================================================================================== +{ + MESSAGE( "SetEtatIter : affectation de l'etat " << Etat << " a l'iteration " << nomIter ); + ADAPT::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter]; + if (CORBA::is_nil(myIteration)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid iteration"; + throw SALOME::SALOME_Exception(es); + return ; + }; + + myIteration->SetState(Etat); + + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration))); + + std::string icone ; + if ( Etat <= 0 ) + icone = "iter0.png" ; + else if ( Etat == 2 ) + icone = "iter_calculee.png" ; + else + icone = "iter_non_calculee.png" ; + PublishInStudyAttr(aStudyBuilder, aIterSO, NULL , NULL, icone.c_str(), NULL) ; + + aStudyBuilder->CommitCommand(); + +} +//============================================================================= +//============================================================================= +// +//============================================================================= +//============================================================================= +// Destruction des structures identifiees par leurs noms +//============================================================================= +//============================================================================= +CORBA::Long ADAPT_Gen_i::DeleteBoundary(const char* BoundaryName) +{ + MESSAGE ( "DeleteBoundary : BoundaryName = " << BoundaryName ); + ADAPT::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName]; + if (CORBA::is_nil(myBoundary)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid boundary"; + throw SALOME::SALOME_Exception(es); + return 1 ; + }; + +// On verifie que la frontiere n'est plus utilisee + ADAPT::listeCases* maListe = GetAllCasesName(); + int numberOfCases = maListe->length(); + MESSAGE ( ".. Nombre de cas = " << numberOfCases ); + std::string CaseName ; + ADAPT::ListBoundaryGroupType* ListBoundaryGroupType ; + int numberOfitems ; + ADAPT::HOMARD_Cas_var myCase ; + for (int NumeCas = 0; NumeCas< numberOfCases; NumeCas++) + { + CaseName = std::string((*maListe)[NumeCas]); + MESSAGE ( "... Examen du cas = " << CaseName.c_str() ); + myCase = myStudyContext._mesCas[CaseName]; + ASSERT(!CORBA::is_nil(myCase)); + ListBoundaryGroupType = myCase->GetBoundaryGroup(); + numberOfitems = ListBoundaryGroupType->length(); + MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems); + for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2) + { + if ( std::string((*ListBoundaryGroupType)[NumBoundary]) == BoundaryName ) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "This boundary is used in a case and cannot be deleted."; + throw SALOME::SALOME_Exception(es); + return 2 ; + }; + }; + } + + // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete + myStudyContext._mesBoundarys.erase(BoundaryName); + SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(BoundaryName, ComponentDataType()); + SALOMEDS::SObject_var aSO =listSO[0]; + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + myStudy->NewBuilder()->RemoveObjectWithChildren(aSO); + + return 0 ; +} +//============================================================================= +CORBA::Long ADAPT_Gen_i::DeleteCase(const char* nomCas, CORBA::Long Option) +{ + // Pour detruire un cas + MESSAGE ( "DeleteCase : nomCas = " << nomCas << ", avec option = " << Option ); + ADAPT::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas]; + if (CORBA::is_nil(myCase)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid case context"; + throw SALOME::SALOME_Exception(es); + return 1; + }; + // On commence par detruire toutes les iterations en partant de l'initiale et y compris elle + CORBA::String_var nomIter = myCase->GetIter0Name(); + CORBA::Long Option1 = 0 ; + if ( DeleteIterationOption(nomIter, Option1, Option) != 0 ) + { + return 2; + }; + + // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete + myStudyContext._mesCas.erase(nomCas); + SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomCas, ComponentDataType()); + SALOMEDS::SObject_var aSO =listSO[0]; + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + myStudy->NewBuilder()->RemoveObjectWithChildren(aSO); + + return 0 ; +} +//============================================================================= +CORBA::Long ADAPT_Gen_i::DeleteHypo(const char* nomHypo) +{ + MESSAGE ( "DeleteHypo : nomHypo = " << nomHypo ); + ADAPT::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo]; + if (CORBA::is_nil(myHypo)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid hypothesis"; + throw SALOME::SALOME_Exception(es); + return 1 ; + }; + +// On verifie que l'hypothese n'est plus utilisee + ADAPT::listeIters* maListeIter = myHypo->GetIterations(); + int numberOfIter = maListeIter->length(); + if ( numberOfIter > 0 ) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "This hypothesis is used in an iteration and cannot be deleted."; + throw SALOME::SALOME_Exception(es); + return 2 ; + }; + + // suppression du lien avec les zones eventuelles + ADAPT::listeZonesHypo* maListe = myHypo->GetZones(); + int numberOfZones = maListe->length(); + MESSAGE ( ".. Nombre de zones = " << numberOfZones ); + for (int NumeZone = 0; NumeZone< numberOfZones; NumeZone++) + { + std::string ZoneName = std::string((*maListe)[NumeZone]); + MESSAGE ( ".. suppression du lien avec la zone = " << ZoneName.c_str() ); + DissociateHypoZone(nomHypo, ZoneName.c_str()) ; + NumeZone += 1 ; + } + + // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete + myStudyContext._mesHypotheses.erase(nomHypo); + SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomHypo, ComponentDataType()); + SALOMEDS::SObject_var aSO =listSO[0]; + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + myStudy->NewBuilder()->RemoveObjectWithChildren(aSO); + + return 0 ; +} +//============================================================================= +CORBA::Long ADAPT_Gen_i::DeleteIteration(const char* nomIter, CORBA::Long Option) +{ + // Option = 0 : On ne supprime pas le fichier du maillage associe + // Option = 1 : On supprime le fichier du maillage associe + // Pour detruire une iteration courante + MESSAGE ( "DeleteIteration : nomIter = " << nomIter << ", avec option = " << Option ); + CORBA::Long Option1 = 1 ; + return DeleteIterationOption(nomIter, Option1, Option); +} +//============================================================================= +CORBA::Long ADAPT_Gen_i::DeleteIterationOption(const char* nomIter, CORBA::Long Option1, CORBA::Long Option2) +{ + // Option1 = 0 : On autorise la destruction de l'iteration 0 + // Option1 = 1 : On interdit la destruction de l'iteration 0 + + // Option2 = 0 : On ne supprime pas le fichier du maillage associe + // Option2 = 1 : On supprime le fichier du maillage associe + MESSAGE ( "DeleteIterationOption : nomIter = " << nomIter << ", avec options = " << Option1<< ", " << Option2 ); + ADAPT::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter]; + if (CORBA::is_nil(myIteration)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid iteration"; + throw SALOME::SALOME_Exception(es); + return 1 ; + }; + + int numero = myIteration->GetNumber(); + MESSAGE ( "DeleteIterationOption : numero = " << numero ); + if ( numero == 0 && Option1 == 1 ) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "This iteration cannot be deleted."; + throw SALOME::SALOME_Exception(es); + return 2 ; + }; + + // On detruit recursivement toutes les filles + ADAPT::listeIterFilles* maListe = myIteration->GetIterations(); + int numberOfIter = maListe->length(); + for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++) + { + std::string nomIterFille = std::string((*maListe)[NumeIter]); + MESSAGE ( ".. appel recursif de DeleteIterationOption pour nomIter = " << nomIterFille.c_str() ); + DeleteIterationOption(nomIterFille.c_str(), Option1, Option2); + } + + // On arrive ici pour une iteration sans fille + MESSAGE ( "Destruction effective de " << nomIter ); + // On commence par invalider l'iteration pour faire le menage des dependances + // et eventuellement du maillage associe + int option ; + if ( numero == 0 ) { option = 0 ; } + else { option = Option2 ; } + InvalideIterOption(nomIter, option) ; + + // Retrait dans la descendance de l'iteration parent + if ( numero > 0 ) + { + std::string nomIterationParent = myIteration->GetIterParentName(); + MESSAGE ( "Retrait dans la descendance de nomIterationParent " << nomIterationParent ); + ADAPT::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterationParent]; + if (CORBA::is_nil(myIterationParent)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid iteration"; + throw SALOME::SALOME_Exception(es); + return 3 ; + }; + myIterationParent->UnLinkNextIteration(nomIter); + } + + // suppression du lien avec l'hypothese + if ( numero > 0 ) + { + std::string nomHypo = myIteration->GetHypoName(); + ADAPT::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo]; + ASSERT(!CORBA::is_nil(myHypo)); + myHypo->UnLinkIteration(nomIter); + } + + // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete + myStudyContext._mesIterations.erase(nomIter); + SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomIter, ComponentDataType()); + SALOMEDS::SObject_var aSO =listSO[0]; + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + myStudy->NewBuilder()->RemoveObjectWithChildren(aSO); + // on peut aussi faire RemoveObject +// MESSAGE ( "Au final" ); +// ADAPT::listeIterations* Liste = GetAllIterationsName() ; +// numberOfIter = Liste->length(); +// for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++) +// { +// std::string nomIterFille = std::string((*Liste)[NumeIter]); +// MESSAGE ( ".. nomIter = " << nomIterFille.c_str() ); +// } + + return 0 ; +} +//============================================================================= +CORBA::Long ADAPT_Gen_i::DeleteYACS(const char* nomYACS, CORBA::Long Option) +{ + // Option = 0 : On ne supprime pas le fichier du schema associe + // Option = 1 : On supprime le fichier du schema associe + MESSAGE ( "DeleteYACS : nomYACS = " << nomYACS << ", avec option = " << Option ); + ADAPT::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS]; + if (CORBA::is_nil(myYACS)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid schema YACS"; + throw SALOME::SALOME_Exception(es); + return 1 ; + }; + // Suppression eventuelle du fichier XML + if ( Option == 1 ) + { + std::string nomFichier = myYACS->GetXMLFile(); + std::string commande = "rm -rf " + nomFichier ; + MESSAGE ( "commande = " << commande ); + if ((system(commande.c_str())) != 0) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "The xml file for the schema YACS cannot be removed." ; + throw SALOME::SALOME_Exception(es); + return 2 ; + } + } + // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete + myStudyContext._mesYACSs.erase(nomYACS); + SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomYACS, ComponentDataType()); + SALOMEDS::SObject_var aSO =listSO[0]; + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + myStudy->NewBuilder()->RemoveObjectWithChildren(aSO); + + return 0 ; +} +//============================================================================= +CORBA::Long ADAPT_Gen_i::DeleteZone(const char* nomZone) +{ + MESSAGE ( "DeleteZone : nomZone = " << nomZone ); + ADAPT::HOMARD_Zone_var myZone = myStudyContext._mesZones[nomZone]; + if (CORBA::is_nil(myZone)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid zone"; + throw SALOME::SALOME_Exception(es); + return 1 ; + }; + +// On verifie que la zone n'est plus utilisee + ADAPT::listeHypo* maListe = myZone->GetHypo(); + int numberOfHypo = maListe->length(); + MESSAGE ( ".. Nombre d'hypotheses = " << numberOfHypo ); + if ( numberOfHypo > 0 ) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "This zone is used in a hypothesis and cannot be deleted."; + throw SALOME::SALOME_Exception(es); + return 2 ; + }; +// + // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete + myStudyContext._mesZones.erase(nomZone); + SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomZone, ComponentDataType()); + SALOMEDS::SObject_var aSO =listSO[0]; + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + myStudy->NewBuilder()->RemoveObjectWithChildren(aSO); + + return 0 ; +} +//============================================================================= +//============================================================================= +// +//============================================================================= +//============================================================================= +// Invalidation des structures identifiees par leurs noms +//============================================================================= +//============================================================================= +void ADAPT_Gen_i::InvalideBoundary(const char* BoundaryName) +{ + MESSAGE( "InvalideBoundary : BoundaryName = " << BoundaryName ); + ADAPT::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName]; + if (CORBA::is_nil(myBoundary)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid boundary"; + throw SALOME::SALOME_Exception(es); + return ; + } + else + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "No change is allowed in a boundary. Ask for evolution."; + throw SALOME::SALOME_Exception(es); + return ; + }; +} +//============================================================================= +void ADAPT_Gen_i::InvalideHypo(const char* nomHypo) +{ + MESSAGE( "InvalideHypo : nomHypo = " << nomHypo ); + ADAPT::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo]; + if (CORBA::is_nil(myHypo)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid hypothesis"; + throw SALOME::SALOME_Exception(es); + return ; + }; + + ADAPT::listeIters* maListe = myHypo->GetIterations(); + int numberOfIter = maListe->length(); + for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++) + { + std::string nomIter = std::string((*maListe)[NumeIter]); + MESSAGE( ".. nomIter = " << nomIter ); + InvalideIter(nomIter.c_str()); + } +} +//============================================================================= +void ADAPT_Gen_i::InvalideIter(const char* nomIter) +{ + MESSAGE("InvalideIter : nomIter = " << nomIter); + // Pour invalider totalement une iteration courante + CORBA::Long Option = 1 ; + return InvalideIterOption(nomIter, Option); +} +//============================================================================= +void ADAPT_Gen_i::InvalideIterOption(const char* nomIter, CORBA::Long Option) +{ + // Option = 0 : On ne supprime pas le fichier du maillage associe + // Option = 1 : On supprime le fichier du maillage associe + MESSAGE ( "InvalideIterOption : nomIter = " << nomIter << ", avec option = " << Option ); + ADAPT::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter]; + if (CORBA::is_nil(myIteration)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid iteration"; + throw SALOME::SALOME_Exception(es); + return ; + }; + + ADAPT::listeIterFilles* maListe = myIteration->GetIterations(); + int numberOfIter = maListe->length(); + for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++) + { + std::string nomIterFille = std::string((*maListe)[NumeIter]); + MESSAGE ( ".. appel recursif de InvalideIter pour nomIter = " << nomIterFille.c_str() ); + InvalideIter(nomIterFille.c_str()); + } + + // On arrive ici pour une iteration sans fille + MESSAGE ( "Invalidation effective de " << nomIter ); + SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration))); + SALOMEDS::ChildIterator_var aIter = myStudy->NewChildIterator(aIterSO); + for (; aIter->More(); aIter->Next()) + { + SALOMEDS::SObject_var so = aIter->Value(); + SALOMEDS::GenericAttribute_var anAttr; + if (!so->FindAttribute(anAttr, "AttributeComment")) continue; + SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr); + std::string value (aCommentAttr->Value()); + if(value == std::string("IterationHomard")) continue; + if(value == std::string("HypoHomard")) continue; + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + aStudyBuilder->RemoveObject(so); + } + + int etat = myIteration->GetState(); + if ( etat > 0 ) + { + SetEtatIter(nomIter,1); + const char * nomCas = myIteration->GetCaseName(); + ADAPT::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas]; + if (CORBA::is_nil(myCase)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid case context"; + throw SALOME::SALOME_Exception(es); + return ; + }; + std::string nomDir = myIteration->GetDirName(); + std::string nomFichier = myIteration->GetMeshFile(); + std::string commande = "rm -rf " + std::string(nomDir); + if ( Option == 1 ) { commande = commande + ";rm -rf " + std::string(nomFichier) ; } + MESSAGE ( "commande = " << commande ); + if ((system(commande.c_str())) != 0) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "The directory for the calculation cannot be cleared." ; + throw SALOME::SALOME_Exception(es); + return ; + } + // Suppression du maillage publie dans SMESH + std::string MeshName = myIteration->GetMeshName() ; + DeleteResultInSmesh(nomFichier, MeshName) ; + }; + +} +//============================================================================= +void ADAPT_Gen_i::InvalideIterInfo(const char* nomIter) +{ + MESSAGE("InvalideIterInfo : nomIter = " << nomIter); + ADAPT::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter]; + if (CORBA::is_nil(myIteration)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid iteration"; + throw SALOME::SALOME_Exception(es); + return ; + }; + + SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration))); + SALOMEDS::ChildIterator_var aIter = myStudy->NewChildIterator(aIterSO); + for (; aIter->More(); aIter->Next()) + { + SALOMEDS::SObject_var so = aIter->Value(); + SALOMEDS::GenericAttribute_var anAttr; + if (!so->FindAttribute(anAttr, "AttributeComment")) continue; + SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr); + std::string value (aCommentAttr->Value()); +/* MESSAGE("... value = " << value);*/ + if( (value == std::string("logInfo")) || ( value == std::string("SummaryInfo")) ) + { + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + aStudyBuilder->RemoveObject(so); + } + } + + const char * nomCas = myIteration->GetCaseName(); + ADAPT::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas]; + if (CORBA::is_nil(myCase)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid case context"; + throw SALOME::SALOME_Exception(es); + return ; + }; + const char* nomDir = myIteration->GetDirName(); + std::string commande = "rm -f " + std::string(nomDir) + "/info* " ; + commande += std::string(nomDir) + "/Liste.*info" ; +/* MESSAGE ( "commande = " << commande );*/ + if ((system(commande.c_str())) != 0) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "The directory for the calculation cannot be cleared." ; + throw SALOME::SALOME_Exception(es); + return ; + } +} +//============================================================================= +void ADAPT_Gen_i::InvalideYACS(const char* YACSName) +{ + MESSAGE( "InvalideYACS : YACSName = " << YACSName ); + ADAPT::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[YACSName]; + if (CORBA::is_nil(myYACS)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid schema YACS"; + throw SALOME::SALOME_Exception(es); + return ; + }; + // + SALOMEDS::SObject_var aYACSSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myYACS))); + SALOMEDS::ChildIterator_var aYACS = myStudy->NewChildIterator(aYACSSO); + for (; aYACS->More(); aYACS->Next()) + { + SALOMEDS::SObject_var so = aYACS->Value(); + SALOMEDS::GenericAttribute_var anAttr; + if (!so->FindAttribute(anAttr, "AttributeComment")) continue; + SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr); + std::string value (aCommentAttr->Value()); + if( value == std::string("xml") ) + { + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + aStudyBuilder->RemoveObject(so); + } + } + std::string nomFichier = myYACS->GetXMLFile(); + std::string commande = "rm -rf " + std::string(nomFichier) ; + MESSAGE ( "commande = " << commande ); + if ((system(commande.c_str())) != 0) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "The XML file for the schema YACS cannot be removed." ; + throw SALOME::SALOME_Exception(es); + return ; + } +} +//============================================================================= +void ADAPT_Gen_i::InvalideZone(const char* ZoneName) +{ + MESSAGE( "InvalideZone : ZoneName = " << ZoneName ); + ADAPT::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName]; + if (CORBA::is_nil(myZone)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid zone"; + throw SALOME::SALOME_Exception(es); + return ; + }; + ADAPT::listeHypo* maListe = myZone->GetHypo(); + int numberOfHypo = maListe->length(); + MESSAGE( ".. numberOfHypo = " << numberOfHypo ); + for (int NumeHypo = 0; NumeHypo< numberOfHypo; NumeHypo++) + { + std::string nomHypo = std::string((*maListe)[NumeHypo]); + MESSAGE( ".. nomHypo = " << nomHypo ); + InvalideHypo(nomHypo.c_str()); + } +} +//============================================================================= +//============================================================================= +// +//============================================================================= +//============================================================================= +// Association de lien entre des structures identifiees par leurs noms +//============================================================================= +//============================================================================= +void ADAPT_Gen_i::AssociateCaseIter(const char* nomCas, const char* nomIter, const char* labelIter) +{ + MESSAGE( "AssociateCaseIter : " << nomCas << ", " << nomIter << ", " << labelIter ); + + ADAPT::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas]; + if (CORBA::is_nil(myCase)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid case"; + throw SALOME::SALOME_Exception(es); + return ; + }; + + ADAPT::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter]; + if (CORBA::is_nil(myIteration)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid iteration"; + throw SALOME::SALOME_Exception(es); + return ; + }; + + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + SALOMEDS::SObject_var aCasSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myCase))); + if (CORBA::is_nil(aCasSO)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid case"; + throw SALOME::SALOME_Exception(es); + return ; + }; + + aStudyBuilder->NewCommand(); + SALOMEDS::SObject_var newStudyIter = aStudyBuilder->NewObject(aCasSO); + PublishInStudyAttr(aStudyBuilder, newStudyIter, nomIter , labelIter, + "iter_non_calculee.png", _orb->object_to_string(myIteration)) ; + aStudyBuilder->CommitCommand(); + + myCase->AddIteration(nomIter); + myIteration->SetCaseName(nomCas); +} +//===================================================================================== +void ADAPT_Gen_i::AssociateHypoZone(const char* nomHypothesis, const char* ZoneName, CORBA::Long TypeUse) +{ + MESSAGE ( "AssociateHypoZone : nomHypo = " << nomHypothesis << ", ZoneName= " << ZoneName << ", TypeUse = " << TypeUse); + + ADAPT::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypothesis]; + ASSERT(!CORBA::is_nil(myHypo)); + SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myHypo))); + ASSERT(!CORBA::is_nil(aHypoSO)); + + ADAPT::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName]; + ASSERT(!CORBA::is_nil(myZone)); + SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myZone))); + ASSERT(!CORBA::is_nil(aZoneSO)); + + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + + aStudyBuilder->NewCommand(); + + SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aHypoSO); + aStudyBuilder->Addreference(aSubSO, aZoneSO); + + aStudyBuilder->CommitCommand(); + + myZone->AddHypo(nomHypothesis); + myHypo->AddZone0(ZoneName, TypeUse); +}; +//============================================================================= +void ADAPT_Gen_i::AssociateIterHypo(const char* nomIter, const char* nomHypo) +{ + MESSAGE("AssociateIterHypo : nomHypo = " << nomHypo << " nomIter = " << nomIter); + + // Verification de l'existence de l'hypothese + ADAPT::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo]; + ASSERT(!CORBA::is_nil(myHypo)); + SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myHypo))); + ASSERT(!CORBA::is_nil(aHypoSO)); + + // Verification de l'existence de l'iteration + ADAPT::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter]; + ASSERT(!CORBA::is_nil(myIteration)); + SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration))); + ASSERT(!CORBA::is_nil(aIterSO)); + + // Gestion de l'arbre d'etudes + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + aStudyBuilder->NewCommand(); + SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO); + aStudyBuilder->Addreference(aSubSO, aHypoSO); + aStudyBuilder->CommitCommand(); + + // Liens reciproques + myIteration->SetHypoName(nomHypo); + myHypo->LinkIteration(nomIter); + + // On stocke les noms des champ a interpoler pour le futur controle de la donnée des pas de temps + myIteration->SupprFieldInterps() ; + ADAPT::listeFieldInterpsHypo* ListField = myHypo->GetFieldInterps(); + int numberOfFieldsx2 = ListField->length(); + for (int iaux = 0; iaux< numberOfFieldsx2; iaux++) + { + std::string FieldName = std::string((*ListField)[iaux]) ; + myIteration->SetFieldInterp(FieldName.c_str()) ; + iaux++ ; + } +}; +//============================================================================= +//============================================================================= +// +//============================================================================= +//============================================================================= +// Dissociation de lien entre des structures identifiees par leurs noms +//============================================================================= +//============================================================================= +void ADAPT_Gen_i::DissociateHypoZone(const char* nomHypothesis, const char* ZoneName) +{ + MESSAGE ( "DissociateHypoZone : ZoneName= " << ZoneName << ", nomHypo = " << nomHypothesis); + + ADAPT::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypothesis]; + ASSERT(!CORBA::is_nil(myHypo)); + SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myHypo))); + ASSERT(!CORBA::is_nil(aHypoSO)); + + ADAPT::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName]; + ASSERT(!CORBA::is_nil(myZone)); + SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myZone))); + ASSERT(!CORBA::is_nil(aZoneSO)); + + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + + SALOMEDS::ChildIterator_var it = myStudy->NewChildIterator(aHypoSO); + for (; it->More(); it->Next()) + { + SALOMEDS::SObject_var aHypObj = it->Value(); + SALOMEDS::SObject_var ptrObj; + if (aHypObj->ReferencedObject(ptrObj)) + { + if (std::string(ptrObj->GetName()) == std::string(aZoneSO->GetName())) + { + aStudyBuilder->NewCommand(); + aStudyBuilder->RemoveObject(aHypObj); + aStudyBuilder->CommitCommand(); + break; + } + } + } + + myZone->SupprHypo(nomHypothesis); + myHypo->SupprZone(ZoneName); +}; +//============================================================================= +//============================================================================= +// + +//============================================================================= +//============================================================================= +// Recuperation des listes +//============================================================================= +//============================================================================= +ADAPT::listeBoundarys* ADAPT_Gen_i::GetAllBoundarysName() +{ + MESSAGE("GetAllBoundarysName"); + IsValidStudy () ; + + ADAPT::listeBoundarys_var ret = new ADAPT::listeBoundarys; + ret->length(myStudyContext._mesBoundarys.size()); + std::map::const_iterator it; + int i = 0; + for (it = myStudyContext._mesBoundarys.begin(); + it != myStudyContext._mesBoundarys.end(); it++) + { + ret[i++] = CORBA::string_dup((*it).first.c_str()); + } + + return ret._retn(); +} +//============================================================================= +ADAPT::listeCases* ADAPT_Gen_i::GetAllCasesName() +{ + MESSAGE("GetAllCasesName"); + IsValidStudy () ; + + ADAPT::listeCases_var ret = new ADAPT::listeCases; + ret->length(myStudyContext._mesCas.size()); + std::map::const_iterator it; + int i = 0; + for (it = myStudyContext._mesCas.begin(); + it != myStudyContext._mesCas.end(); it++) + { + ret[i++] = CORBA::string_dup((*it).first.c_str()); + } + + return ret._retn(); +} +//============================================================================= +ADAPT::listeHypotheses* ADAPT_Gen_i::GetAllHypothesesName() +{ + MESSAGE("GetAllHypothesesName"); + IsValidStudy () ; + + ADAPT::listeHypotheses_var ret = new ADAPT::listeHypotheses; + ret->length(myStudyContext._mesHypotheses.size()); + std::map::const_iterator it; + int i = 0; + for (it = myStudyContext._mesHypotheses.begin(); + it != myStudyContext._mesHypotheses.end(); it++) + { + ret[i++] = CORBA::string_dup((*it).first.c_str()); + } + + return ret._retn(); +} +//============================================================================= +ADAPT::listeIterations* ADAPT_Gen_i::GetAllIterationsName() +{ + MESSAGE("GetAllIterationsName"); + IsValidStudy () ; + + ADAPT::listeIterations_var ret = new ADAPT::listeIterations; + ret->length(myStudyContext._mesIterations.size()); + std::map::const_iterator it; + int i = 0; + for (it = myStudyContext._mesIterations.begin(); + it != myStudyContext._mesIterations.end(); it++) + { + ret[i++] = CORBA::string_dup((*it).first.c_str()); + } + + return ret._retn(); +} +//============================================================================= +ADAPT::listeYACSs* ADAPT_Gen_i::GetAllYACSsName() +{ + MESSAGE("GetAllYACSsName"); + IsValidStudy () ; + + ADAPT::listeYACSs_var ret = new ADAPT::listeYACSs; + ret->length(myStudyContext._mesYACSs.size()); + std::map::const_iterator it; + int i = 0; + for (it = myStudyContext._mesYACSs.begin(); + it != myStudyContext._mesYACSs.end(); it++) + { + ret[i++] = CORBA::string_dup((*it).first.c_str()); + } + + return ret._retn(); +} +//============================================================================= +ADAPT::listeZones* ADAPT_Gen_i::GetAllZonesName() +{ + MESSAGE("GetAllZonesName"); + IsValidStudy () ; + + ADAPT::listeZones_var ret = new ADAPT::listeZones; + ret->length(myStudyContext._mesZones.size()); + std::map::const_iterator it; + int i = 0; + for (it = myStudyContext._mesZones.begin(); + it != myStudyContext._mesZones.end(); it++) + { + ret[i++] = CORBA::string_dup((*it).first.c_str()); + } + + return ret._retn(); +} +//============================================================================= +//============================================================================= + +//============================================================================= +//============================================================================= +// Recuperation des structures identifiees par leurs noms +//============================================================================= +//============================================================================= +ADAPT::HOMARD_Boundary_ptr ADAPT_Gen_i::GetBoundary(const char* nomBoundary) +{ + ADAPT::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[nomBoundary]; + ASSERT(!CORBA::is_nil(myBoundary)); + return ADAPT::HOMARD_Boundary::_duplicate(myBoundary); +} +//============================================================================= +ADAPT::HOMARD_Cas_ptr ADAPT_Gen_i::GetCase(const char* nomCas) +{ + ADAPT::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas]; + ASSERT(!CORBA::is_nil(myCase)); + return ADAPT::HOMARD_Cas::_duplicate(myCase); +} +//============================================================================= +ADAPT::HOMARD_Hypothesis_ptr ADAPT_Gen_i::GetHypothesis(const char* nomHypothesis) +{ + ADAPT::HOMARD_Hypothesis_var myHypothesis = myStudyContext._mesHypotheses[nomHypothesis]; + ASSERT(!CORBA::is_nil(myHypothesis)); + return ADAPT::HOMARD_Hypothesis::_duplicate(myHypothesis); +} +//============================================================================= +ADAPT::HOMARD_Iteration_ptr ADAPT_Gen_i::GetIteration(const char* NomIterationation) +{ + ADAPT::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[NomIterationation]; + ASSERT(!CORBA::is_nil(myIteration)); + return ADAPT::HOMARD_Iteration::_duplicate(myIteration); +} +//============================================================================= +ADAPT::HOMARD_YACS_ptr ADAPT_Gen_i::GetYACS(const char* nomYACS) +{ + ADAPT::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS]; + ASSERT(!CORBA::is_nil(myYACS)); + return ADAPT::HOMARD_YACS::_duplicate(myYACS); +} +//============================================================================= +ADAPT::HOMARD_Zone_ptr ADAPT_Gen_i::GetZone(const char* ZoneName) +{ + ADAPT::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName]; + ASSERT(!CORBA::is_nil(myZone)); + return ADAPT::HOMARD_Zone::_duplicate(myZone); +} +//============================================================================= +//============================================================================= + +//============================================================================= +//============================================================================= +// Informations +//============================================================================= +//============================================================================= +void ADAPT_Gen_i::MeshInfo(const char* nomCas, const char* MeshName, const char* MeshFile, const char* DirName, CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte) +{ + INFOS ( "MeshInfo : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile ); + INFOS ( "Qual = " << Qual << ", Diam = " << Diam << ", Conn = " << Conn << ", Tail = " << Tail << ", Inte = " << Inte ); + IsValidStudy () ; + +// Creation du cas + int option = 1 ; + if ( _PublisMeshIN != 0 ) option = 2 ; + ADAPT::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, 0, option) ; + myCase->SetDirName(DirName) ; +// Analyse + myCase->MeshInfo(Qual, Diam, Conn, Tail, Inte) ; + + return ; +} +//============================================================================= +//============================================================================= + +//============================================================================= +//============================================================================= +// Recuperation des structures par le contexte +//============================================================================= +//============================================================================= +ADAPT::HOMARD_Iteration_ptr ADAPT_Gen_i::LastIteration(const char* nomCas) +{ + ADAPT::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas]; + ASSERT(!CORBA::is_nil(myCase)); +// + ADAPT::HOMARD_Iteration_var myIteration = myCase->LastIteration(); + ASSERT(!CORBA::is_nil(myIteration)); +// + return ADAPT::HOMARD_Iteration::_duplicate(myIteration); +} +//============================================================================= +//============================================================================= + +//============================================================================= +//============================================================================= +// Nouvelles structures +//============================================================================= +//============================================================================= +ADAPT::HOMARD_Cas_ptr ADAPT_Gen_i::newCase() +{ + ADAPT::ADAPT_Gen_var engine = POA_ADAPT::ADAPT_Gen::_this(); + HOMARD_Cas_i* aServant = new HOMARD_Cas_i(_orb, engine); + ADAPT::HOMARD_Cas_var aCase = ADAPT::HOMARD_Cas::_narrow(aServant->_this()); + return aCase._retn(); +} +//============================================================================= +ADAPT::HOMARD_Hypothesis_ptr ADAPT_Gen_i::newHypothesis() +{ + ADAPT::ADAPT_Gen_var engine = POA_ADAPT::ADAPT_Gen::_this(); + HOMARD_Hypothesis_i* aServant = new HOMARD_Hypothesis_i(_orb, engine); + ADAPT::HOMARD_Hypothesis_var aHypo = ADAPT::HOMARD_Hypothesis::_narrow(aServant->_this()); + return aHypo._retn(); +} +//============================================================================= +ADAPT::HOMARD_Iteration_ptr ADAPT_Gen_i::newIteration() +{ + ADAPT::ADAPT_Gen_var engine = POA_ADAPT::ADAPT_Gen::_this(); + HOMARD_Iteration_i* aServant = new HOMARD_Iteration_i(_orb, engine); + ADAPT::HOMARD_Iteration_var aIter = ADAPT::HOMARD_Iteration::_narrow(aServant->_this()); + return aIter._retn(); +} +//============================================================================= +ADAPT::HOMARD_Boundary_ptr ADAPT_Gen_i::newBoundary() +{ + ADAPT::ADAPT_Gen_var engine = POA_ADAPT::ADAPT_Gen::_this(); + HOMARD_Boundary_i* aServant = new HOMARD_Boundary_i(_orb, engine); + ADAPT::HOMARD_Boundary_var aBoundary = ADAPT::HOMARD_Boundary::_narrow(aServant->_this()); + return aBoundary._retn(); +} +//============================================================================= +ADAPT::HOMARD_Zone_ptr ADAPT_Gen_i::newZone() +{ + ADAPT::ADAPT_Gen_var engine = POA_ADAPT::ADAPT_Gen::_this(); + HOMARD_Zone_i* aServant = new HOMARD_Zone_i(_orb, engine); + ADAPT::HOMARD_Zone_var aZone = ADAPT::HOMARD_Zone::_narrow(aServant->_this()); + return aZone._retn(); +} +//============================================================================= +ADAPT::HOMARD_YACS_ptr ADAPT_Gen_i::newYACS() +{ + ADAPT::ADAPT_Gen_var engine = POA_ADAPT::ADAPT_Gen::_this(); + HOMARD_YACS_i* aServant = new HOMARD_YACS_i(_orb, engine); + ADAPT::HOMARD_YACS_var aYACS = ADAPT::HOMARD_YACS::_narrow(aServant->_this()); + return aYACS._retn(); +} +//============================================================================= +//============================================================================= + +//============================================================================= +//============================================================================= +// Creation des structures identifiees par leurs noms +//============================================================================= +//============================================================================= +ADAPT::HOMARD_Cas_ptr ADAPT_Gen_i::CreateCase(const char* nomCas, const char* MeshName, const char* MeshFile) +// +// Creation d'un cas initial +// nomCas : nom du cas a creer +// MeshName, MeshFile : nom et fichier du maillage correspondant +// +{ + INFOS ( "CreateCase : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile ); + + int option = 1 ; + if ( _PublisMeshIN != 0 ) option = 2 ; + ADAPT::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 0, 0, option) ; + +// Valeurs par defaut des filtrages + myCase->SetPyram(0); + + return ADAPT::HOMARD_Cas::_duplicate(myCase); +} +//============================================================================= +ADAPT::HOMARD_Cas_ptr ADAPT_Gen_i::CreateCaseFromIteration(const char* nomCas, const char* DirNameStart) +// +// nomCas : nom du cas a creer +// DirNameStart : nom du répertoire contenant l'iteration de reprise +// +{ + INFOS ( "CreateCaseFromIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart ); + std::string nomDirWork = getenv("PWD") ; + int codret ; + + // A. Decodage du point de reprise + // A.1. Controle du répertoire de depart de l'iteration + codret = CHDIR(DirNameStart) ; + if ( codret != 0 ) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "The directory of the iteration does not exist."; + throw SALOME::SALOME_Exception(es); + return 0; + }; + // A.2. Reperage des fichiers du répertoire de reprise + std::string file_configuration = "" ; + std::string file_maillage_homard = "" ; + int bilan ; +#ifndef WIN32 + DIR *dp; + struct dirent *dirp; + dp = opendir(DirNameStart); + while ( (dirp = readdir(dp)) != NULL ) + { + std::string file_name(dirp->d_name); +// MESSAGE ( file_name ); + bilan = file_name.find("HOMARD.Configuration.") ; + if ( bilan != string::npos ) { file_configuration = file_name ; } + bilan = file_name.find("maill.") ; + if ( bilan != string::npos ) + { + bilan = file_name.find(".hom.med") ; + if ( bilan != string::npos ) { file_maillage_homard = file_name ; } + } + } + closedir(dp); +#else + HANDLE hFind = INVALID_HANDLE_VALUE; + WIN32_FIND_DATA ffd; + hFind = FindFirstFile(DirNameStart, &ffd); + if (INVALID_HANDLE_VALUE != hFind) { + while (FindNextFile(hFind, &ffd) != 0) { + if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories + std::string file_name(ffd.cFileName); + bilan = file_name.find("HOMARD.Configuration.") ; + if ( bilan != string::npos ) { file_configuration = file_name ; } + bilan = file_name.find("maill.") ; + if ( bilan != string::npos ) + { + bilan = file_name.find(".hom.med") ; + if ( bilan != string::npos ) { file_maillage_homard = file_name ; } + } + } + FindClose(hFind); + } +#endif + MESSAGE ( "==> file_configuration : " << file_configuration ) ; + MESSAGE ( "==> file_maillage_homard : " << file_maillage_homard ) ; + // A.3. Controle + if ( ( file_configuration == "" ) || ( file_maillage_homard == "" ) ) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + std::string text ; + if ( file_configuration == "" ) { text = "The configuration file cannot be found." ; } + else { text = "The HOMARD mesh file cannot be found." ; } + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + } + + // B. Lecture du fichier de configuration + // ATTENTION : on doit veiller a la coherence entre HomardDriver et CreateCaseFromIteration + int NumeIter ; + int TypeExt = 0 ; + int TypeConf = 0 ; + int Pyram = 0 ; + char* MeshName ; + char* MeshFile ; + // le constructeur de ifstream permet d'ouvrir un fichier en lecture + std::ifstream fichier( file_configuration.c_str() ); + if ( fichier ) // ce test échoue si le fichier n'est pas ouvert + { + std::string ligne; // variable contenant chaque ligne lue + std::string mot_cle; + std::string argument; + int decalage; + // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient + while ( std::getline( fichier, ligne ) ) + { + // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle + std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux + ligne_bis >> mot_cle ; + // B.2. Des valeurs entieres : le second bloc de la ligne + if ( mot_cle == "NumeIter" ) + { + ligne_bis >> NumeIter ; + NumeIter += 1 ; + } + // B.3. Des valeurs caracteres brutes : le second bloc de la ligne est la valeur + else if ( ( mot_cle == "TypeConf" ) || ( mot_cle == "TypeElem" ) ) + { + ligne_bis >> argument ; + + if ( mot_cle == "TypeConf" ) + { + if ( argument == "conforme" ) { TypeConf = 1 ; } + else if ( argument == "non_conforme_1_noeud" ) { TypeConf = 2 ; } + else if ( argument == "non_conforme_1_arete" ) { TypeConf = 3 ; } + else if ( argument == "non_conforme_indicateur" ) { TypeConf = 4 ; } + } + else if ( mot_cle == "TypeElem" ) + { + if ( argument == "ignore_pyra" ) { Pyram = 1 ; } + else if ( argument == "HOMARD" ) { Pyram = 0 ; } + } + } + // B.4. Des valeurs caracteres : le deuxieme bloc de la ligne peut etre encadre par des quotes : + // il faut les supprimer + else if ( ( mot_cle == "CCNoMNP1" ) || ( mot_cle == "CCMaiNP1" ) ) + { + ligne_bis >> argument ; + if ( argument[0] == '"' ) { decalage = 1 ; } + else { decalage = 0 ; } + size_t size = argument.size() + 1 - 2*decalage ; + + if ( mot_cle == "CCNoMNP1" ) + { + MeshName = new char[ size ]; + strncpy( MeshName, argument.c_str()+decalage, size ); + MeshName[size-1] = '\0' ; + } + else if ( mot_cle == "CCMaiNP1" ) + { + MeshFile = new char[ size ]; + strncpy( MeshFile, argument.c_str()+decalage, size ); + MeshFile[size-1] = '\0' ; + } + } + } + MESSAGE ( "==> TypeConf : " << TypeConf ) ; + MESSAGE ( "==> MeshName : " << MeshName ) ; + MESSAGE ( "==> MeshFile : " << MeshFile ) ; + MESSAGE ( "==> NumeIter : " << NumeIter ) ; + MESSAGE ( "==> Pyram : " << Pyram ) ; + } + else + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + std::string text = "The configuration file cannot be read." ; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + } + + // C. Creation effective du cas + + int option = 1 ; + if ( _PublisMeshIN != 0 ) option = 2 ; + ADAPT::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, NumeIter, option) ; + + // D. Parametrages lus dans le fichier de configuration + + myCase->SetConfType (TypeConf) ; + myCase->SetExtType (TypeExt) ; + myCase->SetPyram (Pyram) ; + + // E. Copie du fichier de maillage homard + // E.1. Répertoire associe au cas + char* nomDirCase = myCase->GetDirName() ; + // E.2. Répertoire associe a l'iteration de ce cas + char* IterName ; + IterName = myCase->GetIter0Name() ; + ADAPT::HOMARD_Iteration_var Iter = GetIteration(IterName) ; + char* nomDirIter = CreateDirNameIter(nomDirCase, 0 ); + Iter->SetDirNameLoc(nomDirIter); + std::string nomDirIterTotal ; + nomDirIterTotal = std::string(nomDirCase) + "/" + std::string(nomDirIter) ; +#ifndef WIN32 + if (mkdir(nomDirIterTotal.c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0) +#else + if (_mkdir(nomDirIterTotal.c_str()) != 0) +#endif + { + MESSAGE ( "nomDirIterTotal : " << nomDirIterTotal ) ; + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + std::string text = "The directory for the computation cannot be created." ; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + } + // E.3. Copie du maillage HOMARD au format MED + codret = CHDIR(DirNameStart) ; + std::string commande = "cp " + file_maillage_homard + " " + nomDirIterTotal ; + MESSAGE ( "commande : " << commande ) ; + codret = system(commande.c_str()) ; + MESSAGE ( "codret : " << codret ) ; + if ( codret != 0 ) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "The starting point for the case cannot be copied into the working directory."; + throw SALOME::SALOME_Exception(es); + return 0; + }; + + // F. Menage + + delete[] MeshName ; + delete[] MeshFile ; + + CHDIR(nomDirWork.c_str()); + return ADAPT::HOMARD_Cas::_duplicate(myCase); +} +//============================================================================= +ADAPT::HOMARD_Cas_ptr ADAPT_Gen_i::CreateCaseFromCaseLastIteration(const char* nomCas, const char* DirNameStart) +// +// nomCas : nom du cas a creer +// DirNameStart : nom du répertoire du cas contenant l'iteration de reprise +// +{ + INFOS ( "CreateCaseFromCaseLastIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart ); + + std::string DirNameStartIter = CreateCase1(DirNameStart, -1) ; + + DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ; + ADAPT::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ; + + return ADAPT::HOMARD_Cas::_duplicate(myCase); +} +//============================================================================= +ADAPT::HOMARD_Cas_ptr ADAPT_Gen_i::CreateCaseFromCaseIteration(const char* nomCas, const char* DirNameStart, CORBA::Long Number) +// +// nomCas : nom du cas a creer +// DirNameStart : nom du répertoire du cas contenant l'iteration de reprise +// Number : numero de l'iteration de depart +// +{ + INFOS ( "CreateCaseFromCaseIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart << ", Number = " << Number ); + if ( Number < 0 ) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "The number of iteration must be positive."; + throw SALOME::SALOME_Exception(es); + return 0; + }; + + std::string DirNameStartIter = CreateCase1(DirNameStart, Number) ; + + DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ; + ADAPT::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ; + + return ADAPT::HOMARD_Cas::_duplicate(myCase); +} +//============================================================================= +std::string ADAPT_Gen_i::CreateCase1(const char* DirNameStart, CORBA::Long Number) +// +// Retourne le nom du répertoire ou se trouve l'iteration voulue. +// DirNameStart : nom du répertoire du cas contenant l'iteration de reprise +// Number : numero de l'iteration de depart ou -1 si on cherche la derniere +// +{ + MESSAGE ( "CreateCase1 : DirNameStart = " << DirNameStart << ", Number = " << Number ); + std::string nomDirWork = getenv("PWD") ; + std::string DirNameStartIter ; + int codret ; + int NumeIterMax = -1 ; + + // A.1. Controle du répertoire de depart du cas + codret = CHDIR(DirNameStart) ; + if ( codret != 0 ) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "The directory of the case for the pursuit does not exist."; + throw SALOME::SALOME_Exception(es); + return 0; + }; + // A.2. Reperage des sous-répertoire du répertoire de reprise + bool existe = false ; +#ifndef WIN32 + DIR *dp; + struct dirent *dirp; + dp = opendir(DirNameStart); + while ( (dirp = readdir(dp)) != NULL ) { + std::string DirName_1(dirp->d_name); +#else + HANDLE hFind = INVALID_HANDLE_VALUE; + WIN32_FIND_DATA ffd; + hFind = FindFirstFile(DirNameStart, &ffd); + if (INVALID_HANDLE_VALUE != hFind) { + while (FindNextFile(hFind, &ffd) != 0) { + std::string DirName_1 = ""; + if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + DirName_1 = std::string(ffd.cFileName); + } +#endif + if ( ( DirName_1 != "." ) && ( DirName_1 != ".." ) ) + { + if ( CHDIR(DirName_1.c_str()) == 0 ) + { +// On cherche le fichier de configuration dans ce sous-répertoire + codret = CHDIR(DirNameStart); +#ifndef WIN32 + DIR *dp_1; + struct dirent *dirp_1; + dp_1 = opendir(DirName_1.c_str()) ; + while ( (dirp_1 = readdir(dp_1)) != NULL ) + { + std::string file_name_1(dirp_1->d_name); +#else + HANDLE hFind1 = INVALID_HANDLE_VALUE; + WIN32_FIND_DATA ffd1; + hFind1 = FindFirstFile(DirName_1.c_str(), &ffd1); + while (FindNextFile(hFind1, &ffd1) != 0) + { + if (ffd1.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories + std::string file_name_1(ffd1.cFileName); +#endif + int bilan = file_name_1.find("HOMARD.Configuration.") ; + if ( bilan != string::npos ) + { + // Decodage du fichier pour trouver le numero d'iteration + CHDIR(DirName_1.c_str()) ; + + std::ifstream fichier( file_name_1.c_str() ); + if ( fichier ) // ce test échoue si le fichier n'est pas ouvert + { + int NumeIter ; + std::string ligne; // variable contenant chaque ligne lue + std::string mot_cle; + // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient + while ( std::getline( fichier, ligne ) ) + { + // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle + std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux + ligne_bis >> mot_cle ; + if ( mot_cle == "NumeIter" ) + { + ligne_bis >> NumeIter ; + NumeIter += 1 ; +// MESSAGE ( "==> NumeIter : " << NumeIter ) ; + if ( Number == - 1 ) + { + if ( NumeIter >= NumeIterMax ) + { + NumeIterMax = NumeIter ; + DirNameStartIter = DirName_1 ; + } + } + else + { + if ( NumeIter == Number ) + { + DirNameStartIter = DirName_1 ; + existe = true ; + break ; + } + } + } + } + } + else + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + std::string text = "The configuration file cannot be read." ; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + } + CHDIR(DirNameStart) ; + } + if ( existe ) { break ; } + } +#ifndef WIN32 + closedir(dp_1); +#else + FindClose(hFind1); +#endif + if ( existe ) { break ; } + } + } + } +#ifndef WIN32 + closedir(dp); +#else + FindClose(hFind); +#endif + CHDIR(nomDirWork.c_str()); + + if ( ( Number >= 0 && ( !existe ) ) || ( Number < 0 && ( NumeIterMax == -1 ) ) ) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "The directory of the iteration does not exist."; + throw SALOME::SALOME_Exception(es); + return 0; + }; + + return DirNameStartIter ; +} +//============================================================================= +ADAPT::HOMARD_Cas_ptr ADAPT_Gen_i::CreateCase0(const char* nomCas, const char* MeshName, const char* MeshFile, CORBA::Long MeshOption, CORBA::Long NumeIter, CORBA::Long Option) +// +// nomCas : nom du cas a creer +// MeshName, MeshFile : nom et fichier du maillage correspondant +// MeshOption : 0 : le maillage fourni est obligatoirement present ==> erreur si absent +// 1 : le maillage fourni peut ne pas exister ==> on continue si absent +// -1 : le maillage n'est pas fourni +// NumeIter : numero de l'iteration correspondante : 0, pour un depart, n>0 pour une poursuite +// Option : multiple de nombres premiers +// 1 : aucune option +// x2 : publication du maillage dans SMESH +{ + MESSAGE ( "CreateCase0 : nomCas = " << nomCas ); + MESSAGE ( "CreateCase0 : MeshName = " << MeshName << ", MeshFile = " << MeshFile << ", MeshOption = " << MeshOption ); + MESSAGE ( "CreateCase0 : NumeIter = " << NumeIter << ", Option = " << Option ); +// + // A. Controles + // A.1. L'etude + IsValidStudy () ; + + // A.2. Controle du nom : + if ((myStudyContext._mesCas).find(nomCas)!=(myStudyContext._mesCas).end()) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "This case has already been defined."; + throw SALOME::SALOME_Exception(es); + return 0; + }; + + // A.3. Controle du fichier du maillage + int existeMeshFile ; + if ( MeshOption >= 0 ) + { + existeMeshFile = MEDFileExist ( MeshFile ) ; + MESSAGE ( "CreateCase0 : existeMeshFile = " << existeMeshFile ); + if ( ( existeMeshFile == 0 ) && ( MeshOption == 0 ) ) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "The mesh file does not exist."; + throw SALOME::SALOME_Exception(es); + return 0; + } + } + else { existeMeshFile = 0 ; } + + // B. Creation de l'objet cas et publication +// MESSAGE ( "CreateCase0 : Creation de l'objet" ); + ADAPT::HOMARD_Cas_var myCase = newCase(); + myCase->SetName(nomCas); + SALOMEDS::SObject_var aSO; + SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myCase, nomCas); + myStudyContext._mesCas[nomCas] = myCase; + + // C. Caracteristiques du maillage + if ( existeMeshFile != 0 ) + { + // Les valeurs extremes des coordonnées +// MESSAGE ( "CreateCase0 : Les valeurs extremes des coordonnées" ); + std::vector LesExtremes =GetBoundingBoxInMedFile(MeshFile) ; + ADAPT::extrema_var aSeq = new ADAPT::extrema() ; + if (LesExtremes.size()!=10) { return 0; } + aSeq->length(10) ; + for (int i =0 ; i< LesExtremes.size() ; i++) + aSeq[i]=LesExtremes[i] ; + myCase->SetBoundingBox(aSeq) ; + // Les groupes +// MESSAGE ( "CreateCase0 : Les groupes" ); + std::set LesGroupes =GetListeGroupesInMedFile(MeshFile) ; + ADAPT::ListGroupType_var aSeqGroupe = new ADAPT::ListGroupType ; + aSeqGroupe->length(LesGroupes.size()); + std::set::const_iterator it ; + int i = 0 ; + for (it=LesGroupes.begin() ; it != LesGroupes.end() ; it++) + aSeqGroupe[i++]=(*it).c_str() ; + myCase->SetGroups(aSeqGroupe) ; + } + + // D. L'iteration initiale du cas + MESSAGE ( "CreateCase0 : iteration initiale du cas" ); + // D.1. Recherche d'un nom : par defaut, on prend le nom du maillage correspondant. + // Si ce nom d'iteration existe deja, on incremente avec 0, 1, 2, etc. + int monNum = 0; + std::string NomIteration = std::string(MeshName) ; + while ( (myStudyContext._mesIterations).find(NomIteration) != (myStudyContext._mesIterations.end()) ) + { + std::ostringstream nom; + nom << MeshName << monNum; + NomIteration = nom.str(); + monNum += 1; + } + MESSAGE ( "CreateCas0 : ==> NomIteration = " << NomIteration ); + + // D.2. Creation de l'iteration + ADAPT::HOMARD_Iteration_var anIter = newIteration(); + myStudyContext._mesIterations[NomIteration] = anIter; + anIter->SetName(NomIteration.c_str()); + AssociateCaseIter (nomCas, NomIteration.c_str(), "IterationHomard"); + + // D.4. Maillage correspondant + if ( existeMeshFile != 0 ) + { + anIter->SetMeshFile(MeshFile); + if ( Option % 2 == 0 ) { PublishResultInSmesh(MeshFile, 0); } + } + anIter->SetMeshName(MeshName); + + // D.5. Numero d'iteration + anIter->SetNumber(NumeIter); + + // D.6. Etat + SetEtatIter(NomIteration.c_str(), -NumeIter); +// + + return ADAPT::HOMARD_Cas::_duplicate(myCase); +} +//============================================================================= +ADAPT::HOMARD_Hypothesis_ptr ADAPT_Gen_i::CreateHypothesis(const char* nomHypothesis) +{ + INFOS ( "CreateHypothesis : nomHypothesis = " << nomHypothesis ); + IsValidStudy () ; + + // A. Controle du nom : + if ((myStudyContext._mesHypotheses).find(nomHypothesis) != (myStudyContext._mesHypotheses).end()) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "This hypothesis has already been defined."; + throw SALOME::SALOME_Exception(es); + return 0; + } + + // B. Creation de l'objet + ADAPT::HOMARD_Hypothesis_var myHypothesis = newHypothesis(); + if (CORBA::is_nil(myHypothesis)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Unable to create the hypothesis"; + throw SALOME::SALOME_Exception(es); + return 0; + }; + myHypothesis->SetName(nomHypothesis); + + // C. Enregistrement + myStudyContext._mesHypotheses[nomHypothesis] = myHypothesis; + + SALOMEDS::SObject_var aSO; + SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myHypothesis, nomHypothesis); + + // D. Valeurs par defaut des options avancees + myHypothesis->SetNivMax(-1); + myHypothesis->SetDiamMin(-1.0); + myHypothesis->SetAdapInit(0); + myHypothesis->SetExtraOutput(1); + + return ADAPT::HOMARD_Hypothesis::_duplicate(myHypothesis); +} + +//============================================================================= +ADAPT::HOMARD_Iteration_ptr ADAPT_Gen_i::CreateIteration(const char* NomIteration, const char* nomIterParent) +//============================================================================= +{ + INFOS ("CreateIteration : NomIteration = " << NomIteration << ", nomIterParent = " << nomIterParent); + IsValidStudy () ; + + ADAPT::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterParent]; + if (CORBA::is_nil(myIterationParent)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "The parent iteration is not defined."; + throw SALOME::SALOME_Exception(es); + return 0; + }; + + const char* nomCas = myIterationParent->GetCaseName(); + MESSAGE ("CreateIteration : nomCas = " << nomCas); + ADAPT::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas]; + if (CORBA::is_nil(myCase)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid case context"; + throw SALOME::SALOME_Exception(es); + return 0; + }; + const char* nomDirCase = myCase->GetDirName(); + + // Controle du nom : + if ((myStudyContext._mesIterations).find(NomIteration)!=(myStudyContext._mesIterations).end()) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "This iteration has already been defined."; + throw SALOME::SALOME_Exception(es); + return 0; + }; + + ADAPT::HOMARD_Iteration_var myIteration = newIteration(); + if (CORBA::is_nil(myIteration)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Unable to create the iteration"; + throw SALOME::SALOME_Exception(es); + return 0; + }; + myStudyContext._mesIterations[std::string(NomIteration)] = myIteration; +// Nom de l'iteration et du maillage + myIteration->SetName(NomIteration); + myIteration->SetMeshName(NomIteration); + myIteration->SetState(1); + + int numero = myIterationParent->GetNumber() + 1; + myIteration->SetNumber(numero); + +// Nombre d'iterations deja connues pour le cas, permettant +// la creation d'un sous-répertoire unique + int nbitercase = myCase->GetNumberofIter(); + char* nomDirIter = CreateDirNameIter(nomDirCase, nbitercase ); + myIteration->SetDirNameLoc(nomDirIter); + +// Le nom du fichier du maillage MED est indice par le nombre d'iterations du cas. +// Si on a une chaine unique depuis le depart, ce nombre est le meme que le +// numero d'iteration dans la sucession : maill.01.med, maill.02.med, etc... C'est la +// situation la plus frequente. +// Si on a plusieurs branches, donc des iterations du meme niveau d'adaptation, utiliser +// le nombre d'iterations du cas permet d'eviter les collisions. + int jaux ; + if ( nbitercase < 100 ) { jaux = 2 ; } + else if ( nbitercase < 1000 ) { jaux = 3 ; } + else if ( nbitercase < 10000 ) { jaux = 4 ; } + else if ( nbitercase < 100000 ) { jaux = 5 ; } + else { jaux = 9 ; } + std::ostringstream iaux ; + iaux << std::setw(jaux) << std::setfill('0') << nbitercase ; + std::stringstream MeshFile; + MeshFile << nomDirCase << "/maill." << iaux.str() << ".med"; + myIteration->SetMeshFile(MeshFile.str().c_str()); + +// Association avec le cas + std::string label = "IterationHomard_" + std::string(nomIterParent); + AssociateCaseIter(nomCas, NomIteration, label.c_str()); +// Lien avec l'iteration precedente + myIterationParent->LinkNextIteration(NomIteration); + myIteration->SetIterParentName(nomIterParent); + // Gestion de l'arbre d'etudes + SALOMEDS::SObject_var aIterSOParent = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIterationParent))); + SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration))); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + aStudyBuilder->NewCommand(); + SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO); + aStudyBuilder->Addreference(aSubSO, aIterSOParent); + aStudyBuilder->CommitCommand(); + + return ADAPT::HOMARD_Iteration::_duplicate(myIteration); +} +//============================================================================= +ADAPT::HOMARD_Boundary_ptr ADAPT_Gen_i::CreateBoundary(const char* BoundaryName, CORBA::Long BoundaryType) +{ + MESSAGE ("CreateBoundary : BoundaryName = " << BoundaryName << ", BoundaryType = " << BoundaryType); + IsValidStudy () ; + + // Controle du nom : + if ((myStudyContext._mesBoundarys).find(BoundaryName)!=(myStudyContext._mesBoundarys).end()) + { + MESSAGE ("CreateBoundary : la frontiere " << BoundaryName << " existe deja"); + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "This boundary has already been defined"; + throw SALOME::SALOME_Exception(es); + return 0; + }; + + ADAPT::HOMARD_Boundary_var myBoundary = newBoundary(); + myBoundary->SetName(BoundaryName); + myBoundary->SetType(BoundaryType); + + myStudyContext._mesBoundarys[BoundaryName] = myBoundary; + + SALOMEDS::SObject_var aSO; + SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myBoundary, BoundaryName); + + return ADAPT::HOMARD_Boundary::_duplicate(myBoundary); +} +//============================================================================= +ADAPT::HOMARD_Boundary_ptr ADAPT_Gen_i::CreateBoundaryCAO(const char* BoundaryName, const char* CAOFile) +{ + INFOS ("CreateBoundaryCAO : BoundaryName = " << BoundaryName << ", CAOFile = " << CAOFile ); + ADAPT::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, -1); + myBoundary->SetDataFile( CAOFile ) ; + + return ADAPT::HOMARD_Boundary::_duplicate(myBoundary); +} +//============================================================================= +ADAPT::HOMARD_Boundary_ptr ADAPT_Gen_i::CreateBoundaryDi(const char* BoundaryName, const char* MeshName, const char* MeshFile) +{ + INFOS ("CreateBoundaryDi : BoundaryName = " << BoundaryName << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile ); + ADAPT::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 0); + myBoundary->SetDataFile( MeshFile ) ; + myBoundary->SetMeshName( MeshName ) ; + + return ADAPT::HOMARD_Boundary::_duplicate(myBoundary); +} +//============================================================================= +ADAPT::HOMARD_Boundary_ptr ADAPT_Gen_i::CreateBoundaryCylinder(const char* BoundaryName, + CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, + CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, + CORBA::Double Rayon) +{ + INFOS ("CreateBoundaryCylinder : BoundaryName = " << BoundaryName ) ; +// + SALOME::ExceptionStruct es; + int error = 0 ; + if ( Rayon <= 0.0 ) + { es.text = "The radius must be positive." ; + error = 1 ; } + double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ; + if ( daux < 0.0000001 ) + { es.text = "The axis must be a non 0 vector." ; + error = 2 ; } + if ( error != 0 ) + { + es.type = SALOME::BAD_PARAM; + throw SALOME::SALOME_Exception(es); + return 0; + }; +// + ADAPT::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 1) ; + myBoundary->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon ) ; + + return ADAPT::HOMARD_Boundary::_duplicate(myBoundary) ; +} +//============================================================================= +ADAPT::HOMARD_Boundary_ptr ADAPT_Gen_i::CreateBoundarySphere(const char* BoundaryName, + CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, + CORBA::Double Rayon) +{ + INFOS ("CreateBoundarySphere : BoundaryName = " << BoundaryName ) ; +// + SALOME::ExceptionStruct es; + int error = 0 ; + if ( Rayon <= 0.0 ) + { es.text = "The radius must be positive." ; + error = 1 ; } + if ( error != 0 ) + { + es.type = SALOME::BAD_PARAM; + throw SALOME::SALOME_Exception(es); + return 0; + }; +// + ADAPT::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 2) ; + myBoundary->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ; + + return ADAPT::HOMARD_Boundary::_duplicate(myBoundary) ; +} +//============================================================================= +ADAPT::HOMARD_Boundary_ptr ADAPT_Gen_i::CreateBoundaryConeA(const char* BoundaryName, + CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, CORBA::Double Angle, + CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre) +{ + INFOS ("CreateBoundaryConeA : BoundaryName = " << BoundaryName ) ; +// + SALOME::ExceptionStruct es; + int error = 0 ; + if ( Angle <= 0.0 || Angle >= 90.0 ) + { es.text = "The angle must be included higher than 0 degree and lower than 90 degrees." ; + error = 1 ; } + double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ; + if ( daux < 0.0000001 ) + { es.text = "The axis must be a non 0 vector." ; + error = 2 ; } + if ( error != 0 ) + { + es.type = SALOME::BAD_PARAM; + throw SALOME::SALOME_Exception(es); + return 0; + }; +// + ADAPT::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 3) ; + myBoundary->SetConeA( Xaxe, Yaxe, Zaxe, Angle, Xcentre, Ycentre, Zcentre ) ; + + return ADAPT::HOMARD_Boundary::_duplicate(myBoundary) ; +} +//============================================================================= +ADAPT::HOMARD_Boundary_ptr ADAPT_Gen_i::CreateBoundaryConeR(const char* BoundaryName, + CORBA::Double Xcentre1, CORBA::Double Ycentre1, CORBA::Double Zcentre1, CORBA::Double Rayon1, + CORBA::Double Xcentre2, CORBA::Double Ycentre2, CORBA::Double Zcentre2, CORBA::Double Rayon2) +{ + INFOS ("CreateBoundaryConeR : BoundaryName = " << BoundaryName ) ; +// + SALOME::ExceptionStruct es; + int error = 0 ; + if ( Rayon1 < 0.0 || Rayon2 < 0.0 ) + { es.text = "The radius must be positive." ; + error = 1 ; } + double daux = fabs(Rayon2-Rayon1) ; + if ( daux < 0.0000001 ) + { es.text = "The radius must be different." ; + error = 2 ; } + daux = fabs(Xcentre2-Xcentre1) + fabs(Ycentre2-Ycentre1) + fabs(Zcentre2-Zcentre1) ; + if ( daux < 0.0000001 ) + { es.text = "The centers must be different." ; + error = 3 ; } + if ( error != 0 ) + { + es.type = SALOME::BAD_PARAM; + throw SALOME::SALOME_Exception(es); + return 0; + }; +// + ADAPT::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 4) ; + myBoundary->SetConeR( Xcentre1, Ycentre1, Zcentre1, Rayon1, Xcentre2, Ycentre2, Zcentre2, Rayon2 ) ; + + return ADAPT::HOMARD_Boundary::_duplicate(myBoundary) ; +} +//============================================================================= +ADAPT::HOMARD_Boundary_ptr ADAPT_Gen_i::CreateBoundaryTorus(const char* BoundaryName, + CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, + CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, + CORBA::Double RayonRev, CORBA::Double RayonPri) +{ + INFOS ("CreateBoundaryTorus : BoundaryName = " << BoundaryName ) ; +// + SALOME::ExceptionStruct es; + int error = 0 ; + if ( ( RayonRev <= 0.0 ) || ( RayonPri <= 0.0 ) ) + { es.text = "The radius must be positive." ; + error = 1 ; } + double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ; + if ( daux < 0.0000001 ) + { es.text = "The axis must be a non 0 vector." ; + error = 2 ; } + if ( error != 0 ) + { + es.type = SALOME::BAD_PARAM; + throw SALOME::SALOME_Exception(es); + return 0; + }; +// + ADAPT::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 5) ; + myBoundary->SetTorus( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, RayonRev, RayonPri ) ; + + return ADAPT::HOMARD_Boundary::_duplicate(myBoundary) ; +} +//============================================================================= +ADAPT::HOMARD_Zone_ptr ADAPT_Gen_i::CreateZone(const char* ZoneName, CORBA::Long ZoneType) +{ + MESSAGE ("CreateZone : ZoneName = " << ZoneName << ", ZoneType = " << ZoneType); + IsValidStudy () ; + + // Controle du nom : + if ((myStudyContext._mesZones).find(ZoneName)!=(myStudyContext._mesZones).end()) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "This zone has already been defined"; + throw SALOME::SALOME_Exception(es); + return 0; + }; + + ADAPT::HOMARD_Zone_var myZone = newZone(); + myZone->SetName(ZoneName); + myZone->SetType(ZoneType); + + myStudyContext._mesZones[ZoneName] = myZone; + + SALOMEDS::SObject_var aSO; + SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myZone, ZoneName); + + return ADAPT::HOMARD_Zone::_duplicate(myZone); +} +//============================================================================= +ADAPT::HOMARD_Zone_ptr ADAPT_Gen_i::CreateZoneBox(const char* ZoneName, + CORBA::Double Xmini, CORBA::Double Xmaxi, + CORBA::Double Ymini, CORBA::Double Ymaxi, + CORBA::Double Zmini, CORBA::Double Zmaxi) +{ + INFOS ("CreateZoneBox : ZoneName = " << ZoneName ) ; +// + SALOME::ExceptionStruct es; + int error = 0 ; + if ( Xmini > Xmaxi ) + { es.text = "The X coordinates are not coherent." ; + error = 1 ; } + if ( Ymini > Ymaxi ) + { es.text = "The Y coordinates are not coherent." ; + error = 2 ; } + if ( Zmini > Zmaxi ) + { es.text = "The Z coordinates are not coherent." ; + error = 3 ; } + if ( error != 0 ) + { + es.type = SALOME::BAD_PARAM; + throw SALOME::SALOME_Exception(es); + return 0; + }; +// + ADAPT::HOMARD_Zone_var myZone = CreateZone(ZoneName, 2) ; + myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ; + + return ADAPT::HOMARD_Zone::_duplicate(myZone) ; +} +//============================================================================= +ADAPT::HOMARD_Zone_ptr ADAPT_Gen_i::CreateZoneSphere(const char* ZoneName, + CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon) +{ + INFOS ("CreateZoneSphere : ZoneName = " << ZoneName ) ; +// + SALOME::ExceptionStruct es; + int error = 0 ; + if ( Rayon <= 0.0 ) + { es.text = "The radius must be positive." ; + error = 1 ; } + if ( error != 0 ) + { + es.type = SALOME::BAD_PARAM; + throw SALOME::SALOME_Exception(es); + return 0; + }; +// + ADAPT::HOMARD_Zone_var myZone = CreateZone(ZoneName, 4) ; + myZone->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ; + + return ADAPT::HOMARD_Zone::_duplicate(myZone) ; +} +//============================================================================= +ADAPT::HOMARD_Zone_ptr ADAPT_Gen_i::CreateZoneCylinder(const char* ZoneName, + CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, + CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, + CORBA::Double Rayon, CORBA::Double Haut) +{ + INFOS ("CreateZoneCylinder : ZoneName = " << ZoneName ) ; +// + SALOME::ExceptionStruct es; + int error = 0 ; + if ( Rayon <= 0.0 ) + { es.text = "The radius must be positive." ; + error = 1 ; } + double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ; + if ( daux < 0.0000001 ) + { es.text = "The axis must be a non 0 vector." ; + error = 2 ; } + if ( Haut <= 0.0 ) + { es.text = "The height must be positive." ; + error = 3 ; } + if ( error != 0 ) + { + es.type = SALOME::BAD_PARAM; + throw SALOME::SALOME_Exception(es); + return 0; + }; +// + ADAPT::HOMARD_Zone_var myZone = CreateZone(ZoneName, 5) ; + myZone->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut ) ; + + return ADAPT::HOMARD_Zone::_duplicate(myZone) ; +} +//============================================================================= +ADAPT::HOMARD_Zone_ptr ADAPT_Gen_i::CreateZonePipe(const char* ZoneName, + CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, + CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, + CORBA::Double Rayon, CORBA::Double Haut, CORBA::Double Rayonint) +{ + INFOS ("CreateZonePipe : ZoneName = " << ZoneName ) ; +// + SALOME::ExceptionStruct es; + int error = 0 ; + if ( Rayon <= 0.0 || Rayonint <= 0.0 ) + { es.text = "The radius must be positive." ; + error = 1 ; } + double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ; + if ( daux < 0.0000001 ) + { es.text = "The axis must be a non 0 vector." ; + error = 2 ; } + if ( Haut <= 0.0 ) + { es.text = "The height must be positive." ; + error = 3 ; } + if ( Rayon <= Rayonint ) + { es.text = "The external radius must be higher than the internal radius." ; + error = 4 ; } + if ( error != 0 ) + { + es.type = SALOME::BAD_PARAM; + throw SALOME::SALOME_Exception(es); + return 0; + }; +// + ADAPT::HOMARD_Zone_var myZone = CreateZone(ZoneName, 7) ; + myZone->SetPipe( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut, Rayonint ) ; + + return ADAPT::HOMARD_Zone::_duplicate(myZone) ; +} +//============================================================================= +ADAPT::HOMARD_Zone_ptr ADAPT_Gen_i::CreateZoneBox2D(const char* ZoneName, + CORBA::Double Umini, CORBA::Double Umaxi, + CORBA::Double Vmini, CORBA::Double Vmaxi, + CORBA::Long Orient) +{ + INFOS ("CreateZoneBox2D : ZoneName = " << ZoneName ) ; +// MESSAGE ("Umini = " << Umini << ", Umaxi =" << Umaxi ) ; +// MESSAGE ("Vmini = " << Vmini << ", Vmaxi =" << Vmaxi ) ; +// MESSAGE ("Orient = " << Orient ) ; +// + SALOME::ExceptionStruct es; + int error = 0 ; + if ( Umini > Umaxi ) + { es.text = "The first coordinates are not coherent." ; + error = 1 ; } + if ( Vmini > Vmaxi ) + { es.text = "The second coordinates are not coherent." ; + error = 2 ; } + if ( Orient < 1 || Orient > 3 ) + { es.text = "The orientation must be 1, 2 or 3." ; + error = 3 ; } + if ( error != 0 ) + { + es.type = SALOME::BAD_PARAM; + throw SALOME::SALOME_Exception(es); + return 0; + }; +// + double Xmini, Xmaxi ; + double Ymini, Ymaxi ; + double Zmini, Zmaxi ; + if ( Orient == 1 ) + { Xmini = Umini ; + Xmaxi = Umaxi ; + Ymini = Vmini ; + Ymaxi = Vmaxi ; + Zmini = 0. ; + Zmaxi = 0. ; } + else if ( Orient == 2 ) + { Xmini = 0. ; + Xmaxi = 0. ; + Ymini = Umini ; + Ymaxi = Umaxi ; + Zmini = Vmini ; + Zmaxi = Vmaxi ; } + else if ( Orient == 3 ) + { Xmini = Vmini ; + Xmaxi = Vmaxi ; + Ymini = 0. ; + Ymaxi = 0. ; + Zmini = Umini ; + Zmaxi = Umaxi ; } + else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; } + + ADAPT::HOMARD_Zone_var myZone = CreateZone(ZoneName, 10+Orient) ; + myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ; + + return ADAPT::HOMARD_Zone::_duplicate(myZone) ; +} +//============================================================================= +ADAPT::HOMARD_Zone_ptr ADAPT_Gen_i::CreateZoneDisk(const char* ZoneName, + CORBA::Double Ucentre, CORBA::Double Vcentre, + CORBA::Double Rayon, + CORBA::Long Orient) +{ + INFOS ("CreateZoneDisk : ZoneName = " << ZoneName ) ; +// + SALOME::ExceptionStruct es; + int error = 0 ; + if ( Rayon <= 0.0 ) + { es.text = "The radius must be positive." ; + error = 1 ; } + if ( Orient < 1 || Orient > 3 ) + { es.text = "The orientation must be 1, 2 or 3." ; + error = 3 ; } + if ( error != 0 ) + { + es.type = SALOME::BAD_PARAM; + throw SALOME::SALOME_Exception(es); + return 0; + }; +// + double Xcentre ; + double Ycentre ; + double Zcentre ; + if ( Orient == 1 ) + { Xcentre = Ucentre ; + Ycentre = Vcentre ; + Zcentre = 0. ; } + else if ( Orient == 2 ) + { Xcentre = 0. ; + Ycentre = Ucentre ; + Zcentre = Vcentre ; } + else if ( Orient == 3 ) + { Xcentre = Vcentre ; + Ycentre = 0. ; + Zcentre = Ucentre ; } + else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; } + + ADAPT::HOMARD_Zone_var myZone = CreateZone(ZoneName, 30+Orient) ; + myZone->SetCylinder( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1. ) ; + + return ADAPT::HOMARD_Zone::_duplicate(myZone) ; +} +//============================================================================= +ADAPT::HOMARD_Zone_ptr ADAPT_Gen_i::CreateZoneDiskWithHole(const char* ZoneName, + CORBA::Double Ucentre, CORBA::Double Vcentre, + CORBA::Double Rayon, CORBA::Double Rayonint, + CORBA::Long Orient) +{ + INFOS ("CreateZoneDiskWithHole : ZoneName = " << ZoneName ) ; +// + SALOME::ExceptionStruct es; + int error = 0 ; + if ( Rayon <= 0.0 || Rayonint <= 0.0 ) + { es.text = "The radius must be positive." ; + error = 1 ; } + if ( Orient < 1 || Orient > 3 ) + { es.text = "The orientation must be 1, 2 or 3." ; + error = 3 ; } + if ( Rayon <= Rayonint ) + { es.text = "The external radius must be higher than the internal radius." ; + error = 4 ; } + if ( error != 0 ) + { + es.type = SALOME::BAD_PARAM; + throw SALOME::SALOME_Exception(es); + return 0; + }; +// + double Xcentre ; + double Ycentre ; + double Zcentre ; + if ( Orient == 1 ) + { Xcentre = Ucentre ; + Ycentre = Vcentre ; + Zcentre = 0. ; } + else if ( Orient == 2 ) + { Xcentre = 0. ; + Ycentre = Ucentre ; + Zcentre = Vcentre ; } + else if ( Orient == 3 ) + { Xcentre = Vcentre ; + Ycentre = 0. ; + Zcentre = Ucentre ; } + else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; } + + ADAPT::HOMARD_Zone_var myZone = CreateZone(ZoneName, 60+Orient) ; + myZone->SetPipe( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1., Rayonint ) ; + + return ADAPT::HOMARD_Zone::_duplicate(myZone) ; +} +//============================================================================= +//============================================================================= + + + + +//============================================================================= +//============================================================================= +// Traitement d'une iteration +// etatMenage = 1 : destruction du répertoire d'execution +// modeHOMARD = 1 : adaptation +// != 1 : information avec les options modeHOMARD +// Option1 >0 : appel depuis python +// <0 : appel depuis GUI +// Option2 : multiple de nombres premiers +// 1 : aucune option +// x2 : publication du maillage dans SMESH +//============================================================================= +CORBA::Long ADAPT_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMenage, CORBA::Long modeHOMARD, CORBA::Long Option1, CORBA::Long Option2) +{ + INFOS ( "Compute : traitement de " << NomIteration << ", avec modeHOMARD = " << modeHOMARD << ", Option1 = " << Option1 << ", Option2 = " << Option2 ); + + // A. Prealable + int codret = 0; + + // A.1. L'objet iteration + ADAPT::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[NomIteration]; + ASSERT(!CORBA::is_nil(myIteration)); + + // A.2. Controle de la possibilite d'agir + // A.2.1. Etat de l'iteration + int etat = myIteration->GetState(); + MESSAGE ( "etat = "<GetNumber(); + std::string siterp1 ; + std::stringstream saux1 ; + saux1 << NumeIter ; + siterp1 = saux1.str() ; + if (NumeIter < 10) { siterp1 = "0" + siterp1 ; } + + std::string siter ; + if ( modeHOMARD==1 ) + { + std::stringstream saux0 ; + int iaux = max(0, NumeIter-1) ; + saux0 << iaux ; + siter = saux0.str() ; + if (NumeIter < 11) { siter = "0" + siter ; } + } + else + { siter = siterp1 ; } + + // A.4. Le cas + const char* nomCas = myIteration->GetCaseName(); + ADAPT::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas]; + ASSERT(!CORBA::is_nil(myCase)); + + // B. Les répertoires + // B.1. Le répertoire courant + std::string nomDirWork = getenv("PWD") ; + // B.2. Le sous-répertoire de l'iteration a traiter + char* DirCompute = ComputeDirManagement(myCase, myIteration, etatMenage); + MESSAGE( ". DirCompute = " << DirCompute ); + + // C. Le fichier des messages + // C.1. Le deroulement de l'execution de HOMARD + std::string LogFile = DirCompute ; + LogFile += "/Liste" ; + if ( modeHOMARD == 1 ) { LogFile += "." + siter + ".vers." + siterp1 ; } + LogFile += ".log" ; + MESSAGE (". LogFile = " << LogFile); + if ( modeHOMARD == 1 ) { myIteration->SetLogFile(LogFile.c_str()); } + // C.2. Le bilan de l'analyse du maillage + std::string FileInfo = DirCompute ; + FileInfo += "/" ; + if ( modeHOMARD == 1 ) { FileInfo += "apad" ; } + else + { if ( NumeIter == 0 ) { FileInfo += "info_av" ; } + else { FileInfo += "info_ap" ; } + } + FileInfo += "." + siterp1 + ".bilan" ; + myIteration->SetFileInfo(FileInfo.c_str()); + + // D. On passe dans le répertoire de l'iteration a calculer + MESSAGE ( ". On passe dans DirCompute = " << DirCompute ); + CHDIR(DirCompute); + + // E. Les données de l'exécution HOMARD + // E.1. L'objet du texte du fichier de configuration + HomardDriver* myDriver = new HomardDriver(siter, siterp1); + myDriver->TexteInit(DirCompute, LogFile, _Langue); + + // E.2. Le maillage associe a l'iteration + const char* NomMesh = myIteration->GetMeshName(); + MESSAGE ( ". NomMesh = " << NomMesh ); + const char* MeshFile = myIteration->GetMeshFile(); + MESSAGE ( ". MeshFile = " << MeshFile ); + + // E.3. Les données du traitement HOMARD + int iaux ; + if ( modeHOMARD == 1 ) + { + iaux = 1 ; + myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ; + myDriver->TexteMaillage(NomMesh, MeshFile, 1); + codret = ComputeAdap(myCase, myIteration, etatMenage, myDriver, Option1, Option2) ; + } + else + { + InvalideIterInfo(NomIteration); + myDriver->TexteInfo( modeHOMARD, NumeIter ) ; + iaux = 0 ; + myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ; + myDriver->TexteMaillage(NomMesh, MeshFile, 0); + myDriver->CreeFichierDonn(); + } + + // E.4. Ajout des informations liees a l'eventuel suivi de frontiere + int BoundaryOption = DriverTexteBoundary(myCase, myDriver) ; + + // E.5. Ecriture du texte dans le fichier + MESSAGE ( ". Ecriture du texte dans le fichier de configuration ; codret = "<CreeFichier(); } + +// G. Execution +// + int codretexec = 1789 ; + if (codret == 0) + { + codretexec = myDriver->ExecuteHomard(Option1); +// + MESSAGE ( "Erreur en executant HOMARD : " << codretexec ); + // En mode adaptation, on ajuste l'etat de l'iteration + if ( modeHOMARD == 1 ) + { + if (codretexec == 0) { SetEtatIter(NomIteration,2); } + else { SetEtatIter(NomIteration,1); } + // GERALD -- QMESSAGE BOX + } + } + + // H. Gestion des resultats + if (codret == 0) + { + std::string Commentaire ; + // H.1. Le fichier des messages, dans tous les cas + Commentaire = "log" ; + if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; } + else { Commentaire += "Info" ; } + PublishFileUnderIteration(NomIteration, LogFile.c_str(), Commentaire.c_str()); + + // H.2. Si tout s'est bien passe : + if (codretexec == 0) + { + // H.2.1. Le fichier de bilan + Commentaire = "Summary" ; + if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; } + else { Commentaire += "Info" ; } + PublishFileUnderIteration(NomIteration, FileInfo.c_str(), Commentaire.c_str()); + // H.2.2. Le fichier de maillage obtenu + if ( modeHOMARD == 1 ) + { + std::stringstream saux0 ; + Commentaire = "Mesh" ; + Commentaire += " " + siterp1 ; + PublishFileUnderIteration(NomIteration, MeshFile, Commentaire.c_str()); + if ( Option2 % 2 == 0 ) { PublishResultInSmesh(MeshFile, 1); } + } + } + // H.3 Message d'erreur + if (codretexec != 0) + { + std::string text = "" ; + // Message d'erreur en cas de probleme en adaptation + if ( modeHOMARD == 1 ) + { + text = "Error during the adaptation.\n" ; + bool stopvu = false ; + std::ifstream fichier( LogFile.c_str() ); + if ( fichier ) // ce test échoue si le fichier n'est pas ouvert + { + std::string ligne; // variable contenant chaque ligne lue + while ( std::getline( fichier, ligne ) ) + { +// INFOS(ligne); + if ( stopvu ) + { text += ligne+ "\n"; } + else + { + int position = ligne.find( "===== HOMARD ===== STOP =====" ) ; + if ( position > 0 ) { stopvu = true ; } + } + } + } + } + text += "\n\nSee the file " + LogFile + "\n" ; + INFOS ( text ) ; + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); +// + // En mode information, on force le succes pour pouvoir consulter le fichier log + if ( modeHOMARD != 1 ) { codretexec = 0 ; } + } + } + + // I. Menage et retour dans le répertoire du cas + if (codret == 0) + { + delete myDriver; + MESSAGE ( ". On retourne dans nomDirWork = " << nomDirWork ); + + CHDIR(nomDirWork.c_str()); + } + + // J. Suivi de la frontière CAO +// std::cout << "- codret : " << codret << std::endl; +// std::cout << "- modeHOMARD : " << modeHOMARD << std::endl; +// std::cout << "- BoundaryOption : " << BoundaryOption << std::endl; +// std::cout << "- codretexec : " << codretexec << std::endl; + if (codret == 0) + { + if ( ( modeHOMARD == 1 ) && ( BoundaryOption % 5 == 0 ) && (codretexec == 0) ) + { + INFOS ( "Suivi de frontière CAO" ); + codret = ComputeCAO(myCase, myIteration, Option1, Option2) ; + } + } + + return codretexec ; +} +//============================================================================= +// Calcul d'une iteration : partie spécifique à l'adaptation +//============================================================================= +CORBA::Long ADAPT_Gen_i::ComputeAdap(ADAPT::HOMARD_Cas_var myCase, ADAPT::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage, HomardDriver* myDriver, CORBA::Long Option1, CORBA::Long Option2) +{ + MESSAGE ( "ComputeAdap avec Option1 = " << Option1 << ", Option2 = " << Option2 ); + + // A. Prealable + // A.1. Bases + int codret = 0; + // Numero de l'iteration + int NumeIter = myIteration->GetNumber(); + std::stringstream saux0 ; + saux0 << NumeIter-1 ; + std::string siter = saux0.str() ; + if (NumeIter < 11) { siter = "0" + siter ; } + + // A.2. On verifie qu il y a une hypothese (erreur improbable); + const char* nomHypo = myIteration->GetHypoName(); + if (std::string(nomHypo) == std::string("")) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "This iteration does not have any associated hypothesis."; + throw SALOME::SALOME_Exception(es); + return 2; + }; + ADAPT::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo]; + ASSERT(!CORBA::is_nil(myHypo)); + + // B. L'iteration parent + const char* nomIterationParent = myIteration->GetIterParentName(); + ADAPT::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterationParent]; + ASSERT(!CORBA::is_nil(myIterationParent)); + // Si l'iteration parent n'est pas calculee, on le fait (recursivite amont) + if ( myIterationParent->GetState() == 1 ) + { + int iaux = 1 ; + int codret = Compute(nomIterationParent, etatMenage, iaux, Option1, Option2); + if (codret != 0) + { + // GERALD -- QMESSAGE BOX + VERIFICATION("Pb au calcul de l'iteration precedente" == 0); + } + }; + + // C. Le sous-répertoire de l'iteration precedente + char* DirComputePa = ComputeDirPaManagement(myCase, myIteration); + MESSAGE( ". DirComputePa = " << DirComputePa ); + + // D. Les données de l'adaptation HOMARD + // D.1. Le type de conformite + int ConfType = myCase->GetConfType(); + MESSAGE ( ". ConfType = " << ConfType ); + + // D.1. Le type externe + int ExtType = myCase->GetExtType(); + MESSAGE ( ". ExtType = " << ExtType ); + + // D.3. Le maillage de depart + const char* NomMeshParent = myIterationParent->GetMeshName(); + MESSAGE ( ". NomMeshParent = " << NomMeshParent ); + const char* MeshFileParent = myIterationParent->GetMeshFile(); + MESSAGE ( ". MeshFileParent = " << MeshFileParent ); + + // D.4. Le maillage associe a l'iteration + const char* MeshFile = myIteration->GetMeshFile(); + MESSAGE ( ". MeshFile = " << MeshFile ); + FILE *file = fopen(MeshFile,"r"); + if (file != NULL) + { + fclose(file); + if (etatMenage == 0) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + std::string text = "MeshFile : " + std::string(MeshFile) + " already exists "; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + return 4; + } + else + { + std::string commande = "rm -f " + std::string(MeshFile); + codret = system(commande.c_str()); + if (codret != 0) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "The mesh file cannot be deleted."; + throw SALOME::SALOME_Exception(es); + return 5; + } + } + } + + // D.5. Les types de raffinement et de deraffinement + // Les appels corba sont lourds, il vaut mieux les grouper + ADAPT::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef(); + ASSERT(ListTypes->length() == 3); + int TypeAdap = (*ListTypes)[0]; + int TypeRaff = (*ListTypes)[1]; + int TypeDera = (*ListTypes)[2]; +// MESSAGE ( ". TypeAdap = " << TypeAdap << ", TypeRaff = " << TypeRaff << ", TypeDera = " << TypeDera ); + + // E. Texte du fichier de configuration + // E.1. Incontournables du texte + myDriver->TexteAdap(ExtType); + int iaux = 0 ; + myDriver->TexteMaillageHOMARD( DirComputePa, siter, iaux ) ; + myDriver->TexteMaillage(NomMeshParent, MeshFileParent, 0); + myDriver->TexteConfRaffDera(ConfType, TypeAdap, TypeRaff, TypeDera); + + // E.2. Ajout des informations liees aux zones eventuelles + if ( TypeAdap == 0 ) + { DriverTexteZone(myHypo, myDriver) ; } + + // E.3. Ajout des informations liees aux champs eventuels + if ( TypeAdap == 1 ) + { DriverTexteField(myIteration, myHypo, myDriver) ; } + + // E.4. Ajout des informations liees au filtrage eventuel par les groupes + ADAPT::ListGroupType* listeGroupes = myHypo->GetGroups(); + int numberOfGroups = listeGroupes->length(); + MESSAGE( ". Filtrage par " << numberOfGroups << " groupes"); + if (numberOfGroups > 0) + { + for (int NumGroup = 0; NumGroup< numberOfGroups; NumGroup++) + { + std::string GroupName = std::string((*listeGroupes)[NumGroup]); + MESSAGE( "... GroupName = " << GroupName ); + myDriver->TexteGroup(GroupName); + } + } + + // E.5. Ajout des informations liees a l'eventuelle interpolation des champs + DriverTexteFieldInterp(myIteration, myHypo, myDriver) ; + + // E.6. Ajout des options avancees + int Pyram = myCase->GetPyram(); + MESSAGE ( ". Pyram = " << Pyram ); + int NivMax = myHypo->GetNivMax(); + MESSAGE ( ". NivMax = " << NivMax ); + double DiamMin = myHypo->GetDiamMin() ; + MESSAGE ( ". DiamMin = " << DiamMin ); + int AdapInit = myHypo->GetAdapInit(); + MESSAGE ( ". AdapInit = " << AdapInit ); + int ExtraOutput = myHypo->GetExtraOutput(); + MESSAGE ( ". ExtraOutput = " << ExtraOutput ); + myDriver->TexteAdvanced(Pyram, NivMax, DiamMin, AdapInit, ExtraOutput); + + // E.7. Ajout des informations sur le deroulement de l'execution + int MessInfo = myIteration->GetInfoCompute(); + MESSAGE ( ". MessInfo = " << MessInfo ); + myDriver->TexteInfoCompute(MessInfo); + + return codret ; +} +//============================================================================= +// Calcul d'une iteration : partie spécifique au suivi de frontière CAO +//============================================================================= +CORBA::Long ADAPT_Gen_i::ComputeCAO(ADAPT::HOMARD_Cas_var myCase, ADAPT::HOMARD_Iteration_var myIteration, CORBA::Long Option1, CORBA::Long Option2) +{ + MESSAGE ( "ComputeCAO avec Option1 = " << Option1 << ", Option2 = " << Option2 ); + + // A. Prealable + // A.1. Bases + int codret = 0; + // A.2. Le sous-répertoire de l'iteration en cours de traitement + char* DirCompute = myIteration->GetDirName(); + // A.3. Le maillage résultat de l'iteration en cours de traitement + char* MeshFile = myIteration->GetMeshFile(); + + // B. Les données pour FrontTrack + // B.1. Le maillage à modifier + const std::string theInputMedFile = MeshFile; + MESSAGE ( ". theInputMedFile = " << theInputMedFile ); + + // B.2. Le maillage après modification : fichier identique + const std::string theOutputMedFile = MeshFile ; + MESSAGE ( ". theOutputMedFile = " << theInputMedFile ); + + // B.3. La liste des fichiers contenant les numéros des noeuds à bouger + std::vector< std::string > theInputNodeFiles ; + MESSAGE ( ". DirCompute = " << DirCompute ); + int bilan ; + int icpt = 0 ; +#ifndef WIN32 + DIR *dp; + struct dirent *dirp; + dp = opendir(DirCompute); + while ( (dirp = readdir(dp)) != NULL ) + { + std::string file_name(dirp->d_name); + bilan = file_name.find("fr") ; + if ( bilan != string::npos ) + { + std::stringstream filename_total ; + filename_total << DirCompute << "/" << file_name ; + theInputNodeFiles.push_back(filename_total.str()) ; + icpt += 1 ; + } + } +#else + HANDLE hFind = INVALID_HANDLE_VALUE; + WIN32_FIND_DATA ffd; + hFind = FindFirstFile(DirNameStart, &ffd); + if (INVALID_HANDLE_VALUE != hFind) { + while (FindNextFile(hFind, &ffd) != 0) { + std::string file_name(ffd.cFileName); + bilan = file_name.find("fr") ; + if ( bilan != string::npos ) + { + std::stringstream filename_total ; + filename_total << DirCompute << "/" << file_name ; + theInputNodeFiles.push_back(filename_total.str()) ; + icpt += 1 ; + } + } + FindClose(hFind); + } +#endif + for ( int i = 0; i < icpt; i++ ) + { MESSAGE ( ". theInputNodeFiles["<< i << "] = " << theInputNodeFiles[i] ); } + + // B.4. Le fichier de la CAO + ADAPT::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup(); + std::string BoundaryName = std::string((*ListBoundaryGroupType)[0]); + MESSAGE ( ". BoundaryName = " << BoundaryName ); + ADAPT::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName]; + const std::string theXaoFileName = myBoundary->GetDataFile(); + MESSAGE ( ". theXaoFileName = " << theXaoFileName ); + + // B.5. Parallélisme + bool theIsParallel = false; + + // C. Lancement des projections + MESSAGE ( ". Lancement des projections" ); + FrontTrack* myFrontTrack = new FrontTrack(); + myFrontTrack->track(theInputMedFile, theOutputMedFile, theInputNodeFiles, theXaoFileName, theIsParallel); + + // D. Transfert des coordonnées modifiées dans le fichier historique de HOMARD + // On lance une exécution spéciale de HOMARD en attendant de savoir le faire avec MEDCoupling + MESSAGE ( ". Transfert des coordonnées" ); + codret = ComputeCAObis(myIteration, Option1, Option2) ; + + return codret ; +} +//============================================================================= +//============================================================================= +// Transfert des coordonnées en suivi de frontière CAO +// Option1 >0 : appel depuis python +// <0 : appel depuis GUI +// Option2 : multiple de nombres premiers +// 1 : aucune option +// x2 : publication du maillage dans SMESH +//============================================================================= +CORBA::Long ADAPT_Gen_i::ComputeCAObis(ADAPT::HOMARD_Iteration_var myIteration, CORBA::Long Option1, CORBA::Long Option2) +{ + MESSAGE ( "ComputeCAObis, avec Option1 = " << Option1 << ", Option2 = " << Option2 ); + + // A. Prealable + int codret = 0; + + // A.1. Controle de la possibilite d'agir + // A.1.1. Etat de l'iteration + int etat = myIteration->GetState(); + MESSAGE ( "etat = "<GetNumber(); + std::string siterp1 ; + std::stringstream saux1 ; + saux1 << NumeIter ; + siterp1 = saux1.str() ; + if (NumeIter < 10) { siterp1 = "0" + siterp1 ; } + MESSAGE ( "siterp1 = "<GetCaseName(); + ADAPT::HOMARD_Cas_var myCase = myStudyContext._mesCas[CaseName]; + ASSERT(!CORBA::is_nil(myCase)); + + // A.4. Le sous-répertoire de l'iteration a traiter + char* DirCompute = myIteration->GetDirName(); + MESSAGE( ". DirCompute = " << DirCompute ); + + // C. Le fichier des messages + std::string LogFile = DirCompute ; + LogFile += "/Liste." + siterp1 + ".maj_coords.log" ; + MESSAGE (". LogFile = " << LogFile); + myIteration->SetFileInfo(LogFile.c_str()); + + // D. On passe dans le répertoire de l'iteration a calculer + MESSAGE ( ". On passe dans DirCompute = " << DirCompute ); + CHDIR(DirCompute); + + // E. Les données de l'exécution HOMARD + // E.1. L'objet du texte du fichier de configuration + HomardDriver* myDriver = new HomardDriver("", siterp1); + myDriver->TexteInit(DirCompute, LogFile, _Langue); + + // E.2. Le maillage associe a l'iteration + const char* NomMesh = myIteration->GetMeshName(); + MESSAGE ( ". NomMesh = " << NomMesh ); + const char* MeshFile = myIteration->GetMeshFile(); + MESSAGE ( ". MeshFile = " << MeshFile ); + + // E.3. Les données du traitement HOMARD + int iaux ; + myDriver->TexteMajCoords( NumeIter ) ; + iaux = 0 ; + myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ; + myDriver->TexteMaillage(NomMesh, MeshFile, 0); +// + // E.4. Ecriture du texte dans le fichier + MESSAGE ( ". Ecriture du texte dans le fichier de configuration ; codret = "<CreeFichier(); } + +// F. Execution +// + int codretexec = 1789 ; + if (codret == 0) + { + codretexec = myDriver->ExecuteHomard(Option1); + MESSAGE ( "Erreur en executant HOMARD : " << codretexec ); + } + + // G. Gestion des resultats + if (codret == 0) + { + // G.1. Le fichier des messages, dans tous les cas + const char* NomIteration = myIteration->GetName(); + std::string Commentaire = "logmaj_coords" ; + PublishFileUnderIteration(NomIteration, LogFile.c_str(), Commentaire.c_str()); + // G.2 Message d'erreur + if (codretexec != 0) + { + std::string text = "\n\nSee the file " + LogFile + "\n" ; + INFOS ( text ) ; + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + + // On force le succes pour pouvoir consulter le fichier log + codretexec = 0 ; + } + } + + // H. Menage et retour dans le répertoire du cas + if (codret == 0) { delete myDriver; } + + return codret ; +} +//============================================================================= +// Creation d'un nom de sous-répertoire pour l'iteration au sein d'un répertoire parent +// nomrep : nom du répertoire parent +// num : le nom du sous-répertoire est sous la forme 'In', n est >= num +//============================================================================= +char* ADAPT_Gen_i::CreateDirNameIter(const char* nomrep, CORBA::Long num ) +{ + MESSAGE ( "CreateDirNameIter : nomrep ="<< nomrep << ", num = "<d_name); +#else + HANDLE hFind = INVALID_HANDLE_VALUE; + WIN32_FIND_DATA ffd; + hFind = FindFirstFile(nomrep, &ffd); + if (INVALID_HANDLE_VALUE != hFind) { + while (FindNextFile(hFind, &ffd) != 0) { + if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories + std::string file_name(ffd.cFileName); +#endif + if ( file_name == DirNameA.str() ) { existe = true ; } + } +#ifndef WIN32 + closedir(dp); +#else + FindClose(hFind); +#endif + if ( !existe ) + { + DirName = DirNameA.str() ; + a_chercher = false ; + break ; + } + } + num += 1; + } + + MESSAGE ( "==> DirName = " << DirName); + MESSAGE ( ". On retourne dans nomDirActuel = " << nomDirActuel ); + CHDIR(nomDirActuel.c_str()); + return CORBA::string_dup( DirName.c_str() ); +} +//============================================================================= +// Calcul d'une iteration : gestion du répertoire de calcul +// Si le sous-répertoire existe : +// etatMenage = 0 : on sort en erreur si le répertoire n'est pas vide +// etatMenage = 1 : on fait le menage du répertoire +// etatMenage = -1 : on ne fait rien +//============================================================================= +char* ADAPT_Gen_i::ComputeDirManagement(ADAPT::HOMARD_Cas_var myCase, ADAPT::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage) +{ + MESSAGE ( "ComputeDirManagement : répertoires pour le calcul" ); + // B.2. Le répertoire du cas + const char* nomDirCase = myCase->GetDirName(); + MESSAGE ( ". nomDirCase = " << nomDirCase ); + + // B.3. Le sous-répertoire de l'iteration a calculer, puis le répertoire complet a creer + // B.3.1. Le nom du sous-répertoire + const char* nomDirIt = myIteration->GetDirNameLoc(); + + // B.3.2. Le nom complet du sous-répertoire + std::stringstream DirCompute ; + DirCompute << nomDirCase << "/" << nomDirIt; + MESSAGE (". DirCompute = " << DirCompute.str() ); + + // B.3.3. Si le sous-répertoire n'existe pas, on le cree + if (CHDIR(DirCompute.str().c_str()) != 0) + { +#ifndef WIN32 + if (mkdir(DirCompute.str().c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0) +#else + if (_mkdir(DirCompute.str().c_str()) != 0) +#endif + { + // GERALD -- QMESSAGE BOX + std::cerr << "Pb Creation du répertoire DirCompute = " << DirCompute.str() << std::endl; + VERIFICATION("Pb a la creation du répertoire" == 0); + } + } + else + { +// Le répertoire existe +// On demande de faire le menage de son contenu : + if (etatMenage == 1) + { + MESSAGE (". Menage du répertoire DirCompute = " << DirCompute.str()); + std::string commande = "rm -rf " + DirCompute.str()+"/*" ; + int codret = system(commande.c_str()); + if (codret != 0) + { + // GERALD -- QMESSAGE BOX + std::cerr << ". Menage du répertoire de calcul" << DirCompute.str() << std::endl; + VERIFICATION("Pb au menage du répertoire de calcul" == 0); + } + } +// On n'a pas demande de faire le menage de son contenu : on sort en erreur : + else + { + if (etatMenage == 0) + { +#ifndef WIN32 + DIR *dp; + struct dirent *dirp; + dp = opendir(DirCompute.str().c_str()); + bool result = true; + while ((dirp = readdir(dp)) != NULL && result ) + { + std::string file_name(dirp->d_name); + result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false + } + closedir(dp); +#else + HANDLE hFind = INVALID_HANDLE_VALUE; + WIN32_FIND_DATA ffd; + hFind = FindFirstFile(DirCompute.str().c_str(), &ffd); + bool result = true; + if (INVALID_HANDLE_VALUE != hFind) { + while (FindNextFile(hFind, &ffd) != 0) { + if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories + std::string file_name(ffd.cFileName); + result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false + } + } + FindClose(hFind); +#endif + if ( result == false) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + std::string text = "Directory : " + DirCompute.str() + " is not empty"; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + VERIFICATION("Directory is not empty" == 0); + } + } + } + } + + return CORBA::string_dup( DirCompute.str().c_str() ); +} +//============================================================================= +// Calcul d'une iteration : gestion du répertoire de calcul de l'iteration parent +//============================================================================= +char* ADAPT_Gen_i::ComputeDirPaManagement(ADAPT::HOMARD_Cas_var myCase, ADAPT::HOMARD_Iteration_var myIteration) +{ + MESSAGE ( "ComputeDirPaManagement : répertoires pour le calcul" ); + // Le répertoire du cas + const char* nomDirCase = myCase->GetDirName(); + MESSAGE ( ". nomDirCase = " << nomDirCase ); + + // Le sous-répertoire de l'iteration precedente + + const char* nomIterationParent = myIteration->GetIterParentName(); + ADAPT::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterationParent]; + const char* nomDirItPa = myIterationParent->GetDirNameLoc(); + std::stringstream DirComputePa ; + DirComputePa << nomDirCase << "/" << nomDirItPa; + MESSAGE( ". nomDirItPa = " << nomDirItPa); + MESSAGE( ". DirComputePa = " << DirComputePa.str() ); + + return CORBA::string_dup( DirComputePa.str().c_str() ); +} +//============================================================================= +// Calcul d'une iteration : ecriture des zones dans le fichier de configuration +//============================================================================= +void ADAPT_Gen_i::DriverTexteZone(ADAPT::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver) +{ + MESSAGE ( "... DriverTexteZone" ); + ADAPT::listeZonesHypo* ListZone = myHypo->GetZones(); + int numberOfZonesx2 = ListZone->length(); + int NumZone ; + + for (int iaux = 0; iaux< numberOfZonesx2; iaux++) + { + std::string ZoneName = std::string((*ListZone)[iaux]); + MESSAGE ( "... ZoneName = " << ZoneName); + ADAPT::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName]; + ASSERT(!CORBA::is_nil(myZone)); + + int ZoneType = myZone->GetType(); + std::string TypeUsestr = std::string((*ListZone)[iaux+1]); + int TypeUse = atoi( TypeUsestr.c_str() ); + MESSAGE ( "... ZoneType = " << ZoneType << ", TypeUse = "<GetCoords(); + if ( ZoneType == 2 || ( ZoneType>=11 && ZoneType <=13 ) ) // Cas d un parallelepipede ou d'un rectangle + { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], 0., 0., 0.); } + else if ( ZoneType == 4 ) // Cas d une sphere + { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], 0., 0., 0., 0., 0.); } + else if ( ZoneType == 5 || ( ZoneType>=31 && ZoneType <=33 ) ) // Cas d un cylindre ou d'un disque + { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], 0.); } + else if ( ZoneType == 7 || ( ZoneType>=61 && ZoneType <=63 ) ) // Cas d un tuyau ou disque perce + { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], (*zone)[8]); } + else { VERIFICATION("ZoneType est incorrect." == 0) ; } + iaux += 1 ; + } + return ; +} +//============================================================================= +// Calcul d'une iteration : ecriture des champs dans le fichier de configuration +//============================================================================= +void ADAPT_Gen_i::DriverTexteField(ADAPT::HOMARD_Iteration_var myIteration, ADAPT::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver) +{ + MESSAGE ( "... DriverTexteField" ); +// Le fichier du champ + char* FieldFile = myIteration->GetFieldFile(); + MESSAGE ( ". FieldFile = " << FieldFile ); + if (strlen(FieldFile) == 0) + { + // GERALD -- QMESSAGE BOX + std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl; + VERIFICATION("The file for the field is not given." == 0); + } +// Les caracteristiques d'instants du champ de pilotage + int TimeStep = myIteration->GetTimeStep(); + MESSAGE( ". TimeStep = " << TimeStep ); + int Rank = myIteration->GetRank(); + MESSAGE( ". Rank = " << Rank ); +// Les informations sur les champs + ADAPT::InfosHypo* aInfosHypo = myHypo->GetField(); +// Le nom + const char* FieldName = aInfosHypo->FieldName; +// Les seuils + int TypeThR = aInfosHypo->TypeThR; + double ThreshR = aInfosHypo->ThreshR; + int TypeThC = aInfosHypo->TypeThC; + double ThreshC = aInfosHypo->ThreshC; +// Saut entre mailles ou non ? + int UsField = aInfosHypo->UsField; + MESSAGE( ". UsField = " << UsField ); +// L'usage des composantes + int UsCmpI = aInfosHypo->UsCmpI; + MESSAGE( ". UsCmpI = " << UsCmpI ); +// + myDriver->TexteField(FieldName, FieldFile, TimeStep, Rank, TypeThR, ThreshR, TypeThC, ThreshC, UsField, UsCmpI); +// +// Les composantes + ADAPT::listeComposantsHypo* mescompo = myHypo->GetComps(); + int numberOfCompos = mescompo->length(); + MESSAGE( ". numberOfCompos = " << numberOfCompos ); + for (int NumeComp = 0; NumeComp< numberOfCompos; NumeComp++) + { + std::string nomCompo = std::string((*mescompo)[NumeComp]); + MESSAGE( "... nomCompo = " << nomCompo ); + myDriver->TexteCompo(NumeComp, nomCompo); + } + return ; +} +//============================================================================= +// Calcul d'une iteration : ecriture des frontieres dans le fichier de configuration +// On ecrit dans l'ordre : +// 1. la definition des frontieres +// 2. les liens avec les groupes +// 3. un entier resumant le type de comportement pour les frontieres +//============================================================================= +int ADAPT_Gen_i::DriverTexteBoundary(ADAPT::HOMARD_Cas_var myCase, HomardDriver* myDriver) +{ + MESSAGE ( "... DriverTexteBoundary" ); + // 1. Recuperation des frontieres + std::list ListeBoundaryTraitees ; + ADAPT::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup(); + int numberOfitems = ListBoundaryGroupType->length(); + MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems); + int BoundaryOption = 1 ; + // 2. Parcours des frontieres pour ecrire leur description + int NumBoundaryAnalytical = 0 ; + for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2) + { + std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]); + MESSAGE ( "... BoundaryName = " << BoundaryName); + // 2.1. La frontiere a-t-elle deja ete ecrite ? + // Cela arrive quand elle est liee a plusieurs groupes. Il ne faut l'ecrire que la premiere fois + int A_faire = 1 ; + std::list::const_iterator it = ListeBoundaryTraitees.begin(); + while (it != ListeBoundaryTraitees.end()) + { + MESSAGE ( "..... BoundaryNameTraitee = " << *it); + if ( BoundaryName == *it ) { A_faire = 0 ; } + it++; + } + // 2.2. Ecriture de la frontiere + if ( A_faire == 1 ) + { + // 2.2.1. Caracteristiques de la frontiere + ADAPT::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName]; + ASSERT(!CORBA::is_nil(myBoundary)); + int BoundaryType = myBoundary->GetType(); + MESSAGE ( "... BoundaryType = " << BoundaryType ); + // 2.2.2. Ecriture selon le type + // 2.2.2.1. Cas d une frontiere CAO + if (BoundaryType == -1) + { +// const char* CAOFile = myBoundary->GetDataFile() ; +// MESSAGE ( ". CAOFile = " << CAOFile ); + if ( BoundaryOption % 5 != 0 ) { BoundaryOption = BoundaryOption*5 ; } + } + // 2.2.2.2. Cas d une frontiere discrete + else if (BoundaryType == 0) + { + const char* MeshName = myBoundary->GetMeshName() ; + MESSAGE ( ". MeshName = " << MeshName ); + const char* MeshFile = myBoundary->GetDataFile() ; + MESSAGE ( ". MeshFile = " << MeshFile ); + myDriver->TexteBoundaryDi( MeshName, MeshFile); + if ( BoundaryOption % 2 != 0 ) { BoundaryOption = BoundaryOption*2 ; } + } + // 2.2.2.3. Cas d une frontiere analytique + else + { + NumBoundaryAnalytical++ ; + ADAPT::double_array* coor = myBoundary->GetCoords(); + if (BoundaryType == 1) // Cas d un cylindre + { + myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.); + if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; } + } + else if (BoundaryType == 2) // Cas d une sphere + { + myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], 0., 0., 0., 0.); + if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; } + } + else if (BoundaryType == 3) // Cas d un cone defini par un axe et un angle + { + myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.); + if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; } + } + else if (BoundaryType == 4) // Cas d un cone defini par les 2 rayons + { + myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]); + if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; } + } + else if (BoundaryType == 5) // Cas d un tore + { + myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]); + if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; } + } + } + // 2.2.3. Memorisation du traitement + ListeBoundaryTraitees.push_back( BoundaryName ); + } + } + // 3. Parcours des frontieres pour ecrire les liens avec les groupes + NumBoundaryAnalytical = 0 ; + for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2) + { + std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]); + MESSAGE ( "... BoundaryName = " << BoundaryName); + ADAPT::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName]; + ASSERT(!CORBA::is_nil(myBoundary)); + int BoundaryType = myBoundary->GetType(); + MESSAGE ( "... BoundaryType = " << BoundaryType ); + // 3.1. Recuperation du nom du groupe + std::string GroupName = std::string((*ListBoundaryGroupType)[NumBoundary+1]); + MESSAGE ( "... GroupName = " << GroupName); + // 3.2. Cas d une frontiere CAO + if ( BoundaryType == -1 ) + { + if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryCAOGr ( GroupName ) ; } + } + // 3.3. Cas d une frontiere discrete + else if ( BoundaryType == 0 ) + { + if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryDiGr ( GroupName ) ; } + } + // 3.4. Cas d une frontiere analytique + else + { + NumBoundaryAnalytical++ ; + myDriver->TexteBoundaryAnGr ( BoundaryName, NumBoundaryAnalytical, GroupName ) ; + } + } + // 4. Ecriture de l'option finale + myDriver->TexteBoundaryOption(BoundaryOption); +// + return BoundaryOption ; +} +//============================================================================= +// Calcul d'une iteration : ecriture des interpolations dans le fichier de configuration +//============================================================================= +void ADAPT_Gen_i::DriverTexteFieldInterp(ADAPT::HOMARD_Iteration_var myIteration, ADAPT::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver) +{ + MESSAGE ( "... DriverTexteFieldInterp" ); + int TypeFieldInterp = myHypo->GetTypeFieldInterp(); + MESSAGE ( "... TypeFieldInterp = " << TypeFieldInterp); + if (TypeFieldInterp != 0) + { +// Le fichier des champs + char* FieldFile = myIteration->GetFieldFile(); + MESSAGE ( ". FieldFile = " << FieldFile ); + if (strlen(FieldFile) == 0) + { + // GERALD -- QMESSAGE BOX + VERIFICATION("The file for the field is not given." == 0); + } + // + const char* MeshFile = myIteration->GetMeshFile(); + myDriver->TexteFieldInterp(FieldFile, MeshFile); + + // Les champs + // Interpolation de tous les champs + if ( TypeFieldInterp == 1 ) + { + myDriver->TexteFieldInterpAll(); + } + // Interpolation de certains champs + else if (TypeFieldInterp == 2) + { + // Les champs et leurs instants pour l'iteration + ADAPT::listeFieldInterpTSRsIter* ListFieldTSR = myIteration->GetFieldInterpsTimeStepRank(); + int numberOfFieldsx3 = ListFieldTSR->length(); + MESSAGE( ". pour iteration, numberOfFields = " << numberOfFieldsx3/3 ); + // Les champs pour l'hypothese + ADAPT::listeFieldInterpsHypo* ListField = myHypo->GetFieldInterps(); + int numberOfFieldsx2 = ListField->length(); + MESSAGE( ". pour hypothese, numberOfFields = " << numberOfFieldsx2/2 ); + // On parcourt tous les champs de l'hypothese + int NumField = 0 ; + for (int iaux = 0; iaux< numberOfFieldsx2; iaux++) + { + // Le nom du champ + std::string FieldName = std::string((*ListField)[iaux]) ; + // Le type d'interpolation + std::string TypeInterpstr = std::string((*ListField)[iaux+1]) ; + MESSAGE( "... FieldName = " << FieldName << ", TypeInterp = " << TypeInterpstr ); + // On cherche ?? savoir si des instants ont ??t?? pr??cis??s pour cette it??ration + int tsrvu = 0; + for (int jaux = 0; jaux< numberOfFieldsx3; jaux++) + { + // Le nom du champ + std::string FieldName2 = std::string((*ListFieldTSR)[jaux]) ; + MESSAGE( "..... FieldName2 = " << FieldName2 ); + // Quand c'est le bon champ, on ecrit le pas de temps + if ( FieldName == FieldName2 ) + { + tsrvu = 1 ; + // Le pas de temps + std::string TimeStepstr = std::string((*ListFieldTSR)[jaux+1]) ; + // Le numero d'ordre + std::string Rankstr = std::string((*ListFieldTSR)[jaux+2]) ; + MESSAGE( "..... TimeStepstr = " << TimeStepstr <<", Rankstr = "<TexteFieldInterpNameType(NumField, FieldName, TypeInterpstr, TimeStep, Rank); + } + jaux += 2 ; + } + // Si aucun instant n'a été défini + if ( tsrvu == 0 ) + { + NumField += 1 ; + myDriver->TexteFieldInterpNameType(NumField, FieldName, TypeInterpstr, -1, -1); + } + iaux++ ; + } + } + } + return ; +} +//=========================================================================== +//=========================================================================== + + +//=========================================================================== +//=========================================================================== +// Publications +//=========================================================================== +//=========================================================================== +SALOMEDS::SObject_ptr ADAPT_Gen_i::PublishInStudy(SALOMEDS::SObject_ptr theSObject, + CORBA::Object_ptr theObject, + const char* theName) +{ + MESSAGE("PublishInStudy pour " << theName); + SALOMEDS::SObject_var aResultSO; + if (CORBA::is_nil(myStudy)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid study context"; + throw SALOME::SALOME_Exception(es); + return 0; + }; + +// Recuperation de l'objet correspondant, en essayant chacun des types possibles +// Rq : Iteration est publiee ailleurs + ADAPT::HOMARD_Boundary_var aBoundary = ADAPT::HOMARD_Boundary::_narrow(theObject); + ADAPT::HOMARD_Cas_var aCase = ADAPT::HOMARD_Cas::_narrow(theObject); + ADAPT::HOMARD_Hypothesis_var aHypo = ADAPT::HOMARD_Hypothesis::_narrow(theObject); + ADAPT::HOMARD_YACS_var aYACS = ADAPT::HOMARD_YACS::_narrow(theObject); + ADAPT::HOMARD_Zone_var aZone = ADAPT::HOMARD_Zone::_narrow(theObject); + + UpdateStudy(); + +// Controle de la non publication d'un objet de meme nom + if ( (!aBoundary->_is_nil()) || (!aHypo->_is_nil()) || (!aYACS->_is_nil()) || (!aZone->_is_nil()) ) + { + SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(theName, ComponentDataType()); + if (listSO->length() >= 1) + { + MESSAGE("This name "<length()<<" time(s)"); + aResultSO = listSO[0]; + return aResultSO._retn(); + } + } + + // Caracteristiques de l'etude + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + aStudyBuilder->NewCommand(); + if(!aBoundary->_is_nil()) + aResultSO = PublishBoundaryInStudy(aStudyBuilder, aBoundary, theName); + else if(!aCase->_is_nil()) + aResultSO = PublishCaseInStudy(aStudyBuilder, aCase, theName); + else if(!aHypo->_is_nil()) + aResultSO = PublishHypotheseInStudy(aStudyBuilder, aHypo, theName); + else if(!aYACS->_is_nil()) + aResultSO = PublishYACSInStudy(aStudyBuilder, aYACS, theName); + else if(!aZone->_is_nil()) + aResultSO = PublishZoneInStudy(aStudyBuilder, aZone, theName); + + aStudyBuilder->CommitCommand(); + + return aResultSO._retn(); +}; +//============================================================================= +SALOMEDS::SObject_ptr ADAPT_Gen_i::PublishBoundaryInStudy( SALOMEDS::StudyBuilder_var aStudyBuilder, + ADAPT::HOMARD_Boundary_ptr theObject, const char* theName) +{ + MESSAGE("PublishBoundaryStudy pour "<FindComponent(ComponentDataType()); + if (theFatherHomard->_is_nil()) + { + MESSAGE("theFatherHomard->_is_nil()"); + return aResultSO._retn(); + } + + // On ajoute la categorie des boundarys dans l etude si necessaire + if ( _tag_boun == 0 ) + { + _tag_gene += 1 ; + _tag_boun = _tag_gene ; + } + MESSAGE("PublishBoundaryInStudy _tag_gene = "<<_tag_gene << ", _tag_boun = "<<_tag_boun ); + SALOMEDS::SObject_var aSObject; + if (!theFatherHomard->FindSubObject(_tag_boun, aSObject)) + { + MESSAGE("Ajout de la categorie des boundarys"); + aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_boun); + PublishInStudyAttr(aStudyBuilder, aSObject, "Boundaries", "BoundList", "zone_icone_2.png", NULL ) ; + } + else { MESSAGE("La categorie des boundarys existe deja."); } + + CORBA::Long BoundaryType = myBoundary->GetType(); +// MESSAGE("BoundaryType : "<NewObject(aSObject); + PublishInStudyAttr(aStudyBuilder, aResultSO, theName, value.c_str(), icone.c_str(), _orb->object_to_string(theObject)); + return aResultSO._retn(); +} +//============================================================================= +SALOMEDS::SObject_ptr ADAPT_Gen_i::PublishCaseInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder, + ADAPT::HOMARD_Cas_ptr theObject, const char* theName) +{ + MESSAGE("PublishCaseInStudy pour "<_is_nil()"); + return aResultSO._retn(); + } + if (myStudy->_is_nil()) { + MESSAGE("ADAPT_Gen_i::myStudy->_is_nil()"); + return aResultSO._retn(); + } + + // On recupere le module pere dans l etude + SALOMEDS::SComponent_var theFatherHomard = myStudy->FindComponent(ComponentDataType()); + if (theFatherHomard->_is_nil()) + { + MESSAGE("theFatherHomard->_is_nil()"); + return aResultSO._retn(); + } + + _tag_gene += 1 ; + MESSAGE("PublishCaseInStudy _tag_gene = "<<_tag_gene ); + aResultSO = aStudyBuilder->NewObject(theFatherHomard); + PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "CasHomard", "cas_calcule.png", + _orb->object_to_string(theObject) ) ; + + return aResultSO._retn(); +} +//============================================================================= +SALOMEDS::SObject_ptr ADAPT_Gen_i::PublishHypotheseInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder, + ADAPT::HOMARD_Hypothesis_ptr theObject, const char* theName) +{ + MESSAGE("PublishHypotheseInStudy pour "<FindComponent(ComponentDataType()); + if (theFatherHomard->_is_nil()) + { + MESSAGE("theFatherHomard->_is_nil()"); + return aResultSO._retn(); + } + + // On ajoute la categorie des hypotheses dans l etude si necessaire + SALOMEDS::SObject_var aSObject; + if ( _tag_hypo == 0 ) + { + _tag_gene += 1 ; + _tag_hypo = _tag_gene ; + } + MESSAGE("PublishHypotheseInStudy _tag_gene = "<<_tag_gene << ", _tag_hypo = "<<_tag_hypo ); + if (!theFatherHomard->FindSubObject(_tag_hypo, aSObject)) + { + MESSAGE("Ajout de la categorie des hypotheses"); + aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_hypo); + PublishInStudyAttr(aStudyBuilder, aSObject, "Hypothesis", "HypoList", "hypotheses.png", NULL); + } + else { MESSAGE("La categorie des hypotheses existe deja."); } + +// Creation du resultat dans l'etude + aResultSO = aStudyBuilder->NewObject(aSObject); + PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "HypoHomard", NULL, _orb->object_to_string(theObject) ) ; + + return aResultSO._retn(); +} +//============================================================================= +SALOMEDS::SObject_ptr ADAPT_Gen_i::PublishYACSInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder, + ADAPT::HOMARD_YACS_ptr theObject, const char* theName) +{ + MESSAGE("PublishYACSInStudy pour "<FindComponent(ComponentDataType()); + if (theFatherHomard->_is_nil()) + { + MESSAGE("theFatherHomard->_is_nil()"); + return aResultSO._retn(); + } + // On ajoute la categorie des schemas YACS dans l etude si necessaire + if ( _tag_yacs == 0 ) + { + _tag_gene += 1 ; + _tag_yacs = _tag_gene ; + } + MESSAGE("PublishZoneStudy _tag_gene = "<<_tag_gene << ", _tag_yacs = "<<_tag_yacs ); + SALOMEDS::SObject_var aSObject; + if (!theFatherHomard->FindSubObject(_tag_yacs, aSObject)) + { + MESSAGE("Ajout de la categorie des schemas YACS"); + aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_yacs); + PublishInStudyAttr(aStudyBuilder, aSObject, "YACS", "YACSList", "full_view.png", NULL); + } + else { MESSAGE("La categorie des schemas YACS existe deja."); } + +// Creation du resultat dans l'etude + aResultSO = aStudyBuilder->NewObject(aSObject); + PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "YACSHomard", "schema.png", _orb->object_to_string(theObject) ) ; + + return aResultSO._retn(); +} + +//============================================================================= +SALOMEDS::SObject_ptr ADAPT_Gen_i::PublishZoneInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder, + ADAPT::HOMARD_Zone_ptr theObject, const char* theName) +{ + MESSAGE("PublishZoneStudy pour "<_is_nil()"); + return aResultSO._retn(); + } + if (myStudy->_is_nil()) + { + MESSAGE("PublishZoneInStudy : myStudy->_is_nil()"); + return aResultSO._retn(); + } + SALOMEDS::SComponent_var theFatherHomard = myStudy->FindComponent(ComponentDataType()); + if (theFatherHomard->_is_nil()) + { + MESSAGE("PublishZoneInStudy : theFatherHomard->_is_nil()"); + return aResultSO._retn(); + } + + // Caracteristique de la zone + ADAPT::HOMARD_Zone_var myZone = myStudyContext._mesZones[theName]; + CORBA::Long ZoneType = myZone->GetType(); + + // On ajoute la categorie des zones dans l etude si necessaire + if ( _tag_zone == 0 ) + { + _tag_gene += 1 ; + _tag_zone = _tag_gene ; + } + MESSAGE("PublishZoneStudy _tag_gene = "<<_tag_gene << ", _tag_zone = "<<_tag_zone ); + SALOMEDS::SObject_var aSObject; + if (!theFatherHomard->FindSubObject(_tag_zone, aSObject)) + { + MESSAGE("Ajout de la categorie des zones"); + aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_zone); + PublishInStudyAttr(aStudyBuilder, aSObject, "Zones", "ZoneList", "zone_icone_2.png", NULL ) ; + } + else { MESSAGE("La categorie des zones existe deja."); } + + aResultSO = aStudyBuilder->NewObject(aSObject); + std::string icone ; + switch (ZoneType) + { + case 11 : + { } + case 12 : + { } + case 13 : + { icone = "boxdxy_2.png" ; + break ; + } + case 2 : + { icone = "boxdxyz_2.png" ; + break ; + } + case 31 : + { } + case 32 : + { } + case 33 : + { icone = "disk_2.png" ; + break ; + } + case 4 : + { icone = "spherepoint_2.png" ; + break ; + } + case 5 : + { icone = "cylinderpointvector_2.png" ; + break ; + } + case 61 : + { } + case 62 : + { } + case 63 : + { icone = "diskwithhole_2.png" ; + break ; + } + case 7 : + { icone = "pipe_2.png" ; + break ; + } + } + PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "ZoneHomard", icone.c_str(), _orb->object_to_string(theObject) ) ; + + return aResultSO._retn(); +} +//=========================================================================== +void ADAPT_Gen_i::PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder, + SALOMEDS::SObject_var aResultSO, + const char* name, const char* comment, const char* icone, const char* ior) +{ + MESSAGE("PublishInStudyAttr pour name = "<SetValue(name); + } + +// Ajout du commentaire + if ( comment != NULL ) + { + anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeComment"); + SALOMEDS::AttributeComment_var aCommentAttrib = SALOMEDS::AttributeComment::_narrow(anAttr); + aCommentAttrib->SetValue(comment); + } + +// Ajout de l'icone + if ( icone != NULL ) + { + anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributePixMap"); + SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap(icone); + } + +// Ajout de l ior + if ( ior != NULL ) + { + anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR"); + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + anIOR->SetValue(ior); + } +}; + +//===================================================================================== +void ADAPT_Gen_i::PublishBoundaryUnderCase(const char* CaseName, const char* BoundaryName) +{ + MESSAGE ( "PublishBoundaryUnderCase : CaseName = " << CaseName << ", BoundaryName= " << BoundaryName ); + + ADAPT::HOMARD_Cas_var myCase = myStudyContext._mesCas[CaseName]; + ASSERT(!CORBA::is_nil(myCase)); + SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myCase))); + ASSERT(!CORBA::is_nil(aCaseSO)); + + ADAPT::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName]; + ASSERT(!CORBA::is_nil(myBoundary)); + SALOMEDS::SObject_var aBoundarySO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myBoundary))); + ASSERT(!CORBA::is_nil(aBoundarySO)); + + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + + aStudyBuilder->NewCommand(); + + SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aCaseSO); + aStudyBuilder->Addreference(aSubSO, aBoundarySO); +// aStudyBuilder->RemoveReference(aSubSO); + + aStudyBuilder->CommitCommand(); + +}; +//===================================================================================== +void ADAPT_Gen_i::PublishCaseUnderYACS(const char* nomYACS, const char* CaseName) +{ + MESSAGE ( "PublishCaseUnderYACS : nomYACS = " << nomYACS << ", CaseName= " << CaseName ); + + ADAPT::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS]; + ASSERT(!CORBA::is_nil(myYACS)); + SALOMEDS::SObject_var aYACSSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myYACS))); + ASSERT(!CORBA::is_nil(aYACSSO)); + + ADAPT::HOMARD_Cas_var myCase = myStudyContext._mesCas[CaseName]; + ASSERT(!CORBA::is_nil(myCase)); + SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myCase))); + ASSERT(!CORBA::is_nil(aCaseSO)); + + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + + aStudyBuilder->NewCommand(); + + SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aYACSSO); + aStudyBuilder->Addreference(aSubSO, aCaseSO); + + aStudyBuilder->CommitCommand(); + +}; +//============================================================================= +void ADAPT_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option) +// Option = 0 : fichier issu d'une importation +// Option = 1 : fichier issu d'une execution HOMARD +{ + MESSAGE( "PublishResultInSmesh " << NomFich << ", avec Option = " << Option); + if (CORBA::is_nil(myStudy)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid study context"; + throw SALOME::SALOME_Exception(es); + return ; + }; + +// Le module SMESH est-il actif ? + SALOMEDS::SObject_var aSmeshSO = myStudy->FindComponent("SMESH"); +// + if (!CORBA::is_nil(aSmeshSO)) + { +// On verifie que le fichier n est pas deja publie + SALOMEDS::ChildIterator_var aIter = myStudy->NewChildIterator(aSmeshSO); + for (; aIter->More(); aIter->Next()) + { + SALOMEDS::SObject_var aSO = aIter->Value(); + SALOMEDS::GenericAttribute_var aGAttr; + if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef")) + { + SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr); + CORBA::String_var value=anAttr->Value(); + if (strcmp((const char*)value,NomFich) == 0) + { + MESSAGE ( "PublishResultInSmesh : le fichier " << NomFich << " est deja publie." ); + // Pour un fichier importe, on ne republie pas + if ( Option == 0 ) { return; } + // Pour un fichier calcule, on commence par faire la depublication + else + { + MESSAGE ( "PublishResultInSmesh : depublication" ); + SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr); + CORBA::String_var value2=anAttr2->Value(); + std::string MeshName = string(value2) ; + MESSAGE ( "PublishResultInSmesh : depublication de " << MeshName ); + DeleteResultInSmesh(NomFich, MeshName) ; + } + } + } + } + } + +// On enregistre le fichier + MESSAGE( "Enregistrement du fichier"); + SALOME_LifeCycleCORBA* myLCC = new SALOME_LifeCycleCORBA(_NS); + SMESH::SMESH_Gen_var aSmeshEngine = SMESH::SMESH_Gen::_narrow(myLCC->FindOrLoad_Component("FactoryServer","SMESH")); + ASSERT(!CORBA::is_nil(aSmeshEngine)); + aSmeshEngine->UpdateStudy(); + SMESH::DriverMED_ReadStatus theStatus; + //aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus); + +// On met a jour les attributs AttributeExternalFileDef et AttributePixMap + SMESH::mesh_array* mesMaillages=aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus); + for (int i = 0; i < mesMaillages->length(); i++) + { + MESSAGE( ". Mise a jour des attributs du maillage"); + SMESH::SMESH_Mesh_var monMaillage= (*mesMaillages)[i]; + SALOMEDS::SObject_var aSO=SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(monMaillage))); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + SALOMEDS::GenericAttribute_var aGAttr = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributeExternalFileDef"); + SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr); + anAttr->SetValue(NomFich); + SALOMEDS::GenericAttribute_var aPixMap = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePixMap" ); + SALOMEDS::AttributePixMap_var anAttr2 = SALOMEDS::AttributePixMap::_narrow(aPixMap); + const char* icone ; + if ( Option == 0 ) { icone = "mesh_tree_importedmesh.png" ; } + else { icone = "mesh_tree_mesh.png" ; } + anAttr2->SetPixMap( icone ); + } + +} +//============================================================================= +void ADAPT_Gen_i::DeleteResultInSmesh(std::string NomFich, std::string MeshName) +{ + MESSAGE ("DeleteResultInSmesh pour le maillage " << MeshName << " dans le fichier " << NomFich ); + if (CORBA::is_nil(myStudy)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid study context"; + throw SALOME::SALOME_Exception(es); + return ; + }; + +// Le module SMESH est-il actif ? + SALOMEDS::SObject_var aSmeshSO = myStudy->FindComponent("SMESH"); +// + if (CORBA::is_nil(aSmeshSO)) + { + return ; + }; +// On verifie que le fichier est deja publie + SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder(); + SALOMEDS::ChildIterator_var aIter = myStudy->NewChildIterator(aSmeshSO); + for (; aIter->More(); aIter->Next()) + { + SALOMEDS::SObject_var aSO = aIter->Value(); + SALOMEDS::GenericAttribute_var aGAttr; + if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef")) + { + SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr); + CORBA::String_var value=anAttr->Value(); + if (strcmp((const char*)value,NomFich.c_str()) == 0) + { + if (aSO->FindAttribute(aGAttr,"AttributeName")) + { + SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr); + CORBA::String_var value2=anAttr2->Value(); + if (strcmp((const char*)value2,MeshName.c_str()) == 0) + { + myBuilder->RemoveObjectWithChildren( aSO ) ; + } + } + } + } + } + return ; +} +//============================================================================= +void ADAPT_Gen_i::PublishMeshIterInSmesh(const char* NomIter) +{ + MESSAGE( "PublishMeshIterInSmesh " << NomIter); + ADAPT::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[NomIter]; + + SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration))); + if (CORBA::is_nil(myIteration)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid iterationStudy Object"; + throw SALOME::SALOME_Exception(es); + return ; + }; + const char* MeshFile = myIteration->GetMeshFile() ; + const char* MeshName = myIteration->GetMeshName() ; + CORBA::Long Option = -1 ; + int etat = myIteration->GetState(); +// Iteration initiale + if ( etat <= 0 ) { Option = 0 ; } +// ou iteration calculee + else if ( etat == 2 ) { Option = 1 ; } +// Publication effective apres menage eventuel + if ( Option >= 0 ) + { + DeleteResultInSmesh(MeshFile, MeshName) ; + PublishResultInSmesh(MeshFile, Option) ; + } + +} +//============================================================================= +void ADAPT_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* NomFich, const char* Commentaire) +{ +// MESSAGE ("PublishFileUnderIteration pour l'iteration " << NomIter << " du fichier " << NomFich << " avec le commentaire " << Commentaire ); + ADAPT::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[NomIter]; + + SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration))); + if (CORBA::is_nil(myIteration)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid iterationStudy Object"; + throw SALOME::SALOME_Exception(es); + return ; + }; + + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + + aStudyBuilder->NewCommand(); + + SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO); +// Pour les fichiers med, on affiche une icone de maillage +// Pour les fichiers qui sont du texte, on affiche une icone de fichier texte 'texte' +// Le reperage se fait par la 1ere lettre du commentaire : I pour Iteration n + std::string icone ; + std::string ior = " " ; + if ( Commentaire[0] == 'M' ) + { icone = "med.png" ; } + else + { icone = "texte_2.png" ; } + PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone.c_str(), ior.c_str() ) ; + + aStudyBuilder->CommitCommand(); +} +// +//============================================================================= +void ADAPT_Gen_i::PublishFileUnderYACS(const char* nomYACS, const char* NomFich, const char* Commentaire) +{ +// MESSAGE ("PublishFileUnderYACS pour le schema " << nomYACS << " du fichier " << NomFich << " avec le commentaire " << Commentaire ); + ADAPT::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS]; + + SALOMEDS::SObject_var aYACSSO=SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myYACS))); + if (CORBA::is_nil(myYACS)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid YACSStudy Object"; + throw SALOME::SALOME_Exception(es); + return ; + }; + + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + + aStudyBuilder->NewCommand(); + + SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aYACSSO); + std::string icone = "texte_2.png" ; + std::string ior = " " ; + PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone.c_str(), ior.c_str() ) ; + + aStudyBuilder->CommitCommand(); +} +// +//============================================================================= +//============================================================================= +// YACS +//============================================================================= +//============================================================================= +//============================================================================= +// Creation d'un schema YACS +// nomCas : nom du cas a traiter +// FileName : nom du fichier contenant le script de lancement du calcul +// DirName : le répertoire de lancement des calculs du schéma +//============================================================================= +ADAPT::HOMARD_YACS_ptr ADAPT_Gen_i::CreateYACSSchema (const char* nomYACS, const char* nomCas, const char* ScriptFile, const char* DirName, const char* MeshFile) +{ + INFOS ( "CreateYACSSchema : Schema YACS " << nomYACS ); + INFOS ( ". nomCas : " << nomCas); + INFOS ( ". ScriptFile : " << ScriptFile); + INFOS ( ". DirName : " << DirName); + INFOS ( ". MeshFile : " << MeshFile); + + // A. Controle du nom : + if ((myStudyContext._mesYACSs).find(nomYACS) != (myStudyContext._mesYACSs).end()) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "This schema YACS has already been defined."; + throw SALOME::SALOME_Exception(es); + return 0; + } + + // B. Creation de l'objet + ADAPT::HOMARD_YACS_var myYACS = newYACS(); + if (CORBA::is_nil(myYACS)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Unable to create the schema YACS"; + throw SALOME::SALOME_Exception(es); + return 0; + }; + myYACS->SetName( nomYACS ) ; + + // C. Enregistrement + myStudyContext._mesYACSs[nomYACS] = myYACS; + + SALOMEDS::SObject_var aSO; + SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myYACS, nomYACS); + + PublishCaseUnderYACS(nomYACS, nomCas); + + // D. Caracterisation + // D.1. Options + myYACS->SetDirName( DirName ) ; + myYACS->SetMeshFile( MeshFile ) ; + myYACS->SetScriptFile( ScriptFile ) ; + myYACS->SetCaseName( nomCas ) ; + // D.2. Defaut + int defaut_i ; + // D.2.1. Type constant + myYACS->SetType( 1 ) ; + // D.2.2. Convergence + defaut_i = GetYACSMaxIter() ; + myYACS->SetMaxIter( defaut_i ) ; + defaut_i = GetYACSMaxNode() ; + myYACS->SetMaxNode( defaut_i ) ; + defaut_i = GetYACSMaxElem() ; + myYACS->SetMaxElem( defaut_i ) ; + // D.3. Fichier de sauvegarde dans le répertoire du cas + ADAPT::HOMARD_Cas_ptr caseyacs = GetCase(nomCas) ; + std::string dirnamecase = caseyacs->GetDirName() ; + std::string XMLFile ; + XMLFile = dirnamecase + "/schema.xml" ; + myYACS->SetXMLFile( XMLFile.c_str() ) ; + + return ADAPT::HOMARD_YACS::_duplicate(myYACS); +} +//============================================================================= +// Ecriture d'un schema YACS +//============================================================================= +CORBA::Long ADAPT_Gen_i::YACSWrite(const char* nomYACS) +{ + INFOS ( "YACSWrite : Ecriture de " << nomYACS ); +// Le répertoire du cas + ADAPT::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS]; + ASSERT(!CORBA::is_nil(myYACS)); +// Le nom du fichier du schema + std::string XMLFile ; + XMLFile = myYACS->GetXMLFile() ; + + int codret = YACSWriteOnFile(nomYACS, XMLFile.c_str()) ; + + return codret ; +} +//============================================================================= +// Ecriture d'un schema YACS sur un fichier donne +//============================================================================= +CORBA::Long ADAPT_Gen_i::YACSWriteOnFile(const char* nomYACS, const char* XMLFile) +{ + INFOS ( "YACSWriteOnFile : Ecriture de " << nomYACS << " sur " << XMLFile ); + + // A. Prealable + int codret = 0; + + // B. L'objet YACS + // B.1. L'objet + ADAPT::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS]; + ASSERT(!CORBA::is_nil(myYACS)); + // B.2. Les caracteristiques + std::string DirName = myYACS->GetDirName() ; + std::string MeshFile = myYACS->GetMeshFile() ; + std::string ScriptFile = myYACS->GetScriptFile() ; + // B.3. Les caracteristiques de convergence + int MaxIter = myYACS->GetMaxIter() ; + int MaxNode = myYACS->GetMaxNode() ; + int MaxElem = myYACS->GetMaxElem() ; + + // C. Le cas + // C.1. L'objet cas + const char* nomCas = myYACS->GetCaseName(); + ADAPT::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas]; + ASSERT(!CORBA::is_nil(myCase)); + // C.2. Les instructions python associees au cas + CORBA::String_var dumpCorbaCase = myCase->GetDumpPython(); + std::string pythonCas = dumpCorbaCase.in(); + MESSAGE ("pythonCas :\n"<GetIter0() ; + std::string Iter0Name = myCase->GetIter0Name() ; + MESSAGE (". Iter0Name = " << Iter0Name); + std::string MeshName = Iter0->GetMeshName(); + MESSAGE (". MeshName = " << MeshName); + // D.2. L'iteration numero 1 + ADAPT::listeIterFilles* maListe = Iter0->GetIterations(); + int numberOfIter = maListe->length(); + if ( numberOfIter > 1 ) + { + MESSAGE (". numberOfIter = " << numberOfIter); + SALOME::ExceptionStruct es ; + es.type = SALOME::BAD_PARAM; + std::string text = "Une seule iteration est permise." ; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + return 0; + } + std::string Iter1Name = std::string((*maListe)[0]); + MESSAGE ("... Iter1Name = " << Iter1Name); + ADAPT::HOMARD_Iteration_var Iter1 = GetIteration(Iter1Name.c_str()) ; + // D.3. Les instructions python associees a l'iteration + CORBA::String_var dumpCorbaIter = Iter1->GetDumpPython(); + std::string pythonIter = dumpCorbaIter.in(); + MESSAGE ("pythonIter :\n"<GetHypoName(); + MESSAGE (". nomHypo = " << nomHypo); + ADAPT::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo]; + ASSERT(!CORBA::is_nil(myHypo)); + // E.2. Les caracteristiques de l'adaptation + ADAPT::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef(); + ASSERT(ListTypes->length() == 3); + int TypeAdap = (*ListTypes)[0]; +// int TypeRaff = (*ListTypes)[1]; +// int TypeDera = (*ListTypes)[2]; + // E.3. Les instructions python associees a l'hypothese + CORBA::String_var dumpCorbaHypo = myHypo->GetDumpPython(); + std::string pythonHypo = dumpCorbaHypo.in(); + MESSAGE ("pythonHypo :\n"<Texte_DataInit_MeshFile(MeshFile); } + // G.1.3. Le script de lancement + else if ( mot_cle == "Alternance_Calcul_HOMARD_Calcul" ) + { myDriver->Texte_Alternance_Calcul_HOMARD_Calcul(ScriptFile); } + // G.1.4. Les options du cas + else if ( mot_cle == "Iter_1_Case_Options" ) + { myDriver->Texte_Iter_1_Case_Options(pythonCas); } + // G.1.5. Execution de HOMARD : le répertoire du cas + else if ( mot_cle == "HOMARD_Exec_DirName" ) + { myDriver->Texte_HOMARD_Exec_DirName(); } + // G.1.6. Execution de HOMARD : le nom du maillage + else if ( mot_cle == "HOMARD_Exec_MeshName" ) + { + myDriver->Texte_HOMARD_Exec_MeshName(MeshName); + std::string node ; + if ( _LangueShort == "fr" ) { node = "Boucle_de_convergence.Alternance_Calcul_HOMARD" ; } + else { node = "Convergence_Loop.Alternation_Computation_HOMARD" ; } + node += ".Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_Iter_1.CreateCase" ; + myDriver->TexteParametre( node, "MeshName", "string", MeshName ) ; + } + // G.1.7. Execution de HOMARD : les options de l'hypothese + else if ( mot_cle == "HOMARD_Exec_Hypo_Options" ) + { myDriver->Texte_python_1( pythonHypo, 3, "Hypo" ) ; } + // G.1.8. Execution de HOMARD : les options de l'iteration + else if ( mot_cle == "HOMARD_Exec_Iter_Options" ) + { myDriver->Texte_python_2( pythonIter, "TimeStep", "Iter" ) ; } + // G.1.9. a. Creation eventuelles des zones et frontieres + // b. Enchainement + else if ( mot_cle == "Iter_1" ) + { + std::string texte_control = "" ; + if ( TypeAdap == 0 ) { texte_control += YACSDriverTexteZone( myHypo, myDriver ) ; } + texte_control += YACSDriverTexteBoundary( myCase, myDriver ) ; + texte_control += myDriver->Texte_Iter_1_control() ; + myDriver->TexteAdd(texte_control); + } + // G.1.10. Les tests de convergence + else if ( mot_cle == "Analyse_Test_Convergence" ) + { myDriver->TexteAnalyse_Test_Convergence(MaxIter, MaxNode, MaxElem); } + // G.1.11. Les parametres + else if ( mot_cle == "PARAMETRES" ) + { myDriver->TexteAddParametres(); } + // G.1.n. La ligne est recopiee telle quelle + else { myDriver->TexteAdd(ligne); } + } + // G.2. Ecriture du texte dans le fichier + if ( codret == 0 ) + { myDriver->CreeFichier(); } + } + else + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + std::string text = "The reference file for the YACS schema cannot be read." ; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + } + + delete myDriver; + + // H. Publication du fichier dans l'arbre + + std::string Commentaire = "xml" ; + PublishFileUnderYACS(nomYACS, XMLFile, Commentaire.c_str()); + + return codret ; +} +//============================================================================= +// Ecriture d'un schema YACS : ecriture des zones associees a une hypothese +//============================================================================= +std::string ADAPT_Gen_i::YACSDriverTexteZone(ADAPT::HOMARD_Hypothesis_var myHypo, YACSDriver* myDriver) +{ + MESSAGE ( "YACSDriverTexteZone" ); + // A. Les zones associees a cette hypothese + ADAPT::listeZonesHypo* ListZone = myHypo->GetZones(); + int numberOfZonesx2 = ListZone->length(); + + // B. Parcours des zones + std::string texte_control ; + for (int iaux = 0; iaux< numberOfZonesx2; iaux++) + { + // 1. Reperage de la zone + std::string ZoneName = std::string((*ListZone)[iaux]); + MESSAGE ( "\n. ZoneName = " << ZoneName << " - " <GetDumpPython(); + std::string pythonStructure_0 = dumpCorbaZone.in(); + MESSAGE ("pythonStructure_0 :"<GetBoundaryGroup(); + int numberOfitems = ListBoundaryGroupType->length(); + + // B. Parcours des frontieres + std::string texte_control ; + std::list ListeBoundaryTraitees ; + for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2) + { + std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]); + MESSAGE ( "... BoundaryName = " << BoundaryName); + // Attention a n'ecrire la definition qu'une seule fois car elle peut se trouver + // plusieurs fois dans la definition du cas, d'ou la liste ListeBoundaryTraitees + int A_faire = 1 ; + std::list::const_iterator it = ListeBoundaryTraitees.begin(); + while (it != ListeBoundaryTraitees.end()) + { + MESSAGE ( "..... BoundaryNameTraitee = " << *it); + if ( BoundaryName == *it ) { A_faire = 0 ; } + it++; + } + if ( A_faire == 1 ) + { + // 1. Caracteristiques de la frontiere + ADAPT::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName]; + ASSERT(!CORBA::is_nil(myBoundary)); + // 2. Les instructions python associees a la frontiere + // La premiere ligne est un commentaire a eliminer + // La seconde ligne est l'instruction a proprement parler ; on ne garde que ce qui suit le "." + CORBA::String_var dumpCorbaBoundary = myBoundary->GetDumpPython(); + std::string pythonStructure_0 = dumpCorbaBoundary.in(); + MESSAGE ("pythonStructure_0 :"<URL())); + aFileName += "_HOMARD.dat"; + + // initialize sequence of file names + SALOMEDS_Tool::ListOfFiles aFileSeq; + aFileSeq.reserve(1); + aFileSeq.push_back(CORBA::string_dup(aFileName.c_str())) ; + + // get full path to the data file + aFileName = tmpDir + aFileName; + + // save data + // -> create file + std::ofstream f(aFileName.c_str()); + + // clear temporary id map + context._idmap.clear(); + + int id = 1; + + // -> save cases + std::map::const_iterator it_case; + for (it_case = context._mesCas.begin(); it_case != context._mesCas.end(); ++it_case) { + ADAPT::HOMARD_Cas_var aCas = it_case->second; + PortableServer::ServantBase_var aServant = GetServant(aCas); + HOMARD_Cas_i* aCasServant = dynamic_cast(aServant.in()); + if (aCasServant) { + f << ADAPT::GetSignature(ADAPT::Case) << aCasServant->Dump() << std::endl; + context._idmap[id++] = dynamic_cast(aCasServant); + } + } + // -> save zones + std::map::const_iterator it_zone; + for (it_zone = context._mesZones.begin(); it_zone != context._mesZones.end(); ++it_zone) { + ADAPT::HOMARD_Zone_var aZone = it_zone->second; + PortableServer::ServantBase_var aServant = GetServant(aZone); + HOMARD_Zone_i* aZoneServant = dynamic_cast(aServant.in()); + if (aZoneServant) { + f << ADAPT::GetSignature(ADAPT::Zone) << aZoneServant->Dump() << std::endl; + context._idmap[id++] = dynamic_cast(aZoneServant); + } + } + // -> save hypotheses + std::map::const_iterator it_hypo; + for (it_hypo = context._mesHypotheses.begin(); it_hypo != context._mesHypotheses.end(); ++it_hypo) { + ADAPT::HOMARD_Hypothesis_var aHypo = it_hypo->second; + PortableServer::ServantBase_var aServant = GetServant(aHypo); + HOMARD_Hypothesis_i* aHypoServant = dynamic_cast(aServant.in()); + if (aHypoServant) { + f << ADAPT::GetSignature(ADAPT::Hypothesis) << aHypoServant->Dump() << std::endl; + context._idmap[id++] = dynamic_cast(aHypoServant); + } + } + // -> save iterations + std::map::const_iterator it_iter; + for (it_iter = context._mesIterations.begin(); it_iter != context._mesIterations.end(); ++it_iter) { + ADAPT::HOMARD_Iteration_var aIter = it_iter->second; + PortableServer::ServantBase_var aServant = GetServant(aIter); + HOMARD_Iteration_i* aIterServant = dynamic_cast(aServant.in()); + if (aIterServant) { + f << ADAPT::GetSignature(ADAPT::Iteration) << aIterServant->Dump() << std::endl; + context._idmap[id++] = dynamic_cast(aIterServant); + } + } + // -> save boundaries + std::map::const_iterator it_boundary; + for (it_boundary = context._mesBoundarys.begin(); it_boundary != context._mesBoundarys.end(); ++it_boundary) { + ADAPT::HOMARD_Boundary_var aBoundary = it_boundary->second; + PortableServer::ServantBase_var aServant = GetServant(aBoundary); + HOMARD_Boundary_i* aBoundaryServant = dynamic_cast(aServant.in()); + if (aBoundaryServant) { + f << ADAPT::GetSignature(ADAPT::Boundary) << aBoundaryServant->Dump() << std::endl; + context._idmap[id++] = dynamic_cast(aBoundaryServant); + } + } + // -> close file + MESSAGE ("close file"); + f.close(); + + // put temporary files to the stream + MESSAGE ("put temporary files to the stream"); + aStreamFile = SALOMEDS_Tool::PutFilesToStream(tmpDir.c_str(), aFileSeq, isMultiFile); + + // remove temporary files + MESSAGE ("remove temporary files"); + if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq, true); + + // return data stream + MESSAGE ("return data stream"); + return aStreamFile._retn(); +}; + +//=========================================================================== +SALOMEDS::TMPFile* ADAPT_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + CORBA::Boolean isMultiFile) +{ + // No specific ASCII persistence + SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile); + return aStreamFile._retn(); +}; + +//=========================================================================== +CORBA::Boolean ADAPT_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile& theStream, + const char* theURL, + CORBA::Boolean isMultiFile) +{ + MESSAGE ("Load pour theURL = "<< theURL); + + // set current study + if (myStudy->_is_nil()) + UpdateStudy(); + + // get temporary directory name + std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir(); + + // Convert the stream into sequence of files to process + SALOMEDS_Tool::ListOfFiles aFileSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, + tmpDir.c_str(), + isMultiFile); + // HOMARD data file name + std::string aFileName = ""; + if (isMultiFile) + aFileName = SALOMEDS_Tool::GetNameFromPath(Kernel_Utils::encode(SMESH_Gen_i::getStudyServant()->URL())); + aFileName = tmpDir + aFileName + "_HOMARD.dat"; + + StudyContext& context = myStudyContext; + + // save data + // -> create file + std::ifstream f(aFileName.c_str()); + + // clear context + context._mesCas.clear(); + context._mesHypotheses.clear(); + context._mesIterations.clear(); + context._mesZones.clear(); + context._mesBoundarys.clear(); + context._idmap.clear(); + + int id = 1; + std::string line; + + while (f) { + std::getline(f, line); + std::string bounSignature = ADAPT::GetSignature(ADAPT::Boundary); + std::string caseSignature = ADAPT::GetSignature(ADAPT::Case); + std::string hypoSignature = ADAPT::GetSignature(ADAPT::Hypothesis); + std::string iterSignature = ADAPT::GetSignature(ADAPT::Iteration); + std::string zoneSignature = ADAPT::GetSignature(ADAPT::Zone); + std::string yacsSignature = ADAPT::GetSignature(ADAPT::YACS); + if (line.substr(0, bounSignature.size()) == bounSignature) { + // re-create boundary + MESSAGE ("Recreation de la frontiere" ); + ADAPT::HOMARD_Boundary_var aBoundary = newBoundary(); + PortableServer::ServantBase_var aServant = GetServant(aBoundary); + HOMARD_Boundary_i* aBoundaryServant = dynamic_cast(aServant.in()); + if (aBoundaryServant && aBoundaryServant->Restore(line.substr(bounSignature.size()))) { + context._mesBoundarys[aBoundary->GetName()] = aBoundary; + context._idmap[id] = dynamic_cast(aBoundaryServant); + } + } + else if (line.substr(0, caseSignature.size()) == caseSignature) { + // re-create case + MESSAGE ("Recreation du cas" ); + ADAPT::HOMARD_Cas_var aCase = newCase(); + PortableServer::ServantBase_var aServant = GetServant(aCase); + HOMARD_Cas_i* aCaseServant = dynamic_cast(aServant.in()); + if (aCaseServant && aCaseServant->Restore(line.substr(caseSignature.size()))) { + context._mesCas[aCase->GetName()] = aCase; + context._idmap[id] = dynamic_cast(aCaseServant); + } + } + else if (line.substr(0, hypoSignature.size()) == hypoSignature) { + // re-create hypothesis + MESSAGE ("Recreation de l hypothese" ); + ADAPT::HOMARD_Hypothesis_var aHypo = newHypothesis(); + PortableServer::ServantBase_var aServant = GetServant(aHypo); + HOMARD_Hypothesis_i* aHypoServant = dynamic_cast(aServant.in()); + if (aHypoServant && aHypoServant->Restore(line.substr(hypoSignature.size()))) { + context._mesHypotheses[aHypo->GetName()] = aHypo; + context._idmap[id] = dynamic_cast(aHypoServant); + } + } + else if (line.substr(0, iterSignature.size()) == iterSignature) { + // re-create iteration + MESSAGE ("Recreation de l'iteration" ); + ADAPT::HOMARD_Iteration_var aIter = newIteration(); + PortableServer::ServantBase_var aServant = GetServant(aIter); + HOMARD_Iteration_i* aIterServant = dynamic_cast(aServant.in()); + if (aIterServant && aIterServant->Restore(line.substr(iterSignature.size()))) { + context._mesIterations[aIter->GetName()] = aIter; + context._idmap[id] = dynamic_cast(aIterServant); + } + } + else if (line.substr(0, zoneSignature.size()) == zoneSignature) { + MESSAGE ("Recreation de la zone" ); + // re-create zone + ADAPT::HOMARD_Zone_var aZone = newZone(); + PortableServer::ServantBase_var aServant = GetServant(aZone); + HOMARD_Zone_i* aZoneServant = dynamic_cast(aServant.in()); + if (aZoneServant && aZoneServant->Restore(line.substr(zoneSignature.size()))) { + context._mesZones[aZone->GetName()] = aZone; + context._idmap[id] = dynamic_cast(aZoneServant); + } + } + else if (line.substr(0, zoneSignature.size()) == yacsSignature) { + MESSAGE ("Recreation du schema YACS" ); + // re-create YACS + ADAPT::HOMARD_YACS_var aYACS = newYACS(); + PortableServer::ServantBase_var aServant = GetServant(aYACS); + HOMARD_YACS_i* aYACSServant = dynamic_cast(aServant.in()); + if (aYACSServant && aYACSServant->Restore(line.substr(yacsSignature.size()))) { + context._mesYACSs[aYACS->GetName()] = aYACS; + context._idmap[id] = dynamic_cast(aYACSServant); + } + } + id++; + } + + // -> close file + f.close(); + + // Remove temporary files created from the stream + if (!isMultiFile) + SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq, true); + + return true; +}; + +//=========================================================================== +CORBA::Boolean ADAPT_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile& theStream, + const char* theURL, + CORBA::Boolean isMultiFile) +{ + // No specific ASCII persistence + return Load(theComponent, theStream, theURL, isMultiFile); +}; + +//=========================================================================== +void ADAPT_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent) +{ +}; + +//=========================================================================== +char* ADAPT_Gen_i::ComponentDataType() +{ + return CORBA::string_dup("HOMARD"); +}; + +//=========================================================================== +char* ADAPT_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, + const char* IORString, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII) +{ + CORBA::String_var aString(""); + if (!CORBA::is_nil(theSObject) && strcmp(IORString, "") != 0) { + StudyContext context = myStudyContext; + CORBA::Object_var anObj = _orb->string_to_object(IORString); + if (!CORBA::is_nil(anObj)) { + PortableServer::ServantBase_var aServant = GetServant(anObj); + PortableServer::ServantBase* aStorable = dynamic_cast(aServant.in()); + if (aStorable) { + std::map::const_iterator it; + for (it = context._idmap.begin(); it != context._idmap.end(); ++it) { + if (it->second == aStorable) { + std::stringstream os; + os << it->first; + aString = CORBA::string_dup(os.str().c_str()); + } + } + } + } + } + return aString._retn(); +}; + +//=========================================================================== +char* ADAPT_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, + const char* aLocalPersistentID, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII) +{ + CORBA::String_var aString(""); + if (!CORBA::is_nil(theSObject) && strcmp(aLocalPersistentID, "") != 0) { + StudyContext context = myStudyContext; + int id = atoi(aLocalPersistentID); + if (id > 0 && context._idmap.find(id) != context._idmap.end()) { + CORBA::Object_var object = _poa->servant_to_reference(context._idmap[ id ]); + if (!CORBA::is_nil(object)) { + aString = _orb->object_to_string(object); + } + } + } + return aString._retn(); +}; + +//=========================================================================== +CORBA::Boolean ADAPT_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) +{ + if(CORBA::is_nil(myStudy)) + return false; + + ADAPT::HOMARD_Cas_var aCas = ADAPT::HOMARD_Cas::_narrow(theIOR); + if(!aCas->_is_nil()) + return true; + + ADAPT::HOMARD_Hypothesis_var aHypo = ADAPT::HOMARD_Hypothesis::_narrow(theIOR); + if(!aHypo->_is_nil()) + return true; + + ADAPT::HOMARD_Zone_var aZone = ADAPT::HOMARD_Zone::_narrow(theIOR); + if(!aZone->_is_nil()) + return true; + + ADAPT::HOMARD_Boundary_var aBoundary = ADAPT::HOMARD_Boundary::_narrow(theIOR); + if(!aBoundary->_is_nil()) + return true; + + /* Iteration is not published directly + ADAPT::HOMARD_Iteration_var aIter = ADAPT::HOMARD_Iteration::_narrow(theIOR); + if(!aIter->_is_nil()) + return true; + */ + return false; +}; + +//=========================================================================== +CORBA::Boolean ADAPT_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) +{ + // No Copy/Paste support + return false; +}; + +//=========================================================================== +SALOMEDS::TMPFile* ADAPT_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, + CORBA::Long& theObjectID) +{ + // No Copy/Paste support + SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0); + return aStreamFile._retn(); +}; + +//=========================================================================== +CORBA::Boolean ADAPT_Gen_i::CanPaste(const char *theComponentName, + CORBA::Long theObjectID) +{ + // No Copy/Paste support + return false; +}; + +//=========================================================================== +SALOMEDS::SObject_ptr ADAPT_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream, + CORBA::Long theObjectID, + SALOMEDS::SObject_ptr theSObject) +{ + // No Copy/Paste support + SALOMEDS::SObject_var aResultSO; + return aResultSO._retn(); +}; + +//=========================================================================== +PortableServer::ServantBase_var ADAPT_Gen_i::GetServant(CORBA::Object_ptr theObject) +{ + PortableServer::Servant aServant = 0; + if (!CORBA::is_nil(theObject)) { + try { + aServant = _poa->reference_to_servant(theObject); + } + catch (...) { + } + } + return aServant; +} + +//========================================================================== +Engines::TMPFile* ADAPT_Gen_i::DumpPython(CORBA::Boolean isPublished, + CORBA::Boolean isMultiFile, + CORBA::Boolean& isValidScript) +{ + MESSAGE ("Entree dans DumpPython"); + isValidScript=1; + + SALOMEDS::SObject_var aSO = SMESH_Gen_i::getStudyServant()->FindComponent("HOMARD"); + if(CORBA::is_nil(aSO)) + return new Engines::TMPFile(0); + + std::string aScript = "\"\"\"\n"; + aScript += "Python script for HOMARD\n"; + aScript += "Copyright 1996, 2011, 2015 EDF\n"; + aScript += "\"\"\"\n"; + aScript += "__revision__ = \"V1.2\"\n"; + aScript += "import HOMARD\n"; + if( isMultiFile ) + aScript += "import salome\n"; + aScript += "homard = salome.lcc.FindOrLoadComponent('FactoryServer','HOMARD')\n"; + aScript += "\thomard.UpdateStudy()\n"; + MESSAGE (". Au depart \n"< 0) + { + MESSAGE (". Ecritures des frontieres"); + aScript += "#\n# Creation of the boundaries"; + aScript += "\n# =========================="; + } + std::map::const_iterator it_boundary; + for (it_boundary = myStudyContext._mesBoundarys.begin(); + it_boundary != myStudyContext._mesBoundarys.end(); ++it_boundary) + { + ADAPT::HOMARD_Boundary_var maBoundary = (*it_boundary).second; + CORBA::String_var dumpCorbaBoundary = maBoundary->GetDumpPython(); + std::string dumpBoundary = dumpCorbaBoundary.in(); + MESSAGE (dumpBoundary<<"\n"); + aScript += dumpBoundary; + } + + + if (myStudyContext._mesZones.size() > 0) + { + MESSAGE (". Ecritures des zones"); + aScript += "#\n# Creation of the zones"; + aScript += "\n# ====================="; + } + std::map::const_iterator it_zone; + for ( it_zone = myStudyContext._mesZones.begin(); + it_zone != myStudyContext._mesZones.end(); ++it_zone) + { + ADAPT::HOMARD_Zone_var myZone = (*it_zone).second; + CORBA::String_var dumpCorbaZone = myZone->GetDumpPython(); + std::string dumpZone = dumpCorbaZone.in(); + MESSAGE (dumpZone<<"\n"); + aScript += dumpZone; + } + + + if (myStudyContext._mesHypotheses.size() > 0) + { + MESSAGE (". Ecritures des hypotheses"); + aScript += "#\n# Creation of the hypotheses"; + aScript += "\n# =========================="; + } + std::map::const_iterator it_hypo; + for ( it_hypo = myStudyContext._mesHypotheses.begin(); + it_hypo != myStudyContext._mesHypotheses.end(); it_hypo++) + { + ADAPT::HOMARD_Hypothesis_var monHypo = (*it_hypo).second; + CORBA::String_var dumpCorbaHypo = monHypo->GetDumpPython(); + std::string dumpHypo = dumpCorbaHypo.in(); + MESSAGE (dumpHypo<<"\n"); + aScript += dumpHypo; + } + + + if (myStudyContext._mesCas.size() > 0) + { + MESSAGE (". Ecritures des cas"); + aScript += "#\n# Creation of the cases"; + aScript += "\n# ====================="; + } + std::map::const_iterator it_cas; + for (it_cas = myStudyContext._mesCas.begin(); + it_cas != myStudyContext._mesCas.end(); it_cas++) + { + std::string nomCas = (*it_cas).first; + std::string dumpCas = std::string("\n# Creation of the case ") ; + dumpCas += nomCas + std::string("\n"); + dumpCas += std::string("\t") + nomCas; + dumpCas += std::string(" = homard.CreateCase(\"") + nomCas + std::string("\", \""); + + ADAPT::HOMARD_Cas_var myCase = (*it_cas).second; + CORBA::String_var cIter0= myCase->GetIter0Name(); + std::string iter0 = cIter0.in(); + + ADAPT::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[iter0]; + CORBA::String_var cMesh0= myIteration->GetMeshFile(); + std::string mesh0 = cMesh0.in(); + CORBA::String_var cMeshName0= myIteration->GetMeshName(); + std::string meshName0 = cMeshName0.in(); + dumpCas += meshName0 + std::string("\", \"")+ mesh0 + std::string("\")\n"); + CORBA::String_var dumpCorbaCase = myCase->GetDumpPython(); + std::string dumpCas2= dumpCorbaCase.in(); + + MESSAGE (dumpCas< 0) + { + MESSAGE (". Ecritures des iterations"); + aScript += "#\n# Creation of the iterations" ; + aScript += "\n# =========================="; + } + std::map::const_iterator it_iter; + for (it_iter = myStudyContext._mesIterations.begin(); + it_iter != myStudyContext._mesIterations.end(); ++it_iter) + { + ADAPT::HOMARD_Iteration_var aIter = (*it_iter).second; + CORBA::String_var dumpCorbaIter = aIter->GetDumpPython(); + std::string dumpIter = dumpCorbaIter.in(); + MESSAGE (dumpIter<<"\n"); + aScript += dumpIter; + } + + + if (myStudyContext._mesYACSs.size() > 0) + { + MESSAGE (". Ecritures des schemas YACS"); + aScript += "#\n# Creation of the schemas YACS"; + aScript += "\n# ============================"; + } + std::map::const_iterator it_yacs; + for ( it_yacs = myStudyContext._mesYACSs.begin(); + it_yacs != myStudyContext._mesYACSs.end(); ++it_yacs) + { + ADAPT::HOMARD_YACS_var myYACS = (*it_yacs).second; + CORBA::String_var dumpCorbaYACS = myYACS->GetDumpPython(); + std::string dumpYACS = dumpCorbaYACS.in(); + MESSAGE (dumpYACS<<"\n"); + aScript += dumpYACS; + } + + MESSAGE (". Ecritures finales"); + if( isMultiFile ) + aScript += "\n\tpass"; + aScript += "\n"; + + if( !isMultiFile ) // remove unnecessary tabulation + aScript = RemoveTabulation( aScript ); + +// MESSAGE ("A ecrire \n"<::const_iterator it; + for (it = myStudyContext._mesCas.begin(); + it != myStudyContext._mesCas.end(); it++) + { + if (std::string(nomDir) == std::string(it->second->GetDirName())) + { + casename = std::string(it->second->GetName()) ; + break ; + } + } + return CORBA::string_dup( casename.c_str() ); +} +/*//============================================================================= +void SALOMEException( std::string message ) +{ + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = message; + throw SALOME::SALOME_Exception(es); + return ; +}*/ +//============================================================================= +char* ADAPT_Gen_i::getVersion() +{ +#if HOMARD_DEVELOPMENT + return CORBA::string_dup(SMESH_VERSION_STR"dev"); +#else + return CORBA::string_dup(SMESH_VERSION_STR); +#endif +} +//=============================================================================== +// Recuperation de la chaine de caracteres par rapport a l'apparition d'un caractere +// ligne : la ligne a manipuler +// caractere : le caractere a reperer +// option : 0 : la chaine avant la premiere apparition du caractere +// 1 : la chaine apres la premiere apparition du caractere +// 2 : la chaine avant la derniere apparition du caractere +// 3 : la chaine apres la derniere apparition du caractere +// Si le caractere est absent, on retourne la chaine totale +//=============================================================================== +std::string ADAPT_Gen_i::GetStringInTexte( const std::string ligne, const std::string caractere, int option ) +{ +// MESSAGE("GetStringInTexte, recherche de '"<> mot_cle ; + chaine = GetStringInTexte ( mot_cle, "\"", 1 ) ; + chaine = GetStringInTexte ( chaine, "\"", 0 ) ; + if ( chaine == "language" ) { section_langue = true ; } + if ( chaine == "HOMARD" ) { section_homard = true ; } + // MESSAGE ( "section_langue = "<" ) + { /*MESSAGE ( "Fin de la section : "<< ligne<<", section_langue = "<> PublisMeshIN ; } + if ( chaine2 == "homard_publish_mesh_out" ) { chainebis >> PublisMeshOUT ; } + // 3.2.2. Les maximum pour YACS + if ( chaine2 == "homard_yacs_max_iter" ) { chainebis >> YACSMaxIter ; } + if ( chaine2 == "homard_yacs_max_node" ) { chainebis >> YACSMaxNode ; } + if ( chaine2 == "homard_yacs_max_elem" ) { chainebis >> YACSMaxElem ; } + if ( chaine2 == "homard_yacs_type_test" ) { YACSTypeTestchaine = chaine ; } + } + } + } + } + } + + // C. Enregistrements + MESSAGE ("Enregistrement de LanguageShort = " << LanguageShort ); + SetLanguageShort( LanguageShort.c_str() ) ; + + MESSAGE ("Enregistrement de PublisMeshIN = " << PublisMeshIN<<", PublisMeshOUT = "<< PublisMeshOUT); + SetPublisMesh(PublisMeshIN, PublisMeshOUT) ; + + MESSAGE ("Enregistrement de YACSMaxIter = " << YACSMaxIter<<", YACSMaxNode = "<< YACSMaxNode<<", YACSMaxElem = "<< YACSMaxElem); + SetYACSMaximum(YACSMaxIter, YACSMaxNode, YACSMaxElem) ; + + MESSAGE ("Enregistrement de TypeTest = " << YACSTypeTestchaine.c_str() ); + int YACSTypeTest ; + if ( ( YACSTypeTestchaine == "VTest > VRef" ) || ( YACSTypeTestchaine == "VTest > VRef" ) ) { YACSTypeTest = 1 ; } + else if ( ( YACSTypeTestchaine == "VTest < VRef" ) || ( YACSTypeTestchaine == "VTest < VRef" ) ) { YACSTypeTest = 2 ; } + else { YACSTypeTest = 0 ; } + MESSAGE ("==> TypeTest = " << YACSTypeTest ); + SetYACSConvergenceType( YACSTypeTest ) ; + + return ; +} +//=============================================================================== +// Langue de SALOME +//=============================================================================== +void ADAPT_Gen_i::SetLanguageShort(const char* LanguageShort) +{ +// MESSAGE ("SetLanguageShort pour LanguageShort = " << LanguageShort ); + _LangueShort = LanguageShort ; + if ( _LangueShort == "fr" ) { _Langue = "Francais" ; } + else { _Langue = "English" ; } + return ; +} +char* ADAPT_Gen_i::GetLanguageShort() +{ +// MESSAGE ("GetLanguageShort"); + return CORBA::string_dup( _LangueShort.c_str() ); +} +//=============================================================================== +// Options de publications +//=============================================================================== +void ADAPT_Gen_i::SetPublisMesh(CORBA::Long PublisMeshIN, CORBA::Long PublisMeshOUT) +{ + _PublisMeshIN = PublisMeshIN ; + _PublisMeshOUT = PublisMeshOUT ; + return ; +} +CORBA::Long ADAPT_Gen_i::GetPublisMeshIN() +{ + return _PublisMeshIN ; +} +CORBA::Long ADAPT_Gen_i::GetPublisMeshOUT() +{ + return _PublisMeshOUT ; +} +//=============================================================================== +// YACS - test de convergence +//=============================================================================== +void ADAPT_Gen_i::SetYACSMaximum(CORBA::Long YACSMaxIter, CORBA::Long YACSMaxNode, CORBA::Long YACSMaxElem) +{ + _YACSMaxIter = YACSMaxIter ; + _YACSMaxNode = YACSMaxNode ; + _YACSMaxElem = YACSMaxElem ; + return ; +} +CORBA::Long ADAPT_Gen_i::GetYACSMaxIter() +{ + return _YACSMaxIter ; +} +CORBA::Long ADAPT_Gen_i::GetYACSMaxNode() +{ + return _YACSMaxNode ; +} +CORBA::Long ADAPT_Gen_i::GetYACSMaxElem() +{ + return _YACSMaxElem ; +} +void ADAPT_Gen_i::SetYACSConvergenceType(CORBA::Long YACSTypeTest) +{ + _YACSTypeTest = YACSTypeTest ; + return ; +} +CORBA::Long ADAPT_Gen_i::GetYACSConvergenceType() +{ + return _YACSTypeTest ; +} + +//============================================================================= +extern "C" +{ + HOMARDENGINE_EXPORT + PortableServer::ObjectId* ADAPTEngine_factory(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId* contId, + const char* instanceName, + const char* interfaceName) + { + MESSAGE("PortableServer::ObjectId* ADAPTEngine_factory()"); + ADAPT_Gen_i* myADAPT_Gen = new ADAPT_Gen_i(orb, poa, contId, instanceName, interfaceName); + return myADAPT_Gen->getId(); + } +} diff --git a/src/ADAPT_I/ADAPT_Gen_i.hxx b/src/ADAPT_I/ADAPT_Gen_i.hxx new file mode 100644 index 000000000..4ef3172f1 --- /dev/null +++ b/src/ADAPT_I/ADAPT_Gen_i.hxx @@ -0,0 +1,347 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef _ADAPT_GEN_I_HXX_ +#define _ADAPT_GEN_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(ADAPT_Gen) +#include CORBA_SERVER_HEADER(HOMARD_Cas) +#include CORBA_SERVER_HEADER(HOMARD_Hypothesis) +#include CORBA_SERVER_HEADER(HOMARD_Iteration) +#include CORBA_SERVER_HEADER(HOMARD_Zone) +#include CORBA_SERVER_HEADER(HOMARD_Boundary) +#include CORBA_SERVER_HEADER(HOMARD_YACS) +#include CORBA_CLIENT_HEADER(SALOMEDS) +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) + +#include "HOMARD_i.hxx" +#include "ADAPT_Gen.hxx" +#include "HomardDriver.hxx" +#include "YACSDriver.hxx" +#include "FrontTrack.hxx" +#include "SALOME_Component_i.hxx" +#include "SALOME_NamingService.hxx" +#include "Utils_CorbaException.hxx" + +#include +#include + +class HOMARDENGINE_EXPORT ADAPT_Gen_i: + public virtual Engines_Component_i, + public virtual POA_ADAPT::ADAPT_Gen +{ +public: + ADAPT_Gen_i( CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId* contId, + const char* instanceName, + const char* interfaceName ); + virtual ~ADAPT_Gen_i(); + + +// Generalites + +// Les creations + ADAPT::HOMARD_Boundary_ptr CreateBoundary (const char* nomBoundary, CORBA::Long typeBoundary); + ADAPT::HOMARD_Boundary_ptr CreateBoundaryCAO(const char* nomBoundary, + const char* DataFile); + ADAPT::HOMARD_Boundary_ptr CreateBoundaryDi (const char* nomBoundary, + const char* MeshName, const char* DataFile); + ADAPT::HOMARD_Boundary_ptr CreateBoundaryCylinder (const char* nomBoundary, + CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, + CORBA::Double Xaxis, CORBA::Double Yaxis, CORBA::Double Zaxis, + CORBA::Double Rayon); + ADAPT::HOMARD_Boundary_ptr CreateBoundarySphere (const char* nomBoundary, + CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, + CORBA::Double Rayon); + ADAPT::HOMARD_Boundary_ptr CreateBoundaryConeR (const char* nomBoundary, + CORBA::Double Xcentre1, CORBA::Double Ycentre1, CORBA::Double Zcentre1, CORBA::Double Rayon1, + CORBA::Double Xcentre2, CORBA::Double Ycentre2, CORBA::Double Zcentre2, CORBA::Double Rayon2); + ADAPT::HOMARD_Boundary_ptr CreateBoundaryConeA (const char* nomBoundary, + CORBA::Double Xaxis, CORBA::Double Yaxis, CORBA::Double Zaxis, CORBA::Double Angle, + CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre); + ADAPT::HOMARD_Boundary_ptr CreateBoundaryTorus (const char* nomBoundary, + CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, + CORBA::Double Xaxis, CORBA::Double Yaxis, CORBA::Double Zaxis, + CORBA::Double RayonRev, CORBA::Double RayonPri); + + ADAPT::HOMARD_Cas_ptr CreateCase (const char* nomCas, const char* MeshName, const char* FileName); + ADAPT::HOMARD_Cas_ptr CreateCaseFromIteration (const char* nomCas, const char* DirNameStart); + ADAPT::HOMARD_Cas_ptr CreateCaseFromCaseLastIteration (const char* nomCas, const char* DirNameStart); + ADAPT::HOMARD_Cas_ptr CreateCaseFromCaseIteration (const char* nomCas, const char* DirNameStart, CORBA::Long Number); + ADAPT::HOMARD_Cas_ptr CreateCase0 (const char* nomCas, const char* MeshName, const char* FileName, CORBA::Long MeshOption, CORBA::Long NumeIter, CORBA::Long Option); + std::string CreateCase1 (const char* DirNameStart, CORBA::Long Number); + + ADAPT::HOMARD_Hypothesis_ptr CreateHypothesis(const char* nomHypothesis); + + ADAPT::HOMARD_Iteration_ptr CreateIteration (const char* nomIter, const char* nomIterParent); + + ADAPT::HOMARD_Zone_ptr CreateZone (const char* nomZone, CORBA::Long typeZone); + ADAPT::HOMARD_Zone_ptr CreateZoneBox (const char* nomZone, + CORBA::Double Xmini, CORBA::Double Xmaxi, + CORBA::Double Ymini, CORBA::Double Ymaxi, + CORBA::Double Zmini, CORBA::Double Zmaxi); + ADAPT::HOMARD_Zone_ptr CreateZoneBox2D (const char* nomZone, + CORBA::Double Umini, CORBA::Double Umaxi, + CORBA::Double Vmini, CORBA::Double Vmaxi, + CORBA::Long Orient); + ADAPT::HOMARD_Zone_ptr CreateZoneCylinder (const char* nomZone, + CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, + CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, + CORBA::Double Rayon, CORBA::Double Haut); + ADAPT::HOMARD_Zone_ptr CreateZoneDisk (const char* nomZone, + CORBA::Double Ucentre, CORBA::Double Vcentre, + CORBA::Double Rayon, + CORBA::Long Orient); + ADAPT::HOMARD_Zone_ptr CreateZoneDiskWithHole (const char* nomZone, + CORBA::Double Ucentre, CORBA::Double Vcentre, + CORBA::Double Rayon, CORBA::Double Rayonint, + CORBA::Long Orient); + ADAPT::HOMARD_Zone_ptr CreateZonePipe (const char* nomZone, + CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, + CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, + CORBA::Double Rayon, CORBA::Double Haut, CORBA::Double Rayonint); + ADAPT::HOMARD_Zone_ptr CreateZoneSphere (const char* nomZone, + CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon); + +// Les informations + ADAPT::HOMARD_Boundary_ptr GetBoundary (const char* nomBoundary); + ADAPT::HOMARD_Cas_ptr GetCase (const char* nomCas); + ADAPT::HOMARD_Hypothesis_ptr GetHypothesis (const char* nomHypothesis); + ADAPT::HOMARD_Iteration_ptr GetIteration (const char* nomIteration); + ADAPT::HOMARD_YACS_ptr GetYACS (const char* nomYACS); + ADAPT::HOMARD_Zone_ptr GetZone (const char* nomZone); + + ADAPT::listeBoundarys* GetAllBoundarysName(); + ADAPT::listeCases* GetAllCasesName(); + ADAPT::listeHypotheses* GetAllHypothesesName(); + ADAPT::listeIterations* GetAllIterationsName(); + ADAPT::listeYACSs* GetAllYACSsName(); + ADAPT::listeZones* GetAllZonesName(); + + void MeshInfo (const char* nomCas, + const char* MeshName, const char* FileName, const char* DirName, + CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte); + + ADAPT::HOMARD_Iteration_ptr LastIteration (const char* nomCas); + +// L'etude + void UpdateStudy(); + void IsValidStudy(); + +// Liens entre structures + void InvalideBoundary(const char* nomBoundary); + void InvalideHypo(const char* nomHypo); + void InvalideIter(const char* nomIter); + void InvalideIterOption(const char* nomIter, CORBA::Long Option); + void InvalideIterInfo(const char* nomIter); + void InvalideYACS(const char* nomYACS); + void InvalideZone(const char* nomZone); + + CORBA::Long DeleteBoundary(const char* nomBoundary); + CORBA::Long DeleteCase(const char* nomCas, CORBA::Long Option); + CORBA::Long DeleteHypo(const char* nomHypothesis); + CORBA::Long DeleteIteration(const char* nomIter, CORBA::Long Option); + CORBA::Long DeleteIterationOption(const char* nomIter, CORBA::Long Option1, CORBA::Long Option2); + CORBA::Long DeleteYACS(const char* nomYACS, CORBA::Long Option); + CORBA::Long DeleteZone(const char* nomZone); + + void AssociateIterHypo(const char* nomIter, const char* nomHypothesis); + + void AssociateHypoZone(const char* nomHypothesis, const char* nomZone, CORBA::Long TypeUse); + void DissociateHypoZone(const char* nomHypothesis, const char* nomZone); + + void AssociateCaseIter(const char* nomCas, const char* nomIter, + const char* labelIter); + +// Actions + void SetEtatIter(const char* nomIter,const CORBA::Long Etat); + char* CreateDirNameIter(const char* nomrep, CORBA::Long num ); + + CORBA::Long Compute(const char* nomIteration, CORBA::Long etatMenage, CORBA::Long modeHOMARD, CORBA::Long Option1, CORBA::Long Option2); + CORBA::Long ComputeAdap(ADAPT::HOMARD_Cas_var myCase, ADAPT::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage, HomardDriver* myDriver, CORBA::Long Option1, CORBA::Long Option2); + CORBA::Long ComputeCAO(ADAPT::HOMARD_Cas_var myCase, ADAPT::HOMARD_Iteration_var myIteration, CORBA::Long Option1, CORBA::Long Option2); + CORBA::Long ComputeCAObis(ADAPT::HOMARD_Iteration_var myIteration, CORBA::Long Option1, CORBA::Long Option2); + char* ComputeDirManagement(ADAPT::HOMARD_Cas_var myCase, ADAPT::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage); + char* ComputeDirPaManagement(ADAPT::HOMARD_Cas_var myCase, ADAPT::HOMARD_Iteration_var myIteration); + void DriverTexteZone(ADAPT::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver); + void DriverTexteField(ADAPT::HOMARD_Iteration_var myIteration, ADAPT::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver); + int DriverTexteBoundary(ADAPT::HOMARD_Cas_var myCase, HomardDriver* myDriver); + void DriverTexteFieldInterp(ADAPT::HOMARD_Iteration_var myIteration, ADAPT::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver); + + char* VerifieDir(const char* nomDir); + + void PublishFileUnderIteration(const char* NomIter, const char* NomFich, const char* Commentaire); + void PublishFileUnderYACS(const char* NomYACS, const char* NomFich, const char* Commentaire); + void PublishBoundaryUnderCase(const char* CaseName, const char* BoundaryName); + void PublishCaseUnderYACS(const char* YACSName, const char* CaseName); + void PublishResultInSmesh(const char* NomFich, CORBA::Long Option); + void DeleteResultInSmesh(std::string NomFich, std::string MeshName); + void PublishMeshIterInSmesh(const char* NomIter); + +// YACS + ADAPT::HOMARD_YACS_ptr CreateYACSSchema (const char* YACSName, const char* nomCas, const char* ScriptFile, const char* DirName, const char* MeshFile); + CORBA::Long YACSWrite(const char* nomYACS); + CORBA::Long YACSWriteOnFile(const char* nomYACS, const char* XMLFile); + std::string YACSDriverTexteZone(ADAPT::HOMARD_Hypothesis_var myHypo, YACSDriver* myDriver); + std::string YACSDriverTexteBoundary(ADAPT::HOMARD_Cas_var myCase, YACSDriver* myDriver); + +// Preferences + void SetPreferences() ; + void SetLanguageShort(const char* LanguageShort); + char* GetLanguageShort(); + void SetPublisMesh(CORBA::Long PublisMeshIN, CORBA::Long PublisMeshOUT); + CORBA::Long GetPublisMeshIN(); + CORBA::Long GetPublisMeshOUT(); + void SetYACSMaximum(CORBA::Long YACSMaxIter, CORBA::Long YACSMaxNode, CORBA::Long YACSMaxElem); + CORBA::Long GetYACSMaxIter(); + CORBA::Long GetYACSMaxNode(); + CORBA::Long GetYACSMaxElem(); + void SetYACSConvergenceType(CORBA::Long YACSTypeTest); + CORBA::Long GetYACSConvergenceType(); + + + // --------------------------------------------------------------- + // next functions are inherited from SALOMEDS::Driver interface + // --------------------------------------------------------------- + + // --> Persistence + virtual SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + CORBA::Boolean isMultiFile); + + virtual SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + CORBA::Boolean isMultiFile); + + virtual CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile& theStream, + const char* theURL, + CORBA::Boolean isMultiFile); + + virtual CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile& theStream, + const char* theURL, + CORBA::Boolean isMultiFile); + + virtual void Close(SALOMEDS::SComponent_ptr IORSComponent); + + virtual char* ComponentDataType(); + + virtual char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, + const char* IORString, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII); + + virtual char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, + const char* aLocalPersistentID, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII); + + // --> Data publishing + virtual CORBA::Boolean CanPublishInStudy(CORBA::Object_ptr theIOR); + + virtual SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::SObject_ptr theSObject, + CORBA::Object_ptr theObject, + const char* theName); + + // --> Copy/Paste + virtual CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject); + + virtual SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, + CORBA::Long& theObjectID); + + virtual CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID); + + virtual SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream, + CORBA::Long theObjectID, + SALOMEDS::SObject_ptr theObject); + +// virtual void SALOMEException( std::string message ); + +private: + SALOMEDS::SObject_ptr PublishBoundaryInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder, + ADAPT::HOMARD_Boundary_ptr theObject, const char* theName); + SALOMEDS::SObject_ptr PublishCaseInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder, + ADAPT::HOMARD_Cas_ptr theObject, const char* theName); + SALOMEDS::SObject_ptr PublishHypotheseInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder, + ADAPT::HOMARD_Hypothesis_ptr theObject, const char* theName); + SALOMEDS::SObject_ptr PublishYACSInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder, + ADAPT::HOMARD_YACS_ptr theObject, const char* theName); + SALOMEDS::SObject_ptr PublishZoneInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder, + ADAPT::HOMARD_Zone_ptr theObject, const char* theName); + virtual void PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder, + SALOMEDS::SObject_var aResultSO, + const char* theName, const char* comment, const char* icone, const char* ior); + + PortableServer::ServantBase_var GetServant(CORBA::Object_ptr theObject); + + ADAPT::HOMARD_Boundary_ptr newBoundary(); + ADAPT::HOMARD_Cas_ptr newCase(); + ADAPT::HOMARD_Hypothesis_ptr newHypothesis(); + ADAPT::HOMARD_Iteration_ptr newIteration(); + ADAPT::HOMARD_YACS_ptr newYACS(); + ADAPT::HOMARD_Zone_ptr newZone(); + + + virtual Engines::TMPFile* DumpPython(CORBA::Boolean isPublished, + CORBA::Boolean isMultiFile, + CORBA::Boolean& isValidScript); + + virtual char* getVersion(); + std::string GetStringInTexte( const std::string Texte, const std::string String, int option ) ; + +private: + struct StudyContext + { + std::map _mesBoundarys; + std::map _mesCas; + std::map _mesHypotheses; + std::map _mesIterations; + std::map _mesYACSs; + std::map _mesZones; + std::map _idmap; + }; + + ::ADAPT_Gen* myHomard; + SALOMEDS::Study_var myStudy; + StudyContext myStudyContext; + SALOME_NamingService* _NS; + + int _tag_gene ; + int _tag_boun ; + int _tag_hypo ; + int _tag_yacs ; + int _tag_zone ; + +// Preferences + std::string _Langue ; + std::string _LangueShort ; + int _PublisMeshIN ; + int _PublisMeshOUT ; + int _YACSMaxIter ; + int _YACSMaxNode ; + int _YACSMaxElem ; + int _YACSTypeTest ; + ; + +}; + +#endif diff --git a/src/ADAPT_I/CMakeLists.txt b/src/ADAPT_I/CMakeLists.txt new file mode 100644 index 000000000..42b4ccc1a --- /dev/null +++ b/src/ADAPT_I/CMakeLists.txt @@ -0,0 +1,102 @@ +# Copyright (C) 2012-2020 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# --- options --- +# additional include directories +INCLUDE_DIRECTORIES( + ${OMNIORB_INCLUDE_DIR} + ${KERNEL_INCLUDE_DIRS} + ${MEDFILE_INCLUDE_DIRS} + ${SMESH_INCLUDE_DIRS} + ${GEOM_INCLUDE_DIRS} + ${HDF5_INCLUDE_DIRS} + ${PROJECT_BINARY_DIR} + ${PROJECT_BINARY_DIR}/idl + ${PROJECT_BINARY_DIR}/adm_local/unix + ${PROJECT_SOURCE_DIR}/src/ADAPTFrontTrack + ${PROJECT_SOURCE_DIR}/src/ADAPT + ${PROJECT_SOURCE_DIR}/src/ADAPTGUI + ${PROJECT_SOURCE_DIR}/src/SMESH_I + ${PROJECT_SOURCE_DIR}/src/SMESH + ${PROJECT_SOURCE_DIR}/src/SMESHDS + ${PROJECT_SOURCE_DIR}/src/SMDS + ${PROJECT_SOURCE_DIR}/src/SMESHUtils + ${MEDCOUPLING_INCLUDE_DIRS} +) +# additional preprocessor / compiler flags +ADD_DEFINITIONS( + ${OMNIORB_DEFINITIONS} +) + +# libraries to link to +SET(_link_LIBRARIES + ${MEDFILE_C_LIBRARIES} + ${KERNEL_SalomeContainer} + ${KERNEL_SalomeNS} + ${KERNEL_Registry} + ${KERNEL_SalomeHDFPersist} + ${KERNEL_SalomeLifeCycleCORBA} + ${KERNEL_TOOLSDS} + ${KERNEL_SalomeGenericObj} + ${SMESH_SalomeIDLSMESH} + ${SMESH_SMESHEngine} + ${MEDCoupling_medloader} + SMESHimpl + ADAPTFrontTrack + ADAPTImpl +) + +# --- headers --- + +# header files / no moc processing +SET(ADAPTEngine_HEADERS + HOMARD_Cas_i.hxx + HOMARD_Hypothesis_i.hxx + HOMARD_Iteration_i.hxx + HOMARD_Zone_i.hxx + ADAPT_Gen_i.hxx + HOMARD_Boundary_i.hxx + HOMARD_YACS_i.hxx + HomardMedCommun.h + HOMARD_i.hxx + #~MG_ADAPT_i.hxx +) + +# --- sources --- + +# sources / static +SET(ADAPTEngine_SOURCES + HOMARD_Cas_i.cxx + HOMARD_Hypothesis_i.cxx + HOMARD_Iteration_i.cxx + ADAPT_Gen_i.cxx + HOMARD_Zone_i.cxx + HOMARD_Boundary_i.cxx + HOMARD_YACS_i.cxx + HomardMedCommun.cxx + #~MG_ADAPT_i.cxx +) + +# --- rules --- + +ADD_LIBRARY(ADAPTEngine ${ADAPTEngine_SOURCES}) +TARGET_LINK_LIBRARIES(ADAPTEngine ${_link_LIBRARIES} ) +INSTALL(TARGETS ADAPTEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +INSTALL(FILES ${ADAPTEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) diff --git a/src/ADAPT_I/HOMARD_Boundary_i.cxx b/src/ADAPT_I/HOMARD_Boundary_i.cxx new file mode 100644 index 000000000..cc1097767 --- /dev/null +++ b/src/ADAPT_I/HOMARD_Boundary_i.cxx @@ -0,0 +1,262 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier +// +#include "HOMARD_Boundary_i.hxx" +#include "ADAPT_Gen_i.hxx" +#include "HOMARD_Boundary.hxx" +#include "HOMARD_DriverTools.hxx" + +#include "utilities.h" + +//============================================================================= +/*! + * standard constructor + */ +//============================================================================= +HOMARD_Boundary_i::HOMARD_Boundary_i() +{ + MESSAGE( "Default constructor, not for use" ); + ASSERT( 0 ); +} +//============================================================================= +/*! + * standard constructor + */ +//============================================================================= +HOMARD_Boundary_i::HOMARD_Boundary_i( CORBA::ORB_ptr orb, + ADAPT::ADAPT_Gen_var engine ) +{ + MESSAGE( "HOMARD_Boundary_i" ); + _gen_i = engine; + _orb = orb; + myHomardBoundary = new ::HOMARD_Boundary(); + ASSERT( myHomardBoundary ); +} +//============================================================================= +/*! + * standard destructor + */ +//============================================================================= +HOMARD_Boundary_i::~HOMARD_Boundary_i() +{ +} +//============================================================================= +//============================================================================= +// Generalites +//============================================================================= +//============================================================================= +void HOMARD_Boundary_i::SetName( const char* Name ) +{ + ASSERT( myHomardBoundary ); + myHomardBoundary->SetName( Name ); +} +//============================================================================= +char* HOMARD_Boundary_i::GetName() +{ + ASSERT( myHomardBoundary ); + return CORBA::string_dup( myHomardBoundary->GetName().c_str() ); +} +//============================================================================= +CORBA::Long HOMARD_Boundary_i::Delete() +{ + ASSERT( myHomardBoundary ); + char* BoundaryName = GetName() ; + MESSAGE ( "Delete : destruction de la frontiere " << BoundaryName ); + return _gen_i->DeleteBoundary(BoundaryName) ; +} +//============================================================================= +char* HOMARD_Boundary_i::GetDumpPython() +{ + ASSERT( myHomardBoundary ); + return CORBA::string_dup( myHomardBoundary->GetDumpPython().c_str() ); +} +//============================================================================= +std::string HOMARD_Boundary_i::Dump() const +{ + return ADAPT::Dump( *myHomardBoundary ); +} +//============================================================================= +bool HOMARD_Boundary_i::Restore( const std::string& stream ) +{ + return ADAPT::Restore( *myHomardBoundary, stream ); +} +//============================================================================= +//============================================================================= +// Caracteristiques +//============================================================================= +//============================================================================= +void HOMARD_Boundary_i::SetType( CORBA::Long Type ) +{ + ASSERT( myHomardBoundary ); + myHomardBoundary->SetType( Type ); +} +//============================================================================= +CORBA::Long HOMARD_Boundary_i::GetType() +{ + ASSERT( myHomardBoundary ); + return CORBA::Long( myHomardBoundary->GetType() ); +} +//============================================================================= +void HOMARD_Boundary_i::SetMeshName( const char* MeshName ) +{ + ASSERT( myHomardBoundary ); + myHomardBoundary->SetMeshName( MeshName ); +} +//============================================================================= +char* HOMARD_Boundary_i::GetMeshName() +{ + ASSERT( myHomardBoundary ); + return CORBA::string_dup( myHomardBoundary->GetMeshName().c_str() ); +} +//============================================================================= +void HOMARD_Boundary_i::SetDataFile( const char* DataFile ) +{ + ASSERT( myHomardBoundary ); + myHomardBoundary->SetDataFile( DataFile ); + int PublisMeshIN = _gen_i->GetPublisMeshIN () ; + if ( PublisMeshIN != 0 ) { _gen_i->PublishResultInSmesh(DataFile, 0); } +} +//============================================================================= +char* HOMARD_Boundary_i::GetDataFile() +{ + ASSERT( myHomardBoundary ); + return CORBA::string_dup( myHomardBoundary->GetDataFile().c_str() ); +} +//============================================================================= +void HOMARD_Boundary_i::SetCylinder( double X0, double X1, double X2, double X3, double X4, double X5, double X6 ) +{ + ASSERT( myHomardBoundary ); + myHomardBoundary->SetCylinder( X0, X1, X2, X3, X4, X5, X6 ); +} +//============================================================================= +void HOMARD_Boundary_i::SetSphere( double Xcentre, double Ycentre, double ZCentre, double rayon ) +{ + ASSERT( myHomardBoundary ); + myHomardBoundary->SetSphere( Xcentre, Ycentre, ZCentre, rayon ); +} +//============================================================================= +void HOMARD_Boundary_i::SetConeR( double Xcentre1, double Ycentre1, double Zcentre1, double Rayon1, double Xcentre2, double Ycentre2, double Zcentre2, double Rayon2) +{ + ASSERT( myHomardBoundary ); + myHomardBoundary->SetConeR( Xcentre1, Ycentre1, Zcentre1, Rayon1, Xcentre2, Ycentre2, Zcentre2, Rayon2 ); +} +//============================================================================= +void HOMARD_Boundary_i::SetConeA( double Xaxe, double Yaxe, double Zaxe, double Angle, double Xcentre, double Ycentre, double Zcentre) +{ + ASSERT( myHomardBoundary ); + myHomardBoundary->SetConeA( Xaxe, Yaxe, Zaxe, Angle, Xcentre, Ycentre, Zcentre ); +} +//============================================================================= +void HOMARD_Boundary_i::SetTorus( double X0, double X1, double X2, double X3, double X4, double X5, double X6, double X7 ) +{ + ASSERT( myHomardBoundary ); + myHomardBoundary->SetTorus( X0, X1, X2, X3, X4, X5, X6, X7 ); +} +//============================================================================= +ADAPT::double_array* HOMARD_Boundary_i::GetCoords() +{ + ASSERT( myHomardBoundary ); + ADAPT::double_array_var aResult = new ADAPT::double_array(); + std::vector mesCoor = myHomardBoundary->GetCoords(); + aResult->length( mesCoor .size() ); + std::vector::const_iterator it; + int i = 0; + for ( it = mesCoor.begin(); it != mesCoor.end(); it++ ) + aResult[i++] = (*it); + return aResult._retn(); +} +//============================================================================= +void HOMARD_Boundary_i::SetLimit( double Xincr, double Yincr, double Zincr ) +{ + ASSERT( myHomardBoundary ); + myHomardBoundary->SetLimit( Xincr, Yincr, Zincr ); +} +//============================================================================= +ADAPT::double_array* HOMARD_Boundary_i::GetLimit() +{ + ASSERT( myHomardBoundary ); + ADAPT::double_array_var aResult = new ADAPT::double_array(); + std::vector mesCoor = myHomardBoundary->GetLimit(); + aResult->length( mesCoor .size() ); + std::vector::const_iterator it; + int i = 0; + for ( it = mesCoor.begin(); it != mesCoor.end(); it++ ) + aResult[i++] = (*it); + return aResult._retn(); +} +//============================================================================= +void HOMARD_Boundary_i::AddGroup( const char* Group) +{ + ASSERT( myHomardBoundary ); + myHomardBoundary->AddGroup( Group ); +} +//============================================================================= +void HOMARD_Boundary_i::SetGroups(const ADAPT::ListGroupType& ListGroup) +{ + ASSERT( myHomardBoundary ); + std::list ListString; + for ( int i = 0; i < ListGroup.length(); i++ ) + { + ListString.push_back(std::string(ListGroup[i])); + } + myHomardBoundary->SetGroups( ListString ); +} +//============================================================================= +ADAPT::ListGroupType* HOMARD_Boundary_i::GetGroups() +{ + ASSERT( myHomardBoundary ); + const std::list& ListString = myHomardBoundary->GetGroups(); + ADAPT::ListGroupType_var aResult = new ADAPT::ListGroupType; + aResult->length( ListString.size() ); + std::list::const_iterator it; + int i = 0; + for ( it = ListString.begin(); it != ListString.end(); it++ ) + { + aResult[i++] = CORBA::string_dup( (*it).c_str() ); + } + return aResult._retn(); +} +//============================================================================= +//============================================================================= +// Liens avec les autres structures +//============================================================================= +//============================================================================= +void HOMARD_Boundary_i::SetCaseCreation( const char* NomCaseCreation ) +{ + ASSERT( myHomardBoundary ); + myHomardBoundary->SetCaseCreation( NomCaseCreation ); +} +//============================================================================= +char* HOMARD_Boundary_i::GetCaseCreation() +{ + ASSERT( myHomardBoundary ); + return CORBA::string_dup( myHomardBoundary->GetCaseCreation().c_str() ); +} + + + diff --git a/src/ADAPT_I/HOMARD_Boundary_i.hxx b/src/ADAPT_I/HOMARD_Boundary_i.hxx new file mode 100644 index 000000000..37b06921e --- /dev/null +++ b/src/ADAPT_I/HOMARD_Boundary_i.hxx @@ -0,0 +1,112 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier +// + +#ifndef _HOMARD_Boundary_I_HXX_ +#define _HOMARD_Boundary_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(ADAPT_Gen) +#include CORBA_SERVER_HEADER(HOMARD_Boundary) + +#include "HOMARD_i.hxx" +#include "SALOME_Component_i.hxx" +#include "SALOME_NamingService.hxx" +#include "Utils_CorbaException.hxx" + +#include + +class HOMARD_Boundary; + +class HOMARDENGINE_EXPORT HOMARD_Boundary_i: + public virtual Engines_Component_i, + public virtual POA_ADAPT::HOMARD_Boundary, + public virtual PortableServer::ServantBase +{ +public: + HOMARD_Boundary_i( CORBA::ORB_ptr orb, ADAPT::ADAPT_Gen_var gen_i ); + HOMARD_Boundary_i(); + + virtual ~HOMARD_Boundary_i(); + +// Generalites + void SetName( const char* Name ); + char* GetName(); + + CORBA::Long Delete(); + + char* GetDumpPython(); + + std::string Dump() const; + bool Restore( const std::string& stream ); + +// Caracteristiques + void SetType( CORBA::Long Type ); + CORBA::Long GetType(); + + void SetMeshName( const char* MeshName ); + char* GetMeshName(); + + void SetDataFile( const char* DataFile ); + char* GetDataFile(); + + void SetCylinder( double Xcentre, double Ycentre, double ZCentre, + double Xaxe, double Yaxe, double Zaxe, + double rayon ); + void SetSphere( double Xcentre, double Ycentre, double ZCentre, + double rayon ); + void SetConeR( double Xcentre1, double Ycentre1, double Zcentre1, double Rayon1, + double Xcentre2, double Ycentre2, double Zcentre2, double Rayon2); + void SetConeA( double Xaxe, double Yaxe, double Zaxe, double Angle, + double Xcentre, double Ycentre, double ZCentre); + void SetTorus( double Xcentre, double Ycentre, double ZCentre, + double Xaxe, double Yaxe, double Zaxe, + double rayonRev, double rayonPri ); + + ADAPT::double_array* GetCoords(); + + void SetLimit( double Xincr, double Yincr, double Zincr); + ADAPT::double_array* GetLimit(); + + void AddGroup( const char* Group); + void SetGroups(const ADAPT::ListGroupType& ListGroup); + ADAPT::ListGroupType* GetGroups(); + +// Liens avec les autres structures + void SetCaseCreation( const char* NomCaseCreation ); + char* GetCaseCreation(); + + +private: + ::HOMARD_Boundary* myHomardBoundary; + + CORBA::ORB_ptr _orb; + ADAPT::ADAPT_Gen_var _gen_i; +}; + +#endif diff --git a/src/ADAPT_I/HOMARD_Cas_i.cxx b/src/ADAPT_I/HOMARD_Cas_i.cxx new file mode 100644 index 000000000..432faf678 --- /dev/null +++ b/src/ADAPT_I/HOMARD_Cas_i.cxx @@ -0,0 +1,599 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier +// + +#include "HOMARD_Cas_i.hxx" +#include "ADAPT_Gen_i.hxx" +#include "HOMARD_Cas.hxx" +#include "HOMARD_DriverTools.hxx" +#include "HOMARD.hxx" + +#include "utilities.h" +#include +#include + +#ifdef WIN32 +#include +#endif + +//============================================================================= +/*! + * standard constructor + */ +//============================================================================= +HOMARD_Cas_i::HOMARD_Cas_i() +{ + MESSAGE( "Default constructor, not for use" ); + ASSERT( 0 ); +} + +//============================================================================= +/*! + * standard constructor + */ +//============================================================================= +HOMARD_Cas_i::HOMARD_Cas_i( CORBA::ORB_ptr orb, + ADAPT::ADAPT_Gen_var engine ) +{ + MESSAGE( "HOMARD_Cas_i" ); + _gen_i = engine; + _orb = orb; + myHomardCas = new ::HOMARD_Cas(); + ASSERT( myHomardCas ); +} + +//============================================================================= +/*! + * standard destructor + */ +//============================================================================= +HOMARD_Cas_i::~HOMARD_Cas_i() +{ +} +//============================================================================= +//============================================================================= +// Generalites +//============================================================================= +//============================================================================= +void HOMARD_Cas_i::SetName( const char* Name ) +{ + ASSERT( myHomardCas ); + myHomardCas->SetName( Name ); +} +//============================================================================= +char* HOMARD_Cas_i::GetName() +{ + ASSERT( myHomardCas ); + return CORBA::string_dup( myHomardCas->GetName().c_str() ); +} +//============================================================================= +CORBA::Long HOMARD_Cas_i::Delete( CORBA::Long Option ) +{ + ASSERT( myHomardCas ); + char* CaseName = GetName() ; + MESSAGE ( "Delete : destruction du cas " << CaseName << ", Option = " << Option ); + return _gen_i->DeleteCase(CaseName, Option) ; +} +//============================================================================= +char* HOMARD_Cas_i::GetDumpPython() +{ + ASSERT( myHomardCas ); + return CORBA::string_dup( myHomardCas->GetDumpPython().c_str() ); +} +//============================================================================= +std::string HOMARD_Cas_i::Dump() const +{ + return ADAPT::Dump( *myHomardCas ); +} +//============================================================================= +bool HOMARD_Cas_i::Restore( const std::string& stream ) +{ + return ADAPT::Restore( *myHomardCas, stream ); +} +//============================================================================= +//============================================================================= +// Caracteristiques +//============================================================================= +//============================================================================= +void HOMARD_Cas_i::SetDirName( const char* NomDir ) +{ + ASSERT( myHomardCas ); + int codret ; + // A. recuperation du nom ; on ne fait rien si c'est le meme + char* oldrep = GetDirName() ; + if ( strcmp(oldrep,NomDir) == 0 ) + { + return ; + } + MESSAGE ( "SetDirName : passage de oldrep = "<< oldrep << " a NomDir = "<VerifieDir(NomDir) ; + if ( ( std::string(casenamedir).size() > 0 ) & ( strcmp(CaseName,casenamedir)!=0 ) ) + { + INFOS ( "Le repertoire " << NomDir << " est deja utilise pour le cas "<< casenamedir ); + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + std::string text ; + text = "The directory " + std::string(NomDir) + " is already used for the case " + std::string(casenamedir) ; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + } + // C. Changement/creation du repertoire + codret = myHomardCas->SetDirName( NomDir ); + if ( codret != 0 ) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + std::string text ; + if ( codret == 1 ) { text = "The directory for the case cannot be modified because some iterations are already defined." ; } + else { text = "The directory for the case cannot be reached." ; } + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + } + // D. En cas de reprise, deplacement du point de depart + if ( GetState() != 0 ) + { + MESSAGE ( "etat : " << GetState() ) ; + // D.1. Nom local du repertoire de l'iteration de depart dans le repertoire actuel du cas + ADAPT::HOMARD_Iteration_ptr Iter = GetIter0() ; + char* DirNameIter = Iter->GetDirNameLoc() ; + MESSAGE ( "SetDirName : nom actuel pour le repertoire de l iteration, DirNameIter = "<< DirNameIter); + // D.2. Recherche d'un nom local pour l'iteration de depart dans le futur repertoire du cas + char* nomDirIter = _gen_i->CreateDirNameIter(NomDir, 0 ); + MESSAGE ( "SetDirName : nom futur pour le repertoire de l iteration, nomDirIter = "<< nomDirIter); + // D.3. Creation du futur repertoire local pour l'iteration de depart + std::string nomDirIterTotal ; + nomDirIterTotal = std::string(NomDir) + "/" + std::string(nomDirIter) ; +#ifndef WIN32 + if (mkdir(nomDirIterTotal.c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0) +#else + if (_mkdir(nomDirIterTotal.c_str()) != 0) +#endif + { + MESSAGE ( "nomDirIterTotal : " << nomDirIterTotal ) ; + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + std::string text = "The directory for the starting iteration cannot be created." ; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + } + // D.4. Deplacement du contenu du repertoire + std::string oldnomDirIterTotal ; + oldnomDirIterTotal = std::string(oldrep) + "/" + std::string(DirNameIter) ; + std::string commande = "mv " + std::string(oldnomDirIterTotal) + "/*" + " " + std::string(nomDirIterTotal) ; + codret = system(commande.c_str()) ; + if ( codret != 0 ) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + std::string text = "The starting point for the case cannot be moved into the new directory." ; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + } + commande = "rm -rf " + std::string(oldnomDirIterTotal) ; + codret = system(commande.c_str()) ; + if ( codret != 0 ) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + std::string text = "The starting point for the case cannot be deleted." ; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + } + // D.5. Memorisation du nom du repertoire de l'iteration + Iter->SetDirNameLoc(nomDirIter) ; + } + return ; +} +//============================================================================= +char* HOMARD_Cas_i::GetDirName() +{ + ASSERT( myHomardCas ); + return CORBA::string_dup( myHomardCas->GetDirName().c_str() ); +} +//============================================================================= +CORBA::Long HOMARD_Cas_i::GetState() +{ + ASSERT( myHomardCas ); +// Nom de l'iteration initiale + char* Iter0Name = GetIter0Name() ; + ADAPT::HOMARD_Iteration_ptr Iter = _gen_i->GetIteration(Iter0Name) ; + int state = Iter->GetNumber() ; + return state ; +} +//============================================================================= +CORBA::Long HOMARD_Cas_i::GetNumberofIter() +{ + ASSERT( myHomardCas ); + return myHomardCas->GetNumberofIter(); +} +//============================================================================= +void HOMARD_Cas_i::SetConfType( CORBA::Long ConfType ) +{ + ASSERT( myHomardCas ); +// VERIFICATION( (ConfType>=-2) && (ConfType<=3) ); + myHomardCas->SetConfType( ConfType ); +} +//============================================================================= +CORBA::Long HOMARD_Cas_i::GetConfType() +{ + ASSERT( myHomardCas ); + return myHomardCas->GetConfType(); +} +//============================================================================= +void HOMARD_Cas_i::SetExtType( CORBA::Long ExtType ) +{ + ASSERT( myHomardCas ); +// VERIFICATION( (ExtType>=0) && (ExtType<=2) ); + myHomardCas->SetExtType( ExtType ); +} +//============================================================================= +CORBA::Long HOMARD_Cas_i::GetExtType() +{ + ASSERT( myHomardCas ); + return myHomardCas->GetExtType(); +} +//============================================================================= +void HOMARD_Cas_i::SetBoundingBox( const ADAPT::extrema& LesExtrema ) +{ + ASSERT( myHomardCas ); + std::vector VExtrema; + ASSERT( LesExtrema.length() == 10 ); + VExtrema.resize( LesExtrema.length() ); + for ( int i = 0; i < LesExtrema.length(); i++ ) + { + VExtrema[i] = LesExtrema[i]; + } + myHomardCas->SetBoundingBox( VExtrema ); +} +//============================================================================= +ADAPT::extrema* HOMARD_Cas_i::GetBoundingBox() +{ + ASSERT(myHomardCas ); + ADAPT::extrema_var aResult = new ADAPT::extrema(); + std::vector LesExtremes = myHomardCas->GetBoundingBox(); + ASSERT( LesExtremes.size() == 10 ); + aResult->length( 10 ); + for ( int i = 0; i < LesExtremes.size(); i++ ) + { + aResult[i] = LesExtremes[i]; + } + return aResult._retn(); +} +//============================================================================= +void HOMARD_Cas_i::AddGroup( const char* Group) +{ + ASSERT( myHomardCas ); + myHomardCas->AddGroup( Group ); +} +//============================================================================= +void HOMARD_Cas_i::SetGroups( const ADAPT::ListGroupType& ListGroup ) +{ + ASSERT( myHomardCas ); + std::list ListString ; + for ( int i = 0; i < ListGroup.length(); i++ ) + { + ListString.push_back(std::string(ListGroup[i])); + } + myHomardCas->SetGroups( ListString ); +} +//============================================================================= +ADAPT::ListGroupType* HOMARD_Cas_i::GetGroups() +{ + ASSERT(myHomardCas ); + const std::list& ListString = myHomardCas->GetGroups(); + ADAPT::ListGroupType_var aResult = new ADAPT::ListGroupType(); + aResult->length( ListString.size() ); + std::list::const_iterator it; + int i = 0; + for ( it = ListString.begin(); it != ListString.end(); it++ ) + { + aResult[i++] = CORBA::string_dup( (*it).c_str() ); + } + return aResult._retn(); +} +//============================================================================= +void HOMARD_Cas_i::AddBoundary(const char* BoundaryName) +{ + MESSAGE ("HOMARD_Cas_i::AddBoundary : BoundaryName = "<< BoundaryName ); + const char * Group = "" ; + AddBoundaryGroup( BoundaryName, Group) ; +} +//============================================================================= +void HOMARD_Cas_i::AddBoundaryGroup( const char* BoundaryName, const char* Group) +{ + MESSAGE ("HOMARD_Cas_i::AddBoundaryGroup : BoundaryName = "<< BoundaryName << ", Group = " << Group ); + ASSERT( myHomardCas ); + // A. Préalables + // A.1. Caractéristiques de la frontière à ajouter + ADAPT::HOMARD_Boundary_ptr myBoundary = _gen_i->GetBoundary(BoundaryName) ; + ASSERT(!CORBA::is_nil(myBoundary)); + int BoundaryType = myBoundary->GetType(); + MESSAGE ( ". BoundaryType = " << BoundaryType ); + // A.2. La liste des frontiere+groupes + const std::list& ListBoundaryGroup = myHomardCas->GetBoundaryGroup(); + std::list::const_iterator it; + // B. Controles + const char * boun ; + int erreur = 0 ; + while ( erreur == 0 ) + { + // B.1. Si on ajoute une frontière CAO, elle doit être la seule frontière + if ( BoundaryType == -1 ) + { + for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ ) + { + boun = (*it).c_str() ; + MESSAGE (".. Frontiere enregistrée : "<< boun ); + if ( *it != BoundaryName ) + { erreur = 1 ; + break ; } + // On saute le nom du groupe + it++ ; + } + } + if ( erreur != 0 ) { break ; } + // B.2. Si on ajoute une frontière non CAO, il ne doit pas y avoir de frontière CAO + if ( BoundaryType != -1 ) + { + for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ ) + { + boun = (*it).c_str() ; + MESSAGE (".. Frontiere enregistrée : "<< boun ); + ADAPT::HOMARD_Boundary_ptr myBoundary_0 = _gen_i->GetBoundary(boun) ; + int BoundaryType_0 = myBoundary_0->GetType(); + MESSAGE ( ".. BoundaryType_0 = " << BoundaryType_0 ); + if ( BoundaryType_0 == -1 ) + { erreur = 2 ; + break ; } + // On saute le nom du groupe + it++ ; + } + if ( erreur != 0 ) { break ; } + } + // B.3. Si on ajoute une frontière discrète, il ne doit pas y avoir d'autre frontière discrète + if ( BoundaryType == 0 ) + { + for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ ) + { + boun = (*it).c_str() ; + MESSAGE (".. Frontiere enregistrée : "<< boun ); + if ( boun != BoundaryName ) + { + ADAPT::HOMARD_Boundary_ptr myBoundary_0 = _gen_i->GetBoundary(boun) ; + int BoundaryType_0 = myBoundary_0->GetType(); + MESSAGE ( ".. BoundaryType_0 = " << BoundaryType_0 ); + if ( BoundaryType_0 == 0 ) + { erreur = 3 ; + break ; } + } + // On saute le nom du groupe + it++ ; + } + if ( erreur != 0 ) { break ; } + } + // B.4. Pour une nouvelle frontiere, publication dans l'arbre d'etudes sous le cas + bool existe = false ; + for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ ) + { + MESSAGE (".. Frontiere : "<< *it ); + if ( *it == BoundaryName ) { existe = true ; } + // On saute le nom du groupe + it++ ; + } + if ( !existe ) + { + char* CaseName = GetName() ; + MESSAGE ( "AddBoundaryGroup : insertion de la frontiere dans l'arbre de " << CaseName ); + _gen_i->PublishBoundaryUnderCase(CaseName, BoundaryName) ; + } + // B.5. Le groupe est-il deja enregistre pour une frontiere de ce cas ? + for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ ) + { + boun = (*it).c_str() ; + it++ ; + MESSAGE (".. Groupe enregistré : "<< *it ); + if ( *it == Group ) + { erreur = 5 ; + break ; } + } + if ( erreur != 0 ) { break ; } + // + break ; + } + // F. Si aucune erreur, enregistrement du couple (frontiere,groupe) dans la reference du cas + // Sinon, arrêt + if ( erreur == 0 ) + { myHomardCas->AddBoundaryGroup( BoundaryName, Group ); } + else + { + std::stringstream ss; + ss << erreur; + std::string str = ss.str(); + std::string texte ; + texte = "Erreur numéro " + str + " pour la frontière à enregistrer : " + std::string(BoundaryName) ; + if ( erreur == 1 ) { texte += "\nIl existe déjà la frontière " ; } + else if ( erreur == 2 ) { texte += "\nIl existe déjà la frontière CAO " ; } + else if ( erreur == 3 ) { texte += "\nIl existe déjà une frontière discrète : " ; } + else if ( erreur == 5 ) { texte += "\nLe groupe " + std::string(Group) + " est déjà enregistré pour la frontière " ; } + texte += std::string(boun) ; + // + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; +#ifdef _DEBUG_ + texte += "\nInvalid AddBoundaryGroup"; +#endif + INFOS(texte) ; + es.text = CORBA::string_dup(texte.c_str()); + throw SALOME::SALOME_Exception(es); + } +} +//============================================================================= +ADAPT::ListBoundaryGroupType* HOMARD_Cas_i::GetBoundaryGroup() +{ + MESSAGE ("GetBoundaryGroup"); + ASSERT(myHomardCas ); + const std::list& ListBoundaryGroup = myHomardCas->GetBoundaryGroup(); + ADAPT::ListBoundaryGroupType_var aResult = new ADAPT::ListBoundaryGroupType(); + aResult->length( ListBoundaryGroup.size() ); + std::list::const_iterator it; + int i = 0; + for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ ) + { + aResult[i++] = CORBA::string_dup( (*it).c_str() ); + } + return aResult._retn(); +} +//============================================================================= +void HOMARD_Cas_i::SupprBoundaryGroup() +{ + MESSAGE ("SupprBoundaryGroup"); + ASSERT(myHomardCas ); + myHomardCas->SupprBoundaryGroup(); +} +//============================================================================= +void HOMARD_Cas_i::SetPyram( CORBA::Long Pyram ) +{ + MESSAGE ("SetPyram, Pyram = " << Pyram ); + ASSERT( myHomardCas ); + myHomardCas->SetPyram( Pyram ); +} +//============================================================================= +CORBA::Long HOMARD_Cas_i::GetPyram() +{ + MESSAGE ("GetPyram"); + ASSERT( myHomardCas ); + return myHomardCas->GetPyram(); +} +//============================================================================= +void HOMARD_Cas_i::MeshInfo(CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte) +{ + MESSAGE ( "MeshInfo : information sur le maillage initial du cas" ); + ASSERT( myHomardCas ); +// +// Nom de l'iteration + char* IterName = GetIter0Name() ; + CORBA::Long etatMenage = -1 ; + CORBA::Long modeHOMARD = 7 ; + CORBA::Long Option1 = 1 ; + CORBA::Long Option2 = 1 ; + if ( Qual != 0 ) { modeHOMARD = modeHOMARD*5 ; } + if ( Diam != 0 ) { modeHOMARD = modeHOMARD*19 ; } + if ( Conn != 0 ) { modeHOMARD = modeHOMARD*11 ; } + if ( Tail != 0 ) { modeHOMARD = modeHOMARD*13 ; } + if ( Inte != 0 ) { modeHOMARD = modeHOMARD*3 ; } + CORBA::Long codret = _gen_i->Compute(IterName, etatMenage, modeHOMARD, Option1, Option2) ; + MESSAGE ( "MeshInfo : codret = " << codret ); + return ; +} +//============================================================================= +//============================================================================= +// Liens avec les autres structures +//============================================================================= +//============================================================================= +char* HOMARD_Cas_i::GetIter0Name() +{ + ASSERT( myHomardCas ); + return CORBA::string_dup( myHomardCas->GetIter0Name().c_str() ); +} +//============================================================================= +ADAPT::HOMARD_Iteration_ptr HOMARD_Cas_i::GetIter0() +{ +// Nom de l'iteration initiale + char* Iter0Name = GetIter0Name() ; + MESSAGE ( "GetIter0 : Iter0Name = " << Iter0Name ); + return _gen_i->GetIteration(Iter0Name) ; +} +//============================================================================= +ADAPT::HOMARD_Iteration_ptr HOMARD_Cas_i::NextIteration( const char* IterName ) +{ +// Nom de l'iteration parent + char* NomIterParent = GetIter0Name() ; + MESSAGE ( "NextIteration : IterName = " << IterName ); + MESSAGE ( "NextIteration : NomIterParent = " << NomIterParent ); + return _gen_i->CreateIteration(IterName, NomIterParent) ; +} +//============================================================================= +ADAPT::HOMARD_Iteration_ptr HOMARD_Cas_i::LastIteration( ) +{ + ADAPT::HOMARD_Iteration_ptr Iter ; + ADAPT::listeIterFilles_var ListeIterFilles ; + char* IterName ; +// Iteration initiale du cas + IterName = GetIter0Name() ; +// On va explorer la descendance de cette iteration initiale +// jusqu'a trouver celle qui n'a pas de filles + int nbiterfilles = 1 ; + while ( nbiterfilles == 1 ) + { +// L'iteration associee +// MESSAGE ( ".. IterName = " << IterName ); + Iter = _gen_i->GetIteration(IterName) ; +// Les filles de cette iteration + ListeIterFilles = Iter->GetIterations() ; + nbiterfilles = ListeIterFilles->length() ; +// MESSAGE ( ".. nbiterfilles = " << nbiterfilles ); +// S'il y a au moins 2 filles, arret : on ne sait pas faire + VERIFICATION( nbiterfilles <= 1 ) ; +// S'il y a une fille unique, on recupere le nom de la fille et on recommence + if ( nbiterfilles == 1 ) + { IterName = ListeIterFilles[0] ; } + } +// + return Iter ; +} +//============================================================================= +void HOMARD_Cas_i::AddIteration( const char* NomIteration ) +{ + ASSERT( myHomardCas ); + myHomardCas->AddIteration( NomIteration ); +} +//============================================================================= +//============================================================================= +// YACS +//============================================================================= +//============================================================================= +//============================================================================= +// Creation d'un schema YACS +// YACSName : nom du schema +// ScriptFile : nom du fichier contenant le script de lancement du calcul +// DirName : le repertoire de lancement des calculs du sch?ma +// MeshFile : nom du fichier contenant le maillage pour le premier calcul +//============================================================================= +ADAPT::HOMARD_YACS_ptr HOMARD_Cas_i::CreateYACSSchema( const char* YACSName, const char* ScriptFile, const char* DirName, const char* MeshFile ) +{ +// Nom du cas + const char* CaseName = GetName() ; + MESSAGE ( "CreateYACSSchema : Schema YACS pour le cas " << YACSName); + MESSAGE ( "nomCas : " << CaseName); + MESSAGE ( "ScriptFile : " << ScriptFile); + MESSAGE ( "DirName : " << DirName); + MESSAGE ( "MeshFile : " << MeshFile); + return _gen_i->CreateYACSSchema(YACSName, CaseName, ScriptFile, DirName, MeshFile) ; +} diff --git a/src/ADAPT_I/HOMARD_Cas_i.hxx b/src/ADAPT_I/HOMARD_Cas_i.hxx new file mode 100644 index 000000000..60027606a --- /dev/null +++ b/src/ADAPT_I/HOMARD_Cas_i.hxx @@ -0,0 +1,119 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier +// + +#ifndef _HOMARD_CAS_I_HXX_ +#define _HOMARD_CAS_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(ADAPT_Gen) +#include CORBA_SERVER_HEADER(HOMARD_Cas) + +#include "HOMARD_i.hxx" +#include "SALOME_Component_i.hxx" +#include "SALOME_NamingService.hxx" +#include "Utils_CorbaException.hxx" + +#include + +class HOMARD_Cas; + +class HOMARDENGINE_EXPORT HOMARD_Cas_i: + public virtual Engines_Component_i, + public virtual POA_ADAPT::HOMARD_Cas, + public virtual PortableServer::ServantBase +{ +public: + HOMARD_Cas_i( CORBA::ORB_ptr orb, ADAPT::ADAPT_Gen_var gen_i ); + HOMARD_Cas_i(); + + virtual ~HOMARD_Cas_i(); + +// Generalites + void SetName( const char* Name ); + char* GetName(); + + CORBA::Long Delete( CORBA::Long Option ); + + char* GetDumpPython(); + + std::string Dump() const; + bool Restore( const std::string& stream ); + +// Caracteristiques + void SetDirName( const char* NomDir ); + char* GetDirName(); + + CORBA::Long GetState(); + + CORBA::Long GetNumberofIter(); + + void SetConfType( CORBA::Long ConfType ); + CORBA::Long GetConfType(); + + void SetExtType( CORBA::Long ExtType ); + CORBA::Long GetExtType(); + + void SetBoundingBox( const ADAPT::extrema& LesExtremes ); + ADAPT::extrema* GetBoundingBox(); + + void AddGroup( const char* Group); + void SetGroups(const ADAPT::ListGroupType& ListGroup); + ADAPT::ListGroupType* GetGroups(); + + void AddBoundary(const char* Boundary); + void AddBoundaryGroup(const char* Boundary, const char* Group); + ADAPT::ListBoundaryGroupType* GetBoundaryGroup(); + void SupprBoundaryGroup( ); + + void SetPyram( CORBA::Long Pyram ); + CORBA::Long GetPyram(); + + void MeshInfo(CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte); + +// Liens avec les autres structures + char* GetIter0Name(); + ADAPT::HOMARD_Iteration_ptr GetIter0() ; + + ADAPT::HOMARD_Iteration_ptr NextIteration( const char* Name ) ; + + ADAPT::HOMARD_Iteration_ptr LastIteration() ; + + void AddIteration( const char* NomIteration ); + +// YACS + ADAPT::HOMARD_YACS_ptr CreateYACSSchema( const char* YACSName, const char* ScriptFile, const char* DirName, const char* MeshFile ); + +private: + ::HOMARD_Cas* myHomardCas; + + CORBA::ORB_ptr _orb; + ADAPT::ADAPT_Gen_var _gen_i; +}; + +#endif diff --git a/src/ADAPT_I/HOMARD_Hypothesis_i.cxx b/src/ADAPT_I/HOMARD_Hypothesis_i.cxx new file mode 100644 index 000000000..b039bc3a8 --- /dev/null +++ b/src/ADAPT_I/HOMARD_Hypothesis_i.cxx @@ -0,0 +1,506 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier +// + +#include "HOMARD_Hypothesis_i.hxx" +#include "ADAPT_Gen_i.hxx" +#include "HOMARD_Hypothesis.hxx" +#include "HOMARD_DriverTools.hxx" + +#include "utilities.h" + +//============================================================================= +/*! + * standard constructor + */ +//============================================================================= +HOMARD_Hypothesis_i::HOMARD_Hypothesis_i() +{ + MESSAGE( "Default constructor, not for use" ); + ASSERT( 0 ); +} + +//============================================================================= +/*! + * standard constructor + */ +//============================================================================= +HOMARD_Hypothesis_i::HOMARD_Hypothesis_i( CORBA::ORB_ptr orb, + ADAPT::ADAPT_Gen_var engine ) +{ + MESSAGE( "standard constructor" ); + _gen_i = engine; + _orb = orb; + myHomardHypothesis = new ::HOMARD_Hypothesis(); + ASSERT( myHomardHypothesis ); +} + +//============================================================================= +/*! + * standard destructor + */ +//============================================================================= +HOMARD_Hypothesis_i::~HOMARD_Hypothesis_i() +{ +} +//============================================================================= +//============================================================================= +// Generalites +//============================================================================= +//============================================================================= +void HOMARD_Hypothesis_i::SetName( const char* Name ) +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->SetName( Name ); +} +//============================================================================= +char* HOMARD_Hypothesis_i::GetName() +{ + ASSERT( myHomardHypothesis ); + return CORBA::string_dup( myHomardHypothesis->GetName().c_str() ); +} +//============================================================================= +CORBA::Long HOMARD_Hypothesis_i::Delete() +{ + ASSERT( myHomardHypothesis ); + char* HypoName = GetName() ; + MESSAGE ( "Delete : destruction de l'hypothese " << HypoName ); + return _gen_i->DeleteHypo(HypoName) ; +} +//============================================================================= +char* HOMARD_Hypothesis_i::GetDumpPython() +{ + ASSERT( myHomardHypothesis ); + return CORBA::string_dup( myHomardHypothesis->GetDumpPython().c_str() ); +} +//============================================================================= +std::string HOMARD_Hypothesis_i::Dump() const +{ + return ADAPT::Dump( *myHomardHypothesis ); +} +//============================================================================= +bool HOMARD_Hypothesis_i::Restore( const std::string& stream ) +{ + return ADAPT::Restore( *myHomardHypothesis, stream ); +} +//============================================================================= +//============================================================================= +// Caracteristiques +//============================================================================= +//============================================================================= +void HOMARD_Hypothesis_i::SetUnifRefinUnRef( CORBA::Long TypeRaffDera ) +{ + ASSERT( myHomardHypothesis ); + VERIFICATION( (TypeRaffDera==1) || (TypeRaffDera==-1) ); + int TypeRaff, TypeDera ; + if ( TypeRaffDera == 1 ) + { + TypeRaff = 1 ; + TypeDera = 0 ; + } + else if ( TypeRaffDera == -1 ) + { + TypeRaff = 0 ; + TypeDera = 1 ; + } + myHomardHypothesis->SetAdapType( -1 ); + myHomardHypothesis->SetRefinTypeDera( TypeRaff, TypeDera ); +} +//============================================================================= +ADAPT::listeTypes* HOMARD_Hypothesis_i::GetAdapRefinUnRef() +{ + ASSERT( myHomardHypothesis ); + ADAPT::listeTypes_var aResult = new ADAPT::listeTypes; + aResult->length( 3 ); + aResult[0] = CORBA::Long( myHomardHypothesis->GetAdapType() ); + aResult[1] = CORBA::Long( myHomardHypothesis->GetRefinType() ); + aResult[2] = CORBA::Long( myHomardHypothesis->GetUnRefType() ); + return aResult._retn(); +} +//============================================================================= +CORBA::Long HOMARD_Hypothesis_i::GetAdapType() +{ + ASSERT( myHomardHypothesis ); + return CORBA::Long( myHomardHypothesis->GetAdapType() ); +} +//============================================================================= +CORBA::Long HOMARD_Hypothesis_i::GetRefinType() +{ + ASSERT( myHomardHypothesis ); + return CORBA::Long( myHomardHypothesis->GetRefinType() ); +} +//============================================================================= +CORBA::Long HOMARD_Hypothesis_i::GetUnRefType() +{ + ASSERT( myHomardHypothesis ); + return CORBA::Long( myHomardHypothesis->GetUnRefType() ); +} +//============================================================================= +void HOMARD_Hypothesis_i::SetField( const char* FieldName ) +{ + myHomardHypothesis->SetField( FieldName ); +} +//============================================================================= +char* HOMARD_Hypothesis_i::GetFieldName() +{ + ASSERT( myHomardHypothesis ); + return CORBA::string_dup( myHomardHypothesis->GetFieldName().c_str() ); +} +//============================================================================= +void HOMARD_Hypothesis_i::SetUseField( CORBA::Long UsField ) +{ + myHomardHypothesis->SetUseField( UsField ); +} +//============================================================================= +ADAPT::InfosHypo* HOMARD_Hypothesis_i::GetField() +{ + ASSERT( myHomardHypothesis ); + ADAPT::InfosHypo* aInfosHypo = new ADAPT::InfosHypo(); + aInfosHypo->FieldName = CORBA::string_dup( myHomardHypothesis->GetFieldName().c_str() ); + aInfosHypo->TypeThR = CORBA::Long( myHomardHypothesis->GetRefinThrType() ); + aInfosHypo->ThreshR = CORBA::Double( myHomardHypothesis->GetThreshR() ); + aInfosHypo->TypeThC = CORBA::Long( myHomardHypothesis->GetUnRefThrType() ); + aInfosHypo->ThreshC = CORBA::Double( myHomardHypothesis->GetThreshC() ); + aInfosHypo->UsField = CORBA::Long( myHomardHypothesis->GetUseField() ); + aInfosHypo->UsCmpI = CORBA::Long( myHomardHypothesis->GetUseComp() ); + return aInfosHypo; +} +//============================================================================= +void HOMARD_Hypothesis_i::SetUseComp( CORBA::Long UsCmpI ) +{ + myHomardHypothesis->SetUseComp( UsCmpI ); +} +//============================================================================= +void HOMARD_Hypothesis_i::AddComp( const char* NomComp ) +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->AddComp( NomComp ); +} +//============================================================================= +void HOMARD_Hypothesis_i::SupprComp( const char* NomComp ) +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->SupprComp(NomComp); +} +//============================================================================= +void HOMARD_Hypothesis_i::SupprComps() +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->SupprComps(); +} +//============================================================================= +ADAPT::listeComposantsHypo* HOMARD_Hypothesis_i::GetComps() +{ + ASSERT( myHomardHypothesis ); + const std::list& ListString = myHomardHypothesis->GetComps(); + ADAPT::listeComposantsHypo_var aResult = new ADAPT::listeComposantsHypo; + aResult->length( ListString.size() ); + std::list::const_iterator it; + int i = 0; + for ( it = ListString.begin(); it != ListString.end(); it++ ) + { + aResult[i++] = CORBA::string_dup( (*it).c_str() ); + } + return aResult._retn(); +} +//============================================================================= +void HOMARD_Hypothesis_i::SetRefinThr( CORBA::Long TypeThR, CORBA::Double ThreshR ) +{ + myHomardHypothesis->SetAdapType( 1 ); + if ( TypeThR > 0 ) + { + int TypeDera = myHomardHypothesis->GetUnRefType() ; + myHomardHypothesis->SetRefinTypeDera( 1, TypeDera ); + } + myHomardHypothesis->SetRefinThr( TypeThR, ThreshR ); +} +//============================================================================= +CORBA::Long HOMARD_Hypothesis_i::GetRefinThrType() +{ + ASSERT( myHomardHypothesis ); + return CORBA::Long( myHomardHypothesis->GetRefinThrType() ); +} +//============================================================================= +void HOMARD_Hypothesis_i::SetUnRefThr( CORBA::Long TypeThC, CORBA::Double ThreshC ) +{ + myHomardHypothesis->SetAdapType( 1 ); + if ( TypeThC > 0 ) + { + int TypeRaff = myHomardHypothesis->GetRefinType() ; + myHomardHypothesis->SetRefinTypeDera( TypeRaff, 1 ); + } + myHomardHypothesis->SetUnRefThr( TypeThC, ThreshC ); +} +//============================================================================= +CORBA::Long HOMARD_Hypothesis_i::GetUnRefThrType() +{ + ASSERT( myHomardHypothesis ); + return CORBA::Long( myHomardHypothesis->GetUnRefThrType() ); +} +//============================================================================= +void HOMARD_Hypothesis_i::SetNivMax( CORBA::Long NivMax ) +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->SetNivMax( NivMax ); +} +//============================================================================= +CORBA::Long HOMARD_Hypothesis_i::GetNivMax() +{ + ASSERT( myHomardHypothesis ); + return myHomardHypothesis->GetNivMax(); +} +//============================================================================= +void HOMARD_Hypothesis_i::SetDiamMin( CORBA::Double DiamMin ) +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->SetDiamMin( DiamMin ); +} +//============================================================================= +CORBA::Double HOMARD_Hypothesis_i::GetDiamMin() +{ + ASSERT( myHomardHypothesis ); + return myHomardHypothesis->GetDiamMin(); +} +//============================================================================= +void HOMARD_Hypothesis_i::SetAdapInit( CORBA::Long AdapInit ) +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->SetAdapInit( AdapInit ); +} +//============================================================================= +CORBA::Long HOMARD_Hypothesis_i::GetAdapInit() +{ + ASSERT( myHomardHypothesis ); + return myHomardHypothesis->GetAdapInit(); +} +//============================================================================= +void HOMARD_Hypothesis_i::SetExtraOutput( CORBA::Long ExtraOutput ) +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->SetExtraOutput( ExtraOutput ); +} +//============================================================================= +CORBA::Long HOMARD_Hypothesis_i::GetExtraOutput() +{ + ASSERT( myHomardHypothesis ); + return myHomardHypothesis->GetExtraOutput(); +} +//============================================================================= +void HOMARD_Hypothesis_i::AddGroup( const char* Group) +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->AddGroup( Group ); +} +//============================================================================= +void HOMARD_Hypothesis_i::SupprGroup( const char* Group ) +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->SupprGroup(Group); +} +//============================================================================= +void HOMARD_Hypothesis_i::SupprGroups() +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->SupprGroups(); +} +//============================================================================= +void HOMARD_Hypothesis_i::SetGroups(const ADAPT::ListGroupType& ListGroup) +{ + ASSERT( myHomardHypothesis ); + std::list ListString; + for ( int i = 0; i < ListGroup.length(); i++ ) + { + ListString.push_back(std::string(ListGroup[i])); + } + myHomardHypothesis->SetGroups( ListString ); +} +//============================================================================= +ADAPT::ListGroupType* HOMARD_Hypothesis_i::GetGroups() +{ + ASSERT( myHomardHypothesis ); + const std::list& ListString = myHomardHypothesis->GetGroups(); + ADAPT::ListGroupType_var aResult = new ADAPT::ListGroupType; + aResult->length( ListString.size() ); + std::list::const_iterator it; + int i = 0; + for ( it = ListString.begin(); it != ListString.end(); it++ ) + { + aResult[i++] = CORBA::string_dup( (*it).c_str() ); + } + return aResult._retn(); +} +//============================================================================= +void HOMARD_Hypothesis_i::SetTypeFieldInterp( CORBA::Long TypeFieldInterp ) +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->SetTypeFieldInterp( TypeFieldInterp ); +} +//============================================================================= +CORBA::Long HOMARD_Hypothesis_i::GetTypeFieldInterp() +{ + ASSERT( myHomardHypothesis ); + return CORBA::Long( myHomardHypothesis->GetTypeFieldInterp() ); +} +//============================================================================= +void HOMARD_Hypothesis_i::AddFieldInterp( const char* FieldInterp ) +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->AddFieldInterpType( FieldInterp, 0 ); +} +//============================================================================= +void HOMARD_Hypothesis_i::AddFieldInterpType( const char* FieldInterp, CORBA::Long TypeInterp ) +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->AddFieldInterpType( FieldInterp, TypeInterp ); +} +//============================================================================= +void HOMARD_Hypothesis_i::SupprFieldInterp( const char* FieldInterp ) +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->SupprFieldInterp(FieldInterp); +} +//============================================================================= +void HOMARD_Hypothesis_i::SupprFieldInterps() +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->SupprFieldInterps(); +} +//============================================================================= +ADAPT::listeFieldInterpsHypo* HOMARD_Hypothesis_i::GetFieldInterps() +{ + ASSERT( myHomardHypothesis ); + const std::list& ListString = myHomardHypothesis->GetFieldInterps(); + ADAPT::listeFieldInterpsHypo_var aResult = new ADAPT::listeFieldInterpsHypo; + aResult->length( ListString.size() ); + std::list::const_iterator it; + int i = 0; + for ( it = ListString.begin(); it != ListString.end(); it++ ) + { + aResult[i++] = CORBA::string_dup( (*it).c_str() ); + } + return aResult._retn(); +} +//============================================================================= +//============================================================================= +// Liens avec les autres structures +//============================================================================= +//============================================================================= +void HOMARD_Hypothesis_i::SetCaseCreation( const char* NomCaseCreation ) +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->SetCaseCreation( NomCaseCreation ); +} +//============================================================================= +char* HOMARD_Hypothesis_i::GetCaseCreation() +{ + ASSERT( myHomardHypothesis ); + return CORBA::string_dup( myHomardHypothesis->GetCaseCreation().c_str() ); +} +//============================================================================= +void HOMARD_Hypothesis_i::LinkIteration( const char* NomIteration ) +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->LinkIteration( NomIteration ); +} +//============================================================================= +void HOMARD_Hypothesis_i::UnLinkIteration( const char* NomIteration ) +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->UnLinkIteration( NomIteration ); +} +//============================================================================= +ADAPT::listeIters* HOMARD_Hypothesis_i::GetIterations() +{ + ASSERT( myHomardHypothesis ); + const std::list& ListString = myHomardHypothesis->GetIterations(); + ADAPT::listeIters_var aResult = new ADAPT::listeIters; + aResult->length( ListString.size() ); + std::list::const_iterator it; + int i = 0; + for ( it = ListString.begin(); it != ListString.end(); it++ ) + { + aResult[i++] = CORBA::string_dup( (*it).c_str() ); + } + return aResult._retn(); +} +//============================================================================= +void HOMARD_Hypothesis_i::AddZone( const char* NomZone, CORBA::Long TypeUse ) +{ + MESSAGE ("Dans AddZone pour " << NomZone << " et TypeUse = " << TypeUse ) ; + ASSERT( myHomardHypothesis ); + VERIFICATION( (TypeUse==1) || (TypeUse==-1) ); + myHomardHypothesis->SetAdapType( 0 ); + int TypeRaff, TypeDera ; + if ( TypeUse == 1 ) + { + TypeRaff = 1 ; + TypeDera = myHomardHypothesis->GetUnRefType() ; + } + else if ( TypeUse == -1 ) + { + TypeRaff = myHomardHypothesis->GetRefinType() ; + TypeDera = 1 ; + } + myHomardHypothesis->SetRefinTypeDera( TypeRaff, TypeDera ); + char* NomHypo = GetName() ; + return _gen_i->AssociateHypoZone(NomHypo, NomZone, TypeUse) ; +} +//============================================================================= +void HOMARD_Hypothesis_i::AddZone0( const char* NomZone, CORBA::Long TypeUse ) +{ + MESSAGE ("Dans AddZone0 pour " << NomZone) ; + ASSERT( myHomardHypothesis ); + myHomardHypothesis->AddZone( NomZone, TypeUse ); +} +//============================================================================= +void HOMARD_Hypothesis_i::SupprZone(const char * NomZone) +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->SupprZone( NomZone); +} +//============================================================================= +void HOMARD_Hypothesis_i::SupprZones() +{ + ASSERT( myHomardHypothesis ); + myHomardHypothesis->SupprZones(); +} +//============================================================================= +ADAPT::listeZonesHypo* HOMARD_Hypothesis_i::GetZones() +{ + ASSERT( myHomardHypothesis ); + const std::list& ListString = myHomardHypothesis->GetZones(); + ADAPT::listeZonesHypo_var aResult = new ADAPT::listeZonesHypo; + aResult->length( ListString.size() ); + std::list::const_iterator it; + int i = 0; + for ( it = ListString.begin(); it != ListString.end(); it++ ) + { + aResult[i++] = CORBA::string_dup( (*it).c_str() ); + } + return aResult._retn(); +} diff --git a/src/ADAPT_I/HOMARD_Hypothesis_i.hxx b/src/ADAPT_I/HOMARD_Hypothesis_i.hxx new file mode 100644 index 000000000..d5dc6f98e --- /dev/null +++ b/src/ADAPT_I/HOMARD_Hypothesis_i.hxx @@ -0,0 +1,138 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier +// + +#ifndef _HOMARD_HYPOTHESIS_I_HXX_ +#define _HOMARD_HYPOTHESIS_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(ADAPT_Gen) +#include CORBA_SERVER_HEADER(HOMARD_Hypothesis) + +#include "HOMARD_i.hxx" +#include "SALOME_Component_i.hxx" +#include "SALOME_NamingService.hxx" +#include "Utils_CorbaException.hxx" + +#include + +class HOMARD_Hypothesis; + +class HOMARDENGINE_EXPORT HOMARD_Hypothesis_i: + public virtual Engines_Component_i, + public virtual POA_ADAPT::HOMARD_Hypothesis, + public virtual PortableServer::ServantBase +{ +public: + HOMARD_Hypothesis_i( CORBA::ORB_ptr orb, ADAPT::ADAPT_Gen_var gen_i ); + HOMARD_Hypothesis_i(); + + virtual ~HOMARD_Hypothesis_i(); + +// Generalites + void SetName( const char* Name ); + char* GetName(); + + CORBA::Long Delete(); + + char* GetDumpPython(); + + std::string Dump() const; + bool Restore( const std::string& stream ); + +// Caracteristiques + void SetUnifRefinUnRef( CORBA::Long TypeRaffDera ); + ADAPT::listeTypes* GetAdapRefinUnRef(); + CORBA::Long GetAdapType(); + CORBA::Long GetRefinType(); + CORBA::Long GetUnRefType(); + + void SetField( const char* FieldName ); + char* GetFieldName(); + void SetUseField(CORBA::Long UsField); + ADAPT::InfosHypo* GetField(); + + void SetUseComp(CORBA::Long UsCmpI); + void AddComp( const char* NomComp ); + void SupprComp( const char* NomComp ); + void SupprComps(); + ADAPT::listeComposantsHypo* GetComps(); + + void SetRefinThr(CORBA::Long TypeThR, CORBA::Double ThreshR); + CORBA::Long GetRefinThrType(); + void SetUnRefThr(CORBA::Long TypeThC, CORBA::Double ThreshC); + CORBA::Long GetUnRefThrType(); + + void SetNivMax( CORBA::Long NivMax ); + CORBA::Long GetNivMax(); + + void SetDiamMin( CORBA::Double DiamMin ); + CORBA::Double GetDiamMin(); + + void SetAdapInit( CORBA::Long AdapInit ); + CORBA::Long GetAdapInit(); + + void SetExtraOutput( CORBA::Long ExtraOutput ); + CORBA::Long GetExtraOutput(); + + void AddGroup( const char* Group); + void SupprGroup( const char* Group ); + void SupprGroups(); + void SetGroups(const ADAPT::ListGroupType& ListGroup); + ADAPT::ListGroupType* GetGroups(); + + void SetTypeFieldInterp( CORBA::Long TypeFieldInterp ); + CORBA::Long GetTypeFieldInterp(); + void AddFieldInterp( const char* FieldInterp ); + void AddFieldInterpType( const char* FieldInterp, CORBA::Long TypeInterp ); + void SupprFieldInterp( const char* FieldInterp ); + void SupprFieldInterps(); + ADAPT::listeFieldInterpsHypo* GetFieldInterps(); + +// Liens avec les autres structures + void SetCaseCreation( const char* NomCaseCreation ); + char* GetCaseCreation(); + + void LinkIteration( const char* NomIteration ); + void UnLinkIteration( const char* NomIteration ); + ADAPT::listeIters* GetIterations(); + + void AddZone( const char* NomZone, CORBA::Long TypeUse ); + void AddZone0( const char* NomZone, CORBA::Long TypeUse ); + void SupprZone( const char* NomZone ); + void SupprZones(); + ADAPT::listeZonesHypo* GetZones(); + +private: + ::HOMARD_Hypothesis* myHomardHypothesis; + + CORBA::ORB_ptr _orb; + ADAPT::ADAPT_Gen_var _gen_i; +}; + +#endif diff --git a/src/ADAPT_I/HOMARD_Iteration_i.cxx b/src/ADAPT_I/HOMARD_Iteration_i.cxx new file mode 100644 index 000000000..5990a6b71 --- /dev/null +++ b/src/ADAPT_I/HOMARD_Iteration_i.cxx @@ -0,0 +1,465 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier +// + +#include "HOMARD_Iteration_i.hxx" +#include "ADAPT_Gen_i.hxx" +#include "HOMARD_Iteration.hxx" +#include "HOMARD_DriverTools.hxx" + +#include "SALOMEDS_Tool.hxx" + +#include "utilities.h" + +//============================================================================= +/*! + * standard constructor + */ +//============================================================================= +HOMARD_Iteration_i::HOMARD_Iteration_i() +{ + MESSAGE( "Default constructor, not for use" ); + ASSERT( 0 ); +} +//============================================================================= +/*! + * standard constructor + */ +//============================================================================= +HOMARD_Iteration_i::HOMARD_Iteration_i( CORBA::ORB_ptr orb, + ADAPT::ADAPT_Gen_var engine ) +{ + MESSAGE("constructor"); + _gen_i = engine; + _orb = orb; + myHomardIteration = new ::HOMARD_Iteration(); + ASSERT( myHomardIteration ); +} +//============================================================================= +/*! + * standard destructor + */ +//============================================================================= +HOMARD_Iteration_i::~HOMARD_Iteration_i() +{ +} +//============================================================================= +//============================================================================= +// Generalites +//============================================================================= +//============================================================================= +void HOMARD_Iteration_i::SetName( const char* Name ) +{ + ASSERT( myHomardIteration ); + myHomardIteration->SetName( Name ); +} +//============================================================================= +char* HOMARD_Iteration_i::GetName() +{ + ASSERT( myHomardIteration ); + return CORBA::string_dup( myHomardIteration->GetName().c_str() ); +} +//============================================================================= +CORBA::Long HOMARD_Iteration_i::Delete( CORBA::Long Option ) +{ + ASSERT( myHomardIteration ); + char* IterName = GetName() ; + MESSAGE ( "Delete : destruction de l'iteration " << IterName << ", Option = " << Option ); + return _gen_i->DeleteIteration(IterName, Option) ; +} +//============================================================================= +char* HOMARD_Iteration_i::GetDumpPython() +{ + ASSERT( myHomardIteration ); + return CORBA::string_dup( myHomardIteration->GetDumpPython().c_str() ); +} +//============================================================================= +std::string HOMARD_Iteration_i::Dump() const +{ + return ADAPT::Dump( *myHomardIteration ); +} +//============================================================================= +bool HOMARD_Iteration_i::Restore( const std::string& stream ) +{ + return ADAPT::Restore( *myHomardIteration, stream ); +} +//============================================================================= +//============================================================================= +// Caracteristiques +//============================================================================= +//============================================================================= +void HOMARD_Iteration_i::SetDirNameLoc( const char* NomDir ) +{ + ASSERT( myHomardIteration ); + myHomardIteration->SetDirNameLoc( NomDir ); +} +//============================================================================= +char* HOMARD_Iteration_i::GetDirNameLoc() +{ + ASSERT( myHomardIteration ); + return CORBA::string_dup( myHomardIteration->GetDirNameLoc().c_str() ); +} +//============================================================================= +char* HOMARD_Iteration_i::GetDirName() +{ + ASSERT( myHomardIteration ); + std::string casename = myHomardIteration->GetCaseName() ; + ADAPT::HOMARD_Cas_ptr caseiter = _gen_i->GetCase(casename.c_str()) ; + std::string dirnamecase = caseiter->GetDirName() ; + std::string dirname = dirnamecase + "/" + GetDirNameLoc() ; + return CORBA::string_dup( dirname.c_str() ); +} +//============================================================================= +void HOMARD_Iteration_i::SetNumber( CORBA::Long NumIter ) +{ + ASSERT( myHomardIteration ); + myHomardIteration->SetNumber( NumIter ); +} +//============================================================================= +CORBA::Long HOMARD_Iteration_i::GetNumber() +{ + ASSERT( myHomardIteration ); + return myHomardIteration->GetNumber() ; +} +//============================================================================= +void HOMARD_Iteration_i::SetState( CORBA::Long Etat ) +{ + ASSERT( myHomardIteration ); + myHomardIteration->SetState( Etat ); +} +//============================================================================= +CORBA::Long HOMARD_Iteration_i::GetState() +{ + ASSERT( myHomardIteration ); + return myHomardIteration->GetState() ; +} +//============================================================================= +void HOMARD_Iteration_i::SetMeshName( const char* NomMesh ) +{ + ASSERT( myHomardIteration ); + myHomardIteration->SetMeshName( NomMesh ); +} +//============================================================================= +char* HOMARD_Iteration_i::GetMeshName() +{ + ASSERT( myHomardIteration ); + return CORBA::string_dup( myHomardIteration->GetMeshName().c_str() ); +} +//============================================================================= +void HOMARD_Iteration_i::SetMeshFile( const char* MeshFile ) +{ + ASSERT( myHomardIteration ); + myHomardIteration->SetMeshFile( MeshFile ); +} +//============================================================================= +char* HOMARD_Iteration_i::GetMeshFile() +{ + ASSERT( myHomardIteration ); + return CORBA::string_dup( myHomardIteration->GetMeshFile().c_str() ); +} +//============================================================================= +void HOMARD_Iteration_i::SetFieldFile( const char* FieldFile ) +{ + ASSERT( myHomardIteration ); + myHomardIteration->SetFieldFile( FieldFile ); +} +//============================================================================= +char* HOMARD_Iteration_i::GetFieldFile() +{ + ASSERT( myHomardIteration ); + return CORBA::string_dup( myHomardIteration->GetFieldFile().c_str() ); +} +//============================================================================= +// Instants pour le champ de pilotage +//============================================================================= +void HOMARD_Iteration_i::SetTimeStep( CORBA::Long TimeStep ) +{ + ASSERT( myHomardIteration ); + myHomardIteration->SetTimeStep( TimeStep ); +} +//============================================================================= +void HOMARD_Iteration_i::SetTimeStepRank( CORBA::Long TimeStep, CORBA::Long Rank ) +{ + ASSERT( myHomardIteration ); + myHomardIteration->SetTimeStepRank( TimeStep, Rank ); +} +//============================================================================= +void HOMARD_Iteration_i::SetTimeStepRankLast() +{ + ASSERT( myHomardIteration ); + myHomardIteration->SetTimeStepRankLast(); +} +//============================================================================= +CORBA::Long HOMARD_Iteration_i::GetTimeStep() +{ + ASSERT( myHomardIteration ); + return CORBA::Long( myHomardIteration->GetTimeStep() ); +} +//============================================================================= +CORBA::Long HOMARD_Iteration_i::GetRank() +{ + ASSERT( myHomardIteration ); + return CORBA::Long( myHomardIteration->GetRank() ); +} +//============================================================================= +// Instants pour un champ a interpoler +//============================================================================= +void HOMARD_Iteration_i::SetFieldInterpTimeStep( const char* FieldInterp, CORBA::Long TimeStep ) +{ + SetFieldInterpTimeStepRank( FieldInterp, TimeStep, TimeStep ); +} +//============================================================================= +void HOMARD_Iteration_i::SetFieldInterpTimeStepRank( const char* FieldInterp, CORBA::Long TimeStep, CORBA::Long Rank ) +{ + ASSERT( myHomardIteration ); + myHomardIteration->SetFieldInterpTimeStepRank( FieldInterp, TimeStep, Rank ); +} +//============================================================================= +ADAPT::listeFieldInterpTSRsIter* HOMARD_Iteration_i::GetFieldInterpsTimeStepRank() +{ + ASSERT( myHomardIteration ); + const std::list& ListString = myHomardIteration->GetFieldInterpsTimeStepRank(); + ADAPT::listeFieldInterpTSRsIter_var aResult = new ADAPT::listeFieldInterpTSRsIter; + aResult->length( ListString.size() ); + std::list::const_iterator it; + int i = 0; + for ( it = ListString.begin(); it != ListString.end(); it++ ) + { + aResult[i++] = CORBA::string_dup( (*it).c_str() ); + } + return aResult._retn(); +} +//============================================================================= +void HOMARD_Iteration_i::SetFieldInterp( const char* FieldInterp ) +{ + myHomardIteration->SetFieldInterp( FieldInterp ); +} +//============================================================================= +ADAPT::listeFieldInterpsIter* HOMARD_Iteration_i::GetFieldInterps() +{ + ASSERT( myHomardIteration ); + const std::list& ListString = myHomardIteration->GetFieldInterps(); + ADAPT::listeFieldInterpsIter_var aResult = new ADAPT::listeFieldInterpsIter; + aResult->length( ListString.size() ); + std::list::const_iterator it; + int i = 0; + for ( it = ListString.begin(); it != ListString.end(); it++ ) + { + aResult[i++] = CORBA::string_dup( (*it).c_str() ); + } + return aResult._retn(); +} +//============================================================================= +void HOMARD_Iteration_i::SupprFieldInterps() +{ + ASSERT( myHomardIteration ); + myHomardIteration->SupprFieldInterps(); +} +//============================================================================= +void HOMARD_Iteration_i::SetLogFile( const char* LogFile ) +{ + ASSERT( myHomardIteration ); + myHomardIteration->SetLogFile( LogFile ); +} +//============================================================================= +char* HOMARD_Iteration_i::GetLogFile() +{ + ASSERT( myHomardIteration ); + return CORBA::string_dup( myHomardIteration->GetLogFile().c_str() ); +} +//============================================================================= +CORBA::Long HOMARD_Iteration_i::Compute(CORBA::Long etatMenage, CORBA::Long Option) +{ + MESSAGE ( "Compute : calcul d'une iteration, etatMenage = "<Compute(IterName, etatMenage, modeHOMARD, Option1, Option) ; +} +//============================================================================= +void HOMARD_Iteration_i::MeshInfo(CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte) +{ + MESSAGE ( "MeshInfo : information sur le maillage associe a une iteration" ); + ASSERT( myHomardIteration ); +// + int Option = 1 ; + MeshInfoOption( Qual, Diam, Conn, Tail, Inte, Option ) ; +// + return ; +} +//============================================================================= +void HOMARD_Iteration_i::MeshInfoOption(CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte, CORBA::Long Option) +{ + MESSAGE ( "MeshInfoOption : information sur le maillage associe a une iteration" ); + ASSERT( myHomardIteration ); +// +// Nom de l'iteration + char* IterName = GetName() ; + CORBA::Long etatMenage = -1 ; + CORBA::Long modeHOMARD = 7 ; + if ( Qual != 0 ) { modeHOMARD = modeHOMARD*5 ; } + if ( Diam != 0 ) { modeHOMARD = modeHOMARD*19 ; } + if ( Conn != 0 ) { modeHOMARD = modeHOMARD*11 ; } + if ( Tail != 0 ) { modeHOMARD = modeHOMARD*13 ; } + if ( Inte != 0 ) { modeHOMARD = modeHOMARD*3 ; } + MESSAGE ( "MeshInfoOption : information sur le maillage de l'iteration " << IterName ); + CORBA::Long Option2 = 1 ; + CORBA::Long codret = _gen_i->Compute(IterName, etatMenage, modeHOMARD, Option, Option2) ; + MESSAGE ( "MeshInfoOption : codret = " << codret ); +// + return ; +} +//============================================================================= +void HOMARD_Iteration_i::SetFileInfo( const char* FileInfo ) +{ + ASSERT( myHomardIteration ); + myHomardIteration->SetFileInfo( FileInfo ); +} +//============================================================================= +char* HOMARD_Iteration_i::GetFileInfo() +{ + ASSERT( myHomardIteration ); + return CORBA::string_dup( myHomardIteration->GetFileInfo().c_str() ); +} +//============================================================================= +//============================================================================= +// Liens avec les autres iterations +//============================================================================= +//============================================================================= +ADAPT::HOMARD_Iteration_ptr HOMARD_Iteration_i::NextIteration( const char* IterName ) +{ +// Nom de l'iteration parent + char* NomIterParent = GetName() ; + MESSAGE ( "NextIteration : creation de l'iteration " << IterName << " comme fille de " << NomIterParent ); + return _gen_i->CreateIteration(IterName, NomIterParent) ; +} +//============================================================================= +void HOMARD_Iteration_i::LinkNextIteration( const char* NomIteration ) +{ + ASSERT( myHomardIteration ); + myHomardIteration->LinkNextIteration( NomIteration ); +} +//============================================================================= +void HOMARD_Iteration_i::UnLinkNextIteration( const char* NomIteration ) +{ + ASSERT( myHomardIteration ); + myHomardIteration->UnLinkNextIteration( NomIteration ); +} +//============================================================================= +ADAPT::listeIterFilles* HOMARD_Iteration_i::GetIterations() +{ + ASSERT( myHomardIteration ); + const std::list& maListe = myHomardIteration->GetIterations(); + ADAPT::listeIterFilles_var aResult = new ADAPT::listeIterFilles; + aResult->length( maListe.size() ); + std::list::const_iterator it; + int i = 0; + for ( it = maListe.begin(); it != maListe.end(); it++ ) + { + aResult[i++] = CORBA::string_dup( (*it).c_str() ); + } + return aResult._retn(); +} +//============================================================================= +void HOMARD_Iteration_i::SetIterParentName( const char* NomIterParent ) +{ + ASSERT( myHomardIteration ); + myHomardIteration->SetIterParentName( NomIterParent ); +} +//============================================================================= +char* HOMARD_Iteration_i::GetIterParentName() +{ + ASSERT( myHomardIteration ); + return CORBA::string_dup( myHomardIteration->GetIterParentName().c_str() ); +} +//============================================================================= +ADAPT::HOMARD_Iteration_ptr HOMARD_Iteration_i::GetIterParent() +{ +// Nom de l'iteration parent + char* NomIterParent = GetIterParentName() ; + MESSAGE ( "GetIterParent : NomIterParent = " << NomIterParent ); + return _gen_i->GetIteration(NomIterParent) ; +} +//============================================================================= +//============================================================================= +// Liens avec les autres structures +//============================================================================= +//============================================================================= +void HOMARD_Iteration_i::SetCaseName( const char* NomCas ) +{ + ASSERT( myHomardIteration ); + myHomardIteration->SetCaseName( NomCas ); +} +//============================================================================= +char* HOMARD_Iteration_i::GetCaseName() +{ + ASSERT( myHomardIteration ); + return CORBA::string_dup( myHomardIteration->GetCaseName().c_str() ); +} +//============================================================================= +void HOMARD_Iteration_i::AssociateHypo( const char* NomHypo ) +{ + ASSERT( myHomardIteration ); +// +// Nom de l'iteration + char* IterName = GetName() ; + MESSAGE ( ". IterName = " << IterName ); + return _gen_i->AssociateIterHypo(IterName, NomHypo) ; +} +//============================================================================= +void HOMARD_Iteration_i::SetHypoName( const char* NomHypo ) +{ + ASSERT( myHomardIteration ); + myHomardIteration->SetHypoName( NomHypo ); +} +//============================================================================= +char* HOMARD_Iteration_i::GetHypoName() +{ + ASSERT( myHomardIteration ); + return CORBA::string_dup( myHomardIteration->GetHypoName().c_str() ); +} +//============================================================================= +//============================================================================= +// Divers +//============================================================================= +//============================================================================= +void HOMARD_Iteration_i::SetInfoCompute( CORBA::Long MessInfo ) +{ + ASSERT( myHomardIteration ); + myHomardIteration->SetInfoCompute( MessInfo ); +} +//============================================================================= +CORBA::Long HOMARD_Iteration_i::GetInfoCompute() +{ + ASSERT( myHomardIteration ); + return myHomardIteration->GetInfoCompute() ; +} diff --git a/src/ADAPT_I/HOMARD_Iteration_i.hxx b/src/ADAPT_I/HOMARD_Iteration_i.hxx new file mode 100644 index 000000000..87d353e77 --- /dev/null +++ b/src/ADAPT_I/HOMARD_Iteration_i.hxx @@ -0,0 +1,145 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier +// + +#ifndef _HOMARD_ITERATION_I_HXX_ +#define _HOMARD_ITERATION_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(ADAPT_Gen) +#include CORBA_SERVER_HEADER(HOMARD_Iteration) + +#include "HOMARD_i.hxx" +#include "SALOME_Component_i.hxx" +#include "SALOME_NamingService.hxx" +#include "Utils_CorbaException.hxx" + +#include + +class HOMARD_Iteration; + +class HOMARDENGINE_EXPORT HOMARD_Iteration_i: + public virtual Engines_Component_i, + public virtual POA_ADAPT::HOMARD_Iteration, + public virtual PortableServer::ServantBase +{ +public: + HOMARD_Iteration_i( CORBA::ORB_ptr orb, + ADAPT::ADAPT_Gen_var gen_i ); + HOMARD_Iteration_i(); + + virtual ~HOMARD_Iteration_i(); + +// Generalites + void SetName( const char* Name ); + char* GetName(); + + CORBA::Long Delete( CORBA::Long Option ); + + char* GetDumpPython(); + + std::string Dump() const; + bool Restore( const std::string& stream ); + +// Caracteristiques + void SetDirNameLoc( const char* NomDir ); + char* GetDirNameLoc(); + + char* GetDirName(); + + void SetNumber( CORBA::Long NumIter ); + CORBA::Long GetNumber(); + + void SetState( CORBA::Long etat ); + CORBA::Long GetState(); + + void SetMeshName( const char* NomMesh ); + char* GetMeshName(); + + void SetMeshFile( const char* MeshFile ); + char* GetMeshFile(); + + void SetFieldFile( const char* FieldFile ); + char* GetFieldFile(); +// Instants pour le champ de pilotage + void SetTimeStep( CORBA::Long TimeStep ); + void SetTimeStepRank( CORBA::Long TimeStep, CORBA::Long Rank ); + void SetTimeStepRankLast(); + CORBA::Long GetTimeStep(); + CORBA::Long GetRank(); +// Instants pour un champ a interpoler + void SetFieldInterpTimeStep( const char* FieldInterp, CORBA::Long TimeStep ); + void SetFieldInterpTimeStepRank( const char* FieldInterp, CORBA::Long TimeStep, CORBA::Long Rank ); + ADAPT::listeFieldInterpTSRsIter* GetFieldInterpsTimeStepRank(); + void SetFieldInterp( const char* FieldInterp ); + ADAPT::listeFieldInterpsIter* GetFieldInterps(); + void SupprFieldInterps(); + + void SetLogFile( const char* LogFile ); + char* GetLogFile(); + + CORBA::Long Compute(CORBA::Long etatMenage, CORBA::Long Option); + + void MeshInfo(CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte); + + void MeshInfoOption(CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte, CORBA::Long Option); + + void SetFileInfo( const char* FileInfo ); + char* GetFileInfo(); + + // Liens avec les autres iterations + ADAPT::HOMARD_Iteration_ptr NextIteration( const char* Name) ; + + void LinkNextIteration( const char* NomIteration ); + void UnLinkNextIteration( const char* NomIteration ); + ADAPT::listeIterFilles* GetIterations(); + + void SetIterParentName( const char* NomIterParent ); + char* GetIterParentName(); + ADAPT::HOMARD_Iteration_ptr GetIterParent() ; + +// Liens avec les autres structures + void SetCaseName( const char* NomCas ); + char* GetCaseName(); + + void AssociateHypo( const char* NomHypo); + void SetHypoName( const char* NomHypo ); + char* GetHypoName(); + +// Divers + void SetInfoCompute( CORBA::Long MessInfo ); + CORBA::Long GetInfoCompute(); + +private: + ::HOMARD_Iteration* myHomardIteration; + + CORBA::ORB_ptr _orb; + ADAPT::ADAPT_Gen_var _gen_i; +}; + +#endif diff --git a/src/ADAPT_I/HOMARD_YACS_i.cxx b/src/ADAPT_I/HOMARD_YACS_i.cxx new file mode 100644 index 000000000..ae6977b23 --- /dev/null +++ b/src/ADAPT_I/HOMARD_YACS_i.cxx @@ -0,0 +1,279 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier +// + +#include "HOMARD_YACS_i.hxx" +#include "ADAPT_Gen_i.hxx" +#include "HOMARD_YACS.hxx" +#include "HOMARD_DriverTools.hxx" + +#include "SALOMEDS_Tool.hxx" + +#include "utilities.h" + +//============================================================================= +/*! + * standard constructor + */ +//============================================================================= +HOMARD_YACS_i::HOMARD_YACS_i() +{ + MESSAGE( "Default constructor, not for use" ); + ASSERT( 0 ); +} +//============================================================================= +/*! + * standard constructor + */ +//============================================================================= +HOMARD_YACS_i::HOMARD_YACS_i( CORBA::ORB_ptr orb, + ADAPT::ADAPT_Gen_var engine ) +{ + MESSAGE("constructor"); + _gen_i = engine; + _orb = orb; + myHomardYACS = new ::HOMARD_YACS(); + ASSERT( myHomardYACS ); +} +//============================================================================= +/*! + * standard destructor + */ +//============================================================================= +HOMARD_YACS_i::~HOMARD_YACS_i() +{ +} +//============================================================================= +//============================================================================= +// Generalites +//============================================================================= +//============================================================================= +void HOMARD_YACS_i::SetName( const char* Name ) +{ + ASSERT( myHomardYACS ); + myHomardYACS->SetName( Name ); +} +//============================================================================= +char* HOMARD_YACS_i::GetName() +{ + ASSERT( myHomardYACS ); + return CORBA::string_dup( myHomardYACS->GetName().c_str() ); +} +//============================================================================= +CORBA::Long HOMARD_YACS_i::Delete( CORBA::Long Option ) +{ + ASSERT( myHomardYACS ); + char* YACSName = GetName() ; + MESSAGE ( "Delete : destruction du schema " << YACSName << ", Option = " << Option ); + return _gen_i->DeleteYACS(YACSName, Option) ; +} +//============================================================================= +char* HOMARD_YACS_i::GetDumpPython() +{ + ASSERT( myHomardYACS ); + return CORBA::string_dup( myHomardYACS->GetDumpPython().c_str() ); +} +//============================================================================= +std::string HOMARD_YACS_i::Dump() const +{ + return ADAPT::Dump( *myHomardYACS ); +} +//============================================================================= +bool HOMARD_YACS_i::Restore( const std::string& stream ) +{ + return ADAPT::Restore( *myHomardYACS, stream ); +} +//============================================================================= +//============================================================================= +// Caracteristiques +//============================================================================= +//============================================================================= +void HOMARD_YACS_i::SetType( CORBA::Long Type ) +{ + ASSERT( myHomardYACS ); + myHomardYACS->SetType( Type ); +} +//============================================================================= +CORBA::Long HOMARD_YACS_i::GetType() +{ + ASSERT( myHomardYACS ); + return CORBA::Long( myHomardYACS->GetType() ); +} +//============================================================================= +//============================================================================= +// Caracteristiques de la convergence +//============================================================================= +//============================================================================= +void HOMARD_YACS_i::SetMaxIter( CORBA::Long MaxIter ) +{ + ASSERT( myHomardYACS ); + myHomardYACS->SetMaxIter( MaxIter ); +} +//============================================================================= +CORBA::Long HOMARD_YACS_i::GetMaxIter() +{ + ASSERT( myHomardYACS ); + return CORBA::Long( myHomardYACS->GetMaxIter() ); +} +//============================================================================= +void HOMARD_YACS_i::SetMaxNode( CORBA::Long MaxNode ) +{ + ASSERT( myHomardYACS ); + myHomardYACS->SetMaxNode( MaxNode ); +} +//============================================================================= +CORBA::Long HOMARD_YACS_i::GetMaxNode() +{ + ASSERT( myHomardYACS ); + return CORBA::Long( myHomardYACS->GetMaxNode() ); +} +//============================================================================= +void HOMARD_YACS_i::SetMaxElem( CORBA::Long MaxElem ) +{ + ASSERT( myHomardYACS ); + myHomardYACS->SetMaxElem( MaxElem ); +} +//============================================================================= +CORBA::Long HOMARD_YACS_i::GetMaxElem() +{ + ASSERT( myHomardYACS ); + return CORBA::Long( myHomardYACS->GetMaxElem() ); +} +//============================================================================= +void HOMARD_YACS_i::SetTestConvergence( CORBA::Long TypeTest, CORBA::Double VRef) +{ + ASSERT( myHomardYACS ); + myHomardYACS->SetTestConvergence( TypeTest, VRef ); +} +//============================================================================= +CORBA::Long HOMARD_YACS_i::GetTestConvergenceType() +{ + ASSERT( myHomardYACS ); + return CORBA::Long( myHomardYACS->GetTestConvergenceType() ); +} +//============================================================================= +CORBA::Double HOMARD_YACS_i::GetTestConvergenceVRef() +{ + ASSERT( myHomardYACS ); + return CORBA::Long( myHomardYACS->GetTestConvergenceVRef() ); +} +//============================================================================= +//============================================================================= +// Repertoire et fichiers +//============================================================================= +//============================================================================= +void HOMARD_YACS_i::SetDirName( const char* NomDir ) +{ + ASSERT( myHomardYACS ); + myHomardYACS->SetDirName( NomDir ); +} +//============================================================================= +char* HOMARD_YACS_i::GetDirName() +{ + ASSERT( myHomardYACS ); + return CORBA::string_dup( myHomardYACS->GetDirName().c_str() ); +} +//============================================================================= +void HOMARD_YACS_i::SetMeshFile( const char* MeshFile ) +{ + ASSERT( myHomardYACS ); + myHomardYACS->SetMeshFile( MeshFile ); +} +//============================================================================= +char* HOMARD_YACS_i::GetMeshFile() +{ + ASSERT( myHomardYACS ); + return CORBA::string_dup( myHomardYACS->GetMeshFile().c_str() ); +} +//============================================================================= +void HOMARD_YACS_i::SetScriptFile( const char* ScriptFile ) +{ + ASSERT( myHomardYACS ); + myHomardYACS->SetScriptFile( ScriptFile ); +} +//============================================================================= +char* HOMARD_YACS_i::GetScriptFile() +{ + ASSERT( myHomardYACS ); + return CORBA::string_dup( myHomardYACS->GetScriptFile().c_str() ); +} +//============================================================================= +void HOMARD_YACS_i::SetXMLFile( const char* XMLFile ) +{ + ASSERT( myHomardYACS ); + MESSAGE ( "SetXMLFile : SetXMLFile = " << XMLFile ); + myHomardYACS->SetXMLFile( XMLFile ); +} +//============================================================================= +char* HOMARD_YACS_i::GetXMLFile() +{ + ASSERT( myHomardYACS ); + return CORBA::string_dup( myHomardYACS->GetXMLFile().c_str() ); +} +//============================================================================= +//============================================================================= +// Liens avec les autres structures +//============================================================================= +//============================================================================= +void HOMARD_YACS_i::SetCaseName( const char* NomCas ) +{ + ASSERT( myHomardYACS ); + myHomardYACS->SetCaseName( NomCas ); +} +//============================================================================= +char* HOMARD_YACS_i::GetCaseName() +{ + ASSERT( myHomardYACS ); + return CORBA::string_dup( myHomardYACS->GetCaseName().c_str() ); +} +//============================================================================= +CORBA::Long HOMARD_YACS_i::Write() +{ +// + char* nomYACS = GetName() ; + return _gen_i->YACSWrite(nomYACS) ; +} +//============================================================================= +CORBA::Long HOMARD_YACS_i::WriteOnFile( const char* XMLFile ) +{ + MESSAGE ( "WriteOnFile : ecriture du schema sur " << XMLFile ); + ASSERT( myHomardYACS ); +// +// Memorisation du fichier associe + SetXMLFile( XMLFile ) ; +// +// Nom du schema + char* nomYACS = GetName() ; + return _gen_i->YACSWriteOnFile(nomYACS, XMLFile) ; +} +//============================================================================= +//============================================================================= +//============================================================================= +// Divers +//============================================================================= +//============================================================================= diff --git a/src/ADAPT_I/HOMARD_YACS_i.hxx b/src/ADAPT_I/HOMARD_YACS_i.hxx new file mode 100644 index 000000000..45c17851d --- /dev/null +++ b/src/ADAPT_I/HOMARD_YACS_i.hxx @@ -0,0 +1,112 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier +// + +#ifndef _HOMARD_YACS_I_HXX_ +#define _HOMARD_YACS_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(ADAPT_Gen) +#include CORBA_SERVER_HEADER(HOMARD_YACS) + +#include "HOMARD_i.hxx" +#include "SALOME_Component_i.hxx" +#include "SALOME_NamingService.hxx" +#include "Utils_CorbaException.hxx" + +#include + +class HOMARD_YACS; + +class HOMARDENGINE_EXPORT HOMARD_YACS_i: + public virtual Engines_Component_i, + public virtual POA_ADAPT::HOMARD_YACS, + public virtual PortableServer::ServantBase +{ +public: + HOMARD_YACS_i( CORBA::ORB_ptr orb, + ADAPT::ADAPT_Gen_var gen_i ); + HOMARD_YACS_i(); + + virtual ~HOMARD_YACS_i(); + +// Generalites + void SetName( const char* Name ); + char* GetName(); + + CORBA::Long Delete( CORBA::Long Option ); + + char* GetDumpPython(); + + std::string Dump() const; + bool Restore( const std::string& stream ); + +// Caracteristiques + void SetType( CORBA::Long Type ); + CORBA::Long GetType(); + + void SetMaxIter( CORBA::Long MaxIter ); + CORBA::Long GetMaxIter(); + void SetMaxNode( CORBA::Long MaxNode ); + CORBA::Long GetMaxNode(); + void SetMaxElem( CORBA::Long MaxElem ); + CORBA::Long GetMaxElem(); + + void SetTestConvergence( CORBA::Long TypeTest, CORBA::Double VRef ); + CORBA::Long GetTestConvergenceType(); + CORBA::Double GetTestConvergenceVRef(); + + void SetDirName( const char* NomDir ); + char* GetDirName(); + + void SetMeshFile( const char* MeshFile ); + char* GetMeshFile(); + + void SetScriptFile( const char* ScriptFile ); + char* GetScriptFile(); + + void SetXMLFile( const char* XMLFile ); + char* GetXMLFile(); + + CORBA::Long Write() ; + CORBA::Long WriteOnFile( const char* XMLFile ) ; + + // Liens avec les autres structures + void SetCaseName( const char* NomCas ); + char* GetCaseName(); + +// Divers + +private: + ::HOMARD_YACS* myHomardYACS; + + CORBA::ORB_ptr _orb; + ADAPT::ADAPT_Gen_var _gen_i; +}; + +#endif diff --git a/src/ADAPT_I/HOMARD_Zone_i.cxx b/src/ADAPT_I/HOMARD_Zone_i.cxx new file mode 100644 index 000000000..b8ee19062 --- /dev/null +++ b/src/ADAPT_I/HOMARD_Zone_i.cxx @@ -0,0 +1,218 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier +// + +#include "HOMARD_Zone_i.hxx" +#include "ADAPT_Gen_i.hxx" +#include "HOMARD_Zone.hxx" +#include "HOMARD_DriverTools.hxx" + +#include "utilities.h" + +//============================================================================= +/*! + * standard constructor + */ +//============================================================================= +HOMARD_Zone_i::HOMARD_Zone_i() +{ + MESSAGE( "Default constructor, not for use" ); + ASSERT( 0 ); +} + +//============================================================================= +/*! + * standard constructor + */ +//============================================================================= +HOMARD_Zone_i::HOMARD_Zone_i( CORBA::ORB_ptr orb, + ADAPT::ADAPT_Gen_var engine ) +{ + MESSAGE( "HOMARD_Zone_i" ); + _gen_i = engine; + _orb = orb; + myHomardZone = new ::HOMARD_Zone(); + ASSERT( myHomardZone ); +} +//============================================================================= +/*! + * standard destructor + */ +//============================================================================= + +HOMARD_Zone_i::~HOMARD_Zone_i() +{ +} +//============================================================================= +//============================================================================= +// Generalites +//============================================================================= +//============================================================================= +void HOMARD_Zone_i::SetName( const char* Name ) +{ + ASSERT( myHomardZone ); + myHomardZone->SetName( Name ); +} +//============================================================================= +char* HOMARD_Zone_i::GetName() +{ + ASSERT( myHomardZone ); + return CORBA::string_dup( myHomardZone->GetName().c_str() ); +} +//============================================================================= +CORBA::Long HOMARD_Zone_i::Delete() +{ + ASSERT( myHomardZone ); + char* ZoneName = GetName() ; + MESSAGE ( "Delete : destruction de la zone " << ZoneName ); + return _gen_i->DeleteZone(ZoneName) ; +} +//============================================================================= +char* HOMARD_Zone_i::GetDumpPython() +{ + ASSERT( myHomardZone ); + return CORBA::string_dup( myHomardZone->GetDumpPython().c_str() ); +} +//============================================================================= +std::string HOMARD_Zone_i::Dump() const +{ + return ADAPT::Dump( *myHomardZone ); +} +//============================================================================= +bool HOMARD_Zone_i::Restore( const std::string& stream ) +{ + return ADAPT::Restore( *myHomardZone, stream ); +} +//============================================================================= +//============================================================================= +// Caracteristiques +//============================================================================= +//============================================================================= +void HOMARD_Zone_i::SetType( CORBA::Long Type ) +{ + ASSERT( myHomardZone ); + myHomardZone->SetType( Type ); +} +//============================================================================= +CORBA::Long HOMARD_Zone_i::GetType() +{ + ASSERT( myHomardZone ); + return CORBA::Long( myHomardZone->GetType() ); +} +//============================================================================= +void HOMARD_Zone_i::SetBox( double X0, double X1, double X2, double X3, double X4, double X5 ) +{ + ASSERT( myHomardZone ); + myHomardZone->SetBox( X0, X1, X2, X3, X4, X5 ); +} +//============================================================================= +void HOMARD_Zone_i::SetCylinder( double Xcentre, double Ycentre, double Zcentre, + double Xaxis, double Yaxis, double Zaxis, + double Rayon, double Haut ) +{ + ASSERT( myHomardZone ); + myHomardZone->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxis, Yaxis, Zaxis, Rayon, Haut ); +} +//============================================================================= +void HOMARD_Zone_i::SetPipe( double Xcentre, double Ycentre, double Zcentre, + double Xaxis, double Yaxis, double Zaxis, + double Rayon, double Haut, double Rayonint ) +{ + ASSERT( myHomardZone ); + myHomardZone->SetPipe( Xcentre, Ycentre, Zcentre, Xaxis, Yaxis, Zaxis, Rayon, Haut, Rayonint ); +} +//============================================================================= +void HOMARD_Zone_i::SetSphere( double Xcentre, double Ycentre, double Zcentre, double Rayon ) +{ + ASSERT( myHomardZone ); + myHomardZone->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ); +} +//============================================================================= +ADAPT::double_array* HOMARD_Zone_i::GetCoords() +{ + ASSERT( myHomardZone ); + ADAPT::double_array_var aResult = new ADAPT::double_array(); + std::vector mesCoor = myHomardZone->GetCoords(); + aResult->length( mesCoor .size() ); + std::vector::const_iterator it; + int i = 0; + for ( it = mesCoor.begin(); it != mesCoor.end(); it++ ) + aResult[i++] = (*it); + return aResult._retn(); +} +//============================================================================= +void HOMARD_Zone_i::SetLimit( double Xincr, double Yincr, double Zincr ) +{ + MESSAGE ("SetLimit, Xincr : " << Xincr << ", Yincr : " << Yincr << ", Zincr : " << Zincr) ; + ASSERT( myHomardZone ); + myHomardZone->SetLimit( Xincr, Yincr, Zincr ); +} +//============================================================================= +ADAPT::double_array* HOMARD_Zone_i::GetLimit() +{ + ASSERT( myHomardZone ); + ADAPT::double_array_var aResult = new ADAPT::double_array(); + std::vector mesCoor = myHomardZone->GetLimit(); + aResult->length( mesCoor .size() ); + std::vector::const_iterator it; + int i = 0; + for ( it = mesCoor.begin(); it != mesCoor.end(); it++ ) + aResult[i++] = (*it); + return aResult._retn(); +} +//============================================================================= +//============================================================================= +// Liens avec les autres structures +//============================================================================= +//============================================================================= +void HOMARD_Zone_i::AddHypo( const char* NomHypo ) +{ + MESSAGE ( " AddHypo, NomHypo= " << NomHypo); + ASSERT( myHomardZone ); + myHomardZone->AddHypo( NomHypo ); +} +//============================================================================= +ADAPT::listeHypo* HOMARD_Zone_i::GetHypo() +{ + ASSERT( myHomardZone ); + const std::list& maListe = myHomardZone->GetHypo(); + ADAPT::listeHypo_var aResult = new ADAPT::listeHypo; + aResult->length( maListe.size() ); + std:: list::const_iterator it; + int i = 0; + for ( it = maListe.begin(); it != maListe.end(); it++ ) + aResult[i++] = CORBA::string_dup( (*it).c_str() ); + return aResult._retn(); +} +//============================================================================= +void HOMARD_Zone_i::SupprHypo( const char* NomHypo ) +{ + ASSERT( myHomardZone ); + myHomardZone->SupprHypo( NomHypo ); +} + diff --git a/src/ADAPT_I/HOMARD_Zone_i.hxx b/src/ADAPT_I/HOMARD_Zone_i.hxx new file mode 100644 index 000000000..ee4e29e7c --- /dev/null +++ b/src/ADAPT_I/HOMARD_Zone_i.hxx @@ -0,0 +1,104 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier +// + +#ifndef _HOMARD_Zone_I_HXX_ +#define _HOMARD_Zone_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(ADAPT_Gen) +#include CORBA_SERVER_HEADER(HOMARD_Zone) + +#include "HOMARD_i.hxx" +#include "SALOME_Component_i.hxx" +#include "SALOME_NamingService.hxx" +#include "Utils_CorbaException.hxx" + +#include + +class HOMARD_Zone; + +class HOMARDENGINE_EXPORT HOMARD_Zone_i: + public virtual Engines_Component_i, + public virtual POA_ADAPT::HOMARD_Zone, + public virtual PortableServer::ServantBase +{ +public: + HOMARD_Zone_i( CORBA::ORB_ptr orb, ADAPT::ADAPT_Gen_var gen_i ); + HOMARD_Zone_i(); + + virtual ~HOMARD_Zone_i(); + +// Generalites + void SetName( const char* Name ); + char* GetName(); + + CORBA::Long Delete(); + + char* GetDumpPython(); + + std::string Dump() const; + bool Restore( const std::string& stream ); + +// Caracteristiques + void SetType( CORBA::Long Type ); + CORBA::Long GetType(); + + void SetBox( double Xmini, double Xmaxi, + double Ymini, double Ymaxi, + double Zmini, double Zmaxi ); + + void SetCylinder( double Xcentre, double Ycentre, double ZCentre, + double Xaxis, double Yaxis, double Zaxis, + double Rayon, double Haut ); + + void SetPipe( double Xcentre, double Ycentre, double ZCentre, + double Xaxis, double Yaxis, double Zaxis, + double Rayon, double Haut, double Rayonint ); + + void SetSphere( double Xcentre, double Ycentre, double ZCentre, + double Rayon ); + + ADAPT::double_array* GetCoords(); + + void SetLimit( double Xincr, double Yincr, double Zincr); + ADAPT::double_array* GetLimit(); + +// Liens avec les autres structures + void AddHypo( const char *NomHypo ); + ADAPT::listeHypo* GetHypo(); + void SupprHypo( const char *NomHypo ); + +private: + ::HOMARD_Zone* myHomardZone; + + CORBA::ORB_ptr _orb; + ADAPT::ADAPT_Gen_var _gen_i; +}; + +#endif diff --git a/src/ADAPT_I/HOMARD_i.hxx b/src/ADAPT_I/HOMARD_i.hxx new file mode 100644 index 000000000..359e33143 --- /dev/null +++ b/src/ADAPT_I/HOMARD_i.hxx @@ -0,0 +1,35 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef _HOMARD_I_HXX_ +#define _HOMARD_I_HXX_ + +#ifdef WIN32 + #if defined HOMARDENGINE_EXPORTS || defined ADAPTEngine_EXPORTS + #define HOMARDENGINE_EXPORT __declspec( dllexport ) + #else + #define HOMARDENGINE_EXPORT __declspec( dllimport ) + #endif +#else + #define HOMARDENGINE_EXPORT +#endif + +#endif //_HOMARD_I_HXX_ + + diff --git a/src/ADAPT_I/HomardMedCommun.cxx b/src/ADAPT_I/HomardMedCommun.cxx new file mode 100644 index 000000000..4fc06c891 --- /dev/null +++ b/src/ADAPT_I/HomardMedCommun.cxx @@ -0,0 +1,335 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "HomardMedCommun.h" + +#include +#include +#include +#include +#include + +#include + +#include "utilities.h" +// ======================================================================= +int MEDFileExist( const char * aFile ) +// Retourne 1 si le fichier existe, 0 sinon +// ======================================================================= +{ + int existe ; + med_idt medIdt = MEDfileOpen(aFile,MED_ACC_RDONLY); + if ( medIdt < 0 ) { existe = 0 ; } + else { MEDfileClose(medIdt); + existe = 1 ; } + return existe ; +} +// ======================================================================= +std::set GetListeGroupesInMedFile(const char * aFile) +// ======================================================================= +{ + std::set ListeGroupes; + med_err erreur = 0 ; + med_idt medIdt ; + while ( erreur == 0 ) + { + // Ouverture du fichier + medIdt = MEDfileOpen(aFile,MED_ACC_RDONLY); + if ( medIdt < 0 ) + { + erreur = 1 ; + break ; + } + // Caracteristiques du maillage + char meshname[MED_NAME_SIZE+1]; + med_int spacedim,meshdim; + med_mesh_type meshtype; + char descriptionription[MED_COMMENT_SIZE+1]; + char dtunit[MED_SNAME_SIZE+1]; + med_sorting_type sortingtype; + med_int nstep; + med_axis_type axistype; + int naxis = MEDmeshnAxis(medIdt,1); + char *axisname=new char[naxis*MED_SNAME_SIZE+1]; + char *axisunit=new char[naxis*MED_SNAME_SIZE+1]; + erreur = MEDmeshInfo(medIdt, + 1, + meshname, + &spacedim, + &meshdim, + &meshtype, + descriptionription, + dtunit, + &sortingtype, + &nstep, + &axistype, + axisname, + axisunit); + delete[] axisname ; + delete[] axisunit ; + if ( erreur < 0 ) { break ; } + // Nombre de familles + med_int nfam ; + nfam = MEDnFamily(medIdt,meshname) ; + if ( nfam < 0 ) + { + erreur = 2 ; + break ; + } + // Lecture des caracteristiques des familles + for (int i=0;i 0 ) + { + char familyname[MED_NAME_SIZE+1]; + med_int numfam; + char* gro = (char*) malloc(MED_LNAME_SIZE*ngro+1); + erreur = MEDfamilyInfo(medIdt, + meshname, + i+1, + familyname, + &numfam, + gro); + if ( erreur < 0 ) + { + free(gro); + break ; + } + // Lecture des groupes pour une famille de mailles + if ( numfam < 0) + { + for (int j=0;j 0 ) MEDfileClose(medIdt); + + return ListeGroupes; +} + +// ======================================================================= +std::vector GetBoundingBoxInMedFile(const char * aFile) +// ======================================================================= +{ +// Le vecteur en retour contiendra les informations suivantes : +// en position 0 et 1 Xmin, Xmax et en position 2 Dx si < 0 2D +// en position 3 et 4 Ymin, Ymax et en position 5 Dy si < 0 2D +// en position 6 et 7 Zmin, Zmax et en position 8 Dz si < 0 2D +// 9 distance max dans le maillage + + std::vector LesExtremes; + med_err erreur = 0 ; + med_idt medIdt ; + while ( erreur == 0 ) + { + // Ouverture du fichier + medIdt = MEDfileOpen(aFile,MED_ACC_RDONLY); + if ( medIdt < 0 ) + { + erreur = 1 ; + break ; + } + //Nombre de maillage : on ne peut en lire qu'un seul + med_int numberOfMeshes = MEDnMesh(medIdt) ; + if (numberOfMeshes != 1 ) + { + erreur = 2 ; + break ; + } + // Caracteristiques du maillage + char meshname[MED_NAME_SIZE+1]; + med_int spacedim,meshdim; + med_mesh_type meshtype; + char descriptionription[MED_COMMENT_SIZE+1]; + char dtunit[MED_SNAME_SIZE+1]; + med_sorting_type sortingtype; + med_int nstep; + med_axis_type axistype; + int naxis = MEDmeshnAxis(medIdt,1); + char *axisname=new char[naxis*MED_SNAME_SIZE+1]; + char *axisunit=new char[naxis*MED_SNAME_SIZE+1]; + erreur = MEDmeshInfo(medIdt, + 1, + meshname, + &spacedim, + &meshdim, + &meshtype, + descriptionription, + dtunit, + &sortingtype, + &nstep, + &axistype, + axisname, + axisunit); + delete[] axisname ; + delete[] axisunit ; + if ( erreur < 0 ) { break ; } + + // Nombre de noeuds + med_bool chgt,trsf; + med_int nnoe = MEDmeshnEntity(medIdt, + meshname, + MED_NO_DT, + MED_NO_IT, + MED_NODE, + MED_NO_GEOTYPE, + MED_COORDINATE, + MED_NO_CMODE, + &chgt, + &trsf); + if ( nnoe < 0 ) + { + erreur = 4; + break ; + } + + // Les coordonnees + med_float* coo = (med_float*) malloc(sizeof(med_float)*nnoe*spacedim); + + erreur = MEDmeshNodeCoordinateRd(medIdt, + meshname, + MED_NO_DT, + MED_NO_IT, + MED_NO_INTERLACE, + coo); + if ( erreur < 0 ) + { + free(coo) ; + break ; + } + + // Calcul des extremes + med_float xmin,xmax,ymin,ymax,zmin,zmax; + + xmin=coo[0]; + xmax=coo[0]; + for (int i=1;i 1) + { + ymin=coo[nnoe]; ymax=coo[nnoe]; + for (int i=nnoe+1;i<2*nnoe;i++) + { + ymin = std::min(ymin,coo[i]); + ymax = std::max(ymax,coo[i]); + } + } + else + { + ymin=0; + ymax=0; + zmin=0; + zmax=0; + } +// + if (spacedim > 2) + { + zmin=coo[2*nnoe]; zmax=coo[2*nnoe]; + for (int i=2*nnoe+1;i<3*nnoe;i++) + { + zmin = std::min(zmin,coo[i]); + zmax = std::max(zmax,coo[i]); + } + } + else + { + zmin=0; + zmax=0; + } + + MESSAGE( "_______________________________________"); + MESSAGE( "xmin : " << xmin << " xmax : " << xmax ); + MESSAGE( "ymin : " << ymin << " ymax : " << ymax ); + MESSAGE( "zmin : " << zmin << " zmax : " << zmax ); + MESSAGE( "_______________________________________" ); + double epsilon = 1.e-6 ; + LesExtremes.push_back(xmin); + LesExtremes.push_back(xmax); + LesExtremes.push_back(0); + LesExtremes.push_back(ymin); + LesExtremes.push_back(ymax); + LesExtremes.push_back(0); + LesExtremes.push_back(zmin); + LesExtremes.push_back(zmax); + LesExtremes.push_back(0); + + + double max1=std::max ( LesExtremes[1] - LesExtremes[0] , LesExtremes[4] - LesExtremes[3] ) ; + double max2=std::max ( max1 , LesExtremes[7] - LesExtremes[6] ) ; + LesExtremes.push_back(max2); + +// LesExtremes[0] = Xmini du maillage +// LesExtremes[1] = Xmaxi du maillage +// LesExtremes[2] = increment de progression en X +// LesExtremes[3,4,5] : idem pour Y +// LesExtremes[6,7,8] : idem pour Z +// LesExtremes[9] = ecart maximal entre coordonnees +// On fait un traitement pour dans le cas d'une coordonnee constante +// inhiber ce cas en mettant un increment negatif +// + double diff = LesExtremes[1] - LesExtremes[0]; + if ( fabs(diff) > epsilon*max2 ) { LesExtremes[2] = diff/100.; } + else { LesExtremes[2] = -1. ; } + + diff = LesExtremes[4] - LesExtremes[3]; + if ( fabs(diff) > epsilon*max2 ) { LesExtremes[5]=diff/100.; } + else { LesExtremes[5] = -1. ; } + + diff = LesExtremes[7] - LesExtremes[6]; + if ( fabs(diff) > epsilon*max2 ) { LesExtremes[8]=diff/100.; } + else { LesExtremes[8] = -1. ; } + + MESSAGE ( "_______________________________________" ); + MESSAGE ( "xmin : " << LesExtremes[0] << " xmax : " << LesExtremes[1] << " xincr : " << LesExtremes[2] ); + MESSAGE ( "ymin : " << LesExtremes[3] << " ymax : " << LesExtremes[4] << " yincr : " << LesExtremes[5] ); + MESSAGE ( "zmin : " << LesExtremes[6] << " zmax : " << LesExtremes[7] << " zincr : " << LesExtremes[8] ); + MESSAGE ( "dmax : " << LesExtremes[9] ); + MESSAGE ( "_______________________________________" ); + + free(coo) ; + break ; + } + // Fermeture du fichier + if ( medIdt > 0 ) MEDfileClose(medIdt); + + return LesExtremes; +} + diff --git a/src/ADAPT_I/HomardMedCommun.h b/src/ADAPT_I/HomardMedCommun.h new file mode 100644 index 000000000..0ab2a3ff3 --- /dev/null +++ b/src/ADAPT_I/HomardMedCommun.h @@ -0,0 +1,32 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HOMARDMEDCOMMUN_H +#define HOMARDMEDCOMMUN_H + +#include "HOMARD_i.hxx" +#include +#include +#include + +HOMARDENGINE_EXPORT int MEDFileExist( const char * aFile ); +HOMARDENGINE_EXPORT std::vector GetBoundingBoxInMedFile( const char * aFile); +HOMARDENGINE_EXPORT std::set GetListeGroupesInMedFile(const char * aFile); + +#endif // HOMARD%MEDCOMMUN_H diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 88405aed6..1142d5784 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -40,6 +40,10 @@ SET(SUBDIRS_COMMON StdMeshers_I SMESH_PY Tools + ADAPT + ADAPT_I + ADAPTFrontTrack + ADAPTFrontTrack_SWIG ) IF(SALOME_SMESH_ENABLE_MEFISTO) @@ -50,7 +54,7 @@ ENDIF(SALOME_SMESH_ENABLE_MEFISTO) # CGNS ## IF(SALOME_SMESH_USE_CGNS) - SET(SUBDIRS_CGNS + SET(SUBDIRS_CGNS DriverCGNS ) ENDIF(SALOME_SMESH_USE_CGNS) @@ -59,12 +63,13 @@ ENDIF(SALOME_SMESH_USE_CGNS) # GUI ## IF(SALOME_BUILD_GUI) - SET(SUBDIRS_GUI OBJECT - SMESHFiltersSelection - SMESHGUI + SET(SUBDIRS_GUI OBJECT + SMESHFiltersSelection + SMESHGUI PluginUtils SMESH_SWIG_WITHIHM StdMeshersGUI + ADAPTGUI ) ENDIF(SALOME_BUILD_GUI) diff --git a/src/SMESH/CMakeLists.txt b/src/SMESH/CMakeLists.txt index 129ec5c41..55b8da584 100644 --- a/src/SMESH/CMakeLists.txt +++ b/src/SMESH/CMakeLists.txt @@ -38,6 +38,7 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/SMDS ${PROJECT_SOURCE_DIR}/src/SMESHDS ${PROJECT_SOURCE_DIR}/src/SMESHUtils + ${MEDCOUPLING_INCLUDE_DIRS} ) # additional preprocessor / compiler flags @@ -67,6 +68,7 @@ SET(_link_LIBRARIES MeshDriverUNV MeshDriverGMF ${DriverCGNS_LIB} + ${MEDCoupling_medloader} ) # --- headers --- @@ -86,6 +88,7 @@ SET(SMESHimpl_HEADERS SMESH_MesherHelper.hxx SMESH_ProxyMesh.hxx SMESH_SMESH.hxx + MG_ADAPT.hxx ) # --- sources --- @@ -104,6 +107,7 @@ SET(SMESHimpl_SOURCES SMESH_HypoFilter.cxx SMESH_ProxyMesh.cxx SMESH_MesherHelper.cxx + MG_ADAPT.cxx ) # --- rules --- diff --git a/src/SMESH/MG_ADAPT.cxx b/src/SMESH/MG_ADAPT.cxx new file mode 100644 index 000000000..2445d8cdb --- /dev/null +++ b/src/SMESH/MG_ADAPT.cxx @@ -0,0 +1,1452 @@ +// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ +// file : MG_ADAPT.cxx + +#include "MG_ADAPT.hxx" + +#include "MeshFormatReader.hxx" +#include "MeshFormatWriter.hxx" +#include "MEDFileMesh.hxx" +#include "MCAuto.hxx" +#include "MEDFileData.hxx" +#include "MEDFileField.hxx" +#include "MEDCouplingFieldDouble.hxx" + +#include +#include +#include +#include +#include +#include +#include + +using namespace MG_ADAPT; +static std::string removeFile(std::string fileName, int& notOk) +{ + std::string errStr; + notOk = std::remove(fileName.c_str()); + if (notOk) errStr = ToComment(" \n error while removing file : ") + << fileName; + else errStr= ToComment("\n file : ")<< fileName << " succesfully deleted! \n "; + + return errStr; +} +std::string remove_extension(const std::string& filename) { + size_t lastdot = filename.find_last_of("."); + if (lastdot == std::string::npos) return filename; + return filename.substr(0, lastdot); +} +namespace +{ +struct GET_DEFAULT // struct used to get default value from GetOptionValue() +{ + bool isDefault; + operator bool* () { + return &isDefault; + } +}; +} + +//---------------------------------------------------------------------------------------- +MgAdapt::MgAdapt() +{ + data = new MgAdaptHypothesisData(); + data->myInMeshName = ""; + data->fromMedFile = defaultFromMedFile(); + data->myFileInDir = defaultWorkingDirectory(); + data->myMeshFileIn = ""; + data->myFileOutDir = defaultWorkingDirectory(); + data->myOutMeshName = ""; + data->myMeshFileOut = ""; + data->myMeshOutMed = defaultMeshOutMed(); + data->myPublish = defaultPublish(); + data->myUseLocalMap = defaultUseLocalMap(); + data->myUseBackgroundMap = defaultUseBackgroundMap(); + data->myFileSizeMapDir = defaultWorkingDirectory(); + data->myMeshFileBackground = ""; + data->myUseConstantValue = defaultUseConstantValue(); + data->myConstantValue = 0.0; + data->myFieldName = ""; + data->myUseNoTimeStep = defaultUseNoTimeStep(); + data->myUseLastTimeStep = defaultUseLastTimeStep(); + data->myUseChosenTimeStep = defaultUseChosenTimeStep(); + data->myTimeStep = -2; + data->myRank = -2; + data->myWorkingDir = defaultWorkingDirectory(); + data->myLogFile = defaultLogFile(); + data->myVerboseLevel = defaultVerboseLevel(); + data->myPrintLogInFile = defaultPrintLogInFile(); + data->myKeepFiles = defaultKeepFiles(); + data->myRemoveLogOnSuccess = defaultRemoveLogOnSuccess(); + + buildModel(); + setAll(); +} +MgAdapt::MgAdapt(MgAdaptHypothesisData* myData) +{ + data = new MgAdaptHypothesisData(); + setData(myData); + buildModel(); +} + +MgAdapt::MgAdapt( const MgAdapt& copy) +{ + + data = new MgAdaptHypothesisData(); + MgAdaptHypothesisData *copyData = copy.getData(); + copyMgAdaptHypothesisData(copyData); + setAll(); + + this->_option2value = copy._option2value; + this->_customOption2value = copy._customOption2value; + this->_defaultOptionValues = copy._defaultOptionValues; + this->_doubleOptions = copy._doubleOptions; + this->_charOptions = copy._charOptions; + this->_boolOptions = copy._boolOptions; + +} + + + +//----------------------------------------------------------------------------------------- +MgAdapt::~MgAdapt() +{ + + delete data; + +} +void MgAdapt::buildModel() +{ + + const char* boolOptionNames[] = { "compute_ridges", // yes + "" // mark of end + }; + // const char* intOptionNames[] = { "max_number_of_errors_printed", // 1 + // "max_number_of_threads", // 4 + // "" // mark of end + // }; + const char* doubleOptionNames[] = { "max_memory", // 0 + "" // mark of end + }; + const char* charOptionNames[] = { "components", // "yes" + "adaptation", // both + "" // mark of end + }; + + int i = 0; + while (boolOptionNames[i][0]) + { + _boolOptions.insert( boolOptionNames[i] ); + _option2value[boolOptionNames[i++]].clear(); + } + // i = 0; + // while (intOptionNames[i][0]) + // _option2value[intOptionNames[i++]].clear(); + + i = 0; + while (doubleOptionNames[i][0]) { + _doubleOptions.insert(doubleOptionNames[i]); + _option2value[doubleOptionNames[i++]].clear(); + } + i = 0; + while (charOptionNames[i][0]) { + _charOptions.insert(charOptionNames[i]); + _option2value[charOptionNames[i++]].clear(); + } + + // default values to be used while MG-Adapt + + _defaultOptionValues["adaptation" ] = "both"; + _defaultOptionValues["components" ] = "outside components"; + _defaultOptionValues["compute_ridges" ] = "yes"; + _defaultOptionValues["max_memory" ] = ToComment(defaultMaximumMemory()); +} + +//============================================================================= +TOptionValues MgAdapt::getOptionValues() const +{ + TOptionValues vals; + TOptionValues::const_iterator op_val = _option2value.begin(); + for ( ; op_val != _option2value.end(); ++op_val ) + vals.insert( make_pair( op_val->first, getOptionValue( op_val->first, GET_DEFAULT() ))); + + return vals; +} + +std::vector MgAdapt::getOptionValuesStrVec() const +{ + std::vector vals; + TOptionValues::const_iterator op_val = _option2value.begin(); + for ( ; op_val != _option2value.end(); ++op_val ) + vals.push_back(op_val->first+":"+getOptionValue( op_val->first, GET_DEFAULT() )); + + return vals; +} + +std::vector MgAdapt::getCustomOptionValuesStrVec() const +{ + std::vector vals; + TOptionValues::const_iterator op_val; + for ( op_val = _customOption2value.begin(); op_val != _customOption2value.end(); ++op_val ) + { + vals.push_back(op_val->first+":"+getOptionValue( op_val->first, GET_DEFAULT() )); + } + return vals; +} +const TOptionValues& MgAdapt::getCustomOptionValues() const +{ + return _customOption2value; +} +void MgAdapt::setData(MgAdaptHypothesisData* myData) +{ + copyMgAdaptHypothesisData(myData); + setAll(); +} +MgAdaptHypothesisData* MgAdapt::getData() const +{ + return data; +} +void MgAdapt::setMedFileIn(std::string fileName) +{ + medFileIn = fileName; + if (medFileOut == "") // default MED file Out + medFileOut = remove_extension( fileName )+ ".adapt.med"; +} + +std::string MgAdapt::getMedFileIn() +{ + return medFileIn; +} + +void MgAdapt::setMedFileOut(std::string fileOut) +{ + medFileOut = fileOut; +} + +std::string MgAdapt::getMedFileOut() +{ + return medFileOut; +} +void MgAdapt::setMeshOutMed(bool mybool) +{ + meshOutMed = mybool; +} +bool MgAdapt::getMeshOutMed() +{ + return meshOutMed; +} +void MgAdapt::setPublish(bool mybool) +{ + publish = mybool; +} +bool MgAdapt::getPublish() +{ + return publish; +} +void MgAdapt::setFieldName(std::string myFieldName) +{ + fieldName = myFieldName; +} +std::string MgAdapt::getFieldName() +{ + return fieldName; +} +void MgAdapt::setTimeStep(int time) +{ + timeStep = time; +} +int MgAdapt::getTimeStep() const +{ + return timeStep; +} + +void MgAdapt::setRankTimeStep(int time, int myRank) +{ + timeStep = time; + rank = myRank; +} + +int MgAdapt::getRank() +{ + return rank; +} +void MgAdapt::setTimeStepRankLast() +{ + myUseLastTimeStep = true; + myUseChosenTimeStep = false; + myUseNoTimeStep = false; + //~med_int aRank, tmst; + //~std::string fieldFile = useBackgroundMap ? sizeMapFile : medFileIn; + //~getTimeStepInfos(fieldFile, tmst, aRank); + //~setRankTimeStep((int) tmst, (int) aRank); +} +void MgAdapt::setNoTimeStep() +{ + myUseLastTimeStep = false; + myUseChosenTimeStep = false; + myUseNoTimeStep = true; + //~int aRank = (int)MED_NO_IT; + //~int tmst = (int)MED_NO_DT ; + //~setRankTimeStep(tmst, aRank); +} +void MgAdapt::setChosenTimeStepRank() +{ + myUseLastTimeStep = false; + myUseChosenTimeStep = true; + myUseNoTimeStep = false; + //~int aRank = (int)MED_NO_IT; + //~int tmst = (int)MED_NO_DT ; + //~setRankTimeStep(tmst, aRank); +} +void MgAdapt::setUseLocalMap(bool myLocal) +{ + useLocalMap = myLocal; +} + +bool MgAdapt::getUseLocalMap() +{ + return useLocalMap; +} + +void MgAdapt::setUseBackgroundMap(bool bckg) +{ + useBackgroundMap = bckg; +} + +bool MgAdapt::getUseBackgroundMap() +{ + return useBackgroundMap; +} + +void MgAdapt::setUseConstantValue(bool cnst) +{ + useConstantValue = cnst; +} +bool MgAdapt::getUseConstantValue() +{ + return useConstantValue; +} +void MgAdapt::setLogFile(std::string myLogFile) +{ + logFile = myLogFile; +} +std::string MgAdapt::getLogFile() +{ + return logFile; +} +void MgAdapt::setVerbosityLevel(int verboLevel) +{ + verbosityLevel = verboLevel; +} +int MgAdapt::getVerbosityLevel() +{ + return verbosityLevel; +} +void MgAdapt::setRemoveOnSuccess(bool rmons) +{ + removeOnSuccess = rmons; +} +bool MgAdapt::getRemoveOnSuccess() +{ + return removeOnSuccess; +} +void MgAdapt::setSizeMapFile(std::string mapFile) +{ + sizeMapFile = mapFile; +} +std::string MgAdapt::getSizeMapFile() +{ + return sizeMapFile; +} + +void MgAdapt::setMeshName(std::string name) +{ + meshName = name; +} +std::string MgAdapt::getMeshName() +{ + return meshName; +} +void MgAdapt::setMeshNameOut(std::string name) +{ + meshNameOut = name; +} +std::string MgAdapt::getMeshNameOut() +{ + return meshNameOut; +} +void MgAdapt::setFromMedFile(bool mybool) +{ + fromMedFile = mybool; +} +bool MgAdapt::isFromMedFile() +{ + return fromMedFile; +} +void MgAdapt::setConstantValue(double cnst) +{ + constantValue = cnst; +} +double MgAdapt::getConstantValue() const +{ + return constantValue; +} + +void MgAdapt::setWorkingDir(std::string dir) +{ + workingDir = dir; +} +std::string MgAdapt::getWorkingDir() const +{ + return workingDir; +} +void MgAdapt::setKeepWorkingFiles(bool mybool) +{ + toKeepWorkingFiles = mybool; +} +bool MgAdapt::getKeepWorkingFiles() +{ + return toKeepWorkingFiles; +} +void MgAdapt::setPrintLogInFile(bool print) +{ + printLogInFile = print; +} +bool MgAdapt::getPrintLogInFile() +{ + return printLogInFile; +} + + +bool MgAdapt::setAll() +{ + + setFromMedFile(data->fromMedFile); + std::string file; + checkDirPath(data->myFileInDir); + file = data->myFileInDir+data->myMeshFileIn; + setMedFileIn(file); + setMeshName(data->myInMeshName); + setMeshNameOut(data->myOutMeshName); + checkDirPath(data->myFileOutDir); + std::string out = data->myFileOutDir+data->myMeshFileOut; + setMedFileOut(out); + setPublish(data->myPublish); + setMeshOutMed(data->myMeshOutMed); + setUseLocalMap(data->myUseLocalMap); + setUseBackgroundMap(data->myUseBackgroundMap); + setUseConstantValue(data->myUseConstantValue); + + std::string mapfile; + if (useBackgroundMap) + { + + checkDirPath(data->myFileSizeMapDir); + mapfile = data->myFileSizeMapDir+data->myMeshFileBackground; + setFieldName(data->myFieldName); + } + else if (useConstantValue) + { + setConstantValue(data->myConstantValue); + } + else + { + mapfile =""; + setConstantValue(0.0); + setFieldName(data->myFieldName); + + } + + setSizeMapFile(mapfile); + if (data->myUseNoTimeStep) + setNoTimeStep(); + else if (data->myUseLastTimeStep) + setTimeStepRankLast(); + else + { + setChosenTimeStepRank(); + setRankTimeStep(data->myTimeStep, data->myRank); + } + /* Advanced options */ + setWorkingDir(data->myWorkingDir); + checkDirPath(data->myWorkingDir); + setLogFile(data->myWorkingDir+defaultLogFile()); + setVerbosityLevel(data->myVerboseLevel); + setRemoveOnSuccess(data->myRemoveLogOnSuccess); + setPrintLogInFile(data->myPrintLogInFile); + setKeepWorkingFiles(data->myKeepFiles); + + return true; +} + +void MgAdapt::checkDirPath(std::string& dirPath) +{ + const char lastChar = *dirPath.rbegin(); +#ifdef WIN32 + if(lastChar != '\\') dirPath+='\\'; +#else + if(lastChar != '/') dirPath+='/'; +#endif +} +//============================================================================= +void MgAdapt::setOptionValue(const std::string& optionName, + const std::string& optionValue) +throw (std::invalid_argument) +{ + TOptionValues::iterator op_val = _option2value.find(optionName); + if (op_val == _option2value.end()) + { + op_val = _customOption2value.find( optionName ); + _customOption2value[ optionName ] = optionValue; + return; + } + + if (op_val->second != optionValue) + { + + std::string lowerOptionValue = toLowerStr(optionValue); + const char* ptr = lowerOptionValue.c_str(); + // strip white spaces + while (ptr[0] == ' ') + ptr++; + int i = strlen(ptr); + while (i != 0 && ptr[i - 1] == ' ') + i--; + // check value type + bool typeOk = true; + std::string typeName; + if (i == 0) { + // empty string + } else if (_charOptions.count(optionName)) { + // do not check strings + } else if (_doubleOptions.count(optionName)) { + // check if value is double + toDbl(ptr, &typeOk); + typeName = "real"; + } else if (_boolOptions.count(optionName)) { + // check if value is bool + toBool(ptr, &typeOk); + typeName = "bool"; + } else { + // check if value is int + toInt(ptr, &typeOk); + typeName = "integer"; + } + if ( typeOk ) // check some specific values ? + { + } + if ( !typeOk ) + { + std::string msg = "Advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName; + throw std::invalid_argument(msg); + } + std::string value( ptr, i ); + if ( _defaultOptionValues[ optionName ] == value ) + value.clear(); + + + op_val->second = value; + + } +} +//============================================================================= +//! Return option value. If isDefault provided, it can be a default value, +// then *isDefault == true. If isDefault is not provided, the value will be +// empty if it equals a default one. +std::string MgAdapt::getOptionValue(const std::string& optionName, bool* isDefault) const +throw (std::invalid_argument) +{ + TOptionValues::const_iterator op_val = _option2value.find(optionName); + if (op_val == _option2value.end()) + { + op_val = _customOption2value.find(optionName); + if (op_val == _customOption2value.end()) + { + std::string msg = "Unknown MG-Adapt option: <" + optionName + ">"; + throw std::invalid_argument(msg); + } + } + std::string val = op_val->second; + if ( isDefault ) *isDefault = ( val.empty() ); + + if ( val.empty() && isDefault ) + { + op_val = _defaultOptionValues.find( optionName ); + if (op_val != _defaultOptionValues.end()) + val = op_val->second; + } + return val; +} +//================================================================================ +/*! + * \brief Converts a string to a real value + */ +//================================================================================ + +double MgAdapt::toDbl(const std::string& str, bool* isOk ) +throw (std::invalid_argument) +{ + if ( str.empty() ) throw std::invalid_argument("Empty value provided"); + + char * endPtr; + double val = strtod(&str[0], &endPtr); + bool ok = (&str[0] != endPtr); + + if ( isOk ) *isOk = ok; + + if ( !ok ) + { + std::string msg = "Not a real value:'" + str + "'"; + throw std::invalid_argument(msg); + } + return val; +} +//================================================================================ +/*! + * \brief Converts a string to a lower + */ +//================================================================================ +std::string MgAdapt::toLowerStr(const std::string& str) +{ + std::string s = str; + for ( size_t i = 0; i <= s.size(); ++i ) + s[i] = tolower( s[i] ); + return s; +} +//================================================================================ +/*! + * \brief Converts a string to a bool + */ +//================================================================================ + +bool MgAdapt::toBool(const std::string& str, bool* isOk ) +throw (std::invalid_argument) +{ + std::string s = str; + if ( isOk ) *isOk = true; + + for ( size_t i = 0; i <= s.size(); ++i ) + s[i] = tolower( s[i] ); + + if ( s == "1" || s == "true" || s == "active" || s == "yes" ) + return true; + + if ( s == "0" || s == "false" || s == "inactive" || s == "no" ) + return false; + + if ( isOk ) + *isOk = false; + else { + std::string msg = "Not a Boolean value:'" + str + "'"; + throw std::invalid_argument(msg); + } + return false; +} +//================================================================================ +/*! + * \brief Converts a string to a integer value + */ +//================================================================================ + +int MgAdapt::toInt(const std::string& str, bool* isOk ) +throw (std::invalid_argument) +{ + if ( str.empty() ) throw std::invalid_argument("Empty value provided"); + + char * endPtr; + int val = (int)strtol( &str[0], &endPtr, 10); + bool ok = (&str[0] != endPtr); + + if ( isOk ) *isOk = ok; + + if ( !ok ) + { + std::string msg = "Not an integer value:'" + str + "'"; + throw std::invalid_argument(msg); + } + return val; +} +//============================================================================= +bool MgAdapt::hasOptionDefined( const std::string& optionName ) const +{ + bool isDefault = false; + try + { + getOptionValue( optionName, &isDefault ); + } + catch ( std::invalid_argument ) + { + return false; + } + return !isDefault; +} +//================================================================================ +/*! + * \brief Return command to run MG-Tetra mesher excluding file prefix (-f) + */ +//================================================================================ + +std::string MgAdapt::getCommandToRun(MgAdapt* hyp) +{ + return hyp ? hyp->getCommandToRun() : ToComment("error with hypothesis!"); +} + + + +int MgAdapt::compute(std::string& errStr) +{ + std::string cmd = getCommandToRun(); + int err = 0; + execCmd( cmd.c_str(), err ); // run + + if ( err ) + { + errStr = ToComment("system(mg-adapt.exe ...) command failed with error: ") + << strerror( errno ); + } + else + { + convertMeshFile(meshFormatOutputMesh, solFormatOutput); + } + if (!err) cleanUp(); + return err; +} + +void MgAdapt::execCmd( const char* cmd, int& err) +{ + err = 1; + std::array buffer; + std::streambuf* buf; + outFileStream fileStream; + if (printLogInFile) + { + fileStream.open(logFile); + buf = fileStream.rdbuf(); + } + else + { + buf = std::cout.rdbuf(); + } + std::ostream logStream(buf); + + std::unique_ptr pipe(popen(cmd, "r"), pclose ); + if(!pipe) + { + throw std::runtime_error("popen() failed!"); + } + while(fgets(buffer.data(), buffer.size(), pipe.get()) !=nullptr ) + { + logStream<::iterator it = tmpFilesToBeDeleted.begin(); + for (; it!=tmpFilesToBeDeleted.end(); ++it) + { + errStr=removeFile(*it, notOk); + if (notOk) + { + appendMsgToLogFile(errStr); + } + + } +} + +void MgAdapt::appendMsgToLogFile(std::string& msg) +{ + std::ofstream logStream; + logStream.open(logFile, std::ofstream::out | std::ofstream::app); + logStream<< msg; + logStream.close(); +} +//================================================================================ +/*! + * \brief Return command to run MG-Tetra mesher excluding file prefix (-f) + */ +//================================================================================ + +std::string MgAdapt::getCommandToRun() +{ + /* + || return system command with args and options + || + */ + std::string errStr; + std::string cmd = getExeName(); + std::string meshIn(""), sizeMapIn(""), solFileIn(""); + updateTimeStepRank(); + convertMedFile(meshIn, solFileIn, sizeMapIn); + if (!isFileExist(meshIn) || !isFileExist(solFileIn)) + { + errStr = ToComment(" failed to find .mesh or .sol file from converter ")<< strerror( errno ); + return errStr; + } + tmpFilesToBeDeleted.push_back(meshIn); + tmpFilesToBeDeleted.push_back(solFileIn); + if(useBackgroundMap && !isFileExist(sizeMapIn)) + { + + errStr = ToComment(" failed to find .mesh size map file from converter ")<< strerror( errno ); + return errStr; + + } + + + cmd+= " --in "+ meshIn; + meshFormatOutputMesh = getFileName()+".mesh"; + tmpFilesToBeDeleted.push_back(meshFormatOutputMesh); + cmd+= " --out "+ meshFormatOutputMesh; + if (useLocalMap || useConstantValue) cmd+= " --sizemap "+ solFileIn; + else // (useBackgroundMap) + { + cmd+= " --background_mesh "+ sizeMapIn ; + cmd+= " --background_sizemap "+ solFileIn; + tmpFilesToBeDeleted.push_back(sizeMapIn); + } + //~else + //~{ + //~// constant value TODO + //~} + /* sizemap file is not adapted in case of only surface adaptation see MeshGems docs */ + std::string adapOp = "adaptation"; + std::string adpOpVal = getOptionValue(adapOp); + std::string surfaceAdapt = "surface"; + if(surfaceAdapt != adpOpVal ) + { + std::string solFileOut = getFileName()+".sol"; + cmd+= " --write_sizemap "+ solFileOut; + solFormatOutput.push_back(solFileOut); + tmpFilesToBeDeleted.push_back(solFileOut); + } + if (verbosityLevel != defaultVerboseLevel()) + { + + cmd+= " --verbose "+ ToComment(verbosityLevel); + } + + std::string option, value; + bool isDefault; + const TOptionValues* options[] = { &_option2value, &_customOption2value }; + for ( int iOp = 0; iOp < 2; ++iOp ) + { + TOptionValues::const_iterator o2v = options[iOp]->begin(); + for ( ; o2v != options[iOp]->end(); ++o2v ) + { + option = o2v->first; + value = getOptionValue( option, &isDefault ); + + if ( isDefault ) + continue; + if ( value.empty() )//value == NoValue() ) + { + if ( _defaultOptionValues.count( option )) + continue; // non-custom option with no value + //value.clear(); + } + if ( strncmp( "no", option.c_str(), 2 ) == 0 ) // options w/o values: --no_* + { + if ( !value.empty() && toBool( value ) == false ) + continue; + value.clear(); + } + if ( option[0] != '-' ) + cmd += " --"; + else + cmd += " "; + cmd += option + " " + value; + } + } + //~} +//~cmd+= " >" +#ifdef WIN32 + cmd += " < NUL"; +#endif + + return cmd; +} + + +bool MgAdapt::isFileExist(const std::string& fName) +{ + + if ( fName.empty() ) + return false; + + boost::system::error_code err; + bool res = boost::filesystem::exists( fName, err ); + + return err ? false : res; +} +//======================================================================= +//function : defaultMaximumMemory +//======================================================================= + +#if defined(WIN32) +#include +#elif !defined(__APPLE__) +#include +#endif + +double MgAdapt::defaultMaximumMemory() +{ +#if defined(WIN32) + // See http://msdn.microsoft.com/en-us/library/aa366589.aspx + MEMORYSTATUSEX statex; + statex.dwLength = sizeof (statex); + long err = GlobalMemoryStatusEx (&statex); + if (err != 0) { + double totMB = (double)statex.ullAvailPhys / 1024. / 1024.; + return (double)( 0.7 * totMB ); + } +#elif !defined(__APPLE__) + struct sysinfo si; + long err = sysinfo( &si ); + if ( err == 0 ) { + long ramMB = si.totalram * si.mem_unit / 1024 / 1024; + return ( 0.7 * ramMB ); + } +#endif + return 1024; +} + + +//======================================================================= +//function : defaultWorkingDirectory +//======================================================================= + +std::string MgAdapt::defaultWorkingDirectory() +{ + TCollection_AsciiString aTmpDir; + + char *Tmp_dir = getenv("SALOME_TMP_DIR"); + if(Tmp_dir != NULL) { + aTmpDir = Tmp_dir; + } + else { +#ifdef WIN32 + aTmpDir = TCollection_AsciiString("C:\\"); +#else + aTmpDir = TCollection_AsciiString("/tmp/"); +#endif + } + return aTmpDir.ToCString(); +} +//================================================================================ +/*! + * \brief Return a unique file name + */ +//================================================================================ + +std::string MgAdapt::getFileName() const +{ + std::string aTmpDir = workingDir; + const char lastChar = *aTmpDir.rbegin(); +#ifdef WIN32 + if(lastChar != '\\') aTmpDir+='\\'; +#else + if(lastChar != '/') aTmpDir+='/'; +#endif + + TCollection_AsciiString aGenericName = (char*)aTmpDir.c_str(); + aGenericName += "MgAdapt_"; + aGenericName += getpid(); + aGenericName += "_"; + aGenericName += Abs((Standard_Integer)(long) aGenericName.ToCString()); + + return aGenericName.ToCString(); +} +//======================================================================= +//function : defaultLogFile +//======================================================================= + +std::string MgAdapt::defaultLogFile() +{ + std::string alogFile("MG_ADAPT.log"); + return alogFile; +} +//======================================================================= +//function : defaultUseConstantValue +//======================================================================= + +bool MgAdapt::defaultUseConstantValue() +{ + return false; +} +//======================================================================= +//function : defaultUseNoTimeStep +//======================================================================= + +bool MgAdapt::defaultUseNoTimeStep() +{ + return true; +} +//======================================================================= +//function : defaultRemoveLogOnSuccess +//======================================================================= + +bool MgAdapt::defaultRemoveLogOnSuccess() +{ + return true; +} +//======================================================================= +//function : defaultPrintLogInFile +//======================================================================= + +bool MgAdapt::defaultPrintLogInFile() +{ + return false; +} +//======================================================================= +//function : defaultUseChosenTimeStep +//======================================================================= + +bool MgAdapt::defaultUseChosenTimeStep() +{ + return false; +} +//======================================================================= +//function : UseLastTimeStep +//======================================================================= + +bool MgAdapt::defaultUseLastTimeStep() +{ + return false; +} +//======================================================================= +//function : defaultUseBackgroundMap +//======================================================================= + +bool MgAdapt::defaultUseBackgroundMap() +{ + return false; +} +//======================================================================= +//function : defaultKeepFiles +//======================================================================= + +bool MgAdapt::defaultKeepFiles() +{ + return false; +} +//======================================================================= +//function : defaultUseLocalMap +//======================================================================= + +bool MgAdapt::defaultUseLocalMap() +{ + return true; +} +//======================================================================= +//function : defaultPublish +//======================================================================= + +bool MgAdapt::defaultPublish() +{ + return false; +} +//======================================================================= +//function : defaultMeshOutMed +//======================================================================= + +bool MgAdapt::defaultMeshOutMed() +{ + return true; +} +//======================================================================= +//function : defaultFromMedFile +//======================================================================= + +bool MgAdapt::defaultFromMedFile() +{ + return true; +} +//======================================================================= +//function : defaultVerboseLevel +//======================================================================= + +int MgAdapt::defaultVerboseLevel() +{ + return 3; +} +std::string MgAdapt::getExeName() +{ + return "mg-adapt.exe"; +} +void MgAdapt::copyMgAdaptHypothesisData( const MgAdaptHypothesisData* from) +{ + + data->myFileInDir = from->myFileInDir; + data->myMeshFileIn = from->myMeshFileIn; + data->myMeshFileBackground = from->myMeshFileBackground; + data->myOutMeshName = from->myOutMeshName; + data->myMeshFileOut = from->myMeshFileOut; + data->myFileOutDir = from->myFileOutDir; + data->myFileSizeMapDir = from->myFileSizeMapDir; + data->myFieldName = from->myFieldName; + data->fromMedFile = from->fromMedFile; + data->myPublish = from->myPublish; + data->myMeshOutMed = from->myMeshOutMed; + data->myUseLocalMap = from->myUseLocalMap; + data->myUseBackgroundMap = from->myUseBackgroundMap; + data->myUseConstantValue = from->myUseConstantValue; + data->myConstantValue = from->myConstantValue; + data->myTimeStep = from->myTimeStep; + data->myRank = from->myRank; + data->myUseNoTimeStep = from->myUseNoTimeStep; + data->myUseLastTimeStep = from->myUseLastTimeStep; + data->myUseChosenTimeStep = from->myUseChosenTimeStep; + data->myWorkingDir = from->myWorkingDir; + data->myLogFile = from->myLogFile; + data->myPrintLogInFile = from->myPrintLogInFile; + data->myKeepFiles = from->myKeepFiles; + data->myRemoveLogOnSuccess = from->myRemoveLogOnSuccess; + data->myVerboseLevel = from->myVerboseLevel; + +} + + +void MgAdapt::convertMedFile(std::string& meshFormatMeshFileName, std::string& solFormatFieldFileName, std::string& meshFormatsizeMapFile) +{ + + std::vector fieldFileNames; + MEDCoupling::MeshFormatWriter writer; + MEDCoupling::MCAuto mfd = MEDCoupling::MEDFileData::New(medFileIn); + MEDCoupling::MEDFileMeshes* meshes = mfd->getMeshes(); + MEDCoupling::MEDFileMesh* fileMesh = meshes->getMeshAtPos(0); // ok only one mesh in file! + if (meshNameOut =="") + meshNameOut = fileMesh->getName(); + storeGroupsAndFams(fileMesh); + + MEDCoupling::MCAuto fields = MEDCoupling::MEDFileFields::New(); + solFormatFieldFileName = getFileName(); + solFormatFieldFileName+=".sol"; + fieldFileNames.push_back(solFormatFieldFileName); + + if (useBackgroundMap) + { + + meshFormatsizeMapFile = getFileName(); + meshFormatsizeMapFile += ".mesh"; + buildBackGroundMeshAndSolFiles(fieldFileNames, meshFormatsizeMapFile); + + } + else if(useLocalMap) + { + + MEDCoupling::MCAuto fts = dynamic_cast( mfd->getFields()->getFieldWithName(fieldName) ); + MEDCoupling::MCAuto f = fts->getTimeStep(timeStep, rank); + MEDCoupling::MCAuto tmFts = MEDCoupling::MEDFileFieldMultiTS::New(); + tmFts->pushBackTimeStep(f); + + fields->pushField(tmFts); + + writer.setFieldFileNames( fieldFileNames); + } + + else + { + MEDCoupling::MCAuto mesh = fileMesh->getMeshAtLevel(1); // nodes mesh + MEDCoupling::MCAuto umesh = mesh->buildUnstructured(); // nodes mesh + int dim = umesh->getSpaceDimension(); + int version = sizeof(double) < 8 ? 1 : 2; + mcIdType nbNodes = umesh->getNumberOfNodes(); + buildConstantSizeMapSolFile(solFormatFieldFileName, dim, version, nbNodes); + + } + + mfd->setFields( fields ); + meshFormatMeshFileName = getFileName(); + meshFormatMeshFileName+=".mesh"; + writer.setMeshFileName(meshFormatMeshFileName); + writer.setMEDFileDS( mfd); + writer.write(); + +} + +void MgAdapt::convertMeshFile(std::string& meshFormatIn, std::vector< std::string>& solFieldFileNames) const +{ + MEDCoupling::MeshFormatReader reader(meshFormatIn, solFieldFileNames); + + MEDCoupling::MCAuto mfd = reader.loadInMedFileDS(); + // write MED + MEDCoupling::MEDFileMeshes* meshes = mfd->getMeshes(); + MEDCoupling::MEDFileMesh* fileMesh = meshes->getMeshAtPos(0); // ok only one mesh in file! + fileMesh->setName(meshNameOut); + restoreGroupsAndFams(fileMesh); + mfd->write(medFileOut, 2); +} + + +void MgAdapt::storeGroupsAndFams(MEDCoupling::MEDFileMesh* fileMesh) +{ + storefams(fileMesh); + storeGroups(fileMesh); +} + +void MgAdapt::restoreGroupsAndFams(MEDCoupling::MEDFileMesh* fileMesh) const +{ + restorefams(fileMesh); + restoreGroups(fileMesh); +} +void MgAdapt::storeGroups(MEDCoupling::MEDFileMesh* fileMesh) +{ + std::map > grpFams = fileMesh->getGroupInfo(); + std::map >::iterator g2ff = grpFams.begin(); + + for ( ; g2ff != grpFams.end(); ++g2ff ) + { + std::string groupName = g2ff->first; + std::vector famNames = g2ff->second; + + if ( famNames.empty() ) continue; + std::size_t k = 0; + std::vector< mcIdType> famListId; + for ( size_t i = 0; i < famNames.size(); ++i ) + { + famListId.push_back( fileMesh->getFamilyId( famNames[i].c_str() ) ); + } + group grp(groupName, famListId, famNames); + groupVec.push_back(grp); + } +} + +void MgAdapt::storefams(MEDCoupling::MEDFileMesh* fileMesh) +{ + std::map grpFams = fileMesh->getFamilyInfo(); + std::map::iterator f = grpFams.begin(); + + for ( ; f != grpFams.end(); ++f ) + { + if(!f->second) continue; // FAMILLE_ZERO + family fs(f->first, f->second); + famVec.push_back(fs); + } + +} + +void MgAdapt::restorefams(MEDCoupling::MEDFileMesh* fileMesh) const +{ + std::vector::const_iterator fIt = famVec.begin(); + + for (; fIt!=famVec.end(); ++fIt) + { + try // + { + std::string givenFamNameFromMeshGemConverter = fileMesh->getFamilyNameGivenId( std::abs(fIt->_famId) ); + fileMesh->changeFamilyId(std::abs(fIt->_famId), fIt->_famId); + fileMesh->changeFamilyName(givenFamNameFromMeshGemConverter, fIt->_famName); + } + catch (const std::exception& e) + { + std::cerr< > info; + std::vector ::const_iterator grpFams = groupVec.begin(); + + for (; grpFams!=groupVec.end(); ++grpFams) + { + info.insert(std::pair > (grpFams->_name, grpFams->_famNames) ); + } + + fileMesh->setGroupInfo(info); +} + +void MgAdapt::buildConstantSizeMapSolFile(const std::string& solFormatFieldFileName, const int dim, const int version, const mcIdType nbNodes) const +{ + MeshFormat::Localizer loc; + MeshFormat::MeshFormatParser writer; + int fileId = writer.GmfOpenMesh( solFormatFieldFileName.c_str(), GmfWrite, version, dim); + int typTab[] = {GmfSca}; + writer.GmfSetKwd(fileId, MeshFormat::GmfSolAtVertices, (int)nbNodes, 1, typTab); + for (mcIdType i = 0; i& fieldFileNames, const std::string& meshFormatsizeMapFile) const +{ + MEDCoupling::MCAuto tmpMfd = MEDCoupling::MEDFileData::New(sizeMapFile); + MEDCoupling::MEDFileFields* tmpFields = tmpMfd->getFields(); + MEDCoupling::MEDFileAnyTypeFieldMultiTS* fts = tmpFields->getFieldWithName(fieldName); + MEDCoupling::MCAuto fts1 = dynamic_cast(fts); + MEDCoupling::MCAuto f = fts1->getTimeStep(timeStep, rank); + MEDCoupling::MCAuto tmFts = MEDCoupling::MEDFileFieldMultiTS::New(); + tmFts->pushBackTimeStep(f); + + MEDCoupling::MCAuto tmp_fields = MEDCoupling::MEDFileFields::New(); + tmp_fields->pushField(tmFts); + + + tmpMfd->setFields( tmp_fields ); + MEDCoupling::MeshFormatWriter tmpWriter; + tmpWriter.setMeshFileName(meshFormatsizeMapFile); + tmpWriter.setFieldFileNames( fieldFileNames); + tmpWriter.setMEDFileDS(tmpMfd); + tmpWriter.write(); +} +// ======================================================================= +med_idt MgAdapt::openMedFile(const std::string aFile) +// ======================================================================= +// renvoie le medId associe au fichier Med apres ouverture +{ + med_idt medIdt = MEDfileOpen(aFile.c_str(),MED_ACC_RDONLY); + if (medIdt <0) + { + //~addMessage( ToComment(" error: Can't open ") << aFile, /*fatal=*/true ); + ; + } + return medIdt; +} + +MgAdapt::Status MgAdapt::addMessage(const std::string& msg, + const bool isFatal/*=false*/) +{ + if ( isFatal ) + _myErrorMessages.clear(); // warnings are useless if a fatal error encounters + + _myErrorMessages.push_back( msg ); + + //~MESSAGE(msg); +#ifdef _DEBUG_ + std::cout << msg << std::endl; +#endif + return ( _myStatus = isFatal ? MgAdapt::DRS_FAIL : MgAdapt::DRS_WARN_SKIP_ELEM ); +} + + + + +// ======================================================================= +void MgAdapt::getTimeStepInfos(std::string aFile, med_int& numdt, med_int& numit) +// ======================================================================= +{ +// Il faut voir si plusieurs maillages + + + herr_t erreur = 0 ; + med_idt medIdt ; + + + // Ouverture du fichier + //~SCRUTE(aFile.toStdString()); + medIdt = openMedFile(aFile); + if ( medIdt < 0 ) return ; + // Lecture du nombre de champs + med_int ncha = MEDnField(medIdt) ; + if (ncha < 1 ) + { + //~addMessage( ToComment(" error: there is no field in ") << aFile, /*fatal=*/true ); + return; + } + // Lecture des caracteristiques du champs + + // Lecture du type du champ, des noms des composantes et du nom de l'unite + char nomcha [MED_NAME_SIZE+1]; + strcpy(nomcha, fieldName.c_str()); +// Lecture du nombre de composantes + med_int ncomp = MEDfieldnComponentByName(medIdt, nomcha); + char meshname[MED_NAME_SIZE+1]; + char * comp = (char*) malloc(ncomp*MED_SNAME_SIZE+1); + char * unit = (char*) malloc(ncomp*MED_SNAME_SIZE+1); + char dtunit[MED_SNAME_SIZE+1]; + med_bool local; + med_field_type typcha; + med_int nbofcstp; + erreur = MEDfieldInfoByName (medIdt, nomcha, meshname,&local,&typcha,comp,unit,dtunit, &nbofcstp); + free(comp); + free(unit); + if ( erreur < 0 ) + { + //~addMessage( ToComment(" error: error while reading field ") << nomcha << " in file " << aFile , /*fatal=*/true ); + return; + } + + med_float dt; + med_int tmp_numdt, tmp_numit; + + //~med_int step = data->myUseLastTimeStep ? nbofcstp : data->myTimeStep+1; + //~myPrint("step ", step); + erreur = MEDfieldComputingStepInfo ( medIdt, nomcha, 1, &numdt, &numit, &dt ); + for(med_int step = 1; step <= nbofcstp; step++ ) + { + erreur = MEDfieldComputingStepInfo ( medIdt, nomcha, step, &tmp_numdt, &tmp_numit, &dt ); + if(tmp_numdt > numdt) + { + numdt = tmp_numdt; + numit = tmp_numit; + } + } + if ( erreur < 0 ) + { + + //~addMessage( ToComment(" error: error while reading field ") << nomcha << "step (numdt, numit) = " <<"("<< numdt<< ", " \ + numit<< ")" <<" in file " << aFile , /*fatal=*/true ); + return; + } + + + + // Fermeture du fichier + if ( medIdt > 0 ) MEDfileClose(medIdt); + + +} + +void MgAdapt::updateTimeStepRank() +{ + + med_int arank; + med_int tmst; + if (myUseNoTimeStep) + { + arank = MED_NO_IT; + tmst = MED_NO_DT ; + setRankTimeStep((int)tmst, (int)arank); + } + else if (myUseLastTimeStep) + { + std::string fieldFile = useBackgroundMap ? sizeMapFile : medFileIn; + getTimeStepInfos(fieldFile, tmst, arank); + setRankTimeStep((int)tmst, (int)arank); + } +} diff --git a/src/SMESH/MG_ADAPT.hxx b/src/SMESH/MG_ADAPT.hxx new file mode 100644 index 000000000..c97ad15d3 --- /dev/null +++ b/src/SMESH/MG_ADAPT.hxx @@ -0,0 +1,341 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ +// +// File : MG_ADAPT.hxx +// +#ifndef MG_ADAPT_HXX +#define MG_ADAPT_HXX +#include +# include +#include +#include +#include +#include + +#include "MCAuto.hxx" +#include "MCType.hxx" +#include "MEDFileMesh.hxx" + +#include +// SMESH includes + +//~#include +std::string remove_extension(const std::string& filename); +namespace MG_ADAPT{ +class MgAdapt; + +typedef std::map< std::string, std::string > TOptionValues; +typedef std::set< std::string > TOptionNames; + +struct MgAdaptHypothesisData +{ + std::string myFileInDir, myMeshFileIn, myInMeshName, myMeshFileBackground, myOutMeshName, + myMeshFileOut, myFileOutDir, myFileSizeMapDir, myFieldName; + bool fromMedFile; + bool myPublish, myMeshOutMed; + bool myUseLocalMap, myUseBackgroundMap, myUseConstantValue; + double myConstantValue; + int myRank, myTimeStep; + bool myUseNoTimeStep, myUseLastTimeStep, myUseChosenTimeStep; + std::string myWorkingDir, myLogFile; + bool myPrintLogInFile, myKeepFiles, myRemoveLogOnSuccess; + int myVerboseLevel; + +}; + +class outFileStream : public std::ofstream{ +public: + ~outFileStream(){close();} //to close file at dtor +}; + +/*! + * \brief Class to generate string from any type + */ +class ToComment : public std::string +{ + std::ostringstream _s ; + +public : + + ToComment():std::string("") {} + + ToComment(const ToComment& c):std::string() { + _s << c.c_str() ; + this->std::string::operator=( _s.str() ); + } + + ToComment & operator=(const ToComment& c) { + _s << c.c_str() ; + this->std::string::operator=( _s.str() ); + return *this; + } + + template + ToComment( const T &anything ) { + _s << anything ; + this->std::string::operator=( _s.str() ); + } + + template + ToComment & operator<<( const T &anything ) { + _s << anything ; + this->std::string::operator=( _s.str() ); + return *this ; + } + + operator char*() const { + return (char*)c_str(); + } + + std::ostream& Stream() { + return _s; + } +}; + + +class MgAdapt +{ + +public: + + MgAdapt(); + MgAdapt(MgAdaptHypothesisData*); + MgAdapt(const MgAdapt&); + ~MgAdapt(); + void buildModel(); + void setData( MgAdaptHypothesisData* data); + + void setMedFileIn(std::string fileName); + std::string getMedFileIn(); + + void setMedFileOut(std::string fileOut); + std::string getMedFileOut(); + + void setMeshName(std::string name); + std::string getMeshName(); + + void setMeshNameOut(std::string name); + std::string getMeshNameOut(); + + void setMeshOutMed(bool mybool); + bool getMeshOutMed(); + + void setPublish(bool mybool); + bool getPublish(); + + void setFieldName(std::string myFieldName); + std::string getFieldName(); + + void setTimeStep(int time); + int getTimeStep() const; + + void setRankTimeStep(int time, int myRank); + int getRank(); + + void setTimeStepRankLast(); + void setNoTimeStep(); + void setChosenTimeStepRank(); + void updateTimeStepRank(); + + void setLogFile(std::string); + std::string getLogFile(); + + void setVerbosityLevel(int verbosity); + int getVerbosityLevel(); + + void setRemoveOnSuccess(bool mybool); + bool getRemoveOnSuccess(); + + MgAdaptHypothesisData* getData() const; + + void setUseLocalMap(bool mybool); + bool getUseLocalMap(); + + void setUseBackgroundMap(bool mybool); + bool getUseBackgroundMap(); + + void setUseConstantValue(bool mybool); + bool getUseConstantValue(); + + void setConstantValue(double cnst); + double getConstantValue() const; + + void setSizeMapFile(std::string mapFile); + std::string getSizeMapFile(); + + void setFromMedFile(bool mybool); + bool isFromMedFile(); + + void setKeepWorkingFiles(bool mybool); + bool getKeepWorkingFiles(); + + void setPrintLogInFile(bool mybool); + bool getPrintLogInFile(); + + void setWorkingDir(std::string dir); + std::string getWorkingDir() const; + + + bool setAll(); + static std::string getCommandToRun(MgAdapt* ); + std::string getCommandToRun() ; + int compute(std::string& errStr); + std::string getFileName() const; + static std::string getExeName(); + void copyMgAdaptHypothesisData( const MgAdaptHypothesisData* from) ; + + void checkDirPath(std::string& dirPath); + + bool hasOptionDefined( const std::string& optionName ) const; + void setOptionValue(const std::string& optionName, + const std::string& optionValue) throw (std::invalid_argument); + std::string getOptionValue(const std::string& optionName, + bool* isDefault=0) const throw (std::invalid_argument); + std::vector getCustomOptionValuesStrVec() const; + std::vector getOptionValuesStrVec() const; + + + TOptionValues getOptionValues() const; + const TOptionValues& getCustomOptionValues() const ; + static double toDbl(const std::string&, bool* isOk = 0) throw (std::invalid_argument); + static bool toBool(const std::string&, bool* isOk = 0) throw (std::invalid_argument); + static int toInt(const std::string&, bool* isOk = 0 ) throw (std::invalid_argument); + static std::string toLowerStr(const std::string& str); + + + /* default values */ + static std::string defaultWorkingDirectory(); + static std::string defaultLogFile(); + static bool defaultKeepFiles(); + static bool defaultRemoveLogOnSuccess(); + static int defaultVerboseLevel(); + static bool defaultPrintLogInFile(); + static bool defaultFromMedFile(); + static bool defaultMeshOutMed(); + static bool defaultPublish(); + static bool defaultUseLocalMap(); + static bool defaultUseBackgroundMap(); + static bool defaultUseConstantValue(); + static bool defaultUseNoTimeStep(); + static bool defaultUseLastTimeStep(); + static bool defaultUseChosenTimeStep(); + static double defaultMaximumMemory(); + static bool isFileExist(const std::string& fName); + + + + + enum Status { + DRS_OK, + DRS_EMPTY, // a file contains no mesh with the given name + DRS_WARN_RENUMBER, // a file has overlapped ranges of element numbers, + // so the numbers from the file are ignored + DRS_WARN_SKIP_ELEM, // some elements were skipped due to incorrect file data + DRS_WARN_DESCENDING, // some elements were skipped due to descending connectivity + DRS_FAIL, // general failure (exception etc.) + DRS_NO_TIME_STEP // general failure (exception etc.) + }; + + struct group { + + std::string _name; + std::vector _famListId; + std::vector _famNames; + group(std::string name, std::vector famListId, std::vector famNames):_name(name) + { + std::vector::iterator it = famListId.begin(); + for (; it!=famListId.end(); ++it) + _famListId.push_back(*it); + + std::vector::iterator itt = famNames.begin(); + for (; itt!=famNames.end(); ++itt) + _famNames.push_back(*itt); + } + }; + + struct family { + std::string _famName; + mcIdType _famId; + family(std::string famName, MEDCoupling::mcIdType famId):_famName(famName), _famId(famId) {} + }; + + +private : + bool fromMedFile; + + std::string medFileIn; + std::string medFileOut; + std::string meshName; + std::string meshNameOut; + bool publish, meshOutMed; + bool useLocalMap, useBackgroundMap, useConstantValue; + bool myUseLastTimeStep, myUseNoTimeStep, myUseChosenTimeStep; + std::string sizeMapFile; + std::string fieldName; + double constantValue; + int rank, timeStep; + + /* advanced options */ + + + std::string logFile; + std::string workingDir; + int verbosityLevel; + bool removeOnSuccess; + bool toKeepWorkingFiles; + bool printLogInFile; + + /* Model DATA */ + MgAdaptHypothesisData* data; + + /* */ + + TOptionValues _option2value, _customOption2value; // user defined values + TOptionValues _defaultOptionValues; // default values + TOptionNames _doubleOptions, _charOptions, _boolOptions; // to find a type of option + + std::vector _myErrorMessages; + Status _myStatus; + std::string meshFormatOutputMesh; + std::vector< std::string> solFormatOutput; + std::vector groupVec; + std::vector famVec; + std::vector< std::string> tmpFilesToBeDeleted; + + /* convert MED-->.mesh format */ + void convertMedFile(std::string& meshIn,std::string& solFileIn, std::string& sizeMapIn) ; + void storeGroups(MEDCoupling::MEDFileMesh* fileMesh); + void restoreGroups(MEDCoupling::MEDFileMesh* fileMesh) const; + void storefams(MEDCoupling::MEDFileMesh* fileMesh); + void restorefams(MEDCoupling::MEDFileMesh* fileMesh) const; + void storeGroupsAndFams(MEDCoupling::MEDFileMesh* fileMesh); + void restoreGroupsAndFams(MEDCoupling::MEDFileMesh* fileMesh) const; + void convertMeshFile(std::string& meshFormatIn, std::vector< std::string>& solFieldFileNames) const ; + void buildConstantSizeMapSolFile(const std::string& solFormatFieldFileName, const int dim, const int version, const mcIdType nbNodes) const; + void buildBackGroundMeshAndSolFiles(const std::vector& fieldFileNames, const std::string& meshFormatsizeMapFile) const; + void getTimeStepInfos(std::string aFile, med_int& numdt, med_int& numit); + Status addMessage(const std::string& msg, const bool isFatal = false); + med_idt openMedFile(const std::string aFile) ; + void execCmd( const char* cmd, int& err); + void cleanUp(); + void appendMsgToLogFile(std::string& msg); +}; + +} + +#endif // MG_ADAPT_HXX diff --git a/src/SMESHGUI/CMakeLists.txt b/src/SMESHGUI/CMakeLists.txt index 5bd61d945..f4fa5526d 100644 --- a/src/SMESHGUI/CMakeLists.txt +++ b/src/SMESHGUI/CMakeLists.txt @@ -42,8 +42,14 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/Controls ${PROJECT_SOURCE_DIR}/src/SMESHClient ${PROJECT_SOURCE_DIR}/src/MEDWrapper + ${PROJECT_SOURCE_DIR}/src/ADAPT + ${PROJECT_SOURCE_DIR}/src/ADAPT_I + ${PROJECT_SOURCE_DIR}/src/ADAPTGUI ${PROJECT_BINARY_DIR} ${PROJECT_BINARY_DIR}/idl + ${PROJECT_BINARY_DIR}/src/ADAPTGUI + ${PROJECT_BINARY_DIR}/src/ADAPT_I + ${MEDCOUPLING_INCLUDE_DIRS} ) # additional preprocessor / compiler flags @@ -73,6 +79,10 @@ SET(_link_LIBRARIES SMDS SMESHControls SMESHObject + ADAPTGUI + ADAPTImpl + ADAPTEngine + ${MEDCoupling_medloader} ) # --- headers --- @@ -145,6 +155,9 @@ SET(_moc_HEADERS SMESHGUI_SplitBiQuad.h SMESHGUI_IdPreview.h SMESHGUI_PreVisualObj.h + SMESHGUI_AdaptDlg.h + SMESHGUI_MG_ADAPTDRIVER.h + MG_ADAPTGUI.hxx # to replace in ../ADAPTGUI/ ) # header files / no moc processing @@ -167,6 +180,7 @@ SET(_other_HEADERS SMESHGUI_FileValidator.h SMESHGUI_SelectionProxy.h SMESH_SMESHGUI.hxx + #~MG_ADAPT.hxx # to replace in ../ADAPT/ ) # header files / to install @@ -260,6 +274,10 @@ SET(_other_SOURCES SMESHGUI_SplitBiQuad.cxx SMESHGUI_PreVisualObj.cxx SMESHGUI_IdPreview.cxx + SMESHGUI_AdaptDlg.cxx + SMESHGUI_MG_ADAPTDRIVER.cxx + MG_ADAPTGUI.cxx # to replace in ../ADAPTGUI/ + #MG_ADAPT.cxx ) # sources / to compile @@ -273,7 +291,7 @@ SET(_ts_RESOURCES SMESH_msg_en.ts SMESH_msg_fr.ts SMESH_msg_ja.ts -) +) # --- rules --- diff --git a/src/SMESHGUI/MG_ADAPTGUI.cxx b/src/SMESHGUI/MG_ADAPTGUI.cxx new file mode 100644 index 000000000..dcca5a7a6 --- /dev/null +++ b/src/SMESHGUI/MG_ADAPTGUI.cxx @@ -0,0 +1,1456 @@ +// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// file : MG_ADAPTGUI.cxx + +#include "MG_ADAPTGUI.hxx" + +#include "SUIT_Desktop.h" +#include "SUIT_Application.h" +#include "SUIT_Session.h" + +#include "SalomeApp_Application.h" +#include "SalomeApp_Module.h" +#include "SalomeApp_Study.h" +//~#include "SMESH_Actor.h" +#include +//~#include +//~#include +//~#include +//~#include +//~#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +// SALOME KERNEL includes +#include +#include +#include +#include +#include "SalomeApp_Tools.h" +#include +#include +#include + +#include + + +const int SPACING = 6; // layout spacing +const int MARGIN = 9; // layout margin + +//================================================================================= +// function : SMESHGUI_MgAdaptDlg() +// purpose : +//================================================================================= +SMESHGUI_MgAdaptDlg::SMESHGUI_MgAdaptDlg( SalomeApp_Module* theModule, SMESH::MG_ADAPT_ptr myModel, QWidget* parent, bool isCreation ) + : mySMESHGUI( theModule ), QDialog(parent) +{ + //~model = new MgAdapt(*myModel); + model = SMESH::MG_ADAPT::_duplicate(myModel); + myData = model->getData(); + buildDlg(); + if (!isCreation) readParamsFromHypo(); +} + +void SMESHGUI_MgAdaptDlg::buildDlg() +{ + setModal( false ); + setAttribute( Qt::WA_DeleteOnClose, true ); + setWindowTitle( tr( "ADAPT_PREF_MG_ADAPT" ) ); + setSizeGripEnabled( true ); + + + myTabWidget = new QTabWidget( this ); + + // Arguments + + myArgs = new SMESHGUI_MgAdaptArguments( myTabWidget ); + SMESH::str_array* str = model->getOptionValuesStrVec(); + SMESH::str_array* str2 = model->getCustomOptionValuesStrVec(); + std::vector s; + for (int i = 0; i< str->length(); i++) s.push_back( (*str)[i].in()); + for (int j = str->length(); j< str2->length(); j++) s.push_back((*str2)[ j - str->length() ].in() ); + //~str.insert( str.end(), str2.begin(), str2.end() ); + + myAdvOpt = new MgAdaptAdvWidget(myTabWidget, &s); + + int argsTab = myTabWidget->addTab( myArgs, tr( "Args" ) ); + int advTab = myTabWidget->addTab( myAdvOpt, tr( "ADVOP" ) ); + + myAdvOpt->workingDirectoryLabel ->setText (tr( "WORKING_DIR" )); + myAdvOpt->workingDirectoryPushButton ->setText (tr( "SELECT_DIR" )); + myAdvOpt->keepWorkingFilesCheck ->setText (tr( "KEEP_WORKING_FILES" )); + myAdvOpt->verboseLevelLabel ->setText (tr( "VERBOSE_LEVEL" )); + myAdvOpt->removeLogOnSuccessCheck ->setText (tr( "REMOVE_LOG_ON_SUCCESS" )); + myAdvOpt->logInFileCheck ->setText (tr( "LOG_IN_FILE" )); + myAdvOpt->logGroupBox ->setTitle(tr( "LOG_GROUP_TITLE" )); + + // buttons + QPushButton* okBtn = new QPushButton( tr( "SMESH_BUT_OK" ), this ); + okBtn->setAutoDefault( true ); + okBtn->setDefault( true ); + okBtn->setFocus(); + QPushButton* buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), this); + buttonApply->setAutoDefault(true); + QPushButton* buttonApplyAndClose = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), this); + buttonApplyAndClose->setAutoDefault(true); + QPushButton* cancelBtn = new QPushButton( tr( "SMESH_BUT_CANCEL" ), this ); + cancelBtn->setAutoDefault( true ); + QPushButton* helpBtn = new QPushButton( tr( "SMESH_BUT_HELP" ), this ); + helpBtn->setAutoDefault( true ); + + QHBoxLayout* btnLayout = new QHBoxLayout; + btnLayout->setSpacing( SPACING ); + btnLayout->setMargin( 0 ); + btnLayout->addWidget( buttonApplyAndClose ); + btnLayout->addStretch( 10 ); + btnLayout->addWidget( buttonApply ); + btnLayout->addStretch( 10 ); + btnLayout->addWidget( okBtn ); + btnLayout->addStretch( 10 ); + btnLayout->addWidget( cancelBtn ); + btnLayout->addStretch( 10 ); + btnLayout->addWidget( helpBtn ); + okBtn->hide(); // tab 1 + + QVBoxLayout* l = new QVBoxLayout ( this ); + l->setMargin( MARGIN ); + l->setSpacing( SPACING ); + l->addWidget( myTabWidget ); + l->addStretch(); + l->addLayout( btnLayout ); + + + connect( okBtn, SIGNAL( clicked() ), this, SLOT( clickOnOk() ) ); + connect( helpBtn, SIGNAL( clicked() ), this, SLOT( clickOnHelp() ) ); + connect(cancelBtn, SIGNAL(clicked()), this, SLOT(reject())); + connect(buttonApply, SIGNAL(clicked()), this,SLOT(clickOnApply())); + connect(buttonApplyAndClose, SIGNAL(clicked()), this,SLOT(clickOnOk())); + connect(myArgs, SIGNAL(meshDimSignal(ADAPTATION_MODE)), myAdvOpt, SLOT( onMeshDimChanged(ADAPTATION_MODE)) ); +} + + +//================================================================================= +// function : ~SMESHGUI_MgAdaptDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_MgAdaptDlg::~SMESHGUI_MgAdaptDlg() +{ + //~delete model; +} + +//~void SMESHGUI_MgAdaptDlg::setModel(MgAdapt* mg) +//~{ + //~model = mg; +//~} +SMESH::MG_ADAPT_ptr SMESHGUI_MgAdaptDlg::getModel() const +{ + return model; +} +/*! + \brief Perform clean-up actions on the dialog box closing. +*/ +bool SMESHGUI_MgAdaptDlg::clickOnApply() +{ + readParamsFromWidgets(); + return true; +} +void SMESHGUI_MgAdaptDlg::clickOnOk() +{ + clickOnApply(); + reject(); +} +void SMESHGUI_MgAdaptDlg::reject() +{ + QDialog::reject(); +} +bool SMESHGUI_MgAdaptDlg::readParamsFromHypo( ) const +{ + bool ret = true; + myArgs->aMedfile->setChecked(myData->fromMedFile) ; + if (myData->fromMedFile) + { + + *(myArgs->myFileInDir) = QString(myData->myFileInDir) ; + myArgs->selectMedFileLineEdit->setText(QString(myData->myMeshFileIn)) ; + // myData->myInMeshName = // TODO + + } + else + { + myArgs->aBrowserObject->setText(QString(myData->myInMeshName)); + //~ myArgs->myFileInDir =""; // TODO + //~ myArgs->selectMedFileLineEdit->setText(); // TODO + } + myArgs->meshNameLineEdit->setText(QString(myData->myOutMeshName)); + myArgs->medFileCheckBox->setChecked(myData->myMeshOutMed); + + if(myData->myMeshOutMed) + { + *(myArgs->myFileOutDir) = QString(myData->myFileOutDir); + myArgs->selectOutMedFileLineEdit->setText(QString(myData->myMeshFileOut)); + + } + else + { + *(myArgs->myFileOutDir) = QString(""); //TODO + } + + myArgs->publishOut->setChecked(myData->myPublish); + + myArgs->localButton->setChecked(myData->myUseLocalMap); + myArgs->backgroundButton->setChecked(myData->myUseBackgroundMap); + myArgs->constantButton->setChecked(myData->myUseConstantValue); + + if (myData->myUseConstantValue) + { + myArgs->dvalue->setValue(myData->myConstantValue); + } + else + { + myArgs->dvalue->setValue(0.0); + } + + if (myData->myUseBackgroundMap) + { + + *(myArgs->myFileSizeMapDir) = QString(myData->myFileSizeMapDir) ; + myArgs->selectMedFileBackgroundLineEdit->setText(QString(myData->myMeshFileBackground)); + } + else + { + *(myArgs->myFileSizeMapDir) = QString("") ; //TODO + myArgs->selectMedFileBackgroundLineEdit->setText(""); //TODO + } + + myArgs->fieldNameCmb->setCurrentText(QString(myData->myFieldName)); + myArgs->noTimeStep->setChecked(myData->myUseNoTimeStep); + myArgs->lastTimeStep->setChecked( myData->myUseLastTimeStep); + myArgs->chosenTimeStep->setChecked(myData->myUseChosenTimeStep); + if (myData->myUseChosenTimeStep) + { + myArgs->rankSpinBox->setValue(myData->myRank); + myArgs->timeStep->setValue(myData->myTimeStep); + } + + myAdvOpt->workingDirectoryLineEdit->setText(QString(myData->myWorkingDir)); + myAdvOpt->logInFileCheck->setChecked(myData->myPrintLogInFile); + + myAdvOpt->verboseLevelSpin->setValue(myData->myVerboseLevel); + myAdvOpt->removeLogOnSuccessCheck->setChecked(myData->myRemoveLogOnSuccess); + myAdvOpt->keepWorkingFilesCheck->setChecked(myData->myKeepFiles); + + return ret; + +} + + +bool SMESHGUI_MgAdaptDlg::readParamsFromWidgets() +{ + bool ret = true; + SMESH::MgAdaptHypothesisData* aData = new SMESH::MgAdaptHypothesisData(); + aData->fromMedFile = myArgs->aMedfile->isChecked(); + if (aData->fromMedFile) + { + + aData->myFileInDir = CORBA::string_dup(myArgs->myFileInDir->toStdString().c_str()); + aData->myMeshFileIn = CORBA::string_dup(myArgs->selectMedFileLineEdit->text().toStdString().c_str()); + // aData->myInMeshName = // TODO + } + else // TODO browser + { + aData->myInMeshName = CORBA::string_dup(myArgs->aBrowserObject->text().toStdString().c_str()); + aData->myFileInDir = CORBA::string_dup(myAdvOpt->workingDirectoryLineEdit->text().toStdString().c_str()); + + TCollection_AsciiString aGenericName = (char*)aData->myFileInDir; + TCollection_AsciiString aGenericName2 = "MgAdapt_"; + aGenericName2 += getpid(); + aGenericName2 += "_"; + aGenericName2 += Abs((Standard_Integer)(long) aGenericName.ToCString()); + aGenericName2 += ".med"; + aGenericName+=aGenericName2; + emit myArgs->toExportMED(aGenericName.ToCString()); + aData->myMeshFileIn = aGenericName2.ToCString(); + } + aData->myOutMeshName = CORBA::string_dup(myArgs->meshNameLineEdit->text().toStdString().c_str()); + aData->myMeshOutMed = myArgs->medFileCheckBox->isChecked(); + if(aData->myMeshOutMed) + { + aData->myFileOutDir = CORBA::string_dup(myArgs->myFileOutDir->toStdString().c_str()); + aData->myMeshFileOut = CORBA::string_dup(myArgs->selectOutMedFileLineEdit->text().toStdString().c_str()); + + } + else + { + aData->myMeshFileOut = ""; + } + + aData->myPublish = myArgs->publishOut->isChecked(); + + + aData->myUseLocalMap = myArgs->localButton->isChecked(); + aData->myUseBackgroundMap = myArgs->backgroundButton->isChecked(); + aData->myUseConstantValue = myArgs->constantButton->isChecked(); + if (aData->myUseConstantValue) + { + aData->myConstantValue = myArgs->dvalue->value(); + } + else + { + aData->myConstantValue = 0.0; + } + if (aData->myUseBackgroundMap) + { + aData->myFileSizeMapDir = CORBA::string_dup(myArgs->myFileSizeMapDir->toStdString().c_str()); + aData->myMeshFileBackground = CORBA::string_dup(myArgs->selectMedFileBackgroundLineEdit->text().toStdString().c_str()); + } + else + { + aData->myMeshFileBackground = ""; + } + + aData->myFieldName = CORBA::string_dup(myArgs->fieldNameCmb->currentText().toStdString().c_str()); + aData->myUseNoTimeStep = myArgs->noTimeStep->isChecked(); + aData->myUseLastTimeStep = myArgs->lastTimeStep->isChecked(); + aData->myUseChosenTimeStep = myArgs->chosenTimeStep->isChecked(); + if (aData->myUseChosenTimeStep) + { + aData->myRank = myArgs->rankSpinBox->value(); + aData->myTimeStep = myArgs->timeStep->value(); + + } + + + aData->myWorkingDir = CORBA::string_dup(myAdvOpt->workingDirectoryLineEdit->text().toStdString().c_str()); + aData->myPrintLogInFile = myAdvOpt->logInFileCheck->isChecked(); + aData->myVerboseLevel = myAdvOpt->verboseLevelSpin->value(); + aData->myRemoveLogOnSuccess = myAdvOpt->removeLogOnSuccessCheck->isChecked(); + aData->myKeepFiles = myAdvOpt->keepWorkingFilesCheck->isChecked(); + model->setData(*aData); + QString msg; + checkParams(msg); + delete aData; + return ret; +} +bool SMESHGUI_MgAdaptDlg::storeParamsToHypo( const SMESH::MgAdaptHypothesisData& ) const +{ + +} +/*! + \brief Show help page +*/ +void SMESHGUI_MgAdaptDlg::clickOnHelp() +{ + // QString aHelpFile; + // if ( myTabWidget->currentIndex() == MinDistance ) { + // aHelpFile = "measurements.html#min-distance-anchor"; + // } else if ( myTabWidget->currentIndex() == BoundingBox ) { + // aHelpFile = "measurements.html#bounding-box-anchor"; + // } else if ( myTabWidget->currentWidget() == myAngle ) { + // aHelpFile = "measurements.html#angle-anchor"; + // } else { + // aHelpFile = "measurements.html#basic-properties-anchor"; + // } + + // SMESH::ShowHelpFile( aHelpFile ); +} +bool SMESHGUI_MgAdaptDlg::checkParams(QString& msg) +{ + if ( !QFileInfo( myAdvOpt->workingDirectoryLineEdit->text().trimmed() ).isWritable() ) { + SUIT_MessageBox::warning( this, + tr( "SMESH_WRN_WARNING" ), + tr( "GHS3D_PERMISSION_DENIED" ) ); + return false; + } + + + myAdvOpt->myOptionTable->setFocus(); + QApplication::instance()->processEvents(); + + QString name, value; + bool isDefault, ok = true; + int iRow = 0, nbRows = myAdvOpt->myOptionTable->topLevelItemCount(); + for ( ; iRow < nbRows; ++iRow ) + { + QTreeWidgetItem* row = myAdvOpt->myOptionTable->topLevelItem( iRow ); + myAdvOpt->GetOptionAndValue( row, name, value, isDefault ); + + if ( name.simplified().isEmpty() ) + continue; // invalid custom option + + if ( isDefault ) // not selected option + value.clear(); + + try { + model->setOptionValue( name.toLatin1().constData(), value.toLatin1().constData() ); + } + catch ( const SALOME::SALOME_Exception& ex ) + { + msg = ex.details.text.in(); + ok = false; + break; + } + } + + + return ok; +} + +//================================================================================= +// function : SMESHGUI_MgAdaptArguments() +// purpose : +//================================================================================= +SMESHGUI_MgAdaptArguments::SMESHGUI_MgAdaptArguments( QWidget* parent ) + :QWidget(parent) +{ + + + myFileInDir = new QString(""); + myFileOutDir = new QString(""); + myFileSizeMapDir = new QString(""); + if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() ) + { + *myFileInDir = QDir::currentPath(); + *myFileOutDir = QDir::currentPath(); + *myFileSizeMapDir = QDir::currentPath(); + } + else + { + *myFileInDir = SUIT_FileDlg::getLastVisitedPath(); + *myFileOutDir = SUIT_FileDlg::getLastVisitedPath(); + *myFileSizeMapDir = SUIT_FileDlg::getLastVisitedPath(); + } + + meshDim = 0; + // Mesh in + aMeshIn = new QGroupBox( tr( "MeshIn" ), this ); + aMedfile = new QRadioButton( tr( "MEDFile" ), aMeshIn ); + aBrowser = new QRadioButton( tr( "Browser" ), aMeshIn ); + aBrowserObject = new QLineEdit( aMeshIn ); + selectMedFilebutton = new QPushButton("", aMeshIn); + selectMedFileLineEdit = new QLineEdit( aMeshIn ); + + meshIn = new QGridLayout( aMeshIn ); + + meshIn->setMargin( MARGIN ); + meshIn->setSpacing( SPACING ); + meshIn->addWidget( aMedfile, 0, 0, 1,1 ); + meshIn->addWidget( aBrowser, 0, 1,1,1); + meshIn->addWidget( aBrowserObject, 0, 2, 1, 1 ); + meshIn->addWidget( selectMedFilebutton, 1, 0,1, 1); + meshIn->addWidget( selectMedFileLineEdit, 1, 1, 1, 1 ); + hspacer = new QSpacerItem(188, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + + meshInGroup = new QButtonGroup( this ); + meshInGroup->addButton( aMedfile, 0 ); + meshInGroup->addButton( aBrowser, 1 ); + + //Mesh out + + aMeshOut = new QGroupBox( tr( "MeshOut" ), this ); + meshName = new QLabel(tr("MeshName"), aMeshOut); + secondHspacer = new QSpacerItem(100, 30); + meshNameLineEdit = new QLineEdit(aMeshOut) ; + medFileCheckBox = new QCheckBox(tr("MEDFile"), aMeshOut); + selectOutMedFilebutton = new QPushButton("", aMeshOut); + thirdHspacer = new QSpacerItem(188, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + selectOutMedFileLineEdit = new QLineEdit(aMeshOut) ; + publishOut = new QCheckBox(tr("Publish_MG_ADAPT"), aMeshOut); + + meshOut = new QGridLayout( aMeshOut ); + + meshOut->setMargin( MARGIN ); + meshOut->setSpacing( SPACING ); + meshOut->addWidget( meshName, 0, 0, 1,1 ); + meshOut->addItem( secondHspacer, 0, 1, 1, 1 ); + meshOut->addWidget( meshNameLineEdit, 0, 2,1,1); + meshOut->addWidget( medFileCheckBox, 1, 0,1,1 ); + meshOut->addWidget( selectOutMedFilebutton, 1, 1,1,1 ); + meshOut->addWidget( selectOutMedFileLineEdit, 1, 2,1,1); + meshOut->addWidget( publishOut, 2, 0,1,1 ); + + //size map definition + + sizeMapDefinition = new QGroupBox(tr("SIZE_MAP_DEF"), this); + localButton = new QRadioButton(tr("LOCAL_MG_ADAPT"), sizeMapDefinition); + backgroundButton = new QRadioButton(tr("BACKGRND_MG_ADAPT"), sizeMapDefinition); + constantButton = new QRadioButton(tr("CNST_MG_ADAPT"), sizeMapDefinition); + medFileBackground = new QLabel(tr("MED_FILE_BCKG"), sizeMapDefinition); + selectMedFileBackgroundbutton = new QPushButton(tr(""), sizeMapDefinition); + selectMedFileBackgroundLineEdit = new QLineEdit(sizeMapDefinition); + valueLabel = new QLabel(tr("VALUE_MG_ADAPT"), sizeMapDefinition); + dvalue = new QDoubleSpinBox(sizeMapDefinition); + sizeMapDefGroup = new QButtonGroup( this ); + sizeMapDefGroup->addButton( localButton, 0 ); + sizeMapDefGroup->addButton( backgroundButton, 1 ); + sizeMapDefGroup->addButton( constantButton, 2 ); + + sizeMapDefGroupLayout = new QGridLayout(sizeMapDefinition); + sizeMapDefGroupLayout->addWidget(localButton, 0,0); + sizeMapDefGroupLayout->addWidget(backgroundButton, 0,1); + sizeMapDefGroupLayout->addWidget(constantButton, 0,2); + sizeMapDefGroupLayout->addWidget(medFileBackground, 1,0); + sizeMapDefGroupLayout->addWidget(selectMedFileBackgroundbutton, 1,1); + sizeMapDefGroupLayout->addWidget(selectMedFileBackgroundLineEdit, 1,2); + sizeMapDefGroupLayout->addWidget(valueLabel, 2,0); + sizeMapDefGroupLayout->addWidget(dvalue, 2,1); + + // size Map field + sizeMapField = new QGroupBox(tr("SIZE_MAP_FIELD"), this); + fieldName = new QLabel(tr("MG_ADAPT_FIELD_NAME"), sizeMapField); + fieldNameCmb = new QComboBox(sizeMapField); + noTimeStep = new QRadioButton(tr("MG_ADAPT_NO_T_ST"), sizeMapField); + lastTimeStep = new QRadioButton(tr("MG_ADAPT_L_ST"), sizeMapField); + chosenTimeStep = new QRadioButton(tr("MG_ADAPT_CH_ST"), sizeMapField); + timeStepLabel = new QLabel(tr("MG_ADAPT_TSTP"), sizeMapField); + timeStep = new QSpinBox(sizeMapField); + //~timeStep->setMinimum(-1); + rankLabel = new QLabel(tr("MG_ADAPT_RANK"), sizeMapField); + rankSpinBox = new QSpinBox(sizeMapField); + rankSpinBox->setMinimum(-1); + + timeStepGroup = new QButtonGroup(this); + timeStepGroup->addButton(noTimeStep, 0); + timeStepGroup->addButton(lastTimeStep, 1); + timeStepGroup->addButton(chosenTimeStep, 2); + + sizeMapFieldGroupLayout = new QGridLayout(sizeMapField); + + sizeMapFieldGroupLayout->addWidget(fieldName, 0,0); + sizeMapFieldGroupLayout->addWidget(fieldNameCmb, 0,1); + sizeMapFieldGroupLayout->addWidget(noTimeStep, 1,0); + sizeMapFieldGroupLayout->addWidget(lastTimeStep, 1,1); + sizeMapFieldGroupLayout->addWidget(chosenTimeStep, 1,2); + sizeMapFieldGroupLayout->addWidget(timeStepLabel, 2,0); + sizeMapFieldGroupLayout->addWidget(timeStep, 2,1); + sizeMapFieldGroupLayout->addWidget(rankLabel, 2,2); + sizeMapFieldGroupLayout->addWidget(rankSpinBox, 2,3); + + + QGridLayout* argumentsLayout = new QGridLayout( this ); + argumentsLayout->setMargin( MARGIN ); + argumentsLayout->setSpacing( SPACING ); + + argumentsLayout->addWidget( aMeshIn, 0, 0, 1, 3 ); + argumentsLayout->addWidget( aMeshOut, 1, 0, 1, 3 ); + argumentsLayout->addWidget( sizeMapDefinition, 2, 0, 1, 3 ); + argumentsLayout->addWidget( sizeMapField, 3, 0, 1, 3 ); + argumentsLayout->setColumnStretch( 1, 5 ); + argumentsLayout->setRowStretch( 4, 5 ); + + // Initial state + setMode( Mesh, Local); + medFileCheckBox->setChecked(true); + + // Connections + connect( meshInGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( modeChanged( int ) ) ); + connect( sizeMapDefGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( sizeMapDefChanged( int ) ) ); + connect( selectMedFilebutton, SIGNAL( pressed( ) ), this, SLOT( onSelectMedFilebuttonClicked( ) ) ); + connect(medFileCheckBox, SIGNAL (stateChanged(int)), this, SLOT(onMedFileCheckBox(int) ) ); + connect(publishOut, SIGNAL (stateChanged(int)), this, SLOT(onPublishOut(int) ) ); + connect(selectOutMedFilebutton, SIGNAL( pressed()), this, SLOT(onSelectOutMedFilebutton())); + connect(selectMedFileBackgroundbutton, SIGNAL(pressed()), this, SLOT(onSelectMedFileBackgroundbutton()) ); + connect( timeStepGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( timeStepGroupChanged( int ) ) ); + emit updateSelection(); +} + +//================================================================================= +// function : ~SMESHGUI_MgAdaptArguments() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_MgAdaptArguments::~SMESHGUI_MgAdaptArguments() +{ +} + +void SMESHGUI_MgAdaptArguments::onNoTimeStep(bool disableOther) +{ + noTimeStep->setChecked(true); + + rankLabel->setVisible(0); + rankSpinBox->setVisible(0); + rankSpinBox->setValue(-2); + + timeStepLabel->setVisible(0); + timeStep->setVisible(0); + timeStep->setValue(-2); + + lastTimeStep->setDisabled(disableOther); + chosenTimeStep->setDisabled(disableOther); + + +} +void SMESHGUI_MgAdaptArguments::onLastTimeStep(bool disableOther) +{ + lastTimeStep->setChecked(true); + + rankLabel->setVisible(0); + rankSpinBox->setVisible(0); + rankSpinBox->setValue(-1); + + timeStepLabel->setVisible(0); + timeStep->setVisible(0); + timeStep->setValue(-1); + noTimeStep->setDisabled(disableOther); +} + +void SMESHGUI_MgAdaptArguments::onChosenTimeStep(bool disableOther, int max) +{ + chosenTimeStep->setChecked(true); + + rankLabel->setVisible(1); + rankSpinBox->setVisible(1); + rankSpinBox->setValue(0); + + timeStepLabel->setVisible(1); + timeStep->setVisible(1); + timeStep->setValue(0); + if (max) timeStep->setMaximum(max); + +} + +void SMESHGUI_MgAdaptArguments::onSelectOutMedFilebutton() +{ + + QString filtre = QString("Med") ; + filtre += QString(" files (*.") + QString("med") + QString(");;"); + QString fileName = QFileDialog::getSaveFileName(this, tr("SAVE_MED"), + QString(""), filtre); + QFileInfo myFileInfo(fileName); + selectOutMedFileLineEdit->setText(myFileInfo.fileName()); + *myFileOutDir = myFileInfo.path(); + +} +void SMESHGUI_MgAdaptArguments::onSelectMedFileBackgroundbutton() +{ + QString fileName0 = selectMedFileBackgroundbutton->text().trimmed(); + + QString fileName = getMedFileName(false); + if (fileName != QString::null) + { + myFieldList = GetListeChamps(fileName); + if (myFieldList.empty()) + { + fileName = fileName0; + fieldNameCmb->clear(); + } + else + { + // fill field name Combobox + fieldNameCmb->clear(); + std::map::const_iterator it; + for ( it=myFieldList.begin() ; it != myFieldList.end(); it++) + { + fieldNameCmb->insertItem(0,QString(it->first)); + int typeStepInField = it->second > 2 ? 2 : it->second ; + timeStepGroupChanged(typeStepInField, true); + } + + } + + } + else + { + fileName = fileName0; + fieldNameCmb->clear(); + } + + QFileInfo myFileInfo(fileName); + *myFileSizeMapDir = myFileInfo.path(); + selectMedFileBackgroundLineEdit->setText(myFileInfo.fileName()); + +} +void SMESHGUI_MgAdaptArguments::onMedFileCheckBox(int state) +{ + if (state == Qt::Checked) + { + selectOutMedFilebutton->show(); + selectOutMedFileLineEdit->show(); + selectOutMedFilebutton->setEnabled(true); + selectOutMedFileLineEdit->setEnabled(true); + } + else + { + selectOutMedFilebutton->setEnabled(false); + selectOutMedFileLineEdit->setEnabled(false); + publishOut->setChecked(true); + } +} +void SMESHGUI_MgAdaptArguments::onPublishOut(int state) +{ + if (state == Qt::Unchecked) + { + medFileCheckBox->setChecked(true); + } +} + +void SMESHGUI_MgAdaptArguments::onSelectMedFilebuttonClicked() +{ + // bool keep = false; + QString fileName0 = selectMedFileLineEdit->text().trimmed(); + + QString fileName = getMedFileName(false); + if(fileName != QString::null) + { + QString aMeshName = lireNomMaillage(fileName.trimmed(), meshDim); + if (aMeshName == QString::null ) + { + QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"), + QObject::tr("MG_ADAPT_MED_FILE_2") ); + fileName = fileName0; + } + else + { + meshNameLineEdit->setText(aMeshName); + ADAPTATION_MODE aMode = meshDim == 3 ? ADAPTATION_MODE::BOTH : ADAPTATION_MODE::SURFACE; // and when dimesh 3 without 2D mesh? + emit meshDimSignal(aMode); + } + + } + else + { + return; + } + + + QFileInfo myFileInfo(fileName); + *myFileInDir = myFileInfo.path(); + *myFileOutDir = myFileInfo.path(); + selectMedFileLineEdit->setText(myFileInfo.fileName()); + QString outF = fileName == QString::null ? myFileInfo.fileName() : + QString( remove_extension(myFileInfo.fileName().toStdString() ).c_str() )+ QString(".adapt.med"); + selectOutMedFileLineEdit->setText(outF); + onLocalSelected(myFileInfo.filePath()); + +} + +void SMESHGUI_MgAdaptArguments::onLocalSelected(QString filePath) +{ + myFieldList = GetListeChamps(filePath, false); + if (myFieldList.empty()) + { + if (localButton->isChecked()) + { + fieldNameCmb->clear(); + } + + } + else + { + // fill field name Combobox + fieldNameCmb->clear(); + std::map::const_iterator it; + for ( it = myFieldList.begin() ; it != myFieldList.end(); it++) + { + fieldNameCmb->insertItem(0,QString(it->first)); + int typeStepInField = it->second > 2 ? 2 : it->second ; + timeStepGroupChanged(typeStepInField, true); + } + + } +} +// ======================================================================= +// Gestion les boutons qui permettent de +// 1) retourne le nom d'un fichier par une fenetre de dialogue si aucun +// objet est selectionne dans l arbre d etude +// 2) retourne le nom du fichier asocie a l objet +// selectionne dans l arbre d etude +// ======================================================================= +QString SMESHGUI_MgAdaptArguments::getMedFileName(bool avertir) +{ + + QString aFile = QString::null; + QString filtre = QString("Med") ; + filtre += QString(" files (*.") + QString("med") + QString(");;"); + aFile = SUIT_FileDlg::getOpenFileName(0, QObject::tr("MG_ADAPT_SELECT_FILE_0"), QString(""), filtre ); + + return aFile; + +} +void SMESHGUI_MgAdaptArguments::setMode(const Mode theMode, const SIZEMAP theSizeMap ) +{ + QRadioButton* aButton = qobject_cast( meshInGroup->button( theMode ) ); + QRadioButton* bButton = qobject_cast( sizeMapDefGroup->button( theSizeMap ) ); + if ( aButton ) { + aButton->setChecked( true ); + modeChanged( theMode ); + } + if ( bButton ) { + bButton->setChecked( true ); + sizeMapDefChanged( theSizeMap ); + } +} + +void SMESHGUI_MgAdaptArguments::modeChanged( int theMode ) +{ + clear(); + if(theMode == Mesh) + { + aBrowserObject->hide(); + selectMedFileLineEdit->show(); + selectMedFilebutton->show(); + localButton->setEnabled(true); + } + else + { + selectMedFileLineEdit->hide(); + selectMedFilebutton->hide(); + localButton->setEnabled(false); + aBrowserObject->show(); + sizeMapDefChanged(Background); + emit updateSelection(); + } + + + +} + +void SMESHGUI_MgAdaptArguments::sizeMapDefChanged( int theSizeMap ) +{ + fieldNameCmb->clear(); + if(theSizeMap == Local) + { + localButton->setEnabled(true); + localButton->setChecked(true); + medFileBackground->hide(); + selectMedFileBackgroundbutton->hide(); + selectMedFileBackgroundLineEdit->hide(); + selectMedFileBackgroundLineEdit->clear(); + valueLabel->hide(); + dvalue->hide(); + + sizeMapField->setEnabled(true); + if (!selectMedFileLineEdit->text().isEmpty()) + { + QFileInfo myFileInfo(QDir(*myFileInDir), selectMedFileLineEdit->text()); + onLocalSelected(myFileInfo.filePath()); + } + } + else if (theSizeMap == Background) + { + medFileBackground->show(); + backgroundButton->setChecked(true); + selectMedFileBackgroundbutton->show(); + selectMedFileBackgroundLineEdit->show(); + valueLabel->hide(); + dvalue->hide(); + sizeMapField->setEnabled(true); + + } + else + { + medFileBackground->hide(); + constantButton->setChecked(true); + selectMedFileBackgroundbutton->hide(); + selectMedFileBackgroundLineEdit->clear(); + selectMedFileBackgroundLineEdit->hide(); + valueLabel->show(); + dvalue->show(); + sizeMapField->setEnabled(false); + + } + + +} +void SMESHGUI_MgAdaptArguments::timeStepGroupChanged(int timeStepType, bool disableOther, int max) +{ + switch (timeStepType) + { + case 0 : + onNoTimeStep(disableOther); + break; + case 1 : + onLastTimeStep(disableOther); + break; + case 2 : + onChosenTimeStep(disableOther, max); + default: + break; + } +} + +void SMESHGUI_MgAdaptArguments::clear() +{ + selectMedFileLineEdit->clear(); + aBrowserObject->clear(); + + meshNameLineEdit->clear(); + selectOutMedFileLineEdit->clear(); +} +med_int SMESHGUI_MgAdaptArguments::getMeshDim() const +{ + return meshDim; +} +QWidget* ItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &o, const QModelIndex &index) const +{ + bool editable = index.data( EDITABLE_ROLE ).toInt(); + return editable ? QItemDelegate::createEditor( parent, o, index ) : 0; +} + +////////////////////////////////////////// +// MgAdaptAdvWidget +////////////////////////////////////////// + +MgAdaptAdvWidget::MgAdaptAdvWidget( QWidget* parent, std::vector * options, Qt::WindowFlags f ) + : QWidget( parent, f ), myOptions(options) +{ + setupWidget(); + myOptionTable->header()->setSectionResizeMode( QHeaderView::ResizeToContents ); + myOptionTable->setItemDelegate( new ItemDelegate( myOptionTable ) ); + + for ( int i = 0, nb = myOptions->size(); i < nb; ++i ) + { + AddOption( (*myOptions)[i].c_str() ); + } + + connect( myOptionTable, SIGNAL( itemChanged(QTreeWidgetItem *, int)), SLOT( itemChanged(QTreeWidgetItem *, int ))); + connect( addBtn, SIGNAL( clicked() ), this, SLOT( onAddOption() ) ); + connect(workingDirectoryPushButton, SIGNAL(pressed()), this, SLOT(_onWorkingDirectoryPushButton())); +} + +MgAdaptAdvWidget::~MgAdaptAdvWidget() +{ +} + +void MgAdaptAdvWidget::AddOption( const char* option, bool isCustom ) +{ + + + QString name, value; + bool isDefault = false; + if ( option ) + { + QStringList name_value_type = QString(option).split( ":", QString::KeepEmptyParts ); + if ( name_value_type.size() > 0 ) + name = name_value_type[0]; + if ( name_value_type.size() > 1 ) + value = name_value_type[1]; + if ( name_value_type.size() > 2 ) + isDefault = !name_value_type[2].toInt(); + + } + QTreeWidget* table = myOptionTable; + //table->setExpanded( true ); + + QTreeWidgetItem* row; + if (optionTreeWidgetItem.size()) + { + std::map::iterator it = optionTreeWidgetItem.find(name); + if(it != optionTreeWidgetItem.end()) return; // option exist + else + { + row = getNewQTreeWidgetItem(table, option, name, isCustom); + } + } + else + { + row = getNewQTreeWidgetItem(table, option, name, isCustom); + } + row->setText( 0, tr( name.toLatin1().constData() )); + row->setText( 1, tr( value.toLatin1().constData() )); + row->setCheckState( 0, isDefault ? Qt::Unchecked : Qt::Checked); + row->setData( NAME_COL, PARAM_NAME, name ); + + if ( isCustom ) + { + myOptionTable->scrollToItem( row ); + myOptionTable->setCurrentItem( row ); + myOptionTable->editItem( row, NAME_COL ); + } +} + +QTreeWidgetItem* MgAdaptAdvWidget::getNewQTreeWidgetItem(QTreeWidget* table, const char* option, QString& name, bool isCustom) +{ + QTreeWidgetItem* row = new QTreeWidgetItem( table ); + row->setData( NAME_COL, EDITABLE_ROLE, int( isCustom && !option )); + row->setFlags( row->flags() | Qt::ItemIsEditable ); + optionTreeWidgetItem.insert(std::pair (name, row)); + + return row; +} + +void MgAdaptAdvWidget::onAddOption() +{ + AddOption( NULL, true ); +} +void MgAdaptAdvWidget::GetOptionAndValue( QTreeWidgetItem * tblRow, + QString& option, + QString& value, + bool& isDefault) +{ + option = tblRow->data( NAME_COL, PARAM_NAME ).toString(); + value = tblRow->text( VALUE_COL ); + isDefault = ! tblRow->checkState( NAME_COL ); + +} + + +void MgAdaptAdvWidget::itemChanged(QTreeWidgetItem* tblRow, int column) +{ + if ( tblRow ) + { + myOptionTable->blockSignals( true ); + + tblRow->setData( VALUE_COL, EDITABLE_ROLE, int( tblRow->checkState( NAME_COL ))); + + int c = tblRow->checkState( NAME_COL ) ? 0 : 150; + tblRow->setForeground( VALUE_COL, QBrush( QColor( c, c, c ))); + + if ( column == NAME_COL && tblRow->data( NAME_COL, EDITABLE_ROLE ).toInt() ) // custom table + { + tblRow->setData( NAME_COL, PARAM_NAME, tblRow->text( NAME_COL )); + } + + myOptionTable->blockSignals( false ); + } +} +void MgAdaptAdvWidget::setupWidget() +{ + if (this->objectName().isEmpty()) + this->setObjectName(QString(tr("MG-ADAPT-ADV"))); + this->resize(337, 369); + gridLayout_4 = new QGridLayout(this); + gridLayout_4->setObjectName(QString("gridLayout_4")); + myOptionTable = new MgAdaptAdvWidgetTreeWidget(this); + QFont font; + font.setBold(false); + font.setWeight(50); + QTreeWidgetItem *__qtreewidgetitem = new QTreeWidgetItem(); + __qtreewidgetitem->setFont(1, font); + __qtreewidgetitem->setFont(0, font); + __qtreewidgetitem->setText(1, tr("OPTION_VALUE_COLUMN")); + __qtreewidgetitem->setText(0, tr("OPTION_NAME_COLUMN")); + myOptionTable->setHeaderItem(__qtreewidgetitem); + myOptionTable->setObjectName(QString("myOptionTable")); + myOptionTable->setEditTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed); + myOptionTable->setTabKeyNavigation(true); + + gridLayout_4->addWidget(myOptionTable, 0, 0, 1, 2); + + addBtn = new QPushButton(this); + addBtn->setObjectName(QString("addBtn")); + + gridLayout_4->addWidget(addBtn, 1, 0, 1, 1); + + horizontalSpacer = new QSpacerItem(188, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + + gridLayout_4->addItem(horizontalSpacer, 1, 1, 1, 1); + + logGroupBox = new QGroupBox(this); + logGroupBox->setObjectName(QString("logGroupBox")); + gridLayout_2 = new QGridLayout(logGroupBox); + gridLayout_2->setObjectName(QString("gridLayout_2")); + gridLayout = new QGridLayout(); + gridLayout->setObjectName(QString("gridLayout")); + workingDirectoryLabel = new QLabel(logGroupBox); + workingDirectoryLabel->setObjectName(QString("workingDirectoryLabel")); + + gridLayout->addWidget(workingDirectoryLabel, 0, 0, 1, 1); + + workingDirectoryLineEdit = new QLineEdit(logGroupBox); + workingDirectoryLineEdit->setObjectName(QString("workingDirectoryLineEdit")); + + gridLayout->addWidget(workingDirectoryLineEdit, 0, 1, 1, 1); + + workingDirectoryPushButton = new QPushButton(logGroupBox); + workingDirectoryPushButton->setObjectName(QString("workingDirectoryPushButton")); + + gridLayout->addWidget(workingDirectoryPushButton, 0, 2, 1, 1); + + verboseLevelLabel = new QLabel(logGroupBox); + verboseLevelLabel->setObjectName(QString("verboseLevelLabel")); + + gridLayout->addWidget(verboseLevelLabel, 1, 0, 1, 1); + + verboseLevelSpin = new QSpinBox(logGroupBox); + verboseLevelSpin->setObjectName(QString("verboseLevelSpin")); + + gridLayout->addWidget(verboseLevelSpin, 1, 1, 1, 1); + + + gridLayout_2->addLayout(gridLayout, 0, 0, 1, 1); + + horizontalLayout = new QHBoxLayout(); + horizontalLayout->setObjectName(QString("horizontalLayout")); + logInFileCheck = new QCheckBox(logGroupBox); + logInFileCheck->setObjectName(QString("logInFileCheck")); + logInFileCheck->setChecked(true); + + horizontalLayout->addWidget(logInFileCheck); + + removeLogOnSuccessCheck = new QCheckBox(logGroupBox); + removeLogOnSuccessCheck->setObjectName(QString("removeLogOnSuccessCheck")); + removeLogOnSuccessCheck->setChecked(true); + + horizontalLayout->addWidget(removeLogOnSuccessCheck); + + + gridLayout_2->addLayout(horizontalLayout, 1, 0, 1, 1); + + keepWorkingFilesCheck = new QCheckBox(logGroupBox); + keepWorkingFilesCheck->setObjectName(QString("keepWorkingFilesCheck")); + keepWorkingFilesCheck->setAutoExclusive(false); + + gridLayout_2->addWidget(keepWorkingFilesCheck, 2, 0, 1, 1); + + + gridLayout_4->addWidget(logGroupBox, 3, 0, 1, 2); + + + // retranslateUi(this); + + // QMetaObject::connectSlotsByName(this); + +} +void MgAdaptAdvWidget::_onWorkingDirectoryPushButton() +{ + QString aDirName=QFileDialog::getExistingDirectory (); + if (!(aDirName.isEmpty()))workingDirectoryLineEdit->setText(aDirName); +} +void MgAdaptAdvWidget::onMeshDimChanged(ADAPTATION_MODE aMode) +{ + /* default adaptation mode + * assume that if meshDim == 2 -->adaptation surface + * if meshDim == 3 and if there is not 2D mesh -->VOLUME + * else BOTH + */ + + QString adaptation("adaptation"), value; + switch(aMode) + { + case ADAPTATION_MODE::SURFACE: + { + value ="surface"; + setOptionValue(adaptation, value); + break; + } + case ADAPTATION_MODE::BOTH : + { + value = "both"; + setOptionValue(adaptation, value); + break; + } + case ADAPTATION_MODE::VOLUME : + { + value = "volume"; + setOptionValue(adaptation, value); + break; + } + } +} +void MgAdaptAdvWidget::setOptionValue(QString& option, QString& value) +{ + + std::map::iterator it = optionTreeWidgetItem.find(option); + if (it != optionTreeWidgetItem.end()) + { + it->second->setText( 0, tr( option.toLatin1().constData() )); + it->second->setText( 1, tr( value.toLatin1().constData() )); + it->second->setCheckState( 0, Qt::Checked ); + it->second->setData( NAME_COL, PARAM_NAME, option ); + myOptionTable->editItem( it->second, NAME_COL ); + } +} +namespace +{ +bool isEditable( const QModelIndex& index ) +{ + return index.isValid() && + index.flags() & Qt::ItemIsEditable && + index.flags() & Qt::ItemIsEnabled && + ( !index.data( Qt::UserRole + 1 ).isValid() || index.data( Qt::UserRole + 1 ).toInt() != 0 ); +} +} + +MgAdaptAdvWidgetTreeWidget::MgAdaptAdvWidgetTreeWidget( QWidget* parent ) + : QTreeWidget( parent ) +{ +} + +QModelIndex MgAdaptAdvWidgetTreeWidget::moveCursor( CursorAction action, Qt::KeyboardModifiers modifiers ) +{ + QModelIndex current = currentIndex(); + int column = current.column(); + if ( action == MoveNext ) { + if ( column < columnCount()-1 ) { + QModelIndex next = current.sibling( current.row(), column+1 ); + if ( isEditable( next ) ) + return next; + } + else { + QModelIndex next = current.sibling( current.row()+1, 0 ); + if ( isEditable( next ) ) + return next; + } + } + else if ( action == MovePrevious ) { + if ( column == 0 ) { + QModelIndex next = current.sibling( current.row()-1, columnCount()-1 ); + if ( isEditable( next ) ) + return next; + } + else { + QModelIndex next = current.sibling( current.row(), column-1 ); + if ( isEditable( next ) ) + return next; + } + } + return QTreeWidget::moveCursor( action, modifiers ); +} + +void MgAdaptAdvWidgetTreeWidget::keyPressEvent( QKeyEvent* e ) +{ + switch ( e->key() ) { + case Qt::Key_F2: + { + QModelIndex index = currentIndex(); + if ( !isEditable( index ) ) { + for ( int i = 0; i < columnCount(); i++ ) { + QModelIndex sibling = index.sibling( index.row(), i ); + if ( isEditable( sibling ) ) { + if ( !edit( sibling, EditKeyPressed, e ) ) + e->ignore(); + } + } + } + } + break; + default: + break; + } + QTreeWidget::keyPressEvent( e ); +} + + +// ======================================================================= +// renvoie le medId associe au fichier Med apres ouverture +// ======================================================================= +med_idt OuvrirFichier(QString aFile) +{ + med_idt medIdt = MEDfileOpen(aFile.toStdString().c_str(),MED_ACC_RDONLY); + if (medIdt <0) + { + QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"), + QObject::tr("MG_ADAPT_MED_FILE_1") ); + } + return medIdt; +} + +// ====================================================== +// ======================================================== +QString lireNomMaillage(QString aFile, med_int& meshdim) +{ + QString nomMaillage = QString::null ; + int erreur = 0 ; + med_idt medIdt ; + + // Ouverture du fichier + medIdt = OuvrirFichier(aFile); + if ( medIdt < 0 ) + { + erreur = 1 ; + return nomMaillage; + } + med_int numberOfMeshes = MEDnMesh(medIdt) ; + if (numberOfMeshes == 0 ) + { + QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"), + QObject::tr("MG_ADAPT_MED_FILE_2") ); + erreur = 2 ; + return nomMaillage; + } + if (numberOfMeshes > 1 ) + { + QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"), + QObject::tr("MG_ADAPT_MED_FILE_3") ); + erreur = 3 ; + return nomMaillage; + } + + nomMaillage = lireNomMaillage2(medIdt,1, meshdim); + // Fermeture du fichier + if ( medIdt > 0 ) MEDfileClose(medIdt); + + return nomMaillage; +} + +// ======================================================================= +// ======================================================================= +QString lireNomMaillage2(med_idt medIdt,int meshId, med_int& meshdim ) +{ + QString NomMaillage=QString::null; + char meshname[MED_NAME_SIZE+1]; + med_int spacedim; + med_mesh_type meshtype; + char descriptionription[MED_COMMENT_SIZE+1]; + char dtunit[MED_SNAME_SIZE+1]; + med_sorting_type sortingtype; + med_int nstep; + med_axis_type axistype; + int naxis = MEDmeshnAxis(medIdt,1); + char *axisname=new char[naxis*MED_SNAME_SIZE+1]; + char *axisunit=new char[naxis*MED_SNAME_SIZE+1]; + med_err aRet = MEDmeshInfo(medIdt, + meshId, + meshname, + &spacedim, + &meshdim, + &meshtype, + descriptionription, + dtunit, + &sortingtype, + &nstep, + &axistype, + axisname, + axisunit); + + if ( aRet < 0 ) { + QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"), \ + QObject::tr("MG_ADAPT_MED_FILE_4") ); + } + else { + NomMaillage=QString(meshname); + } + + delete[] axisname ; + delete[] axisunit ; + + return NomMaillage; +} + + + +// ======================================================================= +std::map GetListeChamps(QString aFile, bool errorMessage) +// ======================================================================= +{ +// Il faut voir si plusieurs maillages + + MESSAGE("GetListeChamps"); + std::map ListeChamp ; + + med_err erreur = 0 ; + med_idt medIdt ; + + while ( erreur == 0 ) + { + // Ouverture du fichier + SCRUTE(aFile.toStdString()); + medIdt = OuvrirFichier(aFile); + if ( medIdt < 0 ) + { + erreur = 1 ; + break ; + } + // Lecture du nombre de champs + med_int ncha = MEDnField(medIdt) ; + if (ncha < 1 ) + { + if(errorMessage) + { + QMessageBox::critical( 0, QObject::tr("_ERROR"), + QObject::tr("HOM_MED_FILE_5") ); + } + erreur = 2 ; + break ; + } + // Lecture des caracteristiques des champs + for (int i=0; i< ncha; i++) + { +// Lecture du nombre de composantes + med_int ncomp = MEDfieldnComponent(medIdt,i+1); +// Lecture du type du champ, des noms des composantes et du nom de l'unite + char nomcha [MED_NAME_SIZE+1]; + char meshname[MED_NAME_SIZE+1]; + char * comp = (char*) malloc(ncomp*MED_SNAME_SIZE+1); + char * unit = (char*) malloc(ncomp*MED_SNAME_SIZE+1); + char dtunit[MED_SNAME_SIZE+1]; + med_bool local; + med_field_type typcha; + med_int nbofcstp; + erreur = MEDfieldInfo(medIdt,i+1,nomcha,meshname,&local,&typcha,comp,unit,dtunit,&nbofcstp) ; + free(comp); + free(unit); + if ( erreur < 0 ) + { + if(errorMessage) + { + QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"), + QObject::tr("MG_ADAPT_MED_FILE_6") ); + } + break ; + } + + ListeChamp.insert(std::pair (QString(nomcha), nbofcstp)); + + } + break ; + } + // Fermeture du fichier + if ( medIdt > 0 ) MEDfileClose(medIdt); + + return ListeChamp; +} + +std::string remove_extension(const std::string& filename) { + size_t lastdot = filename.find_last_of("."); + if (lastdot == std::string::npos) return filename; + return filename.substr(0, lastdot); +} + + diff --git a/src/SMESHGUI/MG_ADAPTGUI.hxx b/src/SMESHGUI/MG_ADAPTGUI.hxx new file mode 100644 index 000000000..7b50a32a5 --- /dev/null +++ b/src/SMESHGUI/MG_ADAPTGUI.hxx @@ -0,0 +1,331 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// SMESH SMESHGUI : GUI for the adaptation in the SMESH component +// File : MG_ADAPTGUI.hxx +// +#ifndef MG_ADAPTGUI_HXX +#define MG_ADAPTGUI_HXX + +#include +// SMESH includes + +// Qt includes +#include +#include +#include + +#include "LightApp_DataOwner.h" +#include "SalomeApp_Application.h" +#include +#include +#include "SalomeApp_Module.h" +#include "SalomeApp_Study.h" +#include +#include + + +// model + + +//~#include "MG_ADAPT.hxx" + +#include CORBA_SERVER_HEADER(MG_ADAPT) + +class SUIT_ViewWindow; +class SUIT_Desktop; +class SUIT_Study; +class SUIT_ResourceMgr; + +class CAM_Module; + +class SALOMEDSClient_Study; +class SALOMEDSClient_SObject; + +class SalomeApp_Study; +class SalomeApp_Module; +class LightApp_SelectionMgr; + + +class QButtonGroup; +class QLineEdit; +class QGroupBox; +class QRadioButton; +class QLabel; +class QCheckBox; +class QGridLayout; +class QTabWidget; +class QDoubleSpinBox; +class QSpinBox; +class QTreeWidget; +class QTreeWidgetItem; +class QSpacerItem; +class QHBoxLayout; +class QItemDelegate; +class QComboBox; + +// IDL includes +#include + +class SVTK_ViewWindow; +class SVTK_Selector; +class SMESHGUI_MgAdaptDlg; +class SMESHGUI_MgAdaptArguments; +class SMESHGUI_SpinBox; +class MgAdaptAdvWidgetTreeWidget; +class MgAdaptAdvWidget; +//~class MgAdapt; +class QHeaderView; +class QFileDialog; + + +std::map GetListeChamps(QString aFile, bool errorMessage = true); +QString lireNomMaillage(QString aFile, med_int& meshDim); +QString lireNomMaillage2(med_idt medIdt,int meshId, med_int& meshDim); +med_idt OuvrirFichier(QString aFile); +std::string remove_extension(const std::string& filename); + + +enum ADAPTATION_MODE{ + SURFACE, // surface adaption when meshDim == 2 + VOLUME, // + BOTH +}; +//================================================================================= +// class : SMESHGUI_MgAdaptDlg +// purpose : +//================================================================================= +class SMESHGUI_MgAdaptDlg : public QDialog +{ + Q_OBJECT; +public: + //! Property type + enum Mode { Arguments, AdvancedOptions}; + SMESHGUI_MgAdaptDlg( SalomeApp_Module*, SMESH::MG_ADAPT_ptr, QWidget* parent= 0,bool isCreation = true ); + ~SMESHGUI_MgAdaptDlg(); + + void buildDlg(); + void reject(); + bool checkParams(QString& msg) ; + //~void setModel(MgAdapt*); + SMESH::MG_ADAPT_ptr getModel() const; + +public slots: + +protected slots: + + virtual bool clickOnApply(); +private slots: + virtual void clickOnHelp(); + virtual void clickOnOk(); +protected : + + SMESHGUI_MgAdaptArguments* myArgs; + MgAdaptAdvWidget* myAdvOpt; + bool readParamsFromHypo( ) const ; + bool readParamsFromWidgets( ) ; + bool storeParamsToHypo( const SMESH::MgAdaptHypothesisData & ) const; + +private: + + + SalomeApp_Module* mySMESHGUI; /* Current SMESHGUI object */ + QTabWidget* myTabWidget; + + + SMESH::MgAdaptHypothesisData* myData; + SMESH::MG_ADAPT_ptr model; + +}; + +class SMESHGUI_MgAdaptArguments : public QWidget +{ + Q_OBJECT; +public: + //! Property type + enum Mode { Mesh, Browser}; + enum SIZEMAP { Local, Background, Constant}; + SMESHGUI_MgAdaptArguments( QWidget* parent); + ~SMESHGUI_MgAdaptArguments(); + void setMode( const Mode, const SIZEMAP ); + med_int getMeshDim() const; + + QString* myFileInDir; + QString* myFileOutDir; + QString* myFileSizeMapDir; + QGroupBox* aMeshIn ; + QRadioButton* aMedfile; + QRadioButton* aBrowser ; + QLineEdit* aBrowserObject; + QPushButton* selectMedFilebutton ; + QSpacerItem* hspacer; + QLineEdit* selectMedFileLineEdit ; + QButtonGroup* meshInGroup ; + QGridLayout* meshIn ; + + QGroupBox* aMeshOut ; + QLabel* meshName; + QLineEdit* meshNameLineEdit; + QSpacerItem* secondHspacer; + QCheckBox* medFileCheckBox; + QPushButton* selectOutMedFilebutton; + QLineEdit* selectOutMedFileLineEdit; + QSpacerItem* thirdHspacer; + QCheckBox* publishOut; + QGridLayout* meshOut ; + + QGroupBox* sizeMapDefinition ; + QRadioButton* localButton; + QRadioButton* backgroundButton ; + QRadioButton* constantButton ; + QLabel* medFileBackground; + QPushButton* selectMedFileBackgroundbutton; + QLineEdit* selectMedFileBackgroundLineEdit; + QLabel* valueLabel; + QDoubleSpinBox* dvalue; + QButtonGroup* sizeMapDefGroup ; + QGridLayout* sizeMapDefGroupLayout; + + + QGroupBox* sizeMapField; + QLabel* fieldName; + QComboBox* fieldNameCmb; + QRadioButton* noTimeStep; + QRadioButton* lastTimeStep ; + QRadioButton* chosenTimeStep; + QLabel* timeStepLabel; + QSpinBox* timeStep; + QLabel* rankLabel; + QSpinBox* rankSpinBox; + QButtonGroup* timeStepGroup; + QGridLayout* sizeMapFieldGroupLayout; + +signals: + void updateSelection(); + void toExportMED(const char *); + void meshDimSignal(ADAPTATION_MODE aMode); +public slots: + +protected slots: + +private slots: + void modeChanged( int); + void sizeMapDefChanged(int); + void timeStepGroupChanged(int timeStepType, bool disableOther = false, int max = 0); + void onSelectMedFilebuttonClicked(); + void clear(); + void onMedFileCheckBox(int); + void onPublishOut(int); + void onSelectOutMedFilebutton(); + void onSelectMedFileBackgroundbutton(); + void onLocalSelected(QString); + void onNoTimeStep(bool disableOther = false); + void onLastTimeStep(bool disableOther = false); + void onChosenTimeStep(bool disableOther = false, int max = 0); + +private: + + QString getMedFileName(bool avertir); + LightApp_SelectionMgr* selMgr ; + med_int meshDim; + std::map myFieldList; + + +}; +enum { + OPTION_ID_COLUMN = 0, + OPTION_TYPE_COLUMN, + OPTION_NAME_COLUMN = 0, + OPTION_VALUE_COLUMN, + NB_COLUMNS, +}; + +////////////////////////////////////////// +// MgAdaptAdvWidget +////////////////////////////////////////// +class MgAdaptAdvWidget : public QWidget +{ + Q_OBJECT + +public: + MgAdaptAdvWidget( QWidget* = 0, std::vector * = nullptr, Qt::WindowFlags = 0 ); + ~MgAdaptAdvWidget(); + std::vector < std::string > * myOptions; + QGridLayout *gridLayout_4; + MgAdaptAdvWidgetTreeWidget *myOptionTable; + QPushButton *addBtn; + QSpacerItem *horizontalSpacer; + QGroupBox *logGroupBox; + QGridLayout *gridLayout_2; + QGridLayout *gridLayout; + QLabel *workingDirectoryLabel; + QLineEdit *workingDirectoryLineEdit; + QPushButton *workingDirectoryPushButton; + QLabel *verboseLevelLabel; + QSpinBox *verboseLevelSpin; + QHBoxLayout *horizontalLayout; + QCheckBox *logInFileCheck; + QCheckBox *removeLogOnSuccessCheck; + QCheckBox *keepWorkingFilesCheck; + + void AddOption( const char* name_value_type, bool isCustom = false ); + void GetOptionAndValue( QTreeWidgetItem * tblRow, QString& option, QString& value, bool& dflt ); + void setupWidget(); +public slots: + + void onAddOption(); + void itemChanged(QTreeWidgetItem * tblRow, int column); + void onMeshDimChanged(ADAPTATION_MODE aMode); +private slots: + void _onWorkingDirectoryPushButton(); +private: + void setOptionValue(QString& option, QString& value); + std::map optionTreeWidgetItem; + + QTreeWidgetItem* getNewQTreeWidgetItem(QTreeWidget* table, const char* option, QString& name, bool isCustom); + +}; + +enum { EDITABLE_ROLE = Qt::UserRole + 1, PARAM_NAME, + NAME_COL = 0, VALUE_COL + }; + + + +class ItemDelegate: public QItemDelegate +{ +public: + + ItemDelegate(QObject* parent=0): QItemDelegate(parent) {} + QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &o, const QModelIndex &index) const; +}; + +class MgAdaptAdvWidgetTreeWidget : public QTreeWidget +{ + Q_OBJECT +public: + MgAdaptAdvWidgetTreeWidget( QWidget* ); + +protected: + QModelIndex moveCursor( CursorAction, Qt::KeyboardModifiers ); + void keyPressEvent( QKeyEvent* ); +}; + + +#endif // MG_ADAPTGUI_HXX diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index ff88035b1..3b460089d 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -30,6 +30,7 @@ // SMESH includes #include "SMESHGUI.h" +#include "SMESHGUI_AdaptDlg.h" #include "SMESHGUI_Add0DElemsOnAllNodesDlg.h" #include "SMESHGUI_AddMeshElementDlg.h" #include "SMESHGUI_AddQuadraticElementDlg.h" @@ -1970,12 +1971,12 @@ void SMESHGUI::OnEditDelete() int objectCount = 0; QString aNameList; QString aParentComponent = QString::null; - + for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() ) { Handle(SALOME_InteractiveObject) anIO = anIt.Value(); if ( anIO.IsNull() ) continue; - + QString father = "unknown", name; _PTR(SObject) aSO = aStudy->FindObjectID( anIO->getEntry() ); @@ -3034,6 +3035,21 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) } break; } + // Adaptation - begin + case SMESHOp::OpUniformRefinement: + case SMESHOp::OpHONewCase: + case SMESHOp::OpHOCaseFollow: + case SMESHOp::OpHONewIter: + case SMESHOp::OpHOIterCompute: + case SMESHOp::OpHOIterComputePublish: + case SMESHOp::OpHOEdit: + case SMESHOp::OpHODelete: + case SMESHOp::OpMGAdapt: + { + SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil(); + SMESHGUI_AdaptDlg *objet = new SMESHGUI_AdaptDlg( this, theCommandID, aMesh); + } + // Adaptation - end case SMESHOp::OpSplitBiQuadratic: case SMESHOp::OpConvertMeshToQuadratic: case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D @@ -4271,6 +4287,18 @@ void SMESHGUI::initialize( CAM_Application* app ) createSMESHAction( SMESHOp::OpAutoColor, "AUTO_COLOR" ); createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" ); + // Adaptation - begin + createSMESHAction( SMESHOp::OpUniformRefinement, "REF_ALL", "ICON_REF_ALL" ); + createSMESHAction( SMESHOp::OpHONewCase, "HOMARD_CREATE_CASE", "ICON_HOMARD_CREATE_CASE" ); + createSMESHAction( SMESHOp::OpHOCaseFollow, "HOMARD_FOLLOW_ITERATION", "ICON_HOMARD_FOLLOW_ITERATION" ); + createSMESHAction( SMESHOp::OpHONewIter, "HOMARD_NEW_ITERATION", "ICON_HOMARD_NEW_ITERATION" ); + createSMESHAction( SMESHOp::OpHOIterCompute, "HOMARD_COMPUTE", "ICON_HOMARD_COMPUTE" ); + createSMESHAction( SMESHOp::OpHOIterComputePublish, "HOMARD_COMPUTE_PUBLISH", "ICON_HOMARD_COMPUTE_PUBLISH" ); + createSMESHAction( SMESHOp::OpHOEdit, "EDIT", "ICON_DLG_EDIT_MESH" ); + createSMESHAction( SMESHOp::OpHODelete, "DELETE", "ICON_DELETE" ); + createSMESHAction( SMESHOp::OpMGAdapt, "MG_ADAPT", "ICON_MG_ADAPT" ); + // Adaptation - end + createSMESHAction( SMESHOp::OpMinimumDistance, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" ); createSMESHAction( SMESHOp::OpBoundingBox, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" ); createSMESHAction( SMESHOp::OpPropertiesLength, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" ); @@ -4312,6 +4340,7 @@ void SMESHGUI::initialize( CAM_Application* app ) meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ), ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ), modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ), + adaptId = createMenu( tr( "MEN_ADAPT" ), -1, 80, 10 ), measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ), viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 ); @@ -4329,6 +4358,7 @@ void SMESHGUI::initialize( CAM_Application* app ) removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ), //renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ), transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ), + refHomardId = createMenu( tr( "MEN_REF_HOMARD" ), adaptId, -1, 10 ), basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 ); //createMenu( SMESHOp::OpImportDAT, importId, -1 ); @@ -4484,6 +4514,20 @@ void SMESHGUI::initialize( CAM_Application* app ) createMenu( SMESHOp::OpSmoothing, modifyId, -1 ); createMenu( SMESHOp::OpPatternMapping, modifyId, -1 ); + // Adaptation - begin + createMenu( SMESHOp::OpUniformRefinement, adaptId, -1 ); + createMenu( SMESHOp::OpHONewCase, refHomardId, -1 ); + createMenu( SMESHOp::OpHOCaseFollow, refHomardId, -1 ); + createMenu( separator(), refHomardId, -1 ); + createMenu( SMESHOp::OpHONewIter, refHomardId, -1 ); + createMenu( SMESHOp::OpHOIterCompute, refHomardId, -1 ); + createMenu( SMESHOp::OpHOIterComputePublish, refHomardId, -1 ); + createMenu( separator(), refHomardId, -1 ); + createMenu( SMESHOp::OpHOEdit, refHomardId, -1 ); + createMenu( SMESHOp::OpHODelete, refHomardId, -1 ); + createMenu( SMESHOp::OpMGAdapt, adaptId, -1 ); + // Adaptation - end + createMenu( SMESHOp::OpMinimumDistance, measureId, -1 ); createMenu( SMESHOp::OpBoundingBox, measureId, -1 ); createMenu( SMESHOp::OpAngle, measureId, -1 ); @@ -4498,22 +4542,7 @@ void SMESHGUI::initialize( CAM_Application* app ) connect( volumeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) ); // ----- create toolbars -------------- - int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ), - info = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ), - groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ), - ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ), - ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ), - ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ), - ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ), - addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ), - addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ), - remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ), - //renumbTb = createTool( tr( "TB_RENUMBER" ), QString( "SMESHRenumberingToolbar" ) ), - transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ), - modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ), - measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ), - dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) ); - + int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ) ; createTool( SMESHOp::OpCreateMesh, meshTb ); createTool( SMESHOp::OpCreateSubMesh, meshTb ); createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb ); @@ -4525,25 +4554,30 @@ void SMESHGUI::initialize( CAM_Application* app ) createTool( SMESHOp::OpEvaluate, meshTb ); createTool( SMESHOp::OpMeshOrder, meshTb ); + int infoTb = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ) ; + createTool( SMESHOp::OpMeshInformation, infoTb ); + //createTool( SMESHOp::OpStdInfo, meshTb ); + //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command) + createTool( SMESHOp::OpFindElementByPoint, infoTb ); + + int groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ) ; createTool( SMESHOp::OpCreateGroup, groupTb ); createTool( SMESHOp::OpCreateGeometryGroup, groupTb ); createTool( SMESHOp::OpConstructGroup, groupTb ); createTool( SMESHOp::OpEditGroup, groupTb ); - createTool( SMESHOp::OpMeshInformation, info ); - //createTool( SMESHOp::OpStdInfo, meshTb ); - //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command) - createTool( SMESHOp::OpFindElementByPoint, info ); - + int ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ) ; createTool( SMESHOp::OpFreeNode, ctrl0dTb ); createTool( SMESHOp::OpEqualNode, ctrl0dTb ); //createTool( SMESHOp::OpNodeConnectivityNb, ctrl0dTb ); + int ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ) ; createTool( SMESHOp::OpFreeBorder, ctrl1dTb ); createTool( SMESHOp::OpLength, ctrl1dTb ); createTool( SMESHOp::OpConnection, ctrl1dTb ); createTool( SMESHOp::OpEqualEdge, ctrl1dTb ); + int ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ) ; createTool( SMESHOp::OpFreeEdge, ctrl2dTb ); createTool( SMESHOp::OpFreeFace, ctrl2dTb ); createTool( SMESHOp::OpBareBorderFace, ctrl2dTb ); @@ -4560,6 +4594,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createTool( SMESHOp::OpEqualFace, ctrl2dTb ); createTool( SMESHOp::OpDeflection2D, ctrl2dTb ); + int ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ) ; createTool( SMESHOp::OpAspectRatio3D, ctrl3dTb ); createTool( SMESHOp::OpVolume, ctrl3dTb ); createTool( SMESHOp::OpMaxElementLength3D, ctrl3dTb ); @@ -4567,6 +4602,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb ); createTool( SMESHOp::OpEqualVolume, ctrl3dTb ); + int addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ) ; createTool( SMESHOp::OpNode, addElemTb ); createTool( SMESHOp::OpElem0D, addElemTb ); createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb ); @@ -4582,6 +4618,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createTool( SMESHOp::OpHexagonalPrism, addElemTb ); createTool( SMESHOp::OpPolyhedron, addElemTb ); + int addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ) ; createTool( SMESHOp::OpQuadraticEdge, addNonElemTb ); createTool( SMESHOp::OpQuadraticTriangle, addNonElemTb ); createTool( SMESHOp::OpBiQuadraticTriangle, addNonElemTb ); @@ -4595,14 +4632,17 @@ void SMESHGUI::initialize( CAM_Application* app ) createTool( SMESHOp::OpQuadraticHexahedron, addNonElemTb ); createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb ); + int remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ) ; createTool( SMESHOp::OpRemoveNodes, remTb ); createTool( SMESHOp::OpRemoveElements, remTb ); createTool( SMESHOp::OpRemoveOrphanNodes, remTb ); createTool( SMESHOp::OpClearMesh, remTb ); +// int renumbTb = createTool( tr( "TB_RENUMBER" ), QString( "SMESHRenumberingToolbar" ) ) ; //createTool( SMESHOp::OpRenumberingNodes, renumbTb ); //createTool( SMESHOp::OpRenumberingElements, renumbTb ); + int transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ) ; createTool( SMESHOp::OpMergeNodes, transformTb ); createTool( SMESHOp::OpMergeElements, transformTb ); createTool( SMESHOp::OpTranslation, transformTb ); @@ -4613,6 +4653,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createTool( SMESHOp::OpSewing, transformTb ); createTool( SMESHOp::OpDuplicateNodes, transformTb ); + int modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ) ; createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb ); createTool( SMESHOp::OpCreateBoundaryElements, modifyTb ); createTool( SMESHOp::OpExtrusion, modifyTb ); @@ -4630,8 +4671,21 @@ void SMESHGUI::initialize( CAM_Application* app ) createTool( SMESHOp::OpSmoothing, modifyTb ); createTool( SMESHOp::OpPatternMapping, modifyTb ); + // Adaptation - begin + int adaptTb = createTool( tr( "TB_ADAPTATION" ),QString( "SMESHAdaptationToolbar" ) ) ; + createTool( SMESHOp::OpUniformRefinement, adaptTb ); + createTool( SMESHOp::OpHONewCase, adaptTb ); + createTool( SMESHOp::OpHOCaseFollow, adaptTb ); + createTool( SMESHOp::OpHONewIter, adaptTb ); + createTool( SMESHOp::OpHOIterCompute, adaptTb ); + createTool( SMESHOp::OpHOIterComputePublish, adaptTb ); + createTool( SMESHOp::OpMGAdapt, adaptTb ); + // Adaptation - end + + int measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ) ; createTool( SMESHOp::OpMinimumDistance, measuremTb ); + int dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) ); createTool( SMESHOp::OpUpdate, dispModeTb ); QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality(); @@ -4707,9 +4761,17 @@ void SMESHGUI::initialize( CAM_Application* app ) popupMgr()->insert( separator(), -1, 0 ); createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh, "&& " + hasElems ); createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2"); - //popupMgr()->insert( separator(), -1, 0 ); + popupMgr()->insert( separator(), -1, 0 ); - //popupMgr()->insert( separator(), -1, 0 ); + // Adaptation - begin + createPopupItem( SMESHOp::OpUniformRefinement, OB, mesh ); + createPopupItem( SMESHOp::OpHONewCase, OB, mesh ); +// createPopupItem( SMESHOp::OpHOCaseFollow, OB, mesh ); +// createPopupItem( SMESHOp::OpHONewIter, OB, mesh ); +// createPopupItem( SMESHOp::OpHOIterCompute, OB, mesh ); +// createPopupItem( SMESHOp::OpHOIterComputePublish, OB, mesh ); + createPopupItem( SMESHOp::OpMGAdapt, OB, mesh ); + // Adaptation - end QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc ); QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc ); @@ -5366,7 +5428,7 @@ void SMESHGUI::createPreferences() setPreferenceProperty( dispgroup, "columns", 2 ); addPreference( tr( "PREF_FITALL_ON_DISPLAYONLY" ), dispgroup, LightApp_Preferences::Bool, "SMESH", "fitall_on_displayonly" ); - + int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" ); QStringList modes; modes.append( tr("MEN_WIRE") ); @@ -5743,6 +5805,57 @@ void SMESHGUI::createPreferences() setPreferenceProperty( coloringType, "indexes", indices ); addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" ); + // Adaptation - begin + // Adaptation tab ------------------------------------------------------------------------ + int adaptTab = addPreference( tr( "ADAPT_PREF_TAB_GENERAL" ) ); + int bloc, pref ; + // Refinement with HOMARD + bloc = addPreference( tr( "ADAPT_PREF_HOMARD_PUBLICATION" ), adaptTab ); + setPreferenceProperty( bloc, "columns", 1 ); + pref = addPreference( tr( "ADAPT_PREF_HOMARD_PUBLICATION_MAILLAGE_IN" ), bloc, LightApp_Preferences::Bool, "HOMARD", "homard_publish_mesh_in" ); + pref = addPreference( tr( "ADAPT_PREF_HOMARD_PUBLICATION_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "homard_publish_mesh_out" ); + + // YACS with HOMARD + bloc = addPreference( tr( "ADAPT_PREF_HOMARD_YACS" ), adaptTab ); + setPreferenceProperty( bloc, "columns", 1 ); + pref = addPreference( tr( "ADAPT_PREF_HOMARD_YACS_MAX_ITER" ), bloc, LightApp_Preferences::IntSpin, "HOMARD", "homard_yacs_max_iter" ); + setPreferenceProperty( pref, "min", 0 ); + setPreferenceProperty( pref, "max", 100000000 ); + setPreferenceProperty( pref, "step", 1 ); + pref = addPreference( tr( "ADAPT_PREF_HOMARD_YACS_MAX_NODE" ), bloc, LightApp_Preferences::IntSpin, "HOMARD", "homard_yacs_max_node" ); + setPreferenceProperty( pref, "min", 0 ); + setPreferenceProperty( pref, "max", 100000000 ); + setPreferenceProperty( pref, "step", 1000 ); + pref = addPreference( tr( "ADAPT_PREF_HOMARD_YACS_MAX_ELEM" ), bloc, LightApp_Preferences::IntSpin, "HOMARD", "homard_yacs_max_elem" ); + setPreferenceProperty( pref, "min", 0 ); + setPreferenceProperty( pref, "max", 100000000 ); + setPreferenceProperty( pref, "step", 1000 ); + pref = addPreference( tr( "ADAPT_PREF_HOMARD_YACS_TYPE_CONVERGENCE" ), bloc, LightApp_Preferences::Selector, "HOMARD", "homard_yacs_type_test" ); + QStringList aListOfTypeTest; + aListOfTypeTest << tr( "ADAPT_PREF_NONE" ); + aListOfTypeTest << "VTest > VRef"; + aListOfTypeTest << "VTest < VRef"; + setPreferenceProperty( pref, "strings", aListOfTypeTest ); + + // MG-Adapt + bloc = addPreference( tr( "ADAPT_PREF_MG_ADAPT" ), adaptTab ); + setPreferenceProperty( bloc, "columns", 1 ); + pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_FILE_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_file_mesh_out" ); + pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_PUBLICATION_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_publish_mesh_out" ); + pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_size_map" ); + QStringList aListOfSizeMap; + aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_LOCAL" ); + aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_BACKGROUND" ); + aListOfSizeMap << tr( "ADAPT_PREF_NONE" );; + setPreferenceProperty( pref, "strings", aListOfSizeMap ); + pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_time_step" ); + QStringList aListOfTimeStep; + aListOfTimeStep << tr( "ADAPT_PREF_NONE" ); + aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_LAST" ); + aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_C" );; + setPreferenceProperty( pref, "strings", aListOfTimeStep ); + // Adaptation - end + } void SMESHGUI::preferencesChanged( const QString& sect, const QString& name ) @@ -5956,6 +6069,18 @@ LightApp_Operation* SMESHGUI::createOperation( const int id ) const case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes op = new SMESHGUI_Add0DElemsOnAllNodesOp(); break; + // Adaptation - begin + case SMESHOp::OpUniformRefinement: + case SMESHOp::OpHONewCase: + case SMESHOp::OpHOCaseFollow: + case SMESHOp::OpHONewIter: + case SMESHOp::OpHOIterCompute: + case SMESHOp::OpHOIterComputePublish: + case SMESHOp::OpHOEdit: + case SMESHOp::OpHODelete: + case SMESHOp::OpMGAdapt: + break; + // Adaptation - end default: break; } diff --git a/src/SMESHGUI/SMESHGUI_AdaptDlg.cxx b/src/SMESHGUI/SMESHGUI_AdaptDlg.cxx new file mode 100644 index 000000000..afd74b0dd --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_AdaptDlg.cxx @@ -0,0 +1,246 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// SMESH SMESHGUI : GUI for the adaptation in the SMESH component +// File : SMESHGUI_AdaptDlg.cxx +// Author : Gerald NICOLAS, EDF + +// SMESH includes +#include "SMESHGUI.h" +#include "SMESHGUI_AdaptDlg.h" +#include "SMESHGUI_MG_ADAPTDRIVER.h" +//~#include "MG_ADAPT_i.hxx" +//~#include "MG_ADAPT.hxx" + +// SALOME GUI includes +#include +#include +#include +#include +#include + +// HOMARD includes +// #include "MonCreateCase.h" + +// SALOME KERNEL includes +#include "utilities.h" +#include + +//================================================================================= +// function : SMESHGUI_AdaptDlg() +// purpose : +//================================================================================= +SMESHGUI_AdaptDlg::SMESHGUI_AdaptDlg( SMESHGUI* theModule, + int theCommandID, + SMESH::SMESH_Mesh_ptr theMesh ) + : mySMESHGUI( theModule ) +{ + action( theCommandID ) ; +} + +//================================================================================= +// function : ~SMESHGUI_AdaptDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_AdaptDlg::~SMESHGUI_AdaptDlg() +{ +} + +/*! + * \brief Pilote les actions d'adaption de maillage + * \param + * \return bool OK/notOK +*/ +void SMESHGUI_AdaptDlg::action (int theCommandID) +//======================================================================= +{ + std::cout << "SMESHGUI_AdaptDlg::action avec theCommandID : " << theCommandID << std::endl; + +// Preferences +// recupPreferences(); + +// Menus and actions + bool ok = OnGUIEvent (theCommandID) ; + if ( ! ok ) INFOS("Erreur"); + + return ; +} + +// /*! +// * \brief Gets the preferences for the adaptation +// * \param +// * \return +// * +// * Pour chaque valeur, le defaut est la valeur definie dans ADAPT_Gen +// * . Si la recuperation dans config/salome s'est bien passee a la creation de ADAPT_Gen +// * ces valeurs sont les valeurs definies. +// * . Si cela ne s'est pas bien passe, ce sont les valeurs par defaut de ADAPT_Gen +// */ +// void SMESHGUI_AdaptDlg::recupPreferences() +// { +// INFOS("Début de recupPreferences") +// // +// // A. Declarations +// // +// SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); +// SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService()); +// Engines::EngineComponent_var comp = ls->FindOrLoad_Component("FactoryServer", "SMESH"); +// ADAPT::ADAPT_Gen_var adaptGen = ADAPT::ADAPT_Gen::_narrow(comp); +// if (!CORBA::is_nil(adaptGen)) +// adaptGen->UpdateStudy(); +// +// SUIT_ResourceMgr* resMgr = mySMESHGUI->getApp()->resourceMgr(); +// +// // B. Les valeurs +// // B.1. La langue +// +// _LanguageShort = resMgr->stringValue("language", "language", "en" ); +// INFOS ("Enregistrement de LanguageShort = " << _LanguageShort.toStdString().c_str() ); +// // adaptGen->SetLanguageShort(_LanguageShort.toStdString().c_str()); +// +// // B.2. Les publications avec HOMARD +// bool publish_mesh ; +// +// publish_mesh = resMgr->booleanValue("HOMARD", "homard_publish_mesh_in", false ); +// if ( publish_mesh ) { _PublisMeshIN = 1 ; } +// else { _PublisMeshIN = 0 ; } +// +// publish_mesh = resMgr->booleanValue("HOMARD", "homard_publish_mesh_out", false ); +// if ( publish_mesh ) { _PublisMeshOUT = 1 ; } +// else { _PublisMeshOUT = 0 ; } +// +// INFOS ("Enregistrement de PublisMeshIN = " << _PublisMeshIN<<", PublisMeshOUT = "<< _PublisMeshOUT); +// // adaptGen->SetPublisMesh(_PublisMeshIN, _PublisMeshOUT); +// +// // B.3. Les maximum pour YACS avec HOMARD +// +// _YACSMaxIter = resMgr->integerValue("HOMARD", "homard_yacs_max_iter", 0 ); +// _YACSMaxNode = resMgr->integerValue("HOMARD", "homard_yacs_max_node", 0 ); +// _YACSMaxElem = resMgr->integerValue("HOMARD", "homard_yacs_max_elem", 0 ); +// +// INFOS ("Enregistrement de YACSMaxIter = " << _YACSMaxIter<<", YACSMaxNode = "<< _YACSMaxNode<<", YACSMaxElem = "<< _YACSMaxElem); +// // adaptGen->SetYACSMaximum(_YACSMaxIter, _YACSMaxNode, _YACSMaxElem); +// +// // B.4. La convergence pour YACS avec HOMARD +// +// QString QString_v = resMgr->stringValue ( "HOMARD", "homard_yacs_type_test", "None" ); +// if ( ( QString_v == "VTest > VRef" ) || ( QString_v == "VTest > VRef" ) ) { _YACSTypeTest = 1 ; } +// else if ( ( QString_v == "VTest < VRef" ) || ( QString_v == "VTest < VRef" ) ) { _YACSTypeTest = 2 ; } +// else { _YACSTypeTest = 0 ; } +// +// INFOS ("Enregistrement de YACSTypeTest = " << _YACSTypeTest); +// // adaptGen->SetYACSConvergenceType(_YACSTypeTest); +// +// } + +/*! + * \brief Launches the GUI for the adaptation + * \param theCommandID - the integer that references the operation + * \return bool OK/notOK +*/ +bool SMESHGUI_AdaptDlg::OnGUIEvent (int theCommandID) +{ + std::cout << "OnGUIEvent avec theCommandID : " << theCommandID << std::endl; +// A. Controles + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( !app ) return false; + + SalomeApp_Study* aStudy = dynamic_cast ( app->activeStudy() ); + if ( !aStudy ) + { + INFOS ( "FAILED to cast active study to SalomeApp_Study" ); + return false; + } + + SUIT_Desktop* parent = SUIT_Session::session()->activeApplication()->desktop(); + + SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService()); + Engines::EngineComponent_var comp = ls->FindOrLoad_Component("FactoryServer", "SMESH"); +// ADAPT::ADAPT_Gen_var adaptGen = ADAPT::ADAPT_Gen::_narrow(comp); +// if (!CORBA::is_nil(adaptGen)) +// adaptGen->UpdateStudy(); + + mySMESHGUI->getApp()->updateObjectBrowser(); +// +// B. Choix selon les commandes + bool ok = true ; + SCRUTE(theCommandID); + switch (theCommandID) + { + case 8000: // Raffinement uniforme + { + INFOS("Raffinement uniforme"); +// A faire + break; + } + case 8011: // Création d'un Cas + { + INFOS("Création d'un Cas"); +// MonCreateCase *aDlg = new MonCreateCase( true, +// ADAPT::ADAPT_Gen::_duplicate(adaptGen) ) ; +// aDlg->show(); + break; + } + case 8012: // Création d'un cas en poursuite d'une itération + { + INFOS("Création d'un cas en poursuite d'une itération"); +// A faire + break; + } + case 8013: // Création d'une itération + { + INFOS("Création d'une itération" ); +// A faire + break; + } + case 8014: // Calcule une itération + { + INFOS("Calcule une itération" ); +// A faire + break; + } + case 8015: // Calcule une itération et publication + { + INFOS("Calcule une itération et publication"); +// A faire + break; + } + case 8020: // Adaptation avec MG-Adpat + { + INFOS("Interface avec MG-Adapt" ); +// A faire + + SMESH::MG_ADAPT_ptr model = SMESHGUI::GetSMESHGen()->CreateMG_ADAPT();// = new SMESH::MG_ADAPT_var(); + //~SMESH::MG_ADAPT_ptr model = SMESH::MG_ADAPT_i::CreateMG_ADAPT(); + bool isCreation = false; + if (mySMESHGUI->isStudyLocked()) break; + mySMESHGUI->EmitSignalDeactivateDialog(); + SMESHGUI_MG_ADAPTDRIVER *mgAdapt = new SMESHGUI_MG_ADAPTDRIVER(mySMESHGUI, model, isCreation); + mgAdapt->show(); + //~delete model; + break; + } + + } + mySMESHGUI->getApp()->updateObjectBrowser(); + return ok; +} + + + diff --git a/src/SMESHGUI/SMESHGUI_AdaptDlg.h b/src/SMESHGUI/SMESHGUI_AdaptDlg.h new file mode 100644 index 000000000..1231b067e --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_AdaptDlg.h @@ -0,0 +1,77 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// SMESH SMESHGUI : GUI for the adaptation in the SMESH component +// File : SMESHGUI_AdaptDlg.h +// Author : Gérald NICOLAS, EDF +// +#ifndef SMESHGUI_ADAPTDLG_H +#define SMESHGUI_ADAPTDLG_H + +// SMESH includes +#include "SMESH_SMESHGUI.hxx" + +// Qt includes +#include + +// IDL includes +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +class SMESHGUI; + +//================================================================================= +// class : SMESHGUI_AdaptDlg +// purpose : +//================================================================================= +class SMESHGUI_EXPORT SMESHGUI_AdaptDlg : public QWidget +{ +public: + SMESHGUI_AdaptDlg( SMESHGUI*, + int theCommandID, + SMESH::SMESH_Mesh_ptr = SMESH::SMESH_Mesh::_nil() ); + ~SMESHGUI_AdaptDlg(); + + void action (int theCommandID); + virtual bool OnGUIEvent (int theCommandID); + +// static ADAPT::ADAPT_Gen_var InitAdaptGen(SalomeApp_Application*); + +public slots: + +protected slots: + +private slots: + +private: + +// void recupPreferences(); + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ + + QString _ObjectName; + QString _LanguageShort ; + int _PublisMeshIN ; + int _PublisMeshOUT ; + int _YACSMaxIter ; + int _YACSMaxNode ; + int _YACSMaxElem ; + int _YACSTypeTest ; +}; + +#endif // SMESHGUI_ADAPTDLG_H diff --git a/src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.cxx b/src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.cxx new file mode 100644 index 000000000..85a719b40 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.cxx @@ -0,0 +1,752 @@ +// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : SMESHGUI_MG_ADAPTDRIVER.cxx + +#include "SMESHGUI_MG_ADAPTDRIVER.h" + +#include "SUIT_Desktop.h" +#include "SUIT_Application.h" +#include "SUIT_Session.h" + +#include "SalomeApp_Application.h" +#include "SalomeApp_Module.h" +#include "SalomeApp_Study.h" + +#include "SMESH_Comment.hxx" +#include "SMESH_Actor.h" +#include "SMESHGUI.h" +#include "SMESHGUI_FilterDlg.h" +#include "SMESHGUI_Selection.h" +#include +#include "SMESHGUI_IdValidator.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_MeshEditPreview.h" +#include "SMESHGUI_VTKUtils.h" +#include +#include +#include +#include +#include +#include "SMESHGUI_SpinBox.h" + +#include +#include +#include +#include +#include +#include +#include "SMESHGUI_MeshUtils.h" + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +// SALOME KERNEL includes +#include +#include +#include +#include +#include "SalomeApp_Tools.h" +#include +#include +#include + +#include + +const int SPACING = 6; // layout spacing +const int MARGIN = 9; // layout margin + +SALOME_ListIO mySelected; + + +//================================================================ +// Function : firstIObject +// Purpose : Return the first selected object in the selected object list +//================================================================ +Handle(SALOME_InteractiveObject) firstIObject() +{ + const SALOME_ListIO& aList = selectedIO(); + return aList.Extent() > 0 ? aList.First() : Handle(SALOME_InteractiveObject)(); +} +//================================================================ +// Function : selectedIO +// Return the list of selected SALOME_InteractiveObject's +//================================================================ +const SALOME_ListIO& selectedIO() +{ + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* > ( SUIT_Session::session()->activeApplication() ); + LightApp_SelectionMgr* aSelectionMgr = app->selectionMgr(); + if( aSelectionMgr ) + { + aSelectionMgr->selectedObjects( mySelected ); + for (SALOME_ListIteratorOfListIO it (mySelected); it.More(); it.Next()) + SCRUTE(it.Value()->getEntry()); + }; + return mySelected; +} +//================================================================ +// Function : getStudy +// Returne un pointeur sur l'etude active +//================================================================ +_PTR(Study) getStudy() +{ + static _PTR(Study) _study; + if(!_study) + _study = SalomeApp_Application::getStudy(); + return _study; +} + +bool createAndPublishMed(QString fileName) +{ + + SMESH::DriverMED_ReadStatus res; + SMESH::mesh_array_var aMeshes = new SMESH::mesh_array; + // SMESHGUI aGui; + + aMeshes = SMESHGUI::GetSMESHGen()->CreateMeshesFromMED( fileName.toUtf8().constData(), res ); + _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[0] ); + _PTR(Study) aStudy = SMESH::getStudy(); + QStringList anEntryList; + // bool isEmpty; + if ( aMeshSO ) { + _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder(); + _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" ); + aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" ); + anEntryList.append( aMeshSO->GetID().c_str() ); + } + else { + // isEmpty = true; + return false; + } + SMESHGUI::GetSMESHGUI()->updateObjBrowser(); + + // browse to the published meshes + if( LightApp_Application* anApp = + dynamic_cast( SUIT_Session::session()->activeApplication() ) ) + anApp->browseObjects( anEntryList ); + return true; +} +bool createMgAdaptObject(MgAdapt *myMgAdapt ) +{ + // SMESH::SMESH_Mesh_var newMesh = SMESHGUI::GetSMESHGen()->CreateEmptyMesh(); + + // _PTR(SObject) aHypothesis; + _PTR(Study) aStudy = SMESH::getStudy(); + QStringList anEntryList; + _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder(); + _PTR(SComponent) mgadapt = aStudy->FindComponent("MG-ADAPT"); + _PTR(GenericAttribute) ga; + if (!aBuilder->FindAttribute(mgadapt, ga, "AttributeName") ) + { + mgadapt = aBuilder->NewComponent("MG-ADAPT"); + _PTR(AttributeName) Name = aBuilder->FindOrCreateAttribute(mgadapt, "AttributeName"); + Name->SetValue("MG-ADAPT"); + _PTR(AttributePixMap) myPixmap = aBuilder->FindOrCreateAttribute( mgadapt, "AttributePixMap" ); + myPixmap->SetPixMap( "ICON_MG_ADAPT" ); + anEntryList.append( mgadapt->GetID().c_str() ); + } + + _PTR(SObject) obj = aBuilder->NewObject(mgadapt); + _PTR(AttributeName) myName = aBuilder->FindOrCreateAttribute(obj, "AttributeName"); + myName->SetValue("hypo"); + _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( obj, "AttributePixMap" ); + aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO" ); + anEntryList.append( obj->GetID().c_str() ); + + SMESHGUI::GetSMESHGUI()->updateObjBrowser(); + + // // browse to the published meshes + if( LightApp_Application* anApp = + dynamic_cast( SUIT_Session::session()->activeApplication() ) ) + anApp->browseObjects( anEntryList ); + return true; +} + + +// MG ADAPT UTILS +//================================================================ +// Function : IObjectCount +// Return the number of selected objects +//================================================================ +int IObjectCount() +{ + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + LightApp_SelectionMgr* aSelectionMgr = app->selectionMgr(); + if( aSelectionMgr ) + { + aSelectionMgr->selectedObjects( mySelected ); + SCRUTE(mySelected.Extent()); + return mySelected.Extent(); + } + return 0; +} + + + +SMESHGUI_MG_ADAPTDRIVER::SMESHGUI_MG_ADAPTDRIVER( SMESHGUI* theModule, SMESH::MG_ADAPT_ptr myModel, bool isCreation ) + : mySMESHGUI( theModule ), + myFilterDlg(0), + myIsApplyAndClose( false ), + SMESHGUI_MgAdaptDlg((SalomeApp_Module*)theModule, myModel, SMESHGUI::desktop(), isCreation) +{ + + resMgr = resourceMgr(); + + selMgr = selectionMgr(); + + // connections + connect(myArgs, SIGNAL(updateSelection()), this, SLOT(updateSelection())); + connect(myArgs, SIGNAL(toExportMED(const char*)), this, SLOT(exportMED(const char*))); +} + +SUIT_ResourceMgr* SMESHGUI_MG_ADAPTDRIVER::resourceMgr() +{ + return dynamic_cast( SUIT_Session::session()->resourceMgr() ); +} + +LightApp_SelectionMgr* SMESHGUI_MG_ADAPTDRIVER::selectionMgr() +{ + SalomeApp_Application* anApp = dynamic_cast( SUIT_Session::session()->activeApplication() ); + if( anApp ) + return dynamic_cast( anApp->selectionMgr() ); + else + return 0; +} + +void SMESHGUI_MG_ADAPTDRIVER::updateSelection() +{ + disconnect( selMgr, 0, this, 0 ); + selMgr->clearFilters(); + + SMESH::SetPointRepresentation( true ); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() ) + aViewWindow->SetSelectionMode( ActorSelection ); + if (myArgs->aBrowser->isChecked()) + { + connect( selMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( selectionChanged() )); + selectionChanged(); + } + +} +void SMESHGUI_MG_ADAPTDRIVER::selectionChanged() +{ + //~ get selected mesh + SALOME_ListIO aList; + selMgr->selectedObjects(aList); + QString aString = ""; + int nbSel = aList.Extent(); + if (nbSel != 1) + return; + + Handle(SALOME_InteractiveObject) IO = aList.First(); + SMESH::SMESH_Mesh_var mesh = SMESH::GetMeshByIO(IO); + if ( !mesh->_is_nil() ) + { + myMesh = mesh; + + mySelectedObject = SMESH::IObjectToInterface( IO ); + if ( mySelectedObject->_is_nil() ) + return; + + } + else + return; + + SMESH::GetNameOfSelectedIObjects( selMgr, aString ); + if ( aString.isEmpty() ) aString = " "; + else aString = aString.trimmed(); + + + bool ok = !aString.isEmpty(); + if ( !mesh->_is_nil() ) + { + myArgs->aBrowserObject->setText( aString ); + myArgs->meshNameLineEdit->setText( aString ); + myArgs->selectOutMedFileLineEdit->setText(aString+QString(".med")); + ADAPTATION_MODE aMode; + int nbVolumes = myMesh->NbVolumes(); + int nbFaces = myMesh->NbFaces(); + if(nbFaces > 0 && nbVolumes > 0) aMode = ADAPTATION_MODE::BOTH; + else if(nbFaces > 0) aMode = ADAPTATION_MODE::SURFACE; + else aMode = ADAPTATION_MODE::VOLUME; + emit myArgs->meshDimSignal(aMode); + } + +} +void SMESHGUI_MG_ADAPTDRIVER::exportMED(const char* tmp_file) +{ + bool toOverwrite = true; + bool toFindOutDim = true; + myMesh->ExportMED(tmp_file, false, -1, toOverwrite, toFindOutDim); +} +void SMESHGUI_MG_ADAPTDRIVER::setMyMesh(SMESH::SMESH_Mesh_var mesh) +{ + myMesh = mesh; +} +SMESH::SMESH_Mesh_var SMESHGUI_MG_ADAPTDRIVER::getMyMesh() +{ + return myMesh; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_MG_ADAPTDRIVER::clickOnOk() +{ + setIsApplyAndClose( true ); + clickOnApply(); + reject(); +} +bool SMESHGUI_MG_ADAPTDRIVER::clickOnApply() +{ + + if ( SMESHGUI::isStudyLocked() ) + return false; + if( !isValid() ) + return false; + + SMESHGUI_MgAdaptDlg::clickOnApply(); + + bool ok = execute(); + if (getModel()->getPublish()) this->createMeshInObjectBrowser(); + + return ok; +} + +bool SMESHGUI_MG_ADAPTDRIVER::execute() +{ + + int err; + //~std::string errStr; + char* errStr; + try + { + err = getModel()->compute(); + errStr = getModel()->getErrMsg(); + std::string msg = err == 0 ? " ok" : std::string("Not ok \n")+CORBA::string_dup(errStr) ; + } + catch (const std::exception& e) + { + std::cerr<clear(); + myNbOkElements = 0; + + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); + + //~myActor = 0; + myMesh = SMESH::SMESH_Mesh::_nil(); + + myIdSourceCheck->setChecked(true); + + onConstructor( 0 ); + } + +} + +//======================================================================= +//function : onConstructor +//purpose : switch operation mode +//======================================================================= + +void SMESHGUI_MG_ADAPTDRIVER::onConstructor( int withGeom ) +{ + + myGeomLabel ->setVisible( withGeom ); + myGeomNameEdit ->setVisible( withGeom ); + myReuseHypCheck ->setVisible( withGeom ); + myCopyElementsCheck->setVisible( withGeom ); + myFilterBtn ->setVisible( !withGeom ); + myIdSourceCheck ->setVisible( !withGeom ); + + if ( !withGeom ) + myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh")); + +} + + +//~void SMESHGUI_MG_ADAPTDRIVER::onSelectIdSource( bool ) +//~{} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_MG_ADAPTDRIVER::enterEvent (QEvent*) +{ + + // if ( !ConstructorsBox->isEnabled() ) { + // SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ); + // if ( aViewWindow && !mySelector ) { + // mySelector = aViewWindow->GetSelector(); + // } + // activateThisDialog(); + // } + +} + +//================================================================================= +// function : keyPressEvent() +// purpose : +//================================================================================= +void SMESHGUI_MG_ADAPTDRIVER::keyPressEvent( QKeyEvent* e ) +{ + + QDialog::keyPressEvent( e ); + if ( e->isAccepted() ) + return; + + if ( e->key() == Qt::Key_F1 ) { + e->accept(); + clickOnHelp(); + } + +} + +//================================================================================= +// function : clickOnHelp() +// purpose : +//================================================================================= +void SMESHGUI_MG_ADAPTDRIVER::clickOnHelp() +{ + + LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) + app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName); + else { + QString platform; +#ifdef WIN32 + platform = "winapplication"; +#else + platform = "application"; +#endif + SUIT_MessageBox::warning(this, tr("WRN_WARNING"), + tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", + platform)). + arg(myHelpFileName)); + } + +} + +//======================================================================= +//function : getErrorMsg +//purpose : Return an error message and entries of invalid smesh object +//======================================================================= + +QString SMESHGUI_MG_ADAPTDRIVER::getErrorMsg( SMESH::string_array_var theInvalidEntries, + QStringList & theEntriesToBrowse ) +{ + + if ( theInvalidEntries->length() == 0 ) + return tr("OPERATION_FAILED"); + + // theInvalidEntries - SObject's that hold geometry objects whose + // counterparts are not found in the newGeometry, followed by SObject's + // holding mesh sub-objects that are invalid because they depend on a not found + // preceding sub-shape + + QString msg = tr("SUBSHAPES_NOT_FOUND_MSG") + "\n"; + + QString objString; + for ( CORBA::ULong i = 0; i < theInvalidEntries->length(); ++i ) + { + _PTR(SObject) so = SMESH::getStudy()->FindObjectID( theInvalidEntries[i].in() ); + + int objType = SMESHGUI_Selection::type( theInvalidEntries[i].in() ); + if ( objType < 0 ) // geom object + { + objString += "\n"; + if ( so ) + objString += so->GetName().c_str(); + else + objString += theInvalidEntries[i].in(); // it's something like "FACE #2" + } + else // smesh object + { + theEntriesToBrowse.push_back( theInvalidEntries[i].in() ); + + objString += "\n "; + switch ( objType ) { + case SMESH::MESH: + objString += tr("SMESH_MESH"); + break; + case SMESH::HYPOTHESIS: + objString += tr("SMESH_HYPOTHESIS"); + break; + case SMESH::ALGORITHM: + objString += tr("SMESH_ALGORITHM"); + break; + case SMESH::SUBMESH_VERTEX: + case SMESH::SUBMESH_EDGE: + case SMESH::SUBMESH_FACE: + case SMESH::SUBMESH_SOLID: + case SMESH::SUBMESH_COMPOUND: + case SMESH::SUBMESH: + objString += tr("SMESH_SUBMESH"); + break; + case SMESH::GROUP: + objString += tr("SMESH_GROUP"); + break; + default: + ; + } + objString += " \""; + if ( so ) + objString += so->GetName().c_str(); + objString += "\" ("; + objString += theInvalidEntries[i].in(); + objString += ")"; + } + } + if ( !objString.isEmpty() ) + msg += objString; + + return msg; +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= + +bool SMESHGUI_MG_ADAPTDRIVER::isValid() +{ + bool ok = true; + return ok; +} + +bool SMESHGUI_MG_ADAPTDRIVER::createMeshInObjectBrowser() +{ + QString filename(getModel()->getMedFileOut()); + QStringList errors; + QStringList anEntryList; + bool isEmpty = false; + bool ok = false; + SMESH::SMESH_Gen_var SMESH_Gen_ptr = SMESHGUI::GetSMESHGen(); + if (!SMESH_Gen_ptr) { + std::cerr << "Could not retrieve SMESH_Gen_ptr" << std::endl; + throw SALOME_Exception(LOCALIZED("Could not retrieve SMESH::GetSMESHGen()")); + } + SMESH::mesh_array_var aMeshes = new SMESH::mesh_array; + aMeshes->length( 1 ); // one mesh only + SMESH::DriverMED_ReadStatus res; + aMeshes = SMESH_Gen_ptr->CreateMeshesFromMED( filename.toUtf8().constData(), res ); + if ( res != SMESH::DRS_OK ) { + errors.append( QString( "%1 :\n\t%2" ).arg( filename ).arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) ); + } + _PTR(Study) aStudy = SMESH::getStudy(); + for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) + { + _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] ); + if ( aMeshSO ) { + _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder(); + _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" ); + aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" ); // put REFINED mesh ico + anEntryList.append( aMeshSO->GetID().c_str() ); + } + else { + isEmpty = true; + } + } + // update Object browser + SMESHGUI::GetSMESHGUI()->updateObjBrowser(); + // browse to the published meshes + if( LightApp_Application* anApp = + dynamic_cast( SUIT_Session::session()->activeApplication() ) ) + anApp->browseObjects( anEntryList ); + + // show Error message box if there were errors + if ( errors.count() > 0 ) { + SUIT_MessageBox::critical( SMESHGUI::desktop(), + QObject::tr( "SMESH_ERROR" ), + QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) ); + } + + // show warning message box, if some imported mesh is empty + if ( isEmpty ) { + SUIT_MessageBox::warning( SMESHGUI::desktop(), + QObject::tr( "SMESH_WRN_WARNING" ), + QObject::tr( "SMESH_DRS_SOME_EMPTY" ) ); + } + return true; +} + +//================================================================ +// function : setIsApplyAndClose +// Purpose : Set value of the flag indicating that the dialog is +// accepted by Apply & Close button +//================================================================ +void SMESHGUI_MG_ADAPTDRIVER::setIsApplyAndClose( const bool theFlag ) +{ + myIsApplyAndClose = theFlag; +}//================================================================ +// function : isApplyAndClose +// Purpose : Get value of the flag indicating that the dialog is +// accepted by Apply & Close button +//================================================================ +bool SMESHGUI_MG_ADAPTDRIVER::isApplyAndClose() const +{ + return myIsApplyAndClose; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_MG_ADAPTDRIVER::deactivateActiveDialog() +{ + + if (ConstructorsBox->isEnabled()) { + ConstructorsBox->setEnabled(false); + GroupArguments->setEnabled(false); + GroupButtons->setEnabled(false); + mySMESHGUI->ResetState(); + mySMESHGUI->SetActiveDialogBox(0); + if ( selMgr ) + selMgr->removeFilter( myIdSourceFilter ); + } +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_MG_ADAPTDRIVER::activateThisDialog() +{ + + /* Emit a signal to deactivate the active dialog */ + // mySMESHGUI->EmitSignalDeactivateDialog(); + // ConstructorsBox->setEnabled(true); + // GroupArguments->setEnabled(true); + // GroupButtons->setEnabled(true); + + // mySMESHGUI->SetActiveDialogBox((QDialog*)this); + + // onSelectIdSource( myIdSourceCheck->isChecked() ); + + // SelectionIntoArgument(); +} + +//================================================================================= +// function : setFilters() +// purpose : SLOT. Called when "Filter" button pressed. +//================================================================================= +void SMESHGUI_MG_ADAPTDRIVER::setFilters() +{ + if(myMesh->_is_nil()) { + SUIT_MessageBox::critical(this, + tr("SMESH_ERROR"), + tr("NO_MESH_SELECTED")); + return; + } + if ( !myFilterDlg ) + myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL ); + + QList types; + if ( myMesh->NbEdges() ) types << SMESH::EDGE; + if ( myMesh->NbFaces() ) types << SMESH::FACE; + if ( myMesh->NbVolumes() ) types << SMESH::VOLUME; + if ( myMesh->NbBalls() ) types << SMESH::BALL; + if ( myMesh->Nb0DElements()) types << SMESH::ELEM0D; + if ( types.count() > 1 ) types << SMESH::ALL; + + myFilterDlg->Init( types ); + myFilterDlg->SetSelection(); + myFilterDlg->SetMesh( myMesh ); + myFilterDlg->SetSourceWg( myLineEditElements ); + + myFilterDlg->show(); +} + +//================================================================================= +// function : onOpenView() +// purpose : +//================================================================================= +void SMESHGUI_MG_ADAPTDRIVER::onOpenView() +{ + if ( mySelector ) { + SMESH::SetPointRepresentation(false); + } + else { + mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector(); + activateThisDialog(); + } +} + +//================================================================================= +// function : onCloseView() +// purpose : +//================================================================================= +void SMESHGUI_MG_ADAPTDRIVER::onCloseView() +{ + deactivateActiveDialog(); + mySelector = 0; +} diff --git a/src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.h b/src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.h new file mode 100644 index 000000000..e73a77795 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.h @@ -0,0 +1,212 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// SMESH SMESHGUI : GUI for the adaptation in the SMESH component +// File : SMESHGUI_MG_ADAPTDRIVER.h +// +#ifndef SMESHGUI_MG_ADAPTDRIVER_H +#define SMESHGUI_MG_ADAPTDRIVER_H + +#include +// SMESH includes +#include "SMESH_SMESHGUI.hxx" + +// Qt includes +#include +#include +#include + +#include + +#include "LightApp_DataOwner.h" +#include "SalomeApp_Application.h" +#include +#include +#include "SalomeApp_Module.h" +#include "SalomeApp_Study.h" +#include +#include +// model +//~#include "MG_ADAPT.h" +#include "MG_ADAPTGUI.hxx" +//~#include "MG_ADAPT.hxx" + +#include CORBA_SERVER_HEADER(MG_ADAPT) + +class SUIT_ViewWindow; +class SUIT_Desktop; +class SUIT_Study; +class SUIT_ResourceMgr; + +class CAM_Module; + +class SALOMEDSClient_Study; +class SALOMEDSClient_SObject; + +class SalomeApp_Study; +class SalomeApp_Module; +class LightApp_SelectionMgr; +class SUIT_SelectionFilter; + + +class QButtonGroup; +class QLineEdit; +class QGroupBox; +class QRadioButton; +class QLabel; +class QCheckBox; +class QGridLayout; +class QTabWidget; +class QDoubleSpinBox; +class QSpinBox; +class QTreeWidget; +class QTreeWidgetItem; +class QSpacerItem; +class QHBoxLayout; +class QItemDelegate; +class QComboBox; +class QObject; + + +// IDL includes +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_SERVER_HEADER(SMESH_Gen) +class SMESHGUI; +class SMESHGUI_MgAdaptDlg; +class SMESHGUI_IdValidator; +class SMESHGUI_FilterDlg; +class MgAdapt; +class QHeaderView; +class QFileDialog; + + +int IObjectCount(); +const SALOME_ListIO& selectedIO(); +_PTR(Study) getStudy(); +Handle(SALOME_InteractiveObject) firstIObject(); +bool createAndPublishMed(QString fileName); +bool createMgAdaptObject(MgAdapt* myMgAdapt = 0); + + +class SMESHGUI_MG_ADAPTDRIVER : public SMESHGUI_MgAdaptDlg +{ + Q_OBJECT; + +public : + SMESHGUI_MG_ADAPTDRIVER( SMESHGUI*, SMESH::MG_ADAPT_ptr, bool isCreation = true ); + void setMyMesh(SMESH::SMESH_Mesh_var); + SMESH::SMESH_Mesh_var getMyMesh() ; + +private : + + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ + LightApp_SelectionMgr* selMgr ; + SUIT_ResourceMgr* resMgr; + SUIT_ResourceMgr* resourceMgr(); + LightApp_SelectionMgr* selectionMgr(); + SMESH::SMESH_Mesh_var myMesh ; + + + + void Init( bool = true ); + void enterEvent( QEvent* ); /* mouse enter the QWidget */ + void keyPressEvent( QKeyEvent* ); + QString getErrorMsg( SMESH::string_array_var invalidEntries, + QStringList & entriesToBrowse ); + + bool isValid(); + bool createMeshInObjectBrowser(); + void setIsApplyAndClose( const bool theFlag ); + bool isApplyAndClose() const; + bool execute(); + SMESHGUI_IdValidator* myIdValidator; + int myNbOkElements; /* to check when elements are defined */ + + SVTK_Selector* mySelector; + + bool myBusy; + GEOM::GEOM_Object_var myNewGeometry; + //~SMESH_Actor* myActor; // + SUIT_SelectionFilter* myIdSourceFilter; + + SMESH::SMESH_IDSource_var mySelectedObject; + + QTabWidget* myTabWidget; + QButtonGroup* GroupConstructors; + + QGroupBox* ConstructorsBox; + QGroupBox* GroupArguments; + QGroupBox* GroupButtons; + + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QPushButton* buttonHelp; + + QLabel* myTextLabelElements; + QLabel* myGeomLabel; + QLineEdit* myLineEditElements; + QLineEdit* myMeshNameEdit; + QLineEdit* myGeomNameEdit; + QCheckBox* myIdSourceCheck; + QCheckBox* myCopyGroupsCheck; + QCheckBox* myReuseHypCheck; + QCheckBox* myCopyElementsCheck; + QCheckBox* myKeepIdsCheck; + + QPushButton* myFilterBtn; + SMESHGUI_FilterDlg* myFilterDlg; + + QString myHelpFileName; + + bool myIsApplyAndClose; + + QString inputMeshName; + QString outputMeshName; +private slots: + void selectionChanged(); + void updateSelection(); + +protected slots : + +private slots: + + void exportMED(const char* ); + + virtual bool clickOnApply(); + virtual void clickOnOk(); + virtual void clickOnHelp(); + //~void SelectionIntoArgument(); + void deactivateActiveDialog(); + void activateThisDialog(); + void onConstructor( int ); + //~void onTextChange( const QString& ); + //~void onSelectIdSource( bool ); + void setFilters(); + void onOpenView(); + void onCloseView(); + + +}; + + + + +#endif // SMESHGUI_MG_ADAPTDRIVER_H diff --git a/src/SMESHGUI/SMESHGUI_Operations.h b/src/SMESHGUI/SMESHGUI_Operations.h index 2782458aa..6edc79469 100644 --- a/src/SMESHGUI/SMESHGUI_Operations.h +++ b/src/SMESHGUI/SMESHGUI_Operations.h @@ -186,6 +186,16 @@ namespace SMESHOp { OpConvertMeshToQuadratic = 4513, // MENU MODIFICATION - CONVERT TO/FROM QUADRATIC OpCreateBoundaryElements = 4514, // MENU MODIFICATION - CREATE BOUNDARY ELEMENTS OpSplitBiQuadratic = 4515, // MENU MODIFICATION - SPLIT BI-QUADRATIC TO LINEAR + // Adaptation ---------------------//-------------------------------- + OpUniformRefinement = 8000, // MENU ADAPTATION - HOMARD - UNIFORM REFINEMENT + OpHONewCase = 8011, // MENU ADAPTATION - HOMARD - FREE REFINEMENT - New Case + OpHOCaseFollow = 8012, // MENU ADAPTATION - HOMARD - FREE REFINEMENT - New Case Follow + OpHONewIter = 8013, // MENU ADAPTATION - HOMARD - FREE REFINEMENT - New Iteration + OpHOIterCompute = 8014, // MENU ADAPTATION - HOMARD - FREE REFINEMENT - Compute Iteration + OpHOIterComputePublish = 8015, // MENU ADAPTATION - HOMARD - FREE REFINEMENT - Compute Iteration and Publish + OpHOEdit = 8016, // MENU ADAPTATION - HOMARD - FREE REFINEMENT - Edit objects + OpHODelete = 8017, // MENU ADAPTATION - HOMARD - FREE REFINEMENT - Delete objects + OpMGAdapt = 8020, // MENU ADAPTATION - MG-ADAPT // Measurements -------------------//-------------------------------- OpPropertiesLength = 5000, // MENU MEASUREMENTS - BASIC PROPERTIES - LENGTH OpPropertiesArea = 5001, // MENU MEASUREMENTS - BASIC PROPERTIES - AREA diff --git a/src/SMESHGUI/SMESH_images.ts b/src/SMESHGUI/SMESH_images.ts index 932d60f07..635b11e5a 100644 --- a/src/SMESHGUI/SMESH_images.ts +++ b/src/SMESHGUI/SMESH_images.ts @@ -83,6 +83,34 @@ ICON_CREATE_GEO_GROUP mesh_groups_from_gemetry.png + + ICON_REF_ALL + adapt_ref_all.png + + + ICON_HOMARD_CREATE_CASE + adapt_ref_homard.png + + + ICON_HOMARD_FOLLOW_ITERATION + adapt_hom_iter_poursuite.png + + + ICON_HOMARD_NEW_ITERATION + adapt_hom_iter_next + + + ICON_HOMARD_COMPUTE + mesh_compute.png + + + ICON_HOMARD_COMPUTE_PUBLISH + mesh_compute.png + + + ICON_MG_ADAPT + adapt_mg_adapt.png + ICON_CONV_TO_QUAD mesh_conv_to_quad.png diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index cdbcfc114..fde42d2f4 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -340,6 +340,150 @@ MEN_CONSTRUCT_GROUP Construct Group + + MEN_REF_ALL + Uniform refinement + + + MEN_REF_HOMARD + Adaptation with HOMARD + + + MEN_HOMARD_CREATE_CASE + New case for adaptation with HOMARD + + + MEN_HOMARD_FOLLOW_ITERATION + Existing case + + + MEN_HOMARD_NEW_ITERATION + New iteration + + + MEN_HOMARD_COMPUTE + Compute + + + MEN_HOMARD_COMPUTE_PUBLISH + Compute and publish + + + MEN_MG_ADAPT + Remesh with MG_Adapt + + + Args + Arguments + + + MeshOut + Mesh Out + + + MeshIn + Mesh In + + + MEDFile + MED file + + + Browser + Browser + + + Publish_MG_ADAPT + Publish + + + SIZE_MAP_FIELD + Size map field + + + MG_ADAPT_FIELD_NAME + Field Name + + + MG_ADAPT_MED_FILE_1 + This MED file cannot be read. + + + MG_ADAPT_MED_FILE_2 + No mesh in this MED file. + + + MG_ADAPT_MED_FILE_3 + More than one mesh in this MED file. + + + MG_ADAPT_MED_FILE_4 + The mesh in this MED file cannot be read. + + + MG_ADAPT_MED_FILE_5 + No field in this MED file. + + + MG_ADAPT_MED_FILE_6 + The field(s) in this MED file cannot be read. + + + MG_ADAPT_ERROR + Error + + + MG_ADAPT_CH_ST + Chosen time step + + + MG_ADAPT_RANK + Rank + + + MG_ADAPT_TSTP + Time step + + + MG_ADAPT_NO_T_ST + No time step + + + MG_ADAPT_L_ST + Last time step + + + MeshName + Mesh name + + + LOCAL_MG_ADAPT + local + + + BACKGRND_MG_ADAPT + Background + + + CNST_MG_ADAPT + Constant + + + MED_FILE_BCKG + MED file background size map + + + VALUE_MG_ADAPT + Value + + + SIZE_MAP_DEF + size map definition + + + ADVOP + Advanced Options + MEN_CONV_TO_QUAD Convert to/from quadratic @@ -788,6 +932,10 @@ MEN_MODIFY Modification + + MEN_ADAPT + Adaptation + MEN_MEASURE Measurements @@ -1502,6 +1650,10 @@ Please enter correct values and try again SMESH_AVAILABLE Available + + SMESH_NOT_AVAILABLE + Not available + SMESH_AVAILABLE_ALGORITHMS Available algorithms @@ -2897,6 +3049,134 @@ Check algorithm documentation for supported geometry SMESH_MULTICOLOR Multicolor + + ADAPT_PREF_TAB_GENERAL + Adaptation + + + ADAPT_PREF_NONE + None + + + ADAPT_PREF_HOMARD_PUBLICATION + Publication of meshes with HOMARD + + + ADAPT_PREF_HOMARD_PUBLICATION_MAILLAGE_IN + IN mesh + + + ADAPT_PREF_HOMARD_PUBLICATION_MAILLAGE_OUT + OUT mesh + + + ADAPT_PREF_HOMARD_YACS + A YACS schema with HOMARD + + + ADAPT_PREF_HOMARD_YACS_MAX_ITER + Maximal number of iterations + + + ADAPT_PREF_HOMARD_YACS_MAX_NODE + Maximal number of nodes + + + ADAPT_PREF_HOMARD_YACS_MAX_ELEM + Maximal number of elements + + + ADAPT_PREF_HOMARD_YACS_TYPE_CONVERGENCE + Test type for a YACS schema with HOMARD + + + ADAPT_PREF_MG_ADAPT + Adaptation with MG-Adapt + + + ADAPT_PREF_MG_ADAPT_FILE_MAILLAGE_OUT + Write the OUT mesh + + + ADAPT_PREF_MG_ADAPT_PUBLICATION_MAILLAGE_OUT + Publication of the OUT mesh + + + OPTION_VALUE_COLUMN + Option + + + OPTION_NAME_COLUMN + Value + + + compute_ridges + Compute ridges + + + max_memory + Maximum memory (Mb) + + + Adaption + adaptation + + + components + Components + + + ADAPT_PREF_MG_ADAPT_SIZE_MAP + Size map + + + ADAPT_PREF_MG_ADAPT_SIZE_MAP_LOCAL + Local + + + ADAPT_PREF_MG_ADAPT_SIZE_MAP_BACKGROUND + Background + + + ADAPT_PREF_MG_ADAPT_MED_SIZE_MAP_BACKGROUND + MED file background size map + + + ADAPT_PREF_MG_ADAPT_TIME_STEP + Time step + + + ADAPT_PREF_MG_ADAPT_NO_TIME_STEP + No time step + + + ADAPT_PREF_MG_ADAPT_TIME_STEP_LAST + Last + + + ADAPT_PREF_MG_ADAPT_AR + Arguments + + + ADAPT_PREF_MG_ADAPT_ADVOP + Advanced Options + + + ADAPT_PREF_MG_ADAPT_TIME_LAST_STEP + Last time step + + + ADAPT_PREF_MG_ADAPT_TIME_C_STEP + Chosen time step + + + ADAPT_PREF_MG_ADAPT_TIME_STEP_C + Value + + + MG_ADAPT_SELECT_FILE_0 + MG-ADAPT select file + SMESH_VISU_PROBLEM Mesh visualization failed @@ -3112,6 +3392,42 @@ Use Display Entity menu command to show them. STB_CONSTRUCT_GROUP Construct Group + + STB_REF_ALL + Uniform refinement + + + STB_REF_HOMARD + Refinement with HOMARD + + + STB_HOMARD_CREATE_CASE + Creation of a new case for adaptation with HOMARD + + + STB_HOMARD_FOLLOW_ITERATION + Creation of a new case: pursuit of a stored iteration + + + STB_HOMARD_NEW_ITERATION + Creation of a next iteration + + + STB_HOMARD_COMPUTE + Compute the refinement + + + STB_HOMARD_COMPUTE_PUBLISH + Compute the refinement and publish the final mesh + + + STB_EDIT + Edit + + + STB_MG_ADAPT + Remesh with MG_Adapt + STB_CONV_TO_QUAD Convert to/from quadratic @@ -3708,6 +4024,10 @@ Use Display Entity menu command to show them. TB_CTRL3D Volume Controls Toolbar + + TB_ADAPTATION + Adaptation Toolbar + TB_MEASUREM Measurements Toolbar @@ -3812,6 +4132,34 @@ Use Display Entity menu command to show them. TOP_CONSTRUCT_GROUP Construct Group + + TOP_REF_ALL + Uniform refinement + + + TOP_HOMARD_CREATE_CASE + New case + + + TOP_HOMARD_FOLLOW_ITERATION + Existing case + + + TOP_HOMARD_NEW_ITERATION + New iteration + + + TOP_HOMARD_COMPUTE + Compute + + + TOP_HOMARD_COMPUTE_PUBLISH + Compute and publish + + + TOP_MG_ADAPT + Remesh with MG_Adapt + TOP_CONV_TO_QUAD Convert to/from quadratic @@ -4443,8 +4791,8 @@ Use Display Entity menu command to show them. FULL_RECOMPUTE_QUESTION -The mesh has been edited since a last total re-compute -that may prevent successful computation. +The mesh has been edited since a last total re-compute +that may prevent successful computation. Do you wish to re-compute the mesh totally to discard the modifications? @@ -6637,7 +6985,7 @@ Please specify them and try again GEOMETRY_OBJECT_IS_NOT_DEFINED_MESH Geometry object is not defined. -Do you want to create an empty mesh +Do you want to create an empty mesh without algorithms and hypotheses? @@ -8322,7 +8670,7 @@ as they are of improper type: SUBSHAPES_NOT_FOUND_MSG -Some sub-shapes not found in the new geometry. They are listed +Some sub-shapes not found in the new geometry. They are listed below along with dependent mesh objects that are marked with red in the Object Browser. diff --git a/src/SMESHGUI/SMESH_msg_fr.ts b/src/SMESHGUI/SMESH_msg_fr.ts index 318c62947..4177ac636 100644 --- a/src/SMESHGUI/SMESH_msg_fr.ts +++ b/src/SMESHGUI/SMESH_msg_fr.ts @@ -482,7 +482,7 @@ MEN_EDIT - Edition + Editer MEN_EDIT_GROUP @@ -788,6 +788,118 @@ MEN_MODIFY Modification + + MEN_ADAPT + Adaptation + + + Args + Arguments + + + MeshOut + Maillage en sortie + + + MEDFile + Fichier MED + + + Browser + Arbre d'études + + + BACKGRND_MG_ADAPT + Arrière-plan + + + CNST_MG_ADAPT + Constante + + + SIZE_MAP_FIELD + Champ de la carte de taille + + + MG_ADAPT_FIELD_NAME + Nom du champ + + + MG_ADAPT_MED_FILE_1 + Ce fichier MED est illisible. + + + MG_ADAPT_MED_FILE_2 + Ce fichier MED ne contient aucun maillage. + + + MG_ADAPT_MED_FILE_3 + Ce fichier MED contient plus d'un maillage. + + + MG_ADAPT_MED_FILE_4 + Impossible de lire le maillage de ce fichier MED. + + + MG_ADAPT_MED_FILE_5 + Ce fichier MED ne contient aucun champ. + + + MG_ADAPT_MED_FILE_6 + Impossible de lire le(s) champ(s) de ce fichier MED. + + + MG_ADAPT_NO_T_ST + Sans pas de temps + + + MG_ADAPT_CH_ST + Pas de temps choisi + + + MG_ADAPT_RANK + Numéro d'ordre + + + MG_ADAPT_TSTP + Pas de temps + + + MG_ADAPT_L_ST + Dernier pas de temps + + + MED_FILE_BCKG + fichier MED de la carte en arrière-plan + + + VALUE_MG_ADAPT + Valeur + + + Publish_MG_ADAPT + Publication + + + LOCAL_MG_ADAPT + locale + + + MeshName + Nom du maillage + + + MeshIn + Maillage en entrée + + + SIZE_MAP_DEF + Définition de la carte de taille + + + ADVOP + Advanced Options + MEN_MEASURE Outils de mesure @@ -1128,6 +1240,38 @@ MEN_TRANSF Transformation + + MEN_REF_ALL + Raffinement uniforme + + + MEN_REF_HOMARD + Raffinement avec HOMARD + + + MEN_HOMARD_CREATE_CASE + Création d'un cas d'adaptation + + + MEN_HOMARD_FOLLOW_ITERATION + Poursuite d'une itération d'adaptation + + + MEN_HOMARD_NEW_ITERATION + Création d'une itération d'adaptation + + + MEN_HOMARD_COMPUTE + Calculer + + + MEN_HOMARD_COMPUTE_PUBLISH + Calculer et publier + + + MEN_MG_ADAPT + Remaillage avec MG_Adapt + MEN_TRANSP Transparence @@ -2895,6 +3039,110 @@ Référez-vous à la documentation sur l'algorithme et la géométrie supportée SMESH_MULTICOLOR Multicouleur + + ADAPT_PREF_TAB_GENERAL + Adaptation + + + ADAPT_PREF_NONE + Sans + + + ADAPT_PREF_HOMARD_PUBLICATION + Publication des maillages avec HOMARD + + + ADAPT_PREF_HOMARD_PUBLICATION_MAILLAGE_IN + Le maillage d'entrée + + + ADAPT_PREF_HOMARD_PUBLICATION_MAILLAGE_OUT + Le maillage de sortie + + + ADAPT_PREF_HOMARD_YACS + Schéma YACS avec HOMARD + + + ADAPT_PREF_HOMARD_YACS_MAX_ITER + Nombre maximal d'itérations + + + ADAPT_PREF_HOMARD_YACS_MAX_NODE + Nombre maximal de noeuds + + + ADAPT_PREF_HOMARD_YACS_MAX_ELEM + Nombre maximal d'éléments + + + ADAPT_PREF_HOMARD_YACS_TYPE_CONVERGENCE + Type de test pour la convergence + + + ADAPT_PREF_MG_ADAPT + Adaptation avec MG-Adapt + + + ADAPT_PREF_MG_ADAPT_FILE_MAILLAGE_OUT + Ecriture du maillage de sortie + + + ADAPT_PREF_MG_ADAPT_PUBLICATION_MAILLAGE_OUT + Publication du maillage de sortie + + + OPTION_VALUE_COLUMN + Option + + + OPTION_NAME_COLUMN + Valeur + + + compute_ridges + Calcul des crêtes + + + max_memory + Maximum memoire (Mb) + + + components + Composants + + + Adapation + adaptation + + + ADAPT_PREF_MG_ADAPT_SIZE_MAP + Carte de tailles + + + ADAPT_PREF_MG_ADAPT_SIZE_MAP_LOCAL + Locale + + + ADAPT_PREF_MG_ADAPT_SIZE_MAP_BACKGROUND + Arrière-plan + + + ADAPT_PREF_MG_ADAPT_TIME_STEP + Choix du pas de temps + + + ADAPT_PREF_MG_ADAPT_TIME_STEP_LAST + Dernier + + + ADAPT_PREF_MG_ADAPT_TIME_STEP_C + Valeur + + + MG_ADAPT_SELECT_FILE_0 + MG-ADAPT selection fichier MED + SMESH_VISU_PROBLEM Impossible de visualiser le maillage, probablement à cause d'un manque de mémoire @@ -3111,6 +3359,42 @@ Utilisez le menu "Visualiser une entité" pour les afficher. STB_CONSTRUCT_GROUP Construire un groupe + + STB_REF_ALL + Raffinement uniforme + + + STB_REF_HOMARD + Adaptation avec HOMARD + + + STB_HOMARD_CREATE_CASE + Création d'un nouveau cas d'adaptation avec HOMARD + + + STB_HOMARD_FOLLOW_ITERATION + Création d'un nouveau cas : poursuite d'une itération stockée + + + STB_HOMARD_NEW_ITERATION + Création d'une nouvelle itération + + + STB_HOMARD_COMPUTE + Calcule le raffinement + + + STB_HOMARD_COMPUTE_PUBLISH + Calcule le raffinement et publie le maillage résultat + + + STB_EDIT + Edit + + + STB_MG_ADAPT + Remaillage avec MG_Adapt + STB_CONV_TO_QUAD Convertir vers/depuis quadratique @@ -3707,6 +3991,10 @@ Utilisez le menu "Visualiser une entité" pour les afficher. TB_CTRL3D Barre des contrôles des volumes + + TB_ADAPTATION + Barre de l'adaptation + TB_MEASUREM Barre des mesures @@ -3811,6 +4099,34 @@ Utilisez le menu "Visualiser une entité" pour les afficher. TOP_CONSTRUCT_GROUP Construire un groupe + + TOP_REF_ALL + Raffinement uniforme + + + TOP_HOMARD_CREATE_CASE + Création d'un cas d'adaptation avec HOMARD + + + TOP_HOMARD_FOLLOW_ITERATION + Poursuite d'une itération d'adaptation avec HOMARD + + + TOP_HOMARD_NEW_ITERATION + Création d'une itération + + + TOP_HOMARD_COMPUTE + Calculer + + + TOP_HOMARD_COMPUTE_PUBLISH + Calculer et publier + + + TOP_MG_ADAPT + Remaillage avec MG_Adapt + TOP_CONV_TO_QUAD Convertir vers/de quadratique diff --git a/src/SMESH_I/CMakeLists.txt b/src/SMESH_I/CMakeLists.txt index 4f1695d84..cc3ad31f1 100644 --- a/src/SMESH_I/CMakeLists.txt +++ b/src/SMESH_I/CMakeLists.txt @@ -37,8 +37,11 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/DriverCGNS ${PROJECT_SOURCE_DIR}/src/SMESH ${PROJECT_SOURCE_DIR}/src/SMESHUtils + #~${PROJECT_SOURCE_DIR}/src/ADAPT ${PROJECT_BINARY_DIR} ${PROJECT_BINARY_DIR}/idl + #~${PROJECT_BINARY_DIR}/ADAPT + ${MEDCOUPLING_INCLUDE_DIRS} ) # additional preprocessor / compiler flags @@ -81,6 +84,7 @@ SET(_link_LIBRARIES SMESHDS SMESHControls MeshDriverMED + ${MEDCoupling_medloader} ) # --- headers --- @@ -107,6 +111,7 @@ SET(SMESHEngine_HEADERS SMESH_PreMeshInfo.hxx SMESH_MeshPartDS.hxx SMESH.hxx + MG_ADAPT_i.hxx ) # --- sources --- @@ -132,6 +137,7 @@ SET(SMESHEngine_SOURCES SMESH_NoteBook.cxx SMESH_Measurements_i.cxx SMESH_PreMeshInfo.cxx + MG_ADAPT_i.cxx ) # --- rules --- diff --git a/src/SMESH_I/MG_ADAPT_i.cxx b/src/SMESH_I/MG_ADAPT_i.cxx new file mode 100644 index 000000000..51160b1df --- /dev/null +++ b/src/SMESH_I/MG_ADAPT_i.cxx @@ -0,0 +1,549 @@ +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Remarques : +// L'ordre de description des fonctions est le meme dans tous les fichiers +// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : +// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore +// 2. Les caracteristiques +// 3. Le lien avec les autres structures +// +// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier +// + +#include "MG_ADAPT_i.hxx" +//~#include "ADAPT_Gen_i.hxx" +#include "string.h" +#include "SMESH_Gen_i.hxx" +#include +#include +#include CORBA_CLIENT_HEADER(SALOMEDS) +//~#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog) +//~#include CORBA_CLIENT_HEADER(SMESH_Gen) + + +//============================================================================= +/*! + * SMESH_Gen_i::CreateMG_ADAPT + * + * Create measurement instance + */ +//============================================================================= + + +using namespace SMESH; +void MG_ADAPT_i::copyHypothesisDataToImpl(const SMESH::MgAdaptHypothesisData& from, ::MG_ADAPT::MgAdaptHypothesisData* to) const +{ + to->myFileInDir = from.myFileInDir; + to->myMeshFileIn = from.myMeshFileIn; + to->myMeshFileBackground = from.myMeshFileBackground; + to->myOutMeshName = from.myOutMeshName; + to->myMeshFileOut = from.myMeshFileOut; + to->myFileOutDir = from.myFileOutDir; + to->myFileSizeMapDir = from.myFileSizeMapDir; + to->myFieldName = from.myFieldName; + to->fromMedFile = from.fromMedFile; + to->myPublish = from.myPublish; + to->myMeshOutMed = from.myMeshOutMed; + to->myUseLocalMap = from.myUseLocalMap; + to->myUseBackgroundMap = from.myUseBackgroundMap; + to->myUseConstantValue = from.myUseConstantValue; + to->myConstantValue = from.myConstantValue; + to->myTimeStep = from.myTimeStep; + to->myRank = from.myRank; + to->myUseNoTimeStep = from.myUseNoTimeStep; + to->myUseLastTimeStep = from.myUseLastTimeStep; + to->myUseChosenTimeStep = from.myUseChosenTimeStep; + to->myWorkingDir = from.myWorkingDir; + to->myLogFile = from.myLogFile; + to->myPrintLogInFile = from.myPrintLogInFile; + to->myKeepFiles = from.myKeepFiles; + to->myRemoveLogOnSuccess = from.myRemoveLogOnSuccess; + to->myVerboseLevel = from.myVerboseLevel; +} +void MG_ADAPT_i::copyHypothesisDataFromImpl(const ::MG_ADAPT::MgAdaptHypothesisData* from, SMESH::MgAdaptHypothesisData* to) const +{ + to->myFileInDir = CORBA::string_dup(from->myFileInDir.c_str()); + to->myMeshFileIn = CORBA::string_dup(from->myMeshFileIn.c_str()); + to->myMeshFileBackground = CORBA::string_dup(from->myMeshFileBackground.c_str()); + to->myOutMeshName = CORBA::string_dup(from->myOutMeshName.c_str()); + to->myMeshFileOut = CORBA::string_dup(from->myMeshFileOut.c_str()); + to->myFileOutDir = CORBA::string_dup(from->myFileOutDir.c_str()); + to->myFileSizeMapDir = CORBA::string_dup(from->myFileSizeMapDir.c_str()); + to->myFieldName = CORBA::string_dup(from->myFieldName.c_str()); + to->fromMedFile = from->fromMedFile; + to->myPublish = from->myPublish; + to->myMeshOutMed = from->myMeshOutMed; + to->myUseLocalMap = from->myUseLocalMap; + to->myUseBackgroundMap = from->myUseBackgroundMap; + to->myUseConstantValue = from->myUseConstantValue; + to->myConstantValue = from->myConstantValue; + to->myTimeStep = from->myTimeStep; + to->myRank = from->myRank; + to->myUseNoTimeStep = from->myUseNoTimeStep; + to->myUseLastTimeStep = from->myUseLastTimeStep; + to->myUseChosenTimeStep = from->myUseChosenTimeStep; + to->myWorkingDir = CORBA::string_dup(from->myWorkingDir.c_str()); + to->myLogFile = CORBA::string_dup(from->myLogFile.c_str()); + to->myPrintLogInFile = from->myPrintLogInFile; + to->myKeepFiles = from->myKeepFiles; + to->myRemoveLogOnSuccess = from->myRemoveLogOnSuccess; + to->myVerboseLevel = from->myVerboseLevel; +} +SMESH::MG_ADAPT_ptr SMESH_Gen_i::CreateMG_ADAPT() +{ + SMESH::MG_ADAPT_i* aMGadapt = new SMESH::MG_ADAPT_i(); + SMESH::MG_ADAPT_var anObj = aMGadapt->_this(); + return anObj._retn(); +} +SMESH::MG_ADAPT_ptr SMESH_Gen_i::CreateAdaptationHypothesis() +{ + SMESH::MG_ADAPT_i* aMGadapt = new SMESH::MG_ADAPT_i(); + SMESH::MG_ADAPT_var anObj = aMGadapt->_this(); + return anObj._retn(); +} +SMESH::MG_ADAPT_OBJECT_ptr SMESH_Gen_i::Adaptation( const char* adaptationType) +{ + + if (!strcmp(adaptationType, "MG_Adapt")){ + SMESH::MG_ADAPT_OBJECT_i* mg_adapt_object = new SMESH::MG_ADAPT_OBJECT_i(); + SMESH::MG_ADAPT_OBJECT_var anObj = mg_adapt_object->_this(); + return anObj._retn(); + } + + +} +//~SMESH::MG_ADAPT_ptr MG_ADAPT_i::CreateMG_ADAPT() +//~{ + + //~SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen(); + //~SMESH::MG_ADAPT_i* aMGadapt = new SMESH::MG_ADAPT_i(smeshGen_i->GetPOA()); + //~SMESH::MG_ADAPT_var anObj = aMGadapt->_this(); + //~return anObj._retn(); +//~} +//============================================================================= +/*! + * standard constructor + */ +//============================================================================= +MG_ADAPT_i::MG_ADAPT_i(): SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() ) +{ + myMgAdapt = new ::MG_ADAPT::MgAdapt(); +} +//~MG_ADAPT_i::MG_ADAPT_i(PortableServer::POA_var myPoa): SALOME::GenericObj_i( myPoa ) +//~{ + //~myMgAdapt = new ::MG_ADAPT::MgAdapt(); +//~} + +//============================================================================= +/*! + * standard constructor + */ +//============================================================================= +//~MG_ADAPT_i::MG_ADAPT_i( CORBA::ORB_ptr orb, + //~ADAPT::ADAPT_Gen_var engine ) +//~{ + + //~_gen_i = engine; + //~_orb = orb; + //~myMgAdapt = new MgAdapt(); +//~} + +//============================================================================= +/*! + * standard destructor + */ +//============================================================================= +MG_ADAPT_i::~MG_ADAPT_i() +{ +} +void MG_ADAPT_i::setData( SMESH::MgAdaptHypothesisData& data) +{ + ::MG_ADAPT::MgAdaptHypothesisData* baseData = new ::MG_ADAPT::MgAdaptHypothesisData(); + copyHypothesisDataToImpl(data, baseData); + myMgAdapt->setData(baseData); + delete baseData; +} +void MG_ADAPT_i::setMedFileIn(const char* str) +{ + myMgAdapt->setMedFileIn(str); +} +char* MG_ADAPT_i::getMedFileIn() +{ + return CORBA::string_dup(myMgAdapt->getMedFileIn().c_str()); +} +void MG_ADAPT_i::setMedFileOut(const char* str) +{ + myMgAdapt->setMedFileOut(str); +} +char* MG_ADAPT_i::getMedFileOut() +{ + return CORBA::string_dup(myMgAdapt->getMedFileOut().c_str()); +} +void MG_ADAPT_i::setMeshName(const char* str) +{ + myMgAdapt->setMeshName(str); +} +char* MG_ADAPT_i::getMeshName() +{ + return CORBA::string_dup(myMgAdapt->getMeshName().c_str()); +} +void MG_ADAPT_i::setMeshNameOut(const char* str) +{ + myMgAdapt->setMeshNameOut(str); +} +char* MG_ADAPT_i::getMeshNameOut() +{ + return CORBA::string_dup(myMgAdapt->getMeshNameOut().c_str()); +} +void MG_ADAPT_i::setMeshOutMed(bool mybool) +{ + myMgAdapt->setMeshOutMed(mybool); +} +bool MG_ADAPT_i::getMeshOutMed() +{ + return myMgAdapt->getMeshOutMed(); +} +void MG_ADAPT_i::setPublish(bool mybool) +{ + myMgAdapt->setPublish(mybool); +} +bool MG_ADAPT_i::getPublish() +{ + return myMgAdapt->getPublish(); +} +void MG_ADAPT_i::setSizeMapFieldName(const char* str) +{ + myMgAdapt->setFieldName(str); +} +char* MG_ADAPT_i::getSizeMapFieldName() +{ + return CORBA::string_dup(myMgAdapt->getFieldName().c_str()); +} +void MG_ADAPT_i::setTimeStep(CORBA::Long t) +{ + myMgAdapt->setTimeStep(t); +} +CORBA::Long MG_ADAPT_i::getTimeStep() +{ + return myMgAdapt->getTimeStep(); +} +void MG_ADAPT_i::setTimeStepRank(CORBA::Long t, CORBA::Long r) +{ + myMgAdapt->setChosenTimeStepRank(); + myMgAdapt->setRankTimeStep(t, r); +} +CORBA::Long MG_ADAPT_i::getRank() +{ + return myMgAdapt->getRank(); +} +void MG_ADAPT_i::setTimeStepRankLast() +{ + myMgAdapt->setTimeStepRankLast(); +} +void MG_ADAPT_i::setNoTimeStep() +{ + myMgAdapt->setNoTimeStep(); +} +void MG_ADAPT_i::setLogFile(const char* str) +{ + myMgAdapt->setLogFile(str); +} +char* MG_ADAPT_i::getLogFile() +{ + return CORBA::string_dup(myMgAdapt->getLogFile().c_str()); +} + +void MG_ADAPT_i::setVerbosityLevel(CORBA::Long v) +{ + myMgAdapt->setVerbosityLevel(v); +} +CORBA::Long MG_ADAPT_i::getVerbosityLevel() +{ + return myMgAdapt->getVerbosityLevel(); +} +void MG_ADAPT_i::setRemoveOnSuccess(bool mybool) +{ + myMgAdapt->setRemoveOnSuccess(mybool); +} +bool MG_ADAPT_i::getRemoveOnSuccess() +{ + myMgAdapt->getRemoveOnSuccess(); +} +SMESH::MgAdaptHypothesisData* MG_ADAPT_i::getData() +{ + SMESH::MgAdaptHypothesisData* result = new SMESH::MgAdaptHypothesisData(); + ::MG_ADAPT::MgAdaptHypothesisData* from = myMgAdapt->getData(); + copyHypothesisDataFromImpl(from, result); + return result; +} +void MG_ADAPT_i::setUseLocalMap(bool mybool) +{ + myMgAdapt->setUseLocalMap(mybool); +} +bool MG_ADAPT_i::getUseLocalMap() +{ + return myMgAdapt->getUseLocalMap(); +} +void MG_ADAPT_i::setUseBackgroundMap(bool mybool) +{ + myMgAdapt->setUseBackgroundMap(mybool); +} +bool MG_ADAPT_i::getUseBackgroundMap() +{ + return myMgAdapt->getUseBackgroundMap(); +} +void MG_ADAPT_i::setUseConstantValue(bool mybool) +{ + myMgAdapt->setUseConstantValue(mybool); +} +bool MG_ADAPT_i::getUseConstantValue() +{ + return myMgAdapt->getUseConstantValue(); +} + +void MG_ADAPT_i::setConstantSize(double value) +{ + myMgAdapt->setConstantValue(value); +} +double MG_ADAPT_i::getConstantSize() +{ + return myMgAdapt->getConstantValue(); +} +void MG_ADAPT_i::setSizeMapFile(const char* str) +{ + myMgAdapt->setSizeMapFile(str); +} +char* MG_ADAPT_i::getSizeMapFile() +{ + return CORBA::string_dup(myMgAdapt->getSizeMapFile().c_str()); +} +void MG_ADAPT_i::setFromMedFile(bool mybool) +{ + myMgAdapt->setFromMedFile(mybool); +} +bool MG_ADAPT_i::isFromMedFile() +{ + return myMgAdapt->isFromMedFile(); +} + +void MG_ADAPT_i::setKeepWorkingFiles(bool mybool) +{ + myMgAdapt->setKeepWorkingFiles(mybool); +} +bool MG_ADAPT_i::getKeepWorkingFiles() +{ + return myMgAdapt->getKeepWorkingFiles(); +} + +//~void MG_ADAPT_i::setPrCORBA::LongLogInFile(bool); +//~bool MG_ADAPT_i::getPrCORBA::LongLogInFile(); + +void MG_ADAPT_i::setSizeMapType(const char* type) +{ + setUseLocalMap(false); + setUseBackgroundMap(false); + setUseConstantValue(false); + + if (!strcmp("Local", type)) + setUseLocalMap(true); + else if (!strcmp("Background", type)) + setUseBackgroundMap(true); + else + setUseConstantValue(true); +} +void MG_ADAPT_i::setWorkingDir(const char* dir) +{ + myMgAdapt->setWorkingDir(dir); +} +char* MG_ADAPT_i::getWorkingDir() +{ + return CORBA::string_dup(myMgAdapt->getWorkingDir().c_str()); +} +bool MG_ADAPT_i::setAll() +{ + return myMgAdapt->setAll(); +} +char* MG_ADAPT_i::getCommandToRun() +{ + return CORBA::string_dup(myMgAdapt->getCommandToRun().c_str()); +} + +//~CORBA::Long MG_ADAPT_i::compute(::CORBA::String_out errStr) +//~{ + //~std::string err(""); + //~CORBA::Long ret = myMgAdapt->compute(err); + //~errStr = err.c_str(); + //~return ret; +//~} +CORBA::Long MG_ADAPT_i::compute() +{ + errStr = ""; + CORBA::Long ret; + try + { + ret = myMgAdapt->compute(errStr); + } + catch (const std::exception& e) + { + std::cerr<getPublish()) + { + SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen(); + SMESH::DriverMED_ReadStatus theStatus; + smeshGen_i->CreateMeshesFromMED(myMgAdapt->getMedFileOut().c_str(), theStatus); + } + //~errStr = err.c_str(); + return ret; +} +char* MG_ADAPT_i::getErrMsg() +{ + return CORBA::string_dup(errStr.c_str()); +} +char* MG_ADAPT_i::getFileName() +{ + return CORBA::string_dup(myMgAdapt->getFileName().c_str()); +} +char* MG_ADAPT_i::getExeName() +{ + return CORBA::string_dup(myMgAdapt->getExeName().c_str()); +} +void MG_ADAPT_i::copyMgAdaptHypothesisData( const SMESH::MgAdaptHypothesisData& data) +{ + ::MG_ADAPT::MgAdaptHypothesisData* baseData = new ::MG_ADAPT::MgAdaptHypothesisData(); + copyHypothesisDataToImpl(data, baseData); + myMgAdapt->copyMgAdaptHypothesisData(baseData); + delete baseData; +} + +//~void MG_ADAPT_i::checkDirPath(char*& str) +//~{ + //~myMgAdapt->checkDirPath(str); +//~} + +bool MG_ADAPT_i::hasOptionDefined( const char* optionName ) +{ + return myMgAdapt->hasOptionDefined(optionName); +} +void MG_ADAPT_i::setOptionValue(const char* optionName, + const char* optionValue) throw (std::invalid_argument) +{ + myMgAdapt->setOptionValue(optionName, optionValue); +} + +char* MG_ADAPT_i::getOptionValue(const char* optionName, + bool& isDefault) throw (std::invalid_argument) +{ + return CORBA::string_dup(myMgAdapt->getOptionValue(optionName, &isDefault).c_str()); +} +str_array* MG_ADAPT_i::getCustomOptionValuesStrVec() +{ + SMESH::str_array_var result = new SMESH::str_array(); + std::vector vals = myMgAdapt->getCustomOptionValuesStrVec(); + result->length(vals.size()); + for (int i = 0; i vals = myMgAdapt->getOptionValuesStrVec(); + result->length(vals.size()); + for (int i = 0; isetPrintLogInFile(mybool); +} +bool MG_ADAPT_i::getPrintLogInFile() +{ + return myMgAdapt->getPrintLogInFile(); +} +//~TOptionValues MG_ADAPT_i::getOptionValues() const; +//~const TOptionValues& MG_ADAPT_i::getCustomOptionValues() const ; + +MG_ADAPT_OBJECT_i::MG_ADAPT_OBJECT_i(): SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() ) +{ + medFileIn=""; + medFileOut=""; + medFileBackground=""; + publish = false; + //~myMesh = CORBA::nil; +} + +void MG_ADAPT_OBJECT_i::setMeshIn(SMESH::SMESH_Mesh_ptr theMesh ) +{ + myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh); +} +void MG_ADAPT_OBJECT_i::setMEDFileIn(const char* f) +{ + medFileIn = f; +} +void MG_ADAPT_OBJECT_i::setMEDFileOut(const char* f) +{ + medFileOut = f; +} +void MG_ADAPT_OBJECT_i::setMEDFileBackground(const char* f) +{ + medFileBackground = f; +} +void MG_ADAPT_OBJECT_i::AddHypothesis(SMESH::MG_ADAPT_ptr mg) +{ + + mg->setMedFileIn(medFileIn.c_str()); + mg->setMedFileOut(medFileOut.c_str()); + mg->setSizeMapFile(medFileBackground.c_str()); + hypothesis = SMESH::MG_ADAPT::_duplicate(mg); +} +CORBA::Long MG_ADAPT_OBJECT_i::Compute(bool publish) +{ + if(!checkMeshFileIn()){ + std::cerr<< "\n Error : Please check the MED file input or mesh input. \n"; + return -1; + } + hypothesis->setPublish(publish); + return hypothesis->compute(); +} + +bool MG_ADAPT_OBJECT_i::checkMeshFileIn() +{ + bool ret = false; // 1 ok , 0 nook + if(!::MG_ADAPT::MgAdapt::isFileExist(medFileIn)) + { + if(!myMesh->_is_nil()) + { + bool toOverwrite = true; + bool toFindOutDim = true; + medFileIn = hypothesis->getFileName(); + medFileIn+= ".med"; + myMesh->ExportMED(medFileIn.c_str(), false, -1, toOverwrite, toFindOutDim); + hypothesis->setMedFileIn(medFileIn.c_str()); + ret = true; + } + } + else + ret = true; + + return ret; +} diff --git a/src/SMESH_I/MG_ADAPT_i.hxx b/src/SMESH_I/MG_ADAPT_i.hxx new file mode 100644 index 000000000..daedce449 --- /dev/null +++ b/src/SMESH_I/MG_ADAPT_i.hxx @@ -0,0 +1,163 @@ +#ifndef MG_ADAPT_I_HXX +#define MG_ADAPT_I_HXX + +#include "MG_ADAPT.hxx" +#include "SMESH.hxx" +#include +//~#include CORBA_SERVER_HEADER(ADAPT_Gen) +#include CORBA_SERVER_HEADER(MG_ADAPT) + +#include "SALOME_GenericObj_i.hh" +#include "SALOME_Component_i.hxx" +#include "SALOME_NamingService.hxx" +#include "Utils_CorbaException.hxx" +#include +#include +#include +#include + +//~struct MgAdaptHypothesisData; +//~static void copyHypothesisDataToImpl(SMESH::MgAdaptHypothesisData& from, MG_ADAPT::MgAdaptHypothesisData* to); +//~static void copyHypothesisDataFromImpl(MG_ADAPT::MgAdaptHypothesisData* from, SMESH::MgAdaptHypothesisData& to); +//~class MgAdapt; +namespace SMESH +{ + +class SMESH_I_EXPORT MG_ADAPT_i : + public virtual SALOME::GenericObj_i, + public virtual POA_SMESH::MG_ADAPT +{ +public: + //~MG_ADAPT_i( CORBA::ORB_ptr orb, ADAPT::ADAPT_Gen_var gen_i ); + //~static SMESH::MG_ADAPT_ptr CreateMG_ADAPT(); + //~MG_ADAPT_i(PortableServer::POA_var poa); + MG_ADAPT_i(); + virtual ~MG_ADAPT_i(); + //~void setData( SMESH::MgAdaptHypothesisData* data); + void setData( SMESH::MgAdaptHypothesisData& data); + + void setMedFileIn(const char* str); + char* getMedFileIn(); + + void setMedFileOut(const char* str); + char* getMedFileOut(); + + void setMeshName(const char* str); + char* getMeshName(); + + void setMeshNameOut(const char* str); + char* getMeshNameOut(); + + void setMeshOutMed(bool mybool); + bool getMeshOutMed(); + + void setPublish(bool mybool); + bool getPublish(); + + void setSizeMapFieldName(const char* str); + char* getSizeMapFieldName(); + + void setTimeStep(CORBA::Long t); + CORBA::Long getTimeStep() ; + + void setTimeStepRank(CORBA::Long t, CORBA::Long r ); + CORBA::Long getRank(); + + void setTimeStepRankLast(); + void setNoTimeStep(); + + void setLogFile(const char* str); + char* getLogFile(); + + void setVerbosityLevel(CORBA::Long v); + CORBA::Long getVerbosityLevel(); + + void setRemoveOnSuccess(bool mybool); + bool getRemoveOnSuccess(); + + SMESH::MgAdaptHypothesisData* getData() ; + void setSizeMapType(const char* type); + void setUseLocalMap(bool mybool); + bool getUseLocalMap(); + + void setUseBackgroundMap(bool mybool); + bool getUseBackgroundMap(); + + void setUseConstantValue(bool mybool); + bool getUseConstantValue(); + + void setConstantSize(double value); + double getConstantSize(); + + void setSizeMapFile(const char* str); + char* getSizeMapFile(); + + void setFromMedFile(bool mybool); + bool isFromMedFile(); + + void setKeepWorkingFiles(bool mybool); + bool getKeepWorkingFiles(); + + //~void setPrCORBA::LongLogInFile(bool); + //~bool getPrCORBA::LongLogInFile(); + + void setWorkingDir(const char* str); + char* getWorkingDir() ; + + void setPrintLogInFile(bool mybool); + bool getPrintLogInFile(); + + bool setAll(); + char* getCommandToRun() ; + //~CORBA::Long compute(::CORBA::String_out errStr); + CORBA::Long compute(); + char* getFileName(); + char* getExeName(); + void copyMgAdaptHypothesisData( const SMESH::MgAdaptHypothesisData& data ) ; + //~void copyMgAdaptHypothesisData( const SMESH::MgAdaptHypothesisData& data ) { + //~copyMgAdaptHypothesisData(&data); + //~} + + //~void checkDirPath(char*& str); + + bool hasOptionDefined( const char* optionName ) ; + void setOptionValue(const char* optionName, + const char* optionValue) throw (std::invalid_argument); + char* getOptionValue(const char* optionName, + bool& isDefault) throw (std::invalid_argument); + str_array* getCustomOptionValuesStrVec() ; + str_array* getOptionValuesStrVec() ; + void copyHypothesisDataFromImpl(const ::MG_ADAPT::MgAdaptHypothesisData* from, SMESH::MgAdaptHypothesisData* to) const; + void copyHypothesisDataToImpl(const SMESH::MgAdaptHypothesisData& from, ::MG_ADAPT::MgAdaptHypothesisData* to) const; + //~TOptionValues getOptionValues() const; + //~const TOptionValues& getCustomOptionValues() const ; + char* getErrMsg(); +private: + ::MG_ADAPT::MgAdapt* myMgAdapt; + std::string errStr; + //~CORBA::ORB_ptr _orb; + //~ADAPT::ADAPT_Gen_var _gen_i; + +}; + +class SMESH_I_EXPORT MG_ADAPT_OBJECT_i: + public virtual SALOME::GenericObj_i, + public virtual POA_SMESH::MG_ADAPT_OBJECT { +public : + MG_ADAPT_OBJECT_i(); + void setMeshIn( SMESH::SMESH_Mesh_ptr theMesh ); + void setMEDFileIn(const char* f); + void setMEDFileOut(const char* f); + void setMEDFileBackground(const char* f); + void AddHypothesis(SMESH::MG_ADAPT_ptr); + CORBA::Long Compute(bool Publish); +private: +std::string medFileIn, medFileOut, medFileBackground; +bool checkMeshFileIn(); +bool publish; +SMESH::SMESH_Mesh_ptr myMesh; +SMESH::MG_ADAPT_ptr hypothesis; +}; + +} +#endif // MG_ADAPT_I_HXX diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx index fb16909b8..08cfb22f7 100644 --- a/src/SMESH_I/SMESH_Gen_i.hxx +++ b/src/SMESH_I/SMESH_Gen_i.hxx @@ -469,6 +469,9 @@ public: void CleanPythonTrace(); static int CountInPyDump(const TCollection_AsciiString& text); + SMESH::MG_ADAPT_ptr CreateMG_ADAPT(); + SMESH::MG_ADAPT_ptr CreateAdaptationHypothesis(); + SMESH::MG_ADAPT_OBJECT_ptr Adaptation( const char* adaptationType); // ***************************************** // Internal methods