Wm4System.inl

Go to the documentation of this file.
00001 // Wild Magic Source Code
00002 // David Eberly
00003 // http://www.geometrictools.com
00004 // Copyright (c) 1998-2007
00005 //
00006 // This library is free software; you can redistribute it and/or modify it
00007 // under the terms of the GNU Lesser General Public License as published by
00008 // the Free Software Foundation; either version 2.1 of the License, or (at
00009 // your option) any later version.  The license is available for reading at
00010 // either of the locations:
00011 //     http://www.gnu.org/copyleft/lgpl.html
00012 //     http://www.geometrictools.com/License/WildMagicLicense.pdf
00013 // The license applies to versions 0 through 4 of Wild Magic.
00014 //
00015 // Version: 4.0.0 (2006/06/28)
00016 
00017 namespace Wm4
00018 {
00019 //----------------------------------------------------------------------------
00021 template <class T>
00022 void Allocate (int iCols, int iRows, T**& raatArray)
00023 {
00024     raatArray = WM4_NEW T*[iRows];
00025     raatArray[0] = WM4_NEW T[iRows*iCols];
00026     for (int iRow = 1; iRow < iRows; iRow++)
00027     {
00028         raatArray[iRow] = &raatArray[0][iCols*iRow];
00029     }
00030 }
00031 //----------------------------------------------------------------------------
00032 template <class T>
00033 void Deallocate (T**& raatArray)
00034 {
00035     if (raatArray)
00036     {
00037         WM4_DELETE[] raatArray[0];
00038         WM4_DELETE[] raatArray;
00039         raatArray = 0;
00040     }
00041 }
00042 //----------------------------------------------------------------------------
00043 template <class T>
00044 void Allocate (int iCols, int iRows, int iSlices, T***& raaatArray)
00045 {
00046     raaatArray = WM4_NEW T**[iSlices];
00047     raaatArray[0] = WM4_NEW T*[iSlices*iRows];
00048     raaatArray[0][0] = WM4_NEW T[iSlices*iRows*iCols];
00049     for (int iSlice = 0; iSlice < iSlices; iSlice++)
00050     {
00051         raaatArray[iSlice] = &raaatArray[0][iRows*iSlice];
00052         for (int iRow = 0; iRow < iRows; iRow++)
00053         {
00054             raaatArray[iSlice][iRow] =
00055                 &raaatArray[0][0][iCols*(iRow+iRows*iSlice)];
00056         }
00057     }
00058 }
00059 //----------------------------------------------------------------------------
00060 template <class T>
00061 void Deallocate (T***& raaatArray)
00062 {
00063     if (raaatArray)
00064     {
00065         WM4_DELETE[] raaatArray[0][0];
00066         WM4_DELETE[] raaatArray[0];
00067         WM4_DELETE[] raaatArray;
00068         raaatArray = 0;
00069     }
00070 }
00072 //----------------------------------------------------------------------------
00073 } //namespace Wm4

Generated on Wed Nov 23 19:01:08 2011 for FreeCAD by  doxygen 1.6.1