Reading multiple vtp files in directory

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Reading multiple vtp files in directory

AlfonsoZR
Hello, I'm trying to read and render multiple files in a directory (when
combined they form an object). But so far I'm getting the following error:


*ERROR: In D:\VTK\VTK-src\IO\XML\vtkXMLReader.cxx, line 283
vtkXMLPolyDataReader (00D1B560): Error opening file D:\3d models\Dist\.

ERROR: In D:\VTK\VTK-src\Common\ExecutionModel\vtkExecutive.cxx, line 782
vtkCompositeDataPipeline (00CC2078): Algorithm
vtkXMLPolyDataReader(00D1B560) returned failure for request: vtkInformation
(00D20688)
  Debug: Off
  Modified Time: 8721
  Reference Count: 1
  Registered Events: (none)
  Request: REQUEST_DATA
  FORWARD_DIRECTION: 0
  ALGORITHM_AFTER_FORWARD: 1
  FROM_OUTPUT_PORT: 0
*

This is the code I'm currenty working on:
*

int main(int argc, char *argv[])
{
  std::string directoryName = "D:\\3d models\\Dist\\" ;

  vtkSmartPointer<vtkDirectory> directory =
vtkSmartPointer<vtkDirectory>::New();
  int opened = directory->Open(directoryName.c_str());

  if(!opened)
  {
    std::cout << "No es posible abrir este directorio!" << std::endl;
    return EXIT_FAILURE;
  }

  int numberOfFiles = directory->GetNumberOfFiles();
  std::cout << "NUmero de archivos: " << numberOfFiles << std::endl;

  for (int i = 0; i < numberOfFiles; i++)
  {
    std::string fileString = directoryName;
    ////fileString += "/";
    fileString += directory->GetFile(i);

    std::string ext =
vtksys::SystemTools::GetFilenameLastExtension(fileString);
    std::cout << fileString.c_str() << " extension: " << ext << std::endl;

    std::string name =
vtksys::SystemTools::GetFilenameWithoutLastExtension(fileString);    
    std::cout << "nombre: " << name << std::endl;

        const char*cstr = fileString.c_str();
        std::cout << cstr << endl;

                vtkSmartPointer<vtkXMLPolyDataReader> reader =
                        vtkSmartPointer<vtkXMLPolyDataReader>::New();
                reader->SetFileName(cstr);
                reader->Update();
                reader->GetOutput();

                vtkSmartPointer<vtkTransform> transform =
                        vtkSmartPointer<vtkTransform>::New();
                transform->Scale(.005, .005, .005);

                vtkSmartPointer<vtkTransformFilter> transformFilter =
                        vtkSmartPointer<vtkTransformFilter>::New();
                transformFilter->SetInputConnection(reader->GetOutputPort());
                transformFilter->SetTransform(transform);

                // Visualizar
                vtkSmartPointer<vtkPolyDataMapper> mapper =
                        vtkSmartPointer<vtkPolyDataMapper>::New();
                mapper->SetInputConnection(transformFilter->GetOutputPort());

                vtkSmartPointer<vtkActor> actor =
                        vtkSmartPointer<vtkActor>::New();
                actor->SetPosition(1.1, .5, .1);
                actor->SetMapper(mapper);

                vtkSmartPointer<vtkOpenVRRenderer> renderer =
                        vtkSmartPointer<vtkOpenVRRenderer>::New();
                vtkSmartPointer<vtkOpenVRRenderWindow> renderWindow =
                        vtkSmartPointer<vtkOpenVRRenderWindow>::New();
                renderWindow->AddRenderer(renderer);
                vtkSmartPointer<vtkOpenVRRenderWindowInteractor> renderWindowInteractor =
                        vtkSmartPointer<vtkOpenVRRenderWindowInteractor>::New();
                renderWindowInteractor->SetRenderWindow(renderWindow);

                vtkNew<vtkOpenVRCamera> cam;
                renderer->SetActiveCamera(cam);

                renderer->AddActor(actor);
                renderer->SetBackground(.2, .3, .4);

                renderWindow->Render();
                renderWindowInteractor->Start();

  }

  return EXIT_SUCCESS;
}*

When it comes to reading the contents of the folder I have no troubles, the
path is correct and I'm using the correct reader for the vtp files. I can't
figure out what is wrong with my program. I've used several break points and
so far what i've noticed is that the reading procces in the for loop only
goes as far as the first file in my folder, then it stops and renders
nothing.

Any ideas on what could be going wrong?





--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Dev-f1251487.html
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers