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.5 2000/06/19 19:04:05 kevin Exp $
13 ** $Log: array2d.h,v $
14 ** Revision 1.5 2000/06/19 19:04:05 kevin
15 ** reorganized header files
17 ** Revision 1.4 2000/06/09 11:03:08 kevin
18 ** Made ImageFile inherit from Array2dFile
20 ** Revision 1.3 2000/06/09 01:35:33 kevin
21 ** Convert MPI structure to C++ class
24 ** This program is free software; you can redistribute it and/or modify
25 ** it under the terms of the GNU General Public License (version 2) as
26 ** published by the Free Software Foundation.
28 ** This program is distributed in the hope that it will be useful,
29 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
30 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 ** GNU General Public License for more details.
33 ** You should have received a copy of the GNU General Public License
34 ** along with this program; if not, write to the Free Software
35 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 ******************************************************************************/
41 #include "ctsupport.h"
47 Array2d (unsigned int x, unsigned int y)
48 : nx(x), ny(y), array_data(0)
54 : array_data(0), nx(0), ny(0)
62 void initSetSize (unsigned int x, unsigned int y)
70 T** getArray (void) const
71 { return array_data; }
73 T* getColumn (unsigned int x) const
74 { return (array_data ? array_data[x] : NULL); }
76 T getPoint (unsigned int x, unsigned int y) const
77 { return (array_data ? array_data[x][y] : NULL); }
79 unsigned int sizeofPixel (void) const
82 unsigned int sizeofColumn (void) const
83 { return (sizeof(T) * ny); }
85 unsigned int sizeofArray (void) const
86 { return (sizeof(T) * nx * ny); }
94 void allocArray (void)
96 array_data = new T*[nx];
98 for (unsigned int i = 0; i < nx; i++)
99 array_data[i] = new T[ny];
102 void deleteArray (void)
105 for (int i = 0; i < nx; i++)
106 delete array_data[i];
112 Array2d& operator= (const Array2d& rhs);
113 Array2d (const Array2d& rhs); // copy constructor