[vtkusers] vtkStringArray problem

Dr. Roman Grothausmann grothausmann.roman at mh-hannover.de
Wed Dec 3 10:52:58 EST 2014


Hi Rich,


I recently had problems with getting/reading/accessing values in vtkStringArray. 
It tourned out that my problems were related to the fact that vtkStringArray is 
NOT a vtkDataArray, it is a vtkAbstractArray (as vtkDataArray is). Joachim 
Pouderoux gave me the hint to use e.g. 
input->GetPointData()->GetAbstractArray(j) instead. Perhaps Your problem is also 
related to the different array types.

Hope this helps
Roman


On 03/12/14 13:29, mbcx9rb9 wrote:
> Cory,
>
> It is written in Qt but the first 4 lines of code create a list of DICOM
> filenames. The part in the for loop is the relevant bit, when I try to write
> in entry by entry into the vtkStringArray. I could just as easily comment
> out the lines:
>
> filenames->SetNumberOfValues(list.size());
> filenames->SetValue(i,temp.c_str());
>
> and uncomment the line:
>
> filenames->InsertNextValue(temp);
>
> however neither work. I have tried various combinations of insert temp as a
> vtkStdString etc. but to no avail.
>
> Cheers,
> Rich
>
>
> void MainWindow::listFiles(QString path)
>
> {
>      // set path to user chosen folder
>      QDir dir = QDir(path);
>
>      // set filter to only search for dicom files
>      QStringList filters;
>      filters << "*.dcm";
>      dir.setNameFilters(filters);
>
>      // Create list of all *.dcm filenames
>      QStringList list = dir.entryList();
>
>      if (list.size() == 0) { QMessageToScreen("Error. No DICOM files found in
> this directory"); }
>      else
>      {
>          // if there exist DICOM files in directory, create vector containing
> them all
>          vtkSmartPointer<vtkStringArray> filenames =
> vtkSmartPointer<vtkStringArray>::New();
>          filenames->SetNumberOfValues(list.size());
>          filenames->SetName("List_of_Filenames");
>          for (int i=0; i<list.size(); i++)
>          {
>              std::string temp = dir.absolutePath().toStdString() +
> "/" + list.at(i).toStdString();
>              std::cout <<temp.c_str()<<std::endl;
>
>              //to assign data use setnumberofvalues and setvalue or
> insertnextvalue
>              filenames->SetValue(i,temp.c_str());
>
>              //filenames->InsertNextValue(temp);
>          }
>
>          QMessageToScreen(QString::number(filenames->GetNumberOfValues()));
>
>          // vktDICOMSorter is used to find out how many series exist in a
> directory
>          //vtkSmartPointer<vtkDICOMSorter> sorter =
> vtkSmartPointer<vtkDICOMSorter>::New();
>          //sorter->SetInputFileNames(filenames);
>          //sorter->Update();
>      }
> }
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/vtkStringArray-problem-tp5729638p5729646.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> 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://public.kitware.com/mailman/listinfo/vtkusers
>

-- 
Dr. Roman Grothausmann

Tomographie und Digitale Bildverarbeitung
Tomography and Digital Image Analysis

Institut für Funktionelle und Angewandte Anatomie, OE 4120
Medizinische Hochschule Hannover
Carl-Neuberg-Str. 1
D-30625 Hannover

Tel. +49 511 532-9574


More information about the vtkusers mailing list