1 #include "bbvtkPolyDataReaderPlus.h"
2 #include "bbvtkPackage.h"
6 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,PolyDataReaderPlus)
7 BBTK_BLACK_BOX_IMPLEMENTATION(PolyDataReaderPlus,bbtk::AtomicBlackBox);
8 void PolyDataReaderPlus::Process()
11 std::cout << "[" << this << "]" << "PolyDataReaderPlus::Process()..." << std::endl;
12 //Review the observers...
14 if (!HasObserver(OBS_POST_READER_1) && bbGetInputInPostReadObs1() != NULL)
15 AddObserver(OBS_POST_READER_1, bbGetInputInPostReadObs1());
17 if (bbGetInputInPath().size()==0)
19 std::cout << "Set InPath." << std::endl;
26 std::vector< std::string > partes = StringSplit(bbGetInputInPath(), ".");
27 std::string extension = partes.at(partes.size()-1);
29 std::cout << "Extension (vtk o vtp?) = " << extension << std::endl;
31 if (extension.compare("vtk") == 0)
33 //vtkPolyDataReader* reader = vtkPolyDataReader::New();
34 vtkGenericDataObjectReader* reader = vtkGenericDataObjectReader::New();
35 reader->SetFileName(bbGetInputInPath().data());
36 informacion = (vtkPolyData*)reader->GetOutput();
37 reader->CloseVTKFile();
38 vtkPolyData* old = bbGetOutputOut(); // old unused ? // JPR
39 bbSetOutputOut(informacion);
43 if (extension.compare("vtp") == 0)
45 vtkXMLPolyDataReader* reader = vtkXMLPolyDataReader::New();
46 reader->SetFileName(bbGetInputInPath().data());
47 informacion = reader->GetOutput();
49 vtkPolyData* old = bbGetOutputOut(); // old unused ? // JPR
50 bbSetOutputOut(informacion);
55 vtkActor *actor = (vtkActor*)bbGetOutputOutActor();
56 vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
58 mapper->SetInput(informacion);
59 actor->SetMapper(mapper);
61 bbSetOutputOutActor(actor);
63 if (bbGetInputInColor().size() >= 3)
65 actor->GetProperty()->SetColor(bbGetInputInColor()[0],bbGetInputInColor()[1],bbGetInputInColor()[2]);
69 actor->GetProperty()->SetColor(1,1,1);
71 actor->GetProperty()->SetOpacity(bbGetInputInOpacity()/100);
75 InvokeEvent(OBS_POST_READER_1, informacion);
77 std::cout << "END [" << this << "]" << "PolyDataReaderPlus::Process()..." << std::endl;
80 void PolyDataReaderPlus::bbUserSetDefaultValues()
83 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
84 // Here we initialize the input 'In' to 0
85 vtkPolyData* empty = vtkPolyData::New();
86 vtkActor *actor = vtkActor::New();
87 bbSetOutputOut(empty);
88 bbSetInputInPostReadObs1(NULL);
89 std::string nada = "";
90 bbSetInputInPath(nada);
91 bbSetOutputOutActor(actor);
92 bbSetInputInOpacity(50);
97 void PolyDataReaderPlus::bbUserInitializeProcessing()
100 // THE INITIALIZATION METHOD BODY :
102 // but this is where you should allocate the internal/output pointers
107 void PolyDataReaderPlus::bbUserFinalizeProcessing()
110 // THE FINALIZATION METHOD BODY :
112 // but this is where you should desallocate the internal/output pointers
118 // EO namespace bbvtk