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)
43 AddObserver(OBS_POST_READER_1, bbGetInputInPostReadObs1());
46 if (bbGetInputInPath().size()==0)
48 std::cout << "Set InPath." << std::endl;
55 std::vector< std::string > partes = StringSplit(bbGetInputInPath(), ".");
56 std::string extension = partes.at(partes.size()-1);
57 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);
69 if (extension.compare("vtp") == 0)
71 vtkXMLPolyDataReader* reader = vtkXMLPolyDataReader::New();
72 reader->SetFileName(bbGetInputInPath().data());
73 informacion = reader->GetOutput();
75 vtkPolyData* old = bbGetOutputOut(); // old unused ? // JPR
76 bbSetOutputOut(informacion);
80 vtkActor *actor = (vtkActor*)bbGetOutputOutActor();
81 vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
82 //EED 2017-01-01 Migration VTK7
83 #if VTK_MAJOR_VERSION <= 5
84 mapper->SetInput(informacion);
86 mapper->SetInputData(informacion);
88 actor->SetMapper(mapper);
89 bbSetOutputOutActor(actor);
90 if (bbGetInputInColor().size() >= 3)
92 actor->GetProperty()->SetColor(bbGetInputInColor()[0],bbGetInputInColor()[1],bbGetInputInColor()[2]);
94 actor->GetProperty()->SetColor(1,1,1);
96 actor->GetProperty()->SetOpacity(bbGetInputInOpacity()/100);
98 InvokeEvent(OBS_POST_READER_1, informacion);
99 std::cout << "END [" << this << "]" << "PolyDataReaderPlus::Process()..." << std::endl;
102 void PolyDataReaderPlus::bbUserSetDefaultValues()
104 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
105 // Here we initialize the input 'In' to 0
106 vtkPolyData* empty = vtkPolyData::New();
107 vtkActor *actor = vtkActor::New();
108 bbSetOutputOut(empty);
109 bbSetInputInPostReadObs1(NULL);
110 std::string nada = "";
111 bbSetInputInPath(nada);
112 bbSetOutputOutActor(actor);
113 bbSetInputInOpacity(50);
117 void PolyDataReaderPlus::bbUserInitializeProcessing()
119 // THE INITIALIZATION METHOD BODY :
121 // but this is where you should allocate the internal/output pointers
125 void PolyDataReaderPlus::bbUserFinalizeProcessing()
127 // THE FINALIZATION METHOD BODY :
129 // but this is where you should desallocate the internal/output pointers
133 }// EO namespace bbvtk