22763: [EDF] Shape processing

Add DropSmallSolids operator
This commit is contained in:
eap 2014-12-11 20:53:33 +03:00
parent ed87a1f7c8
commit e22e35a475
6 changed files with 162 additions and 66 deletions

BIN
doc/salome/gui/GEOM/images/repair1.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

@ -51,11 +51,27 @@ spots and strips.</li>
possible face size.</li>
</ul>
<li><b>Drop Small Edges</b> (DropSmallEdges) - removes edges, which
merge with neighbouring edges.</li>
merge with neighboring edges.</li>
<ul>
<li><b>3D Tolerance</b> (DropSmallEdges.Tolerance3d) - defines minimum
possible distance between two parallel edges.</li>
</ul>
<li><b>Drop Small Solids</b> (DropSmallSolids) - either removes small
solids or merges them with neighboring ones.</li>
<ul>
<li><b>Width factor tol.</b> (DropSmallSolids.WidthFactorThreshold) -
defines maximum value of <em>2V/S</em> of a solid which is
considered small, where \a V is volume and \a S is surface area of
the solid.</li>
<li><b>Volume tol.</b> (DropSmallSolids.VolumeThreshold) - defines
maximum volume of a solid which is considered small.</li>
<li><b>To merge solids</b> (DropSmallSolids.MergeSolids) - if
activated, small solids are removed, else small solids are merged to
adjacent non-small solids or left untouched if cannot be merged.
</li>
</ul>
If the both tolerances are activated a solid is considered small if
it meets the both criteria.
<li><b>Split Angle</b> (SplitAngle) - splits faces based on conical
surfaces, surfaces of revolution and cylindrical surfaces in segments
using a certain angle.</li>

View File

@ -6716,6 +6716,18 @@ Please close this message box and select edges for gluing</translation>
<translation>Enabling this option may result in a very time-consuming operation for some input shapes.
Would you like to continue?</translation>
</message>
<message>
<source>WIDTH_FACTOR_TOL</source>
<translation>Width factor tol.</translation>
</message>
<message>
<source>VOLUME_TOL</source>
<translation>Volume tol.</translation>
</message>
<message>
<source>TO_MERGE_SOLIDS</source>
<translation>To merge solids</translation>
</message>
</context>
<context>
<name>GEOMToolsGUI_DeleteDlg</name>

View File

@ -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() );
@ -315,14 +341,19 @@ void RepairGUI_ShapeProcessDlg::init()
connect( mySelectWdgt->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( lineEditReturnPressed() ));
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();
myStack->setCurrentIndex( 0 );
initName( tr( "PROCESS_SHAPE_NEW_OBJ_NAME" ));
selectionChanged();
}
@ -583,6 +614,7 @@ bool RepairGUI_ShapeProcessDlg::isValid( QString& msg )
while( aListIter.hasNext() ) {
const QString& aParam = aListIter.next();
QWidget* aControl = getControl( aParam );
if ( !aControl->isEnabled() ) continue;
if ( qobject_cast<SalomeApp_DoubleSpinBox*>( aControl ))
ok = qobject_cast<SalomeApp_DoubleSpinBox*>( aControl )->isValid( msg, !IsPreview() ) && ok;
else if ( qobject_cast<SalomeApp_IntSpinBox*>( aControl ))
@ -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";
@ -811,7 +851,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 )
if ( aCtrl && aCtrl->isEnabled() )
aValues[i] = get_convert( (const char*)theParams[i], getValue( aCtrl ));
}
@ -863,9 +903,43 @@ void RepairGUI_ShapeProcessDlg::initSelection()
void RepairGUI_ShapeProcessDlg::advOptionToggled( bool on )
{
QAbstractButton* btn = (QAbstractButton*)sender();
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 ));
}
}

View File

@ -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;
@ -121,6 +124,12 @@ private:
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

View File

@ -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 :