[vtkusers] Input Issue
Bill Lorensen
bill.lorensen at gmail.com
Thu Jul 18 16:11:19 EDT 2013
Please keep the vtk users list in the replies...
Is there an array called Distances in your polydata?
Try printing the polydata:
polydata->Print(std::cout);
On Thu, Jul 18, 2013 at 4:01 PM, rahul indoria <rahulindoria5 at gmail.com>wrote:
> *Hi,*
> * I am trying to modify my example something like that in main
> function to access the point data. can you check it???? *
>
>
>
> // 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();
>
>
> // Extract the polydata
> vtkSmartPointer<vtkPolyData> polydata =
> vtkSmartPointer<vtkPolyData> :: New();
> polydata = vtkPolyData::SafeDownCast(sampleVolume->GetOutput());
>
> // 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;
>
>
>
> On Thu, Jul 18, 2013 at 9:53 PM, rahul indoria <rahulindoria5 at gmail.com>wrote:
>
>> I am trying to get the point data of each point of this example
>> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/CurvedReformation
>>
>>
>> so that`s why i am trying to use the point data access example (
>> http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/GetMiscPointData)
>>
>>
>>
>> Looking forward your reply soon.
>>
>>
>>
>> On Thu, Jul 18, 2013 at 9:48 PM, Bill Lorensen <bill.lorensen at gmail.com>wrote:
>>
>>> The file seems fine. The example read it, but it does not contain any
>>> point data. This example is meant to show you how to access poiont data if
>>> it exists.
>>>
>>> What is your goal?
>>>
>>>
>>>
>>> On Thu, Jul 18, 2013 at 3:45 PM, rahul indoria <rahulindoria5 at gmail.com>wrote:
>>>
>>>> Hi Bill,
>>>> I am also using .vtp file. i am attaching a file with this
>>>> mail, if this is wrong, could you please suggest me some other file, as i
>>>> am new on vtk, so i am not very much familiar with it.
>>>>
>>>> Looking forward your reply soon.
>>>>
>>>>
>>>> On Thu, Jul 18, 2013 at 9:40 PM, Bill Lorensen <bill.lorensen at gmail.com
>>>> > wrote:
>>>>
>>>>> It requires an input xml polydata file, a .vtp file.
>>>>>
>>>>> The file should contain point data.
>>>>>
>>>>>
>>>>>
>>>>> On Thu, Jul 18, 2013 at 3:25 PM, rahul indoria <
>>>>> rahulindoria5 at gmail.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>> could you please check this example, what should be the arguments
>>>>>> for this examples.
>>>>>>
>>>>>> http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/GetMiscPointData
>>>>>>
>>>>>> Can you tell me the arguments of this example.
>>>>>>
>>>>>>
>>>>>> Looking forward your reply soon.
>>>>>>
>>>>>> Rahul
>>>>>>
>>>>>> _______________________________________________
>>>>>> Powered by www.kitware.com
>>>>>>
>>>>>> Visit other Kitware open-source projects at
>>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>>
>>>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>>>
>>>>>> Follow this link to subscribe/unsubscribe:
>>>>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Unpaid intern in BillsBasement at noware dot com
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> *Best Regards
>>>> Rahul Indoria
>>>> Mobile No: +49-157-35652212*
>>>>
>>>
>>>
>>>
>>> --
>>> Unpaid intern in BillsBasement at noware dot com
>>>
>>
>>
>>
>> --
>> *Best Regards
>> Rahul Indoria
>> Mobile No: +49-157-35652212*
>>
>
>
>
> --
> *Best Regards
> Rahul Indoria
> Mobile No: +49-157-35652212*
>
--
Unpaid intern in BillsBasement at noware dot com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130718/4ae6f2ac/attachment.htm>
More information about the vtkusers
mailing list