From: eap Date: Thu, 3 Nov 2016 17:06:08 +0000 (+0300) Subject: IMP23373: [CEA 1170] Optimization of a 3D mesh using MG-Tetra X-Git-Tag: V8_2_0a1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=25112d3bf460b34fe1ff7454a7cf838b51c6f4e2;p=plugins%2Fghs3dplugin.git IMP23373: [CEA 1170] Optimization of a 3D mesh using MG-Tetra --- diff --git a/doc/salome/examples/ghs3d_optimization.py b/doc/salome/examples/ghs3d_optimization.py new file mode 100644 index 0000000..a7ecaf6 --- /dev/null +++ b/doc/salome/examples/ghs3d_optimization.py @@ -0,0 +1,60 @@ +# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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 +# + +import salome +salome.salome_init() + +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + +# create a disk +disk = geompy.MakeDiskR(100., 1, theName="disk") + +# triangulate the disk +mesh = smesh.Mesh( disk ) +cadsurf = mesh.Triangle( smeshBuilder.MG_CADSurf ) +cadsurf.SetQuadAllowed( True ) +mesh.Compute() + +# extrude the 2D mesh into a prismatic mesh +mesh.ExtrusionSweepObject( mesh, [0,0,10], 7 ) + +# split prisms into tetrahedra +mesh.SplitVolumesIntoTetra( mesh ) + +# copy the mesh into a new mesh, since only a mesh not based of geometry +# can be optimized using MG-Tetra Optimization +optMesh = smesh.CopyMesh( mesh, "optimization" ) + +# add MG-Tetra Optimization +mg_opt = optMesh.Tetrahedron( smeshBuilder.MG_Tetra_Optimization ) +mg_opt.SetSmoothOffSlivers( True ) +mg_opt.SetOptimizationLevel( smeshBuilder.Strong_Optimization ) + +# run optimization +optMesh.Compute() + +print "Nb tetra before optimization", mesh.NbTetras() +print "Nb tetra after optimization", optMesh.NbTetras() + +# End of script + diff --git a/doc/salome/gui/GHS3DPLUGIN/images/mgtetra_optim_adv_params.png b/doc/salome/gui/GHS3DPLUGIN/images/mgtetra_optim_adv_params.png new file mode 100644 index 0000000..4f308c1 Binary files /dev/null and b/doc/salome/gui/GHS3DPLUGIN/images/mgtetra_optim_adv_params.png differ diff --git a/doc/salome/gui/GHS3DPLUGIN/images/mgtetra_optim_gen_params.png b/doc/salome/gui/GHS3DPLUGIN/images/mgtetra_optim_gen_params.png new file mode 100644 index 0000000..35a1a68 Binary files /dev/null and b/doc/salome/gui/GHS3DPLUGIN/images/mgtetra_optim_gen_params.png differ diff --git a/doc/salome/gui/GHS3DPLUGIN/input/ghs3dplugin_python_interface.doc b/doc/salome/gui/GHS3DPLUGIN/input/ghs3dplugin_python_interface.doc index ad46d52..3a75b5a 100644 --- a/doc/salome/gui/GHS3DPLUGIN/input/ghs3dplugin_python_interface.doc +++ b/doc/salome/gui/GHS3DPLUGIN/input/ghs3dplugin_python_interface.doc @@ -24,6 +24,7 @@ Below you can see examples of usage of this class for tetrahedral mesh generatio -# \ref tui_ghs3d_basic -# \ref tui_ghs3d_enforced_vertices -# \ref tui_ghs3d_enforced_meshes +-# \ref tui_ghs3d_optimization \section tui_ghs3d_basic Construction of Mesh using MG-Tetra algorithm @@ -57,6 +58,11 @@ Below you can see examples of usage of this class for tetrahedral mesh generatio \image html ghs3d_screenshot_enf5.png \image html ghs3d_screenshot_enf6.png +\section tui_ghs3d_optimization Mesh optimization + +

Example of mesh optimization with MG-Tetra Optimization:

+\tui_script{ghs3d_optimization.py} + \ref tui_ghs3d "Back to top" */ diff --git a/doc/salome/gui/GHS3DPLUGIN/input/index.doc b/doc/salome/gui/GHS3DPLUGIN/input/index.doc index bcc3e4a..bf42483 100644 --- a/doc/salome/gui/GHS3DPLUGIN/input/index.doc +++ b/doc/salome/gui/GHS3DPLUGIN/input/index.doc @@ -2,18 +2,23 @@ \mainpage Introduction to MG-Tetra plug-in -\b MG-Tetra plug-in adds MG-Tetra (former GHS3D) meshing -algorithm to the SALOME Mesh module. +MG-Tetra plug-in adds two meshing algorithm to the SALOME Mesh: +\b MG-Tetra (former GHS3D) and MG-Tetra Optimization. \b MG-Tetra meshing algorithm is destined for: -- Meshing 3D geometric entities: solids are split into tetrahedral (pyramidal) elements. -- Generating 3D meshes from 2D meshes (triangles and quadrangles), working without geometrical objects. + - Meshing 3D geometric entities: solids are split into tetrahedral (pyramidal) elements. + - Generating 3D meshes from 2D meshes (triangles and quadrangles), working without geometrical objects. + +MG-Tetra Optimization algorithm optimizes linear tetrahedral +meshes not based on geometry. \note MG-Tetra plug-in uses MG-Tetra commercial mesher and requires a license to be used within the Mesh module. To obtain a license, visit http://www.meshgems.com/meshgems-products.html -To manage parameters of the MG-Tetra mesher use \subpage ghs3d_hypo_page and \subpage additional_hypo_page +To manage parameters of the MG-Tetra mesher use +\subpage ghs3d_hypo_page and \subpage additional_hypo_page. +Parameters of MG-Tetra Optimization can be managed via \subpage optimization_page. Also all MG-Tetra functionalities are accessible via \subpage ghs3dplugin_python_interface_page "MG-Tetra Python interface". diff --git a/doc/salome/gui/GHS3DPLUGIN/input/optimization_hypo.doc b/doc/salome/gui/GHS3DPLUGIN/input/optimization_hypo.doc new file mode 100644 index 0000000..e1868b5 --- /dev/null +++ b/doc/salome/gui/GHS3DPLUGIN/input/optimization_hypo.doc @@ -0,0 +1,122 @@ +/*! + +\page optimization_page MG-Tetra Optimization Parameters hypothesis + +\anchor optimization_top +MG-Tetra Optimization Parameters hypothesis works only +with MG-Tetra Optimization +algorithm. This algorithm is a commercial software. + +To get a license, visit http://www.meshgems.com/meshgems-products.html + +\tableofcontents + +\section mgtetra_optim_gen_params General parameters + +\image html mgtetra_optim_gen_params.png + +- Name - allows to define the name of the hypothesis (MG-Tetra +Parameters by default). + +- Optimization - sets the optimisation type. If Optimization is: + - No : no optimisation is applied + - Yes (default): optimisation is performed upon mesh generation using + the Optimisation level parameter + - Only : only optimisation is performed to an existing mesh. + +- Optimization level - allows choosing the required +optimization level (higher level of optimization provides better mesh, +but can be time-consuming): + - none + - light + - medium (standard) + - standard+ + - strong + +- Split overconstrained elements - sets treatment of element +having all their vertices on the input surface. +If Split overconstrained elements is: + - No (default): no correction is applied + - Yes : correction is applied upon mesh generation + - Only : only correction is applied to an existing mesh. + +- PThreads mode - sets optimization mode when using multithread +capabilities. Valid values are: + - Safe : slower but quality can only get better + - Aggressive : faster but quality may be altered + - None (default): not activated. + +- Max number of threads - sets the maximum number of threads to +be used in parallel. + +- Smooth off sliver elements - activates elimination of sliver +elements as much as possible. + +- Create new nodes - allows insertion of new nodes. + +\ref optimization_top "Back to top" + + +\section ghs3d_advanced_parameters Advanced parameters + +\image html mgtetra_optim_adv_params.png + +\subsection memory_settings Memory settings + +- Initial memory size - starts MG-Tetra software with +the specified amount of work space, in Mbytes. If this option is checked off, the +software will be started with 100 Megabytes of working space. + +- Maximum memory size - launches MG-Tetra software with +work space limited to the specified amount of RAM, in Mbytes. If this option is +checked off, the software will be launched with 7O% of the total RAM space. + +\subsection log Logs and debug + +- Working directory - allows defining the folder for input and output +files of MG-Tetra software, which are the files starting with "GHS3D_" prefix. + +- Verbose level - to choose verbosity level in the range from +0 to 10. + + - 0, no standard output, + + - 2, prints the data, quality statistics of the skin and final + meshes and indicates when the final mesh is being saved. In addition + the software gives indication regarding the CPU time. + + - 10, same as 2 plus the main steps in the computation, quality + statistics histogram of the skin mesh, quality statistics histogram + together with the characteristics of the final mesh. + +- Print log in a file - if this option is checked on the log is +printed in a file placed in the working directory, otherwise it is +printed on the standard output. + +- Remove log on success - if this option is checked on the log +file is kept only if an error occurs during the computation. This +option is only available if Print log in a file is enabled +(there must be a log file to delete it) and Keep all working + files is disabled (in this case the log file is always kept). + +- Keep all working files - allows checking input and output +files of MG-Tetra software, while usually these files are removed +after the launch of the mesher. The log file (if any) is also kept if +this option is checked. + +\subsection advanced_meshing_options Advanced meshing options + +- A table allows to input in the command line any text for MG-Tetra, +for example, advanced options.
+ +- Add option - adds a line to the table where you can type an +option and its value as text. A check box in the first column +activates/deactivates the option of the current row. A deactivated +option will be erased upon pressing \a Ok. + +
See Also a sample TUI Script of the +\ref tui_ghs3d "creation of a MG-Tetra Optimization hypothesis". + +\ref optimization_top "Back to top" + +*/ diff --git a/idl/GHS3DPlugin_Algorithm.idl b/idl/GHS3DPlugin_Algorithm.idl index f18b3ac..a697472 100644 --- a/idl/GHS3DPlugin_Algorithm.idl +++ b/idl/GHS3DPlugin_Algorithm.idl @@ -54,7 +54,7 @@ module GHS3DPlugin typedef sequence GHS3DEnforcedMeshList; /*! - * GHS3DPlugin_GHS3D: interface of "Tetrahedron (GHS3D)" algorithm + * GHS3DPlugin_GHS3D: interface of "MG-Tetra" algorithm */ interface GHS3DPlugin_GHS3D : SMESH::SMESH_3D_Algo { @@ -62,7 +62,7 @@ module GHS3DPlugin }; /*! - * Parameters of "Tetrahedron (GHS3D)" algorithm + * Parameters of "MG-Tetra" algorithm */ interface GHS3DPlugin_Hypothesis : SMESH::SMESH_Hypothesis { @@ -202,6 +202,49 @@ module GHS3DPlugin */ boolean p_SetEnforcedMesh(in SMESH::SMESH_IDSource theSource, in SMESH::ElementType elementType, in string name, in string groupName) raises (SALOME::SALOME_Exception); }; + + /*! + * GHS3DPlugin_Optimizer: interface of "MG-Tetra Optimization" algorithm + */ + interface GHS3DPlugin_Optimizer : SMESH::SMESH_3D_Algo + { + }; + + enum PThreadsMode { SAFE, AGGRESSIVE, NONE }; + enum Mode { NO, YES, ONLY }; + + /*! + * Parameters of "MG-Tetra Optimization" algorithm + * + * params inherited from GHS3DPlugin_Hypothesis: + * - create new nodes + * - optimization level + * - init and max memory + * - work dir + * - verbosity + * - log to file + * - keep work files + * - remove log file + * - advanced options + */ + interface GHS3DPlugin_OptimizerHypothesis: GHS3DPlugin_Hypothesis + { + void SetOptimization( in Mode optMode ); + Mode GetOptimization(); + + void SetSplitOverConstrained( in Mode ovcMode ); + Mode GetSplitOverConstrained(); + + void SetSmoothOffSlivers( in boolean toSmooth ); + boolean GetSmoothOffSlivers(); + + void SetPThreadsMode( in PThreadsMode mode ); + PThreadsMode GetPThreadsMode(); + + void SetMaximalNumberOfThreads( in short nb ); + short GetMaximalNumberOfThreads(); + }; + }; #endif diff --git a/resources/GHS3DPlugin.xml b/resources/GHS3DPlugin.xml index 684b313..1989d20 100644 --- a/resources/GHS3DPlugin.xml +++ b/resources/GHS3DPlugin.xml @@ -51,6 +51,13 @@ + + + + @@ -71,6 +78,21 @@ + + + MG-Tetra Optimization=Tetrahedron(algo=smeshBuilder.MG_Tetra_Optimization) + MG-Tetra Optimization Parameters=Parameters() + + + diff --git a/src/GHS3DPlugin/CMakeLists.txt b/src/GHS3DPlugin/CMakeLists.txt index 1f49d54..0747cb8 100644 --- a/src/GHS3DPlugin/CMakeLists.txt +++ b/src/GHS3DPlugin/CMakeLists.txt @@ -71,6 +71,9 @@ SET(GHS3DEngine_HEADERS GHS3DPlugin_GHS3D_i.hxx GHS3DPlugin_Hypothesis.hxx GHS3DPlugin_Hypothesis_i.hxx + GHS3DPlugin_Optimizer.hxx + GHS3DPlugin_OptimizerHypothesis.hxx + GHS3DPlugin_OptimizerHypothesis_i.hxx MG_Tetra_API.hxx ) @@ -83,6 +86,9 @@ SET(GHS3DEngine_SOURCES GHS3DPlugin_i.cxx GHS3DPlugin_Hypothesis.cxx GHS3DPlugin_Hypothesis_i.cxx + GHS3DPlugin_Optimizer.cxx + GHS3DPlugin_OptimizerHypothesis.cxx + GHS3DPlugin_OptimizerHypothesis_i.cxx MG_Tetra_API.cxx ) diff --git a/src/GHS3DPlugin/GHS3DPluginBuilder.py b/src/GHS3DPlugin/GHS3DPluginBuilder.py index 2d1a630..d65efc5 100644 --- a/src/GHS3DPlugin/GHS3DPluginBuilder.py +++ b/src/GHS3DPlugin/GHS3DPluginBuilder.py @@ -38,6 +38,12 @@ None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization # V4.1 (partialy redefines V3.1). Issue 0020574 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4 +# import items of enums +for e in GHS3DPlugin.Mode._items: exec('%s = GHS3DPlugin.%s'%(e,e)) +for e in GHS3DPlugin.PThreadsMode._items: exec('%s = GHS3DPlugin.%s'%(e,e)) +Mode_NO, Mode_YES, Mode_ONLY = GHS3DPlugin.Mode._items +Mode_SAFE, Mode_AGGRESSIVE, Mode_NONE = GHS3DPlugin.PThreadsMode._items + #---------------------------- # Mesh algo type identifiers #---------------------------- @@ -45,6 +51,7 @@ None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optim ## Algorithm type: MG-Tetra tetrahedron 3D algorithm, see GHS3D_Algorithm MG_Tetra = "MG-Tetra" GHS3D = MG_Tetra +MG_Tetra_Optimization = "MG-Tetra Optimization" ## Tetrahedron MG-Tetra 3D algorithm # @@ -59,7 +66,7 @@ class GHS3D_Algorithm(Mesh_Algorithm): algoType = MG_Tetra ## doc string of the method in smeshBuilder.Mesh class # @internal - docHelper = "Creates tetrahedron 3D algorithm for volumes" + docHelper = "Creates tetrahedron 3D algorithm" ## Private constructor. # @param mesh parent mesh object algorithm is assigned to @@ -270,3 +277,169 @@ class GHS3D_Algorithm(Mesh_Algorithm): pass pass # end of GHS3D_Algorithm class + + +## MG-Tetra Optimization algorithm - optimizer of tetrahedral meshes +# +# It can be created by calling smeshBuilder.Mesh.Tetrahedron( smeshBuilder.MG_Tetra_Optimization ) +class GHS3D_Optimizer(GHS3D_Algorithm): + + ## name of the dynamic method in smeshBuilder.Mesh class + # @internal + meshMethod = "Tetrahedron" + ## type of algorithm used with helper function in smeshBuilder.Mesh class + # @internal + algoType = MG_Tetra_Optimization + ## doc string of the method in smeshBuilder.Mesh class + # @internal + docHelper = "Creates MG-Tetra optimizer of tetrahedral meshes" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom - not used + def __init__(self, mesh, geom=0): + GHS3D_Algorithm.__init__(self, mesh) + + # remove some inherited methods + # del self.SetToMeshHoles + # del self.SetToMakeGroupsOfDomains + # del self.SetToUseBoundaryRecoveryVersion + # del self.SetFEMCorrection + # del self.SetToRemoveCentralPoint + # del self.SetEnforcedVertex + # del self.SetEnforcedVertexGeom + # del self.RemoveEnforcedVertex + # del self.RemoveEnforcedVertexGeom + # del self.SetEnforcedMesh + # del self.SetTextOption + pass + + ## Defines hypothesis having several parameters + # @return hypothesis object + def Parameters(self): + if not self.params: + self.params = self.Hypothesis("MG-Tetra Optimization Parameters", [], + "libGHS3DEngine.so", UseExisting=0) + pass + return self.params + + ## Set Optimization mode + # @param optMode optimization mode, one of the following values: + # smeshBuilder.Mode_NO, + # smeshBuilder.Mode_YES (default), + # smeshBuilder.MODE_ONLY + def SetOptimizationOnly(self, optMode ): + self.Parameters().SetOptimizationOnly(optMode) + pass + + ## Set mode of splitting over-constrained elements + # @param ovcMode, one of the following values + # smeshBuilder.Mode_NO (default), + # smeshBuilder.Mode_YES, + # smeshBuilder.Mode_ONLY + def SetSplitOverConstrained(self, ovcMode ): + self.Parameters().SetSplitOverConstrained(ovcMode) + pass + + ## Activate smoothing sliver elements: + # @param toSmooth - Boolean flag + def SetSmoothOffSlivers(self, toSmooth ): + self.Parameters().SetSmoothOffSlivers(toSmooth) + pass + + ## Set multithread mode + # @param mode - the mode, one of the following values: + # smeshBuilder.Mode_SAFE, + # smeshBuilder.Mode_AGGRESSIVE, + # smeshBuilder.Mode_NONE (default) + def SetPThreadsMode(self, mode ): + self.Parameters().SetPThreadsMode(mode) + pass + + ## Set maximal number of threads + # @param nb - number of threads + def SetMaximalNumberOfThreads(self, nb ): + self.Parameters().SetMaximalNumberOfThreads(nb) + pass + + + ## Set Optimization level: + # @param level optimization level, one of the following values + # - None_Optimization + # - Light_Optimization + # - Standard_Optimization + # - StandardPlus_Optimization + # - Strong_Optimization. + # . + # Default is Standard_Optimization + def SetOptimizationLevel(self, level): + self.Parameters().SetOptimizationLevel(level) + pass + + ## Set maximal size of memory to be used by the algorithm (in Megabytes). + # @param MB maximal size of memory + def SetMaximumMemory(self, MB): + self.Parameters().SetMaximumMemory(MB) + pass + + ## Set initial size of memory to be used by the algorithm (in Megabytes) in + # automatic memory adjustment mode. + # @param MB initial size of memory + def SetInitialMemory(self, MB): + self.Parameters().SetInitialMemory(MB) + pass + + ## Set path to working directory. + # @param path working directory + def SetWorkingDirectory(self, path): + self.Parameters().SetWorkingDirectory(path) + pass + + ## To keep working files or remove them. + # @param toKeep "keep working files" flag value + def SetKeepFiles(self, toKeep): + self.Parameters().SetKeepFiles(toKeep) + pass + + ## Remove or not the log file (if any) in case of successful computation. + # The log file remains in case of errors anyway. If + # the "keep working files" flag is set to true, this option + # has no effect. + # @param toRemove "remove log on success" flag value + def SetRemoveLogOnSuccess(self, toRemove): + self.Parameters().SetRemoveLogOnSuccess(toRemove) + pass + + ## Print the the log in a file. If set to false, the + # log is printed on the standard output + # @param toPrintLogInFile "print log in a file" flag value + def SetPrintLogInFile(self, toPrintLogInFile): + self.Parameters().SetStandardOutputLog(not toPrintLogInFile) + pass + + ## Set verbosity level [0-10]. + # @param level verbosity level + # - 0 - no standard output, + # - 2 - prints the data, quality statistics of the skin and final meshes and + # indicates when the final mesh is being saved. In addition the software + # gives indication regarding the CPU time. + # - 10 - same as 2 plus the main steps in the computation, quality statistics + # histogram of the skin mesh, quality statistics histogram together with + # the characteristics of the final mesh. + def SetVerboseLevel(self, level): + self.Parameters().SetVerboseLevel(level) + pass + + ## To create new nodes. + # @param toCreate "create new nodes" flag value + def SetToCreateNewNodes(self, toCreate): + self.Parameters().SetToCreateNewNodes(toCreate) + pass + + ## Sets command line option as text. + # @param option command line option + def SetAdvancedOption(self, option): + self.Parameters().SetAdvancedOption(option) + pass + + pass # end of GHS3D_Optimizer class diff --git a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx index 0a1091f..55117ae 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx @@ -135,7 +135,6 @@ static void removeFile( const TCollection_AsciiString& fileName ) GHS3DPlugin_GHS3D::GHS3DPlugin_GHS3D(int hypId, int studyId, SMESH_Gen* gen) : SMESH_3D_Algo(hypId, studyId, gen), _isLibUsed( false ) { - MESSAGE("GHS3DPlugin_GHS3D::GHS3DPlugin_GHS3D"); _name = Name(); _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);// 1 bit /shape type _onlyUnaryInput = false; // Compute() will be called on a compound of solids @@ -143,18 +142,14 @@ GHS3DPlugin_GHS3D::GHS3DPlugin_GHS3D(int hypId, int studyId, SMESH_Gen* gen) _nbShape=0; _compatibleHypothesis.push_back( GHS3DPlugin_Hypothesis::GetHypType()); _compatibleHypothesis.push_back( StdMeshers_ViscousLayers::GetHypType() ); - _requireShape = false; // can work without shape_studyId + _requireShape = false; // can work without shape _smeshGen_i = SMESH_Gen_i::GetSMESHGen(); CORBA::Object_var anObject = _smeshGen_i->GetNS()->Resolve("/myStudyManager"); SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject); - MESSAGE("studyid = " << _studyId); - _study = NULL; _study = aStudyMgr->GetStudyByID(_studyId); - if (!_study->_is_nil()) - MESSAGE("_study->StudyId() = " << _study->StudyId()); _computeCanceled = false; _progressAdvance = 1e-4; @@ -168,7 +163,6 @@ GHS3DPlugin_GHS3D::GHS3DPlugin_GHS3D(int hypId, int studyId, SMESH_Gen* gen) GHS3DPlugin_GHS3D::~GHS3DPlugin_GHS3D() { - MESSAGE("GHS3DPlugin_GHS3D::~GHS3DPlugin_GHS3D"); } //============================================================================= @@ -220,7 +214,6 @@ bool GHS3DPlugin_GHS3D::CheckHypothesis ( SMESH_Mesh& aMesh, TopoDS_Shape GHS3DPlugin_GHS3D::entryToShape(std::string entry) { - MESSAGE("GHS3DPlugin_GHS3D::entryToShape "<_is_nil() ) throw SALOME_Exception("MG-Tetra plugin can't work w/o publishing in the study"); GEOM::GEOM_Object_var aGeomObj; @@ -453,7 +446,6 @@ static void addElemInMeshGroup(SMESH_Mesh* theMesh, SMESHDS_Group* aGroupDS = static_cast( groupDS ); aGroupDS->SMDSGroup().Add(anElem); groupDone = true; -// MESSAGE("Successfully added enforced element to existing group " << groupName); break; } } @@ -465,7 +457,6 @@ static void addElemInMeshGroup(SMESH_Mesh* theMesh, aGroup->SetName( groupName.c_str() ); SMESHDS_Group* aGroupDS = static_cast( aGroup->GetGroupDS() ); aGroupDS->SMDSGroup().Add(anElem); -// MESSAGE("Successfully created enforced vertex group " << groupName); groupDone = true; } if (!groupDone) @@ -489,7 +480,6 @@ static void updateMeshGroups(SMESH_Mesh* theMesh, std::set groupsTo std::string currentGroupName = (string)group->GetName(); if (groupDS->IsEmpty() && groupsToRemove.find(currentGroupName) != groupsToRemove.end()) { // Previous group created by enforced elements - MESSAGE("Delete previous group created by removed enforced elements: " << group->GetName()) theMesh->RemoveGroup(groupDS->GetID()); } } @@ -637,11 +627,9 @@ static bool readGMFFile(MG_Tetra_API* MGOutput, tabRef[GmfHexahedra] = 8; int ver, dim; - MESSAGE("Read " << theFile << " file"); int InpMsh = MGOutput->GmfOpenMesh( theFile, GmfRead, &ver, &dim); if (!InpMsh) return false; - MESSAGE("Done "); // Read ids of domains vector< int > solidIDByDomain; @@ -982,7 +970,6 @@ static bool readGMFFile(MG_Tetra_API* MGOutput, makeDomainGroups( elemsOfDomain, theHelper ); #ifdef _DEBUG_ - MESSAGE("Nb subdomains " << subdomainId2tetraId.size()); std::map >::const_iterator subdomainIt = subdomainId2tetraId.begin(); TCollection_AsciiString aSubdomainFileName = theFile; aSubdomainFileName = aSubdomainFileName + ".subdomain"; @@ -992,7 +979,6 @@ static bool readGMFFile(MG_Tetra_API* MGOutput, for(;subdomainIt != subdomainId2tetraId.end() ; ++subdomainIt) { int subdomainId = subdomainIt->first; std::set tetraIds = subdomainIt->second; - MESSAGE("Subdomain #"<::const_iterator tetraIdsIt = tetraIds.begin(); aSubdomainFile << subdomainId << std::endl; for(;tetraIdsIt != tetraIds.end() ; ++tetraIdsIt) { @@ -1026,7 +1012,6 @@ static bool writeGMFFile(MG_Tetra_API* MGInput GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues & theEnforcedVertices, int & theInvalidEnforcedFlags) { - MESSAGE("writeGMFFile w/o geometry"); std::string tmpStr; int idx, idxRequired = 0, idxSol = 0; const int dummyint = 0; @@ -1800,10 +1785,15 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, } else if ( mgTetra.HasLog() ) { - // get problem description from the log file - _Ghs2smdsConvertor conv( aNodeByGhs3dId, proxyMesh ); - storeErrorDescription( _logInStandardOutput ? 0 : aLogFileName.ToCString(), - mgTetra.GetLog(), conv ); + if( _computeCanceled ) + error( "interruption initiated by user" ); + else + { + // get problem description from the log file + _Ghs2smdsConvertor conv( aNodeByGhs3dId, proxyMesh ); + error( getErrorDescription( _logInStandardOutput ? 0 : aLogFileName.ToCString(), + mgTetra.GetLog(), conv )); + } } else if ( !errStr.empty() ) { @@ -1846,8 +1836,6 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, SMESH_MesherHelper* theHelper) { - MESSAGE("GHS3DPlugin_GHS3D::Compute()"); - theHelper->IsQuadraticSubMesh( theHelper->GetSubShape() ); // a unique working file name @@ -2019,10 +2007,15 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, } else if ( mgTetra.HasLog() ) { - // get problem description from the log file - _Ghs2smdsConvertor conv( aNodeByGhs3dId, proxyMesh ); - storeErrorDescription( _logInStandardOutput ? 0 : aLogFileName.ToCString(), - mgTetra.GetLog(), conv ); + if( _computeCanceled ) + error( "interruption initiated by user" ); + else + { + // get problem description from the log file + _Ghs2smdsConvertor conv( aNodeByGhs3dId, proxyMesh ); + error( getErrorDescription( _logInStandardOutput ? 0 : aLogFileName.ToCString(), + mgTetra.GetLog(), conv )); + } } else { // the log file is empty @@ -2378,17 +2371,13 @@ static char* getIds( char* ptr, int nbIds, vector& ids ) */ //================================================================================ -bool GHS3DPlugin_GHS3D::storeErrorDescription(const char* logFile, - const std::string& log, - const _Ghs2smdsConvertor & toSmdsConvertor ) +SMESH_ComputeErrorPtr +GHS3DPlugin_GHS3D::getErrorDescription(const char* logFile, + const std::string& log, + const _Ghs2smdsConvertor & toSmdsConvertor, + const bool isOk/* = false*/ ) { - if(_computeCanceled) - return error(SMESH_Comment("interruption initiated by user")); - - // read file - // SMESH_File file( logFile.ToCString() ); - // if ( file.size() == 0 ) - // return error( SMESH_Comment("See ") << logFile << " for problem description"); + SMESH_ComputeErrorPtr err = SMESH_ComputeError::New( COMPERR_ALGO_FAILED ); char* ptr = const_cast( log.c_str() ); char* buf = ptr, * bufEnd = ptr + log.size(); @@ -2426,7 +2415,7 @@ bool GHS3DPlugin_GHS3D::storeErrorDescription(const char* logFile if ( strncmp( ptr, "ERR ", 4 ) != 0 ) continue; - list badElems; + list& badElems = err->myBadElements; vector nodeIds; ptr += 4; @@ -2600,13 +2589,6 @@ bool GHS3DPlugin_GHS3D::storeErrorDescription(const char* logFile // continue; // not to report different types of errors with bad elements // } - // store bad elements - //if ( allElemsOk ) { - list::iterator elem = badElems.begin(); - for ( ; elem != badElems.end(); ++elem ) - addBadInputElement( *elem ); - //} - // make error text string text = translateError( errNum ); if ( errDescription.find( text ) == text.npos ) { @@ -2631,14 +2613,20 @@ bool GHS3DPlugin_GHS3D::storeErrorDescription(const char* logFile } } - if ( logFile && logFile[0] ) + if ( !isOk && logFile && logFile[0] ) { if ( errDescription.empty() ) errDescription << "See " << logFile << " for problem description"; else errDescription << "\nSee " << logFile << " for more information"; } - return error( errDescription ); + + err->myComment = errDescription; + + if ( err->myComment.empty() && err->myBadElements.empty() ) + err = SMESH_ComputeError::New(); // OK + + return err; } //================================================================================ @@ -2936,7 +2924,7 @@ double GHS3DPlugin_GHS3D::GetProgress() const if ( _isLibUsed ) { // this->_progress is advanced by MG_Tetra_API according to messages from MG library - // but sharply. Advanced it a bit to get smoother advancement. + // but sharply. Advance it a bit to get smoother advancement. GHS3DPlugin_GHS3D* me = const_cast( this ); if ( _progress < 0.1 ) // the first message is at 10% me->_progress = GetProgressByTic(); diff --git a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx index 7d9a359..b5f4c8b 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx +++ b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx @@ -50,6 +50,7 @@ class TopoDS_Shape; class GHS3DPlugin_GHS3D: public SMESH_3D_Algo { public: + GHS3DPlugin_GHS3D(int hypId, int studyId, SMESH_Gen* gen); virtual ~GHS3DPlugin_GHS3D(); @@ -75,20 +76,23 @@ public: bool importGMFMesh(const char* aGMFFileName, SMESH_Mesh& aMesh); + virtual double GetProgress() const; + + static const char* Name() { return "MG-Tetra"; } - virtual double GetProgress() const; + static SMESH_ComputeErrorPtr getErrorDescription(const char* logFile, + const std::string& log, + const _Ghs2smdsConvertor & toSmdsConvertor, + const bool isOK = false); protected: const GHS3DPlugin_Hypothesis* _hyp; const StdMeshers_ViscousLayers* _viscousLayersHyp; std::string _genericName; - + private: - bool storeErrorDescription(const char* logFile, - const std::string& log, - const _Ghs2smdsConvertor & toSmdsConvertor ); TopoDS_Shape entryToShape(std::string entry); int _iShape; diff --git a/src/GHS3DPlugin/GHS3DPlugin_GHS3D_i.cxx b/src/GHS3DPlugin/GHS3DPlugin_GHS3D_i.cxx index 2ab6dc5..4dc8a18 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_GHS3D_i.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_GHS3D_i.cxx @@ -24,13 +24,16 @@ // $Header$ // #include "GHS3DPlugin_GHS3D_i.hxx" -#include "SMESH_Gen.hxx" -#include "SMESH_Mesh_i.hxx" -#include "SMESH_Gen_i.hxx" + #include "GHS3DPlugin_GHS3D.hxx" -#include "SMESH_PythonDump.hxx" +#include "GHS3DPlugin_Optimizer.hxx" + +#include +#include +#include +#include -#include "utilities.h" +#include #include //============================================================================= @@ -49,7 +52,6 @@ GHS3DPlugin_GHS3D_i::GHS3DPlugin_GHS3D_i (PortableServer::POA_ptr thePOA, SMESH_Algo_i( thePOA ), SMESH_3D_Algo_i( thePOA ) { - MESSAGE( "GHS3DPlugin_GHS3D_i::GHS3DPlugin_GHS3D_i" ); myBaseImpl = new ::GHS3DPlugin_GHS3D (theGenImpl->GetANewId(), theStudyId, theGenImpl ); @@ -65,7 +67,6 @@ GHS3DPlugin_GHS3D_i::GHS3DPlugin_GHS3D_i (PortableServer::POA_ptr thePOA, GHS3DPlugin_GHS3D_i::~GHS3DPlugin_GHS3D_i() { - MESSAGE( "GHS3DPlugin_GHS3D_i::~GHS3DPlugin_GHS3D_i" ); } //============================================================================= @@ -78,7 +79,6 @@ GHS3DPlugin_GHS3D_i::~GHS3DPlugin_GHS3D_i() ::GHS3DPlugin_GHS3D* GHS3DPlugin_GHS3D_i::GetImpl() { - MESSAGE( "GHS3DPlugin_GHS3D_i::GetImpl" ); return ( ::GHS3DPlugin_GHS3D* )myBaseImpl; } @@ -92,7 +92,6 @@ GHS3DPlugin_GHS3D_i::~GHS3DPlugin_GHS3D_i() SMESH::SMESH_Mesh_ptr GHS3DPlugin_GHS3D_i::importGMFMesh(const char* theGMFFileName) { - MESSAGE( "GHS3DPlugin_GHS3D_i::importGMFMesh" ); SMESH_Gen_i* smeshGen = SMESH_Gen_i::GetSMESHGen(); SMESH::SMESH_Mesh_ptr theMesh = smeshGen->CreateEmptyMesh(); smeshGen->RemoveLastFromPythonScript(smeshGen->GetCurrentStudy()->StudyId()); @@ -114,3 +113,25 @@ SMESH::SMESH_Mesh_ptr GHS3DPlugin_GHS3D_i::importGMFMesh(const char* theGMFFileN } return theMesh; } + +//============================================================================= +/*! + * GHS3DPlugin_Optimizer_i::GHS3DPlugin_Optimizer_i + * + * Constructor + */ +//============================================================================= + +GHS3DPlugin_Optimizer_i::GHS3DPlugin_Optimizer_i (PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ), + SMESH_Algo_i( thePOA ), + SMESH_3D_Algo_i( thePOA ) +{ + myBaseImpl = new ::GHS3DPlugin_Optimizer (theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + diff --git a/src/GHS3DPlugin/GHS3DPlugin_GHS3D_i.hxx b/src/GHS3DPlugin/GHS3DPlugin_GHS3D_i.hxx index dc27c27..cf77904 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_GHS3D_i.hxx +++ b/src/GHS3DPlugin/GHS3DPlugin_GHS3D_i.hxx @@ -53,4 +53,18 @@ public: virtual SMESH::SMESH_Mesh_ptr importGMFMesh(const char* theGMFFileName); }; +// ====================================================== +// MG-Tetra Optimization 3d algorithm +// ====================================================== +class GHS3DPlugin_Optimizer_i: + public virtual POA_GHS3DPlugin::GHS3DPlugin_Optimizer, + public virtual SMESH_3D_Algo_i +{ +public: + // Constructor + GHS3DPlugin_Optimizer_i (PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); +}; + #endif diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx index 0e480bc..2f2650e 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx @@ -1461,7 +1461,7 @@ bool GHS3DPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* hyp, const bool hasShapeToMesh, - const bool forExucutable) + const bool forExecutable) { std::string cmd = GetExeName(); // check if any option is overridden by hyp->myTextOption @@ -1523,7 +1523,7 @@ std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* h // to create internal nodes if ( no_int_points && !toCreateNewNodes ) { - if ( forExucutable ) + if ( forExecutable ) cmd += " --no_internal_points"; else cmd += " --internalpoints no"; @@ -1546,7 +1546,7 @@ std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* h // to remove initial central point. if ( rem && hyp && hyp->myToRemoveCentralPoint) { - if ( forExucutable ) + if ( forExecutable ) cmd += " --no_initial_central_point"; else cmd += " --centralpoint no"; @@ -1559,7 +1559,7 @@ std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* h // to define volumic gradation. if ( gra && hyp ) { - if ( forExucutable ) + if ( forExecutable ) cmd += " -Dcpropa=" + SMESH_Comment( hyp->myGradation ); else cmd += " --gradation " + SMESH_Comment( hyp->myGradation ); diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx index c6990a3..afcc808 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx @@ -323,8 +323,6 @@ public: // Persistence virtual std::ostream & SaveTo(std::ostream & save); virtual std::istream & LoadFrom(std::istream & load); - friend GHS3DPLUGIN_EXPORT std::ostream & operator <<(std::ostream & save, GHS3DPlugin_Hypothesis & hyp); - friend GHS3DPLUGIN_EXPORT std::istream & operator >>(std::istream & load, GHS3DPlugin_Hypothesis & hyp); /*! * \brief Does nothing @@ -336,7 +334,7 @@ public: */ virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0); -private: +protected: bool myToMeshHoles; bool myToMakeGroupsOfDomains; diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx index acc6472..da36903 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx @@ -23,26 +23,20 @@ // #include "GHS3DPlugin_Hypothesis_i.hxx" -#include "SMESH_Gen.hxx" -#include "SMESH_PythonDump.hxx" -//#include "SMESH_Mesh.hxx" -//#include "SMESH_ProxyMesh.hxx" -//#include - -#include "Utils_CorbaException.hxx" -#include "utilities.h" -#include "SMESH_Mesh_i.hxx" -#include "SMESH_Group_i.hxx" -#include "SMESH_Gen_i.hxx" -#include "SMESH_TypeDefs.hxx" -#include "SMESHDS_GroupBase.hxx" +#include +#include + +#include +#include +#include +#include +#include +//#include +#include // SALOME KERNEL includes -#include "SALOMEDSClient.hxx" -#include -// // IDL headers -// #include -// #include CORBA_SERVER_HEADER(SALOMEDS) +// #include +// #include using namespace std; @@ -56,7 +50,6 @@ GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr theP : SALOME::GenericObj_i( thePOA ), SMESH_Hypothesis_i( thePOA ) { - MESSAGE( "GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i" ); myBaseImpl = new ::GHS3DPlugin_Hypothesis (theGenImpl->GetANewId(), theStudyId, theGenImpl); @@ -68,7 +61,6 @@ GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr theP GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i() { - MESSAGE( "GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i" ); } //======================================================================= @@ -118,7 +110,7 @@ CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMakeGroupsOfDomains() //======================================================================= void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Long MB) - throw ( SALOME::SALOME_Exception ) + throw ( SALOME::SALOME_Exception ) { if ( MB == 0 ) THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM ); @@ -169,7 +161,7 @@ void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level) throw ( SALOME::SALOME_Exception ) { ::GHS3DPlugin_Hypothesis::OptimizationLevel l = - (::GHS3DPlugin_Hypothesis::OptimizationLevel) level; + (::GHS3DPlugin_Hypothesis::OptimizationLevel) level; if ( l < ::GHS3DPlugin_Hypothesis::None || l > ::GHS3DPlugin_Hypothesis::Strong ) THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM ); @@ -465,39 +457,34 @@ CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetRemoveLogOnSuccess() //======================================================================= bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size) - throw (SALOME::SALOME_Exception) { + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - MESSAGE("IDL : SetEnforcedVertex( "<< x << ", " << y << ", " << z << ", " << size << ")"); return p_SetEnforcedVertex(size, x, y, z); } bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName) - throw (SALOME::SALOME_Exception) { + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - MESSAGE("IDL : SetEnforcedVertexNamed( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ")"); return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", ""); } bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName) - throw (SALOME::SALOME_Exception) { + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theGroupName << ")"); return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName); } bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName) - throw (SALOME::SALOME_Exception) { + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ", " << theGroupName << ")"); return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName); } bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size) - throw (SALOME::SALOME_Exception) { + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { - MESSAGE("theVertex shape type is not VERTEX or COMPOUND"); THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); } @@ -529,21 +516,18 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVe return false; measureOp->PointCoordinates (theVertex, x, y, z); - MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z); } string theVertexName = theVertex->GetName(); - MESSAGE("IDL : SetEnforcedVertexGeom( "<< theVertexEntry << ", " << size<< ")"); return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound); } bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName) - throw (SALOME::SALOME_Exception) { + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { - MESSAGE("theVertex shape type is not VERTEX or COMPOUND"); THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); } @@ -575,21 +559,18 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ return false; measureOp->PointCoordinates (theVertex, x, y, z); - MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z); } string theVertexName = theVertex->GetName(); - MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theVertexEntry << ", " << size<< ", " << theGroupName << ")"); return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound); } bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z, - const char* theVertexName, const char* theVertexEntry, const char* theGroupName, - CORBA::Boolean isCompound) - throw (SALOME::SALOME_Exception) { + const char* theVertexName, const char* theVertexEntry, const char* theGroupName, + CORBA::Boolean isCompound) + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - MESSAGE("IDL : p_SetEnforcedVertex(" << size << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\", " << isCompound<< ")"); bool newValue = false; ::GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap coordsList; @@ -601,20 +582,13 @@ bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::D coords.push_back(y); coords.push_back(z); if (coordsList.find(coords) == coordsList.end()) { - MESSAGE("Coords not found: add it in coordsList"); newValue = true; } else { - MESSAGE("Coords already found, compare names"); ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z); if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) { - MESSAGE("The names or size are different: update"); -// this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z); newValue = true; } - else { - MESSAGE("The names and size are identical"); - } } if (newValue) { @@ -633,24 +607,15 @@ bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::D } } else { -// if (isCompound || (!isCompound && !string(theVertexEntry).empty())) { enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry(); -// ::BLSURFPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry); if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) { - MESSAGE("Geom entry not found: add it in enfVertexEntryList"); newValue = true; } else { - MESSAGE("Geom entry already found, compare names"); ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry); if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) { - MESSAGE("The names or size are different: update"); -// this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z); newValue = true; } - else { - MESSAGE("The names and size are identical"); - } } if (newValue) { @@ -664,7 +629,6 @@ bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::D if (newValue) this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound); - MESSAGE("IDL : SetEnforcedVertexEntry END"); return newValue; } @@ -682,12 +646,7 @@ CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA return isDone; } catch (const std::invalid_argument& ex) { - SALOME::ExceptionStruct ExDescription; - ExDescription.text = ex.what(); - ExDescription.type = SALOME::BAD_PARAM; - ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; - ExDescription.lineNumber = 513; - throw SALOME::SALOME_Exception(ExDescription); + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); @@ -704,7 +663,6 @@ CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ ASSERT(myBaseImpl); if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { - MESSAGE("theVertex shape type is not VERTEX or COMPOUND"); THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); } @@ -733,12 +691,7 @@ CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ return isDone; } catch (const std::invalid_argument& ex) { - SALOME::ExceptionStruct ExDescription; - ExDescription.text = ex.what(); - ExDescription.type = SALOME::BAD_PARAM; - ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; - ExDescription.lineNumber = 538; - throw SALOME::SALOME_Exception(ExDescription); + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); @@ -780,9 +733,9 @@ GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVerti enfVertex->isCompound = currentVertex->isCompound; result[i]=enfVertex; - } + } -// SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()"; + // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()"; return result._retn(); } @@ -801,12 +754,7 @@ bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Doub return res; } catch (const std::invalid_argument& ex) { - SALOME::ExceptionStruct ExDescription; - ExDescription.text = ex.what(); - ExDescription.type = SALOME::BAD_PARAM; - ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; - ExDescription.lineNumber = 625; - throw SALOME::SALOME_Exception(ExDescription); + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); @@ -819,7 +767,6 @@ bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr th ASSERT(myBaseImpl); if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { - MESSAGE("theVertex shape type is not VERTEX or COMPOUND"); THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); } @@ -846,12 +793,7 @@ bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr th return res; } catch (const std::invalid_argument& ex) { - SALOME::ExceptionStruct ExDescription; - ExDescription.text = ex.what(); - ExDescription.type = SALOME::BAD_PARAM; - ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; - ExDescription.lineNumber = 648; - throw SALOME::SALOME_Exception(ExDescription); + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); @@ -907,9 +849,9 @@ GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes( enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str()); result[i]=enfMesh; - } + } -// SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()"; + // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()"; return result._retn(); } @@ -920,16 +862,7 @@ GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes( bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName) throw (SALOME::SALOME_Exception) { -// #if GHS3D_VERSION >= 42 return p_SetEnforcedMesh(theSource, theType, "", theGroupName); -// #else -// SALOME::ExceptionStruct ExDescription; -// ExDescription.text = "Bad version of GHS3D. It must >= 4.2."; -// ExDescription.type = SALOME::BAD_PARAM; -// ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; -// ExDescription.lineNumber = 719; -// throw SALOME::SALOME_Exception(ExDescription); -// #endif } /*! @@ -938,17 +871,7 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_pt bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType) throw (SALOME::SALOME_Exception) { -// MESSAGE("GHS3DPlugin_Hypothesis_i::SetEnforcedMesh"); -// #if GHS3D_VERSION >= 42 return p_SetEnforcedMesh(theSource, theType); -// #else -// SALOME::ExceptionStruct ExDescription; -// ExDescription.text = "Bad version of GHS3D. It must >= 4.2."; -// ExDescription.type = SALOME::BAD_PARAM; -// ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; -// ExDescription.lineNumber = 750; -// throw SALOME::SALOME_Exception(ExDescription); -// #endif } /*! @@ -957,16 +880,7 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSour bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName) throw (SALOME::SALOME_Exception) { -// #if GHS3D_VERSION >= 42 return p_SetEnforcedMesh(theSource, theType, "", theGroupName); -// #else -// SALOME::ExceptionStruct ExDescription; -// ExDescription.text = "Bad version of GHS3D. It must >= 4.2."; -// ExDescription.type = SALOME::BAD_PARAM; -// ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; -// ExDescription.lineNumber = 750; -// throw SALOME::SALOME_Exception(ExDescription); -// #endif } /*! @@ -975,64 +889,32 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSourc bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize) throw (SALOME::SALOME_Exception) { -// #if GHS3D_VERSION >= 42 return p_SetEnforcedMesh(theSource, theType); -// #else -// SALOME::ExceptionStruct ExDescription; -// ExDescription.text = "Bad version of GHS3D. It must >= 4.2."; -// ExDescription.type = SALOME::BAD_PARAM; -// ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; -// ExDescription.lineNumber = 750; -// throw SALOME::SALOME_Exception(ExDescription); -// #endif } -bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theName, const char* theGroupName) +bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, + SMESH::ElementType theType, + const char* theName, + const char* theGroupName) throw (SALOME::SALOME_Exception) { - MESSAGE("GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh"); ASSERT(myBaseImpl); - + if (CORBA::is_nil( theSource )) - { - SALOME::ExceptionStruct ExDescription; - ExDescription.text = "The source mesh CORBA object is NULL"; - ExDescription.type = SALOME::BAD_PARAM; - ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; - ExDescription.lineNumber = 840; - throw SALOME::SALOME_Exception(ExDescription); - } - + THROW_SALOME_CORBA_EXCEPTION( "The source mesh CORBA object is NULL" ,SALOME::BAD_PARAM ); + switch (theType) { - case SMESH::NODE: - MESSAGE("Required type is NODE"); - break; - case SMESH::EDGE: - MESSAGE("Required type is EDGE"); - break; - case SMESH::FACE: - MESSAGE("Required type is FACE"); - break; - default: - MESSAGE("Incompatible required type: " << theType); - return false; + case SMESH::NODE: + case SMESH::EDGE: + case SMESH::FACE: break; + default: + return false; } -// MESSAGE("Required type is "<GetTypes(); - MESSAGE("Available types:"); - for ( CORBA::ULong i=0;ilength();i++){MESSAGE(types[i]);} if ( types->length() >= 1 && types[types->length()-1] < theType) { - MESSAGE("Required type not available"); return false; -// SALOME::ExceptionStruct ExDescription; -// ExDescription.text = "The source mesh has bad type"; -// ExDescription.type = SALOME::BAD_PARAM; -// ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; -// ExDescription.lineNumber = 840; -// throw SALOME::SALOME_Exception(ExDescription); } - SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource); @@ -1074,21 +956,20 @@ bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSo } else if (theGroup_i)// && types->length() == 1 && types[0] == theType) { - MESSAGE("The source is a group") - try { - bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName); - if ( theGroupName && theGroupName[0] ) { - SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " - << theSource << ", " << theType << ", \"" << theGroupName << "\" )"; - } - else { - SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " - << theSource << ", " << theType << " )"; - } - return res; + try { + bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName); + if ( theGroupName && theGroupName[0] ) { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " + << theSource << ", " << theType << ", \"" << theGroupName << "\" )"; } - catch (const std::invalid_argument& ex) { - SALOME::ExceptionStruct ExDescription; + else { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " + << theSource << ", " << theType << " )"; + } + return res; + } + catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; ExDescription.text = ex.what(); ExDescription.type = SALOME::BAD_PARAM; ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; @@ -1101,17 +982,16 @@ bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSo } else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType) { - MESSAGE("The source is a group on geom") try { - bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName); - if ( theGroupName && theGroupName[0] ) { - SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " - << theSource << ", " << theType << ", \"" << theGroupName << "\" )"; - } - else { - SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " - << theSource << ", " << theType << " )"; - } + bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName); + if ( theGroupName && theGroupName[0] ) { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " + << theSource << ", " << theType << ", \"" << theGroupName << "\" )"; + } + else { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " + << theSource << ", " << theType << " )"; + } return res; } catch (const std::invalid_argument& ex) { @@ -1149,4 +1029,3 @@ CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type ) { return type == SMESH::DIM_3D; } - diff --git a/src/GHS3DPlugin/GHS3DPlugin_Optimizer.cxx b/src/GHS3DPlugin/GHS3DPlugin_Optimizer.cxx new file mode 100644 index 0000000..21cac8e --- /dev/null +++ b/src/GHS3DPlugin/GHS3DPlugin_Optimizer.cxx @@ -0,0 +1,444 @@ +// Copyright (C) 2004-2016 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 : GHS3DPlugin_Optimizer.cxx +// Created : Mon Oct 31 20:05:28 2016 + +#include "GHS3DPlugin_Optimizer.hxx" + +#include "GHS3DPlugin_GHS3D.hxx" +#include "GHS3DPlugin_OptimizerHypothesis.hxx" +#include "MG_Tetra_API.hxx" + +#include +#include +#include +#include +#include + +#include + +//================================================================================ +/*! + * \brief Constructor + */ +//================================================================================ + +GHS3DPlugin_Optimizer::GHS3DPlugin_Optimizer(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_3D_Algo(hypId, studyId, gen) +{ + _name = Name(); + _compatibleHypothesis.push_back( GHS3DPlugin_OptimizerHypothesis::GetHypType()); + _requireShape = false; // work without shape only +} + +//================================================================================ +/*! + * \brief Get a hypothesis + */ +//================================================================================ + +bool GHS3DPlugin_Optimizer::CheckHypothesis(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + Hypothesis_Status& aStatus) +{ + _hyp = NULL; + + const std::list & hyps = GetUsedHypothesis(aMesh, aShape); + if ( !hyps.empty() ) + _hyp = dynamic_cast< const GHS3DPlugin_OptimizerHypothesis* >( hyps.front() ); + + aStatus = HYP_OK; + return true; +} + +//================================================================================ +/*! + * \brief Terminate a process + */ +//================================================================================ + +void GHS3DPlugin_Optimizer::CancelCompute() +{ + _computeCanceled = true; +} + +//================================================================================ +/*! + * \brief Evaluate nb of elements + */ +//================================================================================ + +bool GHS3DPlugin_Optimizer::Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, + MapShapeNbElems& aResMap) +{ + return false; +} +//================================================================================ +/*! + * \brief Does nothing + */ +//================================================================================ + +bool GHS3DPlugin_Optimizer::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) +{ + return false; +} + +namespace +{ + //================================================================================ + /*! + * \brief Compute average size of tetrahedra araound a node + */ + //================================================================================ + + double getSizeAtNode( const SMDS_MeshNode* node ) + { + double size = 0; + int nbTet = 0; + + SMDS_VolumeTool vt; + vt.SetExternalNormal(); + + SMDS_ElemIteratorPtr volIt = node->GetInverseElementIterator(SMDSAbs_Volume); + while ( volIt->more() ) + { + const SMDS_MeshElement* vol = volIt->next(); + if ( vol->GetGeomType() != SMDSGeom_TETRA ) + continue; + double volSize = 0.; + int nbLinks = 0; + int dN = vol->IsQuadratic() ? 2 : 1; + vt.Set( vol ); + for ( int iF = 0, nbF = vt.NbFaces(); iF < nbF; ++iF ) + { + const SMDS_MeshNode** nodes = vt. GetFaceNodes( iF ); + for ( int iN = 0, nbN = vt.NbFaceNodes( iF ); iN < nbN; iN += dN ) + if ( nodes[ iN ] < nodes[ iN + dN ]) // use a link once + { + volSize += SMESH_TNodeXYZ( nodes[ iN ]).Distance( nodes[ iN + dN ]); + ++nbLinks; + } + } + size += volSize / nbLinks; + ++nbTet; + } + return nbTet > 0 ? size/nbTet : 0.; + } + + //================================================================================ + /*! + * \brief Write a mesh file and a solution file + */ + //================================================================================ + + bool writeGMFFile( MG_Tetra_API* theMGInput, + SMESH_MesherHelper* theHelper, + const std::string& theMeshFileName, + const std::string& theSolFileName ) + { + const int tag = 0; + + int mfile = theMGInput->GmfOpenMesh( theMeshFileName.c_str(), GmfWrite, GMFVERSION,GMFDIMENSION ); + int sfile = theMGInput->GmfOpenMesh( theSolFileName.c_str(), GmfWrite, GMFVERSION,GMFDIMENSION ); + if ( !mfile || !sfile ) + return false; + + // write all nodes and volume size at them + + SMESHDS_Mesh* meshDS = theHelper->GetMeshDS(); + if ( meshDS->NbNodes() != meshDS->MaxNodeID() ) + meshDS->compactMesh(); + + theMGInput->GmfSetKwd( mfile, GmfVertices, meshDS->NbNodes() ); + int TypTab[] = { GmfSca }; + theMGInput->GmfSetKwd( sfile, GmfSolAtVertices, meshDS->NbNodes(), 1, TypTab); + + SMDS_NodeIteratorPtr nodeIt = theHelper->GetMeshDS()->nodesIterator(); + while ( nodeIt->more() ) + { + const SMDS_MeshNode* node = nodeIt->next(); + theMGInput->GmfSetLin( mfile, GmfVertices, node->X(), node->Y(), node->Z(), tag ); + + double size = getSizeAtNode( node ); + theMGInput->GmfSetLin( sfile, GmfSolAtVertices, &size ); + } + + // write all triangles + + theMGInput->GmfSetKwd( mfile, GmfTriangles, meshDS->GetMeshInfo().NbTriangles() ); + SMDS_ElemIteratorPtr triaIt = meshDS->elementGeomIterator( SMDSGeom_TRIANGLE ); + while ( triaIt->more() ) + { + const SMDS_MeshElement* tria = triaIt->next(); + theMGInput->GmfSetLin( mfile, GmfTriangles, + tria->GetNode(0)->GetID(), + tria->GetNode(1)->GetID(), + tria->GetNode(2)->GetID(), + tag ); + } + + // write all tetra + + theMGInput->GmfSetKwd( mfile, GmfTetrahedra, meshDS->GetMeshInfo().NbTetras() ); + SMDS_ElemIteratorPtr tetIt = meshDS->elementGeomIterator( SMDSGeom_TETRA ); + while ( tetIt->more() ) + { + const SMDS_MeshElement* tet = tetIt->next(); + theMGInput->GmfSetLin( mfile, GmfTetrahedra, + tet->GetNode(0)->GetID(), + tet->GetNode(2)->GetID(), + tet->GetNode(1)->GetID(), + tet->GetNode(3)->GetID(), + tag ); + } + + theMGInput->GmfCloseMesh( mfile ); + theMGInput->GmfCloseMesh( sfile ); + + return true; + } + + //================================================================================ + /*! + * \brief Read optimized tetrahedra + */ + //================================================================================ + + bool readGMFFile( MG_Tetra_API* theMGOutput, + SMESH_MesherHelper* theHelper, + const std::string& theMeshFileName ) + { + int ver, dim, tag; + int inFile = theMGOutput->GmfOpenMesh( theMeshFileName.c_str(), GmfRead, &ver, &dim); + if ( !inFile ) + return false; + + SMESHDS_Mesh* meshDS = theHelper->GetMeshDS(); + + int nbNodes = theMGOutput->GmfStatKwd( inFile, GmfVertices ); + int nbTet = theMGOutput->GmfStatKwd( inFile, GmfTetrahedra ); + int nbNodesOld = meshDS->NbNodes(); + int nbTetOld = meshDS->GetMeshInfo().NbTetras(); + std::cout << "Optimization input: " + << nbNodesOld << " nodes, \t" << nbTetOld << " tetra" << std::endl; + std::cout << "Optimization output: " + << nbNodes << " nodes, \t" << nbTet << " tetra" << std::endl; + + double x,y,z; + int i1, i2, i3, i4; + theMGOutput->GmfGotoKwd( inFile, GmfVertices ); + + if ( nbNodes == nbNodesOld && nbTet == nbTetOld ) + { + // move nodes + SMDS_NodeIteratorPtr nodeIt = theHelper->GetMeshDS()->nodesIterator(); + while ( nodeIt->more() ) + { + const SMDS_MeshNode* node = nodeIt->next(); + theMGOutput->GmfGetLin( inFile, GmfVertices, &x, &y, &z, &tag ); + meshDS->MoveNode( node, x,y,z ); + } + + // update tetra + const SMDS_MeshNode* nodes[ 4 ]; + theMGOutput->GmfGotoKwd( inFile, GmfTetrahedra ); + SMDS_ElemIteratorPtr tetIt = meshDS->elementGeomIterator( SMDSGeom_TETRA ); + for ( int i = 0; i < nbTet; ++i ) + { + const SMDS_MeshElement* tet = tetIt->next(); + theMGOutput->GmfGetLin( inFile, GmfTetrahedra, &i1, &i2, &i3, &i4, &tag); + nodes[ 0 ] = meshDS->FindNode( i1 ); + nodes[ 1 ] = meshDS->FindNode( i3 ); + nodes[ 2 ] = meshDS->FindNode( i2 ); + nodes[ 3 ] = meshDS->FindNode( i4 ); + meshDS->ChangeElementNodes( tet, &nodes[0], 4 ); + } + } + else // tetra added/removed + { + // move or add nodes + for ( int iN = 1; iN <= nbNodes; ++iN ) + { + theMGOutput->GmfGetLin( inFile, GmfVertices, &x, &y, &z, &tag ); + const SMDS_MeshNode* node = meshDS->FindNode( iN ); + if ( !node ) + node = meshDS->AddNode( x,y,z ); + else + meshDS->MoveNode( node, x,y,z ); + } + + // remove tetrahedra + SMDS_ElemIteratorPtr tetIt = meshDS->elementGeomIterator( SMDSGeom_TETRA ); + while ( tetIt->more() ) + meshDS->RemoveFreeElement( tetIt->next(), /*sm=*/0 ); + + // add tetrahedra + theMGOutput->GmfGotoKwd( inFile, GmfTetrahedra ); + for ( int i = 0; i < nbTet; ++i ) + { + theMGOutput->GmfGetLin( inFile, GmfTetrahedra, &i1, &i2, &i3, &i4, &tag); + meshDS->AddVolume( meshDS->FindNode( i1 ), + meshDS->FindNode( i3 ), + meshDS->FindNode( i2 ), + meshDS->FindNode( i4 )); + } + } + + // avoid "No mesh elements assigned to a sub-shape" error + theHelper->GetMesh()->GetSubMesh( theHelper->GetSubShape() )->SetIsAlwaysComputed( true ); + + return true; + } + + void getNodeByGhsId( SMESH_Mesh& mesh, std::vector & nodeByGhsId ) + { + SMESHDS_Mesh* meshDS = mesh.GetMeshDS(); + const int nbNodes = meshDS->NbNodes(); + nodeByGhsId.resize( nbNodes + 1 ); + SMDS_NodeIteratorPtr nodeIt = meshDS->nodesIterator(); + while ( nodeIt->more() ) + { + const SMDS_MeshNode* node = nodeIt->next(); + if ( node->GetID() <= nbNodes ) + nodeByGhsId[ node->GetID() ] = node; +#ifdef _DEBUG_ + else + throw SALOME_Exception(LOCALIZED ("bad ID -- not compacted mesh")); +#endif + } + } + + void removeFile(const std::string& name) + { + SMESH_File( name ).remove(); + } +} + +//================================================================================ +/*! + * \brief Optimize an existing tetrahedral mesh + */ +//================================================================================ + +bool GHS3DPlugin_Optimizer::Compute(SMESH_Mesh& theMesh, + SMESH_MesherHelper* theHelper) +{ + if ( theMesh.NbTetras() == 0 ) + return error( COMPERR_BAD_INPUT_MESH, "No tetrahedra" ); + if ( theMesh.NbTetras( ORDER_QUADRATIC ) > 0 ) + return error( COMPERR_BAD_INPUT_MESH, "Quadratic mesh can't be optimized" ); + if ( theMesh.NbTriangles() == 0 ) + return error( COMPERR_BAD_INPUT_MESH, "2D mesh must exist around tetrahedra" ); + + std::string aGenericName = GHS3DPlugin_Hypothesis::GetFileName(_hyp); + std::string aLogFileName = aGenericName + ".log"; // log + std::string aGMFFileName = aGenericName + ".mesh"; // input GMF mesh file + std::string aSolFileName = aGenericName + ".sol"; // input size map file + std::string aResultFileName = aGenericName + "_Opt.mesh"; // out GMF mesh file + std::string aResSolFileName = aGenericName + "_Opt.sol"; // out size map file + + MG_Tetra_API mgTetra( _computeCanceled, _progress ); + + bool Ok = writeGMFFile( &mgTetra, theHelper, aGMFFileName, aSolFileName ); + + // ----------------- + // run MG-Tetra mesher + // ----------------- + + bool logInStandardOutput = _hyp ? _hyp->GetStandardOutputLog() : false; + bool removeLogOnSuccess = _hyp ? _hyp->GetRemoveLogOnSuccess() : true; + bool keepFiles = _hyp ? _hyp->GetKeepFiles() : false; + + std::string cmd = GHS3DPlugin_OptimizerHypothesis::CommandToRun( _hyp ); + + if ( mgTetra.IsExecutable() ) + { + cmd += " --in " + aGMFFileName; + cmd += " --out " + aResultFileName; + } + if ( !logInStandardOutput ) + { + mgTetra.SetLogFile( aLogFileName.c_str() ); + cmd += " 1>" + aLogFileName; // dump into file + } + std::cout << std::endl; + std::cout << "MG-Tetra execution..." << std::endl; + std::cout << cmd << std::endl; + + _computeCanceled = false; + + std::string errStr; + Ok = mgTetra.Compute( cmd, errStr ); // run + + if ( logInStandardOutput && mgTetra.IsLibrary() ) + std::cout << std::endl << mgTetra.GetLog() << std::endl; + if ( Ok ) + std::cout << std::endl << "End of MG-Tetra execution !" << std::endl; + + // -------------- + // read a result + // -------------- + Ok = Ok && readGMFFile( &mgTetra, theHelper, aResultFileName ); + + // --------------------- + // remove working files + // --------------------- + if ( Ok ) + { + if ( removeLogOnSuccess ) + removeFile( aLogFileName ); + } + if ( mgTetra.HasLog() ) + { + if( _computeCanceled ) + error( "interruption initiated by user" ); + else + { + // get problem description from the log file + std::vector nodeByGhsId; + getNodeByGhsId( theMesh, nodeByGhsId ); + _Ghs2smdsConvertor conv( nodeByGhsId, SMESH_ProxyMesh::Ptr( new SMESH_ProxyMesh( theMesh ))); + error( GHS3DPlugin_GHS3D::getErrorDescription( logInStandardOutput ? 0 : aLogFileName.c_str(), + mgTetra.GetLog(), conv, Ok )); + } + } + else { + // the log file is empty + removeFile( aLogFileName ); + INFOS( "MG-Tetra Error, " << errStr); + error(COMPERR_ALGO_FAILED, errStr); + } + + if ( !keepFiles ) + { + if ( !Ok && _computeCanceled ) + removeFile( aLogFileName ); + removeFile( aGMFFileName ); + removeFile( aSolFileName ); + removeFile( aResultFileName ); + removeFile( aResSolFileName ); + } + return Ok; +} + + +// double GHS3DPlugin_Optimizer::GetProgress() const +// { +// } diff --git a/src/GHS3DPlugin/GHS3DPlugin_Optimizer.hxx b/src/GHS3DPlugin/GHS3DPlugin_Optimizer.hxx new file mode 100644 index 0000000..94e18c5 --- /dev/null +++ b/src/GHS3DPlugin/GHS3DPlugin_Optimizer.hxx @@ -0,0 +1,60 @@ +// Copyright (C) 2004-2016 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 : GHS3DPlugin_Optimizer.hxx +// Created : Mon Oct 31 19:58:02 2016 + + +#ifndef __GHS3DPlugin_Optimizer_HXX__ +#define __GHS3DPlugin_Optimizer_HXX__ + +#include + +class GHS3DPlugin_OptimizerHypothesis; + +class GHS3DPlugin_Optimizer: public SMESH_3D_Algo +{ +public: + GHS3DPlugin_Optimizer(int hypId, int studyId, SMESH_Gen* gen); + + virtual bool CheckHypothesis(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + Hypothesis_Status& aStatus); + + virtual void CancelCompute(); + bool computeCanceled() { return _computeCanceled; } + + virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, + MapShapeNbElems& aResMap); + + virtual bool Compute(SMESH_Mesh& theMesh, + SMESH_MesherHelper* theHelper); + virtual bool Compute(SMESH_Mesh & aMesh, + const TopoDS_Shape & aShape); + + static const char* Name() { return "MG-Tetra Optimization"; } + + //virtual double GetProgress() const; + +private: + + const GHS3DPlugin_OptimizerHypothesis* _hyp; +}; + + +#endif diff --git a/src/GHS3DPlugin/GHS3DPlugin_OptimizerHypothesis.cxx b/src/GHS3DPlugin/GHS3DPlugin_OptimizerHypothesis.cxx new file mode 100644 index 0000000..e4e0c65 --- /dev/null +++ b/src/GHS3DPlugin/GHS3DPlugin_OptimizerHypothesis.cxx @@ -0,0 +1,203 @@ +// Copyright (C) 2004-2016 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 : GHS3DPlugin_OptimizerHypothesis.cxx +// Created : Tue Nov 1 17:18:38 2016 + +#include "GHS3DPlugin_OptimizerHypothesis.hxx" + +#include + +GHS3DPlugin_OptimizerHypothesis::GHS3DPlugin_OptimizerHypothesis(int hypId, + int studyId, + SMESH_Gen * gen) + :GHS3DPlugin_Hypothesis( hypId, studyId, gen ), + myOptimization( YES ), + mySplitOverConstrained( NO ), + mySmoothOffSlivers( false ), + myMaximalNumberOfThreads( 4 ), + myPThreadsMode( NONE ) +{ + _name = GetHypType(); + _param_algo_dim = 3; +} + +void GHS3DPlugin_OptimizerHypothesis::SetOptimization( Mode mode ) +{ + if ( myOptimization != mode ) + { + myOptimization = mode; + NotifySubMeshesHypothesisModification(); + } +} + +GHS3DPlugin_OptimizerHypothesis::Mode GHS3DPlugin_OptimizerHypothesis::GetOptimization() const +{ + return myOptimization; +} + +void GHS3DPlugin_OptimizerHypothesis::SetSplitOverConstrained( Mode mode ) +{ + if ( mode != mySplitOverConstrained ) + { + mySplitOverConstrained = mode; + NotifySubMeshesHypothesisModification(); + } +} + +GHS3DPlugin_OptimizerHypothesis::Mode GHS3DPlugin_OptimizerHypothesis::GetSplitOverConstrained() const +{ + return mySplitOverConstrained; +} + +void GHS3DPlugin_OptimizerHypothesis::SetSmoothOffSlivers( bool toSmooth ) +{ + if ( mySmoothOffSlivers != toSmooth ) + { + mySmoothOffSlivers = toSmooth; + NotifySubMeshesHypothesisModification(); + } +} + +bool GHS3DPlugin_OptimizerHypothesis::GetSmoothOffSlivers() const +{ + return mySmoothOffSlivers; +} + +void GHS3DPlugin_OptimizerHypothesis::SetPThreadsMode( PThreadsMode mode ) +{ + if ( myPThreadsMode != mode ) + { + myPThreadsMode = mode; + NotifySubMeshesHypothesisModification(); + } +} + +GHS3DPlugin_OptimizerHypothesis::PThreadsMode GHS3DPlugin_OptimizerHypothesis::GetPThreadsMode() const +{ + return myPThreadsMode; +} + +void GHS3DPlugin_OptimizerHypothesis::SetMaximalNumberOfThreads( int nb ) +{ + if ( myMaximalNumberOfThreads != nb ) + { + myMaximalNumberOfThreads = nb; + NotifySubMeshesHypothesisModification(); + } +} + +int GHS3DPlugin_OptimizerHypothesis::GetMaximalNumberOfThreads() const +{ + return myMaximalNumberOfThreads; +} + + +std::ostream & GHS3DPlugin_OptimizerHypothesis::SaveTo(std::ostream & save) +{ + save << " " << (int)myOptimization + << " " << (int)mySplitOverConstrained + << " " << (int)mySmoothOffSlivers + << " " << (int)myMaximalNumberOfThreads + << " " << (int)myPThreadsMode << " "; + + GHS3DPlugin_Hypothesis::SaveTo( save ); + + return save; +} + +std::istream & GHS3DPlugin_OptimizerHypothesis::LoadFrom(std::istream & load) +{ + int i; + + if ( load >> i ) + myOptimization = (Mode) i; + if ( load >> i ) + mySplitOverConstrained = (Mode) i; + if ( load >> i ) + mySmoothOffSlivers = (bool) i; + if ( load >> i ) + myMaximalNumberOfThreads = i; + if ( load >> i ) + myPThreadsMode = (PThreadsMode) i; + + GHS3DPlugin_Hypothesis::LoadFrom( load ); + return load; +} + +bool GHS3DPlugin_OptimizerHypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, + const TopoDS_Shape& theShape) +{ + return false; +} + +bool GHS3DPlugin_OptimizerHypothesis::SetParametersByDefaults(const TDefaults& theDflts, + const SMESH_Mesh* theMesh) +{ + return false; +} + +std::string GHS3DPlugin_OptimizerHypothesis::CommandToRun(const GHS3DPlugin_OptimizerHypothesis* hyp) +{ + SMESH_Comment cmd( GetExeName() ); + + if ( hyp ) + { + const char* mode[3] = { "no", "yes", "only" }; + + if ( hyp->GetOptimization() >= 0 && hyp->GetOptimization() < 3 ) + cmd << " --optimisation " << mode[ hyp->GetOptimization() ]; + + if ( hyp->myOptimizationLevel >= 0 && hyp->myOptimizationLevel < 5 ) { + const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" }; + cmd << " --optimisation_level " << level[ hyp->myOptimizationLevel ]; + } + + if ( hyp->GetSplitOverConstrained() >= 0 && hyp->GetSplitOverConstrained() < 3 ) + cmd << " --split_overconstrained_elements " << mode[ hyp->GetSplitOverConstrained() ]; + + if ( hyp->GetSmoothOffSlivers() ) + cmd << " --smooth_off_slivers yes"; + + switch ( hyp->GetPThreadsMode() ) { + case GHS3DPlugin_OptimizerHypothesis::SAFE: + cmd << " --pthreads_mode safe"; break; + case GHS3DPlugin_OptimizerHypothesis::AGGRESSIVE: + cmd << " --pthreads_mode aggressive"; break; + default:; + } + + if ( hyp->GetMaximalNumberOfThreads() > 0 ) + cmd << " --max_number_of_threads " << hyp->GetMaximalNumberOfThreads(); + + if ( !hyp->myToCreateNewNodes ) + cmd << " --no_internal_points"; + + if ( hyp->myMaximumMemory > 0 ) + cmd << " --max_memory " << hyp->myMaximumMemory; + + if ( hyp->myInitialMemory > 0 ) + cmd << " --automatic_memory " << hyp->myInitialMemory; + + cmd << " --verbose " << hyp->myVerboseLevel; + + cmd << " " << hyp->myTextOption; + } + + return cmd; +} diff --git a/src/GHS3DPlugin/GHS3DPlugin_OptimizerHypothesis.hxx b/src/GHS3DPlugin/GHS3DPlugin_OptimizerHypothesis.hxx new file mode 100644 index 0000000..4717158 --- /dev/null +++ b/src/GHS3DPlugin/GHS3DPlugin_OptimizerHypothesis.hxx @@ -0,0 +1,86 @@ +// Copyright (C) 2004-2016 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 : GHS3DPlugin_OptimizerHypothesis.hxx +// Created : Tue Nov 1 17:03:17 2016 + +#ifndef __GHS3DPlugin_OptimizerHypothesis_HXX__ +#define __GHS3DPlugin_OptimizerHypothesis_HXX__ + +#include "GHS3DPlugin_Hypothesis.hxx" + + +class GHS3DPlugin_OptimizerHypothesis : public GHS3DPlugin_Hypothesis +{ +public: + GHS3DPlugin_OptimizerHypothesis(int hypId, int studyId, SMESH_Gen * gen); + + // inherited params: + // 1 - create new nodes + // 2 - optimization level + // 3 - init and max memory + // 4 - work dir + // 5 - verbosity + // 6 - log to file + // 7 - keep work files + // 8 - remove log file + // 9 - advanced options + + enum PThreadsMode { SAFE, AGGRESSIVE, NONE }; + enum Mode { NO, YES, ONLY }; + + void SetOptimization( Mode isOnly ); + Mode GetOptimization() const; + + void SetSplitOverConstrained( Mode mode ); + Mode GetSplitOverConstrained() const; + + void SetSmoothOffSlivers( bool toSmooth ); + bool GetSmoothOffSlivers() const; + + void SetPThreadsMode( PThreadsMode mode ); + PThreadsMode GetPThreadsMode() const; + + void SetMaximalNumberOfThreads( int nb ); + int GetMaximalNumberOfThreads() const; + + static const char* GetHypType() { return "MG-Tetra Optimization Parameters"; } + + // Persistence + virtual std::ostream & SaveTo(std::ostream & save); + virtual std::istream & LoadFrom(std::istream & load); + + /*! + * \brief Does nothing + */ + virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0); + + static std::string CommandToRun(const GHS3DPlugin_OptimizerHypothesis* hyp); + +private: + + Mode myOptimization; // no, yes, only + Mode mySplitOverConstrained; // no, yes, only + bool mySmoothOffSlivers; + int myMaximalNumberOfThreads; + PThreadsMode myPThreadsMode; // safe, aggressive, none + +}; + +#endif diff --git a/src/GHS3DPlugin/GHS3DPlugin_OptimizerHypothesis_i.cxx b/src/GHS3DPlugin/GHS3DPlugin_OptimizerHypothesis_i.cxx new file mode 100644 index 0000000..d2b205e --- /dev/null +++ b/src/GHS3DPlugin/GHS3DPlugin_OptimizerHypothesis_i.cxx @@ -0,0 +1,145 @@ +// Copyright (C) 2004-2016 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 : GHS3DPlugin_OptimizerHypothesis_i.cxx +// Created : Tue Nov 1 17:46:39 2016 + +#include "GHS3DPlugin_OptimizerHypothesis_i.hxx" + +#include +#include + +#include + +GHS3DPlugin_OptimizerHypothesis_i:: +GHS3DPlugin_OptimizerHypothesis_i (PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ), + GHS3DPlugin_Hypothesis_i( thePOA, theStudyId, theGenImpl ) +{ + int id = myBaseImpl ? myBaseImpl->GetID() : theGenImpl->GetANewId(); + if ( myBaseImpl ) + delete myBaseImpl; + + myBaseImpl = new ::GHS3DPlugin_OptimizerHypothesis( id, theStudyId, theGenImpl ); +} + +namespace +{ + const char* dumpMode( GHS3DPlugin::Mode mode ) + { + switch( mode ) { + case GHS3DPlugin::NO: return "GHS3DPlugin.NO"; + case GHS3DPlugin::YES: return "GHS3DPlugin.YES"; + case GHS3DPlugin::ONLY: return "GHS3DPlugin.ONLY"; + default: return "GHS3DPlugin.NO"; + } + return 0; + } +} + +void GHS3DPlugin_OptimizerHypothesis_i::SetOptimization( GHS3DPlugin::Mode mode ) +{ + if ((int) GetImpl()->GetOptimization() != (int) mode ) + { + GetImpl()->SetOptimization( ::GHS3DPlugin_OptimizerHypothesis::Mode( mode )); + SMESH::TPythonDump() << _this() << ".SetOptimization( " << dumpMode( mode ) << " )"; + } +} + +GHS3DPlugin::Mode GHS3DPlugin_OptimizerHypothesis_i::GetOptimization() +{ + return GHS3DPlugin::Mode( GetImpl()->GetOptimization() ); +} + +void GHS3DPlugin_OptimizerHypothesis_i::SetSplitOverConstrained( GHS3DPlugin::Mode mode ) +{ + if ((int) GetImpl()->GetSplitOverConstrained() != (int) mode ) + { + GetImpl()->SetSplitOverConstrained((::GHS3DPlugin_OptimizerHypothesis::Mode) mode ); + SMESH::TPythonDump() << _this() << ".SetSplitOverConstrained( " << dumpMode( mode ) << " )"; + } +} + +GHS3DPlugin::Mode GHS3DPlugin_OptimizerHypothesis_i::GetSplitOverConstrained() +{ + return (GHS3DPlugin::Mode) GetImpl()->GetSplitOverConstrained(); +} + +void GHS3DPlugin_OptimizerHypothesis_i::SetSmoothOffSlivers( CORBA::Boolean toSmooth ) +{ + if ( GetImpl()->GetSmoothOffSlivers() != (bool) toSmooth ) + { + GetImpl()->SetSmoothOffSlivers((bool) toSmooth ); + SMESH::TPythonDump() << _this() << ".SetSmoothOffSlivers( " << toSmooth << " )"; + } +} + +CORBA::Boolean GHS3DPlugin_OptimizerHypothesis_i::GetSmoothOffSlivers() +{ + return GetImpl()->GetSmoothOffSlivers(); +} + +void GHS3DPlugin_OptimizerHypothesis_i::SetPThreadsMode( GHS3DPlugin::PThreadsMode mode ) +{ + if ((int) GetImpl()->GetPThreadsMode() != (int) mode ) + { + GetImpl()->SetPThreadsMode((::GHS3DPlugin_OptimizerHypothesis::PThreadsMode) mode ); + + std::string modeStr; + switch( mode ) { + case ::GHS3DPlugin_OptimizerHypothesis::SAFE: modeStr = "SAFE"; break; + case ::GHS3DPlugin_OptimizerHypothesis::AGGRESSIVE: modeStr = "AGGRESSIVE"; break; + default: modeStr = "NONE"; + } + SMESH::TPythonDump() << _this() << ".SetPThreadsMode( GHS3DPlugin." << modeStr << " )"; + } +} + +GHS3DPlugin::PThreadsMode GHS3DPlugin_OptimizerHypothesis_i::GetPThreadsMode() +{ + return (GHS3DPlugin::PThreadsMode) GetImpl()->GetPThreadsMode(); +} + +void GHS3DPlugin_OptimizerHypothesis_i::SetMaximalNumberOfThreads( CORBA::Short nb ) +{ + if ( GetImpl()->GetMaximalNumberOfThreads() != nb ) + { + GetImpl()->SetMaximalNumberOfThreads( nb ); + SMESH::TPythonDump() << _this() << ".SetMaximalNumberOfThreads( " << nb << " )"; + } +} + +CORBA::Short GHS3DPlugin_OptimizerHypothesis_i::GetMaximalNumberOfThreads() +{ + return (CORBA::Short) GetImpl()->GetMaximalNumberOfThreads(); +} + +::GHS3DPlugin_OptimizerHypothesis* GHS3DPlugin_OptimizerHypothesis_i::GetImpl() +{ + return (::GHS3DPlugin_OptimizerHypothesis*)myBaseImpl; +} + +CORBA::Boolean GHS3DPlugin_OptimizerHypothesis_i::IsDimSupported( SMESH::Dimension type ) +{ + return type == SMESH::DIM_3D; +} + + diff --git a/src/GHS3DPlugin/GHS3DPlugin_OptimizerHypothesis_i.hxx b/src/GHS3DPlugin/GHS3DPlugin_OptimizerHypothesis_i.hxx new file mode 100644 index 0000000..7cffca5 --- /dev/null +++ b/src/GHS3DPlugin/GHS3DPlugin_OptimizerHypothesis_i.hxx @@ -0,0 +1,81 @@ +// Copyright (C) 2004-2016 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 : GHS3DPlugin_OptimizerHypothesis_i.hxx +// Created : Tue Nov 1 17:36:05 2016 + +#ifndef __GHS3DPlugin_OptimizerHypothesis_i_HXX__ +#define __GHS3DPlugin_OptimizerHypothesis_i_HXX__ + +#include "GHS3DPlugin_Defs.hxx" + +#include +#include CORBA_SERVER_HEADER(GHS3DPlugin_Algorithm) + +#include "GHS3DPlugin_OptimizerHypothesis.hxx" +#include "GHS3DPlugin_Hypothesis_i.hxx" +#include "SMESH_Hypothesis_i.hxx" + +class SMESH_Gen; + +// GHS3DPlugin Optimization Parameters hypothesis + +class GHS3DPLUGIN_EXPORT GHS3DPlugin_OptimizerHypothesis_i: + public virtual POA_GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis, + public virtual GHS3DPlugin_Hypothesis_i +{ + public: + GHS3DPlugin_OptimizerHypothesis_i (PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl); + // inherited params: + // 1 - create new nodes + // 2 - optimization level + // 3 - init and max memory + // 4 - work dir + // 5 - verbosity + // 6 - log to file + // 7 - keep work files + // 8 - remove log file + // 9 - advanced options + + void SetOptimization( GHS3DPlugin::Mode mode ); + GHS3DPlugin::Mode GetOptimization(); + + void SetSplitOverConstrained( GHS3DPlugin::Mode mode ); + GHS3DPlugin::Mode GetSplitOverConstrained(); + + void SetSmoothOffSlivers( CORBA::Boolean toSmooth ); + CORBA::Boolean GetSmoothOffSlivers(); + + void SetPThreadsMode( GHS3DPlugin::PThreadsMode mode ); + GHS3DPlugin::PThreadsMode GetPThreadsMode(); + + void SetMaximalNumberOfThreads( CORBA::Short nb ); + CORBA::Short GetMaximalNumberOfThreads(); + + + // Get implementation + ::GHS3DPlugin_OptimizerHypothesis* GetImpl(); + + // Verify whether hypothesis supports given entity type + CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + +}; + +#endif diff --git a/src/GHS3DPlugin/GHS3DPlugin_i.cxx b/src/GHS3DPlugin/GHS3DPlugin_i.cxx index a81254a..2e71020 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_i.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_i.cxx @@ -17,18 +17,11 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// SMESH GHS3DPlugin : implementaion of SMESH idl descriptions -// File : GHS3DPlugin.cxx -// Author : Julia DOROVSKIKH -// Module : SMESH -// $Header$ -// #include "SMESH_Hypothesis_i.hxx" -#include "utilities.h" - #include "GHS3DPlugin_GHS3D_i.hxx" #include "GHS3DPlugin_Hypothesis_i.hxx" +#include "GHS3DPlugin_OptimizerHypothesis_i.hxx" template class GHS3DPlugin_Creator_i:public HypothesisCreator_i { @@ -49,21 +42,23 @@ extern "C" GHS3DPLUGIN_EXPORT GenericHypothesisCreator_i* GetHypothesisCreator (const char* aHypName) { - MESSAGE("GetHypothesisCreator " << aHypName); - GenericHypothesisCreator_i* aCreator = 0; - // Hypotheses - // Algorithm if (strcmp(aHypName, "GHS3D_3D") == 0 || strcmp(aHypName, "MG-Tetra") == 0) aCreator = new GHS3DPlugin_Creator_i; + + else if (strcmp(aHypName, "MG-Tetra Optimization") == 0) + aCreator = new GHS3DPlugin_Creator_i; + // Hypothesis else if (strcmp(aHypName, "GHS3D_Parameters") == 0 || strcmp(aHypName, "MG-Tetra Parameters") == 0) aCreator = new GHS3DPlugin_Creator_i; - else ; + + else if (strcmp(aHypName, "MG-Tetra Optimization Parameters") == 0) + aCreator = new GHS3DPlugin_Creator_i; return aCreator; } diff --git a/src/GHS3DPlugin/MG_Tetra_API.cxx b/src/GHS3DPlugin/MG_Tetra_API.cxx index 6467765..5709912 100644 --- a/src/GHS3DPlugin/MG_Tetra_API.cxx +++ b/src/GHS3DPlugin/MG_Tetra_API.cxx @@ -53,16 +53,18 @@ struct MG_Tetra_API::LibData int _nbRequiredEdges; std::vector _triaNodes; int _nbRequiredTria; + std::vector _tetraNodes; int _count; volatile bool& _cancelled_flag; std::string _errorStr; double& _progress; + bool _progressInCallBack; LibData( volatile bool & cancelled_flag, double& progress ) : _context(0), _session(0), _tria_mesh(0), _sizemap(0), _tetra_mesh(0), _nbRequiredEdges(0), _nbRequiredTria(0), - _cancelled_flag( cancelled_flag ), _progress( progress ) + _cancelled_flag( cancelled_flag ), _progress( progress ), _progressInCallBack( false ) { } // methods setting callbacks implemented after callback definitions @@ -329,6 +331,11 @@ struct MG_Tetra_API::LibData _triaNodes.reserve( nb * 3 ); } + void SetNbTetra( int nb ) + { + _tetraNodes.reserve( nb * 4 ); + } + void SetNbReqVertices( int nb ) { _nodeSize.reserve( nb ); @@ -369,6 +376,14 @@ struct MG_Tetra_API::LibData _triaNodes.push_back( node3 ); } + void AddTetraNodes( int node1, int node2, int node3, int node4, int domain ) + { + _tetraNodes.push_back( node1 ); + _tetraNodes.push_back( node2 ); + _tetraNodes.push_back( node3 ); + _tetraNodes.push_back( node4 ); + } + int NbNodes() { return _xyz.size() / 3; @@ -394,11 +409,21 @@ struct MG_Tetra_API::LibData return _triaNodes.size() / 3; } + int NbTetra() + { + return _tetraNodes.size() / 4; + } + int * GetTriaNodes( int iTria ) { return & _triaNodes[ iTria * 3 ]; } + int * GetTetraNodes( int iTet ) + { + return & _tetraNodes[ iTet * 4 ]; + } + int IsVertexRequired( int iNode ) { return ! ( iNode < int( NbNodes() - _nodeSize.size() )); @@ -485,26 +510,25 @@ namespace // functions called by MG library to exchange with the application // return STATUS_OK; // } - // status_t get_tetrahedron_count(integer * nbtetra, void *user_data) - // { - // MG_Tetra_API::LibData* data = (MG_Tetra_API::LibData *) user_data; - - // *nbtetra = 0; /* the number of tetra in your input mesh (0 if you describe a surface mesh) */ - - // return STATUS_OK; - // } + status_t get_tetrahedron_count(integer * nbtetra, void *user_data) + { + MG_Tetra_API::LibData* data = (MG_Tetra_API::LibData *) user_data; + *nbtetra = data->NbTetra(); - // status_t get_tetrahedron_vertices(integer itetra, integer * vtetra, - // void *user_data) - // { - // int j; - // MG_Tetra_API::LibData* data = (MG_Tetra_API::LibData *) user_data; + return STATUS_OK; + } - // for (j = 0; j < 4; j++) - // vtetra[j] = 0; /* the j'th vertex index of the itetra'th tetrahedron */ + status_t get_tetrahedron_vertices(integer itetra, integer * vtetra, + void *user_data) + { + int j; + MG_Tetra_API::LibData* data = (MG_Tetra_API::LibData *) user_data; + int* nodes = data->GetTetraNodes( itetra-1 ); + for (j = 0; j < 4; j++) + vtetra[j] = nodes[j]; - // return STATUS_OK; - // } + return STATUS_OK; + } status_t get_vertex_required_property(integer ivtx, integer * rvtx, void *user_data) { @@ -534,26 +558,37 @@ namespace // functions called by MG library to exchange with the application //std::cout << desc << std::endl; #endif - // Compute progress - // corresponding messages are: - // " -- PHASE 1 COMPLETED" => 10 % - // " -- PHASE 2 COMPLETED" => 25 % - // " ** ITERATION 1" => 25.* % - // " ** ITERATION 2" => 25.* % - // " -- PHASE 3 COMPLETED" => 70 % - // " -- PHASE 4 COMPLETED" => 98 % - - if ( strncmp( "-- PHASE ", desc + 2, 9 ) == 0 && desc[ 13 ] == 'C' ) + if ( strncmp( "MGMESSAGE 1009001 ", desc, 19 ) == 0 ) { - const double progress[] = { 10., 25., 70., 98., 100., 100., 100. }; - int phase = atoi( desc + 11 ); - data->_progress = std::max( data->_progress, progress[ phase - 1 ] / 100. ); + // progress message (10%): "MGMESSAGE 1009001 0 1 1.000000e+01" + data->_progress = atof( desc + 24 ); + + _progressInCallBack = true; } - else if ( strncmp( "** ITERATION ", desc + 5, 13 ) == 0 ) + + if ( !_progressInCallBack ) { - int iter = atoi( desc + 20 ); - double percent = 25. + iter * ( 70 - 25 ) / 20.; - data->_progress = std::max( data->_progress, ( percent / 100. )); + // Compute progress + // corresponding messages are: + // " -- PHASE 1 COMPLETED" => 10 % + // " -- PHASE 2 COMPLETED" => 25 % + // " ** ITERATION 1" => 25.* % + // " ** ITERATION 2" => 25.* % + // " -- PHASE 3 COMPLETED" => 70 % + // " -- PHASE 4 COMPLETED" => 98 % + + if ( strncmp( "-- PHASE ", desc + 2, 9 ) == 0 && desc[ 13 ] == 'C' ) + { + const double progress[] = { 10., 25., 70., 98., 100., 100., 100. }; + int phase = atoi( desc + 11 ); + data->_progress = std::max( data->_progress, progress[ phase - 1 ] / 100. ); + } + else if ( strncmp( "** ITERATION ", desc + 5, 13 ) == 0 ) + { + int iter = atoi( desc + 20 ); + double percent = 25. + iter * ( 70 - 25 ) / 20.; + data->_progress = std::max( data->_progress, ( percent / 100. )); + } } return STATUS_OK; @@ -595,6 +630,8 @@ void MG_Tetra_API::LibData::Init() mesh_set_get_edge_vertices( _tria_mesh, get_edge_vertices, this ); mesh_set_get_triangle_count( _tria_mesh, get_triangle_count, this ); mesh_set_get_triangle_vertices( _tria_mesh, get_triangle_vertices, this ); + mesh_set_get_tetrahedron_count( _tria_mesh, get_tetrahedron_count, this ); + mesh_set_get_tetrahedron_vertices( _tria_mesh, get_tetrahedron_vertices, this ); // Create a tetra session _session = tetra_session_new( _context ); @@ -607,9 +644,19 @@ void MG_Tetra_API::LibData::Init() bool MG_Tetra_API::LibData::Compute() { - // Set surface mesh - status_t ret = tetra_set_surface_mesh( _session, _tria_mesh ); - if ( ret != STATUS_OK ) MG_Error( "unable to set surface mesh"); + status_t ret; + + if ( _tetraNodes.empty() ) + { + // Set surface mesh + ret = tetra_set_surface_mesh( _session, _tria_mesh ); + if ( ret != STATUS_OK ) MG_Error( "unable to set surface mesh"); + } + else + { + ret = tetra_set_volume_mesh( _session, _tria_mesh ); + if ( ret != STATUS_OK ) MG_Error( "unable to set volume mesh"); + } // Set a sizemap if ( !_nodeSize.empty() ) @@ -1136,6 +1183,24 @@ void MG_Tetra_API::GmfSetLin(int iMesh, GmfKwdCod what, int node1, int node2, in ::GmfSetLin(iMesh, what, node1, node2, node3, domain ); } +//================================================================================ +/*! + * \brief Add tetra nodes + */ +//================================================================================ + +void MG_Tetra_API::GmfSetLin(int iMesh, GmfKwdCod what, + int node1, int node2, int node3, int node4, int domain ) +{ + if ( _useLib ) { +#ifdef USE_MG_LIBS + _libData->AddTetraNodes( node1, node2, node3, node4, domain ); + return; +#endif + } + ::GmfSetLin(iMesh, what, node1, node2, node3, node4, domain ); +} + //================================================================================ /*! * \brief Close a file diff --git a/src/GHS3DPlugin/MG_Tetra_API.hxx b/src/GHS3DPlugin/MG_Tetra_API.hxx index ee4ad30..e5f0db4 100644 --- a/src/GHS3DPlugin/MG_Tetra_API.hxx +++ b/src/GHS3DPlugin/MG_Tetra_API.hxx @@ -51,6 +51,7 @@ public: void GmfSetLin(int iMesh, GmfKwdCod what, int node1, int node2, int domain ); // edge void GmfSetLin(int iMesh, GmfKwdCod what, int id ); // required void GmfSetLin(int iMesh, GmfKwdCod what, int node1, int node2, int node3, int domain ); // tria + void GmfSetLin(int iMesh, GmfKwdCod what, int node1, int node2, int node3, int node4, int domain ); // tetra bool Compute( const std::string& cmdLine, std::string& errStr ); diff --git a/src/GUI/GHS3DPluginGUI.cxx b/src/GUI/GHS3DPluginGUI.cxx index dc0b278..86ed21c 100644 --- a/src/GUI/GHS3DPluginGUI.cxx +++ b/src/GUI/GHS3DPluginGUI.cxx @@ -36,7 +36,8 @@ extern "C" { SMESHGUI_GenericHypothesisCreator* aCreator = NULL; if ( aHypType == "GHS3D_Parameters" || - aHypType == "MG-Tetra Parameters" ) + aHypType == "MG-Tetra Parameters" || + aHypType == "MG-Tetra Optimization Parameters" ) aCreator = new GHS3DPluginGUI_HypothesisCreator( aHypType ); return aCreator; } diff --git a/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx b/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx index f66769e..a13234c 100644 --- a/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx @@ -25,6 +25,7 @@ #include "GHS3DPluginGUI_HypothesisCreator.h" #include "GHS3DPluginGUI_Enums.h" #include "GHS3DPluginGUI_Dlg.h" +#include "GHS3DPlugin_OptimizerHypothesis.hxx" #include @@ -36,50 +37,67 @@ #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 +namespace +{ + QComboBox* getModeCombo( QWidget* parent, bool isPThreadCombo ) + { + QComboBox* combo = new QComboBox( parent ); + if ( isPThreadCombo ) + { + combo->insertItem((int) GHS3DPlugin_OptimizerHypothesis::SAFE, QObject::tr("MODE_SAFE")); + combo->insertItem((int) GHS3DPlugin_OptimizerHypothesis::AGGRESSIVE, QObject::tr("MODE_AGGRESSIVE")); + combo->insertItem((int) GHS3DPlugin_OptimizerHypothesis::NONE, QObject::tr("MODE_NONE")); + } + else + { + combo->insertItem((int) GHS3DPlugin_OptimizerHypothesis::NO, QObject::tr("MODE_NO")); + combo->insertItem((int) GHS3DPlugin_OptimizerHypothesis::YES, QObject::tr("MODE_YES")); + combo->insertItem((int) GHS3DPlugin_OptimizerHypothesis::ONLY, QObject::tr("MODE_ONLY")); + } + return combo; + } +} // // BEGIN EnforcedVertexTableWidgetDelegate // EnforcedVertexTableWidgetDelegate::EnforcedVertexTableWidgetDelegate(QObject *parent) - : QItemDelegate(parent) + : QItemDelegate(parent) { } QWidget *EnforcedVertexTableWidgetDelegate::createEditor(QWidget *parent, - const QStyleOptionViewItem & option , - const QModelIndex & index ) const + const QStyleOptionViewItem & option , + const QModelIndex & index ) const { QModelIndex father = index.parent(); QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data().toString(); @@ -97,14 +115,9 @@ QWidget *EnforcedVertexTableWidgetDelegate::createEditor(QWidget *parent, editor->setDisabled(!entry.isEmpty()); return editor; } -// else if (index.column() == ENF_VER_COMPOUND_COLUMN) { -// QCheckBox *editor = new QCheckBox(parent); -// editor->setDisabled(!entry.isEmpty()); -// return editor; -// } else if (index.column() == ENF_VER_GROUP_COLUMN || index.column() == ENF_VER_NAME_COLUMN) { -// else { + // else { QLineEdit *editor = new QLineEdit(parent); if (index.column() != ENF_VER_GROUP_COLUMN) { editor->setReadOnly(!entry.isEmpty()); @@ -116,7 +129,7 @@ QWidget *EnforcedVertexTableWidgetDelegate::createEditor(QWidget *parent, } void EnforcedVertexTableWidgetDelegate::setEditorData(QWidget *editor, - const QModelIndex &index) const + const QModelIndex &index) const { if (index.column() == ENF_VER_X_COLUMN || index.column() == ENF_VER_Y_COLUMN || @@ -136,7 +149,7 @@ void EnforcedVertexTableWidgetDelegate::setEditorData(QWidget *editor, } void EnforcedVertexTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const + const QModelIndex &index) const { QModelIndex parent = index.parent(); @@ -179,14 +192,15 @@ void EnforcedVertexTableWidgetDelegate::setModelData(QWidget *editor, QAbstractI } void EnforcedVertexTableWidgetDelegate::updateEditorGeometry(QWidget *editor, - const QStyleOptionViewItem &option, const QModelIndex &/* index */) const + const QStyleOptionViewItem &option, + const QModelIndex &/* index */) const { - editor->setGeometry(option.rect); + editor->setGeometry(option.rect); } bool EnforcedVertexTableWidgetDelegate::vertexExists(QAbstractItemModel *model, - const QModelIndex &index, - QString value) const + const QModelIndex &index, + QString value) const { bool exists = false; QModelIndex parent = index.parent(); @@ -243,61 +257,51 @@ bool EnforcedVertexTableWidgetDelegate::vertexExists(QAbstractItemModel *model, // EnforcedMeshTableWidgetDelegate::EnforcedMeshTableWidgetDelegate(QObject *parent) - : QItemDelegate(parent) + : QItemDelegate(parent) { } QWidget *EnforcedMeshTableWidgetDelegate::createEditor(QWidget *parent, - const QStyleOptionViewItem & option , - const QModelIndex & index ) const + const QStyleOptionViewItem & option , + const QModelIndex & index ) const { return QItemDelegate::createEditor(parent, option, index); } void EnforcedMeshTableWidgetDelegate::setEditorData(QWidget *editor, - const QModelIndex &index) const + const QModelIndex &index) const { - QItemDelegate::setEditorData(editor, index); + QItemDelegate::setEditorData(editor, index); } void EnforcedMeshTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const + const QModelIndex &index) const { QItemDelegate::setModelData(editor, model, index); } void EnforcedMeshTableWidgetDelegate::updateEditorGeometry(QWidget *editor, - const QStyleOptionViewItem &option, const QModelIndex &/* index */) const + const QStyleOptionViewItem &option, + const QModelIndex &/* index */) const { - editor->setGeometry(option.rect); + editor->setGeometry(option.rect); } -// bool EnforcedMeshTableWidgetDelegate::enfMeshExists(QAbstractItemModel *model, -// const QModelIndex &index, -// QString value) const -// { -// bool exists = false; -// QModelIndex parent = index.parent(); -// int row = index.row(); -// int col = index.column(); -// return exists; -// } - // // END EnforcedMeshTableWidgetDelegate // GHS3DPluginGUI_HypothesisCreator::GHS3DPluginGUI_HypothesisCreator( const QString& theHypType ) -: SMESHGUI_GenericHypothesisCreator( theHypType ) + : SMESHGUI_GenericHypothesisCreator( theHypType ) { GeomToolSelected = NULL; GeomToolSelected = getGeomSelectionTool(); iconVertex = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_OBJBROWSER_VERTEX"))); iconCompound = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_OBJBROWSER_COMPOUND"))); -// mySelectionMgr = SMESH::GetSelectionMgr(SMESHGUI::GetSMESHGUI()); + // mySelectionMgr = SMESH::GetSelectionMgr(SMESHGUI::GetSMESHGUI()); myEnfMeshConstraintLabels << tr( "GHS3D_ENF_MESH_CONSTRAINT_NODE" ) << tr( "GHS3D_ENF_MESH_CONSTRAINT_EDGE" ) << tr("GHS3D_ENF_MESH_CONSTRAINT_FACE"); } @@ -326,6 +330,11 @@ GEOM::GEOM_Gen_var GHS3DPluginGUI_HypothesisCreator::getGeomEngine() return GeometryGUI::GetGeomGen(); } +bool GHS3DPluginGUI_HypothesisCreator::isOptimization() const +{ + return ( hypType() == GHS3DPlugin_OptimizerHypothesis::GetHypType() ); +} + QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() { QFrame* fr = new QFrame( 0 ); @@ -347,7 +356,7 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() int row = 0; myName = 0; - if( isCreation() ) + if ( isCreation() ) { aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), row, 0, 1, 1 ); myName = new QLineEdit( myStdGroup ); @@ -359,16 +368,61 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() myToMakeGroupsOfDomains = new QCheckBox( tr( "GHS3D_TO_MAKE_DOMAIN_GROUPS" ), myStdGroup ); aStdLayout->addWidget( myToMakeGroupsOfDomains, row++, 1, 1, 1 ); - aStdLayout->addWidget( new QLabel( tr( "GHS3D_OPTIMIZATIOL_LEVEL" ), myStdGroup ), row, 0, 1, 1 ); + QLabel* optimizationLbl = new QLabel( tr( "GHS3D_OPTIMIZATION" ), myStdGroup ); + aStdLayout->addWidget( optimizationLbl, row, 0, 1, 1 ); + myOptimizationCombo = getModeCombo( myStdGroup, false ); + aStdLayout->addWidget( myOptimizationCombo, row++, 1, 1, 1 ); + + QLabel* optimizatiolLevelLbl = new QLabel( tr( "GHS3D_OPTIMIZATIOL_LEVEL" ), myStdGroup ); + aStdLayout->addWidget( optimizatiolLevelLbl, row, 0, 1, 1 ); myOptimizationLevelCombo = new QComboBox( myStdGroup ); aStdLayout->addWidget( myOptimizationLevelCombo, row++, 1, 1, 1 ); - QStringList types; - types << tr( "LEVEL_NONE" ) << tr( "LEVEL_LIGHT" ) << tr( "LEVEL_MEDIUM" ) << tr( "LEVEL_STANDARDPLUS" ) << tr( "LEVEL_STRONG" ); - myOptimizationLevelCombo->addItems( types ); - + QLabel* splitOverconstrainedLbl = new QLabel( tr("GHS3D_SPLIT_OVERCONSTRAINED"), myStdGroup ); + aStdLayout->addWidget( splitOverconstrainedLbl, row, 0, 1, 1 ); + mySplitOverConstrainedCombo = getModeCombo( myStdGroup, false ); + aStdLayout->addWidget( mySplitOverConstrainedCombo, row++, 1, 1, 1 ); + + QLabel* pthreadsModeLbl = new QLabel( tr( "GHS3D_PTHREADS_MODE" ), myStdGroup); + aStdLayout->addWidget( pthreadsModeLbl, row, 0, 1, 1 ); + myPThreadsModeCombo = getModeCombo( myStdGroup, true ); + aStdLayout->addWidget( myPThreadsModeCombo, row++, 1, 1, 1 ); + + QLabel* nbThreadsLbl = new QLabel( tr( "GHS3D_NB_THREADS" ), myStdGroup); + aStdLayout->addWidget( nbThreadsLbl, row, 0, 1, 1 ); + myNumberOfThreadsSpin = new SalomeApp_IntSpinBox( 0, 1000, 1, myStdGroup ); + aStdLayout->addWidget( myNumberOfThreadsSpin, row++, 1, 1, 1 ); + + mySmoothOffSliversCheck = new QCheckBox( tr( "GHS3D_SMOOTH_OFF_SLIVERS" ), myStdGroup ); + aStdLayout->addWidget( mySmoothOffSliversCheck, row, 0, 1, 1 ); + myCreateNewNodesCheck = new QCheckBox( tr( "TO_ADD_NODES" ), myStdGroup ); + aStdLayout->addWidget( myCreateNewNodesCheck, row++, 1, 1, 1 ); + + myOptimizationLevelCombo->addItems( QStringList() + << tr( "LEVEL_NONE" ) << tr( "LEVEL_LIGHT" ) + << tr( "LEVEL_MEDIUM" ) << tr( "LEVEL_STANDARDPLUS" ) + << tr( "LEVEL_STRONG" )); aStdLayout->setRowStretch( row, 10 ); + if ( isOptimization() ) + { + myToMeshHolesCheck->hide(); + myToMakeGroupsOfDomains->hide(); + } + else + { + optimizationLbl->hide(); + myOptimizationCombo->hide(); + splitOverconstrainedLbl->hide(); + mySplitOverConstrainedCombo->hide(); + pthreadsModeLbl->hide(); + myPThreadsModeCombo->hide(); + nbThreadsLbl->hide(); + myNumberOfThreadsSpin->hide(); + mySmoothOffSliversCheck->hide(); + myCreateNewNodesCheck->hide(); + } + // advanced parameters myAdvGroup = new QWidget(); QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup ); @@ -388,7 +442,7 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() myAdvWidget->initialMemoryLabel ->setText (tr( "MEGABYTE" )); myAdvWidget->maxMemoryLabel ->setText (tr( "MEGABYTE" )); - + myAdvWidget->workingDirectoryLabel ->setText (tr( "WORKING_DIR" )); myAdvWidget->workingDirectoryPushButton ->setText (tr( "SELECT_DIR" )); myAdvWidget->keepWorkingFilesCheck ->setText (tr( "KEEP_WORKING_FILES" )); @@ -407,6 +461,16 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() myAdvWidget->gradationLabel ->setText (tr( "GHS3D_GRADATION" )); myAdvWidget->gradationSpinBox->RangeStepAndValidator(0.0, 5.0, 0.05, "length_precision"); + if ( isOptimization() ) + { + myAdvWidget->createNewNodesCheck->hide(); + myAdvWidget->removeInitialCentralPointCheck->hide(); + myAdvWidget->boundaryRecoveryCheck->hide(); + myAdvWidget->FEMCorrectionCheck->hide(); + myAdvWidget->gradationLabel->hide(); + myAdvWidget->gradationSpinBox->hide(); + } + // Enforced vertices parameters myEnfGroup = new QWidget(); QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup); @@ -416,12 +480,12 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() myEnforcedTableWidget->setRowCount( 0 ); myEnforcedTableWidget->setColumnCount( ENF_VER_NB_COLUMNS ); myEnforcedTableWidget->setSortingEnabled(true); - QStringList enforcedHeaders; - enforcedHeaders << tr( "GHS3D_ENF_NAME_COLUMN" ) - << tr( "GHS3D_ENF_VER_X_COLUMN" )<< tr( "GHS3D_ENF_VER_Y_COLUMN" ) << tr( "GHS3D_ENF_VER_Z_COLUMN" ) - << tr( "GHS3D_ENF_SIZE_COLUMN" ) << tr("GHS3D_ENF_ENTRY_COLUMN") << tr("GHS3D_ENF_VER_COMPOUND_COLUMN") << tr( "GHS3D_ENF_GROUP_COLUMN" ); - - myEnforcedTableWidget->setHorizontalHeaderLabels(enforcedHeaders); + myEnforcedTableWidget->setHorizontalHeaderLabels + ( QStringList() + << tr( "GHS3D_ENF_NAME_COLUMN" ) << tr( "GHS3D_ENF_VER_X_COLUMN" ) + << tr( "GHS3D_ENF_VER_Y_COLUMN" ) << tr( "GHS3D_ENF_VER_Z_COLUMN" ) + << tr( "GHS3D_ENF_SIZE_COLUMN" ) << tr("GHS3D_ENF_ENTRY_COLUMN") + << tr("GHS3D_ENF_VER_COMPOUND_COLUMN") << tr( "GHS3D_ENF_GROUP_COLUMN" )); myEnforcedTableWidget->verticalHeader()->hide(); myEnforcedTableWidget->horizontalHeader()->setStretchLastSection(true); myEnforcedTableWidget->setAlternatingRowColors(true); @@ -438,7 +502,7 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() myEnforcedTableWidget->setItemDelegate(new EnforcedVertexTableWidgetDelegate()); -// VERTEX SELECTION + // VERTEX SELECTION TColStd_MapOfInteger shapeTypes; shapeTypes.Add( TopAbs_VERTEX ); shapeTypes.Add( TopAbs_COMPOUND ); @@ -466,20 +530,7 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() addVertexButton = new QPushButton(tr("GHS3D_ENF_ADD"),myEnfGroup); addVertexButton->setEnabled(false); removeVertexButton = new QPushButton(tr("GHS3D_ENF_REMOVE"),myEnfGroup); -// myGlobalGroupName = new QCheckBox(tr("GHS3D_ENF_VER_GROUPS"), myEnfGroup); -// myGlobalGroupName->setChecked(false); - - // QGroupBox* GroupBox = new QGroupBox( myEnfGroup ); - // QLabel* info = new QLabel( GroupBox ); - // info->setText( tr( "GHS3D_ENF_VER_INFO" ) ); - // info->setWordWrap( true ); - // QVBoxLayout* GroupBoxVLayout = new QVBoxLayout( GroupBox ); - // GroupBoxVLayout->setSpacing( 6 ); - // GroupBoxVLayout->setMargin( 11 ); - // GroupBoxVLayout->addWidget( info ); - - //anEnfLayout->addWidget(GroupBox, ENF_VER_WARNING, 0, 1, 2 ); anEnfLayout->addWidget(myEnforcedTableWidget, ENF_VER_VERTEX, 0, ENF_VER_NB_LINES, 1); QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup); @@ -531,9 +582,6 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() myEnforcedMeshTableWidget->setItemDelegate(new EnforcedMeshTableWidgetDelegate()); -// myEnfMesh = SMESH::SMESH_Mesh::_nil(); -// myEnfMeshArray = new SMESH::mesh_array(); - myEnfMeshWdg = new StdMeshersGUI_ObjectReferenceParamWdg( SMESH::IDSOURCE, myEnfMeshGroup, /*multiSel=*/true); myEnfMeshWdg->SetDefaultText(tr("GHS3D_ENF_SELECT_MESH"), "QLineEdit { color: grey }"); @@ -549,19 +597,8 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() myMeshGroupName = new QLineEdit(myEnfMeshGroup); addEnfMeshButton = new QPushButton(tr("GHS3D_ENF_ADD"),myEnfMeshGroup); -// addEnfMeshButton->setEnabled(false); removeEnfMeshButton = new QPushButton(tr("GHS3D_ENF_REMOVE"),myEnfMeshGroup); - - // QGroupBox* GroupBox2 = new QGroupBox( myEnfMeshGroup ); - // QLabel* info2 = new QLabel( GroupBox2 ); - // info2->setText( tr( "GHS3D_ENF_MESH_INFO" ) ); - // info2->setWordWrap( true ); - // QVBoxLayout* GroupBox2VLayout = new QVBoxLayout( GroupBox2 ); - // GroupBox2VLayout->setSpacing( 6 ); - // GroupBox2VLayout->setMargin( 11 ); - // GroupBox2VLayout->addWidget( info2 ); - // anEnfMeshLayout->addWidget( GroupBox2, ENF_MESH_WARNING, 0, 1, 2 ); anEnfMeshLayout->addWidget(myEnforcedMeshTableWidget, ENF_MESH_MESH, 0, ENF_MESH_NB_LINES , 1); QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup); @@ -580,12 +617,13 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() // add tabs tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) ); tab->insertTab( ADV_TAB, myAdvGroup, tr( "GHS3D_ADV_ARGS" ) ); - tab->insertTab( ENF_VER_TAB, myEnfGroup, tr( "GHS3D_ENFORCED_VERTICES" ) ); - tab->insertTab( ENF_MESH_TAB, myEnfMeshGroup, tr( "GHS3D_ENFORCED_MESHES" ) ); + if ( !isOptimization() ) + { + tab->insertTab( ENF_VER_TAB, myEnfGroup, tr( "GHS3D_ENFORCED_VERTICES" ) ); + tab->insertTab( ENF_MESH_TAB, myEnfMeshGroup, tr( "GHS3D_ENFORCED_MESHES" ) ); + } tab->setCurrentIndex( STD_TAB ); - // connections - //connect( myToMeshHolesCheck, SIGNAL( toggled( bool ) ), this, SLOT( onToMeshHoles(bool))); connect( myAdvWidget->maxMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) ); connect( myAdvWidget->initialMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) ); connect( myAdvWidget->boundaryRecoveryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) ); @@ -612,16 +650,13 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() connect( addEnfMeshButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedMesh() ) ); connect( removeEnfMeshButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedMesh() ) ); -// connect( myEnfMeshWdg, SIGNAL( contentModified()), this, SLOT( checkEnfMeshIsDefined() ) ); -// connect( myEnfMeshConstraint, SIGNAL( currentIndexChanged(int) ), this, SLOT( checkEnfMeshIsDefined() ) ); -// connect( this, SIGNAL( enfMeshDefined(bool) ), addEnfMeshButton, SLOT( setEnabled(bool) ) ); return fr; } /** * This method checks if an enforced vertex is defined; -**/ + **/ void GHS3DPluginGUI_HypothesisCreator::clearEnfVertexSelection() { if (myEnfVertexWdg->NbObjects() != 0) { @@ -637,21 +672,21 @@ void GHS3DPluginGUI_HypothesisCreator::clearEnfVertexSelection() /** * This method checks if an enforced vertex is defined; -**/ + **/ void GHS3DPluginGUI_HypothesisCreator::checkVertexIsDefined() { bool enfVertexIsDefined = false; enfVertexIsDefined = (!mySizeValue->GetString().isEmpty() && - (!myEnfVertexWdg->NbObjects() == 0 || - (myEnfVertexWdg->NbObjects() == 0 && !myXCoord->GetString().isEmpty() - && !myYCoord->GetString().isEmpty() - && !myZCoord->GetString().isEmpty()))); + (!myEnfVertexWdg->NbObjects() == 0 || + (myEnfVertexWdg->NbObjects() == 0 && !myXCoord->GetString().isEmpty() + && !myYCoord->GetString().isEmpty() + && !myZCoord->GetString().isEmpty()))); emit vertexDefined(enfVertexIsDefined); } /** * This method checks if an enforced mesh is defined; -**/ + **/ void GHS3DPluginGUI_HypothesisCreator::checkEnfMeshIsDefined() { emit enfMeshDefined( myEnfVertexWdg->NbObjects() != 0); @@ -659,27 +694,24 @@ void GHS3DPluginGUI_HypothesisCreator::checkEnfMeshIsDefined() /** * This method resets the content of the X, Y, Z, size and GroupName widgets; -**/ + **/ void GHS3DPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets() { myXCoord->setCleared(true); myYCoord->setCleared(true); myZCoord->setCleared(true); -// mySizeValue->setCleared(true); myXCoord->setText(""); myYCoord->setText(""); myZCoord->setText(""); -// mySizeValue->setText(""); -// myGroupName->setText(""); addVertexButton->setEnabled(false); } /** GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item) -This method updates the tooltip of a modified item. The QLineEdit widgets content -is synchronized with the coordinates of the enforced vertex clicked in the tree widget. + This method updates the tooltip of a modified item. The QLineEdit widgets content + is synchronized with the coordinates of the enforced vertex clicked in the tree widget. */ -void GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetItem* item) { -// MESSAGE("GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues"); +void GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetItem* item) +{ int row = myEnforcedTableWidget->row(item); QVariant vertexName = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole); @@ -710,7 +742,6 @@ void GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetIt if (!groupName.isEmpty()) toolTip += QString(" [") + groupName + QString("]"); -// MESSAGE("Tooltip: " << toolTip.toStdString()); for (int col=0;colitem(row,col)->setToolTip(toolTip); @@ -733,13 +764,14 @@ void GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetIt } } -void GHS3DPluginGUI_HypothesisCreator::onSelectEnforcedVertex() { +void GHS3DPluginGUI_HypothesisCreator::onSelectEnforcedVertex() +{ int nbSelEnfVertex = myEnfVertexWdg->NbObjects(); clearEnforcedVertexWidgets(); if (nbSelEnfVertex == 1) { if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() ) - return ; + return ; myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1); if (myEnfVertex == GEOM::GEOM_Object::_nil()) @@ -769,13 +801,13 @@ void GHS3DPluginGUI_HypothesisCreator::onSelectEnforcedVertex() { } /** GHS3DPluginGUI_HypothesisCreator::synchronizeCoords() -This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates -of the enforced vertex clicked in the tree widget. + This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates + of the enforced vertex clicked in the tree widget. */ -void GHS3DPluginGUI_HypothesisCreator::synchronizeCoords() { +void GHS3DPluginGUI_HypothesisCreator::synchronizeCoords() +{ clearEnforcedVertexWidgets(); QList items = myEnforcedTableWidget->selectedItems(); -// myEnfVertexWdg->disconnect(SIGNAL(contentModified())); disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) ); if (! items.isEmpty()) { QTableWidgetItem *item; @@ -800,7 +832,7 @@ void GHS3DPluginGUI_HypothesisCreator::synchronizeCoords() { } QVariant group = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole); if (!x.isNull()/* && entry.isNull()*/) { -// disconnect( myXCoord, SIGNAL( textChanged(const QString &)), this, SLOT( onSelectEnforcedVertex() ) ); + // disconnect( myXCoord, SIGNAL( textChanged(const QString &)), this, SLOT( onSelectEnforcedVertex() ) ); disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); @@ -847,11 +879,13 @@ void GHS3DPluginGUI_HypothesisCreator::synchronizeCoords() { } /** GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh( meshName, geomEntry, elemType, size, groupName) -This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName. + This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName. */ -void GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName) +void GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, + std::string entry, + int elementType, + std::string groupName) { - MESSAGE("addEnforcedMesh(\"" << name << ", \"" << entry << "\", " << elementType << ", \"" << groupName << "\")"); bool okToCreate = true; QString itemEntry = ""; int itemElementType = 0; @@ -859,23 +893,19 @@ void GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::st bool allColumns = true; for (int row = 0;row(myEnforcedMeshTableWidget->cellWidget(row, col)) == 0) { allColumns = false; - MESSAGE("allColumns = false"); break; } } else if (myEnforcedMeshTableWidget->item(row, col) == 0) { allColumns = false; - MESSAGE("allColumns = false"); break; } if (col == ENF_MESH_CONSTRAINT_COLUMN) { QComboBox* itemComboBox = qobject_cast(myEnforcedMeshTableWidget->cellWidget(row, col)); itemElementType = itemComboBox->currentIndex(); - MESSAGE("itemElementType: " << itemElementType); } else if (col == ENF_MESH_ENTRY_COLUMN) itemEntry = myEnforcedMeshTableWidget->item(row, col)->data(Qt::EditRole).toString(); @@ -885,11 +915,6 @@ void GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::st break; if (itemEntry == QString(entry.c_str()) && itemElementType == elementType) { -// // update group name -// if (itemGroupName.toStdString() != groupName) { -// MESSAGE("Group is updated from \"" << itemGroupName.toStdString() << "\" to \"" << groupName << "\""); -// myEnforcedMeshTableWidget->item(row, ENF_MESH_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str())); -// } okToCreate = false; break; } // if @@ -899,13 +924,10 @@ void GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::st if (!okToCreate) return; - MESSAGE("Creation of enforced mesh"); - myEnforcedMeshTableWidget->setRowCount(rowCount+1); myEnforcedMeshTableWidget->setSortingEnabled(false); for (int col=0;colpalette(); @@ -914,56 +936,44 @@ void GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::st comboBox->insertItems(0,myEnfMeshConstraintLabels); comboBox->setEditable(false); comboBox->setCurrentIndex(elementType); - MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << comboBox->currentText().toStdString()); myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox); } else { QTableWidgetItem* item = new QTableWidgetItem(); item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled); switch (col) { - case ENF_MESH_NAME_COLUMN: - item->setData( 0, name.c_str() ); - item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled); - MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); - myEnforcedMeshTableWidget->setItem(rowCount,col,item); - break; - case ENF_MESH_ENTRY_COLUMN: - item->setData( 0, entry.c_str() ); - item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled); - MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); - myEnforcedMeshTableWidget->setItem(rowCount,col,item); - break; - case ENF_MESH_GROUP_COLUMN: - item->setData( 0, groupName.c_str() ); - MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); - myEnforcedMeshTableWidget->setItem(rowCount,col,item); - break; - default: - break; + case ENF_MESH_NAME_COLUMN: + item->setData( 0, name.c_str() ); + item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled); + myEnforcedMeshTableWidget->setItem(rowCount,col,item); + break; + case ENF_MESH_ENTRY_COLUMN: + item->setData( 0, entry.c_str() ); + item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled); + myEnforcedMeshTableWidget->setItem(rowCount,col,item); + break; + case ENF_MESH_GROUP_COLUMN: + item->setData( 0, groupName.c_str() ); + myEnforcedMeshTableWidget->setItem(rowCount,col,item); + break; + default: + break; } } - MESSAGE("Done"); } - -// connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) ); - myEnforcedMeshTableWidget->setSortingEnabled(true); -// myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN)); -// updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN)); - } /** GHS3DPluginGUI_HypothesisCreator::addEnforcedVertex( x, y, z, size, vertexName, geomEntry, groupName) -This method adds in the tree widget an enforced vertex with given size and coords (x,y,z) or GEOM vertex or compound and with optionally groupName. + This method adds in the tree widget an enforced vertex with given size and coords (x,y,z) or GEOM vertex or compound and with optionally groupName. */ void GHS3DPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z, double size, std::string vertexName, std::string geomEntry, std::string groupName, bool isCompound) { - MESSAGE("addEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ", \"" << vertexName << ", \"" << geomEntry << "\", \"" << groupName << "\", " << isCompound << ")"); myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *))); bool okToCreate = true; double itemX,itemY,itemZ,itemSize = 0; QString itemEntry, itemGroupName = QString(""); -// bool itemIsCompound; + // bool itemIsCompound; int rowCount = myEnforcedTableWidget->rowCount(); QVariant data; bool allColumns; @@ -978,29 +988,26 @@ void GHS3DPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, dou data = myEnforcedTableWidget->item(row, col)->data(Qt::EditRole); if (!data.isNull()) { switch (col) { - case ENF_VER_GROUP_COLUMN: - itemGroupName = data.toString(); - break; - case ENF_VER_ENTRY_COLUMN: - itemEntry = data.toString(); - break; -// case ENF_VER_COMPOUND_COLUMN: -// itemIsCompound = data.toBool(); -// break; - case ENF_VER_X_COLUMN: - itemX = data.toDouble(); - break; - case ENF_VER_Y_COLUMN: - itemY = data.toDouble(); - break; - case ENF_VER_Z_COLUMN: - itemZ = data.toDouble(); - break; - case ENF_VER_SIZE_COLUMN: - itemSize = data.toDouble(); - break; - default: - break; + case ENF_VER_GROUP_COLUMN: + itemGroupName = data.toString(); + break; + case ENF_VER_ENTRY_COLUMN: + itemEntry = data.toString(); + break; + case ENF_VER_X_COLUMN: + itemX = data.toDouble(); + break; + case ENF_VER_Y_COLUMN: + itemY = data.toDouble(); + break; + case ENF_VER_Z_COLUMN: + itemZ = data.toDouble(); + break; + case ENF_VER_SIZE_COLUMN: + itemSize = data.toDouble(); + break; + default: + break; } } } @@ -1014,12 +1021,10 @@ void GHS3DPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, dou { // update size if (itemSize != size) { - MESSAGE("Size is updated from \"" << itemSize << "\" to \"" << size << "\""); myEnforcedTableWidget->item(row, ENF_VER_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size)); } // update group name if (itemGroupName.toStdString() != groupName) { - MESSAGE("Group is updated from \"" << itemGroupName.toStdString() << "\" to \"" << groupName << "\""); myEnforcedTableWidget->item(row, ENF_VER_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str())); } okToCreate = false; @@ -1028,21 +1033,12 @@ void GHS3DPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, dou } // for if (!okToCreate) { if (geomEntry.empty()) { - MESSAGE("Vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again"); } else { - MESSAGE("Vertex with entry " << geomEntry << " already exist: dont create again"); } return; } - if (geomEntry.empty()) { - MESSAGE("Vertex with coords " << x << ", " << y << ", " << z<< " is created"); - } - else { - MESSAGE("Vertex with geom entry " << geomEntry << " is created"); - } - int vertexIndex=0; int indexRef = -1; QString myVertexName; @@ -1062,73 +1058,67 @@ void GHS3DPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, dou } } - MESSAGE("myVertexName is \"" << myVertexName.toStdString() << "\""); myEnforcedTableWidget->setRowCount(rowCount+1); myEnforcedTableWidget->setSortingEnabled(false); for (int col=0;colsetFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled); switch (col) { - case ENF_VER_NAME_COLUMN: - item->setData( Qt::EditRole, myVertexName ); - if (!geomEntry.empty()) { - if (isCompound) - item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation))); - else - item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation))); - } - break; - case ENF_VER_X_COLUMN: - if (!isCompound) - item->setData( 0, QVariant(x) ); - break; - case ENF_VER_Y_COLUMN: - if (!isCompound) - item->setData( 0, QVariant(y) ); - break; - case ENF_VER_Z_COLUMN: - if (!isCompound) - item->setData( 0, QVariant(z) ); - break; - case ENF_VER_SIZE_COLUMN: - item->setData( 0, QVariant(size) ); - break; - case ENF_VER_ENTRY_COLUMN: - if (!geomEntry.empty()) - item->setData( 0, QString(geomEntry.c_str()) ); - break; - case ENF_VER_COMPOUND_COLUMN: - item->setData( Qt::CheckStateRole, isCompound ); - item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable); - break; - case ENF_VER_GROUP_COLUMN: - if (!groupName.empty()) - item->setData( 0, QString(groupName.c_str()) ); - break; - default: - break; + case ENF_VER_NAME_COLUMN: + item->setData( Qt::EditRole, myVertexName ); + if (!geomEntry.empty()) { + if (isCompound) + item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation))); + else + item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation))); + } + break; + case ENF_VER_X_COLUMN: + if (!isCompound) + item->setData( 0, QVariant(x) ); + break; + case ENF_VER_Y_COLUMN: + if (!isCompound) + item->setData( 0, QVariant(y) ); + break; + case ENF_VER_Z_COLUMN: + if (!isCompound) + item->setData( 0, QVariant(z) ); + break; + case ENF_VER_SIZE_COLUMN: + item->setData( 0, QVariant(size) ); + break; + case ENF_VER_ENTRY_COLUMN: + if (!geomEntry.empty()) + item->setData( 0, QString(geomEntry.c_str()) ); + break; + case ENF_VER_COMPOUND_COLUMN: + item->setData( Qt::CheckStateRole, isCompound ); + item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable); + break; + case ENF_VER_GROUP_COLUMN: + if (!groupName.empty()) + item->setData( 0, QString(groupName.c_str()) ); + break; + default: + break; } - MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); myEnforcedTableWidget->setItem(rowCount,col,item); - MESSAGE("Done"); } connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) ); myEnforcedTableWidget->setSortingEnabled(true); -// myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN)); + // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN)); updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN)); } /** GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh() -This method is called when a item is added into the enforced meshes tree widget + This method is called when a item is added into the enforced meshes tree widget */ void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh() { - MESSAGE("GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh()"); - GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this; that->getGeomSelectionTool()->selectionMgr()->clearFilters(); @@ -1142,44 +1132,30 @@ void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh() if (selEnfMeshes == 0) return; - std::string groupName = myMeshGroupName->text().toStdString(); -// if (myGlobalGroupName->isChecked()) -// groupName = myGlobalGroupName->text().toStdString(); - - if (boost::trim_copy(groupName).empty()) - groupName = ""; - + std::string groupName = myMeshGroupName->text().simplified().toStdString(); int elementType = myEnfMeshConstraint->currentIndex(); _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); - _PTR(SObject) aSObj; //SMESH::SMESH_IDSource::_nil; + _PTR(SObject) aSObj; QString meshEntry = myEnfMeshWdg->GetValue(); - MESSAGE("myEnfMeshWdg->GetValue()" << meshEntry.toStdString()); if (selEnfMeshes == 1) { - MESSAGE("1 SMESH object selected"); -// myEnfMesh = myEnfMeshWdg->GetObject< SMESH::SMESH_IDSource >(); -// std::string entry = myEnfMeshWdg->GetValue(); aSObj = aStudy->FindObjectID(meshEntry.toStdString().c_str()); CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy); - if (!CORBA::is_nil(anObj)) { -// SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface( aSObj ); + if (!CORBA::is_nil(anObj)) addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName); - } } else { - MESSAGE(selEnfMeshes << " SMESH objects selected"); QStringList meshEntries = meshEntry.split(" ", QString::SkipEmptyParts); QStringListIterator meshEntriesIt (meshEntries); while (meshEntriesIt.hasNext()) { aSObj = aStudy->FindObjectID(meshEntriesIt.next().toStdString().c_str()); CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy); if (!CORBA::is_nil(anObj)) { -// SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface( aSObj ); addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName); } } @@ -1193,12 +1169,10 @@ void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh() /** GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex() -This method is called when a item is added into the enforced vertices tree widget + This method is called when a item is added into the enforced vertices tree widget */ void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex() { - MESSAGE("GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex()"); - GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this; that->getGeomSelectionTool()->selectionMgr()->clearFilters(); @@ -1213,18 +1187,12 @@ void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex() if ((selEnfVertex == 0) && coordsEmpty) return; - std::string groupName = myGroupName->text().toStdString(); -// if (myGlobalGroupName->isChecked()) -// groupName = myGlobalGroupName->text().toStdString(); - - if (boost::trim_copy(groupName).empty()) - groupName = ""; + std::string groupName = myGroupName->text().simplified().toStdString(); double size = mySizeValue->GetValue(); if (selEnfVertex <= 1) { - MESSAGE("0 or 1 GEOM object selected"); double x = 0, y = 0, z=0; if (myXCoord->GetString() != "") { x = myXCoord->GetValue(); @@ -1232,7 +1200,6 @@ void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex() z = myZCoord->GetValue(); } if (selEnfVertex == 1) { - MESSAGE("1 GEOM object selected"); myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(); std::string entry = "", name = ""; bool isCompound = false; @@ -1244,8 +1211,6 @@ void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex() addEnforcedVertex(x, y, z, size, name, entry, groupName, isCompound); } else { - MESSAGE("0 GEOM object selected"); - MESSAGE("Coords: ("<IsDone() ) addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName); } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) { - addEnforcedVertex(0., 0., 0., size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName, true); + addEnforcedVertex(0., 0., 0., size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName, true); } } } @@ -1281,7 +1246,7 @@ void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex() } /** GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedMesh() -This method is called when a item is removed from the enforced meshes tree widget + This method is called when a item is removed from the enforced meshes tree widget */ void GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedMesh() { @@ -1294,21 +1259,20 @@ void GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedMesh() if (!selectedRows.contains( row ) ) selectedRows.append(row); } - + qSort( selectedRows ); QListIterator it( selectedRows ); it.toBack(); while ( it.hasPrevious() ) { - row = it.previous(); - MESSAGE("delete row #"<< row); - myEnforcedMeshTableWidget->removeRow(row ); + row = it.previous(); + myEnforcedMeshTableWidget->removeRow(row ); } myEnforcedMeshTableWidget->selectionModel()->clearSelection(); } /** GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() -This method is called when a item is removed from the enforced vertices tree widget + This method is called when a item is removed from the enforced vertices tree widget */ void GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() { @@ -1326,9 +1290,8 @@ void GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() QListIterator it( selectedRows ); it.toBack(); while ( it.hasPrevious() ) { - row = it.previous(); - MESSAGE("delete row #"<< row); - myEnforcedTableWidget->removeRow(row ); + row = it.previous(); + myEnforcedTableWidget->removeRow(row ); } myEnforcedTableWidget->selectionModel()->clearSelection(); @@ -1359,16 +1322,14 @@ void GHS3DPluginGUI_HypothesisCreator::updateWidgets() sender() == myAdvWidget->keepWorkingFilesCheck ) { bool logFileRemovable = myAdvWidget->logInFileCheck->isChecked() && - !myAdvWidget->keepWorkingFilesCheck->isChecked(); - + !myAdvWidget->keepWorkingFilesCheck->isChecked(); + myAdvWidget->removeLogOnSuccessCheck->setEnabled( logFileRemovable ); } } bool GHS3DPluginGUI_HypothesisCreator::checkParams(QString& msg) const { - MESSAGE("GHS3DPluginGUI_HypothesisCreator::checkParams"); - if ( !QFileInfo( myAdvWidget->workingDirectoryLineEdit->text().trimmed() ).isWritable() ) { SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ), @@ -1381,17 +1342,28 @@ bool GHS3DPluginGUI_HypothesisCreator::checkParams(QString& msg) const void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const { - MESSAGE("GHS3DPluginGUI_HypothesisCreator::retrieveParams"); GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this; GHS3DHypothesisData data; readParamsFromHypo( data ); if ( myName ) + { myName->setText( data.myName ); - + + int width = QFontMetrics( myName->font() ).width( data.myName ); + QGridLayout* aStdLayout = (QGridLayout*) myStdGroup->layout(); + aStdLayout->setColumnMinimumWidth( 1, width + 10 ); + } myToMeshHolesCheck ->setChecked ( data.myToMeshHoles ); myToMakeGroupsOfDomains ->setChecked ( data.myToMakeGroupsOfDomains ); myOptimizationLevelCombo ->setCurrentIndex( data.myOptimizationLevel ); + myOptimizationCombo ->setCurrentIndex( data.myOptimization ); + mySplitOverConstrainedCombo ->setCurrentIndex( data.mySplitOverConstrained ); + myPThreadsModeCombo ->setCurrentIndex( data.myPThreadsMode ); + myNumberOfThreadsSpin ->setValue ( data.myNumberOfThreads ); + mySmoothOffSliversCheck ->setChecked ( data.mySmoothOffSlivers ); + myCreateNewNodesCheck ->setChecked ( data.myToCreateNewNodes ); + myAdvWidget->maxMemoryCheck ->setChecked ( data.myMaximumMemory > 0 ); myAdvWidget->maxMemorySpin ->setValue ( qMax( (int)data.myMaximumMemory, myAdvWidget->maxMemorySpin->minimum() )); @@ -1421,63 +1393,52 @@ void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const myEnforcedTableWidget->setRowCount(rowCount+1); for (int col=0;colisCompound: " << enfVertex->isCompound); QTableWidgetItem* item = new QTableWidgetItem(); item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled); switch (col) { - case ENF_VER_NAME_COLUMN: - item->setData( 0, enfVertex->name.c_str() ); - if (!enfVertex->geomEntry.empty()) { - if (enfVertex->isCompound) - item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation))); - else - item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation))); + case ENF_VER_NAME_COLUMN: + item->setData( 0, enfVertex->name.c_str() ); + if (!enfVertex->geomEntry.empty()) { + if (enfVertex->isCompound) + item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation))); + else + item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation))); - MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); - } - break; - case ENF_VER_X_COLUMN: - if (!enfVertex->isCompound) { - item->setData( 0, enfVertex->coords.at(0) ); - MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); - } - break; - case ENF_VER_Y_COLUMN: - if (!enfVertex->isCompound) { - item->setData( 0, enfVertex->coords.at(1) ); - MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); - } - break; - case ENF_VER_Z_COLUMN: - if (!enfVertex->isCompound) { - item->setData( 0, enfVertex->coords.at(2) ); - MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); - } - break; - case ENF_VER_SIZE_COLUMN: - item->setData( 0, enfVertex->size ); - MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); - break; - case ENF_VER_ENTRY_COLUMN: - item->setData( 0, enfVertex->geomEntry.c_str() ); - MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); - break; - case ENF_VER_COMPOUND_COLUMN: - item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable); - item->setData( Qt::CheckStateRole, enfVertex->isCompound ); - MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << enfVertex->isCompound); - break; - case ENF_VER_GROUP_COLUMN: - item->setData( 0, enfVertex->groupName.c_str() ); - MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); - break; - default: - break; + } + break; + case ENF_VER_X_COLUMN: + if (!enfVertex->isCompound) { + item->setData( 0, enfVertex->coords.at(0) ); + } + break; + case ENF_VER_Y_COLUMN: + if (!enfVertex->isCompound) { + item->setData( 0, enfVertex->coords.at(1) ); + } + break; + case ENF_VER_Z_COLUMN: + if (!enfVertex->isCompound) { + item->setData( 0, enfVertex->coords.at(2) ); + } + break; + case ENF_VER_SIZE_COLUMN: + item->setData( 0, enfVertex->size ); + break; + case ENF_VER_ENTRY_COLUMN: + item->setData( 0, enfVertex->geomEntry.c_str() ); + break; + case ENF_VER_COMPOUND_COLUMN: + item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable); + item->setData( Qt::CheckStateRole, enfVertex->isCompound ); + break; + case ENF_VER_GROUP_COLUMN: + item->setData( 0, enfVertex->groupName.c_str() ); + break; + default: + break; } myEnforcedTableWidget->setItem(rowCount,col,item); - MESSAGE("Done"); } that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN)); rowCount++; @@ -1494,14 +1455,13 @@ void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const rowCount = 0; myEnforcedMeshTableWidget->clearContents(); myEnforcedMeshTableWidget->setSortingEnabled(false); -// myEnforcedMeshTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *))); + // myEnforcedMeshTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *))); for(itMesh = data.myEnforcedMeshes.begin() ; itMesh != data.myEnforcedMeshes.end(); itMesh++ ) { TEnfMesh* enfMesh = (*itMesh); myEnforcedMeshTableWidget->setRowCount(rowCount+1); for (int col=0;colpalette(); @@ -1510,43 +1470,35 @@ void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const comboBox->insertItems(0,myEnfMeshConstraintLabels); comboBox->setEditable(false); comboBox->setCurrentIndex(enfMesh->elementType); - MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << comboBox->currentText().toStdString()); myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox); } else { QTableWidgetItem* item = new QTableWidgetItem(); item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled); switch (col) { - case ENF_MESH_NAME_COLUMN: - item->setData( 0, enfMesh->name.c_str() ); - item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled); - MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); - myEnforcedMeshTableWidget->setItem(rowCount,col,item); - break; - case ENF_MESH_ENTRY_COLUMN: - item->setData( 0, enfMesh->entry.c_str() ); - item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled); - MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); - myEnforcedMeshTableWidget->setItem(rowCount,col,item); - break; - case ENF_MESH_GROUP_COLUMN: - item->setData( 0, enfMesh->groupName.c_str() ); - MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); - myEnforcedMeshTableWidget->setItem(rowCount,col,item); - break; - default: - break; + case ENF_MESH_NAME_COLUMN: + item->setData( 0, enfMesh->name.c_str() ); + item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled); + myEnforcedMeshTableWidget->setItem(rowCount,col,item); + break; + case ENF_MESH_ENTRY_COLUMN: + item->setData( 0, enfMesh->entry.c_str() ); + item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled); + myEnforcedMeshTableWidget->setItem(rowCount,col,item); + break; + case ENF_MESH_GROUP_COLUMN: + item->setData( 0, enfMesh->groupName.c_str() ); + myEnforcedMeshTableWidget->setItem(rowCount,col,item); + break; + default: + break; } } -// myEnforcedMeshTableWidget->setItem(rowCount,col,item); - MESSAGE("Done"); } -// that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN)); rowCount++; } -// connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) ); myEnforcedMeshTableWidget->setSortingEnabled(true); for (int col=0;col= 0 && data.myOptimizationLevel < 5 && !data.myBoundaryRecovery) { - const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" }; - valStr += " --optimisation_level "; - valStr += level[ data.myOptimizationLevel ]; - } - if ( data.myMaximumMemory > 0 ) { - valStr += " --max_memory "; - valStr += QString::number( data.myMaximumMemory ); - } - if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) { - valStr += " --automatic_memory "; - valStr += QString::number( data.myInitialMemory ); - } - valStr += " --verbose "; - valStr += QString::number( data.myVerboseLevel ); + if ( !data.myBoundaryRecovery ) + valStr = " --components " + data.myToMeshHoles ? "all" : "outside_components" ; - if ( !data.myToCreateNewNodes ) - valStr += " --no_internal_points"; + if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 5 && !data.myBoundaryRecovery) { + const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" }; + valStr += " --optimisation_level "; + valStr += level[ data.myOptimizationLevel ]; + } + if ( data.myMaximumMemory > 0 ) { + valStr += " --max_memory "; + valStr += QString::number( data.myMaximumMemory ); + } + if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) { + valStr += " --automatic_memory "; + valStr += QString::number( data.myInitialMemory ); + } + valStr += " --verbose "; + valStr += QString::number( data.myVerboseLevel ); - if ( data.myRemoveInitialCentralPoint ) - valStr += " --no_initial_central_point"; + if ( !data.myToCreateNewNodes ) + valStr += " --no_internal_points"; - if ( data.myBoundaryRecovery ) - valStr += " -C"; + if ( data.myRemoveInitialCentralPoint ) + valStr += " --no_initial_central_point"; - if ( data.myFEMCorrection ) - valStr += " -FEM"; + if ( data.myBoundaryRecovery ) + valStr += " -C"; - if ( data.myGradation != 1.05 ) { - valStr += " -Dcpropa="; - valStr += QString::number( data.myGradation ); - } + if ( data.myFEMCorrection ) + valStr += " -FEM"; - valStr += " "; - valStr += data.myTextOption; + if ( data.myGradation != 1.05 ) { + valStr += " -Dcpropa="; + valStr += QString::number( data.myGradation ); + } -// valStr += " #BEGIN ENFORCED VERTICES#"; -// // Add size map parameters storage -// for (int i=0 ; irowCount() ; i++) { -// valStr += " ("; -// double x = mySmpModel->data(mySmpModel->index(i,ENF_VER_X_COLUMN)).toDouble(); -// double y = mySmpModel->data(mySmpModel->index(i,ENF_VER_Y_COLUMN)).toDouble(); -// double z = mySmpModel->data(mySmpModel->index(i,ENF_VER_Z_COLUMN)).toDouble(); -// double size = mySmpModel->data(mySmpModel->index(i,ENF_VER_SIZE_COLUMN)).toDouble(); -// valStr += QString::number( x ); -// valStr += ","; -// valStr += QString::number( y ); -// valStr += ","; -// valStr += QString::number( z ); -// valStr += ")="; -// valStr += QString::number( size ); -// if (i!=mySmpModel->rowCount()-1) -// valStr += ";"; -// } -// valStr += " #END ENFORCED VERTICES#"; -// MESSAGE(valStr.toStdString()); + valStr += " "; + valStr += data.myTextOption; + return valStr; } bool GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DHypothesisData& h_data ) const { - MESSAGE("GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo"); GHS3DPlugin::GHS3DPlugin_Hypothesis_var h = GHS3DPlugin::GHS3DPlugin_Hypothesis::_narrow( initParamsHypothesis() ); + GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis_var opt = + GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis::_narrow( initParamsHypothesis() ); HypothesisData* data = SMESH::GetHypothesisData( hypType() ); h_data.myName = isCreation() && data ? hypName() : ""; + if ( !opt->_is_nil() ) + { + h_data.myOptimization = opt->GetOptimization(); + h_data.mySplitOverConstrained = opt->GetSplitOverConstrained(); + h_data.myPThreadsMode = opt->GetPThreadsMode(); + h_data.myNumberOfThreads = opt->GetMaximalNumberOfThreads(); + h_data.mySmoothOffSlivers = opt->GetSmoothOffSlivers(); + } h_data.myToMeshHoles = h->GetToMeshHoles(); - h_data.myToMakeGroupsOfDomains = /*h->GetToMeshHoles() &&*/ h->GetToMakeGroupsOfDomains(); + h_data.myToMakeGroupsOfDomains = h->GetToMakeGroupsOfDomains(); h_data.myMaximumMemory = h->GetMaximumMemory(); h_data.myInitialMemory = h->GetInitialMemory(); h_data.myInitialMemory = h->GetInitialMemory(); @@ -1655,7 +1595,6 @@ bool GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DHypothesisData& h_data.myRemoveLogOnSuccess = h->GetRemoveLogOnSuccess(); GHS3DPlugin::GHS3DEnforcedVertexList_var vertices = h->GetEnforcedVertices(); - MESSAGE("vertices->length(): " << vertices->length()); h_data.myEnforcedVertices.clear(); for (CORBA::ULong i=0 ; ilength() ; i++) { TEnfVertex* myVertex = new TEnfVertex(); @@ -1667,13 +1606,11 @@ bool GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DHypothesisData& if (vertices[i].coords.length()) { for (CORBA::ULong c = 0; c < vertices[i].coords.length() ; c++) myVertex->coords.push_back(vertices[i].coords[c]); - MESSAGE("Add enforced vertex ("<< myVertex->coords.at(0) << ","<< myVertex->coords.at(1) << ","<< myVertex->coords.at(2) << ") ="<< myVertex->size); } h_data.myEnforcedVertices.insert(myVertex); } GHS3DPlugin::GHS3DEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes(); - MESSAGE("enfMeshes->length(): " << enfMeshes->length()); h_data.myEnforcedMeshes.clear(); for (CORBA::ULong i=0 ; ilength() ; i++) { TEnfMesh* myEnfMesh = new TEnfMesh(); @@ -1681,19 +1618,19 @@ bool GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DHypothesisData& myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in()); myEnfMesh->groupName = CORBA::string_dup(enfMeshes[i].groupName.in()); switch (enfMeshes[i].elementType) { - case SMESH::NODE: - myEnfMesh->elementType = 0; - break; - case SMESH::EDGE: - myEnfMesh->elementType = 1; - break; - case SMESH::FACE: - myEnfMesh->elementType = 2; - break; - default: - break; + case SMESH::NODE: + myEnfMesh->elementType = 0; + break; + case SMESH::EDGE: + myEnfMesh->elementType = 1; + break; + case SMESH::FACE: + myEnfMesh->elementType = 2; + break; + default: + break; } -// myEnfMesh->elementType = enfMeshes[i].elementType; + // myEnfMesh->elementType = enfMeshes[i].elementType; h_data.myEnforcedMeshes.insert(myEnfMesh); } return true; @@ -1701,9 +1638,10 @@ bool GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DHypothesisData& bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisData& h_data ) const { - MESSAGE("GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo"); GHS3DPlugin::GHS3DPlugin_Hypothesis_var h = GHS3DPlugin::GHS3DPlugin_Hypothesis::_narrow( hypothesis() ); + GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis_var opt = + GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis::_narrow( initParamsHypothesis() ); bool ok = true; try @@ -1743,22 +1681,27 @@ bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisD h->SetAdvancedOption ( h_data.myTextOption.toLatin1().constData() ); if ( h->GetStandardOutputLog() != h_data.myLogInStandardOutput ) h->SetStandardOutputLog( h_data.myLogInStandardOutput ); - if ( h->GetRemoveLogOnSuccess() != h_data.myRemoveLogOnSuccess ) + if ( h->GetRemoveLogOnSuccess() != h_data.myRemoveLogOnSuccess ) h->SetRemoveLogOnSuccess( h_data.myRemoveLogOnSuccess ); - + + if ( !opt->_is_nil() ) + { + opt->SetOptimization ( (GHS3DPlugin::Mode) h_data.myOptimization ); + opt->SetSplitOverConstrained ( (GHS3DPlugin::Mode) h_data.mySplitOverConstrained ); + opt->SetPThreadsMode ( (GHS3DPlugin::PThreadsMode) h_data.myPThreadsMode ); + opt->SetSmoothOffSlivers ( h_data.mySmoothOffSlivers ); + opt->SetMaximalNumberOfThreads( h_data.myNumberOfThreads ); + } + // Enforced vertices - int nbVertex = (int) h_data.myEnforcedVertices.size(); GHS3DPlugin::GHS3DEnforcedVertexList_var vertexHyp = h->GetEnforcedVertices(); int nbVertexHyp = vertexHyp->length(); - - MESSAGE("Store params for size maps: " << nbVertex << " enforced vertices"); - MESSAGE("h->GetEnforcedVertices()->length(): " << nbVertexHyp); - + // 1. Clear all enforced vertices in hypothesis // 2. Add new enforced vertex according to h_data if ( nbVertexHyp > 0) h->ClearEnforcedVertices(); - + TEnfVertexList::const_iterator it; double x = 0, y = 0, z = 0; for(it = h_data.myEnforcedVertices.begin() ; it != h_data.myEnforcedVertices.end(); it++ ) { @@ -1771,20 +1714,16 @@ bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisD } ok = h->p_SetEnforcedVertex( enfVertex->size, x, y, z, enfVertex->name.c_str(), enfVertex->geomEntry.c_str(), enfVertex->groupName.c_str(), enfVertex->isCompound); } // for - + // Enforced Meshes - int nbEnfMeshes = (int) h_data.myEnforcedMeshes.size(); GHS3DPlugin::GHS3DEnforcedMeshList_var enfMeshListHyp = h->GetEnforcedMeshes(); int nbEnfMeshListHyp = enfMeshListHyp->length(); - - MESSAGE("Store params for size maps: " << nbEnfMeshes << " enforced meshes"); - MESSAGE("h->GetEnforcedMeshes()->length(): " << nbEnfMeshListHyp); - + // 1. Clear all enforced vertices in hypothesis // 2. Add new enforced vertex according to h_data if ( nbEnfMeshListHyp > 0) h->ClearEnforcedMeshes(); - + TEnfMeshList::const_iterator itEnfMesh; _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); @@ -1795,30 +1734,24 @@ bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisD _PTR(SObject) aSObj = aStudy->FindObjectID(enfMesh->entry.c_str()); SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface( aSObj ); - MESSAGE("enfMesh->elementType: " << enfMesh->elementType); SMESH::ElementType elementType; switch(enfMesh->elementType) { - case 0: - elementType = SMESH::NODE; - break; - case 1: - elementType = SMESH::EDGE; - break; - case 2: - elementType = SMESH::FACE; - break; - default: - break; + case 0: + elementType = SMESH::NODE; + break; + case 1: + elementType = SMESH::EDGE; + break; + case 2: + elementType = SMESH::FACE; + break; + default: + break; } - std::cout << "h->p_SetEnforcedMesh(theSource, "<< elementType <<", \""<< enfMesh->name << "\", \"" << enfMesh->groupName.c_str() <<"\")"<p_SetEnforcedMesh(theSource, elementType, enfMesh->name.c_str(), enfMesh->groupName.c_str()); } // for } // try -// catch(const std::exception& ex) { -// std::cout << "Exception: " << ex.what() << std::endl; -// throw ex; -// } catch ( const SALOME::SALOME_Exception& ex ) { SalomeApp_Tools::QtCatchCorbaException( ex ); @@ -1829,17 +1762,20 @@ bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisD bool GHS3DPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DHypothesisData& h_data ) const { - MESSAGE("GHS3DPluginGUI_HypothesisCreator::readParamsFromWidgets"); h_data.myName = myName ? myName->text() : ""; h_data.myToMeshHoles = myToMeshHolesCheck->isChecked(); h_data.myToMakeGroupsOfDomains = myToMakeGroupsOfDomains->isChecked(); + h_data.myOptimization = myOptimizationCombo->currentIndex(); + h_data.myOptimizationLevel = myOptimizationLevelCombo->currentIndex(); + h_data.mySplitOverConstrained = mySplitOverConstrainedCombo->currentIndex(); + h_data.myPThreadsMode = myPThreadsModeCombo->currentIndex(); + h_data.myNumberOfThreads = myNumberOfThreadsSpin->value(); + h_data.mySmoothOffSlivers = mySmoothOffSliversCheck->isChecked(); h_data.myMaximumMemory = myAdvWidget->maxMemoryCheck->isChecked() ? myAdvWidget->maxMemorySpin->value() : -1; h_data.myInitialMemory = myAdvWidget->initialMemoryCheck->isChecked() ? myAdvWidget->initialMemorySpin->value() : -1; - h_data.myOptimizationLevel = myOptimizationLevelCombo->currentIndex(); h_data.myKeepFiles = myAdvWidget->keepWorkingFilesCheck->isChecked(); h_data.myWorkingDir = myAdvWidget->workingDirectoryLineEdit->text().trimmed(); h_data.myVerboseLevel = myAdvWidget->verboseLevelSpin->value(); - h_data.myToCreateNewNodes = myAdvWidget->createNewNodesCheck->isChecked(); h_data.myRemoveInitialCentralPoint = myAdvWidget->removeInitialCentralPointCheck->isChecked(); h_data.myBoundaryRecovery = myAdvWidget->boundaryRecoveryCheck->isChecked(); h_data.myFEMCorrection = myAdvWidget->FEMCorrectionCheck->isChecked(); @@ -1847,21 +1783,20 @@ bool GHS3DPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DHypothesisDat h_data.myTextOption = myAdvWidget->advOptionTable->GetCustomOptions(); h_data.myLogInStandardOutput = !myAdvWidget->logInFileCheck->isChecked(); h_data.myRemoveLogOnSuccess = myAdvWidget->removeLogOnSuccessCheck->isChecked(); + if ( isOptimization() ) + h_data.myToCreateNewNodes = myCreateNewNodesCheck->isChecked(); + else + h_data.myToCreateNewNodes = myAdvWidget->createNewNodesCheck->isChecked(); // Enforced vertices h_data.myEnforcedVertices.clear(); QVariant valueX, valueY, valueZ; - for (int row=0 ; rowrowCount() ; row++) { - + for (int row=0 ; rowrowCount() ; row++) + { TEnfVertex *myVertex = new TEnfVertex(); myVertex->name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString(); - MESSAGE("Add new enforced vertex \"" << myVertex->name << "\"" ); myVertex->geomEntry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString(); - if (myVertex->geomEntry.size()) - MESSAGE("Geom entry is \"" << myVertex->geomEntry << "\"" ); myVertex->groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString(); - if (myVertex->groupName.size()) - MESSAGE("Group name is \"" << myVertex->groupName << "\"" ); valueX = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data(Qt::EditRole); valueY = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data(Qt::EditRole); valueZ = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data(Qt::EditRole); @@ -1869,34 +1804,24 @@ bool GHS3DPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DHypothesisDat myVertex->coords.push_back(valueX.toDouble()); myVertex->coords.push_back(valueY.toDouble()); myVertex->coords.push_back(valueZ.toDouble()); - MESSAGE("Coords are (" << myVertex->coords.at(0) << ", " - << myVertex->coords.at(1) << ", " - << myVertex->coords.at(2) << ")"); } myVertex->size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data(Qt::EditRole).toDouble(); - MESSAGE("Size is " << myVertex->size); myVertex->isCompound = myEnforcedTableWidget->item(row,ENF_VER_COMPOUND_COLUMN)->data(Qt::CheckStateRole).toBool(); - MESSAGE("Is compound ? " << myVertex->isCompound); h_data.myEnforcedVertices.insert(myVertex); } // Enforced meshes h_data.myEnforcedMeshes.clear(); - for (int row=0 ; rowrowCount() ; row++) { - + for (int row=0 ; rowrowCount() ; row++) + { TEnfMesh *myEnfMesh = new TEnfMesh(); myEnfMesh->name = myEnforcedMeshTableWidget->item(row,ENF_MESH_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString(); - MESSAGE("Add new enforced mesh \"" << myEnfMesh->name << "\"" ); myEnfMesh->entry = myEnforcedMeshTableWidget->item(row,ENF_MESH_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString(); - MESSAGE("Entry is \"" << myEnfMesh->entry << "\"" ); myEnfMesh->groupName = myEnforcedMeshTableWidget->item(row,ENF_MESH_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString(); - MESSAGE("Group name is \"" << myEnfMesh->groupName << "\"" ); QComboBox* combo = qobject_cast(myEnforcedMeshTableWidget->cellWidget(row,ENF_MESH_CONSTRAINT_COLUMN)); myEnfMesh->elementType = combo->currentIndex(); - MESSAGE("Element type: " << myEnfMesh->elementType); h_data.myEnforcedMeshes.insert(myEnfMesh); - std::cout << "h_data.myEnforcedMeshes.size(): " << h_data.myEnforcedMeshes.size() << std::endl; } return true; @@ -1914,10 +1839,10 @@ QPixmap GHS3DPluginGUI_HypothesisCreator::icon() const QString GHS3DPluginGUI_HypothesisCreator::type() const { - return tr( "GHS3D_HYPOTHESIS" ); + return tr( isOptimization() ? "GHS3D_OPTIMIZATIOL_HYPOTHESIS" : "GHS3D_HYPOTHESIS" ); } QString GHS3DPluginGUI_HypothesisCreator::helpPage() const { - return "ghs3d_hypo_page.html"; + return isOptimization() ? "optimization_page.html" : "ghs3d_hypo_page.html"; } diff --git a/src/GUI/GHS3DPluginGUI_HypothesisCreator.h b/src/GUI/GHS3DPluginGUI_HypothesisCreator.h index 1c093ca..4d7ce75 100644 --- a/src/GUI/GHS3DPluginGUI_HypothesisCreator.h +++ b/src/GUI/GHS3DPluginGUI_HypothesisCreator.h @@ -57,11 +57,12 @@ class QTableWidget; class QTableWidgetItem; class QHeaderView; -class SMESHGUI_SpinBox; -class StdMeshersGUI_ObjectReferenceParamWdg; +class GHS3DPluginGUI_AdvWidget; class LightApp_SelectionMgr; +class SMESHGUI_SpinBox; class SUIT_SelectionFilter; -class GHS3DPluginGUI_AdvWidget; +class SalomeApp_IntSpinBox; +class StdMeshersGUI_ObjectReferenceParamWdg; class QTEnfVertex { @@ -151,6 +152,10 @@ typedef struct short myVerboseLevel; TEnfVertexList myEnforcedVertices; TEnfMeshList myEnforcedMeshes; + + int myOptimization, mySplitOverConstrained, myPThreadsMode, myNumberOfThreads; + bool mySmoothOffSlivers; + } GHS3DHypothesisData; /*! @@ -209,46 +214,48 @@ private: bool storeParamsToHypo( const GHS3DHypothesisData& ) const; GeomSelectionTools* getGeomSelectionTool(); GEOM::GEOM_Gen_var getGeomEngine(); + bool isOptimization() const; private: - QWidget* myStdGroup; - QLineEdit* myName; - QCheckBox* myToMeshHolesCheck; - QCheckBox* myToMakeGroupsOfDomains; - QComboBox* myOptimizationLevelCombo; + QWidget* myStdGroup; + QLineEdit* myName; + QCheckBox* myToMeshHolesCheck; + QCheckBox* myToMakeGroupsOfDomains; + QComboBox* myOptimizationLevelCombo; + + QComboBox* myOptimizationCombo; + QComboBox* mySplitOverConstrainedCombo; + QComboBox* myPThreadsModeCombo; + SalomeApp_IntSpinBox* myNumberOfThreadsSpin; + QCheckBox* mySmoothOffSliversCheck; + QCheckBox* myCreateNewNodesCheck; QWidget* myAdvGroup; GHS3DPluginGUI_AdvWidget* myAdvWidget; - QWidget* myEnfGroup; - QPixmap iconVertex, iconCompound; + QWidget* myEnfGroup; + QPixmap iconVertex, iconCompound; StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg; GEOM::GEOM_Object_var myEnfVertex; - QTableWidget* myEnforcedTableWidget; - SMESHGUI_SpinBox* myXCoord; - SMESHGUI_SpinBox* myYCoord; - SMESHGUI_SpinBox* myZCoord; - SMESHGUI_SpinBox* mySizeValue; - QLineEdit* myGroupName; -// QGroupBox* makeGroupsCheck; -// QCheckBox* myGlobalGroupName; - QPushButton* addVertexButton; - QPushButton* removeVertexButton; + QTableWidget* myEnforcedTableWidget; + SMESHGUI_SpinBox* myXCoord; + SMESHGUI_SpinBox* myYCoord; + SMESHGUI_SpinBox* myZCoord; + SMESHGUI_SpinBox* mySizeValue; + QLineEdit* myGroupName; + QPushButton* addVertexButton; + QPushButton* removeVertexButton; - QWidget* myEnfMeshGroup; + QWidget* myEnfMeshGroup; StdMeshersGUI_ObjectReferenceParamWdg *myEnfMeshWdg; -// SMESH::SMESH_IDSource_var myEnfMesh; - QComboBox* myEnfMeshConstraint; - QStringList myEnfMeshConstraintLabels; -// SMESH::mesh_array_var myEnfMeshArray; - QTableWidget* myEnforcedMeshTableWidget; - QLineEdit* myMeshGroupName; - QPushButton* addEnfMeshButton; - QPushButton* removeEnfMeshButton; + QComboBox* myEnfMeshConstraint; + QStringList myEnfMeshConstraintLabels; + QTableWidget* myEnforcedMeshTableWidget; + QLineEdit* myMeshGroupName; + QPushButton* addEnfMeshButton; + QPushButton* removeEnfMeshButton; GeomSelectionTools* GeomToolSelected; -// SVTK_Selector* mySelector; -// LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ }; class EnforcedVertexTableWidgetDelegate : public QItemDelegate diff --git a/src/GUI/GHS3DPlugin_images.ts b/src/GUI/GHS3DPlugin_images.ts index 58d83e2..4ea0d95 100644 --- a/src/GUI/GHS3DPlugin_images.ts +++ b/src/GUI/GHS3DPlugin_images.ts @@ -15,5 +15,9 @@ ICON_SMESH_TREE_HYPO_MG-Tetra Parameters mesh_tree_hypo_ghs3d.png + + ICON_SMESH_TREE_HYPO_MG-Tetra Optimization Parameters + mesh_tree_hypo_ghs3d.png + diff --git a/src/GUI/GHS3DPlugin_msg_en.ts b/src/GUI/GHS3DPlugin_msg_en.ts index bca2a59..b90dc6d 100644 --- a/src/GUI/GHS3DPlugin_msg_en.ts +++ b/src/GUI/GHS3DPlugin_msg_en.ts @@ -11,6 +11,10 @@ GHS3D_HYPOTHESIS MG-Tetra + + GHS3D_OPTIMIZATIOL_HYPOTHESIS + MG-Tetra Optimization + GHS3D_OPTIMIZATIOL_LEVEL Optimization level @@ -231,5 +235,49 @@ GHS3D_ENF_MESH_INFO <b>Warning</b>: Enforced meshes are currently only taken into account for meshes w/o associated geometry. + + MODE_SAFE + Safe + + + MODE_AGGRESSIVE + Aggressive + + + MODE_NONE + None + + + MODE_NO + No + + + MODE_YES + Yes + + + MODE_ONLY + Only + + + GHS3D_OPTIMIZATION + Optimization + + + GHS3D_SPLIT_OVERCONSTRAINED + Split overconstrained elements + + + GHS3D_PTHREADS_MODE + PThreads mode + + + GHS3D_NB_THREADS + Max number of threads + + + GHS3D_SMOOTH_OFF_SLIVERS + Smooth off sliver elements +