Salome HOME
FixedPoints hypothesis: fix problem with values close to 0.0 and 1.0
authorvsr <vsr@opencascade.com>
Tue, 29 Sep 2009 16:52:15 +0000 (16:52 +0000)
committervsr <vsr@opencascade.com>
Tue, 29 Sep 2009 16:52:15 +0000 (16:52 +0000)
src/StdMeshersGUI/StdMeshersGUI_FixedPointsParamWdg.cxx

index 0069a7b4e223032f32d8add8233adfff85d74c0f..c5c228bc74bc7f7e733c2e4eb2c024128d35ca0e 100644 (file)
@@ -48,6 +48,8 @@
 
 #define TOLERANCE 1e-7
 #define EQUAL_DBL(a,b) (fabs(a-b)<TOLERANCE)
+#define LT_DBL(a,b) ((a<b)&&!EQUAL_DBL(a,b))
+#define GT_DBL(a,b) ((a>b)&&!EQUAL_DBL(a,b))
 
 /*
  * class : Tree Widget Item Delegate
@@ -255,13 +257,13 @@ QString StdMeshersGUI_FixedPointsParamWdg::treeItemText( double v1, double v2 )
 //=================================================================================
 void StdMeshersGUI_FixedPointsParamWdg::addPoint( double v)
 {
-  if ( v > 0 && v < 1) {
+  if ( GT_DBL(v, 0.0) && LT_DBL(v, 1.0)) {
     bool toInsert = true;
     int idx = myTreeWidget->topLevelItemCount()-1;
     for ( int i = 0 ; i < myListWidget->count(); i++ ) {
       double lv = point( i );
-      if ( EQUAL_DBL(lv,v) ) { toInsert = false; break; }
-      else if ( lv > v ) {
+      if ( EQUAL_DBL(lv, v) ) { toInsert = false; break; }
+      else if ( GT_DBL(lv, v) ) {
        idx = i; break;
       }
     }
@@ -333,7 +335,8 @@ void StdMeshersGUI_FixedPointsParamWdg::onCheckBoxChanged()
 //=================================================================================
 void StdMeshersGUI_FixedPointsParamWdg::updateState()
 {
-  myAddButton->setEnabled( mySpinBox->value() > 0 && mySpinBox->value() < 1 );
+  double v = mySpinBox->value();
+  myAddButton->setEnabled( GT_DBL(v, 0.0) && LT_DBL(v, 1.0) );
   myRemoveButton->setEnabled( myListWidget->selectedItems().count() > 0 );
 }