[vtkusers] Isosurfacing vti files with C++

shankarjee at ucla.edu shankarjee at ucla.edu
Mon Oct 25 17:49:07 EDT 2010


Hi
    I have a vti file which has some scalar values associated with it.  
I am trying to do some isosurfacing using vtkContourFilter. I do not  
get any output at all. I create the vti file with scalar data as


/*********CODE TO CREATE VTI FILE**************/
void ImageData(vtkImageData * data)
{
   data->SetSpacing(1,1,1);
   data->SetExtent(0,GridSize-1,0,GridSize-1,0,GridSize-1);

   //! Adding Scalar results. Just to test the code
   vtkSmartPointer<vtkDoubleArray>
     pointdata = vtkSmartPointer<vtkDoubleArray>::New();
   pointdata->SetNumberOfComponents(1);
   pointdata->SetName("VoxelLabel");

   for(vtkIdType i = 0; i < pow(GridSize,3); i++)
     {
       double temp_data=i;
       pointdata->InsertNextTupleValue(&temp_data);
     }
   data->GetPointData()->AddArray(pointdata);
   // Write using vtkXMLImageWriter function later
}

In my Isosurfacing I read the vti file I generated from the earlier function

/*************** CODE TO ISOSURFACE *********************/
   // Read the file
   vtkSmartPointer<vtkXMLImageDataReader> reader =
     vtkSmartPointer<vtkXMLImageDataReader>::New();

   reader->SetFileName(inputFilename.c_str());
   reader->Update();



   // Image contour Filter
   vtkContourFilter* iso = vtkContourFilter::New();
   iso->SetInputConnection(reader->GetOutputPort());
   iso->SetValue(0,Iso_value); // Iso_value is user input


   iso->ComputeGradientsOff();
   iso->ComputeNormalsOff();
   iso->Update();

  // Print output using VTKXMLPolyDataWriter

The output when open in paraview does not show anything. Can you  
please help me with this.

Thanks
Jee



More information about the vtkusers mailing list