7 #include "fwVtkIO/helper/Mesh.hpp" 8 #include "fwVtkIO/MeshReader.hpp" 9 #include "fwVtkIO/helper/vtkLambdaCommand.hpp" 11 #include <fwCore/base.hpp> 13 #include <fwDataIO/reader/registry/macros.hpp> 15 #include <fwJobs/IJob.hpp> 16 #include <fwJobs/Observer.hpp> 18 #include <vtkGenericDataObjectReader.h> 19 #include <vtkPolyData.h> 20 #include <vtkSmartPointer.h> 29 ::
fwData::location::enableSingleFile< ::
fwDataIO::reader::IObjectReader >(this),
30 m_job(::
fwJobs::Observer::New(
"Mesh reader"))
52 vtkSmartPointer< vtkGenericDataObjectReader > reader = vtkSmartPointer< vtkGenericDataObjectReader >::New();
53 reader->SetFileName(this->
getFile().
string().c_str());
55 vtkSmartPointer< vtkLambdaCommand > progressCallback;
57 progressCallback = vtkSmartPointer< vtkLambdaCommand >::New();
58 progressCallback->SetCallback(
59 [&](vtkObject* caller,
long unsigned int,
void*)
61 auto filter =
static_cast< vtkGenericDataObjectReader*
>(caller);
62 m_job->doneWork(filter->GetProgress() * 100);
65 reader->AddObserver(vtkCommand::ProgressEvent, progressCallback);
67 m_job->addSimpleCancelHook([&] { reader->AbortExecuteOn(); });
71 vtkDataObject *obj = reader->GetOutput();
72 vtkPolyData* mesh = vtkPolyData::SafeDownCast(obj);
73 FW_RAISE_IF(
"MeshReader cannot read VTK Mesh file : "<< this->
getFile().
string(), !mesh);
FWVTKIO_API void read() override
Reading operator.
FWVTKIO_API ~MeshReader()
Destructor.
#define SLM_TRACE_FUNC()
Trace contextual function signature.
This namespace fwDataIO contains reader and writer for several framework's data.
::fwTools::Object::wptr m_object
Object result of reading process.
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::string extension() override
virtual std::shared_ptr< DataType > getConcreteObject()
m_object getter.
ILocation::PathType getFile()
Get file system path.
Contains the representation of the data objects used in the framework.
static FWVTKIO_API void fromVTKMesh(vtkSmartPointer< vtkPolyData > _polyData,::fwData::Mesh::sptr _mesh)
Convert a vtkPolyData to a ::fwData::Mesh::sptr.
FWVTKIO_API std::shared_ptr< ::fwJobs::IJob > getJob() const override
FWVTKIO_API MeshReader(::fwDataIO::reader::IObjectReader::Key key)
Constructor.
This namespace fwJobs provides jobs management.