X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FOBJECT%2FSMESH_Actor.cxx;h=e4e50c362ba7d76e37777cfa6ca535b1fd4a379e;hb=120207d740662965e1ca6dfe8325d1e7edad0e73;hp=44d2747b755ff2c0893e03823e9e1efc112435d6;hpb=d9f4b53e489dd5857db264ede6acded7b076c9f1;p=modules%2Fsmesh.git diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index 44d2747b7..e4e50c362 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2023 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 @@ -80,13 +80,11 @@ #include #include +#include +#include + #include "utilities.h" -#ifdef _DEBUG_ -static int MYDEBUG = 0; -#else -static int MYDEBUG = 0; -#endif SMESH_ActorDef* SMESH_ActorDef::New(){ return new SMESH_ActorDef(); @@ -114,7 +112,7 @@ SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj, SMESH_ActorDef::SMESH_ActorDef() { - if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<Delete(); // vtkSmartPointer! @@ -589,7 +588,7 @@ SMESH_ActorDef::SMESH_ActorDef() SMESH_ActorDef::~SMESH_ActorDef() { - if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<GetMapper()->SetScalarVisibility(false); myBallActor->GetMapper()->SetScalarVisibility(false); myScalarBarActor->SetVisibility(false); + ClipThreshold(false); + SetWireframeOff(false); bool anIsScalarVisible = theMode > eNone; @@ -1507,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: @@ -1542,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(); @@ -1652,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 @@ -1819,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){ @@ -1927,7 +1937,7 @@ void SMESH_ActorDef::Render(vtkRenderer* /*ren*/) void SMESH_ActorDef::Update() { - if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update"); + MESSAGE("SMESH_ActorDef::Update"); myVisualObj->Update(); @@ -2485,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 threshold = vtkSmartPointer::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 = @@ -2657,7 +2710,7 @@ void SMESH_ActorDef::UpdateFilter() } if ( GetVisibility() ) aFilter->Update(); - if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells()); + MESSAGE(aFilter->GetOutput()->GetNumberOfCells()); } #ifndef DISABLE_PLOT2DVIEWER