<div dir="ltr">Hello and thank you for your answers.<div>I implemented what Cory said and it is working as expected!</div><div>I used two LUTs, one with the original range of colors, and one where I added two values for the out of range values.</div><div>Finally, I attach the full LUT to the color vtkActor but the original LUT to the vtkScalarBarActor.</div><div><br></div><div>Here's the relevant part of my code, with some comments.</div><div>Hope this is useful for someone in the future. Thank you very much.</div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">// m_configuration has all the parameters to display the color field</font></div><div><div><font face="monospace, monospace">int numColors = static_cast<int>(m_configuration.numOfColors);</font></div><div><font face="monospace, monospace">double rangeForTable[2]; // range of values in the Point Data</font></div><div><font face="monospace, monospace">rangeForTable[0] = m_configuration.currentRange[m_configuration.componentToUse*2];</font></div><div><font face="monospace, monospace">rangeForTable[1] = m_configuration.currentRange[m_configuration.componentToUse*2+1];</font></div><div><br></div><div><font face="monospace, monospace">// Generate a table only for the colors with our full range</font></div><div><font face="monospace, monospace">vtkSmartPointer<vtkLookupTable> tempLUT = vtkSmartPointer<vtkLookupTable>::New();</font></div><div><font face="monospace, monospace">tempLUT->SetTableRange (rangeForTable); </font></div><div><font face="monospace, monospace">tempLUT->SetNumberOfTableValues(numColors);</font></div><div><font face="monospace, monospace">tempLUT->SetHueRange (m_configuration.rangeHue[0], m_configuration.rangeHue[1]);</font></div><div><font face="monospace, monospace">tempLUT->SetSaturationRange (m_configuration.rangeSaturation[0], m_configuration.rangeSaturation[1]);</font></div><div><font face="monospace, monospace">tempLUT->SetValueRange (m_configuration.rangeValue[0], m_configuration.rangeValue[1]);</font></div><div><font face="monospace, monospace">tempLUT->Build();</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">// Calculate the new range as the previous range plus the two new values.</font></div><div><font face="monospace, monospace">double newRange[2];</font></div><div><font face="monospace, monospace">double deltaColor = (rangeForTable[1]-rangeForTable[0])/double(numColors+1);</font></div><div><font face="monospace, monospace">// Redefine the range to include below and above values. </font></div><div><font face="monospace, monospace">newRange[0] = rangeForTable[0]-deltaColor;</font></div><div><font face="monospace, monospace">newRange[1] = rangeForTable[1]+deltaColor;</font></div><div><br></div><div><font face="monospace, monospace">m_scalarBarLUT->SetTableRange(newRange);</font></div><div><font face="monospace, monospace">m_scalarBarLUT->SetNumberOfTableValues(numColors+2); // two more for the below and above range</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">m_scalarBarLUT->SetTableValue(0, 0.3, 0.3, 0.3, 1.0); // below color, first</font></div><div><span style="font-family:monospace,monospace"><br></span></div><div><span style="font-family:monospace,monospace">// Copy the values from one LUT to the other (displaced one because I added one value at the beginning).</span><br></div><div><font face="monospace, monospace">for (int i = 0; i < numColors; ++i)</font></div><div><font face="monospace, monospace">{</font></div><div><font face="monospace, monospace"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>double colorRGBA[4];</font></div><div><font face="monospace, monospace"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>tempLUT->GetTableValue(i, colorRGBA);</font></div><div><font face="monospace, monospace"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>m_scalarBarLUT->SetTableValue(i+1, colorRGBA);</font></div><div><font face="monospace, monospace">}</font></div><div><font face="monospace, monospace">m_scalarBarLUT->SetTableValue(numColors+1, 0.3, 0.3, 0.3, 1.0); //above color, last.</font></div><div><font face="monospace, monospace">m_scalarBarLUT->Build();</font></div><div><br></div><div><font face="monospace, monospace">// Edit the number of different values on the scalar bar</font></div><div><font face="monospace, monospace">m_scalarBarActor->SetMaximumNumberOfColors(numColors);</font></div><div><font face="monospace, monospace">m_scalarBarActor->SetNumberOfLabels(numColors+1); // We have one more label to align the labels to the lines of separation between colors.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">// Important here: I attach the full LUT to the color actor (with the new range), but the incomplete (without the out of range values) to the scalar bar</font></div><div><font face="monospace, monospace">m_mapperForActor->SetScalarRange(newRange); // vtkMapper</font></div><div><font face="monospace, monospace">m_mapperForActor->SetLookupTable(m_scalarBarLUT);</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">m_scalarBarActor->SetLookupTable(tempLUT); // vtkScalarBarActor</font></div></div><div><br></div><div><font face="monospace, monospace"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span><br></font></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 30 March 2017 at 22:24, Kimmel, Jason <span dir="ltr"><<a href="mailto:jason.kimmel@albint.com" target="_blank">jason.kimmel@albint.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
We were able to do something in 5.10 similar to what Cory suggests, but using a single lookuptable. See the code sample below, it's been edited a bit for clarity as the actual code uses other objects:<br>
<br>
//setup lookup table<br>
m_lut = vtkLookupTable::New();<br>
m_lut->SetRampToLinear();<br>
m_lut->SetRange(0,1);<br>
m_lut->SetNumberOfTableValues(<wbr>LUT_SIZE);<br>
m_lut->SetValueRange(1,1);<br>
m_lut->SetHueRange(0,2.0/3.0);<br>
m_lut->SetSaturationRange(1,1)<wbr>;<br>
m_lut->ForceBuild();<br>
<br>
//reserve 10% for special values<br>
m_lut->SetRange(0,1.1);<br>
m_lut->SetNumberOfTableValues(<wbr>LUT_SIZE*1.1);<br>
<br>
//set up special values<br>
m_lut->SetTableValue(LUT_SIZE,<wbr>m_lut->GetTableValue(LUT_SIZE-<wbr>1));<br>
int idx = m_lut->GetIndex(1.01);<br>
m_lut->SetTableValue(idx,.85,.<wbr>85,.85);<br>
<br>
I think the biggest trick is to make sure that the lookuptable is not updated (built) again after setting up the special values. Note the above only adds an extra color above the range, but it would be easy to extend to add a color below the original range as well.<br>
<br>
Hope that helps,<br>
Jason<br>
<div><div class="h5"><br>
-----Original Message-----<br>
From: vtkusers [mailto:<a href="mailto:vtkusers-bounces@vtk.org">vtkusers-bounces@vtk.<wbr>org</a>] On Behalf Of Cory Quammen<br>
Sent: Thursday, March 30, 2017 8:11 AM<br>
To: Fernando Nellmeldin <<a href="mailto:f.nellmeldin@open-engineering.com">f.nellmeldin@open-<wbr>engineering.com</a>><br>
Cc: vtk-users <<a href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>><br>
Subject: Re: [vtkusers] Out of range colors in LookupTable in VTK 5.10<br>
<br>
Fernando,<br>
<br>
It should be possible with a little work. You will need to set the color table values yourself. For illustration, let's say you have 4 colors in your color table with data range [0, 8]. You'll need to add one color at the bottom of the table for the below range color and one at the top for the above range color for a total of 6 table colors.<br>
You'll need to adjust your range so that 0 still gets mapped to the previously lowest color and 8 to the previously highest color. In this example, your new range should be [-2, 10]. Now, anything below 0 should map to your below range color in the table and anything about 7 should map to your above range color.<br>
<br>
To set table values explicitly, you can use vtkLookupTable::SetTableValue (vtkIdType indx, double rgba[4]). The trick will be to maintain the lookup table generation of the colors via HSV range while setting table values explicitly - you can't do both in the same vtkLookupTable instance. You might want to use two vtkLookupTables in this case, one that generates the colors via the HSV range, and then use that to build a second vtkLookupTable in which you modify the range and add the above/below range colors.<br>
<br>
HTH,<br>
Cory<br>
<br>
On Thu, Mar 30, 2017 at 7:56 AM, Fernando Nellmeldin <<a href="mailto:f.nellmeldin@open-engineering.com">f.nellmeldin@open-<wbr>engineering.com</a>> wrote:<br>
> Hello.<br>
> I have an unstructuredgrid with point data which I display as a color<br>
> map in the model.<br>
> Let's say the range of the values is [100, 500] and I map blue to 100<br>
> and red to 500. I create a lookuptable with the range of HSV values<br>
> for the colors I want, and everything works as expected.<br>
> Problem is, I would like to have a special color for values below 100<br>
> and values over 500 (gray, for example).<br>
><br>
> I do know that this feature exist from VTK 6 as<br>
> vtkLookupTable::<wbr>setBelowRangeColor and vtkLookupTable::<wbr>setAboveRangeColor.<br>
> But, for compatibility reasons, we are stuck -for the moment- with VTK 5.10.<br>
><br>
> Is there an easy way to accomplish this with VTK 5.10? I've seen the<br>
> code inside vtkLookupTable but there were a lot of changes and I can't<br>
> find the way to do it by myself without modifying my own version of<br>
> VTK (by editing vtkLookupTable in VTK 5.10 with the code added in VTK 6).<br>
><br>
> Thank you.<br>
><br>
> --<br>
> Fernando NELLMELDIN<br>
> Software Engineer<br>
> ______________________________<wbr>______________________________<wbr>___<br>
><br>
> Open Engineering s.a.<br>
><br>
> Rue Bois Saint-Jean 15/1<br>
> B-4102 Seraing (Belgium)<br>
> Tel: +32.4.353.30.34<br>
><br>
</div></div>> <a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.op" rel="noreferrer" target="_blank">https://na01.safelinks.<wbr>protection.outlook.com/?url=<wbr>http%3A%2F%2Fwww.op</a><br>
> <a href="http://en-engineering.com" rel="noreferrer" target="_blank">en-engineering.com</a>&data=01%<wbr>7C01%7CJason.Kimmel%<a href="http://40albint.com" rel="noreferrer" target="_blank">40albint.<wbr>com</a>%7C5ad9f51d<br>
> f86140fca50108d47765d6d4%<wbr>7Cff3d33ae31364152812675e51f4a<wbr>1404%7C0&sdata=<br>
> zI0EH%<wbr>2FVLnc2TBtypv7qFz0C4JR2Cvs4qG4<wbr>65i4rVP3M%3D&reserved=0<br>
> <a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.l" rel="noreferrer" target="_blank">https://na01.safelinks.<wbr>protection.outlook.com/?url=<wbr>https%3A%2F%2Fwww.l</a><br>
> <a href="http://inkedin.com" rel="noreferrer" target="_blank">inkedin.com</a>%2Fcompany%2Fopen-<wbr>engineering%3Ftrk%3Dbiz-<wbr>companies-cym&dat<br>
> a=01%7C01%7CJason.Kimmel%<a href="http://40albint.com" rel="noreferrer" target="_blank">40alb<wbr>int.com</a>%<wbr>7C5ad9f51df86140fca50108d47765<wbr>d6<br>
> d4%<wbr>7Cff3d33ae31364152812675e51f4a<wbr>1404%7C0&sdata=ldlzw0LT%<wbr>2BMgFVnxEPmGV<br>
> ZARlta85na7LQiGdhZMBb%2B4%3D&<wbr>reserved=0<br>
> ______________________________<wbr>______________________________<wbr>__________<br>
> ___<br>
><br>
> ______________________________<wbr>_________________<br>
> Powered by<br>
> <a href="https://na01.safelinks.protection.outlook.com/?url=www.kitware.com&dat" rel="noreferrer" target="_blank">https://na01.safelinks.<wbr>protection.outlook.com/?url=<wbr>www.kitware.com&dat</a><br>
> a=01%7C01%7CJason.Kimmel%<a href="http://40albint.com" rel="noreferrer" target="_blank">40alb<wbr>int.com</a>%<wbr>7C5ad9f51df86140fca50108d47765<wbr>d6<br>
> d4%<wbr>7Cff3d33ae31364152812675e51f4a<wbr>1404%7C0&sdata=<wbr>Qc1VRMLblcX3z7p9LzDrA8<br>
> hS2PkPgyxcpC%2F0J40VZzQ%3D&<wbr>reserved=0<br>
<span class="">><br>
> Visit other Kitware open-source projects at<br>
</span>> <a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.ki" rel="noreferrer" target="_blank">https://na01.safelinks.<wbr>protection.outlook.com/?url=<wbr>http%3A%2F%2Fwww.ki</a><br>
> <a href="http://tware.com" rel="noreferrer" target="_blank">tware.com</a>%2Fopensource%<wbr>2Fopensource.html&data=01%<wbr>7C01%7CJason.Kimmel%4<br>
> <a href="http://0albint.com" rel="noreferrer" target="_blank">0albint.com</a>%<wbr>7C5ad9f51df86140fca50108d47765<wbr>d6d4%7Cff3d33ae3136415281267<br>
> 5e51f4a1404%7C0&sdata=<wbr>JooMrwa5BojD%<wbr>2Bpe78RcbyglmPQNWMTGEr5V18ySgI<wbr>Fw%3D<br>
> &reserved=0<br>
<span class="">><br>
> Please keep messages on-topic and check the VTK FAQ at:<br>
</span>> <a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.vt" rel="noreferrer" target="_blank">https://na01.safelinks.<wbr>protection.outlook.com/?url=<wbr>http%3A%2F%2Fwww.vt</a><br>
> <a href="http://k.org" rel="noreferrer" target="_blank">k.org</a>%2FWiki%2FVTK_FAQ&data=<wbr>01%7C01%7CJason.Kimmel%<a href="http://40albint.com" rel="noreferrer" target="_blank">40albin<wbr>t.com</a>%7C5ad9<br>
> f51df86140fca50108d47765d6d4%<wbr>7Cff3d33ae31364152812675e51f4a<wbr>1404%7C0&sd<br>
> ata=<wbr>IRTZ9qReZgvxlmLGnA1CFgSuz1S9Qd<wbr>mdowqVV%2FwBbfI%3D&reserved=0<br>
<span class="">><br>
> Search the list archives at:<br>
</span>> <a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmarkma" rel="noreferrer" target="_blank">https://na01.safelinks.<wbr>protection.outlook.com/?url=<wbr>http%3A%2F%2Fmarkma</a><br>
> <a href="http://il.org" rel="noreferrer" target="_blank">il.org</a>%2Fsearch%2F%3Fq%<wbr>3Dvtkusers&data=01%7C01%<wbr>7CJason.Kimmel%40albint<br>
> .com%<wbr>7C5ad9f51df86140fca50108d47765<wbr>d6d4%<wbr>7Cff3d33ae31364152812675e51f4a<br>
> 1404%7C0&sdata=ai%<wbr>2Fv3gOrF5vGV2bHn6bnJsNY5YQJfwz<wbr>btn%2BOu8crerg%3D&rese<br>
> rved=0<br>
<span class="">><br>
> Follow this link to subscribe/unsubscribe:<br>
</span>> <a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpublic" rel="noreferrer" target="_blank">https://na01.safelinks.<wbr>protection.outlook.com/?url=<wbr>http%3A%2F%2Fpublic</a><br>
> .<a href="http://kitware.com" rel="noreferrer" target="_blank">kitware.com</a>%2Fmailman%<wbr>2Flistinfo%2Fvtkusers&data=01%<wbr>7C01%7CJason.Kimm<br>
> el%<a href="http://40albint.com" rel="noreferrer" target="_blank">40albint.com</a>%<wbr>7C5ad9f51df86140fca50108d47765<wbr>d6d4%7Cff3d33ae313641528<br>
> 12675e51f4a1404%7C0&sdata=<wbr>J05L%2FEc%2BbEXeIGHX%<wbr>2FeJHpGbaXS8W0jXvNx40hu<br>
> 3%2Fxxc%3D&reserved=0<br>
<span class="">><br>
<br>
<br>
<br>
--<br>
Cory Quammen<br>
Staff R&D Engineer<br>
Kitware, Inc.<br>
</span>______________________________<wbr>_________________<br>
Powered by <a href="https://na01.safelinks.protection.outlook.com/?url=www.kitware.com&data=01%7C01%7CJason.Kimmel%40albint.com%7C5ad9f51df86140fca50108d47765d6d4%7Cff3d33ae31364152812675e51f4a1404%7C0&sdata=Qc1VRMLblcX3z7p9LzDrA8hS2PkPgyxcpC%2F0J40VZzQ%3D&reserved=0" rel="noreferrer" target="_blank">https://na01.safelinks.<wbr>protection.outlook.com/?url=<wbr>www.kitware.com&data=01%7C01%<wbr>7CJason.Kimmel%40albint.com%<wbr>7C5ad9f51df86140fca50108d47765<wbr>d6d4%<wbr>7Cff3d33ae31364152812675e51f4a<wbr>1404%7C0&sdata=<wbr>Qc1VRMLblcX3z7p9LzDrA8hS2PkPgy<wbr>xcpC%2F0J40VZzQ%3D&reserved=0</a><br>
<br>
Visit other Kitware open-source projects at <a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com%2Fopensource%2Fopensource.html&data=01%7C01%7CJason.Kimmel%40albint.com%7C5ad9f51df86140fca50108d47765d6d4%7Cff3d33ae31364152812675e51f4a1404%7C0&sdata=JooMrwa5BojD%2Bpe78RcbyglmPQNWMTGEr5V18ySgIFw%3D&reserved=0" rel="noreferrer" target="_blank">https://na01.safelinks.<wbr>protection.outlook.com/?url=<wbr>http%3A%2F%2Fwww.kitware.com%<wbr>2Fopensource%2Fopensource.<wbr>html&data=01%7C01%7CJason.<wbr>Kimmel%40albint.com%<wbr>7C5ad9f51df86140fca50108d47765<wbr>d6d4%<wbr>7Cff3d33ae31364152812675e51f4a<wbr>1404%7C0&sdata=JooMrwa5BojD%<wbr>2Bpe78RcbyglmPQNWMTGEr5V18ySgI<wbr>Fw%3D&reserved=0</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.vtk.org%2FWiki%2FVTK_FAQ&data=01%7C01%7CJason.Kimmel%40albint.com%7C5ad9f51df86140fca50108d47765d6d4%7Cff3d33ae31364152812675e51f4a1404%7C0&sdata=IRTZ9qReZgvxlmLGnA1CFgSuz1S9QdmdowqVV%2FwBbfI%3D&reserved=0" rel="noreferrer" target="_blank">https://na01.safelinks.<wbr>protection.outlook.com/?url=<wbr>http%3A%2F%2Fwww.vtk.org%<wbr>2FWiki%2FVTK_FAQ&data=01%7C01%<wbr>7CJason.Kimmel%40albint.com%<wbr>7C5ad9f51df86140fca50108d47765<wbr>d6d4%<wbr>7Cff3d33ae31364152812675e51f4a<wbr>1404%7C0&sdata=<wbr>IRTZ9qReZgvxlmLGnA1CFgSuz1S9Qd<wbr>mdowqVV%2FwBbfI%3D&reserved=0</a><br>
<br>
Search the list archives at: <a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmarkmail.org%2Fsearch%2F%3Fq%3Dvtkusers&data=01%7C01%7CJason.Kimmel%40albint.com%7C5ad9f51df86140fca50108d47765d6d4%7Cff3d33ae31364152812675e51f4a1404%7C0&sdata=ai%2Fv3gOrF5vGV2bHn6bnJsNY5YQJfwzbtn%2BOu8crerg%3D&reserved=0" rel="noreferrer" target="_blank">https://na01.safelinks.<wbr>protection.outlook.com/?url=<wbr>http%3A%2F%2Fmarkmail.org%<wbr>2Fsearch%2F%3Fq%3Dvtkusers&<wbr>data=01%7C01%7CJason.Kimmel%<wbr>40albint.com%<wbr>7C5ad9f51df86140fca50108d47765<wbr>d6d4%<wbr>7Cff3d33ae31364152812675e51f4a<wbr>1404%7C0&sdata=ai%<wbr>2Fv3gOrF5vGV2bHn6bnJsNY5YQJfwz<wbr>btn%2BOu8crerg%3D&reserved=0</a><br>
<span class=""><br>
Follow this link to subscribe/unsubscribe:<br>
</span><a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpublic.kitware.com%2Fmailman%2Flistinfo%2Fvtkusers&data=01%7C01%7CJason.Kimmel%40albint.com%7C5ad9f51df86140fca50108d47765d6d4%7Cff3d33ae31364152812675e51f4a1404%7C0&sdata=J05L%2FEc%2BbEXeIGHX%2FeJHpGbaXS8W0jXvNx40hu3%2Fxxc%3D&reserved=0" rel="noreferrer" target="_blank">https://na01.safelinks.<wbr>protection.outlook.com/?url=<wbr>http%3A%2F%2Fpublic.kitware.<wbr>com%2Fmailman%2Flistinfo%<wbr>2Fvtkusers&data=01%7C01%<wbr>7CJason.Kimmel%40albint.com%<wbr>7C5ad9f51df86140fca50108d47765<wbr>d6d4%<wbr>7Cff3d33ae31364152812675e51f4a<wbr>1404%7C0&sdata=J05L%2FEc%<wbr>2BbEXeIGHX%<wbr>2FeJHpGbaXS8W0jXvNx40hu3%<wbr>2Fxxc%3D&reserved=0</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><b>Fernando NELLMELDIN</b><br>Software Engineer<div style="font-size:12.8px"><b style="font-size:12.8px"><font color="#cc0000">_______________________________________________________________</font></b><br></div><div><div style="font-size:12.8px"><b style="font-size:12.8px"><font color="#000000"><br></font></b></div><div style="font-size:12.8px"><b style="font-size:12.8px"><font color="#000000">O</font><font color="#cc0000">pen E</font><font color="#000000">ngineering s.a.</font></b><br></div><div style="font-size:12.8px"><font color="#000000"><br></font></div><div style="font-size:12.8px"><font color="#000000">Rue Bois Saint-Jean 15/1</font></div><div style="font-size:12.8px"><font color="#000000">B-4102 Seraing (Belgium)</font></div><div><font color="#000000" style="font-size:12.8px">Tel: </font>+32.4.353.30.34 </div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><a href="http://www.open-engineering.com/" style="color:rgb(17,85,204)" target="_blank">http://www.open-engineering.com</a></div><div style="font-size:12.8px"><a href="https://www.linkedin.com/company/open-engineering?trk=biz-companies-cym" style="color:rgb(17,85,204)" target="_blank">https://www.linkedin.com/company/open-engineering?trk=biz-companies-cym</a><br></div><div style="font-size:12.8px"><b><font color="#cc0000"><span style="font-family:'arial black',sans-serif;font-size:12.8px">_________________________________________________________________________<br></span></font></b></div></div></div></div></div></div></div>
</div>