<div dir="ltr">When I add<div style>polydata->Print(std::cout);</div><div style><br></div><div style>I see that the point data has two arrays:</div><div style>MetaImage and vtkValidPointMask</div><div style><br></div><div style>
For this example, you want MetaImage.</div><div style>Also, the type of that array is UnsignedCharArray.</div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 18, 2013 at 4:58 PM, rahul indoria <span dir="ltr"><<a href="mailto:rahulindoria5@gmail.com" target="_blank">rahulindoria5@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi all vtk users,<div> <b style="font-size:12.800000190734863px;font-family:arial,sans-serif">Hi,</b></div>
<div style="font-family:arial,sans-serif;font-size:12.800000190734863px"><b> I am trying to get the point data in the given example(</b><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/CurvedReformation" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/CurvedReformation</a><b>) and i am modify my example something like that in main function to access the point data. can you check it???? </b></div>
<div style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></div><div style="font-family:arial,sans-serif;font-size:12.800000190734863px"><b>Green color part is directly copied from the example:</b></div>
<div style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></div><div style="font-family:arial,sans-serif;font-size:12.800000190734863px"><div><div class="h5"><div> <font color="#38761d"><b>// Verify arguments</b></font></div>
<div><font color="#38761d"><b> if (argc < 4)</b></font></div><div><font color="#38761d"><b> {</b></font></div><div><font color="#38761d"><b> std::cout << "Usage: " << argv[0]</b></font></div>
<div><font color="#38761d"><b> << " InputVolume PolyDataInput"</b></font></div><div><font color="#38761d"><b> << " Resolution"</b></font></div><div><font color="#38761d"><b> << std::endl;</b></font></div>
<div><font color="#38761d"><b> return EXIT_FAILURE;</b></font></div><div><font color="#38761d"><b> }</b></font></div><div><font color="#38761d"><b><br></b></font></div><div><font color="#38761d"><b> // Parse arguments</b></font></div>
<div><font color="#38761d"><b> std::string volumeFileName = argv[1];</b></font></div><div><font color="#38761d"><b> std::string polyDataFileName = argv[2];</b></font></div><div><font color="#38761d"><b> std::stringstream ssResolution;</b></font></div>
<div><font color="#38761d"><b> ssResolution << argv[3];</b></font></div><div><font color="#38761d"><b> unsigned int resolution;</b></font></div><div><font color="#38761d"><b> ssResolution >> resolution;</b></font></div>
<div><font color="#38761d"><b><br></b></font></div><div><font color="#38761d"><b> // Output arguments</b></font></div><div><font color="#38761d"><b> std::cout << "InputVolume: " << volumeFileName << std::endl</b></font></div>
<div><font color="#38761d"><b> << "PolyDataInput: " << polyDataFileName << std::endl</b></font></div><div><font color="#38761d"><b> << "Resolution: " << resolution << std::endl;</b></font></div>
<div><font color="#38761d"><b><br></b></font></div><div><font color="#38761d"><b> // Read the volume data</b></font></div><div><font color="#38761d"><b> vtkSmartPointer< vtkImageReader2Factory > imageFactory =</b></font></div>
<div><font color="#38761d"><b> vtkSmartPointer< vtkImageReader2Factory >::New();</b></font></div><div><font color="#38761d"><b> vtkImageReader2 *imageReader =</b></font></div><div><font color="#38761d"><b> imageFactory->CreateImageReader2(volumeFileName.c_str());</b></font></div>
<div><font color="#38761d"><b> imageReader->SetFileName(volumeFileName.c_str());</b></font></div><div><font color="#38761d"><b> imageReader->Update();</b></font></div><div><font color="#38761d"><b><br></b></font></div>
<div><font color="#38761d"><b> // Read the Polyline</b></font></div><div><font color="#38761d"><b> vtkSmartPointer<vtkPolyDataReader> polyLineReader =</b></font></div><div><font color="#38761d"><b> vtkSmartPointer<vtkPolyDataReader>::New();</b></font></div>
<div><font color="#38761d"><b> polyLineReader->SetFileName(polyDataFileName.c_str());</b></font></div><div><font color="#38761d"><b> polyLineReader->Update();</b></font></div><div><font color="#38761d"><b><br></b></font></div>
<div><font color="#38761d"><b> vtkSmartPointer<vtkSplineFilter> spline =</b></font></div><div><font color="#38761d"><b> vtkSmartPointer<vtkSplineFilter>::New();</b></font></div><div><font color="#38761d"><b> spline->SetInputConnection(polyLineReader->GetOutputPort());</b></font></div>
<div><font color="#38761d"><b> spline->SetSubdivideToSpecified();</b></font></div><div><font color="#38761d"><b> spline->SetNumberOfSubdivisions(resolution);</b></font></div><div><font color="#38761d"><b><br></b></font></div>
<div><font color="#38761d"><b> // Sweep the line to form a surface</b></font></div><div><font color="#38761d"><b> double direction[3];</b></font></div><div><font color="#38761d"><b> direction[0] = 0.0;</b></font></div>
<div><font color="#38761d"><b> direction[1] = 0.0;</b></font></div><div><font color="#38761d"><b> direction[2] = 1.0;</b></font></div><div><font color="#38761d"><b> double distance = 164;</b></font></div><div><font color="#38761d"><b> spline->Update();</b></font></div>
<div><font color="#38761d"><b> vtkSmartPointer<vtkPolyData> surface =</b></font></div><div><font color="#38761d"><b> SweepLine(spline->GetOutput(),</b></font></div><div><font color="#38761d"><b> direction,</b></font></div>
<div><font color="#38761d"><b> distance,</b></font></div><div><font color="#38761d"><b> atoi(argv[3]));</b></font></div><div><font color="#38761d"><b><br></b></font></div><div><font color="#38761d"><b> // Probe the volume with the extruded surface</b></font></div>
<div><font color="#38761d"><b> vtkSmartPointer<vtkProbeFilter> sampleVolume =</b></font></div><div><font color="#38761d"><b> vtkSmartPointer<vtkProbeFilter>::New();</b></font></div><div><font color="#38761d"><b> sampleVolume->SetInputConnection(1, imageReader->GetOutputPort());</b></font></div>
<div><font color="#38761d"><b>#if VTK_MAJOR_VERSION <= 5</b></font></div><div><font color="#38761d"><b> sampleVolume->SetInput(0, surface);</b></font></div><div><font color="#38761d"><b> #else</b></font></div><div>
<font color="#38761d"><b> sampleVolume->SetInputData(0, surface);</b></font></div><div><font color="#38761d"><b>#endif</b></font></div><div><font color="#38761d"><b> // Compute a simple window/level based on scalar range</b></font></div>
<div><font color="#38761d"><b> vtkSmartPointer<vtkWindowLevelLookupTable> wlLut =</b></font></div><div><font color="#38761d"><b> vtkSmartPointer<vtkWindowLevelLookupTable>::New();</b></font></div><div><font color="#38761d"><b> double range = imageReader->GetOutput()->GetScalarRange()[1] -</b></font></div>
<div><font color="#38761d"><b> imageReader->GetOutput()->GetScalarRange()[0];</b></font></div><div><font color="#38761d"><b> double level = (imageReader->GetOutput()->GetScalarRange()[1] +</b></font></div>
<div><font color="#38761d"><b> imageReader->GetOutput()->GetScalarRange()[0]) / 2.0;</b></font></div><div><font color="#38761d"><b> wlLut->SetWindow(range);</b></font></div><div><font color="#38761d"><b> wlLut->SetLevel(level);</b></font></div>
<div><font color="#38761d"><b> sampleVolume->Update();</b></font></div><div><br></div><div><br></div></div></div><div><b>Red color part is modified part</b></div><div class="im"><div><b><font color="#cc0000"><br></font></b></div>
<div><b><font color="#cc0000"> // Extract the polydata</font></b></div>
<div><b><font color="#cc0000"> vtkSmartPointer<vtkPolyData> polydata = </font></b></div><div><b><font color="#cc0000"><span style="white-space:pre-wrap">        </span>vtkSmartPointer<vtkPolyData> :: New();</font></b></div>
</div><div><b style="color:rgb(204,0,0)"> polydata = vtkPolyData::SafeDownCast(</b><b><font color="#cc0000">sampleVolume->GetOutput()); </font><font color="#0b5394"> // here the sampleVolume->GetOutput() are the points generated, as i understand.</font></b></div>
<div class="im">
<div><b><font color="#cc0000"><br></font></b></div><div><b><font color="#cc0000"> // Get the number of points in the polydata</font></b></div><div><b><font color="#cc0000"> vtkIdType idNumPointsInFile = polydata->GetNumberOfPoints();</font></b></div>
<div><b><font color="#cc0000"><br></font></b></div><div><b><font color="#cc0000"> vtkSmartPointer<vtkDoubleArray> array = vtkSmartPointer<vtkDoubleArray> :: New();</font></b></div><div><b><font color="#cc0000"> array = vtkDoubleArray::SafeDownCast(polydata->GetPointData()->GetArray("Distances"));</font></b></div>
<div><span style="white-space:pre-wrap"><b><font color="#cc0000">        </font></b></span></div><div><b><font color="#cc0000"> if(array)</font></b></div><div><b><font color="#cc0000"> {</font></b></div><div><b><font color="#cc0000"> for(int i = 0; i < idNumPointsInFile; i++) </font></b></div>
<div><b><font color="#cc0000"> {</font></b></div><div><b><font color="#cc0000"> std::cout << "Got array." << std::endl;</font></b></div><div><b><font color="#cc0000"> double dist;</font></b></div>
<div><b><font color="#cc0000"> dist = array->GetValue(i);</font></b></div><div><b><font color="#cc0000"> /*</font></b></div><div><b><font color="#cc0000"> //if the array held arrays instead of scalars, you would use this:<span style="white-space:pre-wrap">                </span> </font></b></div>
<div><b><font color="#cc0000"> double location[3];</font></b></div><div><b><font color="#cc0000"> array->GetTupleValue(i, location);</font></b></div><div><b><font color="#cc0000"> std::cout << "Location: " << Location[0] << "," << Location[1] << "," << Location[2] << std::endl;</font></b></div>
<div><b><font color="#cc0000"> */</font></b></div><div><b><font color="#cc0000"> std::cout << "Distance: " << dist << std::endl;</font></b></div><div><b><font color="#cc0000"> }</font></b></div>
<div><b><font color="#cc0000"> }//end if(array)</font></b></div><div><b><font color="#cc0000"> else</font></b></div><div><b><font color="#cc0000"> {</font></b></div><div><b><font color="#cc0000"> std::cout << "no array." << std::endl;</font></b></div>
<div><b><font color="#cc0000"> }</font></b></div><div><b><font color="#cc0000"><br></font></b></div><div><b><font color="#cc0000"> system("PAUSE");</font></b></div><div><b><font color="#cc0000"><br></font></b></div>
<div><b><font color="#cc0000"> return EXIT_SUCCESS;</font></b></div><div><b><font color="#cc0000"><br></font></b></div><div><b><font color="#cc0000"><br></font></b></div></div><div><b><font color="#0000ff">could you please suggest me how to get the point data in of the given example?</font></b></div>
</div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Unpaid intern in BillsBasement at noware dot com<br>
</div>