vtkImageData* CREA_EXPORT NewVtkImageDataFromRaw( T* data,
                                                    int nx, 
                                                    int ny,
-                                                   int nz)
+                                                   int nz,
+                                                   bool do_not_desalloc)
   {
     //    std::cout << "NV "<<nx<<" " <<ny<<" " << nz<<std::endl;
     //    std::cout <<  vtkTypeTraits<T>::SizedName() << std::endl;
       = dynamic_cast<vtkDataArrayTemplate<T>*>(array);
     array->SetNumberOfComponents( 1 );
     size_t size = (long)nx*(long)ny*(long)nz;
-    // The last param of SetArray is set to 1 to keep the class from deleting the array when it cleans up or reallocates memory.
-    tarray->SetArray( data, size, 1 );
+    // The last param of SetArray is set to 1 to keep the class from deleting the array 
+    // when it cleans up or reallocates memory.
+       int dndesa = 0;
+       if (do_not_desalloc) dndesa = 1;
+    tarray->SetArray( data, size, dndesa );
     image->GetPointData( )->SetScalars( tarray );
     array->Delete( );
     return image;