38 #ifndef PROFILECONSTANT_OBJECT_H
39 #define PROFILECONSTANT_OBJECT_H
64 class GeoTessMetaData;
106 data(NULL), pointIndex(-1) {};
115 data(dat), pointIndex(-1) {};
136 {
return GeoTessProfileType::CONSTANT; };
142 {
return (GeoTessProfile::operator==(p) &&
153 {
return i == 0 ? radiusBottom : radiusTop; };
169 {
float* fa =
new float [2]; fa[0] = radiusBottom; fa[1] = radiusTop;
return fa; };
190 virtual void setData(
const vector<GeoTessData*>& inData)
191 {
delete data; data = inData[0]; }
197 {
delete data; data = inData; }
207 virtual double getValue(
int attributeIndex,
int nodeIndex)
const
208 {
return nodeIndex <= 1 ? data->
getDouble(attributeIndex) : NaN_DOUBLE; }
220 int attributeIndex,
double radius,
bool allowRadiusOutOfRange)
const
222 if (!allowRadiusOutOfRange &&
223 ((radius < getRadiusBottom()) || (radius > getRadiusTop())))
232 return getValue(attributeIndex, 0);
242 {
return data->
getDouble(attributeIndex); }
254 virtual bool isNaN(
int nodeIndex,
int attributeIndex)
256 return nodeIndex != 0 || data->
isNaN(attributeIndex);
262 virtual void setRadii(
const vector<float>& newRadii)
263 { radiusBottom = newRadii[0]; radiusTop = newRadii[1]; }
270 radiusBottom = radius;
315 data = GeoTessData::getData(ifs, gtmd); };
320 GeoTessProfileConstant(IFStreamAscii& ifs, GeoTessMetaData& gtmd) : GeoTessProfile()
321 { radiusBottom = ifs.readFloat();
322 radiusTop = ifs.readFloat();
323 data = GeoTessData::getData(ifs, gtmd); };
329 virtual ~GeoTessProfileConstant() {
if (data != NULL)
delete data; };
334 virtual void write(IFStreamBinary& ofs)
336 ofs.writeByte((
byte) GeoTessProfileType::CONSTANT.ordinal());
337 ofs.writeFloat(radiusBottom);
338 ofs.writeFloat(radiusTop);
345 virtual void write(IFStreamAscii& ofs)
346 { ofs.writeInt(GeoTessProfileType::CONSTANT.ordinal());
347 ofs.writeString(
" ");
348 ofs.writeFloat(radiusBottom);
349 ofs.writeString(
" ");
350 ofs.writeFloat(radiusTop);
363 virtual int findClosestRadiusIndex(
double radius)
const
364 {
return abs(radiusTop - radius) < abs(radiusBottom - radius) ? 1 : 0; }
373 virtual void setPointIndex(
int nodeIndex,
int pntIndex)
374 { pointIndex = pntIndex; }
383 virtual void resetPointIndices() { pointIndex = -1; }
392 virtual int getPointIndex(
int nodeIndex)
const
393 {
return pointIndex; }
398 virtual GeoTessProfile* copy()
400 return new GeoTessProfileConstant(radiusBottom, radiusTop, data->copy());
409 #endif // PROFILECONSTANT_OBJECT_H