]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
0021008: EDF 1581 GEOM : Bad result in the partition of a compound with a plane
authorvsr <vsr@opencascade.com>
Thu, 14 Oct 2010 10:59:34 +0000 (10:59 +0000)
committervsr <vsr@opencascade.com>
Thu, 14 Oct 2010 10:59:34 +0000 (10:59 +0000)
src/DlgRef/DlgRef.cxx
src/DlgRef/DlgRef.h
src/DlgRef/DlgRef_2Sel1List2Check_QTD.ui [new file with mode: 0644]
src/DlgRef/Makefile.am
src/GEOMGUI/GEOM_msg_en.ts
src/OperationGUI/OperationGUI_PartitionDlg.cxx
src/OperationGUI/OperationGUI_PartitionDlg.h

index 9bd1c3fb3da62b1ddfbae1cf33206affa56ed60e..1ff6c6b8761ef694da1313fc43654c60159f22e5 100644 (file)
@@ -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
 //////////////////////////////////////////
index 642aba6296ac35a2d6c2f6b8090214e6c436bd76..a7b31a94513f3d8baa92c349f3ab457a2a95e32f 100644 (file)
@@ -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 (file)
index 0000000..8cc018c
--- /dev/null
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DlgRef_2Sel1List2Check_QTD</class>
+ <widget class="QWidget" name="DlgRef_2Sel1List2Check_QTD">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>127</width>
+    <height>140</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string/>
+  </property>
+  <layout class="QGridLayout">
+   <property name="margin">
+    <number>0</number>
+   </property>
+   <property name="spacing">
+    <number>0</number>
+   </property>
+   <item row="0" column="0">
+    <widget class="QGroupBox" name="GroupBox1">
+     <property name="title">
+      <string/>
+     </property>
+     <layout class="QGridLayout" name="gridLayout">
+      <item row="0" column="0">
+       <widget class="QLabel" name="TextLabel1">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string>TL1</string>
+        </property>
+        <property name="wordWrap">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1">
+       <widget class="QPushButton" name="PushButton1">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string/>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="2">
+       <widget class="QLineEdit" name="LineEdit1"/>
+      </item>
+      <item row="1" column="0">
+       <widget class="QLabel" name="TextLabel2">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string>TL2</string>
+        </property>
+        <property name="wordWrap">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1">
+       <widget class="QPushButton" name="PushButton2">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string/>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="2">
+       <widget class="QLineEdit" name="LineEdit2"/>
+      </item>
+      <item row="2" column="0">
+       <widget class="QLabel" name="TextLabel3">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string>TL3</string>
+        </property>
+        <property name="wordWrap">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="1" colspan="2">
+       <widget class="QComboBox" name="ComboBox1">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="0" colspan="3">
+       <widget class="QCheckBox" name="CheckButton1">
+        <property name="text">
+         <string/>
+        </property>
+       </widget>
+      </item>
+      <item row="4" column="0" colspan="3">
+       <widget class="QCheckBox" name="CheckButton2">
+        <property name="text">
+         <string/>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
+ <tabstops>
+  <tabstop>PushButton1</tabstop>
+  <tabstop>LineEdit1</tabstop>
+  <tabstop>PushButton2</tabstop>
+  <tabstop>LineEdit2</tabstop>
+  <tabstop>ComboBox1</tabstop>
+  <tabstop>CheckButton1</tabstop>
+  <tabstop>CheckButton2</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+</ui>
index 0aadfc72d83a8b9645b863dc7277d7eceadd0e27..f7af410b2c90ea22b9958fa0be834b7ea4f29303 100644 (file)
@@ -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               \
index db52a677531f31771b0f433bbb032751e4cd3216..4c2773fc01936293bf6ceba4e152598d897e80e3 100644 (file)
@@ -3785,6 +3785,10 @@ Please, select face, shell or solid and try again</translation>
         <source>GEOM_KEEP_NONLIMIT_SHAPES</source>
         <translation>Keep shapes of lower type</translation>
     </message>
+    <message>
+        <source>GEOM_NO_SELF_INTERSECTION</source>
+        <translation>No shapes self-intersection</translation>
+    </message>
     <message>
         <source>GEOM_CENTER_2POINTS</source>
         <translation>Center and two points</translation>
index b6fac51c725384b350fa1f979eef7c7648377367..a1866115892c0b10d40d393497b8fb259076037f 100644 (file)
@@ -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;
 }
 
index f179659a5f803ab3fdfbcc2c167310b36ed9b238..306a2eb142f1ccf475e96499b79f6f6d0e150543 100644 (file)
@@ -29,7 +29,7 @@
 
 #include <GEOMBase_Skeleton.h>
 
-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();