[vtkusers] Help!! MY pipeline is here, But I cannot got contour ????

qin zeng qin_in_usa at hotmail.com
Sun Nov 30 16:08:21 EST 2003


Hi, 

Following is my pipeline: But I cannot get the contour but a grid
///////////////////////////////////////////////////////////////////////////////////


int i;
  vtkFloatArray* pcoords = vtkFloatArray::New();
  pcoords->SetNumberOfComponents(3);
  pcoords->SetNumberOfTuples(10512);

 float pts[10512][3];
 float * temdata = new float[10512]; 
/////////////////////////////////////////////////////////////////////////////////////
 nc_reader myreader("test.dat");
 if (!(myreader.get_float_2d(temdata,2000))) return false;
// This is my function to read data from file, it is OK.
// The grid is global meteorological data 2.5x2.5 
//////////////////////////////////////////////////////////////////////////////////////
    int indexs=0;
 float ii,jj;
 for (ii =0;ii>=73 ;ii = ii++)
 {
  for (jj = 0 ;jj<=144;jj =jj++)
  {
   pts[jj + ii*73 ][0] = jj;pts[jj + ii*73][1] = ii; pts[jj + ii*73][2] = 100;
  }
  
 }

  for (i=0; i<10512; i++)
    {
    pcoords->SetTuple(i, pts[i]);
    }

  // Create vtkPoints and assign pcoords as the internal data array.
  vtkPoints* points = vtkPoints::New();
  points->SetData(pcoords);

  // Create the cells. In this case, a cell is a pixel with four vertices

  vtkCellArray* cells = vtkCellArray::New();

 for (ii =0;ii>=73 ;ii = ii++)
 {
  for (jj = 0 ;jj<=144;jj =jj++)
  { 
   index = jj+ ii*73;
   cells->InsertNextCell(4);
   cells->InsertCellPoint(indexs+144);
   cells->InsertCellPoint(indexs+144 +1);
   cells->InsertCellPoint(indexs);
   cells->InsertCellPoint(indexs+1);
  }
  
 }

   vtkIntArray* temperature = vtkIntArray::New();
  temperature->SetName("Temperature");
  for (i=0; i<10512; i++)
    {
    temperature->InsertNextValue(temdata[i]);
    }

   vtkPolyData* polydata = vtkPolyData::New();
 
  polydata->SetPoints(points);
  polydata->SetPolys(cells);
  polydata->GetPointData()->SetScalars(temperature);
  
  std::cout<<"cell size:"<< polydata->GetNumberOfCells()<<std::endl; 

  vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
  mapper->SetInput(polydata);

 //datarange is 4000~6000
  mapper->SetScalarRange(4000, 6000);

  vtkActor* actor = vtkActor::New();
  actor->SetMapper(mapper);
  std::cout<<"fsdfs"<<std::endl;
  // Create the rendering objects.
  vtkRenderer* ren = vtkRenderer::New();
  ren->AddActor(actor);
  ren->SetBackground(0.2,0.2,0.4); 
  vtkRenderWindow* renWin = vtkRenderWindow::New();
  renWin->AddRenderer(ren);

  vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
  iren->SetRenderWindow(renWin);
  iren->Initialize();
  iren->Start();

  pcoords->Delete();
  points->Delete();
  cells->Delete();
  temperature->Delete();

  polydata->Delete();
  mapper->Delete();
  actor->Delete();
  ren->Delete();
  renWin->Delete();
  iren->Delete();
  delete []temdata;
  return 0;
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20031130/2d406250/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 13366 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20031130/2d406250/attachment.gif>


More information about the vtkusers mailing list