36 #ifndef DATAARRAY_OBJECT_H
37 #define DATAARRAY_OBJECT_H
89 GeoTessDataArray() : GeoTessData(), nValues(0), values(NULL) {};
99 values =
new T [nValues];
100 for (
int i = 0; i < nValues; ++i) values[i] = v[i];
109 values =
new T [nValues];
110 for (
int i = 0; i < nValues; ++i) values[i] = v[i];
118 values =
new T [nValues];
119 for (
int i = 0; i < n; ++i) values[i] = (T) 0;
132 values =
new T [nValues];
133 for (
int i = 0; i < nValues; ++i) ifs.
readType(values[i]);
141 GeoTessDataArray(IFStreamBinary& ifs,
int n) : GeoTessData(), nValues(n), values(NULL)
145 values =
new T [nValues];
146 ifs.readTypeArray(values, nValues);
159 GeoTessDataArray(IFStreamAscii& ifs,
int n, vector<int>& filter) : GeoTessData(), nValues(n), values(NULL)
163 values =
new T [nValues];
165 for (
int i=0; i<(int)filter.size(); ++i)
169 values[filter[i]] = val;
183 GeoTessDataArray(IFStreamBinary& ifs,
int n, vector<int>& filter) : GeoTessData(), nValues(n), values(NULL)
187 values =
new T [nValues];
190 for (
int i=0; i<(int)filter.size(); ++i)
194 values[filter[i]] = val;
202 virtual ~GeoTessDataArray()
203 {
if (values != NULL)
delete [] values; };
208 virtual void write(IFStreamBinary& ofs)
210 for (
int i = 0; i < nValues; ++i) ofs.writeType(values[i]);
216 virtual void write(IFStreamAscii& ofs)
218 for (
int i = 0; i < nValues; ++i)
219 { ofs.writeString(
" "); ofs.writeType(values[i]); }
232 virtual int size()
const {
return nValues; };
243 if (!GeoTessData::operator==(d))
return false;
244 if (nValues != d.nValues)
return false;
246 for (
int i = 0; i < nValues; ++i)
247 if ((values[i] != d.values[i]) &&
248 !(isNaN(i) && d.
isNaN(i)))
return false;
264 {
return (
double) values[attributeIndex]; }
270 {
return (
float) values[attributeIndex]; };
276 {
return (
LONG_INT) values[attributeIndex]; };
281 virtual int getInt(
int attributeIndex)
const
282 {
return (
int) values[attributeIndex]; };
288 {
return (
short) values[attributeIndex]; };
294 {
return (
byte) values[attributeIndex]; };
299 virtual void getValue(
int attributeIndex,
double& val)
const
300 { val = (double) values[attributeIndex]; };
305 virtual void getValue(
int attributeIndex,
float& val)
const
306 { val = (float) values[attributeIndex]; };
312 { val = (
LONG_INT) values[attributeIndex]; };
317 virtual void getValue(
int attributeIndex,
int& val)
const
318 { val = (int) values[attributeIndex]; };
323 virtual void getValue(
int attributeIndex,
short& val)
const
324 { val = (short) values[attributeIndex]; };
330 { val = (
byte) values[attributeIndex]; };
336 {
for (
int i=0; i<n && i<nValues; ++i) vals[i] = (
double) values[i]; }
342 {
for (
int i=0; i<n && i<nValues; ++i) vals[i] = (
float) values[i]; }
348 {
for (
int i=0; i<n && i<nValues; ++i) vals[i] = (
LONG_INT) values[i]; }
354 {
for (
int i=0; i<n && i<nValues; ++i) vals[i] = (
int) values[i]; }
360 {
for (
int i=0; i<n && i<nValues; ++i) vals[i] = (
short) values[i]; }
366 {
for (
int i=0; i<n && i<nValues; ++i) vals[i] = (
byte) values[i]; }
372 { values[attributeIndex] = (T) v;
return *
this; }
378 { values[attributeIndex] = (T) v;
return *
this; }
384 { values[attributeIndex] = (T) v;
return *
this; }
390 { values[attributeIndex] = (T) v;
return *
this; }
396 { values[attributeIndex] = (T) v;
return *
this; };
402 { values[attributeIndex] = (T) v;
return *
this; }
415 virtual bool isNaN(
int attributeIndex)
const {
return false;};
433 inline bool GeoTessDataArray<double>::isNaN(
int attributeIndex)
const
435 return (isnan(values[attributeIndex]));
442 inline bool GeoTessDataArray<float>::isNaN(
int attributeIndex)
const
444 double v = (double) values[attributeIndex];
452 inline const GeoTessDataType& GeoTessDataArray<double>::getDataType()
const
454 return GeoTessDataType::DOUBLE;
461 inline const GeoTessDataType& GeoTessDataArray<float>::getDataType()
const
463 return GeoTessDataType::FLOAT;
470 inline const GeoTessDataType& GeoTessDataArray<LONG_INT>::getDataType()
const
472 return GeoTessDataType::LONG;
479 inline const GeoTessDataType& GeoTessDataArray<int>::getDataType()
const
481 return GeoTessDataType::INT;
488 inline const GeoTessDataType& GeoTessDataArray<short>::getDataType()
const
490 return GeoTessDataType::SHORT;
497 inline const GeoTessDataType& GeoTessDataArray<byte>::getDataType()
const
499 return GeoTessDataType::BYTE;
506 #endif // DATAARRAY_OBJECT_H
virtual const GeoTessDataType & getDataType() const
Retrieve the DataType of this Data object.
Definition: GeoTessDataArray.h:227
bool readType(byte &b)
Read the next byte.
Definition: IFStreamAscii.h:400
virtual GeoTessData & setValue(int attributeIndex, float v)
Set the value at the input attribute index to the input value.
Definition: GeoTessDataArray.h:377
GeoTessDataArray(T v[], const int &n)
Standard constructor.
Definition: GeoTessDataArray.h:97
virtual GeoTessData & setValue(int attributeIndex, double v)
Set the value at the input attribute index to the input value.
Definition: GeoTessDataArray.h:371
virtual int size() const
Returns the number of entries in the array of values.
Definition: GeoTessDataArray.h:232
virtual GeoTessData & setValue(int attributeIndex, byte v)
Set the value at the input attribute index to the input value.
Definition: GeoTessDataArray.h:401
virtual double getDouble(int attributeIndex) const
Returns value defined for the input attribute index as a double.
Definition: GeoTessDataArray.h:263
GeoTessDataArray(const int &n)
Standard constructor.
Definition: GeoTessDataArray.h:116
virtual void getValues(short vals[], const int &n)
Copy the first n values into the supplied array as a short value.
Definition: GeoTessDataArray.h:359
Definition: ArrayReuse.h:55
GeoTessDataArray(const vector< T > &v)
Standard constructor.
Definition: GeoTessDataArray.h:107
virtual void getValues(double vals[], const int &n)
Copy the first n values into the supplied array as a double value.
Definition: GeoTessDataArray.h:335
virtual void getValue(int attributeIndex, byte &val) const
Returns the attribute at the input attribute index as a byte value.
Definition: GeoTessDataArray.h:329
virtual byte getByte(int attributeIndex) const
Returns value defined for the input attribute index as a byte.
Definition: GeoTessDataArray.h:293
virtual GeoTessData & setValue(int attributeIndex, LONG_INT v)
Set the value at the input attribute index to the input value.
Definition: GeoTessDataArray.h:383
virtual void getValue(int attributeIndex, LONG_INT &val) const
Returns the attribute at the input attribute index as a long value.
Definition: GeoTessDataArray.h:311
Enumeration of supported DataType including DOUBLE, FLOAT, LONG, INT, SHORT and BYTE.
Definition: GeoTessDataType.h:67
virtual void getValues(int vals[], const int &n)
Copy the first n values into the supplied array as an int value.
Definition: GeoTessDataArray.h:353
virtual GeoTessData & setValue(int attributeIndex, int v)
Set the value at the input attribute index to the input value.
Definition: GeoTessDataArray.h:389
virtual LONG_INT getLong(int attributeIndex) const
Returns value defined for the input attribute index as a long.
Definition: GeoTessDataArray.h:275
virtual void getValues(byte vals[], const int &n)
Copy the first n values into the supplied array as a byte value.
Definition: GeoTessDataArray.h:365
#define byte
signed-byte typedef
Definition: CPPGlobals.h:94
Opens ascii file for read and write access.
Definition: IFStreamAscii.h:80
virtual int getInt(int attributeIndex) const
Returns value defined for the input attribute index as an int.
Definition: GeoTessDataArray.h:281
virtual void getValue(int attributeIndex, int &val) const
Returns the attribute at the input attribute index as a int value.
Definition: GeoTessDataArray.h:317
#define LONG_INT
Definition: CPPGlobals.h:111
virtual GeoTessDataArray< T > * copy()
Returns a deep copy of this DataArray object.
Definition: GeoTessDataArray.h:420
Manages a 1D array of data values attached to a single grid node.
Definition: GeoTessData.h:62
virtual float getFloat(int attributeIndex) const
Returns value defined for the input attribute index as a float.
Definition: GeoTessDataArray.h:269
Abstract base class that manages the data values attached to a single grid point. ...
Definition: GeoTessData.h:75
virtual short getShort(int attributeIndex) const
Returns value defined for the input attribute index as a short.
Definition: GeoTessDataArray.h:287
virtual GeoTessData & setValue(int attributeIndex, short v)
Set the value at the input attribute index to the input value.
Definition: GeoTessDataArray.h:395
virtual void getValue(int attributeIndex, short &val) const
Returns the attribute at the input attribute index as a short value.
Definition: GeoTessDataArray.h:323
virtual LONG_INT getMemory()
Definition: GeoTessDataArray.h:234
virtual void getValue(int attributeIndex, double &val) const
Returns the attribute at the input attribute index as a double value.
Definition: GeoTessDataArray.h:299
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:71
virtual bool isNaN(int attributeIndex) const
Returns true if the specified attribute is NaN.
Definition: GeoTessDataArray.h:415
virtual void getValue(int attributeIndex, float &val) const
Returns the attribute at the input attribute index as a float value.
Definition: GeoTessDataArray.h:305
virtual void getValues(float vals[], const int &n)
Copy the first n values into the supplied array as a float value.
Definition: GeoTessDataArray.h:341
virtual void getValues(LONG_INT vals[], const int &n)
Copy the first n values into the supplied array as a LONG_INT value.
Definition: GeoTessDataArray.h:347