[vtkusers] Input Issue

Bill Lorensen bill.lorensen at gmail.com
Fri Jul 19 08:31:29 EDT 2013


When I add
polydata->Print(std::cout);

I see that the point data has two arrays:
MetaImage and vtkValidPointMask

For this example, you want MetaImage.
Also, the type of that array is UnsignedCharArray.



On Thu, Jul 18, 2013 at 4:58 PM, rahul indoria <rahulindoria5 at gmail.com>wrote:

> Hi all vtk users,
>  *Hi,*
> *    I am trying to get the point data in the given example(*
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/CurvedReformation*)
> and i am modify my example something like that in main function to access
> the point data. can you check it???? *
>
> *Green color part is directly copied from the example:*
>
>  *// Verify arguments*
> *  if (argc < 4)*
> *    {*
> *      std::cout << "Usage: " << argv[0]*
> *                << " InputVolume PolyDataInput"*
> *                << " Resolution"*
> *                << std::endl;*
> *      return EXIT_FAILURE;*
> *    }*
> *
> *
> *  // Parse arguments*
> *  std::string volumeFileName = argv[1];*
> *  std::string polyDataFileName = argv[2];*
> *  std::stringstream ssResolution;*
> *  ssResolution << argv[3];*
> *  unsigned int resolution;*
> *  ssResolution >> resolution;*
> *
> *
> *  // Output arguments*
> *  std::cout << "InputVolume: " << volumeFileName << std::endl*
> *            << "PolyDataInput: " << polyDataFileName << std::endl*
> *            << "Resolution: " << resolution << std::endl;*
> *
> *
> *  // Read the volume data*
> *  vtkSmartPointer< vtkImageReader2Factory > imageFactory =*
> *    vtkSmartPointer< vtkImageReader2Factory >::New();*
> *  vtkImageReader2 *imageReader =*
> *  imageFactory->CreateImageReader2(volumeFileName.c_str());*
> *  imageReader->SetFileName(volumeFileName.c_str());*
> *  imageReader->Update();*
> *
> *
> *  // Read the Polyline*
> *  vtkSmartPointer<vtkPolyDataReader> polyLineReader =*
> *    vtkSmartPointer<vtkPolyDataReader>::New();*
> *  polyLineReader->SetFileName(polyDataFileName.c_str());*
> *  polyLineReader->Update();*
> *
> *
> *  vtkSmartPointer<vtkSplineFilter> spline =*
> *    vtkSmartPointer<vtkSplineFilter>::New();*
> *  spline->SetInputConnection(polyLineReader->GetOutputPort());*
> *  spline->SetSubdivideToSpecified();*
> *  spline->SetNumberOfSubdivisions(resolution);*
> *
> *
> *  // Sweep the line to form a surface*
> *  double direction[3];*
> *  direction[0] = 0.0;*
> *  direction[1] = 0.0;*
> *  direction[2] = 1.0;*
> *  double distance = 164;*
> *  spline->Update();*
> *  vtkSmartPointer<vtkPolyData> surface =*
> *    SweepLine(spline->GetOutput(),*
> *              direction,*
> *              distance,*
> *              atoi(argv[3]));*
> *
> *
> *  // Probe the volume with the extruded surface*
> *  vtkSmartPointer<vtkProbeFilter> sampleVolume =*
> *    vtkSmartPointer<vtkProbeFilter>::New();*
> *  sampleVolume->SetInputConnection(1, imageReader->GetOutputPort());*
> *#if VTK_MAJOR_VERSION <= 5*
> *  sampleVolume->SetInput(0, surface);*
> * #else*
> *  sampleVolume->SetInputData(0, surface);*
> *#endif*
> *  // Compute a simple window/level based on scalar range*
> *  vtkSmartPointer<vtkWindowLevelLookupTable> wlLut =*
> *    vtkSmartPointer<vtkWindowLevelLookupTable>::New();*
> *  double range = imageReader->GetOutput()->GetScalarRange()[1] -*
> *                 imageReader->GetOutput()->GetScalarRange()[0];*
> *  double level = (imageReader->GetOutput()->GetScalarRange()[1] +*
> *                  imageReader->GetOutput()->GetScalarRange()[0]) / 2.0;*
> *  wlLut->SetWindow(range);*
> *  wlLut->SetLevel(level);*
> *  sampleVolume->Update();*
>
>
> *Red color part is modified part*
> *
> *
> *  // Extract the polydata*
> *   vtkSmartPointer<vtkPolyData> polydata = *
> * vtkSmartPointer<vtkPolyData> :: New();*
> *   polydata = vtkPolyData::SafeDownCast(**sampleVolume->GetOutput());  //
> here the sampleVolume->GetOutput()  are the points generated, as i
> understand.*
> *
> *
> *  // Get the number of points in the polydata*
> *  vtkIdType idNumPointsInFile = polydata->GetNumberOfPoints();*
> *
> *
> *  vtkSmartPointer<vtkDoubleArray> array =
> vtkSmartPointer<vtkDoubleArray> :: New();*
> *   array =
> vtkDoubleArray::SafeDownCast(polydata->GetPointData()->GetArray("Distances"));
> *
> * *
> *  if(array)*
> *    {*
> *    for(int i = 0; i < idNumPointsInFile; i++)      *
> *      {*
> *      std::cout << "Got array." << std::endl;*
> *      double dist;*
> *      dist = array->GetValue(i);*
> *      /**
> *      //if the array held arrays instead of scalars, you would use this:
>   *
> *      double location[3];*
> *      array->GetTupleValue(i, location);*
> *      std::cout << "Location: " << Location[0] << ","  << Location[1] <<
> "," << Location[2] << std::endl;*
> *      */*
> *      std::cout << "Distance: " << dist << std::endl;*
> *      }*
> *    }//end if(array)*
> *  else*
> *    {*
> *    std::cout << "no array." << std::endl;*
> *    }*
> *
> *
> *  system("PAUSE");*
> *
> *
> *  return EXIT_SUCCESS;*
> *
> *
> *
> *
> *could you please suggest me how to get the point data in of the given
> example?*
>



-- 
Unpaid intern in BillsBasement at noware dot com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130719/13d90706/attachment.htm>


More information about the vtkusers mailing list