]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
0023272: [CEA] Add a tolerance for basic properties computation
authorskv <skv@opencascade.com>
Tue, 18 Oct 2016 16:54:53 +0000 (19:54 +0300)
committerskv <skv@opencascade.com>
Tue, 18 Oct 2016 16:54:53 +0000 (19:54 +0300)
doc/salome/gui/GEOM/images/neo-basicprop.png [changed mode: 0755->0644]
doc/salome/gui/GEOM/input/basic_prop.doc
idl/GEOM_Gen.idl
src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx
src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx
src/GEOM_I/GEOM_IMeasureOperations_i.cc
src/GEOM_I/GEOM_IMeasureOperations_i.hh
src/GEOM_SWIG/geomBuilder.py
src/MeasureGUI/MeasureGUI_PropertiesDlg.cxx
src/MeasureGUI/MeasureGUI_PropertiesDlg.h

old mode 100755 (executable)
new mode 100644 (file)
index e36d937..a5b769d
Binary files a/doc/salome/gui/GEOM/images/neo-basicprop.png and b/doc/salome/gui/GEOM/images/neo-basicprop.png differ
index 4210731ca7509391e0717181c430a1fb75337a54..e9feb5d84ad99970c820b9fdc73745211c257b4d 100644 (file)
@@ -15,8 +15,9 @@ in the viewer to navigate between selectable objects.
 For more details, please refer to the \em "Functionality common for OCC and VTK viewers" chapter
 of the GUI module's documentation.
 
 For more details, please refer to the \em "Functionality common for OCC and VTK viewers" chapter
 of the GUI module's documentation.
 
-<b>TUI Command:</b> <em>geompy.BasicProperties(Shape),</em> where
-\em Shape is a shape whose properties are inquired.
+<b>TUI Command:</b> <em>geompy.BasicProperties(Shape, theTolerance=1.e-6),</em>
+where \em Shape is a shape whose properties are inquired, \em theTolerance is
+maximal relative error of area and volume computation.
 
 See also a \ref tui_basic_properties_page "TUI example".
 
 
 See also a \ref tui_basic_properties_page "TUI example".
 
index 1d275720c0aba1863762816261991223d78913ed..66f23e436fa4fbf0f36e1aa46813c38ca116433d 100644 (file)
@@ -4337,12 +4337,14 @@ module GEOM
      *  \brief Get summarized length of all wires,
      *  area of surface and volume of the given shape.
      *  \param theShape Shape to define properties of.
      *  \brief Get summarized length of all wires,
      *  area of surface and volume of the given shape.
      *  \param theShape Shape to define properties of.
+     *  \param theTolerance maximal relative error of area and volume computation.
      *  \param theLength Output. Summarized length of all wires of the given shape.
      *  \param theSurfArea Output. Area of surface of the given shape.
      *  \param theVolume Output. Volume of the given shape.
      *  \return Returns shape properties through the last three arguments.
      */
     void GetBasicProperties (in GEOM_Object theShape,
      *  \param theLength Output. Summarized length of all wires of the given shape.
      *  \param theSurfArea Output. Area of surface of the given shape.
      *  \param theVolume Output. Volume of the given shape.
      *  \return Returns shape properties through the last three arguments.
      */
     void GetBasicProperties (in GEOM_Object theShape,
+                             in double theTolerance,
                              out double theLength,
                              out double theSurfArea,
                              out double theVolume);
                              out double theLength,
                              out double theSurfArea,
                              out double theVolume);
index 6cebe14bc5f862e7511d442db4d62130683f91f4..f713b46667a60c03a80b3d29c0236d94da4211f5 100644 (file)
@@ -965,6 +965,7 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetNormal
  */
 //=============================================================================
 void GEOMImpl_IMeasureOperations::GetBasicProperties (Handle(GEOM_Object) theShape,
  */
 //=============================================================================
 void GEOMImpl_IMeasureOperations::GetBasicProperties (Handle(GEOM_Object) theShape,
+                                                      const Standard_Real theTolerance,
                                                       Standard_Real& theLength,
                                                       Standard_Real& theSurfArea,
                                                       Standard_Real& theVolume)
                                                       Standard_Real& theLength,
                                                       Standard_Real& theSurfArea,
                                                       Standard_Real& theVolume)
@@ -984,7 +985,7 @@ void GEOMImpl_IMeasureOperations::GetBasicProperties (Handle(GEOM_Object) theSha
 
   //Compute the parameters
   GProp_GProps LProps, SProps;
 
   //Compute the parameters
   GProp_GProps LProps, SProps;
-  Standard_Real anEps = 1.e-6;
+  Standard_Real anEps = theTolerance >= 0 ? theTolerance : 1.e-6;
   try {
     OCC_CATCH_SIGNALS;
     BRepGProp::LinearProperties(aShape, LProps);
   try {
     OCC_CATCH_SIGNALS;
     BRepGProp::LinearProperties(aShape, LProps);
index 6943814dd590842bdf6e19b5feede871bc221263..abc02def73d8352fbf129560b3b02e7a048582b7 100644 (file)
@@ -119,6 +119,7 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
                                                  Handle(GEOM_Object) theOptionalPoint);
 
   Standard_EXPORT void GetBasicProperties (Handle(GEOM_Object) theShape,
                                                  Handle(GEOM_Object) theOptionalPoint);
 
   Standard_EXPORT void GetBasicProperties (Handle(GEOM_Object) theShape,
+                                           const Standard_Real theTolerance,
                                            Standard_Real& theLength,
                                            Standard_Real& theSurfArea,
                                            Standard_Real& theVolume);
                                            Standard_Real& theLength,
                                            Standard_Real& theSurfArea,
                                            Standard_Real& theVolume);
index 7babefba88f35b746feacf08c9defe206724ca12..97e8df9698b1a18e0e1e19abbadf29b0cf9840e0 100644 (file)
@@ -495,6 +495,7 @@ GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetNormal
  */
 //=============================================================================
 void GEOM_IMeasureOperations_i::GetBasicProperties (GEOM::GEOM_Object_ptr theShape,
  */
 //=============================================================================
 void GEOM_IMeasureOperations_i::GetBasicProperties (GEOM::GEOM_Object_ptr theShape,
+                                                    CORBA::Double  theTolerance,
                                                     CORBA::Double& theLength,
                                                     CORBA::Double& theSurfArea,
                                                     CORBA::Double& theVolume)
                                                     CORBA::Double& theLength,
                                                     CORBA::Double& theSurfArea,
                                                     CORBA::Double& theVolume)
@@ -507,7 +508,8 @@ void GEOM_IMeasureOperations_i::GetBasicProperties (GEOM::GEOM_Object_ptr theSha
   if (aShape.IsNull()) return;
 
   // Get shape parameters
   if (aShape.IsNull()) return;
 
   // Get shape parameters
-  GetOperations()->GetBasicProperties(aShape, theLength, theSurfArea, theVolume);
+  GetOperations()->GetBasicProperties(aShape, theTolerance, theLength,
+                                      theSurfArea, theVolume);
 }
 
 //=============================================================================
 }
 
 //=============================================================================
index 9311fb9461ed8c73ae663777e2ed6d27059a0fa8..80b55c2c18473fb40a9750e53b27bde39d2bee78 100644 (file)
@@ -52,6 +52,7 @@ class GEOM_I_EXPORT GEOM_IMeasureOperations_i :
                     CORBA::Double& Xx, CORBA::Double& Xy, CORBA::Double& Xz);
 
   void GetBasicProperties (GEOM::GEOM_Object_ptr theShape,
                     CORBA::Double& Xx, CORBA::Double& Xy, CORBA::Double& Xz);
 
   void GetBasicProperties (GEOM::GEOM_Object_ptr theShape,
+                           CORBA::Double  theTolerance,
                            CORBA::Double& theLength,
                            CORBA::Double& theSurfArea,
                            CORBA::Double& theVolume);
                            CORBA::Double& theLength,
                            CORBA::Double& theSurfArea,
                            CORBA::Double& theVolume);
index 29161717f77029422e77f11272c1e86609e59d30..b46ff1c6640249fec600b18e7f8094c24f1faf8f 100644 (file)
@@ -10579,6 +10579,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
         ## Get summarized length of all wires,
         #  area of surface and volume of the given shape.
         #  @param theShape Shape to define properties of.
         ## Get summarized length of all wires,
         #  area of surface and volume of the given shape.
         #  @param theShape Shape to define properties of.
+        #  @param theTolerance maximal relative error of area
+        #         and volume computation.
         #  @return [theLength, theSurfArea, theVolume]\n
         #  theLength:   Summarized length of all wires of the given shape.\n
         #  theSurfArea: Area of surface of the given shape.\n
         #  @return [theLength, theSurfArea, theVolume]\n
         #  theLength:   Summarized length of all wires of the given shape.\n
         #  theSurfArea: Area of surface of the given shape.\n
@@ -10586,13 +10588,15 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
         #
         #  @ref tui_basic_properties_page "Example"
         @ManageTransactions("MeasuOp")
         #
         #  @ref tui_basic_properties_page "Example"
         @ManageTransactions("MeasuOp")
-        def BasicProperties(self,theShape):
+        def BasicProperties(self,theShape, theTolerance=1.e-6):
             """
             Get summarized length of all wires,
             area of surface and volume of the given shape.
 
             Parameters:
                 theShape Shape to define properties of.
             """
             Get summarized length of all wires,
             area of surface and volume of the given shape.
 
             Parameters:
                 theShape Shape to define properties of.
+                theTolerance maximal relative error of area
+                             and volume computation.
 
             Returns:
                 [theLength, theSurfArea, theVolume]
 
             Returns:
                 [theLength, theSurfArea, theVolume]
@@ -10601,7 +10605,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                  theVolume:   Volume of the given shape.
             """
             # Example: see GEOM_TestMeasures.py
                  theVolume:   Volume of the given shape.
             """
             # Example: see GEOM_TestMeasures.py
-            aTuple = self.MeasuOp.GetBasicProperties(theShape)
+            aTuple = self.MeasuOp.GetBasicProperties(theShape, theTolerance)
             RaiseIfFailed("GetBasicProperties", self.MeasuOp)
             return aTuple
 
             RaiseIfFailed("GetBasicProperties", self.MeasuOp)
             return aTuple
 
index dbf95b0246565e6eeacb61660e180f493b1c9065..38a06a7e03654081dfda30feb9c24f53ab242181 100644 (file)
@@ -37,6 +37,8 @@
 
 #include <TColStd_MapOfInteger.hxx>
 
 
 #include <TColStd_MapOfInteger.hxx>
 
+#define DEFAULT_TOLERANCE_VALUE 1.e-6
+
 //=================================================================================
 // class    : MeasureGUI_PropertiesDlg()
 // purpose  : Constructs a MeasureGUI_PropertiesDlg which is a child of 'parent', with the 
 //=================================================================================
 // class    : MeasureGUI_PropertiesDlg()
 // purpose  : Constructs a MeasureGUI_PropertiesDlg which is a child of 'parent', with the 
 //            true to construct a modal dialog.
 //=================================================================================
 MeasureGUI_PropertiesDlg::MeasureGUI_PropertiesDlg( GeometryGUI* GUI, QWidget* parent )
 //            true to construct a modal dialog.
 //=================================================================================
 MeasureGUI_PropertiesDlg::MeasureGUI_PropertiesDlg( GeometryGUI* GUI, QWidget* parent )
-  : MeasureGUI_Skeleton( GUI, parent )
+  : MeasureGUI_Skeleton(GUI, parent),
+    myTolerance(0),
+    myLength(0),
+    mySurface(0),
+    myVolume(0)
 {
   QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
     "GEOM", tr( "ICON_DLG_BASICPROPERTIES" ) ) );
 {
   QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
     "GEOM", tr( "ICON_DLG_BASICPROPERTIES" ) ) );
@@ -59,21 +65,45 @@ MeasureGUI_PropertiesDlg::MeasureGUI_PropertiesDlg( GeometryGUI* GUI, QWidget* p
   mainFrame()->GroupConstructors->setTitle( tr( "GEOM_PROPERTIES" ) );
   mainFrame()->RadioButton1->setIcon( image0 );
 
   mainFrame()->GroupConstructors->setTitle( tr( "GEOM_PROPERTIES" ) );
   mainFrame()->RadioButton1->setIcon( image0 );
 
-  myGrp = new MeasureGUI_1Sel3LineEdit( centralWidget()  );
-  myGrp->GroupBox1->setTitle( tr( "GEOM_PROPERTIES_CONSTR" ) );
-  myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
-  myGrp->TextLabel2->setText( tr( "GEOM_LENGTH" ) );
-  myGrp->TextLabel3->setText( tr( "GEOM_PROPERTIES_SURFACE" ) );
-  myGrp->TextLabel4->setText( tr( "GEOM_PROPERTIES_VOLUME" ) );
-  myGrp->LineEdit1->setReadOnly( true );
-  myGrp->PushButton1->setIcon( image1 );
-  myGrp->LineEdit2->setReadOnly( true );
-  myGrp->LineEdit3->setReadOnly( true );
-  myGrp->LineEdit4->setReadOnly( true );
-
-  QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
-  layout->setMargin( 0 ); layout->setSpacing( 6 );
-  layout->addWidget( myGrp );
+  QGroupBox *aGrpBox  =
+          new QGroupBox(tr("GEOM_PROPERTIES_CONSTR"), centralWidget());
+  QLabel    *anObjLbl = new QLabel(tr("GEOM_OBJECT"), aGrpBox);
+  QLabel    *aTolLbl  = new QLabel(tr("GEOM_TOLERANCE"), aGrpBox);
+  QLabel    *aLenLbl  = new QLabel(tr("GEOM_LENGTH"), aGrpBox);
+  QLabel    *aSurfLbl = new QLabel(tr("GEOM_PROPERTIES_SURFACE"), aGrpBox);
+  QLabel    *aVolLbl  = new QLabel(tr("GEOM_PROPERTIES_VOLUME"), aGrpBox);
+
+  mySelBtn    = new QPushButton(aGrpBox);
+  mySelBtn->setIcon(image1);
+  mySelEdit   = new QLineEdit(aGrpBox);
+  mySelEdit->setReadOnly(true);
+  myTolerance = new SalomeApp_DoubleSpinBox(aGrpBox);
+  myLength    = new QLineEdit(aGrpBox);
+  mySurface   = new QLineEdit(aGrpBox);
+  myVolume    = new QLineEdit(aGrpBox);
+  myLength->setReadOnly(true);
+  mySurface->setReadOnly(true);
+  myVolume->setReadOnly(true);
+
+  QGridLayout* aLayout = new QGridLayout(aGrpBox);
+
+  aLayout->setMargin(9);
+  aLayout->setSpacing(6);
+  aLayout->addWidget(anObjLbl,    0, 0);
+  aLayout->addWidget(aTolLbl,     1, 0);
+  aLayout->addWidget(aLenLbl,     2, 0);
+  aLayout->addWidget(aSurfLbl,    3, 0);
+  aLayout->addWidget(aVolLbl,     4, 0);
+  aLayout->addWidget(mySelBtn,    0, 1);
+  aLayout->addWidget(mySelEdit,   0, 2);
+  aLayout->addWidget(myTolerance, 1, 1, 1, 2);
+  aLayout->addWidget(myLength,    2, 1, 1, 2);
+  aLayout->addWidget(mySurface,   3, 1, 1, 2);
+  aLayout->addWidget(myVolume,    4, 1, 1, 2);
+
+  QVBoxLayout* aDlgLayout = new QVBoxLayout( centralWidget() );
+  aDlgLayout->setMargin( 0 ); aDlgLayout->setSpacing( 6 );
+  aDlgLayout->addWidget(aGrpBox);
   
   /***************************************************************/
 
   
   /***************************************************************/
 
@@ -99,9 +129,24 @@ MeasureGUI_PropertiesDlg::~MeasureGUI_PropertiesDlg()
 //=================================================================================
 void MeasureGUI_PropertiesDlg::Init()
 {
 //=================================================================================
 void MeasureGUI_PropertiesDlg::Init()
 {
-  mySelBtn = myGrp->PushButton1;
-  mySelEdit = myGrp->LineEdit1;
+  mySelEdit->setMinimumSize(100, 0);
+
+  // Obtain precision from preferences
+  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+  int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
+
+  myTolerance->setPrecision(aPrecision);
+  // it's necessary to set decimals before the range setting,
+  // by default Qt rounds boundaries to 2 decimals at setRange
+  myTolerance->setDecimals(qAbs(aPrecision));
+  myTolerance->setRange(0., 1.);
+  myTolerance->setSingleStep(DEFAULT_TOLERANCE_VALUE);
+  myTolerance->setValue(DEFAULT_TOLERANCE_VALUE);
+
   MeasureGUI_Skeleton::Init();
   MeasureGUI_Skeleton::Init();
+
+  connect(myTolerance, SIGNAL(valueChanged(double)),
+          this, SLOT(toleranceChanged(double)));
 }
 
 //=================================================================================
 }
 
 //=================================================================================
@@ -146,6 +191,16 @@ void MeasureGUI_PropertiesDlg::SelectionIntoArgument()
   processObject();
   redisplayPreview();
 }
   processObject();
   redisplayPreview();
 }
+
+//=================================================================================
+// function : isValid
+// purpose  :
+//=================================================================================
+bool MeasureGUI_PropertiesDlg::isValid(QString& msg)
+{
+  return myTolerance->isValid(msg) && MeasureGUI_Skeleton::isValid(msg);
+}
+
 //=================================================================================
 // function : processObject
 // purpose  :
 //=================================================================================
 // function : processObject
 // purpose  :
@@ -156,16 +211,16 @@ void MeasureGUI_PropertiesDlg::processObject()
   
   if ( !getParameters( aLength, anArea, aVolume ) ) {
     mySelEdit->setText( "" );
   
   if ( !getParameters( aLength, anArea, aVolume ) ) {
     mySelEdit->setText( "" );
-    myGrp->LineEdit2->setText( "" );
-    myGrp->LineEdit3->setText( "" );
-    myGrp->LineEdit4->setText( "" );
+    myLength->setText( "" );
+    mySurface->setText( "" );
+    myVolume->setText( "" );
   }
   else {
     SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
     int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
   }
   else {
     SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
     int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
-    myGrp->LineEdit2->setText( DlgRef::PrintDoubleValue( aLength, aPrecision ) );
-    myGrp->LineEdit3->setText( DlgRef::PrintDoubleValue( anArea,  aPrecision ) );
-    myGrp->LineEdit4->setText( DlgRef::PrintDoubleValue( aVolume, aPrecision ) );
+    myLength->setText( DlgRef::PrintDoubleValue( aLength, aPrecision ) );
+    mySurface->setText( DlgRef::PrintDoubleValue( anArea,  aPrecision ) );
+    myVolume->setText( DlgRef::PrintDoubleValue( aVolume, aPrecision ) );
   }
 }
 
   }
 }
 
@@ -182,7 +237,7 @@ bool MeasureGUI_PropertiesDlg::getParameters( double& theLength,
   else {
     GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() );
     try {
   else {
     GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() );
     try {
-      anOper->GetBasicProperties( myObj.get(), theLength, theArea, theVolume );
+      anOper->GetBasicProperties( myObj.get(), myTolerance->value(), theLength, theArea, theVolume );
     }
     catch( const SALOME::SALOME_Exception& e ) {
       SalomeApp_Tools::QtCatchCorbaException( e );
     }
     catch( const SALOME::SALOME_Exception& e ) {
       SalomeApp_Tools::QtCatchCorbaException( e );
@@ -210,3 +265,12 @@ SALOME_Prs* MeasureGUI_PropertiesDlg::buildPrs()
   }
   return prs;
 }
   }
   return prs;
 }
+
+//=================================================================================
+// function : toleranceChanged
+// purpose  :
+//=================================================================================
+void MeasureGUI_PropertiesDlg::toleranceChanged(double)
+{
+  processObject();
+}
index ae759610c5442325d784aa9fca4b12453388dcfa..660f0ce10c302c69322bee107145f73199c7fac6 100644 (file)
@@ -29,7 +29,8 @@
 
 #include "MeasureGUI_Skeleton.h"
 
 
 #include "MeasureGUI_Skeleton.h"
 
-class MeasureGUI_1Sel3LineEdit;
+class SalomeApp_DoubleSpinBox;
+class QLineEdit;
 
 //=================================================================================
 // class    : MeasureGUI_PropertiesDlg
 
 //=================================================================================
 // class    : MeasureGUI_PropertiesDlg
@@ -46,6 +47,7 @@ public:
   
 protected:
   // redefined from GEOMBase_Helper and MeasureGUI_Skeleton
   
 protected:
   // redefined from GEOMBase_Helper and MeasureGUI_Skeleton
+  virtual bool                        isValid( QString& );
   virtual void                        processObject();
   virtual void                        activateSelection();
   virtual void                        SelectionIntoArgument();
   virtual void                        processObject();
   virtual void                        activateSelection();
   virtual void                        SelectionIntoArgument();
@@ -57,8 +59,14 @@ private:
                                                      double&,
                                                      double& );
 
                                                      double&,
                                                      double& );
 
-private:    
-  MeasureGUI_1Sel3LineEdit*           myGrp;
+private:
+  SalomeApp_DoubleSpinBox *myTolerance;
+  QLineEdit               *myLength;
+  QLineEdit               *mySurface;
+  QLineEdit               *myVolume;
+
+private slots:
+  void                                toleranceChanged(double);
 };
 
 #endif // MEASUREGUI_PROPERTIESDLG_H
 };
 
 #endif // MEASUREGUI_PROPERTIESDLG_H