[vtkusers] Polydata contour without vtkreader !!! ????

Paul Tait paul at opes.com.au
Wed Nov 26 20:10:26 EST 2003


your almost there

just add

_polydata->GetPointData()->SetScalars(_iso_data);

vtkPolyDataMapper *pm = vtkPolyDataMapper::New();
pm->SetInput(_polydata);
vtkactor *act = vtkActor::New();
act->SetMapper(pm);
Renderer->AddProp(act);

BTW you shouldn't use underscores on variable names, its against the
standard

Paul Tait

----- Original Message ----- 
From: "qzgrmc" <qin_in_usa at hotmail.com>
To: <vtkusers at public.kitware.com>
Sent: Wednesday, November 26, 2003 10:54 PM
Subject: [vtkusers] Polydata contour without vtkreader !!! ????


> Hi, all,
>
> Sorry for sending  again. I am really so eager to start with VTK.
>
> I am a new user of VTK. I want to contour with some points and I have
tried
> some ways. But no way out. who can help me?
> The first part is all the same : I create a polydata without cells
>
////////////////////////////////////////////////////////////////////////////
> ////////////////
>  vtkPoints* _points = vtkPoints::New();
>  vtkFloatArray* _pcoords =vtkFloatArray::New();
>  vtkFloatArray* _iso_data =vtkFloatArray::New();
>  vtkPolyData* _polydata = vtkPolyData::New();
>  vtkCellArray*  _cells =  vtkCellArray::New();
>
>  float grids[9800][3];       //  9800=70*140
>  _pcoords->SetNumberOfComponents(3); // for x,y,z
>  _pcoords->SetNumberOfTuples(70*140);  // for data (num)
>
> /*
>  Here I retrieve data from a file and store in a array temdata[70*140]
>  process omitted here....
>
> */
>  int indexs=0;
>  float ii,jj;
>  for (ii =0;ii<70 ;ii ++)
>  {
>       for (jj = 0 ;jj< 140;jj =jj ++)
>       {
>           indexs =ii * 140 + jj);
>           _iso_data->InsertNextValue(temdata[indexs]);
>
>            grids[indexs][0] = jj; grids[indexs][1] = ii; grids[indexs][2]
=
> 100;
>            _pcoords->SetTuple(indexs, grids[indexs]);
>
>       }
>  }
>  _points->SetData(_pcoords);
>  _polydata->SetPoints(_points);
>  _polydata->GetPointData()->SetScalars(_iso_data);
>
>
////////////////////////////////////////////////////////////////////////////
> ////////////////
>
> //<1>  Method 1: Manually create Cell.  Actually It is a grid so I create
> Pixel as a cell
> // for the grid 70 * 140 the cell of pixels should be 69 * 139
>   for (ii =0;ii<70-1 ;ii ++)
>  {
>       for (jj = 0 ;jj< 140 -1 ;jj =jj ++)
>       {
>
>            _cells->InsertNextCell(4);
>            _cells->InsertCellPoint( (ii+1)*140 + j );
>            _cells->InsertCellPoint((ii+1)*140 + j+1 );
>            _cells->InsertCellPoint(  ii*140 + j );
>            _cells->InsertCellPoint(  ii*140 + j +1 );
>           // Here establish a cell of pixel
>       }
>  }
> _polydata->SetPolys(_cells);
> //<1> ...............And then I use  vtkContourFilter to process the
> _polydata  and then render it.
>
>
>
> //<2> Method 2: Use vtkDelaunay2D as a filter to transfer the vtkPoints to
> vtkPolydata
>
>     vtkDelaunay2D *  _d_2d =vtkDelaunay2D::New();
>     _d_2d->SetInput(_polydata);
>     _d_2d->SetTolerance(1);
>  _polydata =_d_2d->GetOutput();
>
> // <2>...............And then I use  vtkContourFilter to process the
> _polydata  and then render it.
>
>
>
> //<3> I also use vtkSurfaceReconstructionFilter to do so.
>
>
>
> But I failed to get any contour data!!!!!
> I know that if I create a polydata without cell I will surely fail. But I
> tried different way to create cell and fail too. why??
>
> Is there anything important I am missing?
>
>
> Thanks!!!!
>
> qzgrmc
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list