Salome HOME
#16954 EDF 19466 - localsize
authoreap <eap@opencascade.com>
Thu, 13 Jun 2019 15:49:10 +0000 (18:49 +0300)
committereap <eap@opencascade.com>
Thu, 13 Jun 2019 15:49:10 +0000 (18:49 +0300)
Limit local size by Min and User Size

src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx
src/GUI/BLSURFPlugin_msg_en.ts

index 4ff245c730c821a7a7ef81239e389bea153f82ea..196fcc1c17c99c5c6c3f82d51319fa289f40716f 100644 (file)
@@ -564,12 +564,6 @@ bool BLSURFPluginGUI_HypothesisCreator::checkParams(QString& msg) const
       }
     }
   }
-  if ( !ok )
-  {
-    h->SetOptionValues( myOptions ); // restore values
-    h->SetPreCADOptionValues( myPreCADOptions ); // restore values
-    return ok;
-  }
 
   // SizeMap and attractors
   if ( ok )
@@ -590,7 +584,7 @@ bool BLSURFPluginGUI_HypothesisCreator::checkParams(QString& msg) const
           try {
             e = entry.toStdString();
             s = that->mySMPMap[entry].toStdString();
-            h->SetSizeMapEntry( e.c_str(), s.c_str() );
+            //h->SetSizeMapEntry( e.c_str(), s.c_str() );
           }
           catch ( const SALOME::SALOME_Exception& ex )
           {
@@ -637,9 +631,61 @@ bool BLSURFPluginGUI_HypothesisCreator::checkParams(QString& msg) const
       msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_CHORDAL_ERROR"));
   }
 
+  // #16954 EDF 19466 - localsize
+  // Warn the user if local size is less than Min Size
+  if ( ok &&
+       !myStdWidget->myMinSizeRel->isChecked() &&
+       !myStdWidget->myMinSize->text().isEmpty() )
+  {
+    const double minSize = myStdWidget->myMinSize->GetValue();
+    bool isValue;
+    for ( QMapIterator<QString,QString> i( mySMPMap ); i.hasNext() &&  ok ; )
+    {
+      i.next();
+      double size = i.value().toDouble( &isValue );
+      ok = ( !isValue || size >= minSize );
+    }
+    for ( QMapIterator<QString, TAttractorVec > i( myATTMap ); i.hasNext() &&  ok ; i.next() )
+    {
+      const TAttractorVec& attVec = i.value();
+      for ( size_t i = 0; i < attVec.size(); ++i )
+        ok = ( attVec[i].IsToDelete()  || attVec[i].startSize >= minSize );
+    }
+    if ( !ok )
+      msg = tr( "TOO_SMALL_LOCAL_SIZE" );
+  }
+  // Warn the user if local size is more than User Size
+  if ( ok &&
+       !myStdWidget->myPhySizeRel->isChecked() &&
+       !myStdWidget->myPhySize->text().isEmpty() )
+  {
+    const double userSize = myStdWidget->myPhySize->GetValue();
+    bool isValue;
+    for ( QMapIterator<QString,QString> i( mySMPMap ); i.hasNext() &&  ok ; )
+    {
+      i.next();
+      double size = i.value().toDouble( &isValue );
+      ok = ( !isValue || size <= userSize );
+    }
+    for ( QMapIterator<QString, TAttractorVec > i( myATTMap ); i.hasNext() &&  ok ; i.next() )
+    {
+      const TAttractorVec& attVec = i.value();
+      for ( size_t i = 0; i < attVec.size(); ++i )
+        ok = ( attVec[i].IsToDelete()  || attVec[i].startSize <= userSize );
+    }
+    if ( !ok )
+      msg = tr( "TOO_LARGE_LOCAL_SIZE" );
+  }
+
   // Enforced vertices
   // TODO
 
+  if ( !ok )
+  {
+    h->SetOptionValues( myOptions ); // restore values
+    h->SetPreCADOptionValues( myPreCADOptions ); // restore values
+  }
+
   return ok;
 }
 
@@ -2760,7 +2806,6 @@ void BLSURFPluginGUI_HypothesisCreator::onTabChanged(int tab)
       myHyPatchFaceSelBtn->toggle();
     if ( myHyPatchGroupSelBtn->isChecked() )
       myHyPatchGroupSelBtn->toggle();
-    return;
   }
   else if ( sender() == smpTab )
   {
@@ -2777,6 +2822,22 @@ void BLSURFPluginGUI_HypothesisCreator::onTabChanged(int tab)
     myAttractorCheck->setChecked(false);
     myConstSizeCheck->setChecked(false);
   }
+
+  if ( tab == SMP_TAB ) // [#16954] limit local size by Min and User Size
+  {
+    double minSize = 0, maxSize = COORD_MAX;
+
+    if ( !myStdWidget->myMinSizeRel->isChecked() &&
+         !myStdWidget->myMinSize->text().isEmpty() )
+      minSize = myStdWidget->myMinSize->GetValue();
+
+    if ( !myStdWidget->myPhySizeRel->isChecked() &&
+         !myStdWidget->myPhySize->text().isEmpty() )
+      maxSize = myStdWidget->myPhySize->GetValue();
+
+    mySmpSizeSpin->RangeStepAndValidator(minSize, maxSize, 1.0, "length_precision");
+    myAttSizeSpin->RangeStepAndValidator(minSize, maxSize, 1.0, "length_precision");
+  }
 }
 
 void BLSURFPluginGUI_HypothesisCreator::onAttractorClicked(int state)
index 8117f433edde3ae75f4ed3c679bf29464975408b..41a84a879a1a8091da1be9696373fd51381eb2a5 100644 (file)
@@ -502,6 +502,14 @@ The smaller this distance is, the closer the mesh is to the exact surface (only
         <source>ZERO_VALUE_OF</source>
         <translation>Invalid value (zero) of "%1"</translation>
     </message>
+    <message>
+        <source>TOO_SMALL_LOCAL_SIZE</source>
+        <translation>Local size should be more than Min Size</translation>
+    </message>
+    <message>
+        <source>TOO_LARGE_LOCAL_SIZE</source>
+        <translation>Local size should be less than User Size</translation>
+    </message>
     <message>
         <source>BLSURF_PERIODICITY</source>
         <translation>Periodicity</translation>