36 #ifndef PROFILECONSTANT_OBJECT_H
37 #define PROFILECONSTANT_OBJECT_H
62 class GeoTessMetaData;
104 data(NULL), pointIndex(-1) {};
113 data(dat), pointIndex(-1) {};
123 virtual int class_size()
const
132 {
return GeoTessProfileType::CONSTANT; };
138 {
return (GeoTessProfile::operator==(p) &&
148 virtual float getRadius(
int i)
const
149 {
return i == 0 ? radiusBottom : radiusTop; };
164 virtual float* getRadii()
165 {
float* fa =
new float [2]; fa[0] = radiusBottom; fa[1] = radiusTop;
return fa; };
186 virtual void setData(
const vector<GeoTessData*>& inData)
187 {
delete data; data = inData[0]; }
193 {
delete data; data = inData; }
203 virtual double getValue(
int attributeIndex,
int nodeIndex)
const
204 {
return nodeIndex <= 1 ? data->
getDouble(attributeIndex) : NaN_DOUBLE; }
216 int attributeIndex,
double radius,
bool allowRadiusOutOfRange)
const
218 if (!allowRadiusOutOfRange &&
219 ((radius < getRadiusBottom()) || (radius > getRadiusTop())))
228 return getValue(attributeIndex, 0);
237 virtual double getValueTop(
int attributeIndex)
const
238 {
return data->getDouble(attributeIndex); }
250 virtual bool isNaN(
int nodeIndex,
int attributeIndex)
252 return nodeIndex != 0 || data->isNaN(attributeIndex);
258 virtual void setRadii(
const vector<float>& newRadii)
259 { radiusBottom = newRadii[0]; radiusTop = newRadii[1]; }
298 data = GeoTessData::getData(ifs, gtmd); };
303 GeoTessProfileConstant(IFStreamAscii& ifs, GeoTessMetaData& gtmd) : GeoTessProfile()
304 { radiusBottom = ifs.readFloat();
305 radiusTop = ifs.readFloat();
306 data = GeoTessData::getData(ifs, gtmd); };
312 virtual ~GeoTessProfileConstant() {
if (data != NULL)
delete data; };
317 virtual void write(IFStreamBinary& ofs)
319 ofs.writeByte((
byte) GeoTessProfileType::CONSTANT.ordinal());
320 ofs.writeFloat(radiusBottom);
321 ofs.writeFloat(radiusTop);
328 virtual void write(IFStreamAscii& ofs)
329 { ofs.writeInt(GeoTessProfileType::CONSTANT.ordinal());
330 ofs.writeString(
" ");
331 ofs.writeFloat(radiusBottom);
332 ofs.writeString(
" ");
333 ofs.writeFloat(radiusTop);
346 virtual int findClosestRadiusIndex(
double radius)
const
347 {
return abs(radiusTop - radius) < abs(radiusBottom - radius) ? 1 : 0; }
356 virtual void setPointIndex(
int nodeIndex,
int pntIndex)
357 { pointIndex = pntIndex; }
366 virtual void resetPointIndices() { pointIndex = -1; }
375 virtual int getPointIndex(
int nodeIndex)
const
376 {
return pointIndex; }
381 virtual GeoTessProfile* copy()
383 return new GeoTessProfileConstant(radiusBottom, radiusTop, data->copy());
392 #endif // PROFILECONSTANT_OBJECT_H