<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">Hi,</span><div style="font-family:arial,sans-serif;font-size:13px"> I have an example (<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> ), and i am modifying this example, i am trying to find the point data on the data, i have modified this code, in that way which i am showing, but i am getting some unexpected pointdata values which are nearly zero and which is not possible. could you please suggest me some solution regarding this?</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><div>static vtkSmartPointer<vtkPolyData> SweepLine (vtkPolyData *line,</div><div> double direction[3],</div>
<div> double distance,</div><div> unsigned int cols);</div><div>int main (int argc, char *argv[])</div><div>{</div><div> // Verify arguments</div>
<div> if (argc < 4)</div><div> {</div><div> std::cout << "Usage: " << argv[0]</div><div> << " InputVolume PolyDataInput"</div><div> << " Resolution"</div>
<div> << std::endl;</div><div> return EXIT_FAILURE;</div><div> }</div><div><br></div><div> // Parse arguments</div><div> std::string volumeFileName = argv[1];</div><div> std::string polyDataFileName = argv[2];</div>
<div> std::stringstream ssResolution;</div><div> ssResolution << argv[3];</div><div> unsigned int resolution;</div><div> ssResolution >> resolution;</div><div><br></div><div> // Output arguments</div><div>
std::cout << "InputVolume: " << volumeFileName << std::endl</div><div> << "PolyDataInput: " << polyDataFileName << std::endl</div><div> << "Resolution: " << resolution << std::endl;</div>
<div><br></div><div> // Read the volume data</div><div> vtkSmartPointer< vtkImageReader2Factory > imageFactory =</div><div> vtkSmartPointer< vtkImageReader2Factory >::New();</div><div> vtkImageReader2 *imageReader =</div>
<div> imageFactory->CreateImageReader2(volumeFileName.c_str());</div><div> imageReader->SetFileName(volumeFileName.c_str());</div><div> imageReader->Update();</div><div><br></div><div> // Read the Polyline</div>
<div> vtkSmartPointer<vtkPolyDataReader> polyLineReader =</div><div> vtkSmartPointer<vtkPolyDataReader>::New();</div><div> polyLineReader->SetFileName(polyDataFileName.c_str());</div><div> polyLineReader->Update();</div>
<div><br></div><div> vtkSmartPointer<vtkSplineFilter> spline =</div><div> vtkSmartPointer<vtkSplineFilter>::New();</div><div> spline->SetInputConnection(polyLineReader->GetOutputPort());</div><div> spline->SetSubdivideToSpecified();</div>
<div> spline->SetNumberOfSubdivisions(resolution);</div><div><br></div><div> // Sweep the line to form a surface</div><div> double direction[3];</div><div> direction[0] = 0.0;</div><div> direction[1] = 0.0;</div><div>
direction[2] = 1.0;</div><div> double distance = 164;</div><div> spline->Update();</div><div> vtkSmartPointer<vtkPolyData> surface =</div><div> SweepLine(spline->GetOutput(),</div><div> direction,</div>
<div> distance,</div><div> atoi(argv[3]));</div><div><br></div><div> // Probe the volume with the extruded surface</div><div> vtkSmartPointer<vtkProbeFilter> sampleVolume =</div><div> vtkSmartPointer<vtkProbeFilter>::New();</div>
<div> sampleVolume->SetInputConnection(1, imageReader->GetOutputPort());</div><div>#if VTK_MAJOR_VERSION <= 5</div><div> sampleVolume->SetInput(0, surface);</div><div> #else</div><div> sampleVolume->SetInputData(0, surface);</div>
<div>#endif</div><div> // Compute a simple window/level based on scalar range</div><div> vtkSmartPointer<vtkWindowLevelLookupTable> wlLut =</div><div> vtkSmartPointer<vtkWindowLevelLookupTable>::New();</div>
<div> double range = imageReader->GetOutput()->GetScalarRange()[1] -</div><div> imageReader->GetOutput()->GetScalarRange()[0];</div><div> double level = (imageReader->GetOutput()->GetScalarRange()[1] +</div>
<div> imageReader->GetOutput()->GetScalarRange()[0]) / 2.0;</div><div> wlLut->SetWindow(range);</div><div> wlLut->SetLevel(level);</div><div> sampleVolume->Update();</div></div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><b><font color="#990000">// From Here i have done modification in my code.</font></b></div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><div>// To find out the Pointdata of a surface</div><div><br></div><div> // Extract the polydata</div>
<div> vtkSmartPointer<vtkPolyData> polydata = </div><div><span style="white-space:pre-wrap">        </span>vtkSmartPointer<vtkPolyData> :: New();</div><div> polydata = vtkPolyData::SafeDownCast(sampleVolume->GetOutput());</div>
<div><br></div><div> // Get the number of points in the polydata</div><div> vtkIdType idNumPointsInFile = polydata->GetNumberOfPoints();</div><div><br></div><div> vtkSmartPointer<vtkDoubleArray> array = vtkSmartPointer<vtkDoubleArray> :: New();</div>
<div> // array->SetName("Double");</div><div> array->SetNumberOfTuples(idNumPointsInFile);</div><div><br></div><div> polydata->GetPointData()->AddArray(array);</div><div><br></div><div> // array = vtkDoubleArray::SafeDownCast(polydata->GetPointData()->GetArray("Double"));</div>
<div><span style="white-space:pre-wrap">        </span></div><div> if(array)</div><div> {</div><div> for(int i = 0; i < idNumPointsInFile; i++) </div><div> {</div><div> std::cout << "Got array.= " << i << std::endl;</div>
<div> double dist;</div><div> dist = array->GetValue(i);</div><div> </div><div> // if the array held arrays instead of scalars, you would use this:<span style="white-space:pre-wrap">                </span> </div>
<div> // double location[3];</div><div> // array->GetTupleValue(i, location);</div><div> // std::cout << "Location: " << Location[0] << "," << Location[1] << "," << Location[2] << std::endl;</div>
<div> </div><div> std::cout << "Distance: " << dist << std::endl;</div><div> }</div><div> } //end if(array)</div><div> else</div><div> {</div><div> std::cout << "no array." << std::endl;</div>
<div> }</div><div><br></div><div> system("PAUSE");</div><div><br></div><div> return EXIT_SUCCESS;</div></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
}</div><div><br></div></div>