- vtkLookupTable* aLut = vtkLookupTable::New();
- aLut->SetHueRange( HUE_START, HUE_END );
- aLut->SetSaturationRange( SATURATION_START, SATURATION_END );
- aLut->SetTableRange( Z_MIN, Z_MAX );
- aLut->SetValueRange( 1.0, 1.0 );
- aLut->SetAlphaRange( 1.0, 1.0 );
- aLut->SetNumberOfColors( NB_COLORS );
- aLut->Build();
-
- vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New();
- aMapper->SetScalarRange( Z_MIN, Z_MAX );
- aMapper->ScalarVisibilityOn();
- aMapper->SetScalarModeToUsePointData();
- aMapper->SetLookupTable( aLut );
- aMapper->SetInputData( aVertexGrid );
+ // Update the lookup table range if this bathymetry is out of it
+ if ( myLookupTable )
+ {
+ aZValues->GetRange( myInternalZRange );
+ double* aGlobalRange = myLookupTable->GetRange();
+ // If the global range is not yet initialized or the current one is out of scope then update the global
+ bool anIsUpdated = false;
+ if ( ValuesEquals( aGlobalRange[0], anInvalidZ ) || ( aGlobalRange[0] > myInternalZRange[0] ) )
+ {
+ aGlobalRange[0] = myInternalZRange[0];
+ anIsUpdated = true;
+ }
+
+ if ( ValuesEquals( aGlobalRange[1], anInvalidZ ) || ( aGlobalRange[1] < myInternalZRange[1] ) )
+ {
+ aGlobalRange[1] = myInternalZRange[1];
+ anIsUpdated = true;
+ }
+
+ if ( anIsUpdated )
+ {
+ myLookupTable->SetRange( aGlobalRange );
+ myLookupTable->Build();
+ }
+
+ myMapper->SetScalarRange( aGlobalRange );
+ myMapper->ScalarVisibilityOn();
+ myMapper->SetScalarModeToUsePointData();
+ myMapper->SetLookupTable( myLookupTable );
+ }
+
+ myMapper->SetInputData( aVertexGrid );