From: eap Date: Thu, 11 Dec 2014 17:53:33 +0000 (+0300) Subject: 22763: [EDF] Shape processing X-Git-Tag: V7_6_0a1~60^2~19 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e22e35a47516e2c1bd9bb7c57391381b84fd2e75;p=modules%2Fgeom.git 22763: [EDF] Shape processing Add DropSmallSolids operator --- diff --git a/doc/salome/gui/GEOM/images/repair1.png b/doc/salome/gui/GEOM/images/repair1.png old mode 100755 new mode 100644 index 7347daac0..5e0ee76b6 Binary files a/doc/salome/gui/GEOM/images/repair1.png and b/doc/salome/gui/GEOM/images/repair1.png differ diff --git a/doc/salome/gui/GEOM/input/shape_processing_operation.doc b/doc/salome/gui/GEOM/input/shape_processing_operation.doc index aa97ec32f..c92d48b8c 100644 --- a/doc/salome/gui/GEOM/input/shape_processing_operation.doc +++ b/doc/salome/gui/GEOM/input/shape_processing_operation.doc @@ -51,11 +51,27 @@ spots and strips. possible face size.
  • Drop Small Edges (DropSmallEdges) - removes edges, which -merge with neighbouring edges.
  • +merge with neighboring edges. +
  • Drop Small Solids (DropSmallSolids) - either removes small + solids or merges them with neighboring ones.
  • + +If the both tolerances are activated a solid is considered small if +it meets the both criteria.
  • Split Angle (SplitAngle) - splits faces based on conical surfaces, surfaces of revolution and cylindrical surfaces in segments using a certain angle.
  • diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 31679839b..8f7d8a97a 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -6716,6 +6716,18 @@ Please close this message box and select edges for gluing Enabling this option may result in a very time-consuming operation for some input shapes. Would you like to continue? + + WIDTH_FACTOR_TOL + Width factor tol. + + + VOLUME_TOL + Volume tol. + + + TO_MERGE_SOLIDS + To merge solids + GEOMToolsGUI_DeleteDlg diff --git a/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx b/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx index e05f008d3..7933c1552 100755 --- a/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx +++ b/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx @@ -83,15 +83,15 @@ void RepairGUI_ShapeProcessDlg::init() initParamsValues(); initSelection(); - setWindowTitle( tr( "GEOM_SHAPEPROCESS_TITLE" ) ); + setWindowTitle( tr( "GEOM_SHAPEPROCESS_TITLE" )); mainFrame()->GroupConstructors->hide(); // select widget on the top mySelectWdgt = new DlgRef_1Sel( centralWidget() ); - mySelectWdgt->GroupBox1->setTitle( tr( "GEOM_SHAPE" ) ); - mySelectWdgt->TextLabel1->setText( tr( "GEOM_SELECTED_OBJECTS" ) ); - mySelectWdgt->PushButton1->setIcon( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); + mySelectWdgt->GroupBox1->setTitle( tr( "GEOM_SHAPE" )); + mySelectWdgt->TextLabel1->setText( tr( "GEOM_SELECTED_OBJECTS" )); + mySelectWdgt->PushButton1->setIcon( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ))); mySelectWdgt->LineEdit1->setReadOnly( true ); // layout the two group boxes in the middle, add a list of operations @@ -100,7 +100,7 @@ void RepairGUI_ShapeProcessDlg::init() // operations list widget myOpList = new QListWidget( anOperGr ); myOpList->setSortingEnabled( false ); - myOpList->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); + myOpList->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding )); QVBoxLayout* aOperLay = new QVBoxLayout( anOperGr ); aOperLay->setMargin( 9 ); @@ -109,7 +109,7 @@ void RepairGUI_ShapeProcessDlg::init() QGroupBox* aParamsGr = new QGroupBox( tr( "GEOM_PARAMETERS" ), centralWidget() ); // add a widget stack to the parameters group box - QStackedLayout* aStack = new QStackedLayout( aParamsGr ); + myStack = new QStackedLayout( aParamsGr ); // continueties values.. QStringList aContinueties = QString( "C0,G1,C1,G2,C2,C3,CN" ).split( "," ); @@ -152,6 +152,32 @@ void RepairGUI_ShapeProcessDlg::init() aLay->addWidget( myFixFaceSizeTol, 0, 1 ); aLay->setRowStretch( aLay->rowCount(), 5 ); } + else if ( myOpLst[i] == "DropSmallSolids" ) { + // DropSmallSolids + w = new QWidget( aParamsGr ); + QGridLayout* aLay = new QGridLayout( w ); + aLay->setMargin( 9 ); aLay->setSpacing( 6 ); + + myDropSmallSolidsWidChk = new QCheckBox( tr("WIDTH_FACTOR_TOL"), w ); + 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 ); + myDropSmallSolidsVolChk->setChecked( true ); + myDropSmallSolidsWidTol->setEnabled( false ); + myDropSmallSolidsMergeChk = new QCheckBox( tr("TO_MERGE_SOLIDS"), w ); + + aLay->addWidget( myDropSmallSolidsWidChk, 0, 0 ); + aLay->addWidget( myDropSmallSolidsWidTol, 0, 1 ); + aLay->addWidget( myDropSmallSolidsVolChk, 1, 0 ); + aLay->addWidget( myDropSmallSolidsVolTol, 1, 1 ); + aLay->addWidget( myDropSmallSolidsMergeChk, 2, 0, 1, 2 ); + + aLay->setRowStretch( aLay->rowCount(), 5 ); + } else if ( myOpLst[i] == "DropSmallEdges" ) { // DropSmallEdges w = new QWidget( aParamsGr ); @@ -295,7 +321,7 @@ void RepairGUI_ShapeProcessDlg::init() else { w = new QWidget( aParamsGr ); // dumb widget } - aStack->insertWidget( i, w ); + myStack->insertWidget( i, w ); } QGridLayout* layout = new QGridLayout( centralWidget() ); @@ -305,25 +331,30 @@ void RepairGUI_ShapeProcessDlg::init() layout->addWidget( aParamsGr, 1, 1 ); // signals and slots connections - connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( onOk() ) ); - connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( onApply() ) ); + connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( onOk() )); + connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( onApply() )); - connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( selectionChanged() ) ); + connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ))->selectionMgr(), + SIGNAL( currentSelectionChanged() ), this, SLOT( selectionChanged() )); - connect( mySelectWdgt->PushButton1, SIGNAL( clicked() ), this, SLOT( selectClicked() ) ); - connect( mySelectWdgt->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( lineEditReturnPressed() ) ); + connect( mySelectWdgt->PushButton1, SIGNAL( clicked() ), this, SLOT( selectClicked() )); + connect( mySelectWdgt->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( lineEditReturnPressed() )); - connect( myToBezierSurfModeChk, SIGNAL( toggled( bool ) ), this, SLOT( advOptionToggled( bool ) ) ); + connect( myToBezierSurfModeChk, SIGNAL( toggled( bool )), this, SLOT( advOptionToggled( bool ))); + connect( myDropSmallSolidsWidChk, SIGNAL( toggled( bool )), this, SLOT( advOptionToggled( bool ))); + connect( myDropSmallSolidsVolChk, SIGNAL( toggled( bool )), this, SLOT( advOptionToggled( bool ))); - connect( myOpList, SIGNAL( currentRowChanged( int ) ), aStack, SLOT( setCurrentIndex( int ) ) ); + connect( myOpList, SIGNAL( currentRowChanged( int )), myStack, SLOT( setCurrentIndex( int ))); + connect( myOpList, SIGNAL( itemChanged( QListWidgetItem* )), this, SLOT( operatorChecked( QListWidgetItem* ))); adjustSize(); loadDefaults(); // init dialog fields with values from resource file //myOpList->setCurrentRow( myOpList->findItem( 0 ); reset(); - initName( tr( "PROCESS_SHAPE_NEW_OBJ_NAME" ) ); + myStack->setCurrentIndex( 0 ); + + initName( tr( "PROCESS_SHAPE_NEW_OBJ_NAME" )); selectionChanged(); } @@ -373,14 +404,14 @@ void RepairGUI_ShapeProcessDlg::selectionChanged() myObjects->length(aSelList.Extent()); for (SALOME_ListIteratorOfListIO anIt (aSelList); anIt.More(); anIt.Next()) { GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value() ); - if ( !CORBA::is_nil( aSelectedObject ) ) + if ( !CORBA::is_nil( aSelectedObject )) myObjects[i++] = aSelectedObject; } myObjects->length( i ); if ( i == 1 ) - mySelectWdgt->LineEdit1->setText( GEOMBase::GetName( myObjects[0] ) ); + mySelectWdgt->LineEdit1->setText( GEOMBase::GetName( myObjects[0] )); else if ( i > 0 ) - mySelectWdgt->LineEdit1->setText( QString::number( i ) + "_" + tr( "GEOM_OBJECTS" ) ); + mySelectWdgt->LineEdit1->setText( QString::number( i ) + "_" + tr( "GEOM_OBJECTS" )); } @@ -413,8 +444,8 @@ void RepairGUI_ShapeProcessDlg::lineEditReturnPressed() void RepairGUI_ShapeProcessDlg::activate() { GEOMBase_Skeleton::ActivateThisDialog(); - connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication( ) ))->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( selectionChanged() ) ); + connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication( )))->selectionMgr(), + SIGNAL( currentSelectionChanged() ), this, SLOT( selectionChanged() )); reset(); //myGeomGUI->SetState( 0 ); @@ -451,7 +482,7 @@ void RepairGUI_ShapeProcessDlg::reset() //================================================================================= const char* get_convert( const char* theParam, const QString& theValue ) { - if ( !strcmp( theParam, "SplitAngle.Angle" ) ) { + if ( !strcmp( theParam, "SplitAngle.Angle" )) { double doubleValue = theValue.toDouble() * M_PI / 180.; return CORBA::string_dup( QString::number( doubleValue ).toLatin1().constData() ); } @@ -464,7 +495,7 @@ const char* get_convert( const char* theParam, const QString& theValue ) //================================================================================= QString set_convert( const char* theParam, const char* theValue ) { - if ( !strcmp( theParam, "SplitAngle.Angle" ) ) { + if ( !strcmp( theParam, "SplitAngle.Angle" )) { Kernel_Utils::Localizer loc; double doubleValue = atof( theValue ) * 180. / M_PI; return QString::number( doubleValue ); @@ -502,7 +533,7 @@ void RepairGUI_ShapeProcessDlg::loadDefaults() for ( int j = 0; j < aParams->length(); j++ ) { QWidget* aCtrl = getControl( (const char*)aParams[j] ); - setValue( aCtrl, set_convert( (const char*)aParams[j], aValues[j] ) ); + setValue( aCtrl, set_convert( (const char*)aParams[j], aValues[j] )); } } } @@ -514,13 +545,13 @@ void RepairGUI_ShapeProcessDlg::loadDefaults() void RepairGUI_ShapeProcessDlg::setValue( QWidget* theControl, const QString& theValue ) { if ( theControl && !theValue.isNull() ) { - if ( qobject_cast( theControl ) ) + if ( qobject_cast( theControl )) qobject_cast( theControl )->setValue( theValue.toDouble() ); - else if ( qobject_cast( theControl ) ) + else if ( qobject_cast( theControl )) qobject_cast( theControl )->setValue( theValue.toInt() ); - else if ( qobject_cast( theControl ) ) + else if ( qobject_cast( theControl )) qobject_cast( theControl )->setEditText( theValue ); - else if ( qobject_cast( theControl ) ) + else if ( qobject_cast( theControl )) qobject_cast( theControl )->setChecked( theValue.toInt() != 0 ); } } @@ -532,13 +563,13 @@ 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 )) 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; @@ -551,9 +582,9 @@ QString RepairGUI_ShapeProcessDlg::getValue( QWidget* theControl ) const QString RepairGUI_ShapeProcessDlg::getText( QWidget* theControl ) const { if ( theControl ) { - if ( qobject_cast( theControl ) ) + if ( qobject_cast( theControl )) return qobject_cast( theControl )->text(); - else if ( qobject_cast( theControl ) ) + else if ( qobject_cast( theControl )) return qobject_cast( theControl )->text(); } return QString::null; @@ -583,9 +614,10 @@ bool RepairGUI_ShapeProcessDlg::isValid( QString& msg ) while( aListIter.hasNext() ) { const QString& aParam = aListIter.next(); QWidget* aControl = getControl( aParam ); - if ( qobject_cast( aControl ) ) + if ( !aControl->isEnabled() ) continue; + if ( qobject_cast( aControl )) ok = qobject_cast( aControl )->isValid( msg, !IsPreview() ) && ok; - else if ( qobject_cast( aControl ) ) + else if ( qobject_cast( aControl )) ok = qobject_cast( aControl )->isValid( msg, !IsPreview() ) && ok; } } @@ -699,6 +731,9 @@ QWidget* RepairGUI_ShapeProcessDlg::getControl( const QString& theParam ) else if ( theParam == "SplitClosedFaces.NbSplitPoints" ) return mySplitClosedFacesNum; 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.MergeSolids" ) return myDropSmallSolidsMergeChk; else if ( theParam == "BSplineRestriction.SurfaceMode" ) return myBSplineSurfModeChk; else if ( theParam == "BSplineRestriction.Curve3dMode" ) return myBSpline3DCurveChk; else if ( theParam == "BSplineRestriction.Curve2dMode" ) return myBSpline2DCurveChk; @@ -740,6 +775,11 @@ void RepairGUI_ShapeProcessDlg::initParamsValues() myOpLst << "DropSmallEdges"; myValMap["DropSmallEdges"] << "DropSmallEdges.Tolerance3d"; + myOpLst << "DropSmallSolids"; + myValMap["DropSmallSolids"] << "DropSmallSolids.WidthFactorThreshold"; + myValMap["DropSmallSolids"] << "DropSmallSolids.VolumeThreshold"; + myValMap["DropSmallSolids"] << "DropSmallSolids.MergeSolids"; + myOpLst << "SplitAngle"; myValMap["SplitAngle"] << "SplitAngle.Angle"; myValMap["SplitAngle"] << "SplitAngle.MaxTolerance"; @@ -808,13 +848,13 @@ GEOM::string_array* RepairGUI_ShapeProcessDlg::getValues( const GEOM::string_arr { GEOM::string_array_var aValues = new GEOM::string_array(); aValues->length( theParams.length() ); - + for ( int i = 0; i < theParams.length(); i++ ) { QWidget* aCtrl = getControl( (const char*)theParams[i] ); - if ( aCtrl ) - aValues[i] = get_convert( (const char*)theParams[i], getValue( aCtrl ) ); + if ( aCtrl && aCtrl->isEnabled() ) + aValues[i] = get_convert( (const char*)theParams[i], getValue( aCtrl )); } - + return aValues._retn(); } @@ -863,9 +903,43 @@ void RepairGUI_ShapeProcessDlg::initSelection() void RepairGUI_ShapeProcessDlg::advOptionToggled( bool on ) { QAbstractButton* btn = (QAbstractButton*)sender(); - if ( on && btn->isCheckable() && - SUIT_MessageBox::warning( this, - tr( "GEOM_WRN_WARNING" ), tr( "TIME_CONSUMING" ), - SUIT_MessageBox::Yes | SUIT_MessageBox::No ) == SUIT_MessageBox::No ) - btn->toggle(); + if ( btn == myToBezierSurfModeChk ) + { + if ( on && btn->isCheckable() && + SUIT_MessageBox::warning( this, + tr( "GEOM_WRN_WARNING" ), tr( "TIME_CONSUMING" ), + SUIT_MessageBox::Yes | SUIT_MessageBox::No ) == SUIT_MessageBox::No ) + btn->toggle(); + } + + // either myDropSmallSolidsWidChk or myDropSmallSolidsVolChk must be checked + if ( btn == myDropSmallSolidsWidChk ) + { + myDropSmallSolidsWidTol->setEnabled( on ); + if ( !on ) { + myDropSmallSolidsVolChk->setChecked( true ); + myDropSmallSolidsVolTol->setEnabled( true ); + } + } + if ( btn == myDropSmallSolidsVolChk ) + { + myDropSmallSolidsVolTol->setEnabled( on ); + if ( !on ) { + myDropSmallSolidsWidChk->setChecked( true ); + myDropSmallSolidsWidTol->setEnabled( true ); + } + } +} + +//======================================================================= +//function : operatorChecked +//purpose : show parameters of a selected operator +//======================================================================= + +void RepairGUI_ShapeProcessDlg::operatorChecked( QListWidgetItem * item ) +{ + if ( item && item->checkState() == Qt::Checked ) + { + myStack->setCurrentIndex( myOpList->row( item )); + } } diff --git a/src/RepairGUI/RepairGUI_ShapeProcessDlg.h b/src/RepairGUI/RepairGUI_ShapeProcessDlg.h index 4a6480220..2049a0d62 100755 --- a/src/RepairGUI/RepairGUI_ShapeProcessDlg.h +++ b/src/RepairGUI/RepairGUI_ShapeProcessDlg.h @@ -34,9 +34,11 @@ class DlgRef_1Sel; class SalomeApp_IntSpinBox; class SalomeApp_DoubleSpinBox; -class QComboBox; class QCheckBox; +class QComboBox; class QListWidget; +class QListWidgetItem; +class QStackedLayout; //================================================================================= // class : RepairGUI_ShapeProcessDlg @@ -87,6 +89,7 @@ private: DlgRef_1Sel* mySelectWdgt; QListWidget* myOpList; + QStackedLayout* myStack; SalomeApp_DoubleSpinBox* myFixShapeTol3D; SalomeApp_DoubleSpinBox* myFixShapeMaxTol3D; @@ -120,7 +123,13 @@ private: SalomeApp_DoubleSpinBox* myToBezierMaxTol; SalomeApp_DoubleSpinBox* mySameParameterTol3D; - + + QCheckBox* myDropSmallSolidsWidChk; + QCheckBox* myDropSmallSolidsVolChk; + SalomeApp_DoubleSpinBox* myDropSmallSolidsWidTol; + SalomeApp_DoubleSpinBox* myDropSmallSolidsVolTol; + QCheckBox* myDropSmallSolidsMergeChk; + private slots: void onOk(); bool onApply(); @@ -131,6 +140,7 @@ private slots: void selectionChanged(); void selectClicked(); void advOptionToggled( bool ); -}; + void operatorChecked( QListWidgetItem * item ); +}; #endif // REPAIRGUI_SHAPEPROCESSDLG_H diff --git a/src/ShHealOper/ShHealOper_ShapeProcess.cxx b/src/ShHealOper/ShHealOper_ShapeProcess.cxx index d991e1f7e..26905677a 100644 --- a/src/ShHealOper/ShHealOper_ShapeProcess.cxx +++ b/src/ShHealOper/ShHealOper_ShapeProcess.cxx @@ -62,7 +62,6 @@ ShHealOper_ShapeProcess::ShHealOper_ShapeProcess ( ) : myLevel = TopAbs_EDGE; myDone = Standard_False; myOperations.Context()->SetDetalisation ( TopAbs_EDGE ); - myOperations.Context()->SetTraceLevel( 3 ); } //======================================================================= @@ -131,23 +130,8 @@ void ShHealOper_ShapeProcess::Perform(const TopoDS_Shape& theOldShape, myStatistics.AddModif( txt.ToCString() ); } } - -// for (TopTools_DataMapIteratorOfDataMapOfShapeShape It (myOperations.Context()->Map()); It.More(); It.Next()) { -// TopoDS_Shape keyshape = It.Key(), valueshape = It.Value(); -// /* if (keyshape.ShapeType() == TopAbs_SHELL) { -// if (valueshape.IsNull()) SN++; -// else SS++; -// } -// else if (keyshape.ShapeType() == TopAbs_FACE)*/ { -// if (valueshape.IsNull()) cout << "Removed" << endl; -// else { -// TopAbs::Print( keyshape.ShapeType(), cout ) << " -> "; -// TopAbs::Print( valueshape.ShapeType(), cout ) << " IsSame()=" << keyshape.IsSame(valueshape) << endl; -// } -// } -// } - } + //======================================================================= //function : SetOperators //purpose :