mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-28 18:30:36 +05:00
Add FixMode parameter to DropSmallSolids operator for uses two threshold optional parameters: VolumeThreshold and WidthFactorThreshold
This commit is contained in:
parent
41bdac6716
commit
a524a14a10
@ -18,6 +18,7 @@ ShapeProcess.FixFaceSize.Tolerance : 0.05
|
|||||||
|
|
||||||
ShapeProcess.DropSmallEdges.Tolerance3d : 0.05
|
ShapeProcess.DropSmallEdges.Tolerance3d : 0.05
|
||||||
|
|
||||||
|
ShapeProcess.DropSmallSolids.FixMode : 2
|
||||||
ShapeProcess.DropSmallSolids.WidthFactorThreshold : 1
|
ShapeProcess.DropSmallSolids.WidthFactorThreshold : 1
|
||||||
ShapeProcess.DropSmallSolids.VolumeThreshold : 1000
|
ShapeProcess.DropSmallSolids.VolumeThreshold : 1000
|
||||||
ShapeProcess.DropSmallSolids.MergeSolids : 1
|
ShapeProcess.DropSmallSolids.MergeSolids : 1
|
||||||
|
@ -276,6 +276,7 @@ bool GEOMImpl_IHealingOperations::GetParameters (const std::string theOperation,
|
|||||||
theParams.push_back( "DropSmallEdges.Tolerance3d" );
|
theParams.push_back( "DropSmallEdges.Tolerance3d" );
|
||||||
|
|
||||||
} else if( theOperation == "DropSmallSolids" ) {
|
} else if( theOperation == "DropSmallSolids" ) {
|
||||||
|
theParams.push_back( "DropSmallSolids.FixMode" );
|
||||||
theParams.push_back( "DropSmallSolids.WidthFactorThreshold" );
|
theParams.push_back( "DropSmallSolids.WidthFactorThreshold" );
|
||||||
theParams.push_back( "DropSmallSolids.VolumeThreshold" );
|
theParams.push_back( "DropSmallSolids.VolumeThreshold" );
|
||||||
theParams.push_back( "DropSmallSolids.MergeSolids" );
|
theParams.push_back( "DropSmallSolids.MergeSolids" );
|
||||||
|
@ -48,7 +48,12 @@
|
|||||||
|
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ALL_PARAMETERS,
|
||||||
|
ONLY_WIDTH_FACTOR_PARAMETER,
|
||||||
|
ONLY_VOLUME_PARAMETER
|
||||||
|
};
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// class : RepairGUI_ShapeProcessDlg()
|
// class : RepairGUI_ShapeProcessDlg()
|
||||||
// purpose : Constructs a RepairGUI_ShapeProcessDlg which is a child of 'parent', with the
|
// purpose : Constructs a RepairGUI_ShapeProcessDlg which is a child of 'parent', with the
|
||||||
@ -169,10 +174,6 @@ void RepairGUI_ShapeProcessDlg::init()
|
|||||||
myDropSmallSolidsVolTol = new SalomeApp_DoubleSpinBox( w );
|
myDropSmallSolidsVolTol = new SalomeApp_DoubleSpinBox( w );
|
||||||
initSpinBox( myDropSmallSolidsWidTol, 0., 1e3, 1., "len_tol_precision" );
|
initSpinBox( myDropSmallSolidsWidTol, 0., 1e3, 1., "len_tol_precision" );
|
||||||
initSpinBox( myDropSmallSolidsVolTol, 0., 1e9, 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 );
|
myDropSmallSolidsMergeChk = new QCheckBox( tr("TO_MERGE_SOLIDS"), w );
|
||||||
|
|
||||||
aLay->addWidget( myDropSmallSolidsWidChk, 0, 0 );
|
aLay->addWidget( myDropSmallSolidsWidChk, 0, 0 );
|
||||||
@ -366,6 +367,45 @@ void RepairGUI_ShapeProcessDlg::init()
|
|||||||
updateSelectAll();
|
updateSelectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : getOptionalValues()
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
int RepairGUI_ShapeProcessDlg::getOptionalValues()
|
||||||
|
{
|
||||||
|
bool anWidCheckState = myDropSmallSolidsWidChk->checkState() == Qt::Checked;
|
||||||
|
bool anVolCheckState = myDropSmallSolidsVolChk->checkState() == Qt::Checked;
|
||||||
|
if ( anWidCheckState && anVolCheckState )
|
||||||
|
return ALL_PARAMETERS;
|
||||||
|
else if (anWidCheckState)
|
||||||
|
return ONLY_WIDTH_FACTOR_PARAMETER;
|
||||||
|
else if (anVolCheckState)
|
||||||
|
return ONLY_VOLUME_PARAMETER;
|
||||||
|
return ALL_PARAMETERS;
|
||||||
|
}
|
||||||
|
//=================================================================================
|
||||||
|
// function : getMapWithoutOptionalParameters()
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
QMap<QString,QStringList> RepairGUI_ShapeProcessDlg::getMapWithoutOptionalParameters()
|
||||||
|
{
|
||||||
|
int mode = getOptionalValues();
|
||||||
|
QMap<QString, QStringList> aValMap(myValMap);
|
||||||
|
if ( mode == ALL_PARAMETERS )
|
||||||
|
return aValMap;
|
||||||
|
QMap<QString, QStringList>::iterator it;
|
||||||
|
it = aValMap.find("DropSmallSolids");
|
||||||
|
if ( it != aValMap.end() ) {
|
||||||
|
if ( mode == ONLY_VOLUME_PARAMETER) {
|
||||||
|
it.value().removeOne("DropSmallSolids.WidthFactorThreshold");
|
||||||
|
}
|
||||||
|
else if ( mode== ONLY_WIDTH_FACTOR_PARAMETER) {
|
||||||
|
it.value().removeOne("DropSmallSolids.VolumeThreshold");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return aValMap;
|
||||||
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : onOk()
|
// function : onOk()
|
||||||
// purpose : Same than click on apply but close this dialog.
|
// purpose : Same than click on apply but close this dialog.
|
||||||
@ -538,11 +578,33 @@ void RepairGUI_ShapeProcessDlg::loadDefaults()
|
|||||||
// set default values of parameters
|
// set default values of parameters
|
||||||
if ( aParams->length() != aValues->length() )
|
if ( aParams->length() != aValues->length() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for ( int j = 0; j < aParams->length(); j++ ) {
|
for ( int j = 0; j < aParams->length(); j++ ) {
|
||||||
QWidget* aCtrl = getControl( (const char*)aParams[j] );
|
QWidget* aCtrl = getControl( (const char*)aParams[j] );
|
||||||
|
if (aCtrl) {
|
||||||
setValue( aCtrl, set_convert( (const char*)aParams[j], aValues[j] ));
|
setValue( aCtrl, set_convert( (const char*)aParams[j], aValues[j] ));
|
||||||
}
|
}
|
||||||
|
else if (!strcmp( (const char*)aParams[j], "DropSmallSolids.FixMode" )) {
|
||||||
|
int aDropSmallSolidsFixMode = QString(aValues[j].in()).toInt();
|
||||||
|
if ( aDropSmallSolidsFixMode == ALL_PARAMETERS ) {
|
||||||
|
myDropSmallSolidsWidChk->setChecked( true );
|
||||||
|
myDropSmallSolidsWidTol->setEnabled( true );
|
||||||
|
myDropSmallSolidsVolChk->setChecked( true );
|
||||||
|
myDropSmallSolidsVolTol->setEnabled( true );
|
||||||
|
}
|
||||||
|
else if ( aDropSmallSolidsFixMode == ONLY_WIDTH_FACTOR_PARAMETER ) {
|
||||||
|
myDropSmallSolidsWidChk->setChecked( true );
|
||||||
|
myDropSmallSolidsWidTol->setEnabled( true );
|
||||||
|
myDropSmallSolidsVolChk->setChecked( false );
|
||||||
|
myDropSmallSolidsVolTol->setEnabled( false );
|
||||||
|
}
|
||||||
|
else if ( aDropSmallSolidsFixMode == ONLY_VOLUME_PARAMETER ) {
|
||||||
|
myDropSmallSolidsWidChk->setChecked( false );
|
||||||
|
myDropSmallSolidsWidTol->setEnabled( false );
|
||||||
|
myDropSmallSolidsVolChk->setChecked( true );
|
||||||
|
myDropSmallSolidsVolTol->setEnabled( true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,11 +634,6 @@ QString RepairGUI_ShapeProcessDlg::getValue( QWidget* theControl ) const
|
|||||||
{
|
{
|
||||||
if ( theControl ) {
|
if ( theControl ) {
|
||||||
if ( qobject_cast<SalomeApp_DoubleSpinBox*>( theControl )) {
|
if ( qobject_cast<SalomeApp_DoubleSpinBox*>( 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<SalomeApp_DoubleSpinBox*>( theControl )->value() );
|
return QString::number( qobject_cast<SalomeApp_DoubleSpinBox*>( theControl )->value() );
|
||||||
}
|
}
|
||||||
else if ( qobject_cast<SalomeApp_IntSpinBox*>( theControl )) {
|
else if ( qobject_cast<SalomeApp_IntSpinBox*>( theControl )) {
|
||||||
@ -631,7 +688,7 @@ bool RepairGUI_ShapeProcessDlg::isValid( QString& msg )
|
|||||||
while( aListIter.hasNext() ) {
|
while( aListIter.hasNext() ) {
|
||||||
const QString& aParam = aListIter.next();
|
const QString& aParam = aListIter.next();
|
||||||
QWidget* aControl = getControl( aParam );
|
QWidget* aControl = getControl( aParam );
|
||||||
if ( !aControl->isEnabled() ) continue;
|
if ( !aControl || !aControl->isEnabled() ) continue;
|
||||||
if ( qobject_cast<SalomeApp_DoubleSpinBox*>( aControl ))
|
if ( qobject_cast<SalomeApp_DoubleSpinBox*>( aControl ))
|
||||||
ok = qobject_cast<SalomeApp_DoubleSpinBox*>( aControl )->isValid( msg, !IsPreview() ) && ok;
|
ok = qobject_cast<SalomeApp_DoubleSpinBox*>( aControl )->isValid( msg, !IsPreview() ) && ok;
|
||||||
else if ( qobject_cast<SalomeApp_IntSpinBox*>( aControl ))
|
else if ( qobject_cast<SalomeApp_IntSpinBox*>( aControl ))
|
||||||
@ -663,7 +720,6 @@ bool RepairGUI_ShapeProcessDlg::execute( ObjectList& objects )
|
|||||||
GEOM::string_array_var anOperators = getActiveOperators();
|
GEOM::string_array_var anOperators = getActiveOperators();
|
||||||
GEOM::string_array_var aParams = getParameters( anOperators );
|
GEOM::string_array_var aParams = getParameters( anOperators );
|
||||||
GEOM::string_array_var aValues = getValues( aParams );
|
GEOM::string_array_var aValues = getValues( aParams );
|
||||||
|
|
||||||
/*//-- check --
|
/*//-- check --
|
||||||
int z;
|
int z;
|
||||||
MESSAGE("Objects : ");
|
MESSAGE("Objects : ");
|
||||||
@ -790,6 +846,7 @@ void RepairGUI_ShapeProcessDlg::initParamsValues()
|
|||||||
myValMap["DropSmallEdges"] << "DropSmallEdges.Tolerance3d";
|
myValMap["DropSmallEdges"] << "DropSmallEdges.Tolerance3d";
|
||||||
|
|
||||||
myOpLst << "DropSmallSolids";
|
myOpLst << "DropSmallSolids";
|
||||||
|
myValMap["DropSmallSolids"] << "DropSmallSolids.FixMode";
|
||||||
myValMap["DropSmallSolids"] << "DropSmallSolids.WidthFactorThreshold";
|
myValMap["DropSmallSolids"] << "DropSmallSolids.WidthFactorThreshold";
|
||||||
myValMap["DropSmallSolids"] << "DropSmallSolids.VolumeThreshold";
|
myValMap["DropSmallSolids"] << "DropSmallSolids.VolumeThreshold";
|
||||||
myValMap["DropSmallSolids"] << "DropSmallSolids.MergeSolids";
|
myValMap["DropSmallSolids"] << "DropSmallSolids.MergeSolids";
|
||||||
@ -835,17 +892,17 @@ GEOM::string_array* RepairGUI_ShapeProcessDlg::getParameters( const GEOM::string
|
|||||||
{
|
{
|
||||||
GEOM::string_array_var aParams = new GEOM::string_array();
|
GEOM::string_array_var aParams = new GEOM::string_array();
|
||||||
int i = 0, j = 0;
|
int i = 0, j = 0;
|
||||||
|
QMap<QString, QStringList> aValMap = getMapWithoutOptionalParameters();
|
||||||
// calculate the length of parameters
|
// calculate the length of parameters
|
||||||
for ( i = 0, j = 0; i < theOperators.length(); i++ )
|
for ( i = 0, j = 0; i < theOperators.length(); i++ )
|
||||||
j += myValMap[ QString( theOperators[i].in() ) ].size();
|
j += aValMap[ QString( theOperators[i].in() ) ].size();
|
||||||
|
|
||||||
// set the new length of paremeters
|
// set the new length of paremeters
|
||||||
aParams->length( j );
|
aParams->length( j );
|
||||||
|
|
||||||
// fill the parameters
|
// fill the parameters
|
||||||
for ( i = 0, j = 0; i < theOperators.length(); i++ ) {
|
for ( i = 0, j = 0; i < theOperators.length(); i++ ) {
|
||||||
QStringList aParamLst = myValMap[ QString( theOperators[i].in() ) ];
|
QStringList aParamLst = aValMap[ QString( theOperators[i].in() ) ];
|
||||||
foreach ( QString aParam, aParamLst ) {
|
foreach ( QString aParam, aParamLst ) {
|
||||||
aParams[j++] = CORBA::string_dup( aParam.toLatin1().constData() );
|
aParams[j++] = CORBA::string_dup( aParam.toLatin1().constData() );
|
||||||
}
|
}
|
||||||
@ -856,7 +913,6 @@ GEOM::string_array* RepairGUI_ShapeProcessDlg::getParameters( const GEOM::string
|
|||||||
return aParams._retn();
|
return aParams._retn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : getValues
|
// function : getValues
|
||||||
// purpose :
|
// purpose :
|
||||||
@ -868,9 +924,13 @@ GEOM::string_array* RepairGUI_ShapeProcessDlg::getValues( const GEOM::string_arr
|
|||||||
|
|
||||||
for ( int i = 0; i < theParams.length(); i++ ) {
|
for ( int i = 0; i < theParams.length(); i++ ) {
|
||||||
QWidget* aCtrl = getControl( (const char*)theParams[i] );
|
QWidget* aCtrl = getControl( (const char*)theParams[i] );
|
||||||
if ( aCtrl )
|
if ( aCtrl ) {
|
||||||
aValues[i] = get_convert( (const char*)theParams[i], getValue( aCtrl ));
|
aValues[i] = get_convert( (const char*)theParams[i], getValue( aCtrl ));
|
||||||
}
|
}
|
||||||
|
else if( !strcmp( (const char*)theParams[i], "DropSmallSolids.FixMode" ) ) {
|
||||||
|
aValues[i] = QString::number(getOptionalValues()).toLatin1().constData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return aValues._retn();
|
return aValues._retn();
|
||||||
}
|
}
|
||||||
@ -891,6 +951,9 @@ QStringList RepairGUI_ShapeProcessDlg::getTexts( const GEOM::string_array& thePa
|
|||||||
if( !aText.isNull() )
|
if( !aText.isNull() )
|
||||||
aTexts.append( aText );
|
aTexts.append( aText );
|
||||||
}
|
}
|
||||||
|
else if( !strcmp( (const char*)theParams[i], "DropSmallSolids.FixMode" ) ) {
|
||||||
|
aTexts.append( QString::number(getOptionalValues()) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return aTexts;
|
return aTexts;
|
||||||
|
@ -77,6 +77,8 @@ private:
|
|||||||
QString getValue( QWidget* ) const; // retrieve value of the control in the proper way
|
QString getValue( QWidget* ) const; // retrieve value of the control in the proper way
|
||||||
QString getText( QWidget* ) const; // retrieve text of the control (for spin-boxes only)
|
QString getText( QWidget* ) const; // retrieve text of the control (for spin-boxes only)
|
||||||
|
|
||||||
|
int getOptionalValues( );
|
||||||
|
QMap<QString,QStringList> getMapWithoutOptionalParameters();
|
||||||
//QDict<QString,QWidget*> myCtrlMap; // map of controls (values) of parameters
|
//QDict<QString,QWidget*> myCtrlMap; // map of controls (values) of parameters
|
||||||
void initParamsValues(); // initialize the data structures
|
void initParamsValues(); // initialize the data structures
|
||||||
void initSelection();
|
void initSelection();
|
||||||
|
Loading…
Reference in New Issue
Block a user