7 #include "fwVtkIO/MetaImageWriter.hpp" 9 #include "fwVtkIO/helper/vtkLambdaCommand.hpp" 10 #include "fwVtkIO/vtk.hpp" 12 #include <fwCore/base.hpp> 14 #include <fwDataIO/writer/registry/macros.hpp> 16 #include <fwJobs/IJob.hpp> 17 #include <fwJobs/Observer.hpp> 19 #include <vtkImageData.h> 20 #include <vtkMetaImageWriter.h> 21 #include <vtkSmartPointer.h> 30 ::
fwData::location::enableSingleFile< ::
fwDataIO::writer::IObjectWriter >(this),
31 m_job(::
fwJobs::Observer::New(
"MetaImage writer"))
54 vtkSmartPointer< vtkMetaImageWriter > writer = vtkSmartPointer< vtkMetaImageWriter >::New();
55 vtkSmartPointer< vtkImageData > vtkImage = vtkSmartPointer< vtkImageData >::New();
56 ::fwVtkIO::toVTKImage( pImage, vtkImage );
57 writer->SetInputData( vtkImage );
58 writer->SetFileName( this->
getFile().
string().c_str() );
59 writer->SetCompression(
true);
61 vtkSmartPointer<vtkLambdaCommand> progressCallback;
62 progressCallback = vtkSmartPointer<vtkLambdaCommand>::New();
63 progressCallback->SetCallback([
this](vtkObject* caller,
long unsigned int,
void* )
65 auto filter =
static_cast<vtkMetaImageWriter*
>(caller);
66 m_job->doneWork( filter->GetProgress()*100 );
69 writer->AddObserver(vtkCommand::ProgressEvent, progressCallback);
70 m_job->addSimpleCancelHook( [&]()
72 writer->AbortExecuteOn();
#define SLM_TRACE_FUNC()
Trace contextual function signature.
This namespace fwDataIO contains reader and writer for several framework's data.
::fwTools::Object::cwptr m_object
Object write on filesystem by the process.
virtual std::shared_ptr< const DataType > getConcreteObject() const
m_object getter.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
std::shared_ptr< ::fwJobs::IJob > sptr
Cancel request callback type.
ILocation::PathType getFile()
Get file system path.
Contains the representation of the data objects used in the framework.
This namespace fwJobs provides jobs management.