The fix to show all element with the same color when all values are almost equal.

This commit is contained in:
eap 2013-03-28 16:17:09 +00:00
parent b3cac3834a
commit 36ba432b4b

View File

@ -295,30 +295,42 @@ SMESH_DeviceActor
vtkIdType aNbCells = aGrid->GetNumberOfCells(); vtkIdType aNbCells = aGrid->GetNumberOfCells();
aScalars->SetNumberOfComponents(1); aScalars->SetNumberOfComponents(1);
aScalars->SetNumberOfTuples(aNbCells); aScalars->SetNumberOfTuples(aNbCells);
double* range;// = aScalars->GetRange();
myVisualObj->UpdateFunctor(theFunctor); myVisualObj->UpdateFunctor(theFunctor);
using namespace SMESH::Controls; using namespace SMESH::Controls;
if(NumericalFunctor* aNumericalFunctor = dynamic_cast<NumericalFunctor*>(theFunctor.get())){ if(NumericalFunctor* aNumericalFunctor = dynamic_cast<NumericalFunctor*>(theFunctor.get()))
{
for(vtkIdType i = 0; i < aNbCells; i++){ for(vtkIdType i = 0; i < aNbCells; i++){
vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i); vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
vtkIdType anObjId = myVisualObj->GetElemObjId(anId); vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
double aValue = aNumericalFunctor->GetValue(anObjId); double aValue = aNumericalFunctor->GetValue(anObjId);
aScalars->SetValue(i,aValue); aScalars->SetValue(i,aValue);
} }
}else if(Predicate* aPredicate = dynamic_cast<Predicate*>(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<Predicate*>(theFunctor.get()))
{
for(vtkIdType i = 0; i < aNbCells; i++){ for(vtkIdType i = 0; i < aNbCells; i++){
vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i); vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
vtkIdType anObjId = myVisualObj->GetElemObjId(anId); vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
bool aValue = aPredicate->IsSatisfy(anObjId); bool aValue = aPredicate->IsSatisfy(anObjId);
aScalars->SetValue(i,aValue); aScalars->SetValue(i,aValue);
} }
range = aScalars->GetRange();
} }
aDataSet->GetCellData()->SetScalars(aScalars); aDataSet->GetCellData()->SetScalars(aScalars);
aScalars->Delete(); aScalars->Delete();
theLookupTable->SetRange(aScalars->GetRange()); theLookupTable->SetRange( range );
theLookupTable->SetNumberOfTableValues(theScalarBarActor->GetMaximumNumberOfColors()); theLookupTable->SetNumberOfTableValues(theScalarBarActor->GetMaximumNumberOfColors());
theLookupTable->Build(); theLookupTable->Build();