From fc0a5273b3af6c7092aaecd8b2c9c93ea154e718 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 14 Oct 2010 10:59:34 +0000 Subject: [PATCH] 0021008: EDF 1581 GEOM : Bad result in the partition of a compound with a plane --- src/DlgRef/DlgRef.cxx | 14 ++ src/DlgRef/DlgRef.h | 16 ++ src/DlgRef/DlgRef_2Sel1List2Check_QTD.ui | 151 ++++++++++++++++++ src/DlgRef/Makefile.am | 1 + src/GEOMGUI/GEOM_msg_en.ts | 4 + .../OperationGUI_PartitionDlg.cxx | 139 +++++++++------- src/OperationGUI/OperationGUI_PartitionDlg.h | 4 +- 7 files changed, 270 insertions(+), 59 deletions(-) create mode 100644 src/DlgRef/DlgRef_2Sel1List2Check_QTD.ui diff --git a/src/DlgRef/DlgRef.cxx b/src/DlgRef/DlgRef.cxx index 9bd1c3fb3..1ff6c6b87 100644 --- a/src/DlgRef/DlgRef.cxx +++ b/src/DlgRef/DlgRef.cxx @@ -288,6 +288,20 @@ DlgRef_2Sel1List1Check::~DlgRef_2Sel1List1Check() { } +////////////////////////////////////////// +// DlgRef_2Sel1List2Check +////////////////////////////////////////// + +DlgRef_2Sel1List2Check::DlgRef_2Sel1List2Check( QWidget* parent, Qt::WindowFlags f ) +: QWidget( parent, f ) +{ + setupUi( this ); +} + +DlgRef_2Sel1List2Check::~DlgRef_2Sel1List2Check() +{ +} + ////////////////////////////////////////// // DlgRef_2Sel1List ////////////////////////////////////////// diff --git a/src/DlgRef/DlgRef.h b/src/DlgRef/DlgRef.h index 642aba629..a7b31a945 100644 --- a/src/DlgRef/DlgRef.h +++ b/src/DlgRef/DlgRef.h @@ -339,6 +339,22 @@ public: ~DlgRef_2Sel1List1Check(); }; +////////////////////////////////////////// +// DlgRef_2Sel1List2Check +////////////////////////////////////////// + +#include "ui_DlgRef_2Sel1List2Check_QTD.h" + +class DLGREF_EXPORT DlgRef_2Sel1List2Check : public QWidget, + public Ui::DlgRef_2Sel1List2Check_QTD +{ + Q_OBJECT + +public: + DlgRef_2Sel1List2Check( QWidget* = 0, Qt::WindowFlags = 0 ); + ~DlgRef_2Sel1List2Check(); +}; + ////////////////////////////////////////// // DlgRef_2Sel1List ////////////////////////////////////////// diff --git a/src/DlgRef/DlgRef_2Sel1List2Check_QTD.ui b/src/DlgRef/DlgRef_2Sel1List2Check_QTD.ui new file mode 100644 index 000000000..8cc018c02 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel1List2Check_QTD.ui @@ -0,0 +1,151 @@ + + + DlgRef_2Sel1List2Check_QTD + + + + 0 + 0 + 127 + 140 + + + + + + + + 0 + + + 0 + + + + + + + + + + + + 0 + 0 + + + + TL1 + + + false + + + + + + + + 0 + 0 + + + + + + + + + + + + + + + 0 + 0 + + + + TL2 + + + false + + + + + + + + 0 + 0 + + + + + + + + + + + + + + + 0 + 0 + + + + TL3 + + + false + + + + + + + + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + qPixmapFromMimeSource + + PushButton1 + LineEdit1 + PushButton2 + LineEdit2 + ComboBox1 + CheckButton1 + CheckButton2 + + + + diff --git a/src/DlgRef/Makefile.am b/src/DlgRef/Makefile.am index 0aadfc72d..f7af410b2 100644 --- a/src/DlgRef/Makefile.am +++ b/src/DlgRef/Makefile.am @@ -55,6 +55,7 @@ UIC_FILES = \ ui_DlgRef_1SelExt_QTD.h \ ui_DlgRef_1Spin_QTD.h \ ui_DlgRef_2Sel1List1Check_QTD.h \ + ui_DlgRef_2Sel1List2Check_QTD.h \ ui_DlgRef_2Sel1List_QTD.h \ ui_DlgRef_2Sel1Spin2Check_QTD.h \ ui_DlgRef_2Sel1Spin_QTD.h \ diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index db52a6775..4c2773fc0 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -3785,6 +3785,10 @@ Please, select face, shell or solid and try again GEOM_KEEP_NONLIMIT_SHAPES Keep shapes of lower type + + GEOM_NO_SELF_INTERSECTION + No shapes self-intersection + GEOM_CENTER_2POINTS Center and two points diff --git a/src/OperationGUI/OperationGUI_PartitionDlg.cxx b/src/OperationGUI/OperationGUI_PartitionDlg.cxx index b6fac51c7..a18661158 100644 --- a/src/OperationGUI/OperationGUI_PartitionDlg.cxx +++ b/src/OperationGUI/OperationGUI_PartitionDlg.cxx @@ -67,7 +67,7 @@ OperationGUI_PartitionDlg::OperationGUI_PartitionDlg( GeometryGUI* theGeometryGU mainFrame()->RadioButton3->close(); // Full partition (contains half-space partition) - GroupPoints = new DlgRef_2Sel1List1Check( centralWidget() ); + GroupPoints = new DlgRef_2Sel1List2Check( centralWidget() ); GroupPoints->GroupBox1->setTitle( tr( "GEOM_PARTITION" ) ); GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) ); GroupPoints->TextLabel2->setText( tr( "GEOM_TOOL_OBJECTS" ) ); @@ -76,9 +76,10 @@ OperationGUI_PartitionDlg::OperationGUI_PartitionDlg( GeometryGUI* theGeometryGU GroupPoints->PushButton2->setIcon( image2 ); GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly( true ); - GroupPoints->LineEdit1->setEnabled(true); - GroupPoints->LineEdit2->setEnabled(false); + GroupPoints->LineEdit1->setEnabled( true ); + GroupPoints->LineEdit2->setEnabled( false ); GroupPoints->CheckButton1->setText( tr( "GEOM_KEEP_NONLIMIT_SHAPES" ) ); + GroupPoints->CheckButton2->setText( tr( "GEOM_NO_SELF_INTERSECTION" ) ); QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setMargin( 0 ); layout->setSpacing( 6 ); @@ -161,20 +162,22 @@ void OperationGUI_PartitionDlg::ConstructorsClicked( int constructorId ) disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); globalSelection(); - myListShapes.length( 0 ); - myListTools.length( 0 ); - myListKeepInside.length( 0 ); - myListRemoveInside.length( 0 ); - myListMaterials.length( 0 ); + //myListShapes.length( 0 ); + //myListTools.length( 0 ); + //myListKeepInside.length( 0 ); // obsolete + //myListRemoveInside.length( 0 ); // obsolete + //myListMaterials.length( 0 ); // obsolete switch ( constructorId ) { case 0: /*Full partition */ GroupPoints->GroupBox1->setTitle( tr( "GEOM_PARTITION" ) ); + GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) ); GroupPoints->TextLabel2->setText( tr( "GEOM_TOOL_OBJECTS" ) ); GroupPoints->TextLabel3->show(); GroupPoints->ComboBox1->show(); GroupPoints->ComboBox1->setCurrentIndex( 0 ); GroupPoints->CheckButton1->show(); + GroupPoints->CheckButton2->show(); GroupPoints->PushButton1->setDown( true ); GroupPoints->PushButton2->setDown( false ); GroupPoints->LineEdit1->setEnabled(true); @@ -184,8 +187,10 @@ void OperationGUI_PartitionDlg::ConstructorsClicked( int constructorId ) GroupPoints->GroupBox1->setTitle( tr( "GEOM_PARTITION_HALFSPACE" ) ); GroupPoints->TextLabel3->hide(); GroupPoints->ComboBox1->hide(); + GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECT" ) ); GroupPoints->TextLabel2->setText( tr( "GEOM_PLANE" ) ); GroupPoints->CheckButton1->hide(); + GroupPoints->CheckButton2->hide(); GroupPoints->PushButton1->setDown( true ); GroupPoints->LineEdit1->setEnabled(true); break; @@ -249,27 +254,38 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument() int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true); - if ( nbSel < 1 ) { - if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { - myListShapes.length( 0 ); - myListMaterials.length( 0 ); + if ( getConstructorId() == 1 ) { + // for half-selection, only one shape can be selected as an object + // and only one plane as a tool + if ( nbSel != 1 ) { + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { + myListShapes.length( 0 ); + // myListMaterials.length( 0 ); // obsolete + return; + } + else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { + myListTools.length( 0 ); + return; + } } - else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) - myListTools.length( 0 ); } - - // One and only one plane can be selected - - if ( getConstructorId() == 1 && - myEditCurrentArgument == GroupPoints->LineEdit2 && - nbSel != 1 ) { - myListTools.length( 0 ); - return; + else { + if ( nbSel < 1 ) { + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { + myListShapes.length( 0 ); + //myListMaterials.length( 0 ); // obsolete + return; + } + else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { + myListTools.length( 0 ); + return; + } + } } if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListShapes, true); - myListMaterials.length( 0 ); + //myListMaterials.length( 0 ); // obsolete if ( !myListShapes.length() ) return; } @@ -277,6 +293,17 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument() GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListTools, true); if ( !myListTools.length() ) return; + else if ( myListTools.length() == 1 && getConstructorId() == 1 ) { + GEOM::GEOM_IMeasureOperations_var mOp = getGeomEngine()->GetIMeasureOperations( getStudyId() ); + GEOM::ListOfLong_var intList; + GEOM::ListOfDouble_var dblList; + GEOM::GEOM_IKindOfShape::shape_kind kind = mOp->KindOfShape( myListTools[0].in(), intList.out(), dblList.out() ); + mOp->Destroy(); + if ( kind < GEOM::GEOM_IKindOfShape::DISK_CIRCLE || kind > GEOM::GEOM_IKindOfShape::PLANAR ) { + myListTools.length( 0 ); + return; + } + } } myEditCurrentArgument->setText( aString ); @@ -372,8 +399,9 @@ GEOM::GEOM_IOperations_ptr OperationGUI_PartitionDlg::createOperation() //================================================================================= bool OperationGUI_PartitionDlg::isValid( QString& ) { - return ( myListShapes.length() || myListTools.length() || - myListKeepInside.length() || myListRemoveInside.length() ); + printf("OperationGUI_PartitionDlg::isValid:myListShapes.length()=%d\n",myListShapes.length()); + printf("OperationGUI_PartitionDlg::isValid:myListTools.length()=%d\n",myListTools.length()); + return ( myListShapes.length() || myListTools.length() ); // || myListKeepInside.length() || myListRemoveInside.length() // obsolete } @@ -384,50 +412,47 @@ bool OperationGUI_PartitionDlg::isValid( QString& ) bool OperationGUI_PartitionDlg::execute( ObjectList& objects ) { bool res = false; - GEOM::GEOM_Object_var anObj; - QString msg; - - int aLimit = GetLimit(); - int aConstructorId = getConstructorId(); - int aKeepNonlimitShapes = 0; - - if ( aConstructorId == 1 ) { - aLimit = GEOM::SHAPE; - } - else { - if ( GroupPoints->CheckButton1->isChecked() ) { - aKeepNonlimitShapes = 1; - } - else { - aKeepNonlimitShapes = 0; - } - } - if ( isValid( msg ) ) { - GEOM::GEOM_IBooleanOperations_var anOper = GEOM::GEOM_IBooleanOperations::_narrow(getOperation()); - anObj = anOper->MakePartition( myListShapes, myListTools, - myListKeepInside, myListRemoveInside, - aLimit, false, myListMaterials, aKeepNonlimitShapes ); + int aLimit = GetLimit(); + int aKeepNonlimitShapes = GroupPoints->CheckButton1->isChecked(); + bool aNoSelfIntersection = GroupPoints->CheckButton2->isChecked(); + + GEOM::GEOM_IBooleanOperations_var anOper = GEOM::GEOM_IBooleanOperations::_narrow( getOperation() ); + + switch ( getConstructorId() ) { + case 0: + anObj = aNoSelfIntersection ? + anOper->MakePartitionNonSelfIntersectedShape( myListShapes, myListTools, + myListKeepInside, myListRemoveInside, + aLimit, false, myListMaterials, aKeepNonlimitShapes ) : + anOper->MakePartition( myListShapes, myListTools, + myListKeepInside, myListRemoveInside, + aLimit, false, myListMaterials, aKeepNonlimitShapes ); res = true; + break; + case 1: + anObj = anOper->MakeHalfPartition( myListShapes[0].in(), myListTools[0].in() ); + res = true; + break; } if ( !anObj->_is_nil() ) { TopoDS_Shape aShape; - GEOMBase::GetShape(anObj, aShape, TopAbs_SHAPE); - TopoDS_Iterator It (aShape, Standard_True, Standard_True); - int nbSubshapes=0; - for (; It.More(); It.Next()) + GEOMBase::GetShape( anObj, aShape, TopAbs_SHAPE ); + TopoDS_Iterator It( aShape, Standard_True, Standard_True ); + int nbSubshapes = 0; + for ( ; It.More(); It.Next() ) nbSubshapes++; - if (nbSubshapes) + if ( nbSubshapes ) objects.push_back( anObj._retn() ); else - SUIT_MessageBox::warning(this, - QObject::tr("GEOM_ERROR"), - QObject::tr("GEOM_WRN_PARTITION_RESULT_EMPTY")); + SUIT_MessageBox::warning( this, + QObject::tr( "GEOM_ERROR" ), + QObject::tr( "GEOM_WRN_PARTITION_RESULT_EMPTY" ) ); } - + return res; } diff --git a/src/OperationGUI/OperationGUI_PartitionDlg.h b/src/OperationGUI/OperationGUI_PartitionDlg.h index f179659a5..306a2eb14 100644 --- a/src/OperationGUI/OperationGUI_PartitionDlg.h +++ b/src/OperationGUI/OperationGUI_PartitionDlg.h @@ -29,7 +29,7 @@ #include -class DlgRef_2Sel1List1Check; +class DlgRef_2Sel1List2Check; //================================================================================= // class : OperationGUI_PartitionDlg @@ -65,7 +65,7 @@ private: GEOM::ListOfGO myListRemoveInside; GEOM::ListOfGO myListKeepInside; - DlgRef_2Sel1List1Check* GroupPoints; + DlgRef_2Sel1List2Check* GroupPoints; private slots: void ClickOnOk(); -- 2.39.2