]> SALOME platform Git repositories - modules/smesh.git/blobdiff - src/OBJECT/SMESH_Actor.cxx
Salome HOME
[bos #32736][CEA] Threshold of criteria. Fixed showing Wireframe for hidden objects.
[modules/smesh.git] / src / OBJECT / SMESH_Actor.cxx
index 1d0400ce20925081a17606289449d298f477c36b..d54efb3b1ab65e75c2d30164c1b1d66dd1103b34 100644 (file)
@@ -80,6 +80,9 @@
 #include <vtkImplicitBoolean.h>
 #include <vtkImplicitFunctionCollection.h>
 
+#include <vtkThreshold.h>
+#include <vtkPassThrough.h>
+
 #include "utilities.h"
 
 
@@ -120,6 +123,7 @@ SMESH_ActorDef::SMESH_ActorDef()
   myIsPointsVisible = false;
   myIsEntityModeCache = false;
   myRepresentationCache = 0;
+  objectEntitiesCache = 0;
 
   myHighlightActor = SMESH_SVTKActor::New();
   myHighlightActor->Delete(); // vtkSmartPointer!
@@ -837,6 +841,8 @@ void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
   my3DActor->GetMapper()->SetScalarVisibility(false);
   myBallActor->GetMapper()->SetScalarVisibility(false);
   myScalarBarActor->SetVisibility(false);
+  ClipThreshold(false);
+  SetWireframeOff(false);
 
   bool anIsScalarVisible = theMode > eNone;
 
@@ -1502,12 +1508,14 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
   my3DExtActor->VisibilityOff();
 
   myScalarBarActor->VisibilityOff();
+  
 
   if ( GetVisibility() ) {
     if ( theIsUpdateRepersentation )
       SetRepresentation(GetRepresentation());
-
-    if(myControlMode != eNone) {
+  
+    // Avoid calling VisibilityOn of ExtActor after editing hypothesis. Use the same criteria than scalarBarActor
+    if( myControlMode != eNone && myFunctor && myVisualObj->GetNbEntities( myFunctor->GetType() ) ) { 
       switch(myControlMode) {
       case eFreeNodes:
       case eCoincidentNodes:
@@ -1537,9 +1545,8 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
         break;
       default:;
       }
-      if ( myFunctor && myVisualObj->GetNbEntities( myFunctor->GetType() ))
-        myScalarBarActor->VisibilityOn();
-    }
+      myScalarBarActor->VisibilityOn();
+    }    
 
     if ( GetPickable( ))
       myPickableActor->VisibilityOn();
@@ -1647,6 +1654,12 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
     SetRepresentation( ePoint );
   }
 
+  if ( anObjectEntities != 0 && objectEntitiesCache == 0 )
+  {
+    objectEntitiesCache = anObjectEntities;
+    SetRepresentation( eSurface );
+  }
+
   if ( myEntityMode != theMode )
   {
     myEntityMode = theMode; // entities to show
@@ -1814,6 +1827,8 @@ void SMESH_ActorDef::UpdateHighlight()
   case SMESH_DeviceActor::eSurface:
   case SMESH_DeviceActor::eWireframe:
     {
+      anIsVisible = anIsVisible && !IsWireframeOff();
+
       if(myIsHighlighted) {
         myHighlitableActor->SetProperty(myHighlightProp);
       }else if(myIsPreselected){
@@ -2480,6 +2495,49 @@ void SMESH_ActorDef::UpdateScalarBar()
 
 }
 
+// Hides the cells beyond threshold if isThresholdOn == true.
+void SMESH_ActorDef::ClipThreshold(bool isThresholdOn, double min /*= 0.0*/, double max /*= 0.0*/)
+{
+  myIsClipThresholdOn = isThresholdOn;
+  
+  if (isThresholdOn)
+  {
+    // Initialize the filter
+    vtkSmartPointer<vtkThreshold> threshold = vtkSmartPointer<vtkThreshold>::New();
+
+    // We have set scalar data with SMESH_DeviceActor::SetControlMode() call as vtkDataSetAttributes::SCALARS.
+    // So, we don't need to pass an array name in SetInputArrayToProcess().
+    threshold->SetInputConnection(myControlActor->myMergeFilter->GetOutputPort());               
+    threshold->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, vtkDataSetAttributes::SCALARS);
+
+    // Set range
+    threshold->SetThresholdFunction(vtkThreshold::THRESHOLD_BETWEEN);
+    threshold->SetLowerThreshold(min);
+    threshold->SetUpperThreshold(max);
+
+    // Debug output
+    threshold->Update();
+    SCRUTE(threshold->GetOutput()->GetNumberOfCells());
+
+    // Add to the filters' chain
+    vtkAlgorithmOutput* port = threshold->GetOutputPort();
+    myControlActor->myPassFilter[0]->SetInputConnection(port);
+  }
+  else
+  {
+    // Restore the filters' chain
+    myControlActor->SetImplicitFunctionUsed(myControlActor->myIsImplicitFunctionUsed);
+  }
+}
+
+// Hides the wireframe if isWireframeOff == true.
+void SMESH_ActorDef::SetWireframeOff(bool isWireframeOff)
+{
+  myIsWireframeOff = isWireframeOff;
+
+  UpdateHighlight();
+}
+
 void SMESH_ActorDef::UpdateDistribution()
 {
   if(SMESH::Controls::NumericalFunctor* fun =