Commit 4f02c199 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Implementing the mesh initializer.

parent d631606a
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -87,6 +87,8 @@ class tnlStaticArray

   bool load( tnlFile& file);

   void sort();

   protected:
   Element data[ Size ];

@@ -166,6 +168,8 @@ class tnlStaticArray< 1, Element >

   bool load( tnlFile& file);

   void sort();

   protected:
   Element data[ size ];
};
@@ -261,6 +265,8 @@ class tnlStaticArray< 2, Element >

   bool load( tnlFile& file);

   void sort();

   protected:
   Element data[ size ];
};
@@ -368,6 +374,8 @@ class tnlStaticArray< 3, Element >

   bool load( tnlFile& file);

   void sort();

   protected:
   Element data[ size ];

+5 −0
Original line number Diff line number Diff line
@@ -169,6 +169,11 @@ bool tnlStaticArray< 1, Element >::load( tnlFile& file)
   return true;
}

template< typename Element >
void tnlStaticArray< 1, Element >::sort()
{
}

#ifdef TEMPLATE_EXPLICIT_INSTANTIATION

extern template class tnlStaticArray< 1, char >;
+7 −0
Original line number Diff line number Diff line
@@ -204,6 +204,13 @@ bool tnlStaticArray< 2, Element >::load( tnlFile& file)
   return true;
}

template< typename Element >
void tnlStaticArray< 2, Element >::sort()
{
   if( data[ 0 ] > data[ 1 ] )
      Swap( data[ 0 ], data[ 1 ] );
}

#ifdef TEMPLATE_EXPLICIT_INSTANTIATION

extern template class tnlStaticArray< 2, char >;
+14 −0
Original line number Diff line number Diff line
@@ -228,6 +228,20 @@ bool tnlStaticArray< 3, Element >::load( tnlFile& file)
   return true;
}

template< typename Element >
void tnlStaticArray< 3, Element >::sort()
{
   /****
    * Bubble sort on three elements
    */
   if( data[ 0 ] > data[ 1 ] )
      Swap( data[ 0 ], data[ 1 ] );
   if( data[ 1 ] > data[ 2 ] )
      Swap( data[ 1 ], data[2  ] );
   if( data[ 0 ] > data[ 1 ] )
      Swap( data[ 0 ], data[ 1 ] );
}

#ifdef TEMPLATE_EXPLICIT_INSTANTIATION

extern template class tnlStaticArray< 3, char >;
+14 −0
Original line number Diff line number Diff line
@@ -161,6 +161,20 @@ bool tnlStaticArray< Size, Element >::load( tnlFile& file)
   return true;
}

template< int Size, typename Element >
void tnlStaticArray< Size, Element >::sort()
{
   /****
    * We assume that the array data is small and so
    * may sort it with the bubble sort.
    */
   for( int k = Size - 1; k > 0; k--)
      for( int i = 0; i < k; i++ )
         if( data[ i ] > data[ i+1 ] )
            Swap( data[ i ], data[ i+1 ] );
}


template< int Size, typename Element >
ostream& operator << ( ostream& str, const tnlStaticArray< Size, Element >& a )
{
Loading