From: Eduardo Davila Date: Mon, 6 Aug 2012 11:49:20 +0000 (+0000) Subject: BUG 1576 Flip Box X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=6d51daa37bb1a74e8a42053a4c47c3e3ef074406;p=bbtk.git BUG 1576 Flip Box We need to duplicate memory --- diff --git a/packages/vtk/src/bbvtkFlip.cxx b/packages/vtk/src/bbvtkFlip.cxx index 33d70a7..4a9bcd2 100644 --- a/packages/vtk/src/bbvtkFlip.cxx +++ b/packages/vtk/src/bbvtkFlip.cxx @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbvtkFlip.cxx,v $ Language: C++ - Date: $Date: 2012/07/09 13:03:17 $ - Version: $Revision: 1.3 $ + Date: $Date: 2012/08/06 11:49:20 $ + Version: $Revision: 1.4 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -58,8 +58,6 @@ namespace bbvtk void Flip::bbUserInitializeProcessing() { //std::cout << "-------- entree ds Flip::bbUserInitalizeProcessing()\n" << std::endl; - //bbUserFinalizeProcessing(); - mImageOut = vtkImageData::New(); // Alloc depends on bbGetInputIn().size() } //--------------------------------------------------------------------- @@ -70,8 +68,8 @@ namespace bbvtk // WTF? we never enter here // JPR bbUserFinalizeProcessing() JPR if (mImageOut!=NULL) { - // mImageOut->Delete(); - // mImageOut=NULL; + mImageOut->Delete(); + mImageOut=NULL; } bbSetOutputOut(mImageOut); } @@ -85,45 +83,57 @@ namespace bbvtk /// void Flip::Process() { - vtkImageData* imageIn = bbGetInputIn(); - vtkImageData * mImageOut = flip(imageIn); - - // Devrait etre dans bbUserFinalizeProcessing() ? // JPR - bbSetOutputOut(mImageOut); -} - + + if (bbGetInputIn()!=NULL) + { + if (mImageOut!=NULL) + { + mImageOut->Delete(); + mImageOut=NULL; + } // if mImageOut + + mImageOut = vtkImageData::New(); // Alloc depends on bbGetInputIn().size() + mImageOut->Initialize(); + mImageOut->SetScalarType( bbGetInputIn()->GetScalarType() ); + mImageOut->SetSpacing( bbGetInputIn()->GetSpacing() ); + mImageOut->SetDimensions( bbGetInputIn()->GetDimensions() ); + mImageOut->SetNumberOfScalarComponents( bbGetInputIn()->GetNumberOfScalarComponents() ); + mImageOut->AllocateScalars(); + + int inputdims[3]; + // int outputdims[3]; + bbGetInputIn()->GetDimensions (inputdims); + bbGetInputIn()->Update(); + int nbScalComp = bbGetInputIn()->GetNumberOfScalarComponents(); + int scalarSize = bbGetInputIn()->GetScalarSize(); + int lineSize = inputdims[0]*scalarSize*nbScalComp; + int planeSize = inputdims[1]*lineSize; + char *pixelsIn = (char *)bbGetInputIn()->GetScalarPointer(); + char *pixelsOut = (char *)mImageOut->GetScalarPointer(); + + char *lineIn; + char *lineOut; + char *debPlanIn; + char *debPlanOut; + int j,k; + for(k=0; kGetDimensions (inputdims); - imageIn->Update(); - int nbScalComp = imageIn->GetNumberOfScalarComponents(); - int scalarSize = imageIn->GetScalarSize(); - int lineSize = inputdims[0]*scalarSize*nbScalComp; - int planeSize = inputdims[1]*lineSize; - char *pixelsIn = (char *)imageIn->GetScalarPointer(); - - char *temp = (char *)malloc(lineSize); - char *line1; - char *line2; - char *debPlan; - for(int k=0; k