From bda31fa0fe5fee5b3f84298d66a78fc1ae83142b Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 6 May 2008 14:40:22 +0000 Subject: [PATCH] This commit was generated by cvs2git to create tag 'V4_1_0rc1'. Sprout from BR_Dev_For_4_0 2007-11-08 13:12:45 UTC jfa 'Add missing include.' Cherrypick from V4_1_0_maintainance 2008-05-06 14:40:21 UTC eap 'PAL19680 Meshers: BLSURF, GHS3D and holed shapes': resources/mesh_hypo_ghs3d.png resources/mesh_tree_hypo_ghs3d.png src/GHS3DPlugin_Defs.hxx src/GHS3DPlugin_Hypothesis.cxx src/GHS3DPlugin_Hypothesis.hxx src/GHS3DPlugin_Hypothesis_i.cxx src/GHS3DPlugin_Hypothesis_i.hxx src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx src/GUI/GHS3DPluginGUI_HypothesisCreator.h src/GUI/GHS3DPlugin_images.po src/GUI/GHS3DPlugin_msg_en.po src/GUI/Makefile.am --- resources/mesh_hypo_ghs3d.png | Bin 0 -> 616 bytes resources/mesh_tree_hypo_ghs3d.png | Bin 0 -> 278 bytes src/GHS3DPlugin_Defs.hxx | 37 ++ src/GHS3DPlugin_Hypothesis.cxx | 616 +++++++++++++++++++ src/GHS3DPlugin_Hypothesis.hxx | 146 +++++ src/GHS3DPlugin_Hypothesis_i.cxx | 301 +++++++++ src/GHS3DPlugin_Hypothesis_i.hxx | 120 ++++ src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx | 446 ++++++++++++++ src/GUI/GHS3DPluginGUI_HypothesisCreator.h | 108 ++++ src/GUI/GHS3DPlugin_images.po | 47 ++ src/GUI/GHS3DPlugin_msg_en.po | 94 +++ src/GUI/Makefile.am | 63 ++ 12 files changed, 1978 insertions(+) create mode 100644 resources/mesh_hypo_ghs3d.png create mode 100644 resources/mesh_tree_hypo_ghs3d.png create mode 100644 src/GHS3DPlugin_Defs.hxx create mode 100644 src/GHS3DPlugin_Hypothesis.cxx create mode 100644 src/GHS3DPlugin_Hypothesis.hxx create mode 100644 src/GHS3DPlugin_Hypothesis_i.cxx create mode 100644 src/GHS3DPlugin_Hypothesis_i.hxx create mode 100644 src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx create mode 100644 src/GUI/GHS3DPluginGUI_HypothesisCreator.h create mode 100644 src/GUI/GHS3DPlugin_images.po create mode 100755 src/GUI/GHS3DPlugin_msg_en.po create mode 100644 src/GUI/Makefile.am diff --git a/resources/mesh_hypo_ghs3d.png b/resources/mesh_hypo_ghs3d.png new file mode 100644 index 0000000000000000000000000000000000000000..3fb67d507bc568b7a406c497e52e76a68b61262b GIT binary patch literal 616 zcmV-u0+;=XP)gk0*WI5 zYK&P=DhHv(ok~os#Qtm3x^86>yemH)59hsgylw%-5w$PvREIIfYF)Q-`fH7We5-B-}HkHZ%;m1IbZ_q{%pYlPG9F?n-(n>+z0&(EC&>c_wn@oZe_JbH65Rw zS9n*crw5Y(iX$o#pYX0S_t~=-@pm}yX>vn~;)vESZJs|7=D9u}E-L)$PGAMbK??wt za*0y8^e9MDc4CVqgi{EoO8^Rwc}@pa)+^iv9qxiIrfIC)J^UX_pJp>T<@kMCfK_W$ zb7gI-I<%g2zv*ZY>djVZ`}|7mE4psdQ$ z-6Y5-Q9-heuUp3sl~+H>~rToA)Pq!JRcbY~o};nfq4fXC4-u RA_a6VgQu&X%Q~loCIDO + +//======================================================================= +//function : GHS3DPlugin_Hypothesis +//======================================================================= + +GHS3DPlugin_Hypothesis::GHS3DPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen) + : SMESH_Hypothesis(hypId, studyId, gen) +{ + _name = "GHS3D_Parameters"; + _param_algo_dim = 3; + + myToMeshHoles = DefaultMeshHoles(); + myMaximumMemory = -1;//DefaultMaximumMemory(); + myInitialMemory = -1;//DefaultInitialMemory(); + myOptimizationLevel = DefaultOptimizationLevel(); + myWorkingDirectory = DefaultWorkingDirectory(); + myKeepFiles = DefaultKeepFiles(); + myVerboseLevel = DefaultVerboseLevel(); + myToCreateNewNodes = DefaultToCreateNewNodes(); + myToUseBoundaryRecoveryVersion = DefaultToUseBoundaryRecoveryVersion(); +} + +//======================================================================= +//function : SetToMeshHoles +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetToMeshHoles(bool toMesh) +{ + if ( myToMeshHoles != toMesh ) { + myToMeshHoles = toMesh; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetToMeshHoles +//======================================================================= + +bool GHS3DPlugin_Hypothesis::GetToMeshHoles(bool checkFreeOption) const +{ + if (checkFreeOption && !myTextOption.empty()) { + if ( myTextOption.find("-c 0")) + return true; + if ( myTextOption.find("-c 1")) + return false; + } + return myToMeshHoles; +} + +//======================================================================= +//function : SetMaximumMemory +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetMaximumMemory(short MB) +{ + if ( myMaximumMemory != MB ) { + myMaximumMemory = MB; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetMaximumMemory +// * automatic memory adjustment mode. Default is zero +//======================================================================= + +short GHS3DPlugin_Hypothesis::GetMaximumMemory() const +{ + return myMaximumMemory; +} + +//======================================================================= +//function : SetInitialMemory +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetInitialMemory(short MB) +{ + if ( myInitialMemory != MB ) { + myInitialMemory = MB; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetInitialMemory +//======================================================================= + +short GHS3DPlugin_Hypothesis::GetInitialMemory() const +{ + return myInitialMemory; +} + +//======================================================================= +//function : SetOptimizationLevel +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetOptimizationLevel(OptimizationLevel level) +{ + if ( myOptimizationLevel != level ) { + myOptimizationLevel = level; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetOptimizationLevel +//======================================================================= + +GHS3DPlugin_Hypothesis::OptimizationLevel GHS3DPlugin_Hypothesis::GetOptimizationLevel() const +{ + return (OptimizationLevel) myOptimizationLevel; +} + +//======================================================================= +//function : SetWorkingDirectory +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetWorkingDirectory(const string& path) +{ + if ( myWorkingDirectory != path ) { + myWorkingDirectory = path; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetWorkingDirectory +//======================================================================= + +string GHS3DPlugin_Hypothesis::GetWorkingDirectory() const +{ + return myWorkingDirectory; +} + +//======================================================================= +//function : SetKeepFiles +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetKeepFiles(bool toKeep) +{ + if ( myKeepFiles != toKeep ) { + myKeepFiles = toKeep; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetKeepFiles +//======================================================================= + +bool GHS3DPlugin_Hypothesis::GetKeepFiles() const +{ + return myKeepFiles; +} + +//======================================================================= +//function : SetVerboseLevel +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetVerboseLevel(short level) +{ + if ( myVerboseLevel != level ) { + myVerboseLevel = level; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetVerboseLevel +//======================================================================= + +short GHS3DPlugin_Hypothesis::GetVerboseLevel() const +{ + return myVerboseLevel; +} + +//======================================================================= +//function : SetToCreateNewNodes +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetToCreateNewNodes(bool toCreate) +{ + if ( myToCreateNewNodes != toCreate ) { + myToCreateNewNodes = toCreate; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetToCreateNewNodes +//======================================================================= + +bool GHS3DPlugin_Hypothesis::GetToCreateNewNodes() const +{ + return myToCreateNewNodes; +} + +//======================================================================= +//function : SetToUseBoundaryRecoveryVersion +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetToUseBoundaryRecoveryVersion(bool toUse) +{ + if ( myToUseBoundaryRecoveryVersion != toUse ) { + myToUseBoundaryRecoveryVersion = toUse; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetToUseBoundaryRecoveryVersion +//======================================================================= + +bool GHS3DPlugin_Hypothesis::GetToUseBoundaryRecoveryVersion() const +{ + return myToUseBoundaryRecoveryVersion; +} + +//======================================================================= +//function : SetTextOption +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetTextOption(const string& option) +{ + if ( myTextOption != option ) { + myTextOption = option; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetTextOption +//======================================================================= + +string GHS3DPlugin_Hypothesis::GetTextOption() const +{ + return myTextOption; +} + + +//======================================================================= +//function : DefaultMeshHoles +//======================================================================= + +bool GHS3DPlugin_Hypothesis::DefaultMeshHoles() +{ + return false; // PAL19680 +} + +//======================================================================= +//function : DefaultMaximumMemory +//======================================================================= + +#ifndef WIN32 +#include +#endif + +short GHS3DPlugin_Hypothesis::DefaultMaximumMemory() +{ +#ifndef WIN32 + struct sysinfo si; + int err = sysinfo( &si ); + if ( err == 0 ) { + int ramMB = si.totalram * si.mem_unit / 1024 / 1024; + return (short) ( 0.7 * ramMB ); + } +#endif + return -1; +} + +//======================================================================= +//function : DefaultInitialMemory +//======================================================================= + +short GHS3DPlugin_Hypothesis::DefaultInitialMemory() +{ + return DefaultMaximumMemory(); +} + +//======================================================================= +//function : DefaultOptimizationLevel +//======================================================================= + +short GHS3DPlugin_Hypothesis::DefaultOptimizationLevel() +{ + return Medium; +} + +//======================================================================= +//function : DefaultWorkingDirectory +//======================================================================= + +string GHS3DPlugin_Hypothesis::DefaultWorkingDirectory() +{ + TCollection_AsciiString aTmpDir; + + char *Tmp_dir = getenv("SALOME_TMP_DIR"); + if(Tmp_dir != NULL) { + aTmpDir = Tmp_dir; + } + else { +#ifdef WIN32 + aTmpDir = TCollection_AsciiString("C:\\"); +#else + aTmpDir = TCollection_AsciiString("/tmp/"); +#endif + } + return aTmpDir.ToCString(); +} + +//======================================================================= +//function : DefaultKeepFiles +//======================================================================= + +bool GHS3DPlugin_Hypothesis::DefaultKeepFiles() +{ + return false; +} + +//======================================================================= +//function : DefaultVerboseLevel +//======================================================================= + +short GHS3DPlugin_Hypothesis::DefaultVerboseLevel() +{ + return 10; +} + +//======================================================================= +//function : DefaultToCreateNewNodes +//======================================================================= + +bool GHS3DPlugin_Hypothesis::DefaultToCreateNewNodes() +{ + return true; +} + +//======================================================================= +//function : DefaultToUseBoundaryRecoveryVersion +//======================================================================= + +bool GHS3DPlugin_Hypothesis::DefaultToUseBoundaryRecoveryVersion() +{ + return false; +} + +//======================================================================= +//function : SaveTo +//======================================================================= + +ostream & GHS3DPlugin_Hypothesis::SaveTo(ostream & save) +{ + save << (int) myToMeshHoles << " "; + save << myMaximumMemory << " "; + save << myInitialMemory << " "; + save << myOptimizationLevel << " "; + save << myWorkingDirectory << " "; + save << (int)myKeepFiles << " "; + save << myVerboseLevel << " "; + save << (int)myToCreateNewNodes << " "; + save << (int)myToUseBoundaryRecoveryVersion << " "; + save << myTextOption << " "; + return save; +} + +//======================================================================= +//function : LoadFrom +//======================================================================= + +istream & GHS3DPlugin_Hypothesis::LoadFrom(istream & load) +{ + bool isOK = true; + int i; + + isOK = (load >> i); + if (isOK) + myToMeshHoles = i; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> i); + if (isOK) + myMaximumMemory = i; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> i); + if (isOK) + myInitialMemory = i; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> i); + if (isOK) + myOptimizationLevel = i; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> myWorkingDirectory); + if (isOK) { + if ( myWorkingDirectory == "0") { // myWorkingDirectory was empty + myKeepFiles = false; + myWorkingDirectory.clear(); + } + else if ( myWorkingDirectory == "1" ) { + myKeepFiles = true; + myWorkingDirectory.clear(); + } + } + else + load.clear(ios::badbit | load.rdstate()); + + if ( !myWorkingDirectory.empty() ) { + isOK = (load >> i); + if (isOK) + myKeepFiles = i; + else + load.clear(ios::badbit | load.rdstate()); + } + + isOK = (load >> i); + if (isOK) + myVerboseLevel = (short) i; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> i); + if (isOK) + myToCreateNewNodes = (bool) i; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> i); + if (isOK) + myToUseBoundaryRecoveryVersion = (bool) i; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> myTextOption); + while (isOK) { + string txt; + if (load >> txt) { + myTextOption += " "; + myTextOption += txt; + } + else + isOK = false; + } +// else +// load.clear(ios::badbit | load.rdstate()); + + return load; +} + +//======================================================================= +//function : SetParametersByMesh +//======================================================================= + +bool GHS3DPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* ,const TopoDS_Shape&) +{ + return false; +} + +//================================================================================ +/*! + * \brief Return command to run ghs3d mesher excluding file prefix (-f) + */ +//================================================================================ + +string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* hyp, + const bool hasShapeToMesh) +{ +#ifndef WIN32 + TCollection_AsciiString cmd( "ghs3d" ); +#else + TCollection_AsciiString cmd( "ghs3d.exe" ); +#endif + // check if any option is overridden by hyp->myTextOption + bool m = hyp ? ( hyp->myTextOption.find("-m") == string::npos ) : true; + bool M = hyp ? ( hyp->myTextOption.find("-M") == string::npos ) : true; + bool c = hyp ? ( hyp->myTextOption.find("-c") == string::npos ) : true; + bool o = hyp ? ( hyp->myTextOption.find("-o") == string::npos ) : true; + bool p0= hyp ? ( hyp->myTextOption.find("-p0")== string::npos ) : true; + bool C = hyp ? ( hyp->myTextOption.find("-C") == string::npos ) : true; + bool v = hyp ? ( hyp->myTextOption.find("-v") == string::npos ) : true; + + // if use boundary recovery version, few options are allowed + bool useBndRecovery = !C; + if ( !useBndRecovery && hyp ) + useBndRecovery = hyp->myToUseBoundaryRecoveryVersion; + + // ghs3d needs to know amount of memory it may use (MB). + // Default memory is defined at ghs3d installation but it may be not enough, + // so allow to use about all available memory + if ( m ) { + short aMaximumMemory = hyp ? hyp->myMaximumMemory : -1; + cmd += " -m "; + if ( aMaximumMemory < 0 ) + cmd += DefaultMaximumMemory(); + else + cmd += aMaximumMemory; + } + if ( M && !useBndRecovery ) { + short aInitialMemory = hyp ? hyp->myInitialMemory : -1; + cmd += " -M "; + if ( aInitialMemory > 0 ) + cmd += aInitialMemory; + else + cmd += "100"; + } + // component to mesh + // 0 , all components to be meshed + // 1 , only the main ( outermost ) component to be meshed + if ( c && !useBndRecovery ) { + // We always run GHS3D with "to mesh holes'==TRUE (see PAL19680) + if ( hasShapeToMesh ) + cmd += " -c 0"; + else { + bool aToMeshHoles = hyp ? hyp->myToMeshHoles : DefaultMeshHoles(); + if ( aToMeshHoles ) + cmd += " -c 0"; + else + cmd += " -c 1"; + } + } + + // optimization level + if ( o && hyp && !useBndRecovery ) { + if ( hyp->myOptimizationLevel >= 0 && hyp->myOptimizationLevel < 4 ) { + char* level[] = { "none" , "light" , "standard" , "strong" }; + cmd += " -o "; + cmd += level[ hyp->myOptimizationLevel ]; + } + } + + // to create internal nodes + if ( p0 && hyp && !hyp->myToCreateNewNodes ) { + cmd += " -p0"; + } + + // verbose mode + if ( v && hyp ) { + cmd += " -v "; + cmd += hyp->myVerboseLevel; + } + + // boundary recovery version + if ( useBndRecovery ) { + cmd += " -C"; + } + + // options as text + if ( hyp && !hyp->myTextOption.empty() ) { + cmd += " "; + cmd += (char*) hyp->myTextOption.c_str(); + } + + return cmd.ToCString(); +} + +//================================================================================ +/*! + * \brief Return a unique file name + */ +//================================================================================ + +string GHS3DPlugin_Hypothesis::GetFileName(const GHS3DPlugin_Hypothesis* hyp) +{ + string aTmpDir = hyp ? hyp->GetWorkingDirectory() : DefaultWorkingDirectory(); + const char lastChar = *aTmpDir.rbegin(); +#ifdef WIN32 + if(lastChar != '\\') aTmpDir+='\\'; +#else + if(lastChar != '/') aTmpDir+='/'; +#endif + + TCollection_AsciiString aGenericName = (char*)aTmpDir.c_str(); + aGenericName += "GHS3D_"; +#ifdef WIN32 + aGenericName += GetCurrentProcessId(); +#else + aGenericName += getpid(); +#endif + aGenericName += "_"; + aGenericName += Abs((Standard_Integer)(long) & aGenericName); + + return aGenericName.ToCString(); +} diff --git a/src/GHS3DPlugin_Hypothesis.hxx b/src/GHS3DPlugin_Hypothesis.hxx new file mode 100644 index 0000000..a50d11a --- /dev/null +++ b/src/GHS3DPlugin_Hypothesis.hxx @@ -0,0 +1,146 @@ +// GHS3DPlugin : C++ implementation +// +// Copyright (C) 2006 OPEN CASCADE, 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. +// +// 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 + +// File : GHS3DPlugin_Hypothesis.hxx +// Created : Wed Apr 2 12:21:17 2008 +// Author : Edward AGAPOV (eap) + +#ifndef GHS3DPlugin_Hypothesis_HeaderFile +#define GHS3DPlugin_Hypothesis_HeaderFile + +#include "GHS3DPlugin_Defs.hxx" + +#include + +using namespace std; + +class GHS3DPLUGIN_EXPORT GHS3DPlugin_Hypothesis: public SMESH_Hypothesis +{ +public: + + GHS3DPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen); + + /*! + * To mesh "holes" in a solid or not. Default is to mesh. + */ + void SetToMeshHoles(bool toMesh); + bool GetToMeshHoles(bool checkFreeOption = false) const; + /*! + * Maximal size of memory to be used by the algorithm (in Megabytes) + */ + void SetMaximumMemory(short MB); + short GetMaximumMemory() const; + /*! + * Initial size of memory to be used by the algorithm (in Megabytes) in + * automatic memory adjustment mode. Default is zero + */ + void SetInitialMemory(short MB); + short GetInitialMemory() const; + /*! + * Optimization level: 0-none, 1-light, 2-medium, 3-strong. Default is medium + */ + enum OptimizationLevel { None = 0, Light, Medium, Strong }; + void SetOptimizationLevel(OptimizationLevel level); + OptimizationLevel GetOptimizationLevel() const; + /*! + * Path to working directory + */ + void SetWorkingDirectory(const string& path); + string GetWorkingDirectory() const; + /*! + * To keep working files or remove them. Log file remains in case of errors anyway. + */ + void SetKeepFiles(bool toKeep); + bool GetKeepFiles() const; + /*! + * Verbose level [0-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. + */ + void SetVerboseLevel(short level); + short GetVerboseLevel() const; + /*! + * To create new nodes + */ + void SetToCreateNewNodes(bool toCreate); + bool GetToCreateNewNodes() const; + /*! + * To use boundary recovery version which tries to create mesh on a very poor + * quality surface mesh + */ + void SetToUseBoundaryRecoveryVersion(bool toUse); + bool GetToUseBoundaryRecoveryVersion() const; + /*! + * To set hiden/undocumented/advanced options + */ + void SetTextOption(const string& option); + string GetTextOption() const; + + static bool DefaultMeshHoles(); + static short DefaultMaximumMemory(); + static short DefaultInitialMemory(); + static short DefaultOptimizationLevel(); + static string DefaultWorkingDirectory(); + static bool DefaultKeepFiles(); + static short DefaultVerboseLevel(); + static bool DefaultToCreateNewNodes(); + static bool DefaultToUseBoundaryRecoveryVersion(); + + /*! + * \brief Return command to run ghs3d mesher excluding file prefix (-f) + */ + static std::string CommandToRun(const GHS3DPlugin_Hypothesis* hyp, + const bool hasShapeToMesh=true); + /*! + * \brief Return a unique file name + */ + static std::string GetFileName(const GHS3DPlugin_Hypothesis* hyp); + + // Persistence + virtual ostream & SaveTo(ostream & save); + virtual istream & LoadFrom(istream & load); + friend GHS3DPLUGIN_EXPORT ostream & operator <<(ostream & save, GHS3DPlugin_Hypothesis & hyp); + friend GHS3DPLUGIN_EXPORT istream & operator >>(istream & load, GHS3DPlugin_Hypothesis & hyp); + + /*! + * \brief Does nothing + */ + virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + +private: + + bool myToMeshHoles; + short myMaximumMemory; + short myInitialMemory; + short myOptimizationLevel; + bool myKeepFiles; + string myWorkingDirectory; + short myVerboseLevel; + bool myToCreateNewNodes; + bool myToUseBoundaryRecoveryVersion; + string myTextOption; + +}; + + +#endif diff --git a/src/GHS3DPlugin_Hypothesis_i.cxx b/src/GHS3DPlugin_Hypothesis_i.cxx new file mode 100644 index 0000000..cbedd2d --- /dev/null +++ b/src/GHS3DPlugin_Hypothesis_i.cxx @@ -0,0 +1,301 @@ +// File : GHS3DPlugin_Hypothesis_i.cxx +// Created : Wed Apr 2 13:53:01 2008 +// Author : Edward AGAPOV (eap) + + +#include "GHS3DPlugin_Hypothesis_i.hxx" + +#include +#include + +#include +#include +#include + +//======================================================================= +//function : GHS3DPlugin_Hypothesis_i +//======================================================================= + +GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + MESSAGE( "GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i" ); + myBaseImpl = new ::GHS3DPlugin_Hypothesis (theGenImpl->GetANewId(), + theStudyId, + theGenImpl); +} + +//======================================================================= +//function : ~GHS3DPlugin_Hypothesis_i +//======================================================================= + +GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i() +{ + MESSAGE( "GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i" ); +} + +//======================================================================= +//function : SetToMeshHoles +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetToMeshHoles(CORBA::Boolean toMesh) +{ + ASSERT(myBaseImpl); + this->GetImpl()->SetToMeshHoles(toMesh); + SMESH::TPythonDump() << _this() << ".SetToMeshHoles( " << toMesh << " )"; +} + +//======================================================================= +//function : GetToMeshHoles +//======================================================================= + +CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMeshHoles() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetToMeshHoles(); +} + +//======================================================================= +//function : SetMaximumMemory +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Short MB) + throw ( SALOME::SALOME_Exception ) +{ + if ( MB == 0 ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM ); + ASSERT(myBaseImpl); + this->GetImpl()->SetMaximumMemory(MB); + SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )"; +} + +//======================================================================= +//function : GetMaximumMemory +//======================================================================= + +CORBA::Short GHS3DPlugin_Hypothesis_i::GetMaximumMemory() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetMaximumMemory(); +} + +//======================================================================= +//function : SetInitialMemory +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Short MB) + throw ( SALOME::SALOME_Exception ) +{ + if ( MB == 0 ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM ); + ASSERT(myBaseImpl); + this->GetImpl()->SetInitialMemory(MB); + SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )"; +} + +//======================================================================= +//function : GetInitialMemory +//======================================================================= + +CORBA::Short GHS3DPlugin_Hypothesis_i::GetInitialMemory() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetInitialMemory(); +} + +//======================================================================= +//function : SetOptimizationLevel +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level) + throw ( SALOME::SALOME_Exception ) +{ + ::GHS3DPlugin_Hypothesis::OptimizationLevel l = + (::GHS3DPlugin_Hypothesis::OptimizationLevel) level; + if ( l < ::GHS3DPlugin_Hypothesis::None || + l > ::GHS3DPlugin_Hypothesis::Strong ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM ); + + ASSERT(myBaseImpl); + this->GetImpl()->SetOptimizationLevel(l); + SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )"; +} + +//======================================================================= +//function : GetOptimizationLevel +//======================================================================= + +CORBA::Short GHS3DPlugin_Hypothesis_i::GetOptimizationLevel() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetOptimizationLevel(); +} + +//======================================================================= +//function : SetWorkingDirectory +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception ) +{ + if (!path ) + THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM ); + + string file(path); + const char lastChar = *file.rbegin(); +#ifdef WIN32 + if ( lastChar != '\\' ) file += '\\'; +#else + if ( lastChar != '/' ) file += '/'; +#endif + file += "GHS3D.log"; + SMESH_Mesh_i::PrepareForWriting (file.c_str()); + + ASSERT(myBaseImpl); + this->GetImpl()->SetWorkingDirectory(path); + SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )"; +} + +//======================================================================= +//function : GetWorkingDirectory +//======================================================================= + +char* GHS3DPlugin_Hypothesis_i::GetWorkingDirectory() +{ + ASSERT(myBaseImpl); + return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() ); +} + +//======================================================================= +//function : SetKeepFiles +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep) +{ + ASSERT(myBaseImpl); + this->GetImpl()->SetKeepFiles(toKeep); + SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )"; +} + +//======================================================================= +//function : GetKeepFiles +//======================================================================= + +CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetKeepFiles() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetKeepFiles(); +} + +//======================================================================= +//function : SetVerboseLevel +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level) + throw ( SALOME::SALOME_Exception ) +{ + if (level < 0 || level > 10 ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]", + SALOME::BAD_PARAM ); + ASSERT(myBaseImpl); + this->GetImpl()->SetVerboseLevel(level); + SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )"; +} + +//======================================================================= +//function : GetVerboseLevel +//======================================================================= + +CORBA::Short GHS3DPlugin_Hypothesis_i::GetVerboseLevel() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetVerboseLevel(); +} + +//======================================================================= +//function : SetToCreateNewNodes +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate) +{ + ASSERT(myBaseImpl); + this->GetImpl()->SetToCreateNewNodes(toCreate); + SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )"; +} + +//======================================================================= +//function : GetToCreateNewNodes +//======================================================================= + +CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToCreateNewNodes() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetToCreateNewNodes(); +} + +//======================================================================= +//function : SetToUseBoundaryRecoveryVersion +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse) +{ + ASSERT(myBaseImpl); + this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse); + SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )"; +} + +//======================================================================= +//function : GetToUseBoundaryRecoveryVersion +//======================================================================= + +CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetToUseBoundaryRecoveryVersion(); +} + +//======================================================================= +//function : SetTextOption +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option) +{ + ASSERT(myBaseImpl); + this->GetImpl()->SetTextOption(option); + SMESH::TPythonDump() << _this() << ".SetTextOption( '" << option << "' )"; +} + +//======================================================================= +//function : GetTextOption +//======================================================================= + +char* GHS3DPlugin_Hypothesis_i::GetTextOption() +{ + ASSERT(myBaseImpl); + return CORBA::string_dup( this->GetImpl()->GetTextOption().c_str() ); +} + +//============================================================================= +/*! + * Get implementation + */ +//============================================================================= + +::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl() +{ + return (::GHS3DPlugin_Hypothesis*)myBaseImpl; +} + +//================================================================================ +/*! + * \brief Verify whether hypothesis supports given entity type + */ +//================================================================================ + +CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type ) +{ + return type == SMESH::DIM_3D; +} + diff --git a/src/GHS3DPlugin_Hypothesis_i.hxx b/src/GHS3DPlugin_Hypothesis_i.hxx new file mode 100644 index 0000000..f86e4f4 --- /dev/null +++ b/src/GHS3DPlugin_Hypothesis_i.hxx @@ -0,0 +1,120 @@ +// GHS3DPlugin : C++ implementation +// +// Copyright (C) 2006 OPEN CASCADE, 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. +// +// 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_Hypothesis_i.hxx +// Date : 03/04/2006 +// Project : SALOME + +#ifndef _GHS3DPlugin_Hypothesis_i_HXX_ +#define _GHS3DPlugin_Hypothesis_i_HXX_ + +#include "GHS3DPlugin_Defs.hxx" + +#include +#include CORBA_SERVER_HEADER(GHS3DPlugin_Algorithm) + +#include "SMESH_Hypothesis_i.hxx" +#include "GHS3DPlugin_Hypothesis.hxx" + +class SMESH_Gen; + +// GHS3DPlugin parameters hypothesis + +class GHS3DPLUGIN_EXPORT GHS3DPlugin_Hypothesis_i: + public virtual POA_GHS3DPlugin::GHS3DPlugin_Hypothesis, + public virtual SMESH_Hypothesis_i +{ + public: + // Constructor + GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl); + // Destructor + virtual ~GHS3DPlugin_Hypothesis_i(); + + /*! + * To mesh "holes" in a solid or not. Default is to mesh. + */ + void SetToMeshHoles(CORBA::Boolean toMesh); + CORBA::Boolean GetToMeshHoles(); + /*! + * Maximal size of memory to be used by the algorithm (in Megabytes) + */ + void SetMaximumMemory(CORBA::Short MB) throw ( SALOME::SALOME_Exception ); + CORBA::Short GetMaximumMemory(); + /*! + * Initial size of memory to be used by the algorithm (in Megabytes) in + * automatic memory adjustment mode. Default is zero + */ + void SetInitialMemory(CORBA::Short MB) throw ( SALOME::SALOME_Exception ); + CORBA::Short GetInitialMemory(); + /*! + * Optimization level: 0-none, 1-light, 2-medium, 3-strong. Default is medium + */ + void SetOptimizationLevel(CORBA::Short level) throw ( SALOME::SALOME_Exception ); + CORBA::Short GetOptimizationLevel(); + /*! + * Path to working directory + */ + void SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception ); + char* GetWorkingDirectory(); + /*! + * To keep working files or remove them. Log file remains in case of errors anyway. + */ + void SetKeepFiles(CORBA::Boolean toKeep); + CORBA::Boolean GetKeepFiles(); + /*! + * Verbose level [0-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. + */ + void SetVerboseLevel(CORBA::Short level) throw ( SALOME::SALOME_Exception ); + CORBA::Short GetVerboseLevel(); + /*! + * To create new nodes + */ + void SetToCreateNewNodes(CORBA::Boolean toCreate); + CORBA::Boolean GetToCreateNewNodes(); + /*! + * To use boundary recovery version which tries to create mesh on a very poor + * quality surface mesh + */ + void SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse); + CORBA::Boolean GetToUseBoundaryRecoveryVersion(); + /*! + * To set hiden/undocumented/advanced options + */ + void SetTextOption(const char* option); + char* GetTextOption(); + + // Get implementation + ::GHS3DPlugin_Hypothesis* GetImpl(); + + // Verify whether hypothesis supports given entity type + CORBA::Boolean IsDimSupported( SMESH::Dimension type ); +}; + +#endif diff --git a/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx b/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx new file mode 100644 index 0000000..fde9f30 --- /dev/null +++ b/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx @@ -0,0 +1,446 @@ +// GHS3DPlugin GUI: GUI for plugged-in mesher GHS3DPlugin +// +// Copyright (C) 2003 CEA +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : GHS3DPluginGUI_HypothesisCreator.cxx +// Author : Michael Zorin +// Module : GHS3DPlugin +// $Header: + +#include "GHS3DPluginGUI_HypothesisCreator.h" + +#include +#include + +#include CORBA_SERVER_HEADER(GHS3DPlugin_Algorithm) + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include + +enum { + STD_TAB = 0, + ADV_TAB +}; + +namespace { + +#ifndef WIN32 +#include +#endif + + int maxAvailableMemory() + { +#ifndef WIN32 + struct sysinfo si; + int err = sysinfo( &si ); + if ( err == 0 ) { + int totMB = + si.totalram * si.mem_unit / 1024 / 1024 + + si.totalswap * si.mem_unit / 1024 / 1024 ; + return (int) ( 0.7 * totMB ); + } +#endif + return 100000; + } +} + +GHS3DPluginGUI_HypothesisCreator::GHS3DPluginGUI_HypothesisCreator( const QString& theHypType ) +: SMESHGUI_GenericHypothesisCreator( theHypType ) +{ +} + +GHS3DPluginGUI_HypothesisCreator::~GHS3DPluginGUI_HypothesisCreator() +{ +} + +QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() +{ + QFrame* fr = new QFrame( 0, "myframe" ); + QVBoxLayout* lay = new QVBoxLayout( fr, 5, 0 ); + + // tab + QTabBar* tab = new QTabBar( fr, "QTabBar"); + tab->setShape( QTabBar::RoundedAbove ); + tab->insertTab( new QTab( tr( "SMESH_ARGUMENTS")), STD_TAB); + tab->insertTab( new QTab( tr( "GHS3D_ADV_ARGS")), ADV_TAB); + lay->addWidget( tab ); + + // basic parameters + myStdGroup = new QGroupBox( 2, Qt::Horizontal, fr, "myStdGroup" ); + myStdGroup->layout()->setSpacing( 6 ); + myStdGroup->layout()->setMargin( 11 ); + lay->addWidget( myStdGroup ); + + myName = 0; + if( isCreation() ) + { + new QLabel( tr( "SMESH_NAME" ), myStdGroup ); + myName = new QLineEdit( myStdGroup ); + } + + myToMeshHolesCheck = new QCheckBox( tr( "GHS3D_TO_MESH_HOLES" ), myStdGroup ); + myStdGroup->addSpace(0); + + new QLabel( tr( "GHS3D_OPTIMIZATIOL_LEVEL" ), myStdGroup ); + myOptimizationLevelCombo = new QtxComboBox( myStdGroup ); + QStringList types; + types.append( QObject::tr( "LEVEL_NONE" ) ); + types.append( QObject::tr( "LEVEL_LIGHT" ) ); + types.append( QObject::tr( "LEVEL_MEDIUM" ) ); + types.append( QObject::tr( "LEVEL_STRONG" ) ); + myOptimizationLevelCombo->insertStringList( types ); + + // advanced parameters + myAdvGroup = new QGroupBox( 3, Qt::Horizontal, fr, "myAdvGroup" ); + lay->addWidget( myAdvGroup ); + QFrame* anAdvFrame = new QFrame(myAdvGroup, "anAdvFrame"); + QGridLayout* anAdvLayout = new QGridLayout(anAdvFrame, 8, 3); + anAdvLayout->setSpacing(6); + anAdvLayout->setAutoAdd(false); + + myMaximumMemoryCheck = new QCheckBox( tr("MAX_MEMORY_SIZE"), anAdvFrame ); + + myMaximumMemorySpin = new QSpinBox( anAdvFrame ); + myMaximumMemorySpin->setMinValue( 1 ); + myMaximumMemorySpin->setMaxValue( maxAvailableMemory() ); + myMaximumMemorySpin->setLineStep( 10 ); + QLabel* aMegabyteLabel = new QLabel( tr("MEGABYTE"), anAdvFrame); + + myInitialMemoryCheck = new QCheckBox( tr("INIT_MEMORY_SIZE"), anAdvFrame ); + + myInitialMemorySpin = new QSpinBox( anAdvFrame ); + myInitialMemorySpin->setMinValue( 1 ); + myInitialMemorySpin->setMaxValue( maxAvailableMemory() ); + myInitialMemorySpin->setLineStep( 10 ); + QLabel* aMegabyteLabel2 = new QLabel( tr("MEGABYTE"), anAdvFrame); + + QLabel* aWorkinDirLabel = new QLabel( tr( "WORKING_DIR" ), anAdvFrame ); + QPushButton* dirBtn = new QPushButton( tr( "SELECT_DIR"), anAdvFrame, "dirBtn"); + myWorkingDir = new QLineEdit( anAdvFrame, "myWorkingDir"); + myWorkingDir->setReadOnly( true ); + + myKeepFiles = new QCheckBox( tr( "KEEP_WORKING_FILES" ), anAdvFrame ); + + QLabel* aVerboseLevelLabel = new QLabel( tr("VERBOSE_LEVEL"), anAdvFrame); + myVerboseLevelSpin = new QSpinBox( anAdvFrame ); + myVerboseLevelSpin->setMinValue( 0 ); + myVerboseLevelSpin->setMaxValue( 10 ); + myVerboseLevelSpin->setLineStep( 1 ); + + myToCreateNewNodesCheck = new QCheckBox( tr( "TO_ADD_NODES" ), anAdvFrame ); + + myBoundaryRecoveryCheck = new QCheckBox( tr( "RECOVERY_VERSION" ), anAdvFrame ); + + QLabel* aTextOptionLabel = new QLabel( tr( "TEXT_OPTION" ), anAdvFrame ); + myTextOption = new QLineEdit( anAdvFrame, "myTextOption"); + + + anAdvLayout->addWidget(myMaximumMemoryCheck, 0, 0); + anAdvLayout->addWidget(myMaximumMemorySpin, 0, 1); + anAdvLayout->addWidget(aMegabyteLabel, 0, 2); + + anAdvLayout->addWidget(myInitialMemoryCheck, 1, 0); + anAdvLayout->addWidget(myInitialMemorySpin, 1, 1); + anAdvLayout->addWidget(aMegabyteLabel2, 1, 2); + + anAdvLayout->addWidget(aWorkinDirLabel, 2, 0); + anAdvLayout->addWidget(dirBtn, 2, 1); + anAdvLayout->addWidget(myWorkingDir, 2, 2); + + anAdvLayout->addWidget(myKeepFiles, 3, 0); + + anAdvLayout->addWidget(aVerboseLevelLabel, 4, 0); + anAdvLayout->addWidget(myVerboseLevelSpin, 4, 1); + + anAdvLayout->addWidget(myToCreateNewNodesCheck, 5, 0); + + anAdvLayout->addMultiCellWidget(myBoundaryRecoveryCheck, 6, 6, 0, 1); + + anAdvLayout->addWidget(aTextOptionLabel, 7, 0); + anAdvLayout->addMultiCellWidget(myTextOption,7, 7, 1, 2); + + + connect( tab, SIGNAL( selected(int) ), this, SLOT( onTabSelected(int) ) ); + connect( myMaximumMemoryCheck, SIGNAL( toggled(bool) ), this, SLOT( onCheckToggled(bool) )); + connect( myInitialMemoryCheck, SIGNAL( toggled(bool) ), this, SLOT( onCheckToggled(bool) )); + connect( myBoundaryRecoveryCheck,SIGNAL(toggled(bool)), this, SLOT( onCheckToggled(bool) )); + connect( dirBtn, SIGNAL( clicked() ), this, SLOT( onDirBtnClicked() ) ); + + return fr; +} + +void GHS3DPluginGUI_HypothesisCreator::onTabSelected(int tab) +{ + if ( tab == STD_TAB ) { + myAdvGroup->hide(); + myStdGroup->show(); + } + else { + myStdGroup->hide(); + myAdvGroup->show(); + } +// qApp->processEvents(); + dlg()->adjustSize(); +} + +void GHS3DPluginGUI_HypothesisCreator::onCheckToggled(bool on) +{ + const QObject * aSender = sender(); + if ( aSender == myMaximumMemoryCheck ) + myMaximumMemorySpin->setEnabled( on ); + + else if ( aSender == myInitialMemoryCheck ) + myInitialMemorySpin->setEnabled( on ); + + else if ( aSender == myBoundaryRecoveryCheck ) { + myOptimizationLevelCombo->setEnabled( !on ); + myInitialMemorySpin->setEnabled( myInitialMemoryCheck->isChecked() && !on ); + myInitialMemoryCheck->setEnabled( !on ); + myOptimizationLevelCombo->setEnabled( !on ); + } + +} + +void GHS3DPluginGUI_HypothesisCreator::onDirBtnClicked() +{ + QString dir = SUIT_FileDlg::getExistingDirectory(dlg(),QString::null, QString::null ); + if ( dir ) + myWorkingDir->setText( dir ); +} + + +bool GHS3DPluginGUI_HypothesisCreator::checkParams() const +{ + if ( !QFileInfo( myWorkingDir->text() ).isWritable() ) { + SUIT_MessageBox::warn1(dlg(), + QObject::tr("SMESH_WRN_WARNING"), + QObject::tr("GHS3D_PERMISSION_DENIED"), + QObject::tr("SMESH_BUT_OK")); + return false; + } + return true; +} + +void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const +{ + GHS3DHypothesisData data; + readParamsFromHypo( data ); + + if( myName ) + myName->setText( data.myName ); + + myToMeshHolesCheck ->setChecked ( data.myToMeshHoles ); + myOptimizationLevelCombo->setCurrentItem( data.myOptimizationLevel ); + myMaximumMemoryCheck ->setChecked ( data.myMaximumMemory > 0 ); + myMaximumMemorySpin ->setValue ( std::max( data.myMaximumMemory, + myMaximumMemorySpin->minValue() )); + myInitialMemoryCheck ->setChecked ( data.myInitialMemory > 0 ); + myInitialMemorySpin ->setValue ( std::max( data.myInitialMemory, + myInitialMemorySpin->minValue() )); + myWorkingDir ->setText ( data.myWorkingDir ); + myKeepFiles ->setChecked ( data.myKeepFiles ); + myVerboseLevelSpin ->setValue ( data.myVerboseLevel ); + myToCreateNewNodesCheck ->setChecked ( data.myToCreateNewNodes ); + myBoundaryRecoveryCheck ->setChecked ( data.myBoundaryRecovery ); + myTextOption ->setText ( data.myTextOption ); + + myOptimizationLevelCombo->setEnabled ( !data.myBoundaryRecovery ); + myMaximumMemorySpin ->setEnabled ( myMaximumMemoryCheck->isChecked() ); + myInitialMemorySpin ->setEnabled ( myInitialMemoryCheck->isChecked() && + !data.myBoundaryRecovery ); + myInitialMemoryCheck ->setEnabled (!data.myBoundaryRecovery ); + myOptimizationLevelCombo->setEnabled (!data.myBoundaryRecovery ); +} + +QString GHS3DPluginGUI_HypothesisCreator::storeParams() const +{ + GHS3DHypothesisData data; + readParamsFromWidgets( data ); + storeParamsToHypo( data ); + + QString valStr = ""; + + if ( !data.myBoundaryRecovery ) + valStr = "-c " + QString::number( !data.myToMeshHoles ); + + if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 4 && !data.myBoundaryRecovery) { + char* level[] = { "none" , "light" , "standard" , "strong" }; + valStr += " -o "; + valStr += level[ data.myOptimizationLevel ]; + } + if ( data.myMaximumMemory > 0 ) { + valStr += " -m "; + valStr += QString::number( data.myMaximumMemory ); + } + if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) { + valStr += " -M "; + valStr += QString::number( data.myInitialMemory ); + } + valStr += " -v "; + valStr += QString::number( data.myVerboseLevel ); + + if ( !data.myToCreateNewNodes ) + valStr += " -p0"; + + if ( data.myBoundaryRecovery ) + valStr += " -C"; + + valStr += " "; + valStr += data.myTextOption; + + return valStr; +} + +bool GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DHypothesisData& h_data ) const +{ + GHS3DPlugin::GHS3DPlugin_Hypothesis_var h = + GHS3DPlugin::GHS3DPlugin_Hypothesis::_narrow( initParamsHypothesis() ); + + HypothesisData* data = SMESH::GetHypothesisData( hypType() ); + h_data.myName = isCreation() && data ? hypName() : ""; + + h_data.myToMeshHoles = h->GetToMeshHoles(); + h_data.myMaximumMemory = h->GetMaximumMemory(); + h_data.myInitialMemory = h->GetInitialMemory(); + h_data.myInitialMemory = h->GetInitialMemory(); + h_data.myOptimizationLevel = h->GetOptimizationLevel(); + h_data.myKeepFiles = h->GetKeepFiles(); + h_data.myWorkingDir = h->GetWorkingDirectory(); + h_data.myVerboseLevel = h->GetVerboseLevel(); + h_data.myToCreateNewNodes = h->GetToCreateNewNodes(); + h_data.myBoundaryRecovery = h->GetToUseBoundaryRecoveryVersion(); + h_data.myTextOption = h->GetTextOption(); + + return true; +} + +bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisData& h_data ) const +{ + GHS3DPlugin::GHS3DPlugin_Hypothesis_var h = + GHS3DPlugin::GHS3DPlugin_Hypothesis::_narrow( hypothesis() ); + + bool ok = true; + try + { + if( isCreation() ) + SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.latin1() ); + + if ( h->GetToMeshHoles() != h_data.myToMeshHoles ) // avoid duplication of DumpPython commands + h->SetToMeshHoles ( h_data.myToMeshHoles ); + if ( h->GetMaximumMemory() != h_data.myMaximumMemory ) + h->SetMaximumMemory ( h_data.myMaximumMemory ); + if ( h->GetInitialMemory() != h_data.myInitialMemory ) + h->SetInitialMemory ( h_data.myInitialMemory ); + if ( h->GetInitialMemory() != h_data.myInitialMemory ) + h->SetInitialMemory ( h_data.myInitialMemory ); + if ( h->GetOptimizationLevel() != h_data.myOptimizationLevel ) + h->SetOptimizationLevel( h_data.myOptimizationLevel ); + if ( h->GetKeepFiles() != h_data.myKeepFiles ) + h->SetKeepFiles ( h_data.myKeepFiles ); + if ( h->GetWorkingDirectory() != h_data.myWorkingDir ) + h->SetWorkingDirectory ( h_data.myWorkingDir ); + if ( h->GetVerboseLevel() != h_data.myVerboseLevel ) + h->SetVerboseLevel ( h_data.myVerboseLevel ); + if ( h->GetToCreateNewNodes() != h_data.myToCreateNewNodes ) + h->SetToCreateNewNodes( h_data.myToCreateNewNodes ); + if ( h->GetToUseBoundaryRecoveryVersion() != h_data.myBoundaryRecovery ) + h->SetToUseBoundaryRecoveryVersion( h_data.myBoundaryRecovery ); + if ( h->GetTextOption() != h_data.myTextOption ) + h->SetTextOption ( h_data.myTextOption ); + } + catch(const SALOME::SALOME_Exception& ex) + { + SalomeApp_Tools::QtCatchCorbaException(ex); + ok = false; + } + return ok; +} + +bool GHS3DPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DHypothesisData& h_data ) const +{ + h_data.myName = myName ? myName->text() : ""; + h_data.myToMeshHoles = myToMeshHolesCheck->isChecked(); + h_data.myMaximumMemory = myMaximumMemoryCheck->isChecked() ? myMaximumMemorySpin->value() : -1; + h_data.myInitialMemory = myInitialMemoryCheck->isChecked() ? myInitialMemorySpin->value() : -1; + h_data.myOptimizationLevel = myOptimizationLevelCombo->currentItem(); + h_data.myKeepFiles = myKeepFiles->isChecked(); + h_data.myWorkingDir = myWorkingDir->text(); + h_data.myVerboseLevel = myVerboseLevelSpin->value(); + h_data.myToCreateNewNodes = myToCreateNewNodesCheck->isChecked(); + h_data.myBoundaryRecovery = myBoundaryRecoveryCheck->isChecked(); + h_data.myTextOption = myTextOption->text(); + + return true; +} + +QString GHS3DPluginGUI_HypothesisCreator::caption() const +{ + return tr( "GHS3D_TITLE" ); +} + +QPixmap GHS3DPluginGUI_HypothesisCreator::icon() const +{ + QString hypIconName = tr( QString("ICON_DLG_GHS3D_PARAMETERS" )); + return SUIT_Session::session()->resourceMgr()->loadPixmap( "GHS3DPlugin", hypIconName ); +} + +QString GHS3DPluginGUI_HypothesisCreator::type() const +{ + return tr( "GHS3D_HYPOTHESIS" ); +} + +QString GHS3DPluginGUI_HypothesisCreator::helpPage() const +{ + return "ghs3d_hypo_page.html"; +} + +//============================================================================= +/*! GetHypothesisCreator + * + */ +//============================================================================= +extern "C" +{ + GHS3DPLUGIN_EXPORT + SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator( const QString& aHypType ) + { + if( aHypType=="GHS3D_Parameters" ) + return new GHS3DPluginGUI_HypothesisCreator( aHypType ); + return 0; + } +} diff --git a/src/GUI/GHS3DPluginGUI_HypothesisCreator.h b/src/GUI/GHS3DPluginGUI_HypothesisCreator.h new file mode 100644 index 0000000..3ba32cd --- /dev/null +++ b/src/GUI/GHS3DPluginGUI_HypothesisCreator.h @@ -0,0 +1,108 @@ +// GHS3DPlugin GUI: GUI for plugged-in mesher GHS3DPlugin +// +// Copyright (C) 2003 CEA +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : GHS3DPluginGUI_HypothesisCreator.h +// Author : Michael Zorin +// Module : GHS3DPlugin + +#ifndef GHS3DPLUGINGUI_HypothesisCreator_HeaderFile +#define GHS3DPLUGINGUI_HypothesisCreator_HeaderFile + +#include "../GHS3DPlugin_Defs.hxx" +#include + +class QtxComboBox; +class QCheckBox; +class QLineEdit; +class QSpinBox; + +typedef struct +{ + bool myToMeshHoles; + int myMaximumMemory; + int myInitialMemory; + int myOptimizationLevel; + bool myKeepFiles; + QString myWorkingDir; + QString myName; + short myVerboseLevel; + bool myToCreateNewNodes; + bool myBoundaryRecovery; + QString myTextOption; + +} GHS3DHypothesisData; + +/*! + * \brief Class for creation of GHS3D2D and GHS3D3D hypotheses +*/ +class GHS3DPLUGIN_EXPORT GHS3DPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator +{ + Q_OBJECT + +public: + GHS3DPluginGUI_HypothesisCreator( const QString& ); + virtual ~GHS3DPluginGUI_HypothesisCreator(); + + virtual bool checkParams() const; + virtual QString helpPage() const; + +protected: + virtual QFrame* buildFrame (); + virtual void retrieveParams() const; + virtual QString storeParams () const; + + virtual QString caption() const; + virtual QPixmap icon() const; + virtual QString type() const; + +protected slots: + + void onTabSelected(int); + void onCheckToggled(bool); + void onDirBtnClicked(); + +private: + bool readParamsFromHypo( GHS3DHypothesisData& ) const; + bool readParamsFromWidgets( GHS3DHypothesisData& ) const; + bool storeParamsToHypo( const GHS3DHypothesisData& ) const; + +private: + + QGroupBox* myStdGroup; + QLineEdit* myName; + QCheckBox* myToMeshHolesCheck; + QtxComboBox* myOptimizationLevelCombo; + + QGroupBox* myAdvGroup; + QCheckBox* myMaximumMemoryCheck; + QSpinBox* myMaximumMemorySpin; + QCheckBox* myInitialMemoryCheck; + QSpinBox* myInitialMemorySpin; + QLineEdit* myWorkingDir; + QCheckBox* myKeepFiles; + QSpinBox* myVerboseLevelSpin; + QCheckBox* myToCreateNewNodesCheck; + QCheckBox* myBoundaryRecoveryCheck; + QLineEdit* myTextOption; +}; + +#endif diff --git a/src/GUI/GHS3DPlugin_images.po b/src/GUI/GHS3DPlugin_images.po new file mode 100644 index 0000000..6a78382 --- /dev/null +++ b/src/GUI/GHS3DPlugin_images.po @@ -0,0 +1,47 @@ +# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA 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. +# +# 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 +# +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2002-05-28 10:57:43 AM CEST\n" +"PO-Revision-Date: 2004-03-30 17:24+0400\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + + +#----------------------------------------------------------- +# ObjectBrowser +#----------------------------------------------------------- + +msgid "ICON_SMESH_TREE_ALGO_GHS3D_3D" +msgstr "mesh_tree_hypo_ghs3d.png" + +msgid "ICON_SMESH_TREE_HYPO_GHS3D_Parameters" +msgstr "mesh_tree_hypo_ghs3d.png" + +#----------------------------------------------------------- +# Hypothesis +#----------------------------------------------------------- + +msgid "ICON_DLG_GHS3D_PARAMETERS" +msgstr "mesh_hypo_ghs3d.png" + diff --git a/src/GUI/GHS3DPlugin_msg_en.po b/src/GUI/GHS3DPlugin_msg_en.po new file mode 100755 index 0000000..43209d0 --- /dev/null +++ b/src/GUI/GHS3DPlugin_msg_en.po @@ -0,0 +1,94 @@ +# Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS, L3S, LJLL, MENSI +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2002-05-28 10:46:48 AM CEST\n" +"PO-Revision-Date: YYYY-MM-DD\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + + +msgid "GHS3D_STD_ARGS" +msgstr "Parameters" + +msgid "GHS3D_ADV_ARGS" +msgstr "Advanced" + +msgid "GHS3D_TO_MESH_HOLES" +msgstr "To mesh holes" + +msgid "GHS3D_OPTIMIZATIOL_LEVEL" +msgstr "Optimization level" + +msgid "LEVEL_NONE" +msgstr "None" + +msgid "LEVEL_LIGHT" +msgstr "Light" + +msgid "LEVEL_MEDIUM" +msgstr "Medium (standard)" + +msgid "LEVEL_STRONG" +msgstr "Strong" + +msgid "MAX_MEMORY_SIZE" +msgstr "Maximum memory size" + +msgid "INIT_MEMORY_SIZE" +msgstr "Initial memory size" + +msgid "MEGABYTE" +msgstr "Megabytes" + +msgid "WORKING_DIR" +msgstr "Working directory" + +msgid "GHS3D_PERMISSION_DENIED" +msgstr "Working directory is not writable" + +msgid "SELECT_DIR" +msgstr "..." + +msgid "KEEP_WORKING_FILES" +msgstr "To keep working files" + +msgid "VERBOSE_LEVEL" +msgstr "Verbose level" + +msgid "TO_ADD_NODES" +msgstr "To create new nodes" + +msgid "RECOVERY_VERSION" +msgstr "To use boundary recovery version" + +msgid "TEXT_OPTION" +msgstr "Option as text" + + +msgid "GHS3D_HYPOTHESIS" +msgstr "GHS3D" + +msgid "GHS3D_TITLE" +msgstr "Hypothesis Construction" diff --git a/src/GUI/Makefile.am b/src/GUI/Makefile.am new file mode 100644 index 0000000..5928a7c --- /dev/null +++ b/src/GUI/Makefile.am @@ -0,0 +1,63 @@ +# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA 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. +# +# 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 +# +# -* Makefile *- +# +# Author : Edward AGAPOV (OCC) +# Modified by : Alexander BORODIN (OCN) - autotools usage +# Module : GHS3DPLUGIN +# Date : 10/01/2004 +# +# + +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +# header files +salomeinclude_HEADERS = + +# Libraries targets +lib_LTLIBRARIES = libGHS3DPluginGUI.la + +dist_libGHS3DPluginGUI_la_SOURCES = GHS3DPluginGUI_HypothesisCreator.cxx + +MOC_FILES = GHS3DPluginGUI_HypothesisCreator_moc.cxx +nodist_libGHS3DPluginGUI_la_SOURCES= $(MOC_FILES) + +libGHS3DPluginGUI_la_CPPFLAGS = \ + $(QT_INCLUDES) \ + $(KERNEL_CXXFLAGS) \ + $(GUI_CXXFLAGS) \ + $(GEOM_CXXFLAGS) \ + $(MED_CXXFLAGS) \ + $(SMESH_CXXFLAGS) \ + $(BOOST_CPPFLAGS) \ + $(CORBA_CXXFLAGS) \ + $(CORBA_INCLUDES) \ + $(CAS_CPPFLAGS) \ + -I$(top_builddir)/idl \ + -I$(top_builddir)/salome_adm/unix + +libGHS3DPluginGUI_la_LDFLAGS = \ + ../../idl/libSalomeIDLGHS3DPLUGIN.la \ + $(SMESH_LDFLAGS) -lSMESH \ + $(CAS_KERNEL) + +# resources files +nodist_salomeres_DATA= \ + GHS3DPlugin_images.qm \ + GHS3DPlugin_msg_en.qm -- 2.39.2