]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Changes for 0020673 - Implementation of "Auto-correct edges orientation".
authorskl <skl@opencascade.com>
Thu, 18 Mar 2010 13:18:15 +0000 (13:18 +0000)
committerskl <skl@opencascade.com>
Thu, 18 Mar 2010 13:18:15 +0000 (13:18 +0000)
16 files changed:
doc/salome/gui/GEOM/images/filling.png
doc/salome/gui/GEOM/input/creating_filling.doc
idl/GEOM_Gen.idl
idl/GEOM_Superv.idl
src/DlgRef/DlgRef_1Sel5Spin1Check_QTD.ui
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMImpl/GEOMImpl_FillingDriver.cxx
src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx
src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx
src/GEOMImpl/GEOMImpl_IFilling.hxx
src/GEOM_I/GEOM_I3DPrimOperations_i.cc
src/GEOM_I/GEOM_I3DPrimOperations_i.hh
src/GEOM_I_Superv/GEOM_Superv_i.cc
src/GEOM_I_Superv/GEOM_Superv_i.hh
src/GenerationGUI/GenerationGUI_FillingDlg.cxx
src/GenerationGUI/GenerationGUI_FillingDlg.h

index da4ad8d41ce3b3b4967c4aa68f613caaafb24a10..2b2f4fb10378374d2b0c25fd12b0ec47b1578522 100755 (executable)
Binary files a/doc/salome/gui/GEOM/images/filling.png and b/doc/salome/gui/GEOM/images/filling.png differ
index b096fd8e7520e2ea5892d247ccbbf620d831f701..e082127ac10bbf98d4dc01f611deac6d58fa498e 100644 (file)
@@ -18,9 +18,13 @@ created surface and the reference edge;
 Iterations</b> - defines the maximum number of iterations. The
 iterations are repeated until the required tolerance is reached. So, a
 greater number of iterations allows producing a better surface. 
-\n <b>Use orientation</b> - if checked, orientation of edges are used:
-if edge is reversed curve from this edge is reversed before using in
-filling algorithm.
+\n <b>Method</b> - Kind of method to perform filling operation
+1. Default - standard behaviour
+2. Use edges orientation - orientation of edges are used: if edge is
+reversed curve from this edge is reversed before using in filling
+algorithm.
+3. Auto-correct edges orientation - change orientation of curves using
+minimization of sum of distances between ends points of edges.
 \n <b>Approximation</b> - if checked, BSpline curves are generated in
 the process of surface construction (using
 GeomAPI_PointsToBSplineSurface functionality). By default the surface
index 451d7e6d2e99f8b57a43b1390b3c6583c4d7b00b..a93cdb751991f792e7b4086dc11e81a78686dd82 100644 (file)
@@ -114,6 +114,22 @@ module GEOM
     FSM_GetInPlaceByHistory
   };
 
+  /*!
+   *  Kind of method to perform filling operation
+   *  Is used in functions GEOM_Gen.MakeFilling<xxx>()
+   */
+  enum filling_oper_method
+  {
+    /*! Default (standard behaviour) */
+    FOM_Default,
+
+    /*! Use edges orientation */
+    FOM_UseOri,
+
+    /*! Auto-correct edges orientation */
+    FOM_AutoCorrect
+  };
+
 
   typedef sequence<string>      string_array;
   typedef sequence<short>       short_array;
@@ -1180,12 +1196,14 @@ module GEOM
      *  \param theTol2D a 2d tolerance to be reached
      *  \param theTol3D a 3d tolerance to be reached
      *  \param theNbIter a number of iteration of approximation algorithm
+     *  \param theMethod Kind of method to perform filling operation.
      *  \return New GEOM_Object, containing the created filling surface.
      */
     GEOM_Object MakeFilling (in GEOM_Object theShape,
                             in long theMinDeg, in long theMaxDeg,
                             in double theTol2D, in double theTol3D,
-                            in long theNbIter,  in boolean theUseOri,
+                            in long theNbIter,
+                             in filling_oper_method theMethod,
                              in boolean theApprox);
 
     /*!
index 8fdc7d1c0c254dfeb3e54b3f599d667c7800a9d1..1c7986bf828193329fcd90a768443ea89c239333 100644 (file)
@@ -200,7 +200,8 @@ module GEOM
     GEOM_Object MakeFilling (in GEOM_Object theShape,
                             in long theMinDeg, in long theMaxDeg,
                             in double theTol2D, in double theTol3D,
-                            in long theNbIter, in boolean theUseOri,
+                            in long theNbIter,
+                             in filling_oper_method theMethod,
                              in boolean theApprox) ;
     GEOM_Object MakeThruSections(in ListOfGO theSeqSections,
                                 in boolean theModeSolid,
index cbb0de7d9b589a550ad776f45d0bb693609ccca1..da4fd5062e8b8542a8b15463a7662b42b2c7fa47 100644 (file)
@@ -7,13 +7,13 @@
     <x>0</x>
     <y>0</y>
     <width>200</width>
-    <height>153</height>
+    <height>162</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string/>
   </property>
-  <layout class="QGridLayout">
+  <layout class="QGridLayout" name="gridLayout_2">
    <property name="margin">
     <number>0</number>
    </property>
         </item>
        </layout>
       </item>
-      <item row="1" column="0" colspan="2">
-       <widget class="QCheckBox" name="CheckBox2">
+      <item row="1" column="0">
+       <widget class="QLabel" name="TextLabel7">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
         <property name="text">
-         <string/>
+         <string>TL7</string>
+        </property>
+        <property name="wordWrap">
+         <bool>false</bool>
         </property>
        </widget>
       </item>
+      <item row="1" column="1">
+       <widget class="QComboBox" name="ComboBox1"/>
+      </item>
       <item row="2" column="0" colspan="2">
        <layout class="QGridLayout">
         <item row="0" column="0">
  <tabstops>
   <tabstop>PushButton1</tabstop>
   <tabstop>LineEdit1</tabstop>
-  <tabstop>CheckBox2</tabstop>
+  <tabstop>ComboBox1</tabstop>
   <tabstop>SpinBox1</tabstop>
   <tabstop>SpinBox2</tabstop>
   <tabstop>SpinBox4</tabstop>
index 1f7fb0a0beb95fc759655158b01610fa8124e290..766fcc0cbb0c95101085afc45100369cd79601c0 100644 (file)
@@ -3787,9 +3787,21 @@ Please, select face, shell or solid and try again</translation>
             <source>GEOM_FILLING_APPROX</source>
             <translation>Approximation</translation>
         </message>
+        <message>
+            <source>GEOM_FILLING_METHOD</source>
+            <translation>Method</translation>
+        </message>
+        <message>
+            <source>GEOM_FILLING_DEFAULT</source>
+            <translation>Default (standard behaviour)</translation>
+        </message>
         <message>
             <source>GEOM_FILLING_USEORI</source>
-            <translation>Use orientation</translation>
+            <translation>Use edges orientation</translation>
+        </message>
+        <message>
+            <source>GEOM_FILLING_AUTO</source>
+            <translation>Auto-correct edges orientation</translation>
         </message>
         <message>
             <source>GEOM_WRN_NO_APPROPRIATE_SELECTION</source>
index cf893cd465531afbf63903fce464645e09aa9a1e..a941a0f69165f7f74d496967a1fa887385b2db03 100644 (file)
@@ -110,7 +110,7 @@ Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const
   Standard_Real tol2d = IF.GetTol3D();
   Standard_Integer nbiter = IF.GetNbIter();
   Standard_Boolean isApprox = IF.GetApprox();
-  Standard_Boolean isUseOri = IF.GetUseOri();
+  Standard_Integer aMethod = IF.GetMethod();
 
   if (mindeg > maxdeg) {
     Standard_RangeError::Raise("Minimal degree can not be more than maximal degree");
@@ -224,6 +224,8 @@ Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const
     // make filling as in old version of SALOME (before 4.1.1)
     GeomFill_SectionGenerator Section;
     Standard_Integer i = 0;
+    Handle(Geom_Curve) aLastC;
+    gp_Pnt PL1,PL2;
     for (Ex.Init(aShape, TopAbs_EDGE); Ex.More(); Ex.Next()) {
       Scurrent = Ex.Current();
       if (Scurrent.IsNull() || Scurrent.ShapeType() != TopAbs_EDGE) return 0;
@@ -235,9 +237,33 @@ Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const
       //else
       //  C = new Geom_TrimmedCurve(C, First, Last);
       C = new Geom_TrimmedCurve(C, First, Last);
-      if( isUseOri && Scurrent.Orientation() == TopAbs_REVERSED ) {
+      gp_Pnt P1,P2;
+      C->D0(First,P1);
+      C->D0(Last,P2);
+
+      if( aMethod==1 && Scurrent.Orientation() == TopAbs_REVERSED ) {
         C->Reverse();
       }
+      else if( aMethod==2 ) {
+        if( i==0 ) {
+          PL1 = P1;
+          PL2 = P2;
+        }
+        else {
+          double d1 = PL1.Distance(P1) + PL2.Distance(P2);
+          double d2 = PL1.Distance(P2) + PL2.Distance(P1);
+          if(d2<d1) {
+            C->Reverse();
+            PL1 = P2;
+            PL2 = P1;
+          }
+          else {
+            PL1 = P1;
+            PL2 = P2;
+          }
+        }
+      }
+
       Section.AddCurve(C);
       i++;
     }
index 185f6bb728d43b791a0c9e6b1aa868c991b3c179..6c03dd7fbe9f29f7e681ecbdb89fe13c88d40e1b 100644 (file)
@@ -1454,7 +1454,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
        (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
         double theTol2D, double theTol3D, int theNbIter,
-        bool isUseOri, bool isApprox)
+        int theMethod, bool isApprox)
 {
   SetErrorCode(KO);
 
@@ -1483,7 +1483,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
   aFI.SetTol3D(theTol3D);
   aFI.SetNbIter(theNbIter);
   aFI.SetApprox(isApprox);
-  aFI.SetUseOri(isUseOri);
+  aFI.SetMethod(theMethod);
 
   //Compute the Solid value
   try {
index f8652b3facb9215ba859e6718cc93cc889bc8a3b..87277ae71fcc4c9c4fd5a47d84557f38906164c4 100644 (file)
@@ -100,7 +100,7 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations {
   Standard_EXPORT Handle(GEOM_Object) MakeFilling (Handle(GEOM_Object) theShape,
                                                    int theMinDeg, int theMaxDeg,
                                                    double theTol2D, double theTol3D,
-                                                   int theNbIter, bool isUseOri,
+                                                   int theNbIter, int theMethod,
                                                    bool isApprox);
 
   Standard_EXPORT Handle(GEOM_Object) MakeThruSections
index d5d875684f5c13d9f221d216f1dd371dd06eae70..c24aa969283ce2fa21dd112e77979c8ed8511fb7 100644 (file)
@@ -30,7 +30,7 @@
 #define FILL_ARG_SHAPE    5
 #define FILL_ARG_NBITER   6
 #define FILL_ARG_APPROX   7
-#define FILL_ARG_USEORI   8
+#define FILL_ARG_METHOD   8
 
 class GEOMImpl_IFilling
 {
@@ -53,8 +53,8 @@ class GEOMImpl_IFilling
   void SetApprox(bool theApprox) { _func->SetInteger(FILL_ARG_APPROX, theApprox); }
   bool GetApprox() { return _func->GetInteger(FILL_ARG_APPROX); } 
 
-  void SetUseOri(bool theUseOri) { _func->SetInteger(FILL_ARG_USEORI, theUseOri); }
-  bool GetUseOri() { return _func->GetInteger(FILL_ARG_USEORI); } 
+  void SetMethod(int theMethod) { _func->SetInteger(FILL_ARG_METHOD, theMethod); }
+  int GetMethod() { return _func->GetInteger(FILL_ARG_METHOD); } 
 
   void SetShape(Handle(GEOM_Function) theShape) { _func->SetReference(FILL_ARG_SHAPE, theShape); }
   Handle(GEOM_Function) GetShape() { return _func->GetReference(FILL_ARG_SHAPE); }
index c1ae473146373e135bd709f616cc291044a54565..b56c70e632c29714088143e922738d8147133278 100644 (file)
@@ -704,14 +704,15 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeRevolutionAxisAngle2Ways
  *  MakeFilling
  */
 //=============================================================================
-GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFilling(GEOM::GEOM_Object_ptr theShape,
-                                                            CORBA::Long theMinDeg,
-                                                            CORBA::Long theMaxDeg,
-                                                            CORBA::Double theTol2D,
-                                                            CORBA::Double theTol3D,
-                                                            CORBA::Long theNbIter,
-                                                            CORBA::Boolean theUseOri,
-                                                            CORBA::Boolean theApprox)
+GEOM::GEOM_Object_ptr
+GEOM_I3DPrimOperations_i::MakeFilling(GEOM::GEOM_Object_ptr theShape,
+                                      CORBA::Long theMinDeg,
+                                      CORBA::Long theMaxDeg,
+                                      CORBA::Double theTol2D,
+                                      CORBA::Double theTol3D,
+                                      CORBA::Long theNbIter,
+                                      GEOM::filling_oper_method theMethod,
+                                      CORBA::Boolean theApprox)
 {
   GEOM::GEOM_Object_var aGEOMObject;
 
@@ -723,10 +724,34 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFilling(GEOM::GEOM_Object_pt
 
   if (aShape.IsNull()) return aGEOMObject._retn();
 
+  int aMethod = 0;
+  switch (theMethod) {
+  case GEOM::FOM_Default:
+    {
+      // Default (standard behaviour)
+      aMethod = 0;
+    }
+    break;
+  case GEOM::FOM_UseOri:
+    {
+      // Use edges orientation
+      aMethod = 1;
+    }
+    break;
+  case GEOM::FOM_AutoCorrect:
+    {
+      // Auto-correct edges orientation
+      aMethod = 2;
+    }
+    break;
+  default:
+    {}
+  }
+
   //Create the Solid
   Handle(GEOM_Object) anObject = GetOperations()->MakeFilling
     (aShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter,
-     theUseOri, theApprox);
+     aMethod, theApprox);
   if (!GetOperations()->IsDone() || anObject.IsNull())
     return aGEOMObject._retn();
 
index a31221abb9b8c35b180e0cc265b7a556be426ef7..cabae19a53283298340b53d52781ede5a65afff1 100644 (file)
@@ -137,7 +137,8 @@ class GEOM_I_EXPORT GEOM_I3DPrimOperations_i :
   GEOM::GEOM_Object_ptr MakeFilling(GEOM::GEOM_Object_ptr theShape,
                                     CORBA::Long theMinDeg, CORBA::Long theMaxDeg,
                                     CORBA::Double theTol2D, CORBA::Double theTol3D,
-                                    CORBA::Long theNbIter, CORBA::Boolean theUseOri,
+                                    CORBA::Long theNbIter,
+                                    GEOM::filling_oper_method theMethod,
                                     CORBA::Boolean theApprox);
 
   GEOM::GEOM_Object_ptr MakeThruSections(const GEOM::ListOfGO& theSeqSections,
index 0ce3c95394cec5f990b441884baffaad5134c0b3..46d820c65ddc5fe827112f59b5d05dcd7c314cb9 100644 (file)
@@ -1247,7 +1247,7 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFilling (GEOM::GEOM_Object_ptr theShape
                                                  CORBA::Double theTol2D,
                                                   CORBA::Double theTol3D,
                                                  CORBA::Long theNbIter,
-                                                  CORBA::Boolean theUseOri,
+                                                  GEOM::filling_oper_method theMethod,
                                                   CORBA::Boolean theApprox)
 {
   beginService( " GEOM_Superv_i::MakeFilling" );
@@ -1255,7 +1255,7 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFilling (GEOM::GEOM_Object_ptr theShape
   get3DPrimOp();
   GEOM::GEOM_Object_ptr anObj =
     my3DPrimOp->MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D,
-                            theNbIter, theUseOri, theApprox);
+                            theNbIter, theMethod, theApprox);
   endService( " GEOM_Superv_i::MakeFilling" );
   return anObj;
 }
index a1d19e9fdb3fded2db3ae7468484bb9c5a5ca173..a5f4c9f046f95ac536f596d51097ff10c38a323b 100644 (file)
@@ -288,7 +288,8 @@ public:
   GEOM::GEOM_Object_ptr MakeFilling (GEOM::GEOM_Object_ptr theShape,
                                     CORBA::Long theMinDeg, CORBA::Long theMaxDeg,
                                     CORBA::Double theTol2D, CORBA::Double theTol3D,
-                                    CORBA::Long theNbIter, CORBA::Boolean theUseOri,
+                                    CORBA::Long theNbIter,
+                                     GEOM::filling_oper_method theMethod,
                                      CORBA::Boolean theApprox);
 
   GEOM::GEOM_Object_ptr MakeThruSections(const GEOM::ListOfGO& theSeqSections,
index c43b3fd2c5a24c2921d26d3dbf9a48e0badd3440..38ccb0933932eef53d25cad3cf4e369e452cf6b5 100644 (file)
@@ -70,7 +70,7 @@ GenerationGUI_FillingDlg::GenerationGUI_FillingDlg( GeometryGUI* theGeometryGUI,
   GroupPoints->TextLabel5->setText( tr( "GEOM_FILLING_MAX_DEG" ) );
   GroupPoints->TextLabel6->setText( tr( "GEOM_FILLING_TOL_3D" ) );
   GroupPoints->CheckBox1->setText( tr( "GEOM_FILLING_APPROX" ) );
-  GroupPoints->CheckBox2->setText( tr( "GEOM_FILLING_USEORI" ) );
+  GroupPoints->TextLabel7->setText( tr( "GEOM_FILLING_METHOD" ) );
   GroupPoints->PushButton1->setIcon( image1 );
   GroupPoints->LineEdit1->setReadOnly( true );
 
@@ -109,7 +109,7 @@ void GenerationGUI_FillingDlg::Init()
   myTol3D = 0.0001;
   myTol2D = 0.0001;
   myNbIter = 0;
-  myIsUseOri = false;
+  myMethod = 0;
   myIsApprox = false;
   myOkCompound = false;
 
@@ -130,6 +130,10 @@ void GenerationGUI_FillingDlg::Init()
   GroupPoints->SpinBox4->setValue( myMaxDeg );
   GroupPoints->SpinBox5->setValue( myTol3D );
 
+  GroupPoints->ComboBox1->addItem(tr("GEOM_FILLING_DEFAULT"));
+  GroupPoints->ComboBox1->addItem(tr("GEOM_FILLING_USEORI"));
+  GroupPoints->ComboBox1->addItem(tr("GEOM_FILLING_AUTO"));
+
   /* signals and slots connections */
   connect( buttonOk(),    SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
   connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
@@ -137,6 +141,8 @@ void GenerationGUI_FillingDlg::Init()
   connect( GroupPoints->PushButton1, SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
   connect( GroupPoints->LineEdit1,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
 
+  connect( GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(MethodChanged()));
+
   connect( GroupPoints->SpinBox1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
   connect( GroupPoints->SpinBox2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
   connect( GroupPoints->SpinBox3, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
@@ -146,9 +152,6 @@ void GenerationGUI_FillingDlg::Init()
   connect( GroupPoints->CheckBox1, SIGNAL( stateChanged( int ) ),
            this, SLOT( ApproxChanged() ) );
 
-  connect( GroupPoints->CheckBox2, SIGNAL( stateChanged( int ) ),
-           this, SLOT( UseOriChanged() ) );
-
   connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
 
   connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
@@ -322,12 +325,12 @@ void GenerationGUI_FillingDlg::ValueChangedInSpinBox( double newValue )
 }
 
 //=================================================================================
-// function : UseOriChanged()
+// function : MethodChanged
 // purpose  :
 //=================================================================================
-void GenerationGUI_FillingDlg::UseOriChanged()
+void GenerationGUI_FillingDlg::MethodChanged()
 {
-  myIsUseOri = GroupPoints->CheckBox2->isChecked();
+  myMethod = GroupPoints->ComboBox1->currentIndex();
   displayPreview();
 }
 
@@ -375,9 +378,19 @@ bool GenerationGUI_FillingDlg::execute( ObjectList& objects )
 {
   GEOM::GEOM_I3DPrimOperations_var anOper =
     GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
+
+  GEOM::filling_oper_method aMethod;
+  switch (GroupPoints->ComboBox1->currentIndex())
+  {
+    case 0:  aMethod = GEOM::FOM_Default; break;
+    case 1:  aMethod = GEOM::FOM_UseOri; break;
+    case 2:  aMethod = GEOM::FOM_AutoCorrect; break;
+    default: break;
+  }
+
   GEOM::GEOM_Object_var anObj =
     anOper->MakeFilling( myCompound, myMinDeg, myMaxDeg, myTol2D, myTol3D,
-                         myNbIter, myIsUseOri, myIsApprox );
+                         myNbIter, aMethod, myIsApprox );
   if ( !anObj->_is_nil() )
   {
     if ( !IsPreview() )
index f30dfa2bdc36d1a4d7c4e07db68b9a1ee99d1d33..e7b8ac075fe45f0c0c0d28089b193123c499ff1b 100644 (file)
@@ -60,7 +60,7 @@ private:
   Standard_Real                      myTol2D;
   Standard_Integer                   myNbIter;
   bool                               myIsApprox;
-  bool                               myIsUseOri;
+  int                                myMethod;
   bool                               myOkCompound; /* to check when curv. compound is defined */
 
   DlgRef_1Sel5Spin1Check*            GroupPoints;
@@ -73,7 +73,7 @@ private slots:
   void                               SelectionIntoArgument();
   void                               SetEditCurrentArgument();
   void                               ValueChangedInSpinBox( double );
-  void                               UseOriChanged();
+  void                               MethodChanged();
   void                               ApproxChanged();
   void                               SetDoubleSpinBoxStep( double );
 };