Thanks David and Bill. Even I change the color of the actor to none, I got only one color I set in the lookup table. I can't test my application right now. Can you please tell me why we need triangulation in the given example?<div>
<br></div><div><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/Color_a_mesh_by_height" target="_blank" style>http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/Color_a_mesh_by_height</a> </div><div><br></div><div> I am just a beginner in this, so please bear with me. </div>
<div><div><br><div class="gmail_quote">On Fri, Feb 3, 2012 at 7:14 PM, Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Change<br>
mapper->ScalarVisibilityOff();<br>
to<br>
mapper->ScalarVisibilityOn();<br>
<br>
When ScalarVisibility is off, the color of the actor is used. If it is<br>
On, the scalar data mapped through the lookup table will be used.<br>
<div class="im"><br>
<br>
On Fri, Feb 3, 2012 at 2:19 AM, Gishara Indeewarie <<a href="mailto:gish.777@gmail.com">gish.777@gmail.com</a>> wrote:<br>
</div><div><div class="h5">> Hi all,<br>
><br>
> I have a set of points (x,y,z) and the values of each point. I have created<br>
> a surface according to the following example.<br>
> <a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Filters/SurfaceFromUnorganizedPoints" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Filters/SurfaceFromUnorganizedPoints</a><br>
><br>
> And I want to create a color map by giving colors to each point according to<br>
> the value of each point.<br>
> My problem is that I can't see the color map in my example. All I see is the<br>
> surface with a plain color.<br>
> The code is as below:<br>
><br>
> vtkPoints *points = newPts;//ReadCFDData2();<br>
> vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();<br>
> polydata->SetPoints(points);<br>
><br>
> vtkSmartPointer<vtkDoubleArray> weights =<br>
> vtkSmartPointer<vtkDoubleArray>::New();<br>
> weights->SetNumberOfValues(PoValues.GetSize());<br>
> for(int i=0; i< PoValues.GetSize();i++){<br>
> weights->SetValue(i, PoValues[i]);<br>
> }<br>
> polydata->GetPointData()->SetScalars(weights);<br>
><br>
> vtkSmartPointer<vtkVertexGlyphFilter> glyphFilter =<br>
> vtkSmartPointer<vtkVertexGlyphFilter>::New();<br>
> #if VTK_MAJOR_VERSION <= 5<br>
> glyphFilter->SetInputConnection(polydata->GetProducerPort());<br>
> #else<br>
> glyphFilter->SetInputData(polydata);<br>
> #endif<br>
> glyphFilter->Update();<br>
><br>
> // Create a plane to cut<br>
> vtkSmartPointer<vtkPlane> plane =<br>
> vtkSmartPointer<vtkPlane>::New();<br>
> plane->SetOrigin(polydata->GetCenter());<br>
> plane->SetNormal(1,1,1);<br>
><br>
><br>
> // Construct the surface and create isosurface.<br>
> vtkSmartPointer<vtkSurfaceReconstructionFilter> surf =<br>
> vtkSmartPointer<vtkSurfaceReconstructionFilter>::New();<br>
><br>
> surf->SetInput(polydata);<br>
> //<br>
> vtkSmartPointer<vtkContourFilter> cf =<br>
> vtkSmartPointer<vtkContourFilter>::New();<br>
> cf->SetInputConnection(surf->GetOutputPort());<br>
><br>
> // Create the color map<br>
> vtkSmartPointer<vtkLookupTable> colorLookupTable =<br>
> vtkSmartPointer<vtkLookupTable>::New();<br>
> colorLookupTable->SetNumberOfColors(64);<br>
> colorLookupTable->SetHueRange( 0.0,0.667);<br>
> colorLookupTable->SetTableRange(0,3);<br>
> colorLookupTable->Build();<br>
><br>
> // Create a mapper and actor<br>
> vtkSmartPointer<vtkPolyDataMapper> mapper =<br>
> vtkSmartPointer<vtkPolyDataMapper>::New();<br>
><br>
> mapper->SetInputConnection(/*reverse->GetOutputPort()*/cf->GetOutputPort());<br>
> mapper->ScalarVisibilityOff();<br>
> mapper->SetLookupTable(colorLookupTable);<br>
><br>
> vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();<br>
> actor->GetProperty()->SetColor(1.0, 0.8941, 0.7686); // bisque<br>
> actor->SetMapper(mapper);<br>
><br>
> //Create a renderer, render window, and interactor<br>
> vtkSmartPointer<vtkRenderer> renderer<br>
> = vtkSmartPointer<vtkRenderer>::New();<br>
> vtkSmartPointer<vtkRenderWindow> renderWindow<br>
> = vtkSmartPointer<vtkRenderWindow>::New();<br>
> renderWindow->AddRenderer(renderer);<br>
> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor<br>
> = vtkSmartPointer<vtkRenderWindowInteractor>::New();<br>
> renderWindowInteractor->SetRenderWindow(renderWindow);<br>
><br>
> //Add the actor to the scene<br>
> renderer->AddActor(actor);<br>
> renderer->SetBackground(.3, .6, .3); // Background color green<br>
><br>
> //Render and interact<br>
> renderWindow->Render();<br>
> renderWindowInteractor->Start();<br>
><br>
> Please explain me where I have gone wrong. Thanks a lot.<br>
><br>
> --<br>
> Gish<br>
><br>
</div></div>> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the VTK FAQ at:<br>
> <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
><br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
Unpaid intern in BillsBasement at noware dot com<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div></div><font color="#666666">Gish</font><br>
</div></div>