1 /*****************************************************************************
5 ** Purpose: 2-dimension array classes
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: June 2000
9 ** This is part of the CTSim program
10 ** Copyright (C) 1983-2000 Kevin Rosenberg
12 ** $Id: array2d.h,v 1.4 2000/06/09 11:03:08 kevin Exp $
13 ** $Log: array2d.h,v $
14 ** Revision 1.4 2000/06/09 11:03:08 kevin
15 ** Made ImageFile inherit from Array2dFile
17 ** Revision 1.3 2000/06/09 01:35:33 kevin
18 ** Convert MPI structure to C++ class
21 ** This program is free software; you can redistribute it and/or modify
22 ** it under the terms of the GNU General Public License (version 2) as
23 ** published by the Free Software Foundation.
25 ** This program is distributed in the hope that it will be useful,
26 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
27 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 ** GNU General Public License for more details.
30 ** You should have received a copy of the GNU General Public License
31 ** along with this program; if not, write to the Free Software
32 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 ******************************************************************************/
43 Array2d (unsigned int x, unsigned int y)
44 : nx(x), ny(y), array_data(0)
50 : array_data(0), nx(0), ny(0)
58 void initSetSize (unsigned int x, unsigned int y)
66 T** getArray (void) const
67 { return array_data; }
69 T* getColumn (unsigned int x) const
70 { return (array_data ? array_data[x] : NULL); }
72 T getPoint (unsigned int x, unsigned int y) const
73 { return (array_data ? array_data[x][y] : NULL); }
75 unsigned int sizeofPixel (void) const
78 unsigned int sizeofColumn (void) const
79 { return (sizeof(T) * ny); }
81 unsigned int sizeofArray (void) const
82 { return (sizeof(T) * nx * ny); }
90 void allocArray (void)
92 array_data = new T*[nx];
94 for (unsigned int i = 0; i < nx; i++)
95 array_data[i] = new T[ny];
98 void deleteArray (void)
101 for (int i = 0; i < nx; i++)
102 delete array_data[i];
108 Array2d& operator= (const Array2d& rhs);
109 Array2d (const Array2d& rhs); // copy constructor