From: eap Date: Wed, 9 Oct 2019 12:47:42 +0000 (+0300) Subject: #17784 [EDF] MESH-GEMS-2.9.6 Meshers options X-Git-Tag: V9_4_0b1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c25f14e19b3cf37f766d869f56f5176594839da2;p=plugins%2Fhexoticplugin.git #17784 [EDF] MESH-GEMS-2.9.6 Meshers options --- diff --git a/doc/salome/gui/HexoticPLUGIN/images/hexotic_advanced_options.png b/doc/salome/gui/HexoticPLUGIN/images/hexotic_advanced_options.png index 79bd05b..e1f5a03 100644 Binary files a/doc/salome/gui/HexoticPLUGIN/images/hexotic_advanced_options.png and b/doc/salome/gui/HexoticPLUGIN/images/hexotic_advanced_options.png differ diff --git a/doc/salome/gui/HexoticPLUGIN/images/hexotic_parameters.png b/doc/salome/gui/HexoticPLUGIN/images/hexotic_parameters.png index 1bd2539..b6de4db 100644 Binary files a/doc/salome/gui/HexoticPLUGIN/images/hexotic_parameters.png and b/doc/salome/gui/HexoticPLUGIN/images/hexotic_parameters.png differ diff --git a/doc/salome/gui/HexoticPLUGIN/input/hexotic_hypo.doc b/doc/salome/gui/HexoticPLUGIN/input/hexotic_hypo.doc index ab29eb8..0901b1e 100644 --- a/doc/salome/gui/HexoticPLUGIN/input/hexotic_hypo.doc +++ b/doc/salome/gui/HexoticPLUGIN/input/hexotic_hypo.doc @@ -14,33 +14,30 @@ algorithm. This algorithm is a commercial software.
  • Name - allows to define the name of the hypothesis (MG-Hexa Parameters by default).
  • -
  • Min size - allows defining the minimal size of the elements (overrides Nb. Hexes Max Level value).
  • +
  • Physical size - defines size of elements +
  • -
  • Authorize invalid elements - specifies that the mesher must conform as much as possible to the geometry (especially the sharp edges). The resulting meshes may contain invalid elements (but with positive volumes: for example, three vertices of an hexahedron on the same edge), for the benefit of better geometry accuracy. -
  • - -
  • Sharp angle threshold in degrees - specifies the angle between two triangles above which the hex mesher will consider the edge common to these two triangles as being a "ridge". A ridge is a geometrical entity (a sharp edge) which has to be kept as it is in the final hex mesh.The default value is 60 (degrees).
    If you raise this value, the hex mesher will detect less ridges, and the final solid mesh will therefore be smoother. On the other hand, if you reduce this value, more ridges will be detected and the algorithm will face harder situations to conform to. -
  • - -
  • Number of threads - specifies the number of threads to be used (this should be the number of cores or processors of a shared memory parallel architecture). -
  • - -
  • Working directory - specifies the directory where the input/output files will be created. -
  • - -
  • Verbosity - specifies the verbose level to print information on meshing steps. -
  • - -
  • Max memory (MB) - specifies the maximum allocatable memory in MegaBytes. +
  • Geometric size - defines size of elements depending on curvature +
  • Sub-domains mesh mode - This option allows the user to mesh or not mesh internal subdomains (such as holes), or to mesh non-manifold domains. @@ -64,9 +61,78 @@ This allows to avoid the reconstruction of the GMF file from the SMESH structure In \b Advanced tab page you can specify advanced options of MG-Hexa not exposed in other pages. + Add option adds a line to the table where you can type an option and its value as text. A check box in the first column activates/deactivates the option of the current row. A deactivated option will be erased upon pressing \a Ok. + + \section hexotic_local_size_parameters Local size The local size allows you to drive locally the density of the 3D mesh. diff --git a/idl/HexoticPlugin_Algorithm.idl b/idl/HexoticPlugin_Algorithm.idl index 18eb819..443b51c 100644 --- a/idl/HexoticPlugin_Algorithm.idl +++ b/idl/HexoticPlugin_Algorithm.idl @@ -34,15 +34,17 @@ */ module HexoticPlugin { + typedef sequence string_array; + /*! * Type definitions for the size maps */ struct HexoticPluginSizeMap { - string entry; - double size; + string entry; + double size; }; - - typedef sequence HexoticPluginSizeMapsList; + + typedef sequence HexoticPluginSizeMapsList; /*! * HexoticPlugin_Hexotic: interface of Hexotic algorithm @@ -68,45 +70,84 @@ module HexoticPlugin void SetMaxSize(in double value); double GetMaxSize(); + void SetGeomApproxAngle(in double angle); + double GetGeomApproxAngle(); + void SetHexoticIgnoreRidges(in boolean value); boolean GetHexoticIgnoreRidges(); void SetHexoticInvalidElements(in boolean value); boolean GetHexoticInvalidElements(); - + void SetHexoticSharpAngleThreshold(in double value); double GetHexoticSharpAngleThreshold(); - + void SetHexoticNbProc(in long value); long GetHexoticNbProc(); void SetHexoticWorkingDirectory(in string path) raises (SALOME::SALOME_Exception); string GetHexoticWorkingDirectory(); - + void SetHexoticSdMode(in long value); long GetHexoticSdMode(); - + void SetHexoticVerbosity(in long value); long GetHexoticVerbosity(); void SetHexoticMaxMemory(in long value); long GetHexoticMaxMemory(); - - void SetAdvancedOption(in string option); + + void SetKeepFiles(in boolean toKeep); + boolean GetKeepFiles(); + + void SetStandardOutputLog(in boolean logInStandardOutput); + boolean GetStandardOutputLog(); + + void SetRemoveLogOnSuccess(in boolean removeLogOnSuccess); + boolean GetRemoveLogOnSuccess(); + + /*! + * Set advanced option value + */ + void SetOptionValue(in string optionName, + in string optionValue) raises (SALOME::SALOME_Exception); + string GetOptionValue(in string optionName) raises (SALOME::SALOME_Exception); + void UnsetOption(in string optionName); + /*! + * Adds custom advanced option and its value + */ + void SetAdvancedOption(in string optionsAndValues) // in a form "option_1 v1 option_2 v2'" + raises (SALOME::SALOME_Exception); string GetAdvancedOption(); + void AddOption(in string optionName, in string optionValue); + string GetOption(in string optionName); void SetTextOptions(in string option);// obsolete - string GetTextOptions(); - - void SetSizeMapEntry(in string entry, - in double size); + string GetTextOptions(); // obsolete + /*! + * Return array of strings each of which is option name concatenated + * with option value devided by semicolon - "option_name:option_value:option_type". + * Option value is empty if an option is not set. + * option_type: 1 if user-define, 0 if default + * Note: the method is mostly for interaction with GUI. + */ + string_array GetOptionValues(); + string_array GetAdvancedOptionValues(); + /*! + * Set option values each in the form "option_name[:option_value][:option_type]". + * Note: the method is mostly for interaction with GUI. + */ + void SetOptionValues(in string_array options) raises (SALOME::SALOME_Exception); + void SetAdvancedOptionValues(in string_array options); + + + void SetSizeMapEntry(in string entry, in double size); void UnsetSizeMapEntry(in string entry); - void SetSizeMap(in GEOM::GEOM_Object GeomObj, - in double size); + void SetSizeMap(in GEOM::GEOM_Object GeomObj, in double size); void UnsetSizeMap(in GEOM::GEOM_Object GeomObj); HexoticPluginSizeMapsList GetSizeMaps(); - + void SetNbLayers(in long theVal); long GetNbLayers(); diff --git a/src/GUI/CMakeLists.txt b/src/GUI/CMakeLists.txt index 210d64b..1ed0189 100644 --- a/src/GUI/CMakeLists.txt +++ b/src/GUI/CMakeLists.txt @@ -37,6 +37,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_BINARY_DIR}/idl ${PROJECT_SOURCE_DIR}/src/HexoticPlugin + ${PROJECT_SOURCE_DIR}/src/GUI ) # additional preprocessor / compiler flags @@ -67,6 +68,7 @@ SET(_link_LIBRARIES SET(_moc_HEADERS HexoticPluginGUI_HypothesisCreator.h HexoticPluginGUI_Dlg.h + HexoticPluginGUI_TreeWidget.h ) # header files / no moc processed @@ -85,9 +87,11 @@ QT_WRAP_MOC(_moc_SOURCES ${_moc_HEADERS}) SET(_other_SOURCES HexoticPluginGUI.cxx HexoticPluginGUI_StdWidget.cxx + HexoticPluginGUI_AdvWidget.cxx HexoticPluginGUI_SizeMapsWidget.cxx HexoticPluginGUI_ViscousLayersWidget.cxx HexoticPluginGUI_HypothesisCreator.cxx + HexoticPluginGUI_TreeWidget.cxx ) # --- resources --- @@ -103,6 +107,7 @@ SET(_ts_RESOURCES # resource files / to be processed by uic SET(_uic_files HexoticPluginGUI_StdWidget_QTD.ui + HexoticPluginGUI_AdvWidget_QTD.ui HexoticPluginGUI_SizeMapsWidget_QTD.ui HexoticPluginGUI_ViscousLayersWidget_QTD.ui ) diff --git a/src/GUI/HexoticPLUGIN_msg_en.ts b/src/GUI/HexoticPLUGIN_msg_en.ts index 2caa662..f794b90 100644 --- a/src/GUI/HexoticPLUGIN_msg_en.ts +++ b/src/GUI/HexoticPLUGIN_msg_en.ts @@ -17,7 +17,7 @@ Hexotic_INPUT_SIZE - Sizes + Physical size Hexotic_INPUT_LEVEL @@ -65,7 +65,7 @@ Hexotic_VERBOSITY - Verbosity + Verbose level Hexotic_MAX_MEMORY @@ -151,5 +151,85 @@ Hexotic_IMPRINTED_FACES Imprinted faces + + Hexotic_ADD_OPTION + Add option + + + Hexotic_GEOM_SIZE + Geometric size + + + Hexotic_PHY_SIZE_TYPE + Type + + + Hexotic_GEOM_SIZE_TYPE + Type + + + Hexotic_NONE + None + + + Hexotic_GLOBAL + Global + + + Hexotic_GEOM_APPROX_ANGLE + Mesh Angle + + + allow_invalid_elements + Allow invalid elements + + + element_order + Element order + + + enforce_constant_layer_size + Enforce constant layer size + + + compute_ridges + Compute ridges + + + flatten_hexa_sides + Flatten hexa sides + + + max_memory + Maximal memory + + + max_number_of_threads + Maximal number of threads + + + ridge_angle + Ridge angle (degrees) + + + min_level + Nb. Hexes Min Level + + + max_level + Nb. Hexes Max Level + + + recover_sharp_angles + Recover sharp angles + + + sizemap_level + Size map level + + + tags + Tags + diff --git a/src/GUI/HexoticPluginGUI_AdvWidget.cxx b/src/GUI/HexoticPluginGUI_AdvWidget.cxx new file mode 100644 index 0000000..8325e41 --- /dev/null +++ b/src/GUI/HexoticPluginGUI_AdvWidget.cxx @@ -0,0 +1,147 @@ +// Copyright (C) 2007-2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// --- +// File : HexoticPluginGUI_Dlg.cxx +// Authors : Renaud NEDELEC (OCC) +// --- +// + +#include "HexoticPluginGUI_Dlg.h" + +#include +#include + +#include +#include +#include + +namespace +{ + enum { EDITABLE_ROLE = Qt::UserRole + 1, PARAM_NAME, + NAME_COL = 0, VALUE_COL }; + + class ItemDelegate: public QItemDelegate { + public: + ItemDelegate(QObject* parent=0): QItemDelegate(parent) {} + QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &o, const QModelIndex &index) const + { + bool editable = index.data( EDITABLE_ROLE ).toInt(); + return editable ? QItemDelegate::createEditor( parent, o, index ) : 0; + } + }; +} + +////////////////////////////////////////// +// HexoticPluginGUI_AdvWidget +////////////////////////////////////////// + +HexoticPluginGUI_AdvWidget::HexoticPluginGUI_AdvWidget( QWidget* parent, Qt::WindowFlags f ) +: QWidget( parent, f ) +{ + setupUi( this ); + //myOptionTable->layout()->setMargin( 0 ); + myOptionTable->header()->setSectionResizeMode( QHeaderView::ResizeToContents ); + myOptionTable->setItemDelegate( new ItemDelegate( myOptionTable ) ); + + connect( myOptionTable, SIGNAL( itemChanged(QTreeWidgetItem *, int)), SLOT( itemChanged(QTreeWidgetItem *, int ))); +} + +HexoticPluginGUI_AdvWidget::~HexoticPluginGUI_AdvWidget() +{ +} + +void HexoticPluginGUI_AdvWidget::AddOption( const char* option, bool isCustom ) +{ + QTreeWidget * table = myOptionTable; + //table->setExpanded( true ); + + QTreeWidgetItem * row = new QTreeWidgetItem( table ); + row->setData( NAME_COL, EDITABLE_ROLE, int( isCustom && !option )); + row->setFlags( row->flags() | Qt::ItemIsEditable ); + + QString name, value; + bool isDefault = false; + if ( option ) + { + QStringList name_value_type = QString(option).split( ":", QString::KeepEmptyParts ); + if ( name_value_type.size() > 0 ) + name = name_value_type[0]; + if ( name_value_type.size() > 1 ) + value = name_value_type[1]; + if ( name_value_type.size() > 2 ) + isDefault = !name_value_type[2].toInt(); + + // if ( value == HexoticPlugin_Hypothesis::NoValue() ) + // value.clear(); + } + row->setText( 0, tr( name.toLatin1().constData() )); + row->setText( 1, tr( value.toLatin1().constData() )); + row->setCheckState( 0, isDefault ? Qt::Unchecked : Qt::Checked); + row->setData( NAME_COL, PARAM_NAME, name ); + + if ( isCustom ) + { + myOptionTable->scrollToItem( row ); + myOptionTable->setCurrentItem( row ); + myOptionTable->editItem( row, NAME_COL ); + } +} + +void HexoticPluginGUI_AdvWidget::GetOptionAndValue( QTreeWidgetItem * tblRow, + QString& option, + QString& value, + bool& isDefault) +{ + option = tblRow->data( NAME_COL, PARAM_NAME ).toString(); + value = tblRow->text( VALUE_COL ); + isDefault = ! tblRow->checkState( NAME_COL ); + + // if ( value.isEmpty() ) + // value = HexoticPlugin_Hypothesis::NoValue(); +} + + +void HexoticPluginGUI_AdvWidget::itemChanged(QTreeWidgetItem * tblRow, int column) +{ + if ( tblRow ) + { + myOptionTable->blockSignals( true ); + + tblRow->setData( VALUE_COL, EDITABLE_ROLE, int( tblRow->checkState( NAME_COL ))); + + int c = tblRow->checkState( NAME_COL ) ? 0 : 150; + tblRow->setForeground( VALUE_COL, QBrush( QColor( c, c, c ))); + + if ( column == NAME_COL && tblRow->data( NAME_COL, EDITABLE_ROLE ).toInt() ) // custom table + { + tblRow->setData( NAME_COL, PARAM_NAME, tblRow->text( NAME_COL )); + } + + myOptionTable->blockSignals( false ); + } +} + + +void HexoticPluginGUI_AdvWidget::onDirBtnClicked() +{ + QString dir = SUIT_FileDlg::getExistingDirectory( this, myHexoticWorkingDir->text(), QString() ); + if ( !dir.isEmpty() ) + myHexoticWorkingDir->setText( dir ); +} diff --git a/src/GUI/HexoticPluginGUI_AdvWidget_QTD.ui b/src/GUI/HexoticPluginGUI_AdvWidget_QTD.ui new file mode 100644 index 0000000..45847cf --- /dev/null +++ b/src/GUI/HexoticPluginGUI_AdvWidget_QTD.ui @@ -0,0 +1,166 @@ + + + HexoticPluginGUI_AdvWidget_QTD + + + + 0 + 0 + 344 + 355 + + + + Form + + + + + + + 0 + 2 + + + + QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed + + + true + + + + OPTION_NAME_COLUMN + + + + 50 + false + + + + + + OPTION_VALUE_COLUMN + + + + 50 + false + + + + + + + + + Qt::Horizontal + + + + 188 + 20 + + + + + + + + + 0 + 0 + + + + Logs and debug + + + + + + + + Hexotic_WORKING_DIR + + + + + + + + + + Hexotic_SELECT_DIR + + + + + + + Hexotic_VERBOSITY + + + + + + + + + + + + + + Print log in a file + + + true + + + + + + + Remove log file on success + + + true + + + + + + + + + Keep working files + + + false + + + + + + + + + + Hexotic_ADD_OPTION + + + + + + + + HexoticPluginGUI_TreeWidget + QTreeWidget +
    HexoticPluginGUI_TreeWidget.h
    +
    +
    + + +
    diff --git a/src/GUI/HexoticPluginGUI_Dlg.h b/src/GUI/HexoticPluginGUI_Dlg.h index a7735c7..286ce52 100644 --- a/src/GUI/HexoticPluginGUI_Dlg.h +++ b/src/GUI/HexoticPluginGUI_Dlg.h @@ -32,11 +32,20 @@ enum { SD_MODE_4 }; +enum { + OPTION_ID_COLUMN = 0, + OPTION_TYPE_COLUMN, + OPTION_NAME_COLUMN = 0, + OPTION_VALUE_COLUMN, + NB_COLUMNS, +}; + ////////////////////////////////////////// // HexoticPluginGUI_StdWidget ////////////////////////////////////////// #include "ui_HexoticPluginGUI_StdWidget_QTD.h" +#include "ui_HexoticPluginGUI_AdvWidget_QTD.h" #include "ui_HexoticPluginGUI_SizeMapsWidget_QTD.h" #include "ui_HexoticPluginGUI_ViscousLayersWidget_QTD.h" #include "HexoticPluginGUI.h" @@ -53,13 +62,32 @@ public: ~HexoticPluginGUI_StdWidget(); public slots: - void onDirBtnClicked(); void onSdModeSelected(int sdMode); + void onSizeTypeChange(int); public: QPixmap imageSdMode; }; +class HEXOTICPLUGIN_GUI_EXPORT HexoticPluginGUI_AdvWidget : public QWidget, + public Ui::HexoticPluginGUI_AdvWidget_QTD +{ + Q_OBJECT + +public: + HexoticPluginGUI_AdvWidget( QWidget* = 0, Qt::WindowFlags = 0 ); + ~HexoticPluginGUI_AdvWidget(); + + void AddOption( const char* name_value_type, bool isCustom = false ); + void GetOptionAndValue( QTreeWidgetItem * tblRow, QString& option, QString& value, bool& dflt ); + +public slots: + + void onDirBtnClicked(); + void itemChanged(QTreeWidgetItem * tblRow, int column); + +}; + class HEXOTICPLUGIN_GUI_EXPORT HexoticPluginGUI_SizeMapsWidget : public QWidget, public Ui::HexoticPluginGUI_SizeMapsWidget_QTD { diff --git a/src/GUI/HexoticPluginGUI_HypothesisCreator.cxx b/src/GUI/HexoticPluginGUI_HypothesisCreator.cxx index 2687eab..2e1340d 100644 --- a/src/GUI/HexoticPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/HexoticPluginGUI_HypothesisCreator.cxx @@ -32,8 +32,6 @@ #include "utilities.h" -#include CORBA_SERVER_HEADER(HexoticPlugin_Algorithm) - #include #include #include @@ -121,9 +119,9 @@ void SizeMapsTableWidgetDelegate::updateEditorGeometry(QWidget *editor, HexoticPluginGUI_HypothesisCreator::HexoticPluginGUI_HypothesisCreator( const QString& theHypType ) -: SMESHGUI_GenericHypothesisCreator( theHypType ), - myIs3D( true ), - mySizeMapsToRemove() + : SMESHGUI_GenericHypothesisCreator( theHypType ), + myIs3D( true ), + mySizeMapsToRemove() { } @@ -135,30 +133,68 @@ bool HexoticPluginGUI_HypothesisCreator::checkParams(QString& msg) const { msg.clear(); + HexoticPlugin::HexoticPlugin_Hypothesis_var h = + HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( hypothesis() ); + + myAdvWidget->myOptionTable->setFocus(); + QApplication::instance()->processEvents(); + + QString name, value; + bool isDefault, ok = true; + int iRow = 0, nbRows = myAdvWidget->myOptionTable->topLevelItemCount(); + for ( ; iRow < nbRows; ++iRow ) + { + QTreeWidgetItem* row = myAdvWidget->myOptionTable->topLevelItem( iRow ); + myAdvWidget->GetOptionAndValue( row, name, value, isDefault ); + + if ( name.simplified().isEmpty() ) + continue; // invalid custom option + + if ( isDefault ) // not selected option + value.clear(); + + try { + h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() ); + } + catch ( const SALOME::SALOME_Exception& ex ) + { + msg = ex.details.text.in(); + ok = false; + break; + } + } + + if ( !ok ) + { + h->SetOptionValues( myOptions ); // restore values + return false; + } + HexoticHypothesisData data_old, data_new; - readParamsFromHypo( data_old ); - + readParamsFromHypo( data_old ); // new values of advanced options ( myOptions ) are read + bool res = readParamsFromWidgets( data_new ); if ( !res ){ return res; } - res = storeParamsToHypo( data_new ); + + res = data_old.myMinSize <= data_old.myMaxSize; if ( !res ) { - storeParamsToHypo( data_old ); + msg = tr(QString("Min size (%1) is higher than max size (%2)").arg(data_old.myMinSize).arg(data_old.myMaxSize).toStdString().c_str()); return res; } - res = data_new.myMinSize <= data_new.myMaxSize; + res = data_old.myHexesMinLevel == 0 || \ + ( data_old.myHexesMinLevel != 0 && (data_old.myHexesMinLevel < data_old.myHexesMaxLevel) ); if ( !res ) { - msg = tr(QString("Min size (%1) is higher than max size (%2)").arg(data_new.myMinSize).arg(data_new.myMaxSize).toStdString().c_str()); + msg = tr(QString("Min hexes level (%1) is higher than max hexes level (%2)").arg(data_old.myHexesMinLevel).arg(data_old.myHexesMaxLevel).toStdString().c_str()); return res; } - res = data_new.myHexesMinLevel == 0 || \ - ( data_new.myHexesMinLevel != 0 && (data_new.myHexesMinLevel < data_new.myHexesMaxLevel) ); + res = storeParamsToHypo( data_new ); if ( !res ) { - msg = tr(QString("Min hexes level (%1) is higher than max hexes level (%2)").arg(data_new.myHexesMinLevel).arg(data_new.myHexesMaxLevel).toStdString().c_str()); + storeParamsToHypo( data_old ); return res; } @@ -171,7 +207,7 @@ QFrame* HexoticPluginGUI_HypothesisCreator::buildFrame() QVBoxLayout* lay = new QVBoxLayout( fr ); lay->setMargin( 0 ); lay->setSpacing( 6 ); - + // main TabWidget of the dialog QTabWidget* aTabWidget = new QTabWidget( fr ); aTabWidget->setTabShape( QTabWidget::Rounded ); @@ -183,7 +219,7 @@ QFrame* HexoticPluginGUI_HypothesisCreator::buildFrame() QGridLayout* l = new QGridLayout( aStdGroup ); l->setSpacing( 6 ); l->setMargin( 11 ); - + int row = 0; myName = 0; if( isCreation() ) { @@ -193,9 +229,6 @@ QFrame* HexoticPluginGUI_HypothesisCreator::buildFrame() myName->setMinimumWidth( 150 ); } - HexoticPlugin::HexoticPlugin_Hypothesis_var h = - HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( initParamsHypothesis() ); - myStdWidget = new HexoticPluginGUI_StdWidget(aStdGroup); #ifdef WIN32 myStdWidget->label_6->hide(); @@ -203,33 +236,32 @@ QFrame* HexoticPluginGUI_HypothesisCreator::buildFrame() #endif l->addWidget( myStdWidget, row++, 0, 1, 3 ); myStdWidget->onSdModeSelected(SD_MODE_4); + //myStdWidget->gridLayout->setRowStretch( 1, 2 ); + + // Advanced TAB + myAdvWidget = new HexoticPluginGUI_AdvWidget( aTabWidget ); + //myAdvWidget->gridLayout->setRowStretch( 0, 2 ); - myAdvWidget = new SMESH_AdvOptionsWdg( aTabWidget ); - // SIZE MAPS TAB - QWidget* aSmpGroup = new QWidget(); - lay->addWidget( aSmpGroup ); - - // Size map widget creation and initialisation - mySmpWidget = new HexoticPluginGUI_SizeMapsWidget(aSmpGroup); + mySmpWidget = new HexoticPluginGUI_SizeMapsWidget( aTabWidget ); mySmpWidget->doubleSpinBox->RangeStepAndValidator(0.0, COORD_MAX, 1.0, "length_precision"); mySmpWidget->doubleSpinBox->setValue(0.0); - + // Filters of selection - TColStd_MapOfInteger SM_ShapeTypes; + TColStd_MapOfInteger SM_ShapeTypes; SM_ShapeTypes.Add( TopAbs_VERTEX ); SM_ShapeTypes.Add( TopAbs_EDGE ); SM_ShapeTypes.Add( TopAbs_WIRE ); SM_ShapeTypes.Add( TopAbs_FACE ); SM_ShapeTypes.Add( TopAbs_SOLID ); - SM_ShapeTypes.Add( TopAbs_COMPOUND ); + SM_ShapeTypes.Add( TopAbs_COMPOUND ); SMESH_NumberFilter* aFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes); - + // Selection widget myGeomSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( aFilter, mySmpWidget, /*multiSel=*/false); myGeomSelWdg->SetDefaultText(tr("Hexotic_SEL_SHAPE"), "QLineEdit { color: grey }"); mySmpWidget->gridLayout->addWidget(myGeomSelWdg, 0, 1); - + // Configuration of the table widget QStringList headerLabels; headerLabels << tr("Hexotic_ENTRY")<< tr("Hexotic_NAME")<< tr("Hexotic_SIZE"); @@ -239,22 +271,16 @@ QFrame* HexoticPluginGUI_HypothesisCreator::buildFrame() mySmpWidget->label->setText(tr("LOCAL_SIZE")); mySmpWidget->pushButton_1->setText(tr("Hexotic_ADD")); mySmpWidget->pushButton_2->setText(tr("Hexotic_REMOVE")); - + // Setting a custom delegate for the size column SizeMapsTableWidgetDelegate* delegate = new SizeMapsTableWidgetDelegate(); mySmpWidget->tableWidget->setItemDelegateForColumn(SIZE_COL, delegate); - - // Add the size maps widget to a layout - QHBoxLayout* aSmpLayout = new QHBoxLayout( aSmpGroup ); - aSmpLayout->setMargin( 0 ); - aSmpLayout->addWidget( mySmpWidget); - + + // Viscous Layers tab - QWidget* aVLGroup = new QWidget(); - lay->addWidget( aVLGroup ); // Viscous layers widget creation and initialisation - myVLWidget = new HexoticPluginGUI_ViscousLayersWidget(aVLGroup); + myVLWidget = new HexoticPluginGUI_ViscousLayersWidget( aTabWidget ); QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry(); QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry(); @@ -266,27 +292,19 @@ QFrame* HexoticPluginGUI_HypothesisCreator::buildFrame() } else { - myVLWidget->labelFacesWithLayers->setVisible(false); + myVLWidget->labelFacesWithLayers->setVisible(false); myVLWidget->myFacesWithLayers->setVisible(false); myVLWidget->labelImprintedFaces->setVisible(false); myVLWidget->myImprintedFaces->setVisible(false); } - // Add the viscous layers widget to a layout - QHBoxLayout* aVLLayout = new QHBoxLayout( aVLGroup ); - aVLLayout->setSpacing( 6 ); - aVLLayout->setMargin( 11 ); - aVLLayout->addWidget( myVLWidget ); - -// resizeEvent(); - - aTabWidget->insertTab( STD_TAB, aStdGroup, tr( "SMESH_ARGUMENTS" )); + aTabWidget->insertTab( STD_TAB, aStdGroup, tr( "SMESH_ARGUMENTS" )); aTabWidget->insertTab( ADV_TAB, myAdvWidget, tr( "SMESH_ADVANCED" )); - aTabWidget->insertTab( SMP_TAB, aSmpGroup, tr( "LOCAL_SIZE" )); - aTabWidget->insertTab( VL_TAB, aVLGroup, tr( "Hexotic_VISCOUS_LAYERS")); - + aTabWidget->insertTab( SMP_TAB, mySmpWidget, tr( "LOCAL_SIZE" )); + aTabWidget->insertTab( VL_TAB, myVLWidget, tr( "Hexotic_VISCOUS_LAYERS")); + myIs3D = true; - + // Size Maps mySizeMapsToRemove.clear(); connect( mySmpWidget->pushButton_1, SIGNAL( clicked() ), this, SLOT( onAddLocalSize() ) ); @@ -299,16 +317,16 @@ void HexoticPluginGUI_HypothesisCreator::onAddLocalSize() { int rowCount = mySmpWidget->tableWidget->rowCount(); //int columnCount = mySmpWidget->tableWidget->columnCount(); - + // Get the selected object properties GEOM::GEOM_Object_var sizeMapObject = myGeomSelWdg->GetObject< GEOM::GEOM_Object >(0); if (sizeMapObject->_is_nil()) return; - + std::string entry, shapeName; entry = (std::string) sizeMapObject->GetStudyEntry(); shapeName = sizeMapObject->GetName(); - + // Check if the object is already in the widget QList listFound = mySmpWidget->tableWidget ->findItems( QString(entry.c_str()), Qt::MatchExactly ); @@ -413,6 +431,8 @@ void HexoticPluginGUI_HypothesisCreator::retrieveParams() const if( myName ) myName->setText( data.myName ); + myStdWidget->myPhySizeType->setCurrentIndex( data.myMinSize > 0 || data.myMaxSize > 0 ); + myStdWidget->myMinSize->setCleared(data.myMinSize == 0); if (data.myMinSize == 0) myStdWidget->myMinSize->setText(""); @@ -425,38 +445,35 @@ void HexoticPluginGUI_HypothesisCreator::retrieveParams() const else myStdWidget->myMaxSize->setValue( data.myMaxSize ); - myStdWidget->myHexesMinLevel->setCleared(data.myHexesMinLevel == 0); - if (data.myHexesMinLevel == 0) - myStdWidget->myHexesMinLevel->setText(""); - else - myStdWidget->myHexesMinLevel->setValue( data.myHexesMinLevel ); - - myStdWidget->myHexesMaxLevel->setCleared(data.myHexesMaxLevel == 0); - if (data.myHexesMaxLevel == 0) - myStdWidget->myHexesMaxLevel->setText(""); - else - myStdWidget->myHexesMaxLevel->setValue( data.myHexesMaxLevel ); + myStdWidget->myGeomSizeType->setCurrentIndex( data.myApproxAngle > 0 ); - myStdWidget->myHexoticIgnoreRidges->setChecked( data.myHexoticIgnoreRidges ); - myStdWidget->myHexoticInvalidElements->setChecked( data.myHexoticInvalidElements ); - - myStdWidget->myHexoticSharpAngleThreshold->setCleared(data.myHexoticSharpAngleThreshold == 0); - if (data.myHexoticSharpAngleThreshold == 0) - myStdWidget->myHexoticSharpAngleThreshold->setText(""); + myStdWidget->myGeomApproxAngle->setCleared( data.myApproxAngle == 0 ); + if (data.myApproxAngle == 0) + myStdWidget->myGeomApproxAngle->setText(""); else - myStdWidget->myHexoticSharpAngleThreshold->setValue( data.myHexoticSharpAngleThreshold ); -#ifndef WIN32 - myStdWidget->myHexoticNbProc->setValue( data.myHexoticNbProc ); -#endif - myStdWidget->myHexoticWorkingDir->setText( data.myHexoticWorkingDir ); + myStdWidget->myGeomApproxAngle->setValue( data.myApproxAngle ); - myStdWidget->myHexoticVerbosity->setValue( data.myHexoticVerbosity ); + myAdvWidget->myHexoticWorkingDir->setText( data.myHexoticWorkingDir ); - myStdWidget->myHexoticMaxMemory->setValue( data.myHexoticMaxMemory ); + myAdvWidget->myHexoticVerbosity->setValue( data.myHexoticVerbosity ); myStdWidget->myHexoticSdMode->setCurrentIndex(data.myHexoticSdMode); - - myAdvWidget->SetCustomOptions(data.myTextOptions); + + //myAdvWidget->SetCustomOptions(data.myTextOptions); + + if ( myOptions.operator->() ) { + for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) + myAdvWidget->AddOption( myOptions[i].in() ); + } + if ( myCustomOptions.operator->() ) { + for ( int i = 0, nb = myCustomOptions->length(); i < nb; ++i ) + myAdvWidget->AddOption( myCustomOptions[i].in() ); + } + myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN ); + + myAdvWidget->keepWorkingFilesCheck->setChecked( data.myKeepFiles ); + myAdvWidget->logInFileCheck->setChecked( !data.myLogInStandardOutput ); + myAdvWidget->removeLogOnSuccessCheck->setChecked( data.myRemoveLogOnSuccess ); HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it = data.mySizeMaps.begin(); for ( int row = 0; it != data.mySizeMaps.end(); it++, row++ ) @@ -502,13 +519,6 @@ void HexoticPluginGUI_HypothesisCreator::retrieveParams() const aVec[i]=vector.at(i); myVLWidget->myImprintedFaces->SetListOfIDs(aVec); - - std::cout << "myStdWidget->myMinSize->value(): " << myStdWidget->myMinSize->value() << std::endl; - std::cout << "myStdWidget->myMaxSize->value(): " << myStdWidget->myMaxSize->value() << std::endl; - std::cout << "myStdWidget->myHexesMinLevel->value(): " << myStdWidget->myHexesMinLevel->value() << std::endl; - std::cout << "myStdWidget->myHexesMaxLevel->value(): " << myStdWidget->myHexesMaxLevel->value() << std::endl; - std::cout << "myStdWidget->myHexoticSharpAngleThreshold->value(): " << myStdWidget->myHexoticSharpAngleThreshold->value() << std::endl; - } void HexoticPluginGUI_HypothesisCreator::printData( HexoticHypothesisData& data) const @@ -571,6 +581,7 @@ bool HexoticPluginGUI_HypothesisCreator::readParamsFromHypo( HexoticHypothesisDa h_data.myName = isCreation() && data ? data->Label : ""; h_data.myMinSize = h->GetMinSize(); h_data.myMaxSize = h->GetMaxSize(); + h_data.myApproxAngle = h->GetGeomApproxAngle(); h_data.myHexesMinLevel = h->GetHexesMinLevel(); h_data.myHexesMaxLevel = h->GetHexesMaxLevel(); h_data.myHexoticIgnoreRidges = h->GetHexoticIgnoreRidges(); @@ -581,11 +592,18 @@ bool HexoticPluginGUI_HypothesisCreator::readParamsFromHypo( HexoticHypothesisDa h_data.myHexoticVerbosity = h->GetHexoticVerbosity(); h_data.myHexoticMaxMemory = h->GetHexoticMaxMemory(); h_data.myHexoticSdMode = h->GetHexoticSdMode()-1; - h_data.myTextOptions = h->GetAdvancedOption(); - + h_data.myKeepFiles = h->GetKeepFiles(); + h_data.myLogInStandardOutput = h->GetStandardOutputLog(); + h_data.myRemoveLogOnSuccess = h->GetRemoveLogOnSuccess(); + //h_data.myTextOptions = h->GetAdvancedOption(); + + HexoticPluginGUI_HypothesisCreator* that = (HexoticPluginGUI_HypothesisCreator*)this; + that->myOptions = h->GetOptionValues(); + that->myCustomOptions = h->GetAdvancedOptionValues(); + // Size maps HexoticPlugin::HexoticPluginSizeMapsList_var sizeMaps = h->GetSizeMaps(); - for ( CORBA::ULong i = 0 ; i < sizeMaps->length() ; i++) + for ( CORBA::ULong i = 0 ; i < sizeMaps->length() ; i++) { HexoticPlugin::HexoticPluginSizeMap aSizeMap = sizeMaps[i]; std::string entry = CORBA::string_dup(aSizeMap.entry.in()); @@ -623,17 +641,13 @@ bool HexoticPluginGUI_HypothesisCreator::storeParamsToHypo( const HexoticHypothe h->SetMinSize( h_data.myMinSize ); h->SetMaxSize( h_data.myMaxSize ); - h->SetHexesMinLevel( h_data.myHexesMinLevel ); - h->SetHexesMaxLevel( h_data.myHexesMaxLevel ); - h->SetHexoticIgnoreRidges( h_data.myHexoticIgnoreRidges ); - h->SetHexoticInvalidElements( h_data.myHexoticInvalidElements ); - h->SetHexoticSharpAngleThreshold( h_data.myHexoticSharpAngleThreshold ); - h->SetHexoticNbProc( h_data.myHexoticNbProc ); + h->SetGeomApproxAngle( h_data.myApproxAngle ); h->SetHexoticWorkingDirectory( h_data.myHexoticWorkingDir.toLatin1().constData() ); h->SetHexoticVerbosity( h_data.myHexoticVerbosity ); - h->SetHexoticMaxMemory( h_data.myHexoticMaxMemory ); h->SetHexoticSdMode( h_data.myHexoticSdMode+1 ); - h->SetAdvancedOption( h_data.myTextOptions.toLatin1().constData() ); + h->SetKeepFiles( h_data.myKeepFiles ); + h->SetStandardOutputLog( h_data.myLogInStandardOutput ); + h->SetRemoveLogOnSuccess( h_data.myRemoveLogOnSuccess ); HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it; @@ -680,22 +694,16 @@ bool HexoticPluginGUI_HypothesisCreator::readParamsFromWidgets( HexoticHypothesi { h_data.myName = myName ? myName->text() : ""; - h_data.myHexoticIgnoreRidges = myStdWidget->myHexoticIgnoreRidges->isChecked(); - h_data.myHexoticInvalidElements = myStdWidget->myHexoticInvalidElements->isChecked(); -#ifndef WIN32 - h_data.myHexoticNbProc = myStdWidget->myHexoticNbProc->value(); -#endif - h_data.myHexoticWorkingDir = myStdWidget->myHexoticWorkingDir->text(); - h_data.myHexoticVerbosity = myStdWidget->myHexoticVerbosity->value(); - h_data.myHexoticMaxMemory = myStdWidget->myHexoticMaxMemory->value(); - h_data.myHexoticSdMode = myStdWidget->myHexoticSdMode->currentIndex(); - h_data.myTextOptions = myAdvWidget->GetCustomOptions(); - h_data.myMinSize = myStdWidget->myMinSize->text().isEmpty() ? 0.0 : myStdWidget->myMinSize->value(); h_data.myMaxSize = myStdWidget->myMaxSize->text().isEmpty() ? 0.0 : myStdWidget->myMaxSize->value(); - h_data.myHexesMinLevel = myStdWidget->myHexesMinLevel->text().isEmpty() ? 0 : myStdWidget->myHexesMinLevel->value(); - h_data.myHexesMaxLevel = myStdWidget->myHexesMaxLevel->text().isEmpty() ? 0 : myStdWidget->myHexesMaxLevel->value(); - h_data.myHexoticSharpAngleThreshold = myStdWidget->myHexoticSharpAngleThreshold->text().isEmpty() ? 0 : myStdWidget->myHexoticSharpAngleThreshold->value(); + h_data.myApproxAngle = myStdWidget->myGeomApproxAngle->text().isEmpty() ? 0.0 : myStdWidget->myGeomApproxAngle->value(); + h_data.myHexoticSdMode = myStdWidget->myHexoticSdMode->currentIndex(); + + h_data.myHexoticWorkingDir = myAdvWidget->myHexoticWorkingDir->text(); + h_data.myHexoticVerbosity = myAdvWidget->myHexoticVerbosity->value(); + h_data.myKeepFiles = myAdvWidget->keepWorkingFilesCheck->isChecked(); + h_data.myLogInStandardOutput = !myAdvWidget->logInFileCheck->isChecked(); + h_data.myRemoveLogOnSuccess = myAdvWidget->removeLogOnSuccessCheck->isChecked(); // Size maps reading bool ok = readSizeMapsFromWidgets( h_data ); diff --git a/src/GUI/HexoticPluginGUI_HypothesisCreator.h b/src/GUI/HexoticPluginGUI_HypothesisCreator.h index a135c05..884cab4 100644 --- a/src/GUI/HexoticPluginGUI_HypothesisCreator.h +++ b/src/GUI/HexoticPluginGUI_HypothesisCreator.h @@ -26,19 +26,21 @@ #define HexoticPLUGINGUI_HypothesisCreator_H #include "HexoticPluginGUI.h" - -#include -#include "StdMeshersGUI_ObjectReferenceParamWdg.h" #include "HexoticPlugin_Hypothesis.hxx" +#include +#include #include +#include CORBA_SERVER_HEADER(HexoticPlugin_Algorithm) + class QtxIntSpinBox; class QCheckBox; class QLineEdit; class QTableWidgetItem; class HexoticPluginGUI_StdWidget; +class HexoticPluginGUI_AdvWidget; class HexoticPluginGUI_SizeMapsWidget; class HexoticPluginGUI_ViscousLayersWidget; class SMESH_AdvOptionsWdg; @@ -47,7 +49,7 @@ typedef struct { QString myName; int myHexesMinLevel, myHexesMaxLevel; - double myMinSize, myMaxSize; + double myMinSize, myMaxSize, myApproxAngle; bool myHexoticInvalidElements; bool myHexoticIgnoreRidges; double myHexoticSharpAngleThreshold; @@ -57,6 +59,7 @@ typedef struct int myHexoticMaxMemory; int myHexoticSdMode; QString myTextOptions; + bool myKeepFiles,myLogInStandardOutput, myRemoveLogOnSuccess; HexoticPlugin_Hypothesis::THexoticSizeMaps mySizeMaps; int myNbLayers; double myFirstLayerSize; @@ -103,12 +106,13 @@ private: private: // QWidget* myStdGroup; - QLineEdit* myName; - HexoticPluginGUI_StdWidget* myStdWidget; - SMESH_AdvOptionsWdg* myAdvWidget; - HexoticPluginGUI_SizeMapsWidget* mySmpWidget; - HexoticPluginGUI_ViscousLayersWidget* myVLWidget; - StdMeshersGUI_ObjectReferenceParamWdg* myGeomSelWdg; + QLineEdit* myName; + HexoticPluginGUI_StdWidget* myStdWidget; + HexoticPluginGUI_AdvWidget* myAdvWidget; + mutable HexoticPlugin::string_array_var myOptions, myCustomOptions; + HexoticPluginGUI_SizeMapsWidget* mySmpWidget; + HexoticPluginGUI_ViscousLayersWidget* myVLWidget; + StdMeshersGUI_ObjectReferenceParamWdg* myGeomSelWdg; bool myIs3D; std::vector< std::string > mySizeMapsToRemove; diff --git a/src/GUI/HexoticPluginGUI_StdWidget.cxx b/src/GUI/HexoticPluginGUI_StdWidget.cxx index 01171c6..2514923 100644 --- a/src/GUI/HexoticPluginGUI_StdWidget.cxx +++ b/src/GUI/HexoticPluginGUI_StdWidget.cxx @@ -54,42 +54,36 @@ HexoticPluginGUI_StdWidget::HexoticPluginGUI_StdWidget( QWidget* parent, Qt::Win myMaxSize->setPrecision(precision); // myMaxSize->setSpecialValueText(" "); - myHexesMinLevel->setMinimum(0); - myHexesMinLevel->setMaximum(10); -// myHexesMinLevel->setSpecialValueText(" "); - - myHexesMaxLevel->setMinimum(0); - myHexesMaxLevel->setMaximum(10); -// myHexesMaxLevel->setSpecialValueText(" "); - - myHexoticSharpAngleThreshold->setMinimum(0); - myHexoticSharpAngleThreshold->setMaximum(90); - myHexoticSharpAngleThreshold->setPrecision(precision); -// myHexoticSharpAngleThreshold->setSpecialValueText(" "); - - myHexoticNbProc->setMinimum( 1 ); - myHexoticNbProc->setMaximum( 256 ); -// myHexoticNbProc->setSingleStep( 1 ); + myGeomApproxAngle->RangeStepAndValidator( 0, 180, 1, "angle_precision" ); myHexoticSdMode->setCurrentIndex(SD_MODE_4); imageSdMode = SUIT_Session::session()->resourceMgr()->loadPixmap("HexoticPLUGIN", tr("Hexotic_SD_MODE_4_PIXMAP")); -} -HexoticPluginGUI_StdWidget::~HexoticPluginGUI_StdWidget() -{ + connect( myPhySizeType, SIGNAL( currentIndexChanged(int)), SLOT( onSizeTypeChange(int) )); + connect( myGeomSizeType, SIGNAL( currentIndexChanged(int)), SLOT( onSizeTypeChange(int) )); } -void HexoticPluginGUI_StdWidget::onDirBtnClicked() +HexoticPluginGUI_StdWidget::~HexoticPluginGUI_StdWidget() { - QString dir = SUIT_FileDlg::getExistingDirectory( this, myHexoticWorkingDir->text(), QString() ); - if ( !dir.isEmpty() ) - myHexoticWorkingDir->setText( dir ); } - void HexoticPluginGUI_StdWidget::onSdModeSelected(int sdMode) { imageSdMode = SUIT_Session::session()->resourceMgr()->loadPixmap("HexoticPLUGIN", tr(QString("Hexotic_SD_MODE_%1_PIXMAP").arg(sdMode+1).toStdString().c_str())); sdModeLabel->setPixmap(imageSdMode.scaled(sdModeLabel->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); } + +void HexoticPluginGUI_StdWidget::onSizeTypeChange(int index) +{ + if ( sender() == myPhySizeType ) + { + myMinSize->setEnabled( index ); + myMaxSize->setEnabled( index ); + } + else + { + myGeomApproxAngle->setEnabled( index ); + } +} + diff --git a/src/GUI/HexoticPluginGUI_StdWidget_QTD.ui b/src/GUI/HexoticPluginGUI_StdWidget_QTD.ui index 1416d0c..a06c25a 100644 --- a/src/GUI/HexoticPluginGUI_StdWidget_QTD.ui +++ b/src/GUI/HexoticPluginGUI_StdWidget_QTD.ui @@ -6,170 +6,137 @@ 0 0 - 561 - 908 + 649 + 482 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Hexotic_SHARP_ANGLE_THRESHOLD - - - - - - - 99999 - - - 128 - - - 2048 - - - - + + + + + 0 + 0 + + Hexotic_INPUT_SIZE - + + + + Hexotic_PHY_SIZE_TYPE + + + + + + + 1 + + + + Hexotic_NONE + + + + + Hexotic_GLOBAL + + + + + Hexotic_MIN_SIZE - + - + Hexotic_MAX_SIZE - + - - - - Hexotic_MAX_MEMORY - - - - - - - Hexotic_WORKING_DIR - - - - - + + - + 0 0 - - Hexotic_SELECT_DIR - - - - - - - Hexotic_INVALID_ELEMENTS - - - - - - - 10 - - - 1 - - - - - - Hexotic_INPUT_LEVEL + Hexotic_GEOM_SIZE - + - Hexotic_HEXES_MIN_LEVEL + Hexotic_GEOM_SIZE_TYPE - + + + + Hexotic_NONE + + + + + Hexotic_GLOBAL + + + - Hexotic_HEXES_MAX_LEVEL + Hexotic_GEOM_APPROX_ANGLE - + + + + + + Qt::Vertical + + + + 228 + 50 + + + - - - - - - - - - Hexotic_IGNORE_RIDGES - - - - - - - Hexotic_NB_PROC - - - - - - - + + + 0 + 0 + + Hexotic_SUBDOMAIN_MESH_MODE @@ -229,13 +196,6 @@ - - - - Hexotic_VERBOSITY - - - @@ -245,44 +205,18 @@
    SalomeApp_DoubleSpinBox.h
    - SalomeApp_IntSpinBox - QLineEdit -
    SalomeApp_IntSpinBox.h
    + SMESHGUI_SpinBox + QDoubleSpinBox +
    SMESHGUI_SpinBox.h
    myMinSize myMaxSize - myHexesMinLevel - myHexesMaxLevel - myHexoticIgnoreRidges - myHexoticInvalidElements - myHexoticSharpAngleThreshold - myHexoticNbProc - dirBtn - myHexoticWorkingDir - myHexoticMaxMemory - myHexoticVerbosity myHexoticSdMode - - dirBtn - clicked() - HexoticPluginGUI_StdWidget_QTD - onDirBtnClicked() - - - 261 - 220 - - - 390 - 143 - - - myHexoticSdMode currentIndexChanged(int) @@ -290,8 +224,8 @@ onSdModeSelected(int) - 147 - 310 + 166 + 207 170 diff --git a/src/GUI/HexoticPluginGUI_TreeWidget.cxx b/src/GUI/HexoticPluginGUI_TreeWidget.cxx new file mode 100644 index 0000000..6037291 --- /dev/null +++ b/src/GUI/HexoticPluginGUI_TreeWidget.cxx @@ -0,0 +1,91 @@ +// Copyright (C) 2007-2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "HexoticPluginGUI_TreeWidget.h" +#include + +namespace +{ + bool isEditable( const QModelIndex& index ) + { + return index.isValid() && + index.flags() & Qt::ItemIsEditable && + index.flags() & Qt::ItemIsEnabled && + ( !index.data( Qt::UserRole + 1 ).isValid() || index.data( Qt::UserRole + 1 ).toInt() != 0 ); + } +} + +HexoticPluginGUI_TreeWidget::HexoticPluginGUI_TreeWidget( QWidget* parent ) + : QTreeWidget( parent ) +{ +} + +QModelIndex HexoticPluginGUI_TreeWidget::moveCursor( CursorAction action, Qt::KeyboardModifiers modifiers ) +{ + QModelIndex current = currentIndex(); + int column = current.column(); + if ( action == MoveNext ) { + if ( column < columnCount()-1 ) { + QModelIndex next = current.sibling( current.row(), column+1 ); + if ( isEditable( next ) ) + return next; + } + else { + QModelIndex next = current.sibling( current.row()+1, 0 ); + if ( isEditable( next ) ) + return next; + } + } + else if ( action == MovePrevious ) { + if ( column == 0 ) { + QModelIndex next = current.sibling( current.row()-1, columnCount()-1 ); + if ( isEditable( next ) ) + return next; + } + else { + QModelIndex next = current.sibling( current.row(), column-1 ); + if ( isEditable( next ) ) + return next; + } + } + return QTreeWidget::moveCursor( action, modifiers ); +} + +void HexoticPluginGUI_TreeWidget::keyPressEvent( QKeyEvent* e ) +{ + switch ( e->key() ) { + case Qt::Key_F2: + { + QModelIndex index = currentIndex(); + if ( !isEditable( index ) ) { + for ( int i = 0; i < columnCount(); i++ ) { + QModelIndex sibling = index.sibling( index.row(), i ); + if ( isEditable( sibling ) ) { + if ( !edit( sibling, EditKeyPressed, e ) ) + e->ignore(); + } + } + } + } + break; + default: + break; + } + QTreeWidget::keyPressEvent( e ); +} diff --git a/src/GUI/HexoticPluginGUI_TreeWidget.h b/src/GUI/HexoticPluginGUI_TreeWidget.h new file mode 100644 index 0000000..d1d5220 --- /dev/null +++ b/src/GUI/HexoticPluginGUI_TreeWidget.h @@ -0,0 +1,36 @@ +// Copyright (C) 2007-2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#if !defined(HexoticPluginGUI_TreeWidget_H) +#define HexoticPluginGUI_TreeWidget_H + +#include + +class HexoticPluginGUI_TreeWidget : public QTreeWidget +{ + Q_OBJECT +public: + HexoticPluginGUI_TreeWidget( QWidget* ); + +protected: + QModelIndex moveCursor( CursorAction, Qt::KeyboardModifiers ); + void keyPressEvent( QKeyEvent* ); +}; + +#endif // HexoticPluginGUI_TreeWidget_H diff --git a/src/HexoticPlugin/HexoticPLUGINBuilder.py b/src/HexoticPlugin/HexoticPLUGINBuilder.py index 11ae62f..fb199bc 100644 --- a/src/HexoticPlugin/HexoticPLUGINBuilder.py +++ b/src/HexoticPlugin/HexoticPLUGINBuilder.py @@ -128,6 +128,13 @@ class Hexotic_Algorithm(Mesh_Algorithm): print("WARNING: Function MinMaxQuad is deprecated, use SetMinMaxHexes instead") return self.SetMinMaxHexes(min, max) + ## Set advanced option value + # @param optionName option name + # @param optionValue option value + def SetOptionValue(self, optionName, optionValue): + self.Parameters().SetOptionValue( optionName, optionValue ) + pass + ## Defines "ViscousLayers" hypothesis to give MG-Hexa parameters # @param numberOfLayers number of boundary layers # @param firstLayerSize height of the first layer @@ -171,6 +178,28 @@ class Hexotic_Algorithm(Mesh_Algorithm): return self.Parameters() + ## To keep working files or remove them. + # @param toKeep "keep working files" flag value + def SetKeepFiles(self, toKeep): + self.Parameters().SetKeepFiles(toKeep) + pass + + ## Remove or not the log file (if any) in case of successful computation. + # The log file remains in case of errors anyway. If + # the "keep working files" flag is set to true, this option + # has no effect. + # @param toRemove "remove log on success" flag value + def SetRemoveLogOnSuccess(self, toRemove): + self.Parameters().SetRemoveLogOnSuccess(toRemove) + pass + + ## Print the the log in a file. If set to false, the + # log is printed on the standard output + # @param toPrintLogInFile "print log in a file" flag value + def SetPrintLogInFile(self, toPrintLogInFile): + self.Parameters().SetStandardOutputLog(not toPrintLogInFile) + pass + ## Defines hypothesis having several parameters # @return hypothesis object def Parameters(self): diff --git a/src/HexoticPlugin/HexoticPlugin_Hexotic.cxx b/src/HexoticPlugin/HexoticPlugin_Hexotic.cxx index cc623a3..ecc0adc 100644 --- a/src/HexoticPlugin/HexoticPlugin_Hexotic.cxx +++ b/src/HexoticPlugin/HexoticPlugin_Hexotic.cxx @@ -655,6 +655,7 @@ void HexoticPlugin_Hexotic::SetParameters(const HexoticPlugin_Hypothesis* hyp) { _hexesMaxLevel = hyp->GetHexesMaxLevel(); _hexesMinSize = hyp->GetMinSize(); _hexesMaxSize = hyp->GetMaxSize(); + _approxAngle = hyp->GetGeomApproxAngle(); _hexoticIgnoreRidges = hyp->GetHexoticIgnoreRidges(); _hexoticInvalidElements = hyp->GetHexoticInvalidElements(); _hexoticSharpAngleThreshold = hyp->GetHexoticSharpAngleThreshold(); @@ -671,6 +672,9 @@ void HexoticPlugin_Hexotic::SetParameters(const HexoticPlugin_Hypothesis* hyp) { _growth = hyp->GetGrowth(); _facesWithLayers = hyp->GetFacesWithLayers(); _imprintedFaces = hyp->GetImprintedFaces(); + _keepFiles = hyp->GetKeepFiles(); + _removeLogOnSuccess = hyp->GetRemoveLogOnSuccess(); + _logInStandardOutput = hyp->GetStandardOutputLog(); } else { cout << std::endl; @@ -680,6 +684,7 @@ void HexoticPlugin_Hexotic::SetParameters(const HexoticPlugin_Hypothesis* hyp) { _hexesMaxLevel = hyp->GetDefaultHexesMaxLevel(); _hexesMinSize = hyp->GetDefaultMinSize(); _hexesMaxSize = hyp->GetDefaultMaxSize(); + _approxAngle = hyp->GetDefaultGeomApproxAngle(); _hexoticIgnoreRidges = hyp->GetDefaultHexoticIgnoreRidges(); _hexoticInvalidElements = hyp->GetDefaultHexoticInvalidElements(); _hexoticSharpAngleThreshold = hyp->GetDefaultHexoticSharpAngleThreshold(); @@ -696,6 +701,9 @@ void HexoticPlugin_Hexotic::SetParameters(const HexoticPlugin_Hypothesis* hyp) { _growth = hyp->GetDefaultGrowth(); _facesWithLayers = hyp->GetDefaultFacesWithLayers(); _imprintedFaces = hyp->GetDefaultImprintedFaces(); + _keepFiles = hyp->GetDefaultKeepFiles(); + _removeLogOnSuccess = hyp->GetDefaultRemoveLogOnSuccess(); + _logInStandardOutput = hyp->GetDefaultStandardOutputLog(); } } @@ -1116,35 +1124,45 @@ bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh& aMesh, &aHelper, _nbShape, tabShape, tabBox ); std::string log = mgHexa.GetLog(); + hexahedraMessage = "failed"; if ( Ok ) { hexahedraMessage = "success"; -#ifndef _DEBUG_ - removeFile(Hexotic_Out); - removeFile(Hexotic_In); - //removeFile(aLogFileName); - for( size_t i=0; i _facesWithLayers; std::vector _imprintedFaces; SMDS_MeshNode** _tabNode; + bool _keepFiles; + bool _removeLogOnSuccess; + bool _logInStandardOutput; #ifdef WITH_BLSURFPLUGIN const BLSURFPlugin_Hypothesis* _blsurfHypo; diff --git a/src/HexoticPlugin/HexoticPlugin_Hypothesis.cxx b/src/HexoticPlugin/HexoticPlugin_Hypothesis.cxx index b0aaca8..f5e23a6 100644 --- a/src/HexoticPlugin/HexoticPlugin_Hypothesis.cxx +++ b/src/HexoticPlugin/HexoticPlugin_Hypothesis.cxx @@ -26,10 +26,20 @@ #include #include +#include + +namespace +{ + struct GET_DEFAULT // struct used to get default value from GetOptionValue() + { + bool isDefault; + operator bool* () { return &isDefault; } + }; +} //============================================================================= /*! - * + * */ //============================================================================= HexoticPlugin_Hypothesis::HexoticPlugin_Hypothesis (int hypId, SMESH_Gen* gen) @@ -38,16 +48,18 @@ HexoticPlugin_Hypothesis::HexoticPlugin_Hypothesis (int hypId, SMESH_Gen* gen) _hexesMaxLevel( GetDefaultHexesMaxLevel() ), _minSize( GetDefaultMinSize() ), _maxSize( GetDefaultMaxSize() ), + _approxAngle( GetDefaultGeomApproxAngle() ), _hexoticIgnoreRidges( GetDefaultHexoticIgnoreRidges() ), - _hexoticInvalidElements( GetDefaultHexoticInvalidElements() ), + _hexoticInvalidElements( GetDefaultHexoticInvalidElements() ), _hexoticSharpAngleThreshold( GetDefaultHexoticSharpAngleThreshold() ), _hexoticNbProc( GetDefaultHexoticNbProc() ), _hexoticSdMode(GetDefaultHexoticSdMode()), _hexoticVerbosity(GetDefaultHexoticVerbosity()), _hexoticMaxMemory(GetDefaultHexoticMaxMemory()), - _textOptions(GetDefaultTextOptions()), - _sizeMaps(GetDefaultHexoticSizeMaps()), _hexoticWorkingDirectory( GetDefaultHexoticWorkingDirectory() ), + _logInStandardOutput( GetDefaultStandardOutputLog() ), + _removeLogOnSuccess( GetDefaultRemoveLogOnSuccess() ), + _keepFiles( GetDefaultKeepFiles() ), _nbLayers(GetDefaultNbLayers()), _firstLayerSize(GetDefaultFirstLayerSize()), _direction(GetDefaultDirection()), @@ -58,68 +70,135 @@ HexoticPlugin_Hypothesis::HexoticPlugin_Hypothesis (int hypId, SMESH_Gen* gen) MESSAGE("HexoticPlugin_Hypothesis::HexoticPlugin_Hypothesis"); _name = GetHypType(); _param_algo_dim = 3; + + const char* boolOptionNames[] = { "allow_invalid_elements", + "enforce_constant_layer_size", + "compute_ridges", + "flatten_hexa_sides", + "recover_sharp_angles", + "" // mark of end + }; + const char* intOptionNames[] = { "max_memory", // 2048 + "max_number_of_threads", // 4 + "min_level", // 6 + "max_level", // 10 + "sizemap_level", // 10 + "" // mark of end + }; + const char* doubleOptionNames[] = { "ridge_angle", // 60 + "" // mark of end + }; + const char* charOptionNames[] = { "element_order", // linear + "tags", // respect + "" // mark of end + }; + + int i = 0; + while (boolOptionNames[i][0]) + { + _boolOptions.insert( boolOptionNames[i] ); + _option2value[boolOptionNames[i++]].clear(); + } + i = 0; + while (intOptionNames[i][0]) + _option2value[intOptionNames[i++]].clear(); + + i = 0; + while (doubleOptionNames[i][0]) { + _doubleOptions.insert(doubleOptionNames[i]); + _option2value[doubleOptionNames[i++]].clear(); + } + i = 0; + while (charOptionNames[i][0]) { + _charOptions.insert(charOptionNames[i]); + _option2value[charOptionNames[i++]].clear(); + } + + // default values to be used while MG meshing + + _defaultOptionValues["allow_invalid_elements" ] = "no"; + _defaultOptionValues["enforce_constant_layer_size"] = "no"; + _defaultOptionValues["compute_ridges" ] = "yes"; + _defaultOptionValues["flatten_hexa_sides" ] = "no"; + _defaultOptionValues["recover_sharp_angles" ] = "yes"; + _defaultOptionValues["max_memory" ] = "2048"; + _defaultOptionValues["max_number_of_threads" ] = "4"; + _defaultOptionValues["min_level" ] = "6"; + _defaultOptionValues["max_level" ] = "10"; + _defaultOptionValues["sizemap_level" ] = "10"; + _defaultOptionValues["ridge_angle" ] = "60"; + _defaultOptionValues["element_order" ] = "linear"; + _defaultOptionValues["tags" ] = "respect"; + +#ifdef _DEBUG_ + // check validity of option names of _defaultOptionValues + TOptionValues::iterator n2v = _defaultOptionValues.begin(); + for ( ; n2v != _defaultOptionValues.end(); ++n2v ) + ASSERT( _option2value.count( n2v->first )); + ASSERT( _option2value.size() == _defaultOptionValues.size() ); +#endif } //============================================================================= /*! - * + * */ //============================================================================= -void HexoticPlugin_Hypothesis::SetHexesMinLevel(int theVal) { - if (theVal != _hexesMinLevel) { - _hexesMinLevel = theVal; - NotifySubMeshesHypothesisModification(); - } +void HexoticPlugin_Hypothesis::SetHexesMinLevel(int theVal) +{ + SetOptionValue( "min_level", SMESH_Comment( theVal )); + _hexesMinLevel = theVal; } -void HexoticPlugin_Hypothesis::SetHexesMaxLevel(int theVal) { - if (theVal != _hexesMaxLevel) { - _hexesMaxLevel = theVal; - NotifySubMeshesHypothesisModification(); - } +void HexoticPlugin_Hypothesis::SetHexesMaxLevel(int theVal) +{ + SetOptionValue( "max_level", SMESH_Comment( theVal )); + _hexesMaxLevel = theVal; } void HexoticPlugin_Hypothesis::SetMinSize(double theVal) { if (theVal != _minSize) { - _minSize = theVal; + _minSize = theVal; NotifySubMeshesHypothesisModification(); } } void HexoticPlugin_Hypothesis::SetMaxSize(double theVal) { if (theVal != _maxSize) { - _maxSize = theVal; + _maxSize = theVal; NotifySubMeshesHypothesisModification(); } } -void HexoticPlugin_Hypothesis::SetHexoticIgnoreRidges(bool theVal) { - if (theVal != _hexoticIgnoreRidges) { - _hexoticIgnoreRidges = theVal; +void HexoticPlugin_Hypothesis::SetGeomApproxAngle(double theVal) { + if (theVal != _approxAngle) { + _approxAngle = theVal; NotifySubMeshesHypothesisModification(); } } -void HexoticPlugin_Hypothesis::SetHexoticInvalidElements(bool theVal) { - if (theVal != _hexoticInvalidElements) { - _hexoticInvalidElements = theVal; - NotifySubMeshesHypothesisModification(); - } +void HexoticPlugin_Hypothesis::SetHexoticIgnoreRidges(bool theVal) { + SetOptionValue( "compute_ridges", theVal ? "no" : "yes" ); + _hexoticIgnoreRidges = theVal; } -void HexoticPlugin_Hypothesis::SetHexoticSharpAngleThreshold(double theVal) { - if (theVal != _hexoticSharpAngleThreshold) { - _hexoticSharpAngleThreshold = theVal; - NotifySubMeshesHypothesisModification(); - } +void HexoticPlugin_Hypothesis::SetHexoticInvalidElements(bool theVal) +{ + SetOptionValue( "allow_invalid_elements", theVal ? "yes" : "no" ); + _hexoticInvalidElements = theVal; } -void HexoticPlugin_Hypothesis::SetHexoticNbProc(int theVal) { - if (theVal != _hexoticNbProc) { - _hexoticNbProc = theVal; - NotifySubMeshesHypothesisModification(); - } +void HexoticPlugin_Hypothesis::SetHexoticSharpAngleThreshold(double theVal) +{ + SetOptionValue( "ridge_angle", SMESH_Comment( theVal )); + _hexoticSharpAngleThreshold = theVal; +} + +void HexoticPlugin_Hypothesis::SetHexoticNbProc(int theVal) +{ + SetOptionValue( "max_number_of_threads", SMESH_Comment( theVal )); + _hexoticNbProc = theVal; } void HexoticPlugin_Hypothesis::SetHexoticWorkingDirectory(const std::string& path) @@ -154,35 +233,314 @@ void HexoticPlugin_Hypothesis::SetHexoticVerbosity(int theVal) { } } -void HexoticPlugin_Hypothesis::SetHexoticMaxMemory(int theVal) { - if (theVal != _hexoticMaxMemory) { - _hexoticMaxMemory = theVal; +void HexoticPlugin_Hypothesis::SetHexoticMaxMemory(int theVal) +{ + SetOptionValue( "max_memory", SMESH_Comment( theVal )); + _hexoticMaxMemory = theVal; +} + +void HexoticPlugin_Hypothesis::SetKeepFiles(bool toKeep) +{ + if ( _keepFiles != toKeep ) { + _keepFiles = toKeep; NotifySubMeshesHypothesisModification(); } } -void HexoticPlugin_Hypothesis::SetAdvancedOption(const std::string& theOptions) +void HexoticPlugin_Hypothesis::SetStandardOutputLog(bool logInStandardOutput) { - if (_textOptions != theOptions ) { - _textOptions = theOptions; + if ( _logInStandardOutput != logInStandardOutput ) { + _logInStandardOutput = logInStandardOutput; NotifySubMeshesHypothesisModification(); } } -void HexoticPlugin_Hypothesis::SetTextOptions(const std::string& theOptions) + +void HexoticPlugin_Hypothesis::SetRemoveLogOnSuccess(bool removeLogOnSuccess) { - if (_textOptions != theOptions ) { - _textOptions = theOptions; + if ( _removeLogOnSuccess != removeLogOnSuccess ) { + _removeLogOnSuccess = removeLogOnSuccess; NotifySubMeshesHypothesisModification(); } } -bool HexoticPlugin_Hypothesis::AddSizeMap(std::string theEntry, double theSize) { +void HexoticPlugin_Hypothesis::SetOptionValue(const std::string& optionName, + const std::string& optionValue) + throw (std::invalid_argument) +{ + TOptionValues::iterator op_val = _option2value.find(optionName); + if (op_val == _option2value.end()) + { + op_val = _customOption2value.find( optionName ); + if ( op_val != _customOption2value.end() && op_val->second != optionValue ) + NotifySubMeshesHypothesisModification(); + _customOption2value[ optionName ] = optionValue; + return; + } + + 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 (_charOptions.count(optionName)) { + // do not check strings + } else if (_doubleOptions.count(optionName)) { + // check if value is double + ToDbl(ptr, &typeOk); + typeName = "real"; + } else if (_boolOptions.count(optionName)) { + // check if value is bool + ToBool(ptr, &typeOk); + typeName = "bool"; + } else { + // check if value is int + ToInt(ptr, &typeOk); + typeName = "integer"; + } + if ( typeOk ) // check some specific values ? + { + } + if ( !typeOk ) + { + std::string msg = "Advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName; + throw std::invalid_argument(msg); + } + std::string value( ptr, i ); + if ( _defaultOptionValues[ optionName ] == value ) + value.clear(); + + op_val->second = value; + + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +//! Return option value. If isDefault provided, it can be a default value, +// then *isDefault == true. If isDefault is not provided, the value will be +// empty if it equals a default one. +std::string HexoticPlugin_Hypothesis::GetOptionValue(const std::string& optionName, + bool* isDefault) const + throw (std::invalid_argument) +{ + TOptionValues::const_iterator op_val = _option2value.find(optionName); + if (op_val == _option2value.end()) + { + op_val = _customOption2value.find(optionName); + if (op_val == _customOption2value.end()) + { + std::string msg = "Unknown MG-Tetra option: <" + optionName + ">"; + throw std::invalid_argument(msg); + } + } + std::string val = op_val->second; + if ( isDefault ) *isDefault = ( val.empty() ); + + if ( val.empty() && isDefault ) + { + op_val = _defaultOptionValues.find( optionName ); + if (op_val != _defaultOptionValues.end()) + val = op_val->second; + } + return val; +} + + +//============================================================================= +bool HexoticPlugin_Hypothesis::HasOptionDefined( const std::string& optionName ) const +{ + bool isDefault = false; + try + { + GetOptionValue( optionName, &isDefault ); + } + catch ( std::invalid_argument ) + { + return false; + } + return !isDefault; +} + +//============================================================================= +void HexoticPlugin_Hypothesis::ClearOption(const std::string& optionName) +{ + TOptionValues::iterator op_val = _customOption2value.find(optionName); + if (op_val != _customOption2value.end()) + _customOption2value.erase(op_val); + else { + op_val = _option2value.find(optionName); + if (op_val != _option2value.end()) + op_val->second.clear(); + } +} + +//============================================================================= +HexoticPlugin_Hypothesis::TOptionValues HexoticPlugin_Hypothesis::GetOptionValues() const +{ + TOptionValues vals; + TOptionValues::const_iterator op_val = _option2value.begin(); + for ( ; op_val != _option2value.end(); ++op_val ) + vals.insert( make_pair( op_val->first, GetOptionValue( op_val->first, GET_DEFAULT() ))); + + return vals; +} + +//================================================================================ +/*! + * \brief Converts a string to a bool + */ +//================================================================================ + +bool HexoticPlugin_Hypothesis::ToBool(const std::string& str, bool* isOk ) + throw (std::invalid_argument) +{ + std::string s = str; + if ( isOk ) *isOk = true; + + for ( size_t i = 0; i <= s.size(); ++i ) + s[i] = tolower( s[i] ); + + if ( s == "1" || s == "true" || s == "active" || s == "yes" ) + return true; + + if ( s == "0" || s == "false" || s == "inactive" || s == "no" ) + return false; + + if ( isOk ) + *isOk = false; + else { + std::string msg = "Not a Boolean value:'" + str + "'"; + throw std::invalid_argument(msg); + } + return false; +} + +//================================================================================ +/*! + * \brief Converts a string to a real value + */ +//================================================================================ + +double HexoticPlugin_Hypothesis::ToDbl(const std::string& str, bool* isOk ) + throw (std::invalid_argument) +{ + if ( str.empty() ) throw std::invalid_argument("Empty value provided"); + + char * endPtr; + double val = strtod(&str[0], &endPtr); + bool ok = (&str[0] != endPtr); + + if ( isOk ) *isOk = ok; + + if ( !ok ) + { + std::string msg = "Not a real value:'" + str + "'"; + throw std::invalid_argument(msg); + } + return val; +} + +//================================================================================ +/*! + * \brief Converts a string to a integer value + */ +//================================================================================ + +int HexoticPlugin_Hypothesis::ToInt(const std::string& str, bool* isOk ) + throw (std::invalid_argument) +{ + if ( str.empty() ) throw std::invalid_argument("Empty value provided"); + + char * endPtr; + int val = (int)strtol( &str[0], &endPtr, 10); + bool ok = (&str[0] != endPtr); + + if ( isOk ) *isOk = ok; + + if ( !ok ) + { + std::string msg = "Not an integer value:'" + str + "'"; + throw std::invalid_argument(msg); + } + return val; +} + +void HexoticPlugin_Hypothesis::SetAdvancedOption(const std::string& option) +{ + size_t wsPos = option.find(' '); + if ( wsPos == std::string::npos ) + { + SetOptionValue( option, "" ); + } + else + { + std::string opt( option, 0, wsPos ); + std::string val( option, wsPos + 1 ); + SetOptionValue( opt, val ); + } +} + +//======================================================================= +//function : GetAdvancedOption +//purpose : Return only options having NO corresponding member fields +//======================================================================= + +std::string HexoticPlugin_Hypothesis::GetAdvancedOption( bool customOnly ) const +{ + // options having corresponding member fields + static std::set< std::string > toSkip = { + "min_level", + "max_level", + "compute_ridges", + "allow_invalid_elements", + "ridge_angle", + "max_number_of_threads", + "max_memory" + }; + + // Return only options having NO corresponding member fields + + SMESH_Comment txt; + + TOptionValues::const_iterator o2v = _option2value.begin(); + if ( !customOnly ) + { + for ( ; o2v != _option2value.end(); ++o2v ) + if ( !o2v->second.empty() && !toSkip.count( o2v->first )) + { + if ( !txt.empty() ) + txt << " "; + txt << "--" << o2v->first << " " << o2v->second; + } + } + for ( o2v = _customOption2value.begin(); o2v != _customOption2value.end(); ++o2v ) + { + if ( !txt.empty() ) + txt << " "; + // if ( o2v->first[0] != '-' ) + // txt << "--"; + txt << o2v->first << " " << o2v->second; + } + return txt; +} + +bool HexoticPlugin_Hypothesis::AddSizeMap(std::string theEntry, double theSize) +{ THexoticSizeMaps::iterator it; it=_sizeMaps.find(theEntry); - + if(theSize <= 0) return false; - + if( it == _sizeMaps.end() ) // If no size map is defined on the given object { _sizeMaps[theEntry] = theSize; @@ -199,7 +557,7 @@ bool HexoticPlugin_Hypothesis::AddSizeMap(std::string theEntry, double theSize) } else { - MESSAGE("NO size map added") + MESSAGE("NO size map added"); return false; // No size map added } } @@ -272,7 +630,7 @@ std::ostream& HexoticPlugin_Hypothesis::SaveTo(std::ostream& save) //explicit outputs for future code compatibility of saved .hdf //save without any whitespaces! //int dummy = -1; - save<<"hexesMinLevel="<<_hexesMinLevel<<";"; + save<<"hexesMinLevel="<<_hexesMinLevel<<";"; save<<"hexesMaxLevel="<<_hexesMaxLevel<<";"; save<<"hexoticIgnoreRidges="<<(int)_hexoticIgnoreRidges<<";"; save<<"hexoticInvalidElements="<<(int)_hexoticInvalidElements<<";"; @@ -284,7 +642,7 @@ std::ostream& HexoticPlugin_Hypothesis::SaveTo(std::ostream& save) save<<"hexoticSdMode="<<_hexoticSdMode<<";"; save<<"hexoticVerbosity="<<_hexoticVerbosity<<";"; save<<"hexoticMaxMemory="<<_hexoticMaxMemory<<";"; - std::string textOptions = _textOptions; // save _textOptions + std::string textOptions;// = _textOptions; replace(textOptions.begin(), textOptions.end(), ' ', '*'); save<<"textOptions="<first << " -" << o2v->second; + + save << " " << _customOption2value.size(); + for ( o2v = _customOption2value.begin(); o2v != _customOption2value.end(); ++o2v ) + save << " -" << o2v->first << " -" << o2v->second; + return save; } //============================================================================= /*! - * + * */ //============================================================================= std::istream& HexoticPlugin_Hypothesis::LoadFrom(std::istream& load) @@ -350,23 +725,23 @@ std::istream& HexoticPlugin_Hypothesis::LoadFrom(std::istream& load) str4 = str2.substr(eqpos+1); pos = found + 1; - if (str3=="hexesMinLevel") _hexesMinLevel = atoi(str4.c_str()); - if (str3=="hexesMaxLevel") _hexesMaxLevel = atoi(str4.c_str()); + if (str3=="hexesMinLevel") _hexesMinLevel = atoi(str4.c_str()); + if (str3=="hexesMaxLevel") _hexesMaxLevel = atoi(str4.c_str()); if (str3=="hexoticQuadrangles") {} - if (str3=="hexoticIgnoreRidges") _hexoticIgnoreRidges = (bool) atoi(str4.c_str()); - if (str3=="hexoticInvalidElements") _hexoticInvalidElements = (bool) atoi(str4.c_str()); + if (str3=="hexoticIgnoreRidges") _hexoticIgnoreRidges = (bool) atoi(str4.c_str()); + if (str3=="hexoticInvalidElements") _hexoticInvalidElements = (bool) atoi(str4.c_str()); if (str3=="hexoticSharpAngleThreshold") _hexoticSharpAngleThreshold = atof(str4.c_str()); - if (str3=="hexoticNbProc") _hexoticNbProc = atoi(str4.c_str()); - if (str3=="hexoticWorkingDirectory") _hexoticWorkingDirectory = str4; - if (str3=="minSize") _minSize = atof(str4.c_str()); - if (str3=="maxSize") _maxSize = atof(str4.c_str()); - if (str3=="hexoticSdMode") _hexoticSdMode = atoi(str4.c_str()); - if (str3=="hexoticVerbosity") _hexoticVerbosity = atoi(str4.c_str()); - if (str3=="hexoticMaxMemory") _hexoticMaxMemory = atoi(str4.c_str()); + if (str3=="hexoticNbProc") _hexoticNbProc = atoi(str4.c_str()); + if (str3=="hexoticWorkingDirectory") _hexoticWorkingDirectory = str4; + if (str3=="minSize") _minSize = atof(str4.c_str()); + if (str3=="maxSize") _maxSize = atof(str4.c_str()); + if (str3=="hexoticSdMode") _hexoticSdMode = atoi(str4.c_str()); + if (str3=="hexoticVerbosity") _hexoticVerbosity = atoi(str4.c_str()); + if (str3=="hexoticMaxMemory") _hexoticMaxMemory = atoi(str4.c_str()); if (str3=="textOptions") { replace(str4.begin(), str4.end(), '*', ' '); - _textOptions = str4; + //_textOptions = str4; } if (str3=="sizeMaps") { @@ -384,10 +759,10 @@ std::istream& HexoticPlugin_Hypothesis::LoadFrom(std::istream& load) sm_pos = sm_found + 1; } } - if (str3 == "nbLayers") _nbLayers = atoi(str4.c_str()); + if (str3 == "nbLayers") _nbLayers = atoi(str4.c_str()); if (str3 == "firstLayerSize") _firstLayerSize = atof(str4.c_str()); - if (str3 == "direction") _direction = atoi(str4.c_str()); - if (str3 == "growth") _growth = atof(str4.c_str()); + if (str3 == "direction") _direction = atoi(str4.c_str()); + if (str3 == "growth") _growth = atof(str4.c_str()); if (str3 == "facesWithLayers") { std::string id; @@ -413,6 +788,35 @@ std::istream& HexoticPlugin_Hypothesis::LoadFrom(std::istream& load) } } } + + // New options in 2.9.6 (issue #17784) + + if ( static_cast( load >> _approxAngle )) + { + int i; + load >> i; _logInStandardOutput = (bool)i; + load >> i; _removeLogOnSuccess = (bool)i; + load >> i; _keepFiles = (bool)i; + + std::string option, value; + if ( static_cast( load >> i ) && i >= 0 ) + { + for ( int nbRead = 0; nbRead < i; ++nbRead ) + { + load >> option >> value; + _option2value[ std::string( option, 1 )] = std::string( value, 1 ); + } + } + if ( static_cast( load >> i ) && i >= 0 ) + { + for ( int nbRead = 0; nbRead < i; ++nbRead ) + { + load >> option >> value; + _customOption2value[ std::string( option, 1 )] = std::string( value, 1 ); + } + } + } + return load; } diff --git a/src/HexoticPlugin/HexoticPlugin_Hypothesis.hxx b/src/HexoticPlugin/HexoticPlugin_Hypothesis.hxx index e692dba..638588f 100644 --- a/src/HexoticPlugin/HexoticPlugin_Hypothesis.hxx +++ b/src/HexoticPlugin/HexoticPlugin_Hypothesis.hxx @@ -31,6 +31,7 @@ #include "Utils_SALOME_Exception.hxx" #include +#include #include // class HexoticSizeMap @@ -67,6 +68,9 @@ public: void SetMaxSize(double theVal); double GetMaxSize() const { return _maxSize; } + void SetGeomApproxAngle(double angle); + double GetGeomApproxAngle() const { return _approxAngle; } + void SetHexoticIgnoreRidges(bool theVal); bool GetHexoticIgnoreRidges() const { return _hexoticIgnoreRidges; } @@ -91,14 +95,36 @@ public: void SetHexoticMaxMemory(int theVal); int GetHexoticMaxMemory() const { return _hexoticMaxMemory; } - void SetAdvancedOption(const std::string& theOptions); - std::string GetAdvancedOption() const { return _textOptions; } - void SetTextOptions(const std::string& theOptions); // obsolete - std::string GetTextOptions() const { return _textOptions; } + void SetKeepFiles(bool toKeep); + bool GetKeepFiles() const { return _keepFiles; } + void SetStandardOutputLog(bool logInStandardOutput); + bool GetStandardOutputLog() const { return _logInStandardOutput; } + void SetRemoveLogOnSuccess(bool removeLogOnSuccess); + bool GetRemoveLogOnSuccess() const { return _removeLogOnSuccess; } + + + typedef std::map< std::string, std::string > TOptionValues; + typedef std::set< std::string > TOptionNames; + + void SetOptionValue(const std::string& optionName, + const std::string& optionValue) throw (std::invalid_argument); + std::string GetOptionValue(const std::string& optionName, + bool* isDefault=0) const throw (std::invalid_argument); + bool HasOptionDefined( const std::string& optionName ) const; + void ClearOption(const std::string& optionName); + TOptionValues GetOptionValues() const; + const TOptionValues& GetCustomOptionValues() const { return _customOption2value; } + std::string GetAdvancedOption( bool customOnly = false ) const; + void SetAdvancedOption(const std::string& theOptions); // obsolete + + static bool ToBool(const std::string& str, bool* isOk=0) throw (std::invalid_argument); + static double ToDbl(const std::string& str, bool* isOk=0) throw (std::invalid_argument); + static int ToInt(const std::string& str, bool* isOk=0) throw (std::invalid_argument); + // Size Maps typedef std::map THexoticSizeMaps; - + // For the GUI HexoticPluginGUI_HypothesisCreator::storeParamToHypo const THexoticSizeMaps& GetSizeMaps() const { return _sizeMaps; } @@ -129,6 +155,7 @@ public: static int GetDefaultHexesMaxLevel(); static double GetDefaultMinSize(); static double GetDefaultMaxSize(); + static double GetDefaultGeomApproxAngle() { return 0; } static bool GetDefaultHexoticIgnoreRidges(); static bool GetDefaultHexoticInvalidElements(); static double GetDefaultHexoticSharpAngleThreshold(); @@ -145,6 +172,9 @@ public: static double GetDefaultGrowth(); static std::vector GetDefaultFacesWithLayers(); static std::vector GetDefaultImprintedFaces(); + static bool GetDefaultStandardOutputLog() { return false; } + static bool GetDefaultRemoveLogOnSuccess() { return false; } + static bool GetDefaultKeepFiles() { return false; } // Persistence virtual std::ostream& SaveTo(std::ostream& save); @@ -166,11 +196,12 @@ public: */ virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0); -private: + private: int _hexesMinLevel; int _hexesMaxLevel; double _minSize; double _maxSize; + double _approxAngle; bool _hexoticIgnoreRidges; bool _hexoticInvalidElements; double _hexoticSharpAngleThreshold; @@ -178,9 +209,17 @@ private: int _hexoticSdMode; int _hexoticVerbosity; int _hexoticMaxMemory; - std::string _textOptions; THexoticSizeMaps _sizeMaps; + + TOptionValues _option2value, _customOption2value; // user defined values + TOptionValues _defaultOptionValues; // default values + TOptionNames _doubleOptions, _charOptions, _boolOptions; // to find a type of option + std::string _hexoticWorkingDirectory; + bool _logInStandardOutput; + bool _removeLogOnSuccess; + bool _keepFiles; + int _nbLayers; double _firstLayerSize; bool _direction; diff --git a/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.cxx b/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.cxx index 240d72b..910d0e2 100644 --- a/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.cxx +++ b/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.cxx @@ -43,7 +43,6 @@ HexoticPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA, : SALOME::GenericObj_i( thePOA ), SMESH_Hypothesis_i( thePOA ) { - MESSAGE( "HexoticPlugin_Hypothesis_i::HexoticPlugin_Hypothesis_i" ); myBaseImpl = new ::HexoticPlugin_Hypothesis (theGenImpl->GetANewId(), theGenImpl); } @@ -57,7 +56,6 @@ HexoticPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA, //============================================================================= HexoticPlugin_Hypothesis_i::~HexoticPlugin_Hypothesis_i() { - MESSAGE( "HexoticPlugin_Hypothesis_i::~HexoticPlugin_Hypothesis_i" ); } //============================================================================= @@ -86,7 +84,6 @@ HexoticPlugin_Hypothesis_i::~HexoticPlugin_Hypothesis_i() void HexoticPlugin_Hypothesis_i::SetHexesMinLevel (CORBA::Long theValue) { - // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMinLevel"); ASSERT(myBaseImpl); CORBA::Long oldValue = GetHexesMinLevel(); this->GetImpl()->SetHexesMinLevel(theValue); @@ -96,7 +93,6 @@ void HexoticPlugin_Hypothesis_i::SetHexesMinLevel (CORBA::Long theValue) void HexoticPlugin_Hypothesis_i::SetHexesMaxLevel (CORBA::Long theValue) { - // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMaxLevel"); ASSERT(myBaseImpl); CORBA::Long oldValue = GetHexesMaxLevel(); this->GetImpl()->SetHexesMaxLevel(theValue); @@ -106,7 +102,6 @@ void HexoticPlugin_Hypothesis_i::SetHexesMaxLevel (CORBA::Long theValue) void HexoticPlugin_Hypothesis_i::SetMinSize (CORBA::Double theValue) { - // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMaxLevel"); ASSERT(myBaseImpl); CORBA::Double oldValue = GetMinSize(); this->GetImpl()->SetMinSize(theValue); @@ -116,7 +111,6 @@ void HexoticPlugin_Hypothesis_i::SetMinSize (CORBA::Double theValue) void HexoticPlugin_Hypothesis_i::SetMaxSize (CORBA::Double theValue) { - // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMaxLevel"); ASSERT(myBaseImpl); CORBA::Double oldValue = GetMaxSize(); this->GetImpl()->SetMaxSize(theValue); @@ -124,9 +118,21 @@ void HexoticPlugin_Hypothesis_i::SetMaxSize (CORBA::Double theValue) SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theValue << " )"; } +void HexoticPlugin_Hypothesis_i::SetGeomApproxAngle(CORBA::Double angle) +{ + CORBA::Double oldValue = GetGeomApproxAngle(); + this->GetImpl()->SetGeomApproxAngle( angle ); + if (angle != oldValue) + SMESH::TPythonDump() << _this() << ".SetGeomApproxAngle( " << angle << " )"; +} + +CORBA::Double HexoticPlugin_Hypothesis_i::GetGeomApproxAngle() +{ + return this->GetImpl()->GetGeomApproxAngle(); +} + void HexoticPlugin_Hypothesis_i::SetHexoticIgnoreRidges (CORBA::Boolean theValue) { - // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticIgnoreRidges"); ASSERT(myBaseImpl); CORBA::Boolean oldValue = GetHexoticIgnoreRidges(); this->GetImpl()->SetHexoticIgnoreRidges(theValue); @@ -136,7 +142,6 @@ void HexoticPlugin_Hypothesis_i::SetHexoticIgnoreRidges (CORBA::Boolean theValue void HexoticPlugin_Hypothesis_i::SetHexoticInvalidElements (CORBA::Boolean theValue) { - // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticInvalidElements"); ASSERT(myBaseImpl); CORBA::Boolean oldValue = GetHexoticInvalidElements(); this->GetImpl()->SetHexoticInvalidElements(theValue); @@ -146,7 +151,6 @@ void HexoticPlugin_Hypothesis_i::SetHexoticInvalidElements (CORBA::Boolean theVa void HexoticPlugin_Hypothesis_i::SetHexoticSharpAngleThreshold (CORBA::Double theValue) { - // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticSharpAngleThreshold"); ASSERT(myBaseImpl); CORBA::Double oldValue = GetHexoticSharpAngleThreshold(); this->GetImpl()->SetHexoticSharpAngleThreshold(theValue); @@ -156,7 +160,6 @@ void HexoticPlugin_Hypothesis_i::SetHexoticSharpAngleThreshold (CORBA::Double th void HexoticPlugin_Hypothesis_i::SetHexoticNbProc (CORBA::Long theValue) { - // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticNbProc"); ASSERT(myBaseImpl); CORBA::Long oldValue = GetHexoticNbProc(); this->GetImpl()->SetHexoticNbProc(theValue); @@ -190,9 +193,50 @@ void HexoticPlugin_Hypothesis_i::SetHexoticWorkingDirectory(const char* path) th SMESH::TPythonDump() << _this() << ".SetHexoticWorkingDirectory( '" << path << "' )"; } +void HexoticPlugin_Hypothesis_i::SetKeepFiles(::CORBA::Boolean toKeep) +{ + if ( GetKeepFiles() != toKeep ) + { + this->GetImpl()->SetKeepFiles(toKeep); + SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )"; + } +} + +::CORBA::Boolean HexoticPlugin_Hypothesis_i::GetKeepFiles() +{ + return this->GetImpl()->GetKeepFiles(); +} + +void HexoticPlugin_Hypothesis_i::SetStandardOutputLog(::CORBA::Boolean logInStandardOutput) +{ + if ( GetStandardOutputLog() != logInStandardOutput ) + { + this->GetImpl()->SetStandardOutputLog(logInStandardOutput); + SMESH::TPythonDump() << _this() << ".SetStandardOutputLog( " << logInStandardOutput << " )"; + } +} + +::CORBA::Boolean HexoticPlugin_Hypothesis_i::GetStandardOutputLog() +{ + return this->GetImpl()->GetStandardOutputLog(); +} + +void HexoticPlugin_Hypothesis_i::SetRemoveLogOnSuccess(::CORBA::Boolean removeLogOnSuccess) +{ + if ( GetRemoveLogOnSuccess() != removeLogOnSuccess ) + { + this->GetImpl()->SetRemoveLogOnSuccess(removeLogOnSuccess); + SMESH::TPythonDump() << _this() << ".SetRemoveLogOnSuccess( " << removeLogOnSuccess << " )"; + } +} + +::CORBA::Boolean HexoticPlugin_Hypothesis_i::GetRemoveLogOnSuccess() +{ + return this->GetImpl()->GetRemoveLogOnSuccess(); +} + void HexoticPlugin_Hypothesis_i::SetHexoticSdMode (CORBA::Long theValue) { - // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticSdMode"); ASSERT(myBaseImpl); CORBA::Long oldValue = GetHexoticSdMode(); this->GetImpl()->SetHexoticSdMode(theValue); @@ -202,7 +246,6 @@ void HexoticPlugin_Hypothesis_i::SetHexoticSdMode (CORBA::Long theValue) void HexoticPlugin_Hypothesis_i::SetHexoticVerbosity (CORBA::Long theValue) { - // MESSAGE("HexoticPlugin_Hypothesis_i::SetVerbosity"); ASSERT(myBaseImpl); CORBA::Long oldValue = GetHexoticVerbosity(); this->GetImpl()->SetHexoticVerbosity(theValue); @@ -212,7 +255,6 @@ void HexoticPlugin_Hypothesis_i::SetHexoticVerbosity (CORBA::Long theValue) void HexoticPlugin_Hypothesis_i::SetHexoticMaxMemory (CORBA::Long theValue) { - // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticMaxMemory"); ASSERT(myBaseImpl); CORBA::Long oldValue = GetHexoticMaxMemory(); this->GetImpl()->SetHexoticMaxMemory(theValue); @@ -220,19 +262,264 @@ void HexoticPlugin_Hypothesis_i::SetHexoticMaxMemory (CORBA::Long theValue) SMESH::TPythonDump() << _this() << ".SetHexoticMaxMemory( " << theValue << " )"; } -void HexoticPlugin_Hypothesis_i::SetTextOptions(const char* theOptions) +void HexoticPlugin_Hypothesis_i::SetOptionValue(const char* optionName, const char* optionValue) + throw (SALOME::SALOME_Exception) { - // MESSAGE("HexoticPlugin_Hypothesis_i::SetTextOptions"); ASSERT(myBaseImpl); - std::string oldValue(GetAdvancedOption()); - this->GetImpl()->SetAdvancedOption(theOptions); - if (theOptions != oldValue) - SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << theOptions << "' )"; + try { + std::string name( optionName ); + if ( !optionValue || !optionValue[0] ) + UnsetOption( optionName ); + + // options having corresponding methods + + else if ( name == "max_memory" ) + SetHexoticMaxMemory( GetImpl()->ToInt( optionValue )); + + else if ( name == "min_level" ) + SetHexesMinLevel( GetImpl()->ToInt( optionValue )); + + else if ( name == "max_level" ) + SetHexesMaxLevel( GetImpl()->ToInt( optionValue )); + + else if ( name == "min_size" ) + SetMinSize( GetImpl()->ToDbl( optionValue )); + + else if ( name == "max_size" ) + SetMaxSize( GetImpl()->ToDbl( optionValue )); + + else if ( name == "ridge_angle" ) + SetHexoticSharpAngleThreshold( GetImpl()->ToDbl( optionValue )); + + else if ( name == "compute_ridges" ) + SetHexoticIgnoreRidges( ! GetImpl()->ToBool( optionValue )); + + else if ( name == "allow_invalid_elements" ) + SetHexoticInvalidElements( GetImpl()->ToBool( optionValue )); + + else if ( name == "max_number_of_threads" ) + SetHexoticNbProc( GetImpl()->ToInt( optionValue )); + + else if ( name == "verbose" ) + SetHexoticVerbosity( GetImpl()->ToInt( optionValue )); + + // advanced options (for backward compatibility) + // else if ( name == "create_tag_on_collision" || + // name == "tiny_edge_respect_geometry" ) + // AddOption( optionName, optionValue ); + + else { + bool valueChanged = true, isDefault; + try { + valueChanged = ( this->GetImpl()->GetOptionValue( name, &isDefault ) != optionValue ); + } + catch ( std::invalid_argument ) { + } + if ( valueChanged ) + { + this->GetImpl()->SetOptionValue(optionName, optionValue); + SMESH::TPythonDump() << _this() << ".SetOptionValue( '" << optionName << "', '" << optionValue << "' )"; + } + } + } catch (const std::invalid_argument& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } +} + +//============================================================================= + +char* HexoticPlugin_Hypothesis_i::GetOptionValue(const char* optionName) + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + try { + bool isDefault; + return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName,&isDefault).c_str()); + } catch (const std::invalid_argument& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } + return 0; +} + +//============================================================================= + +void HexoticPlugin_Hypothesis_i::UnsetOption(const char* optionName) { + ASSERT(myBaseImpl); + if ( !GetImpl()->GetOptionValue( optionName ).empty() ) + { + this->GetImpl()->ClearOption(optionName); + SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )"; + } +} + +//============================================================================= + +HexoticPlugin::string_array* HexoticPlugin_Hypothesis_i::GetOptionValues() +{ + HexoticPlugin::string_array_var result = new HexoticPlugin::string_array(); + + const ::HexoticPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues(); + result->length(opts.size()); + int i=0; + + bool isDefault; + ::HexoticPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin(); + for (; opIt != opts.end(); ++opIt, ++i) + { + std::string name_value_type = opIt->first; + //if (!opIt->second.empty()) + { + name_value_type += ":"; + name_value_type += GetImpl()->GetOptionValue( opIt->first, &isDefault ); + name_value_type += isDefault ? ":0" : ":1"; + } + result[i] = CORBA::string_dup(name_value_type.c_str()); + } + + return result._retn(); +} + +//============================================================================= + +HexoticPlugin::string_array* HexoticPlugin_Hypothesis_i::GetAdvancedOptionValues() +{ + HexoticPlugin::string_array_var result = new HexoticPlugin::string_array(); + + const ::HexoticPlugin_Hypothesis::TOptionValues & custom_opts = this->GetImpl()->GetCustomOptionValues(); + result->length(custom_opts.size()); + int i=0; + + ::HexoticPlugin_Hypothesis::TOptionValues::const_iterator opIt = custom_opts.begin(); + for (; opIt != custom_opts.end(); ++opIt, ++i) { + std::string name_value_type = opIt->first; + if (!opIt->second.empty()) { + name_value_type += ":"; + name_value_type += opIt->second; + name_value_type += ":1"; // user defined + } + result[i] = CORBA::string_dup(name_value_type.c_str()); + } + return result._retn(); +} + +//============================================================================= + +void HexoticPlugin_Hypothesis_i::SetOptionValues(const HexoticPlugin::string_array& options) + throw (SALOME::SALOME_Exception) +{ + for (CORBA::ULong i = 0; i < options.length(); ++i) + { + std::string name_value_type = options[i].in(); + if(name_value_type.empty()) + continue; + size_t colonPos = name_value_type.find(':'); + std::string name, value; + if (colonPos == std::string::npos) // ':' not found + name = name_value_type; + else { + name = name_value_type.substr(0, colonPos); + if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') { + std::string value_type = name_value_type.substr(colonPos + 1); + colonPos = value_type.find(':'); + value = value_type.substr(0, colonPos); + if (colonPos < value_type.size() - 1 && value_type[colonPos] != ' ') + if ( value_type.substr(colonPos + 1) == "0" ) // is default + value.clear(); + } + } + SetOptionValue(name.c_str(), value.c_str()); + } } -void HexoticPlugin_Hypothesis_i::SetAdvancedOption(const char* theOptions) +//============================================================================= + +void HexoticPlugin_Hypothesis_i::SetAdvancedOptionValues(const HexoticPlugin::string_array& options) +{ + SMESH::TPythonDump dump; + + std::string optionsAndValues; + for ( CORBA::ULong i = 0; i < options.length(); ++i) { + std::string name_value_type = options[i].in(); + if(name_value_type.empty()) + continue; + size_t colonPos = name_value_type.find(':'); + std::string name, value; + if (colonPos == std::string::npos) // ':' not found + name = name_value_type; + else { + name = name_value_type.substr(0, colonPos); + if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') { + std::string value_type = name_value_type.substr(colonPos + 1); + colonPos = value_type.find(':'); + value = value_type.substr(0, colonPos); + } + } + AddOption(name.c_str(), value.c_str()); + + optionsAndValues += name + " " + value + " "; + } + + if ( !optionsAndValues.empty() ) + dump << _this() << ".SetAdvancedOptions( '" << optionsAndValues.c_str() << "' )"; +} + +//============================================================================= + +void HexoticPlugin_Hypothesis_i::SetAdvancedOption(const char* optionsAndValues) + throw (SALOME::SALOME_Exception) +{ + if ( !optionsAndValues ) return; + + SMESH::TPythonDump dump; + + std::istringstream strm( optionsAndValues ); + std::istream_iterator sIt( strm ), sEnd; + for ( int nbPairs = 0; sIt != sEnd; ++nbPairs ) + { + std::string option = *sIt; + if ( ++sIt != sEnd ) + { + std::string value = *sIt; + ++sIt; + AddOption( option.c_str(), value.c_str() ); + } + else + { + if ( nbPairs > 0 ) + THROW_SALOME_CORBA_EXCEPTION( "Uneven number of options and values" ,SALOME::BAD_PARAM ); + AddOption( option.c_str(), "" ); + } + } + dump << _this() << ".SetAdvancedOption( '" << optionsAndValues << "' )"; +} + +//============================================================================= + +void HexoticPlugin_Hypothesis_i::AddOption(const char* optionName, const char* optionValue) +{ + ASSERT(myBaseImpl); + bool valueChanged = ( !this->GetImpl()->HasOptionDefined(optionName) || + this->GetImpl()->GetOptionValue(optionName) != optionValue ); + if (valueChanged) { + this->GetImpl()->SetOptionValue(optionName, optionValue); + SMESH::TPythonDump() << _this() << ".SetOptionValue( '" << optionName << "', '" << optionValue << "' )"; + } +} + +//============================================================================= + +char* HexoticPlugin_Hypothesis_i::GetOption(const char* optionName) +{ + ASSERT(myBaseImpl); + return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName).c_str()); +} + +void HexoticPlugin_Hypothesis_i::SetTextOptions(const char* theOptions) { - // MESSAGE("HexoticPlugin_Hypothesis_i::SetAdvancedOption"); ASSERT(myBaseImpl); std::string oldValue(GetAdvancedOption()); this->GetImpl()->SetAdvancedOption(theOptions); @@ -261,7 +548,6 @@ HexoticPlugin::HexoticPluginSizeMapsList* HexoticPlugin_Hypothesis_i::GetSizeMap void HexoticPlugin_Hypothesis_i::SetSizeMapEntry ( const char* theEntry, CORBA::Double theSize ) { -// MESSAGE("HexoticPlugin_Hypothesis_i::SetSizeMapEntry"); bool valueChanged = this->GetImpl()->AddSizeMap(theEntry, theSize); if (valueChanged) SMESH::TPythonDump() << _this() << ".SetSizeMap( "<< theEntry << ", " << theSize << " )"; @@ -269,7 +555,6 @@ void HexoticPlugin_Hypothesis_i::SetSizeMapEntry ( const char* theEntry, CORBA:: void HexoticPlugin_Hypothesis_i::UnsetSizeMapEntry ( const char* theEntry ) { -// MESSAGE("HexoticPlugin_Hypothesis_i::UnsetSizeMapEntry"); bool entryRemoved = this->GetImpl()->UnsetSizeMap(theEntry); if (entryRemoved) SMESH::TPythonDump() << _this() << ".UnsetSizeMap( "<< theEntry << " )"; @@ -277,7 +562,6 @@ void HexoticPlugin_Hypothesis_i::UnsetSizeMapEntry ( const char* theEntry ) void HexoticPlugin_Hypothesis_i::SetSizeMap (const GEOM::GEOM_Object_ptr theGeomObj, const double theSize) { -// MESSAGE("HexoticPlugin_Hypothesis_i::SetSizeMap"); ASSERT(myBaseImpl); std::string entry = theGeomObj->GetStudyEntry(); SetSizeMapEntry( entry.c_str(), theSize); @@ -285,7 +569,6 @@ void HexoticPlugin_Hypothesis_i::SetSizeMap (const GEOM::GEOM_Object_ptr theGeom void HexoticPlugin_Hypothesis_i::UnsetSizeMap (const GEOM::GEOM_Object_ptr theGeomObj) { -// MESSAGE("HexoticPlugin_Hypothesis_i::UnsetSizeMap"); ASSERT(myBaseImpl); std::string entry = theGeomObj->GetStudyEntry(); UnsetSizeMapEntry( entry.c_str()); @@ -293,7 +576,6 @@ void HexoticPlugin_Hypothesis_i::UnsetSizeMap (const GEOM::GEOM_Object_ptr theGe void HexoticPlugin_Hypothesis_i::SetNbLayers(CORBA::Long theVal) { - // MESSAGE("HexoticPlugin_Hypothesis_i::SetNbLayers"); ASSERT(myBaseImpl); CORBA::Long oldValue = GetNbLayers(); this->GetImpl()->SetNbLayers(theVal); @@ -303,7 +585,6 @@ void HexoticPlugin_Hypothesis_i::SetNbLayers(CORBA::Long theVal) void HexoticPlugin_Hypothesis_i::SetFirstLayerSize(CORBA::Double theVal) { - // MESSAGE("HexoticPlugin_Hypothesis_i::SetFirstLayerSize"); ASSERT(myBaseImpl); CORBA::Double oldValue = GetFirstLayerSize(); this->GetImpl()->SetFirstLayerSize(theVal); @@ -313,7 +594,6 @@ void HexoticPlugin_Hypothesis_i::SetFirstLayerSize(CORBA::Double theVal) void HexoticPlugin_Hypothesis_i::SetDirection(CORBA::Boolean theVal) { - // MESSAGE("HexoticPlugin_Hypothesis_i::SetDirection"); ASSERT(myBaseImpl); CORBA::Boolean oldValue = GetDirection(); this->GetImpl()->SetDirection(theVal); @@ -323,7 +603,6 @@ void HexoticPlugin_Hypothesis_i::SetDirection(CORBA::Boolean theVal) void HexoticPlugin_Hypothesis_i::SetGrowth(CORBA::Double theVal) { - // MESSAGE("HexoticPlugin_Hypothesis_i::SetGrowth"); ASSERT(myBaseImpl); CORBA::Double oldValue = GetGrowth(); this->GetImpl()->SetGrowth(theVal); @@ -333,7 +612,6 @@ void HexoticPlugin_Hypothesis_i::SetGrowth(CORBA::Double theVal) void HexoticPlugin_Hypothesis_i::SetFacesWithLayers(const ::SMESH::long_array& theVal) { - // MESSAGE("HexoticPlugin_Hypothesis_i::SetFacesWithLayers"); std::vector ids( theVal.length() ); for ( unsigned i = 0; i < ids.size(); ++i ) ids[i] = theVal[i]; @@ -345,7 +623,6 @@ void HexoticPlugin_Hypothesis_i::SetFacesWithLayers(const ::SMESH::long_array& t void HexoticPlugin_Hypothesis_i::SetImprintedFaces(const ::SMESH::long_array& theVal) { - // MESSAGE("HexoticPlugin_Hypothesis_i::SetImprintedFaces"); std::vector ids( theVal.length() ); for ( unsigned i = 0; i < ids.size(); ++i ) ids[i] = theVal[i]; @@ -381,56 +658,48 @@ void HexoticPlugin_Hypothesis_i::SetImprintedFaces(const ::SMESH::long_array& th CORBA::Long HexoticPlugin_Hypothesis_i::GetHexesMinLevel() { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexesMinLevel"); ASSERT(myBaseImpl); return this->GetImpl()->GetHexesMinLevel(); } CORBA::Long HexoticPlugin_Hypothesis_i::GetHexesMaxLevel() { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexesMaxLevel"); ASSERT(myBaseImpl); return this->GetImpl()->GetHexesMaxLevel(); } CORBA::Double HexoticPlugin_Hypothesis_i::GetMinSize() { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetMinSize"); ASSERT(myBaseImpl); return this->GetImpl()->GetMinSize(); } CORBA::Double HexoticPlugin_Hypothesis_i::GetMaxSize() { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetMaxSize"); ASSERT(myBaseImpl); return this->GetImpl()->GetMaxSize(); } CORBA::Boolean HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges() { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges"); ASSERT(myBaseImpl); return this->GetImpl()->GetHexoticIgnoreRidges(); } CORBA::Boolean HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements() { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements"); ASSERT(myBaseImpl); return this->GetImpl()->GetHexoticInvalidElements(); } CORBA::Double HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold() { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold"); ASSERT(myBaseImpl); return this->GetImpl()->GetHexoticSharpAngleThreshold(); } CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticNbProc() { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticNbProc"); ASSERT(myBaseImpl); return this->GetImpl()->GetHexoticNbProc(); } @@ -443,69 +712,59 @@ char* HexoticPlugin_Hypothesis_i::GetHexoticWorkingDirectory() CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticSdMode () { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticSdMode"); ASSERT(myBaseImpl); return this->GetImpl()->GetHexoticSdMode(); } CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticVerbosity() { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetVerbosity"); ASSERT(myBaseImpl); return this->GetImpl()->GetHexoticVerbosity(); } CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticMaxMemory() { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticMaxMemory"); ASSERT(myBaseImpl); return this->GetImpl()->GetHexoticMaxMemory(); } char* HexoticPlugin_Hypothesis_i::GetAdvancedOption() { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetAdvancedOption"); ASSERT(myBaseImpl); - return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() ); + return CORBA::string_dup( this->GetImpl()->GetAdvancedOption( /*customOnly=*/true ).c_str() ); } char* HexoticPlugin_Hypothesis_i::GetTextOptions() { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetTextOptions"); ASSERT(myBaseImpl); return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() ); } CORBA::Long HexoticPlugin_Hypothesis_i::GetNbLayers() { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetNbLayers"); ASSERT(myBaseImpl); return this->GetImpl()->GetNbLayers(); } CORBA::Double HexoticPlugin_Hypothesis_i::GetFirstLayerSize() { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetFirstLayerSize"); ASSERT(myBaseImpl); return this->GetImpl()->GetFirstLayerSize(); } CORBA::Boolean HexoticPlugin_Hypothesis_i::GetDirection() { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetDirection"); ASSERT(myBaseImpl); return this->GetImpl()->GetDirection(); } CORBA::Double HexoticPlugin_Hypothesis_i::GetGrowth() { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetGrowth"); ASSERT(myBaseImpl); return this->GetImpl()->GetGrowth(); } SMESH::long_array* HexoticPlugin_Hypothesis_i::GetFacesWithLayers() { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetFacesWithLayers"); ASSERT(myBaseImpl); std::vector idsVec = this->GetImpl()->GetFacesWithLayers(); SMESH::long_array_var ids = new SMESH::long_array; @@ -517,7 +776,6 @@ SMESH::long_array* HexoticPlugin_Hypothesis_i::GetFacesWithLayers() SMESH::long_array* HexoticPlugin_Hypothesis_i::GetImprintedFaces() { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetImprintedFaces"); ASSERT(myBaseImpl); std::vector idsVec = this->GetImpl()->GetImprintedFaces(); SMESH::long_array_var ids = new SMESH::long_array; @@ -535,7 +793,6 @@ SMESH::long_array* HexoticPlugin_Hypothesis_i::GetImprintedFaces() //============================================================================= ::HexoticPlugin_Hypothesis* HexoticPlugin_Hypothesis_i::GetImpl() { - // MESSAGE("HexoticPlugin_Hypothesis_i::GetImpl"); return (::HexoticPlugin_Hypothesis*)myBaseImpl; } diff --git a/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.hxx b/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.hxx index 8d69219..241331c 100644 --- a/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.hxx +++ b/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.hxx @@ -59,21 +59,33 @@ class HEXOTICPLUGIN_EXPORT HexoticPlugin_Hypothesis_i: void SetMaxSize(CORBA::Double theVal); CORBA::Double GetMaxSize(); + void SetGeomApproxAngle(CORBA::Double angle); + CORBA::Double GetGeomApproxAngle(); + void SetHexoticIgnoreRidges(CORBA::Boolean theVal); CORBA::Boolean GetHexoticIgnoreRidges(); - + void SetHexoticInvalidElements(CORBA::Boolean theVal); CORBA::Boolean GetHexoticInvalidElements(); - + void SetHexoticSharpAngleThreshold(CORBA::Double theVal); CORBA::Double GetHexoticSharpAngleThreshold(); - + void SetHexoticNbProc(CORBA::Long theVal); CORBA::Long GetHexoticNbProc(); - + void SetHexoticWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception ); char* GetHexoticWorkingDirectory(); + void SetKeepFiles(::CORBA::Boolean toKeep); + ::CORBA::Boolean GetKeepFiles(); + + void SetStandardOutputLog(::CORBA::Boolean logInStandardOutput); + ::CORBA::Boolean GetStandardOutputLog(); + + void SetRemoveLogOnSuccess(::CORBA::Boolean removeLogOnSuccess); + ::CORBA::Boolean GetRemoveLogOnSuccess(); + void SetHexoticSdMode(CORBA::Long value); CORBA::Long GetHexoticSdMode(); @@ -82,15 +94,27 @@ class HEXOTICPLUGIN_EXPORT HexoticPlugin_Hypothesis_i: void SetHexoticMaxMemory(CORBA::Long theVal); CORBA::Long GetHexoticMaxMemory(); - - void SetAdvancedOption(const char* theOptions); + + void SetAdvancedOption(const char* theOptions) throw (SALOME::SALOME_Exception); char* GetAdvancedOption(); void SetTextOptions(const char* theOptions); // obsolete char* GetTextOptions(); + void SetOptionValue(const char* optionName, const char* optionValue) throw (SALOME::SALOME_Exception); + char* GetOptionValue(const char* optionName) throw (SALOME::SALOME_Exception); + void UnsetOption(const char* optionName); + + HexoticPlugin::string_array* GetOptionValues(); + HexoticPlugin::string_array* GetAdvancedOptionValues(); + + void SetOptionValues(const HexoticPlugin::string_array& options) throw (SALOME::SALOME_Exception); + void SetAdvancedOptionValues(const HexoticPlugin::string_array& options); + + void AddOption(const char* optionName, const char* optionValue); + char* GetOption(const char* optionName); void SetSizeMapEntry(const char* theEntry, CORBA::Double theSize); void UnsetSizeMapEntry(const char* theEntry); - + void SetSizeMap(GEOM::GEOM_Object_ptr theGeomObj, double theSize); void UnsetSizeMap(GEOM::GEOM_Object_ptr theGeomObj); HexoticPlugin::HexoticPluginSizeMapsList* GetSizeMaps ();