From: gdd Date: Tue, 23 Aug 2011 15:24:32 +0000 (+0000) Subject: Update PreCAD feature. X-Git-Tag: V6_4_0a1~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=834bde033dd69d22a4247e19fea51741e3613716;p=plugins%2Fblsurfplugin.git Update PreCAD feature. New methods were added to set the preCAD options: SetPreCADOptionValue GetPreCADOptionValue UnsetPreCADOption --- diff --git a/idl/BLSURFPlugin_Algorithm.idl b/idl/BLSURFPlugin_Algorithm.idl index e5e6281..43a2757 100644 --- a/idl/BLSURFPlugin_Algorithm.idl +++ b/idl/BLSURFPlugin_Algorithm.idl @@ -234,18 +234,22 @@ module BLSURFPlugin * for the topology processing. */ void SetPreCADEpsNano(in double epsNano); - boolean GetPreCADEpsNano(); + double GetPreCADEpsNano(); /*! * Sets advanced option value */ void SetOptionValue(in string optionName, in string optionValue) raises (SALOME::SALOME_Exception); + void SetPreCADOptionValue(in string optionName, + in string optionValue) raises (SALOME::SALOME_Exception); string GetOptionValue(in string optionName) raises (SALOME::SALOME_Exception); + string GetPreCADOptionValue(in string optionName) raises (SALOME::SALOME_Exception); /*! * Unsets advanced option */ void UnsetOption(in string optionName); + void UnsetPreCADOption(in string optionName); /*! * Return array of strings each of which is option name concatenated @@ -254,12 +258,14 @@ module BLSURFPlugin * Note: the method is mostly for interaction with GUI. */ string_array GetOptionValues(); + string_array GetPreCADOptionValues(); /*! * Set option values each in the form "option_name[:option_value]". * Note: the method is mostly for interaction with GUI. */ void SetOptionValues(in string_array options); + void SetPreCADOptionValues(in string_array options); /*! * SizeMap diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index ebae152..070ce9f 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -722,18 +722,17 @@ void BLSURFPlugin_BLSURF::SetParameters( const BLSURFPlugin_Hypothesis::TOptionValues & opts = hyp->GetOptionValues(); BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt; - std::string preCADOptName; - size_t preCADstr_found; for ( opIt = opts.begin(); opIt != opts.end(); ++opIt ) if ( !opIt->second.empty() ) { - preCADstr_found = opIt->first.find("PRECAD_"); - if (preCADstr_found !=std::string::npos && int(preCADstr_found) == 0 && _topology == BLSURFPlugin_Hypothesis::PreCAD) { - preCADOptName = opIt->first.substr(preCADstr_found+7); - MESSAGE("precad_set_param(): " << preCADOptName << " = " << opIt->second); - blsurf_set_param(bls, preCADOptName.c_str(), opIt->second.c_str()); - } - else { - MESSAGE("blsurf_set_param(): " << opIt->first << " = " << opIt->second); + MESSAGE("blsurf_set_param(): " << opIt->first << " = " << opIt->second); + blsurf_set_param(bls, opIt->first.c_str(), opIt->second.c_str()); + } + + const BLSURFPlugin_Hypothesis::TOptionValues & preCADopts = hyp->GetPreCADOptionValues(); + for ( opIt = preCADopts.begin(); opIt != preCADopts.end(); ++opIt ) + if ( !opIt->second.empty() ) { + if (_topology == BLSURFPlugin_Hypothesis::PreCAD) { + MESSAGE("precad_set_param(): " << opIt->first << " = " << opIt->second); blsurf_set_param(bls, opIt->first.c_str(), opIt->second.c_str()); } } diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index feb9401..3fb9382 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -95,10 +95,21 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_G }; const char* charOptionNames[] = { "export_format", "export_option", "import_option", "prefix", "" // mark of end }; + + // PreCAD advanced options + const char* preCADintOptionNames[] = { "closed_geometry", "debug", "manifold_geometry", "create_tag_on_collision","" // mark of end + }; + const char* preCADdoubleOptionNames[] = { "eps_nano_relative", "eps_sewing", "eps_sewing_relative", "periodic_tolerance", + "periodic_tolerance_relative", "periodic_split_tolerance", "periodic_split_tolerance_relative", "" // mark of end + }; int i = 0; while (intOptionNames[i][0]) _option2value[intOptionNames[i++]].clear(); + + i = 0; + while (preCADintOptionNames[i][0]) + _preCADoption2value[preCADintOptionNames[i++]].clear(); i = 0; while (doubleOptionNames[i][0]) { @@ -106,27 +117,17 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_G _option2value[doubleOptionNames[i++]].clear(); } i = 0; + while (preCADdoubleOptionNames[i][0]) { + _preCADdoubleOptions.insert(preCADdoubleOptionNames[i]); + _preCADoption2value[preCADdoubleOptionNames[i++]].clear(); + } + i = 0; while (charOptionNames[i][0]) { _charOptions.insert(charOptionNames[i]); _option2value[charOptionNames[i++]].clear(); } - - // PreCAD advanced options - const char* preCADintOptionNames[] = { "PRECAD_closed_geometry", "PRECAD_debug", "PRECAD_manifold_geometry", "PRECAD_create_tag_on_collision","" // mark of end - }; - const char* preCADdoubleOptionNames[] = { "PRECAD_eps_nano_relative", "PRECAD_eps_sewing", "PRECAD_eps_sewing_relative", "PRECAD_periodic_tolerance", - "PRECAD_periodic_tolerance_relative", "PRECAD_periodic_split_tolerance", "PRECAD_periodic_split_tolerance_relative", "" // mark of end - }; - i = 0; - while (preCADintOptionNames[i][0]) - _option2value[preCADintOptionNames[i++]].clear(); - i = 0; - while (preCADdoubleOptionNames[i][0]) { - _doubleOptions.insert(preCADdoubleOptionNames[i]); - _option2value[preCADdoubleOptionNames[i++]].clear(); - } _sizeMap.clear(); _attractors.clear(); @@ -375,6 +376,49 @@ void BLSURFPlugin_Hypothesis::SetOptionValue(const std::string& optionName, cons } } +//============================================================================= +void BLSURFPlugin_Hypothesis::SetPreCADOptionValue(const std::string& optionName, const std::string& optionValue) + throw (std::invalid_argument) { + TOptionValues::iterator op_val = _preCADoption2value.find(optionName); + if (op_val == _preCADoption2value.end()) { + std::string msg = "Unknown BLSURF option: '" + optionName + "'"; + throw std::invalid_argument(msg); + } + if (op_val->second != optionValue) { + const char* ptr = optionValue.c_str(); + // strip white spaces + while (ptr[0] == ' ') + ptr++; + int i = strlen(ptr); + while (i != 0 && ptr[i - 1] == ' ') + i--; + // check value type + bool typeOk = true; + std::string typeName; + if (i == 0) { + // empty string + } else if (_preCADdoubleOptions.find(optionName) != _preCADdoubleOptions.end()) { + // check if value is double + char * endPtr; + strtod(ptr, &endPtr); + typeOk = (ptr != endPtr); + typeName = "real"; + } else { + // check if value is int + char * endPtr; + strtol(ptr, &endPtr, 10); + typeOk = (ptr != endPtr); + typeName = "integer"; + } + if (!typeOk) { + std::string msg = "PreCAD advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName; + throw std::invalid_argument(msg); + } + op_val->second = optionValue; + NotifySubMeshesHypothesisModification(); + } +} + //============================================================================= std::string BLSURFPlugin_Hypothesis::GetOptionValue(const std::string& optionName) throw (std::invalid_argument) { TOptionValues::iterator op_val = _option2value.find(optionName); @@ -386,6 +430,17 @@ std::string BLSURFPlugin_Hypothesis::GetOptionValue(const std::string& optionNam return op_val->second; } +//============================================================================= +std::string BLSURFPlugin_Hypothesis::GetPreCADOptionValue(const std::string& optionName) throw (std::invalid_argument) { + TOptionValues::iterator op_val = _preCADoption2value.find(optionName); + if (op_val == _preCADoption2value.end()) { + std::string msg = "Unknown PRECAD option: <"; + msg += optionName + ">"; + throw std::invalid_argument(msg); + } + return op_val->second; +} + //============================================================================= void BLSURFPlugin_Hypothesis::ClearOption(const std::string& optionName) { TOptionValues::iterator op_val = _option2value.find(optionName); @@ -393,6 +448,13 @@ void BLSURFPlugin_Hypothesis::ClearOption(const std::string& optionName) { op_val->second.clear(); } +//============================================================================= +void BLSURFPlugin_Hypothesis::ClearPreCADOption(const std::string& optionName) { + TOptionValues::iterator op_val = _preCADoption2value.find(optionName); + if (op_val != _preCADoption2value.end()) + op_val->second.clear(); +} + //======================================================================= //function : SetSizeMapEntry //======================================================================= @@ -999,6 +1061,16 @@ std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) { } save << " " << "__OPTIONS_END__"; } + + op_val = _preCADoption2value.begin(); + if (op_val != _preCADoption2value.end()) { + save << " " << "__PRECAD_OPTIONS_BEGIN__"; + for (; op_val != _preCADoption2value.end(); ++op_val) { + if (!op_val->second.empty()) + save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end + } + save << " " << "__PRECAD_OPTIONS_END__"; + } TSizeMap::iterator it_sm = _sizeMap.begin(); if (it_sm != _sizeMap.end()) { @@ -1202,6 +1274,7 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) { std::string option_or_sm; bool hasOptions = false; + bool hasPreCADOptions = false; bool hasSizeMap = false; bool hasAttractor = false; bool hasNewAttractor = false; @@ -1211,6 +1284,8 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) { if (isOK) if (option_or_sm == "__OPTIONS_BEGIN__") hasOptions = true; + else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__") + hasPreCADOptions = true; else if (option_or_sm == "__SIZEMAP_BEGIN__") hasSizeMap = true; else if (option_or_sm == "__ATTRACTORS_BEGIN__") @@ -1250,7 +1325,9 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) { if (hasOptions) { isOK = (load >> option_or_sm); if (isOK) - if (option_or_sm == "__SIZEMAP_BEGIN__") + if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__") + hasPreCADOptions = true; + else if (option_or_sm == "__SIZEMAP_BEGIN__") hasSizeMap = true; else if (option_or_sm == "__ATTRACTORS_BEGIN__") hasAttractor = true; @@ -1260,6 +1337,45 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) { hasEnforcedVertex = true; } + while (isOK && hasPreCADOptions) { + isOK = (load >> optName); + if (isOK) { + if (optName == "__PRECAD_OPTIONS_END__") + break; + isOK = (load >> optValue); + } + if (isOK) { + std::string & value = _preCADoption2value[optName]; + value = optValue; + int len = value.size(); + // continue reading until "%#" encountered + while (value[len - 1] != '#' || value[len - 2] != '%') { + isOK = (load >> optValue); + if (isOK) { + value += " "; + value += optValue; + len = value.size(); + } else { + break; + } + } + value[len - 2] = '\0'; //cut off "%#" + } + } + + if (hasPreCADOptions) { + isOK = (load >> option_or_sm); + if (isOK) + if (option_or_sm == "__SIZEMAP_BEGIN__") + hasSizeMap = true; + else if (option_or_sm == "__ATTRACTORS_BEGIN__") + hasAttractor = true; + else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__") + hasNewAttractor = true; + else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__") + hasEnforcedVertex = true; + } + std::string smEntry, smValue; while (isOK && hasSizeMap) { isOK = (load >> smEntry); diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx index 9e47632..8ec9d37 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx @@ -314,9 +314,14 @@ public: void SetOptionValue(const std::string& optionName, const std::string& optionValue) throw (std::invalid_argument); + void SetPreCADOptionValue(const std::string& optionName, + const std::string& optionValue) throw (std::invalid_argument); std::string GetOptionValue(const std::string& optionName) throw (std::invalid_argument); + std::string GetPreCADOptionValue(const std::string& optionName) throw (std::invalid_argument); void ClearOption(const std::string& optionName); + void ClearPreCADOption(const std::string& optionName); const TOptionValues& GetOptionValues() const { return _option2value; } + const TOptionValues& GetPreCADOptionValues() const { return _preCADoption2value; } /*! * Sets the file for export resulting mesh in GMF format @@ -362,10 +367,10 @@ private: bool _preCADMergeEdges; bool _preCADRemoveNanoEdges; bool _preCADDiscardInput; - bool _preCADEpsNano; + double _preCADEpsNano; - TOptionValues _option2value; - TOptionNames _doubleOptions, _charOptions; + TOptionValues _option2value, _preCADoption2value; + TOptionNames _doubleOptions, _charOptions, _preCADdoubleOptions, _preCADcharOptions; TSizeMap _sizeMap; TSizeMap _attractors; TAttractorMap _classAttractors; diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx index 4555fca..7079c10 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx @@ -126,7 +126,7 @@ CORBA::Long BLSURFPlugin_Hypothesis_i::GetPhysicalMesh() { */ //============================================================================= void BLSURFPlugin_Hypothesis_i::SetPhySize(CORBA::Double theValue) { - MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhySize"); +// MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhySize"); ASSERT(myBaseImpl); this->GetImpl()->SetPhySize(theValue); SMESH::TPythonDump() << _this() << ".SetPhySize( " << theValue << " )"; @@ -140,7 +140,7 @@ void BLSURFPlugin_Hypothesis_i::SetPhySize(CORBA::Double theValue) { */ //============================================================================= CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhySize() { - MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhySize"); +// MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhySize"); ASSERT(myBaseImpl); return this->GetImpl()->GetPhySize(); } @@ -472,7 +472,7 @@ void BLSURFPlugin_Hypothesis_i::SetPreCADEpsNano(CORBA::Double theValue) { * Get length of nano edges */ //============================================================================= -CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetPreCADEpsNano() { +CORBA::Double BLSURFPlugin_Hypothesis_i::GetPreCADEpsNano() { // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPreCADEpsNano"); ASSERT(myBaseImpl); return this->GetImpl()->GetPreCADEpsNano(); @@ -504,6 +504,30 @@ void BLSURFPlugin_Hypothesis_i::SetOptionValue(const char* optionName, const cha //============================================================================= +void BLSURFPlugin_Hypothesis_i::SetPreCADOptionValue(const char* optionName, const char* optionValue) + throw (SALOME::SALOME_Exception) { + ASSERT(myBaseImpl); + bool valueChanged = false; + try { + valueChanged = (this->GetImpl()->GetPreCADOptionValue(optionName) != optionValue); + if (valueChanged) + this->GetImpl()->SetPreCADOptionValue(optionName, optionValue); + } catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = ex.what(); + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetPreCADOptionValue(name,value)"; + ExDescription.lineNumber = 0; + throw SALOME::SALOME_Exception(ExDescription); + } catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } + if (valueChanged) + SMESH::TPythonDump() << _this() << ".SetPreCADOptionValue( '" << optionName << "', '" << optionValue << "' )"; +} + +//============================================================================= + char* BLSURFPlugin_Hypothesis_i::GetOptionValue(const char* optionName) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); try { @@ -523,6 +547,25 @@ char* BLSURFPlugin_Hypothesis_i::GetOptionValue(const char* optionName) throw (S //============================================================================= +char* BLSURFPlugin_Hypothesis_i::GetPreCADOptionValue(const char* optionName) throw (SALOME::SALOME_Exception) { + ASSERT(myBaseImpl); + try { + return CORBA::string_dup(this->GetImpl()->GetPreCADOptionValue(optionName).c_str()); + } catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = ex.what(); + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetPreCADOptionValue(name)"; + ExDescription.lineNumber = 0; + throw SALOME::SALOME_Exception(ExDescription); + } catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } + return 0; +} + +//============================================================================= + void BLSURFPlugin_Hypothesis_i::UnsetOption(const char* optionName) { ASSERT(myBaseImpl); this->GetImpl()->ClearOption(optionName); @@ -531,6 +574,14 @@ void BLSURFPlugin_Hypothesis_i::UnsetOption(const char* optionName) { //============================================================================= +void BLSURFPlugin_Hypothesis_i::UnsetPreCADOption(const char* optionName) { + ASSERT(myBaseImpl); + this->GetImpl()->ClearPreCADOption(optionName); + SMESH::TPythonDump() << _this() << ".UnsetPreCADOption( '" << optionName << "' )"; +} + +//============================================================================= + BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues() { ASSERT(myBaseImpl); BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array(); @@ -552,6 +603,27 @@ BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues() { //============================================================================= +BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetPreCADOptionValues() { + ASSERT(myBaseImpl); + BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array(); + + const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetPreCADOptionValues(); + result->length(opts.size()); + + ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin(); + for (int i = 0; opIt != opts.end(); ++opIt, ++i) { + string name_value = opIt->first; + if (!opIt->second.empty()) { + name_value += ":"; + name_value += opIt->second; + } + result[i] = CORBA::string_dup(name_value.c_str()); + } + return result._retn(); +} + +//============================================================================= + void BLSURFPlugin_Hypothesis_i::SetOptionValues(const BLSURFPlugin::string_array& options) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); @@ -572,6 +644,26 @@ void BLSURFPlugin_Hypothesis_i::SetOptionValues(const BLSURFPlugin::string_array //============================================================================= +void BLSURFPlugin_Hypothesis_i::SetPreCADOptionValues(const BLSURFPlugin::string_array& options) + throw (SALOME::SALOME_Exception) { + ASSERT(myBaseImpl); + for (int i = 0; i < options.length(); ++i) { + string name_value = options[i].in(); + int colonPos = name_value.find(':'); + string name, value; + if (colonPos == string::npos) // ':' not found + name = name_value; + else { + name = name_value.substr(0, colonPos); + if (colonPos < name_value.size() - 1 && name_value[colonPos] != ' ') + value = name_value.substr(colonPos + 1); + } + SetPreCADOptionValue(name.c_str(), value.c_str()); + } +} + +//============================================================================= + void BLSURFPlugin_Hypothesis_i::SetSizeMapEntry(const char* entry, const char* sizeMap) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); @@ -2083,7 +2175,7 @@ void BLSURFPlugin_Hypothesis_i::SetGMFFile(const char* theFileName) { //================================================================================ char* BLSURFPlugin_Hypothesis_i::GetGMFFile() { ASSERT(myBaseImpl); - MESSAGE("IDL : GetGMFFile()"); +// MESSAGE("IDL : GetGMFFile()"); return CORBA::string_dup(this->GetImpl()->GetGMFFile().c_str()); } diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx index 73e12d9..bd5c2e7 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx @@ -97,16 +97,21 @@ public: CORBA::Boolean GetPreCADDiscardInput(); void SetPreCADEpsNano(CORBA::Double theValue); - CORBA::Boolean GetPreCADEpsNano(); + CORBA::Double GetPreCADEpsNano(); void SetOptionValue(const char* optionName, const char* optionValue) throw (SALOME::SALOME_Exception); + void SetPreCADOptionValue(const char* optionName, const char* optionValue) throw (SALOME::SALOME_Exception); char* GetOptionValue(const char* optionName) throw (SALOME::SALOME_Exception); + char* GetPreCADOptionValue(const char* optionName) throw (SALOME::SALOME_Exception); void UnsetOption(const char* optionName); + void UnsetPreCADOption(const char* optionName); BLSURFPlugin::string_array* GetOptionValues(); + BLSURFPlugin::string_array* GetPreCADOptionValues(); void SetOptionValues(const BLSURFPlugin::string_array& options) throw (SALOME::SALOME_Exception); + void SetPreCADOptionValues(const BLSURFPlugin::string_array& options) throw (SALOME::SALOME_Exception); void SetSizeMapEntry(const char* entry, const char* sizeMap) throw (SALOME::SALOME_Exception); @@ -116,7 +121,7 @@ public: BLSURFPlugin::string_array* GetSizeMapEntries(); - void SetSizeMapEntries(const BLSURFPlugin::string_array& options) throw (SALOME::SALOME_Exception); + void SetSizeMapEntries(const BLSURFPlugin::string_array& sizeMaps) throw (SALOME::SALOME_Exception); void SetSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap); diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index 4f112e8..69c8077 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -109,6 +109,7 @@ enum { SMP_TAB, ENF_TAB, OPTION_ID_COLUMN = 0, + OPTION_TYPE_COLUMN, OPTION_NAME_COLUMN, OPTION_VALUE_COLUMN, NB_COLUMNS, @@ -568,7 +569,11 @@ bool BLSURFPluginGUI_HypothesisCreator::checkParams() const QString value = myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed(); if ( !value.isEmpty() ) { try { - h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() ); + QString optionType = myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().trimmed(); + if (optionType == "PRECAD") + h->SetPreCADOptionValue( name.toLatin1().constData(), value.toLatin1().constData() ); + else if (optionType == "BLSURF") + h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() ); } catch ( const SALOME::SALOME_Exception& ex ) { @@ -580,6 +585,7 @@ bool BLSURFPluginGUI_HypothesisCreator::checkParams() const } } h->SetOptionValues( myOptions ); // restore values + h->SetPreCADOptionValues( myPreCADOptions ); // restore values } // SizeMap and attractors @@ -759,9 +765,10 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() myOptionTable = new QTableWidget( 0, NB_COLUMNS, myAdvGroup ); QStringList headers; - headers << tr( "OPTION_ID_COLUMN" ) << tr( "OPTION_NAME_COLUMN" ) << tr( "OPTION_VALUE_COLUMN" ); + headers << tr( "OPTION_ID_COLUMN" )<< tr( "OPTION_TYPE_COLUMN" ) << tr( "OPTION_NAME_COLUMN" ) << tr( "OPTION_VALUE_COLUMN" ); myOptionTable->setHorizontalHeaderLabels( headers ); myOptionTable->horizontalHeader()->hideSection( OPTION_ID_COLUMN ); +// myOptionTable->horizontalHeader()->hideSection( OPTION_TYPE_COLUMN ); myOptionTable->horizontalHeader()->setStretchLastSection(true); myOptionTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); //myOptionTable->setColumnReadOnly( OPTION_NAME_COLUMN, TRUE );////// @@ -1061,11 +1068,11 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() connect( addMapButton, SIGNAL( clicked()), this, SLOT( onAddMap() ) ); connect( removeMapButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) ); connect( modifyMapButton, SIGNAL( clicked()), this, SLOT( onModifyMap() ) ); - connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) ); +// connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) ); connect( mySizeMapTable, SIGNAL( itemClicked (QTreeWidgetItem *, int)),this, SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) ); connect( myGeomSelWdg2, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) ); connect( myGeomSelWdg1, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) ); - connect( myAttractorGroup, SIGNAL( clicked(bool) ), this, SLOT( onAttractorGroupClicked(bool) ) ); +// connect( myAttractorGroup, SIGNAL( clicked(bool) ), this, SLOT( onAttractorGroupClicked(bool) ) ); connect( mySizeMapTable, SIGNAL( itemChanged (QTreeWidgetItem *, int)),this, SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) ); connect( myAttractorCheck, SIGNAL( stateChanged ( int )), this, SLOT( onAttractorClicked( int ) ) ); connect( myConstSizeCheck, SIGNAL( stateChanged ( int )), this, SLOT( onConstSizeClicked( int ) ) ); @@ -1074,7 +1081,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() // Enforced vertices connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) ); connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) ); - connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( update(QTreeWidgetItem *, int) ) ); +// connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( update(QTreeWidgetItem *, int) ) ); connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) ); connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) ); connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) ); @@ -1525,6 +1532,30 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const myOptionTable->setRowCount( row+1 ); myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) ); myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 ); + myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( "BLSURF" ) ); + myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 ); + myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) ); + myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 ); + myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) ); + myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable | + Qt::ItemIsEditable | + Qt::ItemIsEnabled ); + } + } + } + if ( myPreCADOptions.operator->() ) { +// MESSAGE("retrieveParams():myPreCADOptions->length() = " << myPreCADOptions->length()); + for ( int i = 0, nb = myPreCADOptions->length(); i < nb; ++i ) { + QString option = that->myPreCADOptions[i].in(); + QStringList name_value = option.split( ":", QString::KeepEmptyParts ); + if ( name_value.count() > 1 ) { + QString idStr = QString("%1").arg( i ); + int row = myOptionTable->rowCount(); + myOptionTable->setRowCount( row+1 ); + myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) ); + myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 ); + myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( "PRECAD" ) ); + myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 ); myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) ); myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 ); myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) ); @@ -1680,6 +1711,7 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; that->myOptions = h->GetOptionValues(); + that->myPreCADOptions = h->GetPreCADOptionValues(); h_data.myGMFFileName = h->GetGMFFile(); // h_data.myGMFFileMode = h->GetGMFFileMode(); @@ -1873,6 +1905,7 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi #endif h->SetOptionValues( myOptions ); // is set in checkParams() + h->SetPreCADOptionValues( myPreCADOptions ); // is set in checkParams() if ( h->GetGMFFile() != h_data.myGMFFileName ) // || ( h->GetGMFFileMode() != h_data.myGMFFileMode ) ) @@ -2025,15 +2058,23 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes for ( ; row < nbRows; ++row ) { int id = myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt(); - if ( id >= 0 && id < myOptions->length() ) + std::string optionType = myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().toStdString(); + if ( id >= 0 && ( ( optionType == "BLSURF" && id < myOptions->length() ) || ( optionType == "PRECAD" && id < myPreCADOptions->length() ) ) ) { QString name = myOptionTable->item( row, OPTION_NAME_COLUMN )->text(); QString value = myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed(); if ( value.isNull() ) value = ""; - that->myOptions[ id ] = ( name + ":" + value).toLatin1().constData(); - if ( value != "" ) + if (optionType == "PRECAD") + that->myPreCADOptions[ id ] = ( name + ":" + value).toLatin1().constData(); + else + that->myOptions[ id ] = ( name + ":" + value).toLatin1().constData(); + + if ( value != "" ) { + if (optionType == "PRECAD") + guiHyp += "PRECAD_"; guiHyp += name + " = " + value + "; "; + } } } @@ -2165,11 +2206,21 @@ void BLSURFPluginGUI_HypothesisCreator::onAddOption() QMenu* menu = (QMenu*)sender(); // fill popup with option names menu->clear(); + QString name_value, name; if ( myOptions.operator->() ) { + QMenu* blsurfMenu = menu->addMenu(tr("OPTION_MENU_BLSURF")); for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) { - QString name_value = myOptions[i].in(); - QString name = name_value.split( ":", QString::KeepEmptyParts )[0]; - menu->addAction( name ); + name_value = myOptions[i].in(); + name = name_value.split( ":", QString::KeepEmptyParts )[0]; + blsurfMenu->addAction( name ); + } + } + if ( myPreCADOptions.operator->() ) { + QMenu* preCADmenu = menu->addMenu(tr("OPTION_MENU_PRECAD")); + for ( int i = 0, nb = myPreCADOptions->length(); i < nb; ++i ) { + name_value = myPreCADOptions[i].in(); + name = name_value.split( ":", QString::KeepEmptyParts )[0]; + preCADmenu->addAction( name ); } } } @@ -2181,19 +2232,30 @@ void BLSURFPluginGUI_HypothesisCreator::onOptionChosenInPopup( QAction* a ) int idx = menu->actions().indexOf( a ); QString idStr = QString("%1").arg( idx ); - QString option = myOptions[idx].in(); + QString option, optionType; + if (menu->title() == tr("OPTION_MENU_BLSURF")) { + option = myOptions[idx].in(); + optionType = "BLSURF"; + } + else if (menu->title() == tr("OPTION_MENU_PRECAD")) { + option = myPreCADOptions[idx].in(); + optionType = "PRECAD"; + } QString optionName = option.split( ":", QString::KeepEmptyParts )[0]; // look for a row with optionName int row = 0, nbRows = myOptionTable->rowCount(); for ( ; row < nbRows; ++row ) if ( myOptionTable->item( row, OPTION_ID_COLUMN )->text() == idStr ) - break; + if ( myOptionTable->item( row, OPTION_TYPE_COLUMN )->text() == optionType ) + break; // add a row if not found if ( row == nbRows ) { myOptionTable->setRowCount( row+1 ); myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) ); myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 ); + myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( optionType ) ); + myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 ); myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( optionName ) ); myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 ); myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( "" ) ); @@ -2220,8 +2282,12 @@ void BLSURFPluginGUI_HypothesisCreator::onDeleteOption() if ( !selectedRows.contains( row ) ) { selectedRows.append( row ); int id = myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt(); - if ( id >= 0 && id < myOptions->length() ) - myOptions[ id ] = myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData(); + std::string optionType = myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().toStdString(); + if ( id >= 0 ) + if (optionType == "BLSURF" && id < myOptions->length() ) + myOptions[ id ] = myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData(); + else if (optionType == "PRECAD" && id < myPreCADOptions->length() ) + myPreCADOptions[ id ] = myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData(); } } qSort( selectedRows ); diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h index a2d6267..445abae 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h @@ -125,7 +125,8 @@ typedef struct double myAngleMeshS, myAngleMeshC, myGradation; double myPhySize, myGeoMin, myGeoMax, myPhyMin,myPhyMax; bool myAllowQuadrangles, myDecimesh,mySmpsurface,mySmpedge,mySmppoint,myEnforcedVertex; - bool myPreCADMergeEdges, myPreCADRemoveNanoEdges, myPreCADDiscardInput, myPreCADEpsNano; + bool myPreCADMergeEdges, myPreCADRemoveNanoEdges, myPreCADDiscardInput; + double myPreCADEpsNano; // bool myGMFFileMode; std::string myGMFFileName; TEnfVertexList enfVertexList; @@ -316,7 +317,7 @@ private: GeomSelectionTools* GeomToolSelected; LightApp_SelectionMgr* aSel; - BLSURFPlugin::string_array_var myOptions; + BLSURFPlugin::string_array_var myOptions, myPreCADOptions; PyObject * main_mod; PyObject * main_dict; diff --git a/src/GUI/BLSURFPlugin_msg_en.ts b/src/GUI/BLSURFPlugin_msg_en.ts index 5984638..16d2ea2 100644 --- a/src/GUI/BLSURFPlugin_msg_en.ts +++ b/src/GUI/BLSURFPlugin_msg_en.ts @@ -111,6 +111,10 @@ OBLIGATORY_VALUE (Obligatory value) + + OPTION_TYPE_COLUMN + Type + OPTION_NAME_COLUMN Option @@ -119,6 +123,14 @@ OPTION_VALUE_COLUMN Value + + OPTION_MENU_BLSURF + BLSURF + + + OPTION_MENU_PRECAD + PreCAD + REMOVE_OPTION Clear option diff --git a/src/GUI/BLSURFPlugin_msg_fr.ts b/src/GUI/BLSURFPlugin_msg_fr.ts index 02358d1..2b58c98 100755 --- a/src/GUI/BLSURFPlugin_msg_fr.ts +++ b/src/GUI/BLSURFPlugin_msg_fr.ts @@ -111,6 +111,10 @@ OBLIGATORY_VALUE (Valeur obligatoire) + + OPTION_TYPE_COLUMN + Type + OPTION_NAME_COLUMN Option @@ -119,6 +123,14 @@ OPTION_VALUE_COLUMN Valeur + + OPTION_MENU_BLSURF + BLSURF + + + OPTION_MENU_PRECAD + PreCAD + REMOVE_OPTION Effacer l'option