From 57bf55dc1f86e410f88da48e87d99e1380ed1e5e Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 16 Dec 2014 14:16:15 +0300 Subject: [PATCH] 22763: [EDF] Shape processing For DropSmallSolids operator, fix some bugs: - Add missing default values of parameters in a resource file - Add workaround to ShapeProcess functionality to process properly optional parameters (the case for DropSmallSolids operator) - Small redesign of RepairGUI::ShowStatistics() function --- resources/ShHealing | 9 ++++ src/GEOMImpl/GEOMImpl_IHealingOperations.cxx | 5 ++ src/RepairGUI/RepairGUI.cxx | 17 ++++--- src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx | 53 ++++++++++++-------- src/ShHealOper/ShHealOper_ShapeProcess.cxx | 8 +-- 5 files changed, 59 insertions(+), 33 deletions(-) diff --git a/resources/ShHealing b/resources/ShHealing index 087f7a05b..864e192a1 100644 --- a/resources/ShHealing +++ b/resources/ShHealing @@ -18,6 +18,10 @@ ShapeProcess.FixFaceSize.Tolerance : 0.05 ShapeProcess.DropSmallEdges.Tolerance3d : 0.05 +ShapeProcess.DropSmallSolids.WidthFactorThreshold : 1 +ShapeProcess.DropSmallSolids.VolumeThreshold : 1000 +ShapeProcess.DropSmallSolids.MergeSolids : 1 + ShapeProcess.BSplineRestriction.SurfaceMode : 1 ShapeProcess.BSplineRestriction.Curve3dMode : 1 ShapeProcess.BSplineRestriction.Curve2dMode : 1 @@ -210,6 +214,11 @@ ShapeProcess.SameParameter.Tolerance3d : 1.e-7 ! DropSmallEdges : Eliminate small edges by removing or merging with neighbour ! DropSmallEdges.Tolerance3d : Tolerance (3d) +! DropSmallSolids : Eliminate small solids by a) removing them or b) absorbing them by adjacent larger solids. +! DropSmallSolids.WidthFactorThreshold : Maximum value of 2V/S of a solid where V is volume and S is surface area of the solid. +! DropSmallSolids.VolumeThreshold : Maximum volume of a solid. +! DropSmallSolids.MergeSolids : If false, solids are removed; otherwise, solids are merged to adjacent larger solids. + ! FixShape.Tolerance3d : Tolerance (3d) for fixing of shape. ! FixShape.MaxTolerance3d : Maximal possible value of increasing of tolerance during fixing. ! FixShape.MinTolerance3d : Minimal value of tolerance. diff --git a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx index 3b8ab1147..865867dac 100644 --- a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx @@ -275,6 +275,11 @@ bool GEOMImpl_IHealingOperations::GetParameters (const std::string theOperation, } else if( theOperation == "DropSmallEdges" ) { theParams.push_back( "DropSmallEdges.Tolerance3d" ); + } else if( theOperation == "DropSmallSolids" ) { + theParams.push_back( "DropSmallSolids.WidthFactorThreshold" ); + theParams.push_back( "DropSmallSolids.VolumeThreshold" ); + theParams.push_back( "DropSmallSolids.MergeSolids" ); + } else if( theOperation == "BSplineRestriction" ) { theParams.push_back( "BSplineRestriction.SurfaceMode" ); theParams.push_back( "BSplineRestriction.Curve3dMode" ); diff --git a/src/RepairGUI/RepairGUI.cxx b/src/RepairGUI/RepairGUI.cxx index b65327e91..b8e95235e 100644 --- a/src/RepairGUI/RepairGUI.cxx +++ b/src/RepairGUI/RepairGUI.cxx @@ -29,6 +29,7 @@ #include #include +#include #include #include "RepairGUI_SewingDlg.h" // Method SEWING @@ -147,8 +148,7 @@ namespace StatsDlg::StatsDlg( GEOM::ModifStatistics_var stats, QWidget* parent ): QDialog( parent ) { - setModal( false ); - setAttribute( Qt::WA_DeleteOnClose, true ); + setModal( true ); setWindowTitle( tr( "GEOM_HEALING_STATS_TITLE" ) ); setMinimumWidth( 500 ); @@ -174,11 +174,12 @@ namespace // helpBtn->setAutoDefault( true ); QHBoxLayout* btnLayout = new QHBoxLayout; - btnLayout->setMargin( 9 ); + btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 ); + btnLayout->addStretch(); btnLayout->addWidget( okBtn ); - btnLayout->addStretch( 10 ); + btnLayout->addStretch(); // btnLayout->addWidget( helpBtn ); QVBoxLayout* aLay = new QVBoxLayout( this ); @@ -196,7 +197,6 @@ namespace connect( okBtn, SIGNAL( clicked() ), this, SLOT( reject() )); //connect( helpBtn, SIGNAL( clicked() ), this, SLOT( help() )); - } } @@ -213,6 +213,9 @@ void RepairGUI::ShowStatistics( GEOM::GEOM_IHealingOperations_var anOper, QWidge if ( ! &stats.in() || stats->length() == 0 ) return; - StatsDlg* dlg = new StatsDlg( stats, parent ); - dlg->exec(); + SUIT_OverrideCursor wc; + wc.suspend(); + + StatsDlg dlg( stats, parent ); + dlg.exec(); } diff --git a/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx b/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx index 7933c1552..6c3cdfa4c 100755 --- a/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx +++ b/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx @@ -162,10 +162,10 @@ void RepairGUI_ShapeProcessDlg::init() myDropSmallSolidsVolChk = new QCheckBox( tr("VOLUME_TOL"), w ); myDropSmallSolidsWidTol = new SalomeApp_DoubleSpinBox( w ); myDropSmallSolidsVolTol = new SalomeApp_DoubleSpinBox( w ); - initSpinBox( myDropSmallSolidsWidTol, 0., 100., 1e-7, "len_tol_precision" ); - initSpinBox( myDropSmallSolidsVolTol, 0., 100., 1e-7, "len_tol_precision" ); - myDropSmallSolidsWidTol->setValue( 1e-7 ); - myDropSmallSolidsVolTol->setValue( 1e-7 ); + initSpinBox( myDropSmallSolidsWidTol, 0., 1e3, 1., "len_tol_precision" ); + initSpinBox( myDropSmallSolidsVolTol, 0., 1e9, 1., "len_tol_precision" ); + myDropSmallSolidsWidTol->setValue( 1 ); + myDropSmallSolidsVolTol->setValue( 1e3 ); myDropSmallSolidsVolChk->setChecked( true ); myDropSmallSolidsWidTol->setEnabled( false ); myDropSmallSolidsMergeChk = new QCheckBox( tr("TO_MERGE_SOLIDS"), w ); @@ -563,14 +563,23 @@ void RepairGUI_ShapeProcessDlg::setValue( QWidget* theControl, const QString& th QString RepairGUI_ShapeProcessDlg::getValue( QWidget* theControl ) const { if ( theControl ) { - if ( qobject_cast( theControl )) + if ( qobject_cast( theControl )) { + if ( ( theControl == myDropSmallSolidsWidTol || theControl == myDropSmallSolidsVolTol ) && !theControl->isEnabled() ) { + // VSR: stupid workaround about ShapeProcessAPI: + // specific processing for optional parameters of DropSmallSolids operator + return QString::number( Precision::Infinite() ); + } return QString::number( qobject_cast( theControl )->value() ); - else if ( qobject_cast( theControl )) + } + else if ( qobject_cast( theControl )) { return QString::number( qobject_cast( theControl )->value() ); - else if ( qobject_cast( theControl )) + } + else if ( qobject_cast( theControl )) { return qobject_cast( theControl )->currentText(); - else if ( qobject_cast( theControl )) + } + else if ( qobject_cast( theControl )) { return qobject_cast( theControl )->isChecked() ? "1" : "0"; + } } return 0; } @@ -705,17 +714,14 @@ bool RepairGUI_ShapeProcessDlg::execute( ObjectList& objects ) GEOM::string_array* RepairGUI_ShapeProcessDlg::getActiveOperators() { GEOM::string_array_var anOperators = new GEOM::string_array(); - QStringList aCheckedList; - for ( int i = 0; i < myOpList->count(); i++ ) { + int j = 0, n = myOpList->count(); + anOperators->length( n ); + for ( int i = 0; i < n; i++ ) { if ( myOpList->item( i )->checkState() == Qt::Checked ) - aCheckedList << myOpList->item( i )->text(); + anOperators[j++] = myOpList->item( i )->text().toLatin1().constData(); } - - anOperators->length( aCheckedList.count() ); - - for ( int i = 0; i < aCheckedList.count(); i++ ) - anOperators[i] = aCheckedList[i].toLatin1().constData(); + anOperators->length( j ); return anOperators._retn(); } @@ -732,7 +738,7 @@ QWidget* RepairGUI_ShapeProcessDlg::getControl( const QString& theParam ) else if ( theParam == "FixFaceSize.Tolerance" ) return myFixFaceSizeTol; else if ( theParam == "DropSmallEdges.Tolerance3d" ) return myDropSmallEdgesTol3D; else if ( theParam == "DropSmallSolids.WidthFactorThreshold" ) return myDropSmallSolidsWidTol; - else if ( theParam == "DropSmallSolids.VolumeThreshold" ) return myDropSmallSolidsWidTol; + else if ( theParam == "DropSmallSolids.VolumeThreshold" ) return myDropSmallSolidsVolTol; else if ( theParam == "DropSmallSolids.MergeSolids" ) return myDropSmallSolidsMergeChk; else if ( theParam == "BSplineRestriction.SurfaceMode" ) return myBSplineSurfModeChk; else if ( theParam == "BSplineRestriction.Curve3dMode" ) return myBSpline3DCurveChk; @@ -824,18 +830,21 @@ GEOM::string_array* RepairGUI_ShapeProcessDlg::getParameters( const GEOM::string // calculate the length of parameters for ( i = 0, j = 0; i < theOperators.length(); i++ ) - j += myValMap[ QString( theOperators[i] ) ].size(); + j += myValMap[ QString( theOperators[i].in() ) ].size(); // set the new length of paremeters aParams->length( j ); // fill the parameters for ( i = 0, j = 0; i < theOperators.length(); i++ ) { - QStringList aValLst = myValMap[ QString( theOperators[i] ) ]; - for ( QStringList::Iterator it = aValLst.begin(); it != aValLst.end(); ++it ) - aParams[j++] = CORBA::string_dup( (*it).toLatin1().constData() ); + QStringList aParamLst = myValMap[ QString( theOperators[i].in() ) ]; + foreach ( QString aParam, aParamLst ) { + aParams[j++] = CORBA::string_dup( aParam.toLatin1().constData() ); + } } + aParams->length( j ); + return aParams._retn(); } @@ -851,7 +860,7 @@ GEOM::string_array* RepairGUI_ShapeProcessDlg::getValues( const GEOM::string_arr for ( int i = 0; i < theParams.length(); i++ ) { QWidget* aCtrl = getControl( (const char*)theParams[i] ); - if ( aCtrl && aCtrl->isEnabled() ) + if ( aCtrl ) aValues[i] = get_convert( (const char*)theParams[i], getValue( aCtrl )); } diff --git a/src/ShHealOper/ShHealOper_ShapeProcess.cxx b/src/ShHealOper/ShHealOper_ShapeProcess.cxx index 26905677a..7ce0c9573 100644 --- a/src/ShHealOper/ShHealOper_ShapeProcess.cxx +++ b/src/ShHealOper/ShHealOper_ShapeProcess.cxx @@ -163,12 +163,12 @@ void ShHealOper_ShapeProcess::SetParameter(const TCollection_AsciiString& theNam TCollection_AsciiString anameParam(myPrefix); anameParam += "."; anameParam+= theNameParam; - if(theVal.IsIntegerValue()) - myOperations.Context()->ResourceManager()-> - SetResource(anameParam.ToCString(),theVal.IntegerValue()); - else if(theVal.IsRealValue()) + if(theVal.IsRealValue()) myOperations.Context()->ResourceManager()-> SetResource(anameParam.ToCString(),theVal.RealValue()); + else if(theVal.IsIntegerValue()) + myOperations.Context()->ResourceManager()-> + SetResource(anameParam.ToCString(),theVal.IntegerValue()); else myOperations.Context()->ResourceManager()-> SetResource(anameParam.ToCString(),theVal.ToCString()); -- 2.39.2