X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FcreaVtk.txx;h=c4e7167747d135f05c2d48269e4b445efb39bc82;hb=08d413da4e6a2345cf06424418857a4f6715daf9;hp=4d39387958debb94ce4b6316ccdff53b8986af9d;hpb=bfb05457f0fad7329768d34492a2a2149195471a;p=crea.git diff --git a/src/creaVtk.txx b/src/creaVtk.txx index 4d39387..c4e7167 100644 --- a/src/creaVtk.txx +++ b/src/creaVtk.txx @@ -1,39 +1,83 @@ #include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include -#include +#include +#include namespace crea -{ - +{ template - vtkImageData* CREA_EXPORT NewVtkImageDataFromRaw( T* data, + /*CREA_EXPORT*/ vtkImageData* NewVtkImageDataFromRaw( T* data, int nx, int ny, - int nz) + int nz, + bool do_not_desalloc) { - std::cout << "NV "<::SizedName() << std::endl; + vtkImageData *image = vtkImageData::New(); + + // Shouldn't we pass NumberOfScalarComponents to deal with RGB, RGBA images as well? // JPR + image->SetNumberOfScalarComponents(1); - image->SetScalarType(GetVtkIdType(*data)); - image->SetDimensions(nx,ny,nz); - image->SetSpacing(1,1,1); - std::cout << "alloc"<::VTKTypeID(); + image->SetScalarType(vtktype); + image->SetDimensions(nx, ny ,nz); + image->SetSpacing(1, 1, 1); image->AllocateScalars(); - std::cout << "alloc ok"<* array - = (vtkDataArrayTemplate*)vtkDataArrayTemplate::New(); - std::cout << "data array alloc ok"<SetNumberOfComponents( 1 ); - std::cout << "nb compo ok"<::SizedName() + <<" non implemented"); + } + vtkDataArrayTemplate* tarray + = dynamic_cast*>(array); + array->SetNumberOfComponents( 1 ); size_t size = (long)nx*(long)ny*(long)nz; - std::cout << "SetArray"<SetArray( data, size, 1 ); - //Pay attention in particular to the last param of SetArray: - //http://www.vtk.org/doc/nightly/html/classvtkUnsignedShortArray.html#z798_0 - std::cout << "SetScalars"<GetPointData( )->SetScalars( array ); - std::cout << "Delete"<SetArray( data, size, dndesa ); + image->GetPointData( )->SetScalars( tarray ); array->Delete( ); return image; }