#include "bbvtkPolyDataReaderPlus.h" #include "bbvtkPackage.h" namespace bbvtk { BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,PolyDataReaderPlus) BBTK_BLACK_BOX_IMPLEMENTATION(PolyDataReaderPlus,bbtk::AtomicBlackBox); void PolyDataReaderPlus::Process() { std::cout << "[" << this << "]" << "PolyDataReaderPlus::Process()..." << std::endl; //Review the observers... if (!HasObserver(OBS_POST_READER_1) && bbGetInputInPostReadObs1() != NULL) AddObserver(OBS_POST_READER_1, bbGetInputInPostReadObs1()); if (bbGetInputInPath().size()==0) { std::cout << "Set InPath." << std::endl; return; } //Read! if (!readed) { std::vector< std::string > partes = StringSplit(bbGetInputInPath(), "."); std::string extension = partes.at(partes.size()-1); std::cout << "Extension (vtk o vtp?) = " << extension << std::endl; if (extension.compare("vtk") == 0) { //vtkPolyDataReader* reader = vtkPolyDataReader::New(); vtkGenericDataObjectReader* reader = vtkGenericDataObjectReader::New(); reader->SetFileName(bbGetInputInPath().data()); informacion = (vtkPolyData*)reader->GetOutput(); reader->CloseVTKFile(); vtkPolyData* old = bbGetOutputOut(); bbSetOutputOut(informacion); readed = true; } if (extension.compare("vtp") == 0) { vtkXMLPolyDataReader* reader = vtkXMLPolyDataReader::New(); reader->SetFileName(bbGetInputInPath().data()); informacion = reader->GetOutput(); vtkPolyData* old = bbGetOutputOut(); bbSetOutputOut(informacion); readed = true; } } vtkActor *actor = (vtkActor*)bbGetOutputOutActor(); vtkPolyDataMapper *mapper = vtkPolyDataMapper::New(); mapper->SetInput(informacion); actor->SetMapper(mapper); bbSetOutputOutActor(actor); if (bbGetInputInColor().size() >= 3) { actor->GetProperty()->SetColor(bbGetInputInColor()[0],bbGetInputInColor()[1],bbGetInputInColor()[2]); } else { actor->GetProperty()->SetColor(1,1,1); } actor->GetProperty()->SetOpacity(bbGetInputInOpacity()/100); //old->Delete(); InvokeEvent(OBS_POST_READER_1, informacion); std::cout << "END [" << this << "]" << "PolyDataReaderPlus::Process()..." << std::endl; } void PolyDataReaderPlus::bbUserSetDefaultValues() { // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 vtkPolyData* empty = vtkPolyData::New(); vtkActor *actor = vtkActor::New(); bbSetOutputOut(empty); bbSetInputInPostReadObs1(NULL); std::string nada = ""; bbSetInputInPath(nada); bbSetOutputOutActor(actor); bbSetInputInOpacity(50); readed = false; } void PolyDataReaderPlus::bbUserInitializeProcessing() { // THE INITIALIZATION METHOD BODY : // Here does nothing // but this is where you should allocate the internal/output pointers // if any } void PolyDataReaderPlus::bbUserFinalizeProcessing() { // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any } } // EO namespace bbvtk