From: jean-pierre roux <jean-pierre.roux@creatis.insa-lyon.fr>
Date: Wed, 17 Feb 2010 17:41:52 +0000 (+0000)
Subject: Chasse aux variables non initialisées
X-Git-Tag: CREATOOLS.2-0-3~5
X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=de35484154f0fc838c0aa515db96994166bba17d;p=creaRigidRegistration.git

Chasse aux variables non initialisées
---

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c81b8a9..d9613c2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,7 +10,7 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
 ###################################
-PROJECT(CreaRecalage)
+PROJECT(creaRigidRegistration)
 ###################################
 
 #==================================
diff --git a/PackRecalage/bbs/appli/ExampleRecalage.bbs b/PackRecalage/bbs/appli/ExampleRecalage.bbs
index 463371c..ea5ea42 100644
--- a/PackRecalage/bbs/appli/ExampleRecalage.bbs
+++ b/PackRecalage/bbs/appli/ExampleRecalage.bbs
@@ -98,7 +98,6 @@ new ViewerNV viewer3
 
 new CommandButton butExec
   //set butExec.Label "Execute"
- 
 
 //Tab for the first image
 
@@ -140,4 +139,4 @@ connect tab1.Widget main.Widget1
 connect tab2.Widget main.Widget2
 //connect result.Widget main.Widget3
 
-exec main
\ No newline at end of file
+exec main
diff --git a/PackRecalage/src/bbPackRecalageReSlicerBox.cxx b/PackRecalage/src/bbPackRecalageReSlicerBox.cxx
index 7719669..0786a1d 100644
--- a/PackRecalage/src/bbPackRecalageReSlicerBox.cxx
+++ b/PackRecalage/src/bbPackRecalageReSlicerBox.cxx
@@ -37,11 +37,11 @@ void ReSlicerBox::Process()
 		imageResult->SetOutputSpacing( spc ); 
 		imageResult->SetOutputOrigin( 0,0,0 ); 
 	
-		bbSetOutputOut( imageResult->GetOutput() );			
+		bbSetOutputOut( imageResult->GetOutput() );
 	}
 	else
 	{
-		bbSetOutputOut( NULL );		
+		bbSetOutputOut( NULL );
 	}  
 }
 void ReSlicerBox::bbUserSetDefaultValues()
diff --git a/PackRecalage/src/bbPackRecalageResampleBox.cxx b/PackRecalage/src/bbPackRecalageResampleBox.cxx
index 3a5a7b8..9350844 100644
--- a/PackRecalage/src/bbPackRecalageResampleBox.cxx
+++ b/PackRecalage/src/bbPackRecalageResampleBox.cxx
@@ -3,8 +3,8 @@
 namespace bbPackRecalage
 {
 
-BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,ResampleBox)
-BBTK_BLACK_BOX_IMPLEMENTATION(ResampleBox,bbtk::AtomicBlackBox);
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage, ResampleBox)
+BBTK_BLACK_BOX_IMPLEMENTATION(ResampleBox, bbtk::AtomicBlackBox);
 void ResampleBox::Process()
 {
     if(bbGetInputIn() != NULL && bbGetInputFactor() != 0)
@@ -24,20 +24,24 @@ void ResampleBox::Process()
 		bbSetOutputOut(NULL);
 	}
 }
+
 void ResampleBox::bbUserSetDefaultValues()
 {
     bbSetInputIn(NULL);
 	bbSetInputFactor(0);
 	bbSetOutputOut(NULL);
 }
+
 void ResampleBox::bbUserInitializeProcessing()
 {
 	resample = vtkImageResample::New();
 }
+
 void ResampleBox::bbUserFinalizeProcessing()
 {
 	resample->Delete(); 
 }
+
 }
 // EO namespace bbPackRecalage
 
diff --git a/PackRecalage/src/bbPackRecalageResampleBox.h b/PackRecalage/src/bbPackRecalageResampleBox.h
index 8cf3b37..33d7eb2 100644
--- a/PackRecalage/src/bbPackRecalageResampleBox.h
+++ b/PackRecalage/src/bbPackRecalageResampleBox.h
@@ -13,7 +13,7 @@ class bbPackRecalage_EXPORT ResampleBox
  : 
    public bbtk::AtomicBlackBox
 {
-  BBTK_BLACK_BOX_INTERFACE(ResampleBox,bbtk::AtomicBlackBox);
+  BBTK_BLACK_BOX_INTERFACE(ResampleBox, bbtk::AtomicBlackBox);
   BBTK_DECLARE_INPUT(In,vtkImageData *);
   BBTK_DECLARE_INPUT(Factor,double);
   BBTK_DECLARE_OUTPUT(Out,vtkImageData *);
diff --git a/PackRecalage/src/bbPackRecalageTransform3D3PointsBox.cxx b/PackRecalage/src/bbPackRecalageTransform3D3PointsBox.cxx
index 009c16a..b4eb9df 100644
--- a/PackRecalage/src/bbPackRecalageTransform3D3PointsBox.cxx
+++ b/PackRecalage/src/bbPackRecalageTransform3D3PointsBox.cxx
@@ -16,7 +16,7 @@ void Transform3D3PointsBox::Process()
 		double A2[3];
 		double B2[3];
 		double O2[3];
-		
+
 		//In case there is an order in the points
 		if(!bbGetInputLabels1().empty() && !bbGetInputLabels2().empty() && bbGetInputLabels1()[0].compare("1") == 0 && bbGetInputLabels1()[1].compare("2") == 0 && bbGetInputLabels1()[2].compare("3") == 0)
 		{
@@ -92,7 +92,7 @@ void Transform3D3PointsBox::Process()
 		}
 
 		//Create the new center point
-		double centerPoint[3];
+		double centerPoint[3];  // JPR
 		centerPoint[0] = O2[0];
 		centerPoint[1] = O2[1];
 		centerPoint[2] = O2[2];
@@ -252,3 +252,4 @@ void Transform3D3PointsBox::bbUserFinalizeProcessing()
 }
 }
 // EO namespace bbPackRecalage
+
diff --git a/lib/CheckBoard.cpp b/lib/CheckBoard.cpp
index cb3bdc6..a0ae2d7 100644
--- a/lib/CheckBoard.cpp
+++ b/lib/CheckBoard.cpp
@@ -1,12 +1,22 @@
 #include "CheckBoard.h"
 
-
 /*
 * Constructor
 */
 //------------------------------------------------------------
 CheckBoard::CheckBoard()
+:		// use 'Initialization List'! //JPR
+	image1(NULL);
+	image2(NULL);
+	squaresX(0);
+	squaresY(0);
+	newImage(NULL);
+	processed(false);
+	newImage(NULL);
+	resample(NULL);
+	result(NULL);
 {
+/*
 	image1=NULL;
 	image2=NULL;
 	squaresX=0;
@@ -16,6 +26,7 @@ CheckBoard::CheckBoard()
 	newImage = NULL;
 	resample = NULL;
 	result = NULL;
+*/
 }
 
 /*
@@ -27,7 +38,7 @@ CheckBoard::~CheckBoard()
 	//if (image1 != NULL ) { image1->Delete(); }
 	//if (image2 != NULL ) { image2->Delete(); }
 	if (newImage != NULL ) { newImage->Delete(); }
-	if (result != NULL ) { result->Delete(); }
+	if (result   != NULL ) { result->Delete();   }
 }
 
 //------------------------------------------------------------
@@ -36,7 +47,6 @@ void CheckBoard::calculateImage()
 
 	if(image1!=NULL && image2!=NULL)
 	{
-
 		// IMAGE 1
 			
 		// Information from image1
@@ -44,7 +54,7 @@ void CheckBoard::calculateImage()
 		image1->GetExtent(extImg1);
 
 		type = image1->GetScalarType();
-		
+
 		// The Z dimension is 1 for a 2D image
 		dimImg1[0] = extImg1[1] - extImg1[0]+1;
 		dimImg1[1] = extImg1[3] - extImg1[2]+1;
@@ -63,7 +73,7 @@ void CheckBoard::calculateImage()
 
 		long numPixelsImg1 = dimImg1[0]*dimImg1[1];
 		long numPixelsImg2 = dimImg2[0]*dimImg2[1];
-		
+
 		double factorX = 1;
 		double factorY = 1;
 		resample = vtkImageResample::New();
@@ -81,7 +91,6 @@ void CheckBoard::calculateImage()
 			result = resample->GetOutput();
 			result->Update();
 			createImage(result,image2,dimImg2[0],dimImg2[1]);		
-			
 		} //if
 		else if (numPixelsImg1>numPixelsImg2)
 		{
@@ -94,7 +103,7 @@ void CheckBoard::calculateImage()
 
 			initialize(dimImg1, spcImg1);
 			result = resample->GetOutput();
-			
+
 			result->Update();
 
 			createImage(image1,result,dimImg1[0],dimImg1[1]);
@@ -114,11 +123,11 @@ void CheckBoard::calculateImage()
 
 			result = resample->GetOutput();
 			result->Update();
-			
+
 			createImage(image1,result,dimImg1[0],dimImg1[1]);
 
 		} //else
-		
+
 		resample->Delete();		
 		processed=true;
 	}
@@ -137,8 +146,6 @@ void CheckBoard::initialize(int dimensions[], double spacing[])
 	newImage->SetDimensions(dimensions);
 	newImage->AllocateScalars();
 	newImage->Update();
-	
-
 }
 
 //------------------------------------------------------------
@@ -247,7 +254,6 @@ void CheckBoard::createImage(vtkImageData *img1, vtkImageData *img2, int sizeX,
 		createImageByType(dataImagePointer1,dataImagePointer2,dataImageResultPointer,img1,img2,sizeX,sizeY);
 	}
 
-		
 	//std::cout << "The image has been checkboardized!" << std::endl;
    newImage->Update();
 //   newImage->Modified();
@@ -260,7 +266,7 @@ void CheckBoard::createImageByType(T* dataImagePointer1, T* dataImagePointer2, T
 	dataImagePointer1 = (T*) img1->GetScalarPointer(0,0,0);
 	dataImagePointer2 = (T*) img2->GetScalarPointer(0,0,0);
 	dataImageResultPointer = (T*) newImage->GetScalarPointer(0,0,0);
-	
+
 	if(squaresX == 0)
 	{
 		squaresX = 1;
@@ -268,11 +274,12 @@ void CheckBoard::createImageByType(T* dataImagePointer1, T* dataImagePointer2, T
 	if(squaresY == 0)
 	{
 		squaresY = 1;
-	}    
+	}
 
 	int divX = sizeX/squaresX;
 	int divY = sizeY/squaresY;
-	int i, j, counterX, counterY;
+	int i, j;
+	int counterX=0, counterY;  // JPR : uninitialized
 	for(i = 0; i < sizeX; i++)
 	{
 		counterY = 0; 
@@ -341,4 +348,3 @@ void CheckBoard::setRows(int rows)
 {
 	squaresY=rows;
 }
-
diff --git a/lib/Substraction.cxx b/lib/Substraction.cxx
index 853e5de..96f01a4 100644
--- a/lib/Substraction.cxx
+++ b/lib/Substraction.cxx
@@ -44,7 +44,7 @@ Substraction::Substraction(vtkImageData* imageData1,vtkImageData* imageData2, in
 	}
 	
 	//Original image type this case is an unsigned char (3)
-	int t=imageData1->GetScalarType();
+	//int t=imageData1->GetScalarType(); // JPR : unused
 	//substracting the image
 	substractImage(imageData1, imageData2);
 }
@@ -58,7 +58,6 @@ Substraction::~Substraction()
 // Methods
 //----------------------------------------------------------------------------
 
-
 /*
 Calculate the new image and save it in the attribute imageResult
 it is used if the user had given the imageData
@@ -66,27 +65,27 @@ it is used if the user had given the imageData
 void Substraction::substractImage(vtkImageData* imageData1, vtkImageData* imageData2)
 {
 	//dimensions of the image (extent)
-	int ext[6];
+    int ext[6];
 	//setting the dimensionality (1d or 2d or 3d )
     int newDim[3];
 	//image spacing
     double spc[3];
   
 	//getting the information from the original image
-	imageData1->GetSpacing(spc);
-	imageData1->GetExtent(ext);
+    imageData1->GetSpacing(spc);
+    imageData1->GetExtent(ext);
 	
 	//this a 2d image
-	newDim[0]=ext[1]-ext[0]+1;
+    newDim[0]=ext[1]-ext[0]+1;
     newDim[1]=ext[3]-ext[2]+1;
     newDim[2]=1;// in general it is ext[5]-ext[4]+1
 
 
-	imageType = imageData1->GetScalarType();
+    imageType = imageData1->GetScalarType();
 	//initializing the image that represents the substracted image
-	initialize(newDim,spc);
+    initialize(newDim,spc);
 	//Time to substract
-	substract(imageData1, imageData2);	
+    substract(imageData1, imageData2);	
 }
 
 /*
diff --git a/lib/Surface.cxx b/lib/Surface.cxx
index 08993a9..0886e13 100644
--- a/lib/Surface.cxx
+++ b/lib/Surface.cxx
@@ -233,7 +233,8 @@ void Surface::surfaceByType(T* dataImagePointer, vtkImageData* imageData, T max)
 	//-----------------
 	//walking in the image
 	int i=0,j=0,k=0;
-	double sum1=0,sum2=0,sum3=0,sum4=0;	
+	double sum1=0;  
+	//double sum2=0,sum3=0,sum4=0;	// JPR : unused
 	for(i=0;i<sx;i++)
 	{
 		for(j=0;j<sy;j++)