Salome HOME
[bos #40653][CEA] New mesh import export formats with meshio.
[modules/smesh.git] / src / OBJECT / SMESH_Actor.cxx
index d9e47586c42f180086b608d097df2083ef781945..2799e4494d5292f79b638af2bc02776369c57507 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -953,6 +953,14 @@ void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
       myControlActor = my3DActor;
       break;
     }
+    case eScaledJacobian:
+    {
+      SMESH::Controls::ScaledJacobian* aControl = new SMESH::Controls::ScaledJacobian();
+      aControl->SetPrecision( myControlsPrecision );
+      myFunctor.reset( aControl );
+      myControlActor = my3DActor;
+      break;
+    }
     case eMaxElementLength2D:
     {
       SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
@@ -1005,6 +1013,14 @@ void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
       myControlActor = my2DActor;
       break;
     }
+    case eWarping3D:
+    {
+      SMESH::Controls::Warping3D* aControl = new SMESH::Controls::Warping3D();
+      aControl->SetPrecision(myControlsPrecision);
+      myFunctor.reset(aControl);
+      myControlActor = my3DActor;
+      break;
+    }
     case eSkew:
     {
       SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
@@ -1070,6 +1086,10 @@ void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
         my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
         UpdateDistribution();
         break;
+      case eWarping3D:
+        my2DExtActor->SetExtControlMode(myFunctor, myScalarBarActor, myLookupTable);
+        UpdateDistribution();
+        break;
       default:
         myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
         UpdateDistribution();
@@ -1112,7 +1132,6 @@ void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
     QString aTitle = QString(myScalarBarActor->GetTitle());
     aTitle.replace(QRegExp("(:\\s).*"),"\\1"+ QString::number(GetNumberControlEntities()));
     myScalarBarActor->SetTitle(aTitle.toUtf8().constData());
-
   }
   else {
     if(theCheckEntityMode){
@@ -1508,12 +1527,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:
@@ -1534,6 +1555,7 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
       case eBareBorderFace:
       case eOverConstrainedFace:
       case eCoincidentElems2D:
+      case eWarping3D:
         my2DExtActor->VisibilityOn();
         break;
       case eBareBorderVolume:
@@ -1543,14 +1565,14 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
         break;
       default:;
       }
-      if ( myFunctor && myVisualObj->GetNbEntities( myFunctor->GetType() ))
-        myScalarBarActor->VisibilityOn();
-    }
+      myScalarBarActor->VisibilityOn();
+    }    
 
     if ( GetPickable( ))
       myPickableActor->VisibilityOn();
 
-    if ( GetRepresentation() != ePoint )
+    if ( GetRepresentation() != ePoint && 
+      !(IsClipThresholdOn() && GetActorForThreshold() != myControlActor)) // Avoid calling VisibilityOn if for display result of Threshold Criteria need only ExtActor
     {
       if(myEntityMode & e0DElements  ){
         my0DActor->VisibilityOn();
@@ -1826,7 +1848,7 @@ void SMESH_ActorDef::UpdateHighlight()
   case SMESH_DeviceActor::eSurface:
   case SMESH_DeviceActor::eWireframe:
     {
-      anIsVisible = !IsWireframeOff();
+      anIsVisible = anIsVisible && !IsWireframeOff();
 
       if(myIsHighlighted) {
         myHighlitableActor->SetProperty(myHighlightProp);
@@ -2494,11 +2516,27 @@ void SMESH_ActorDef::UpdateScalarBar()
 
 }
 
+// Get Actor for Threshold criteria compute
+SMESH_DeviceActor* SMESH_ActorDef::GetActorForThreshold()
+{
+  switch (myControlMode) {
+  case eLength2D:
+    return my1DExtActor;
+  case eWarping3D:
+    return my2DExtActor;
+  default:;
+    return myControlActor;
+  }
+}
+
 // Hides the cells beyond threshold if isThresholdOn == true.
-void SMESH_ActorDef::ClipThreshold(bool isThresholdOn, double min /*= 0.0*/, double max /*= 0.0*/)
+void SMESH_ActorDef::ClipThreshold(bool isThresholdOn,double min /*= 0.0*/, double max /*= 0.0*/)
 {
+  SMESH_DeviceActor* anActor = GetActorForThreshold();
+  if (anActor != myControlActor)
+    myControlActor->VisibilityOff();
+
   myIsClipThresholdOn = isThresholdOn;
-  
   if (isThresholdOn)
   {
     // Initialize the filter
@@ -2506,7 +2544,7 @@ void SMESH_ActorDef::ClipThreshold(bool isThresholdOn, double min /*= 0.0*/, dou
 
     // 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->SetInputConnection(anActor->myMergeFilter->GetOutputPort());
     threshold->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, vtkDataSetAttributes::SCALARS);
 
     // Set range
@@ -2520,12 +2558,18 @@ void SMESH_ActorDef::ClipThreshold(bool isThresholdOn, double min /*= 0.0*/, dou
 
     // Add to the filters' chain
     vtkAlgorithmOutput* port = threshold->GetOutputPort();
-    myControlActor->myPassFilter[0]->SetInputConnection(port);
+    anActor->myPassFilter[0]->SetInputConnection(port);
   }
   else
   {
     // Restore the filters' chain
-    myControlActor->SetImplicitFunctionUsed(myControlActor->myIsImplicitFunctionUsed);
+    anActor->SetImplicitFunctionUsed(anActor->myIsImplicitFunctionUsed);
+    // Restore Actor filters when after Controls, which not use ExtACtor was called Controls, which use ExtActor
+    // For avoid artifact's
+    if (anActor != myControlActor)
+      myControlActor->SetImplicitFunctionUsed(myControlActor->myIsImplicitFunctionUsed);
+
+    myControlActor->VisibilityOn();
   }
 }