From 36ba432b4bbdc1b53074b35d4c89f75394b93e2c Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 28 Mar 2013 16:17:09 +0000 Subject: [PATCH] The fix to show all element with the same color when all values are almost equal. --- src/OBJECT/SMESH_DeviceActor.cxx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/OBJECT/SMESH_DeviceActor.cxx b/src/OBJECT/SMESH_DeviceActor.cxx index c82bbf305..259573aff 100644 --- a/src/OBJECT/SMESH_DeviceActor.cxx +++ b/src/OBJECT/SMESH_DeviceActor.cxx @@ -295,30 +295,42 @@ SMESH_DeviceActor vtkIdType aNbCells = aGrid->GetNumberOfCells(); aScalars->SetNumberOfComponents(1); aScalars->SetNumberOfTuples(aNbCells); + double* range;// = aScalars->GetRange(); myVisualObj->UpdateFunctor(theFunctor); using namespace SMESH::Controls; - if(NumericalFunctor* aNumericalFunctor = dynamic_cast(theFunctor.get())){ + if(NumericalFunctor* aNumericalFunctor = dynamic_cast(theFunctor.get())) + { for(vtkIdType i = 0; i < aNbCells; i++){ vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i); vtkIdType anObjId = myVisualObj->GetElemObjId(anId); double aValue = aNumericalFunctor->GetValue(anObjId); aScalars->SetValue(i,aValue); } - }else if(Predicate* aPredicate = dynamic_cast(theFunctor.get())){ + range = aScalars->GetRange(); + if ( range[1] - range[0] < ( qMax(qAbs(range[0]),qAbs(range[1])) + 1e-100 ) * 1e-6 ) + { + range[1] = range[0]; + for(vtkIdType i = 0; i < aNbCells; i++) + aScalars->SetValue(i,range[0]); + } + } + else if(Predicate* aPredicate = dynamic_cast(theFunctor.get())) + { for(vtkIdType i = 0; i < aNbCells; i++){ vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i); vtkIdType anObjId = myVisualObj->GetElemObjId(anId); bool aValue = aPredicate->IsSatisfy(anObjId); aScalars->SetValue(i,aValue); } + range = aScalars->GetRange(); } aDataSet->GetCellData()->SetScalars(aScalars); aScalars->Delete(); - - theLookupTable->SetRange(aScalars->GetRange()); + + theLookupTable->SetRange( range ); theLookupTable->SetNumberOfTableValues(theScalarBarActor->GetMaximumNumberOfColors()); theLookupTable->Build(); -- 2.39.2