[vtkusers] Vtk help needed

de Boer Ingo I.deBoer at polytec.de
Thu Jul 21 05:59:39 EDT 2005


Hi,

you have to set scalar values to your data.

Please take a look at the Cube.cxx sample shipped with VTK.

greets
  Ingo

---
Dr.-Ing. Ingo H. de Boer

Polytec GmbH
Polytec-Platz 1-7, 76337 Waldbronn, Germany
phone: ++49 7243 604 106
fax  : ++49 7243 604 255
 

> -----Original Message-----
> From: vtkusers-bounces+i.deboer=polytec.de at vtk.org
> [mailto:vtkusers-bounces+i.deboer=polytec.de at vtk.org]On Behalf Of
> Ramisetti Srinivas
> Sent: Thursday, July 21, 2005 11:55 AM
> To: vtkusers at vtk.org
> Subject: [vtkusers] Vtk help needed
> 
> 
> 
> hi to all,
> 
> i am a beginner to VTK.
> i want to apply a blue to red varying colors to my 
> unstructred grid using 
> vtk Lookup Table,
> but i was unable to do it....
> plz help me.
> Here is my code......
> 
> 
> #include "vtkActor.h"
> #include "vtkCamera.h"
> #include "vtkFloatArray.h"
> #include "vtkHedgeHog.h"
> #include "vtkMath.h"
> #include "vtkPointData.h"
> #include "vtkPoints.h"
> #include "vtkPolyDataMapper.h"
> #include "vtkProperty.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderWindowInteractor.h"
> #include "vtkRenderer.h"
> #include "vtkStructuredGrid.h"
> #include "vtkLookupTable.h"
> 
> int main( int argc, char *argv[] )
> {
>   int i, j, k, kOffset, jOffset, offset;
>   float x[3], v[3], rMin=0.5, rMax=1.0, deltaRad, deltaZ;
>   float radius, theta;
>   static int dims[3]={13,11,11};
> 
> 	vtkLookupTable *hueLut = vtkLookupTable::New();
>     hueLut->SetTableRange (0, 2000);
>     hueLut->SetHueRange (0, 0.66667);
>     //hueLut->SetSaturationRange (1, 1);
>     //hueLut->SetValueRange (1, 1);
>     //hueLut->Build(); //effective built  // Create the 
> structured grid.
>   vtkStructuredGrid *sgrid = vtkStructuredGrid::New();
>       sgrid->SetDimensions(dims);
> 
>   // We also create the points and vectors. The points
>   // form a hemi-cylinder of data.
>   vtkFloatArray *vectors = vtkFloatArray::New();
>     vectors->SetNumberOfComponents(3);
>     vectors->SetNumberOfTuples(dims[0]*dims[1]*dims[2]);
>   vtkPoints *points = vtkPoints::New();
>     points->Allocate(dims[0]*dims[1]*dims[2]);
> 
>   deltaZ = 2.0 / (dims[2]-1);
>   deltaRad = (rMax-rMin) / (dims[1]-1);
>   v[2]=0.0;
>   for ( k=0; k<dims[2]; k++)
>     {
>     x[2] = -1.0 + k*deltaZ;
>     kOffset = k * dims[0] * dims[1];
>     for (j=0; j<dims[1]; j++)
>       {
>       radius = rMin + j*deltaRad;
>       jOffset = j * dims[0];
>       for (i=0; i<dims[0]; i++)
>         {
>         theta = i * 15.0 * vtkMath::DegreesToRadians();
>         x[0] = radius * cos(theta);
>         x[1] = radius * sin(theta);
>         v[0] = -x[1];
>         v[1] = x[0];
>         offset = i + jOffset + kOffset;
>         points->InsertPoint(offset,x);
>         vectors->InsertTuple(offset,v);
>         }
>       }
>     }
>   sgrid->SetPoints(points);
>   points->Delete();
>   sgrid->GetPointData()->SetVectors(vectors);
>   vectors->Delete();
> 
>   // We create a simple pipeline to display the data.
>   vtkHedgeHog *hedgehog = vtkHedgeHog::New();
>       hedgehog->SetInput(sgrid);
>       hedgehog->SetScaleFactor(0.1);
> //hedgehog->SetLookupTable(hueLut);
>   vtkPolyDataMapper *sgridMapper = vtkPolyDataMapper::New();
>       sgridMapper->SetInput(hedgehog->GetOutput());
> 	  sgridMapper->SetLookupTable(hueLut);
> 	  hueLut->Build();
>   vtkActor *sgridActor = vtkActor::New();
>       sgridActor->SetMapper(sgridMapper);
>       sgridActor->GetProperty()->SetColor(0,0,0);
> 
>   // Create the usual rendering stuff
>   vtkRenderer *renderer = vtkRenderer::New();
>   vtkRenderWindow *renWin = vtkRenderWindow::New();
>     renWin->AddRenderer(renderer);
> 
>   vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>     iren->SetRenderWindow(renWin);
> 
>   renderer->AddActor(sgridActor);
>   renderer->SetBackground(1,1,1);
>   renderer->GetActiveCamera()->Elevation(60.0);
>   renderer->GetActiveCamera()->Azimuth(30.0);
>   renderer->GetActiveCamera()->Zoom(1.25);
>   renWin->SetSize(300,300);
> 
>   // interact with data
>   renWin->Render();
>   iren->Start();
> 
>   renderer->Delete();
>   renWin->Delete();
>   iren->Delete();
>   sgrid->Delete();
>   hedgehog->Delete();
>   sgridMapper->Delete();
>   sgridActor->Delete();
> 
>   return 0;
> }
> 
> _________________________________________________________________
> Meet interesting singles like you 
> http://match.msn.co.in/match/mt.cfm?pg=channel&tcid=234764 
> Sign up with 
> Match.com
> 
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: 
http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers



More information about the vtkusers mailing list