/*# --------------------------------------------------------------------- # # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image # pour la Sant�) # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton # Previous Authors : Laurent Guigues, Jean-Pierre Roux # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil # # This software is governed by the CeCILL-B license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL-B # license as circulated by CEA, CNRS and INRIA at the following URL # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html # or in the file LICENSE.txt. # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL-B license and that you accept its terms. # ------------------------------------------------------------------------ */ #include "wxMaracasSurfaceRenderingManagerData.h" #include #include "vtkSTLWriter.h" #include "vtkPLYWriter.h" #include "vtkPolyDataWriter.h" #include "surfacerenderingimagestencilexport.h" #include "vtkMetaImageWriter.h" #include "vtkPolyDataReader.h" #include "vtkPLYReader.h" #include "vtkSmartPointer.h" /******************************************************************************************** ** Start of data viewmanagerData *********************************************************************************************/ wxMaracasSurfaceRenderingManagerData::wxMaracasSurfaceRenderingManagerData(vtkProp3D* prop3Dvect, std::string dataname, vtkRenderWindowInteractor* interactor){ _dataMapper = 0; _prop3D = prop3Dvect; _dataname = dataname; _boxWidgetS1=NULL; initializeBoxWidget(interactor); /*_boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(0) ); _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(1) ); _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(2) ); _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(3) );*/ } wxMaracasSurfaceRenderingManagerData::wxMaracasSurfaceRenderingManagerData(string filename, vtkRenderWindowInteractor* interactor){ _prop3D = getProp3D(filename); _dataname = filename; _boxWidgetS1=NULL; initializeBoxWidget(interactor); } vtkProp3D* wxMaracasSurfaceRenderingManagerData::getProp3D(std::string filename){ if(filename.compare("")!= 0){ vtkSmartPointer polydata = vtkSmartPointer::New(); std::string ext = filename.substr(filename.find_last_of("."), 4); if(ext.compare(STL)==0){ vtkSmartPointer STLReader=vtkSmartPointer::New(); STLReader->SetFileName(filename.c_str()); STLReader->Update(); polydata->DeepCopy(STLReader->GetOutput()); }else if(ext.compare(PLY)==0){ vtkSmartPointer plyreader =vtkSmartPointer::New(); plyreader->SetFileName(filename.c_str()); plyreader->Update(); polydata->DeepCopy(plyreader->GetOutput()); }else if(ext.compare(VTK)==0){ vtkSmartPointer polyreader =vtkSmartPointer::New(); polyreader->SetFileName(filename.c_str()); polyreader->Update(); polydata->DeepCopy(polyreader->GetOutput()); } _dataMapper = vtkPolyDataMapper::New(); _dataMapper->SetInput(polydata); vtkActor* dataActor = vtkActor::New(); dataActor->SetMapper(_dataMapper); dataActor->GetProperty()->SetOpacity(1); return dataActor; } return NULL; } wxMaracasSurfaceRenderingManagerData::~wxMaracasSurfaceRenderingManagerData(){ _prop3D->Delete(); if (_boxWidgetS1!=NULL) { _boxWidgetS1 -> Delete(); } } void wxMaracasSurfaceRenderingManagerData::initializeBoxWidget(vtkRenderWindowInteractor* interactor){ if(interactor!= NULL){ } } /** ** Adds a prop3D to the world of the application **/ void wxMaracasSurfaceRenderingManagerData::setProp3D(vtkProp3D* prop3D){ _prop3D = prop3D; } void wxMaracasSurfaceRenderingManagerData::addRemoveSurfaceBox(bool visible) { if(_boxWidgetS1){ if (visible==true){ _boxWidgetS1->On(); } else { _boxWidgetS1->Off(); } } } /** ** Changes the opacity in a prop3D **/ void wxMaracasSurfaceRenderingManagerData::changeOpacity(int value){ std::cout<<"chage op"<_prop3D; actor->GetProperty()->SetOpacity((double)value/100.0); } void wxMaracasSurfaceRenderingManagerData::changeColor(double red, double green, double blue){ std::cout<<"chage col"<_prop3D; actor->GetProperty()->SetColor(red,green,blue); } /** ** Check if the variables are setted correctly **/ void wxMaracasSurfaceRenderingManagerData::checkInvariant(){ } /** ** get the prop3D **/ vtkProp3D* wxMaracasSurfaceRenderingManagerData::getProp3D(){ return this->_prop3D; } /** ** return the id from the daat **/ int wxMaracasSurfaceRenderingManagerData::getId(){ return _id; } /** ** set data id **/ void wxMaracasSurfaceRenderingManagerData::setId(int propid){ _id = propid; } /** ** Get the filanme **/ std::string wxMaracasSurfaceRenderingManagerData::getDataname(){ return _dataname; } /** ** Set the filanme **/ void wxMaracasSurfaceRenderingManagerData::setDataname(std::string dataname){ _dataname = dataname; } void wxMaracasSurfaceRenderingManagerData::saveProp3DSTL(const char* filename){ if(_dataMapper){ std::string filena(filename); std::string ext = filena.substr(filena.find_last_of("."), 4); if(ext.compare(PLY) == 0){ vtkSmartPointer plywriter = vtkSmartPointer::New(); plywriter->SetFileName(filename); plywriter->SetInput(_dataMapper->GetInput()); plywriter->Write(); }else if(ext.compare(STL) == 0){ vtkSmartPointer stlWriter = vtkSmartPointer::New(); stlWriter->SetFileName(filename); stlWriter->SetInput(_dataMapper->GetInput()); stlWriter->SetFileTypeToBinary(); stlWriter->Write(); }else if(ext.compare(VTK) == 0){ vtkSmartPointer polydataWriter = vtkSmartPointer::New(); polydataWriter->SetFileName(filename); polydataWriter->SetInput(_dataMapper->GetInput()); polydataWriter->SetFileTypeToBinary(); polydataWriter->Write(); }else{ cout<<"unsupported format"< stencilexport = vtkSmartPointer< SurfaceRenderingImageStencilExport >::New(); stencilexport->SetInput( _dataMapper->GetInput()); stencilexport->Update(); vtkImageData* imgstencil = stencilexport->GetOutput(); vtkSmartPointer metawriter = vtkSmartPointer::New(); metawriter->SetFileName(filename); metawriter->SetInput(imgstencil); metawriter->Write(); }else{ cout<<"No poly data set to data mapper."<