2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 #include "bbvtkPolyDataReaderPlus.h"
29 #include "bbvtkPackage.h"
33 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,PolyDataReaderPlus)
34 BBTK_BLACK_BOX_IMPLEMENTATION(PolyDataReaderPlus,bbtk::AtomicBlackBox);
35 void PolyDataReaderPlus::Process()
38 std::cout << "[" << this << "]" << "PolyDataReaderPlus::Process()..." << std::endl;
39 //Review the observers...
41 if (!HasObserver(OBS_POST_READER_1) && bbGetInputInPostReadObs1() != NULL)
42 AddObserver(OBS_POST_READER_1, bbGetInputInPostReadObs1());
44 if (bbGetInputInPath().size()==0)
46 std::cout << "Set InPath." << std::endl;
53 std::vector< std::string > partes = StringSplit(bbGetInputInPath(), ".");
54 std::string extension = partes.at(partes.size()-1);
56 std::cout << "Extension (vtk o vtp?) = " << extension << std::endl;
58 if (extension.compare("vtk") == 0)
60 //vtkPolyDataReader* reader = vtkPolyDataReader::New();
61 vtkGenericDataObjectReader* reader = vtkGenericDataObjectReader::New();
62 reader->SetFileName(bbGetInputInPath().data());
63 informacion = (vtkPolyData*)reader->GetOutput();
64 reader->CloseVTKFile();
65 vtkPolyData* old = bbGetOutputOut(); // old unused ? // JPR
66 bbSetOutputOut(informacion);
70 if (extension.compare("vtp") == 0)
72 vtkXMLPolyDataReader* reader = vtkXMLPolyDataReader::New();
73 reader->SetFileName(bbGetInputInPath().data());
74 informacion = reader->GetOutput();
76 vtkPolyData* old = bbGetOutputOut(); // old unused ? // JPR
77 bbSetOutputOut(informacion);
82 vtkActor *actor = (vtkActor*)bbGetOutputOutActor();
83 vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
85 //EED 2017-01-01 Migration VTK7
86 #if VTK_MAJOR_VERSION <= 5
87 mapper->SetInput(informacion);
89 mapper->SetInputData(informacion);
92 actor->SetMapper(mapper);
93 bbSetOutputOutActor(actor);
95 if (bbGetInputInColor().size() >= 3)
97 actor->GetProperty()->SetColor(bbGetInputInColor()[0],bbGetInputInColor()[1],bbGetInputInColor()[2]);
101 actor->GetProperty()->SetColor(1,1,1);
103 actor->GetProperty()->SetOpacity(bbGetInputInOpacity()/100);
107 InvokeEvent(OBS_POST_READER_1, informacion);
109 std::cout << "END [" << this << "]" << "PolyDataReaderPlus::Process()..." << std::endl;
112 void PolyDataReaderPlus::bbUserSetDefaultValues()
115 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
116 // Here we initialize the input 'In' to 0
117 vtkPolyData* empty = vtkPolyData::New();
118 vtkActor *actor = vtkActor::New();
119 bbSetOutputOut(empty);
120 bbSetInputInPostReadObs1(NULL);
121 std::string nada = "";
122 bbSetInputInPath(nada);
123 bbSetOutputOutActor(actor);
124 bbSetInputInOpacity(50);
129 void PolyDataReaderPlus::bbUserInitializeProcessing()
132 // THE INITIALIZATION METHOD BODY :
134 // but this is where you should allocate the internal/output pointers
139 void PolyDataReaderPlus::bbUserFinalizeProcessing()
142 // THE FINALIZATION METHOD BODY :
144 // but this is where you should desallocate the internal/output pointers
150 // EO namespace bbvtk