<div class="gmail_quote">On Fri, Feb 3, 2012 at 2:19 AM, Gishara Indeewarie <span dir="ltr"><<a href="mailto:gish.777@gmail.com">gish.777@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<div><br></div><div>I have a set of points (x,y,z) and the values of each point. I have created a surface according to the following example.</div><div><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> </div>
<div> </div><div>And I want to create a color map by giving colors to each point according to the value of each point. </div><div>My problem is that I can't see the color map in my example. All I see is the surface with a plain color.</div>
<div>The code is as below:</div><div><br clear="all"><div><div>vtkPoints *points = newPts;//ReadCFDData2();</div><div><span style="white-space:pre-wrap">        </span></div><div>vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();</div>
<div> polydata->SetPoints(points);</div><div><br></div><div> vtkSmartPointer<vtkDoubleArray> weights = vtkSmartPointer<vtkDoubleArray>::New();</div><div> weights->SetNumberOfValues(PoValues.GetSize());</div>
<div> for(int i=0; i< PoValues.GetSize();i++){</div><div> weights->SetValue(i, PoValues[i]);</div><div> }</div><div> polydata->GetPointData()->SetScalars(weights);</div><div> </div><div> vtkSmartPointer<vtkVertexGlyphFilter> glyphFilter =</div>
<div> vtkSmartPointer<vtkVertexGlyphFilter>::New();</div><div>#if VTK_MAJOR_VERSION <= 5</div><div> glyphFilter->SetInputConnection(polydata->GetProducerPort());</div><div>#else</div><div> glyphFilter->SetInputData(polydata);</div>
<div>#endif</div><div> glyphFilter->Update();</div><div> </div><div> // Create a plane to cut</div><div> vtkSmartPointer<vtkPlane> plane =</div><div> vtkSmartPointer<vtkPlane>::New();</div><div> plane->SetOrigin(polydata->GetCenter());</div>
<div> plane->SetNormal(1,1,1);</div><div><br></div><div> </div><div> // Construct the surface and create isosurface.<span style="white-space:pre-wrap">        </span></div><div> vtkSmartPointer<vtkSurfaceReconstructionFilter> surf = </div>
<div> vtkSmartPointer<vtkSurfaceReconstructionFilter>::New();</div><div><br></div><div> surf->SetInput(polydata);</div><div> //</div><div> vtkSmartPointer<vtkContourFilter> cf = vtkSmartPointer<vtkContourFilter>::New();</div>
<div> cf->SetInputConnection(surf->GetOutputPort());</div><div><br></div><div> // Create the color map</div><div> vtkSmartPointer<vtkLookupTable> colorLookupTable = vtkSmartPointer<vtkLookupTable>::New();</div>
<div> colorLookupTable->SetNumberOfColors(64);</div><div> colorLookupTable->SetHueRange( 0.0,0.667);</div><div> colorLookupTable->SetTableRange(0,3);</div><div> colorLookupTable->Build();</div><div> </div>
<div> // Create a mapper and actor</div><div> vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();</div><div> mapper->SetInputConnection(/*reverse->GetOutputPort()*/cf->GetOutputPort());</div>
<div> mapper->ScalarVisibilityOff();</div><div> mapper->SetLookupTable(colorLookupTable);</div><div><br></div><div> vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();</div><div> actor->GetProperty()->SetColor(1.0, 0.8941, 0.7686); // bisque</div>
<div> actor->SetMapper(mapper);</div><div> </div><div> //Create a renderer, render window, and interactor</div><div> vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();</div><div>
vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New();</div><div> renderWindow->AddRenderer(renderer);</div><div> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();</div>
<div> renderWindowInteractor->SetRenderWindow(renderWindow);</div><div><br></div><div> //Add the actor to the scene</div><div> renderer->AddActor(actor);</div><div> renderer->SetBackground(.3, .6, .3); // Background color green</div>
<div> </div><div> //Render and interact</div><div> renderWindow->Render();</div><div> renderWindowInteractor->Start();</div></div><div><br></div><div>Please explain me where I have gone wrong. Thanks a lot.</div>
<span class="HOEnZb"><font color="#888888">
<div><br></div>-- <br><div></div><font color="#666666">Gish</font></font></span></div></blockquote><div><br></div><div>Why are you setting a color on the actor if you want the lookup table to provide the colors?</div><div>
actor->GetProperty()->SetColor(1.0, 0.8941, 0.7686); // bisque ?</div><div><br></div><div>Here is a working example of using a color map:</div><div><br></div><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/Color_a_mesh_by_height">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/Color_a_mesh_by_height</a><br clear="all">
<br></div><div class="gmail_quote">See if that helps.<br><br><div>David </div></div>