Răsfoiți Sursa

code formatting in Example.*

Sven Sickert 8 ani în urmă
părinte
comite
dedf824de4
2 a modificat fișierele cu 108 adăugiri și 107 ștergeri
  1. 107 106
      cbaselib/Example.cpp
  2. 1 1
      cbaselib/Example.h

+ 107 - 106
cbaselib/Example.cpp

@@ -10,15 +10,15 @@ using namespace NICE;
 
 Example::Example()
 {
-	weight = 0.0;
-	height = 0;
+    weight = 0.0;
+    height = 0;
     depth = 0;
-	width = 0;
+    width = 0;
     x = y = z = 0;
-	vec = NULL;
-	svec = NULL;
+    vec = NULL;
+    svec = NULL;
     ce = NULL;
-	position = 0;
+    position = 0;
 }
 
 Example::~Example ()
@@ -47,17 +47,17 @@ Example::Example ( CachedExample *_ce )
     y = height/2;
     z = depth/2;
 
-    ce = _ce; 
+    ce = _ce;
     vec = NULL;
     svec = NULL;
     weight = 1.0;
-	position = 0;
+    position = 0;
 }
 
-Example::Example ( CachedExample *_ce, 
-						   int _x,
-						   int _y,
-						   double _weight )
+Example::Example ( CachedExample *_ce,
+                   int _x,
+                   int _y,
+                   double _weight )
 {
     ce = _ce;
     x  = _x;
@@ -69,14 +69,14 @@ Example::Example ( CachedExample *_ce,
     vec = NULL;
     svec = NULL;
     weight = _weight;
-	position = 0;
+    position = 0;
 }
 
 Example::Example ( CachedExample *_ce,
-                           int _x,
-                           int _y,
-                           int _z,
-                           double _weight )
+                   int _x,
+                   int _y,
+                   int _z,
+                   double _weight )
 {
     ce = _ce;
     x  = _x;
@@ -91,12 +91,12 @@ Example::Example ( CachedExample *_ce,
     position = 0;
 }
 
-Example::Example ( CachedExample *_ce, 
-						   int _x,
-						   int _y,
-						   int _width,
-						   int _height,
-						   double _weight )
+Example::Example ( CachedExample *_ce,
+                   int _x,
+                   int _y,
+                   int _width,
+                   int _height,
+                   double _weight )
 {
     ce = _ce;
     x  = _x;
@@ -110,17 +110,17 @@ Example::Example ( CachedExample *_ce,
     vec = NULL;
     svec = NULL;
     weight = _weight;
-	position = 0;
+    position = 0;
 }
 
 Example::Example ( CachedExample *_ce,
-                           int _x,
-                           int _y,
-                           int _z,
-                           int _width,
-                           int _height,
-                           int _depth,
-                           double _weight )
+                   int _x,
+                   int _y,
+                   int _z,
+                   int _width,
+                   int _height,
+                   int _depth,
+                   double _weight )
 {
     ce = _ce;
     x  = _x;
@@ -137,8 +137,8 @@ Example::Example ( CachedExample *_ce,
     position = 0;
 }
 
-Example::Example ( NICE::Vector *_vec, 
-						   double _weight )
+Example::Example ( NICE::Vector *_vec,
+                   double _weight )
 {
     x = y = z = 0;
     width = height = depth = 0;
@@ -146,28 +146,28 @@ Example::Example ( NICE::Vector *_vec,
     vec = _vec;
     svec = NULL;
     weight = _weight;
-	position = 0;
+    position = 0;
 }
 
 void Example::clean ()
 {
-	if ( ce != NULL )
-	{
-		delete ce;
-		ce =  NULL;
-	}
-
-	if ( vec != NULL )
-	{
-		delete vec;
-		vec = NULL;
-	}
-    
-	if ( svec != NULL )
-	{
-		delete svec;
-		svec = NULL;
-	}
+    if ( ce != NULL )
+    {
+        delete ce;
+        ce =  NULL;
+    }
+
+    if ( vec != NULL )
+    {
+        delete vec;
+        vec = NULL;
+    }
+
+    if ( svec != NULL )
+    {
+        delete svec;
+        svec = NULL;
+    }
 }
 
 
@@ -178,18 +178,18 @@ Example::Example ( const Example &ex)
 
 void Example::copy ( const Example &ex)
 {
-	vec = ex.vec;
-	svec = ex.svec;
-	weight = ex.weight;
-	position = ex.position;
-	width = ex.width;
-	height = ex.height;
+    vec = ex.vec;
+    svec = ex.svec;
+    weight = ex.weight;
+    position = ex.position;
+    width = ex.width;
+    height = ex.height;
     depth = ex.depth;
-	x = ex.x;
-	y = ex.y;
+    x = ex.x;
+    y = ex.y;
     z = ex.z;
-	ce = ex.ce;
-	scale = ex.scale;
+    ce = ex.ce;
+    scale = ex.scale;
 }
 
 void Example::restore (istream & is, int format)
@@ -218,27 +218,28 @@ void Example::restore (istream & is, int format)
         z = 0;
     }
 
-	int tmp;
-	is >> tmp;
-
-	if(tmp == 1)
-	{
-		svec = new SparseVector();
-		svec->restore(is);
-	}
-	else
-		svec = NULL;
-	is >> tmp;
-	if(tmp >= 0 )
-	{
-		vec = new Vector(tmp);
-		for(int i = 0; i < tmp; i++)
-		{
-			is >> vec[i];
-		}
-	}
-	else
-		vec = NULL;
+    int tmp;
+    is >> tmp;
+
+    if(tmp == 1)
+    {
+        svec = new SparseVector();
+        svec->restore(is);
+    }
+    else
+	svec = NULL;
+
+    is >> tmp;
+    if(tmp >= 0 )
+    {
+        vec = new Vector(tmp);
+        for(int i = 0; i < tmp; i++)
+        {
+            is >> vec[i];
+        }
+    }
+    else
+        vec = NULL;
 }
 
 void Example::store (ostream & os, int format) const
@@ -248,33 +249,33 @@ void Example::store (ostream & os, int format) const
     else
         os << weight << " " <<  x << " " << y << " " << width << " " << height << " " << position << endl;
 
-	if(svec == NULL)
-		os << 0 << endl;
-	else
-	{
-		os << 1 << endl;
-		svec->store(os);
-	}
-	
-	if(vec == NULL)
-		os << -1 << endl;
-	else
-	{
-		os << vec->size() << endl;
-		for(int i = 0; i < (int)vec->size(); i++)
-		{
-			os << vec[i] << " ";
-		}
-	}
+    if( svec == NULL )
+        os << 0 << endl;
+    else
+    {
+        os << 1 << endl;
+        svec->store(os);
+    }
+
+    if(vec == NULL)
+        os << -1 << endl;
+    else
+    {
+        os << vec->size() << endl;
+        for(int i = 0; i < (int)vec->size(); i++)
+        {
+            os << vec[i] << " ";
+        }
+    }
 }
 
 void Examples::clean ()
 {
-	for ( iterator i = begin(); i != end(); i++ )
-	{
-		Example & example = i->second;
-		example.clean();
-	}
+    for ( iterator i = begin(); i != end(); i++ )
+    {
+        Example & example = i->second;
+        example.clean();
+    }
     clear();
 }
 
@@ -310,7 +311,7 @@ bool Examples::wrapExamplesAroundFeatureMatrix(const Matrix &p_MatFeaturesColumW
         return false;
     p_Examples.resize( t_iNumSamples );
     const double *pDataPtr = p_MatFeaturesColumWiseSamples.getDataPointer();
-    
+
 #ifdef NICE_USELIB_OPENMP
 #pragma omp parallel for default(none) shared(p_VecLabels, p_Examples, t_iNumFeatures, t_iNumSamples, pDataPtr)
 #endif

+ 1 - 1
cbaselib/Example.h

@@ -4,7 +4,7 @@
 /**
 * @file Example.h
 * @brief data caching of several feature images and many more
-* @author Erik Rodner
+* @author Erik Rodner, Johannes Ruehle, Sven Sickert
 * @date 04/21/2008
 */