7 #include "fwVtkIO/MeshWriter.hpp" 9 #include "fwVtkIO/helper/Mesh.hpp" 10 #include "fwVtkIO/helper/vtkLambdaCommand.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 <vtkGenericDataObjectWriter.h> 20 #include <vtkPolyData.h> 21 #include <vtkSmartPointer.h> 30 ::
fwData::location::enableSingleFile< ::
fwDataIO::writer::IObjectWriter >(this),
31 m_job(::
fwJobs::Observer::New(
"Mesh writer"))
54 vtkSmartPointer< vtkGenericDataObjectWriter > writer = vtkSmartPointer< vtkGenericDataObjectWriter >::New();
55 vtkSmartPointer< vtkPolyData > vtkMesh = vtkSmartPointer< vtkPolyData >::New();
57 writer->SetInputData( vtkMesh );
58 writer->SetFileName(this->
getFile().
string().c_str());
59 writer->SetFileTypeToBinary();
61 vtkSmartPointer<vtkLambdaCommand> progressCallback;
63 progressCallback = vtkSmartPointer<vtkLambdaCommand>::New();
64 progressCallback->SetCallback(
65 [&](vtkObject* caller,
long unsigned int,
void* )
67 auto filter =
static_cast<vtkGenericDataObjectWriter*
>(caller);
68 m_job->doneWork( filter->GetProgress()*100 );
71 writer->AddObserver(vtkCommand::ProgressEvent, progressCallback);
73 m_job->addSimpleCancelHook([&] { writer->AbortExecuteOn(); });
#define SLM_TRACE_FUNC()
Trace contextual function signature.
FWVTKIO_API ~MeshWriter()
Destructor.
static FWVTKIO_API void toVTKMesh(const ::fwData::Mesh::csptr &_mesh, vtkSmartPointer< vtkPolyData > _polyData)
Convert a ::fwData::Mesh::csptr to a vtkPolyData.
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.
FWVTKIO_API MeshWriter(::fwDataIO::writer::IObjectWriter::Key key)
Constructor.
FWVTKIO_API std::string extension() override
FWVTKIO_API void write() override
Reading operator.
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.
FWVTKIO_API std::shared_ptr< ::fwJobs::IJob > getJob() const override
ILocation::PathType getFile()
Get file system path.
Contains the representation of the data objects used in the framework.
This namespace fwJobs provides jobs management.