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]; }
261 virtual void setRadius(
int index,
float radius)
266 radiusBottom = radius;
311 data = GeoTessData::getData(ifs, gtmd); };
316 GeoTessProfileConstant(IFStreamAscii& ifs, GeoTessMetaData& gtmd) : GeoTessProfile()
317 { radiusBottom = ifs.readFloat();
318 radiusTop = ifs.readFloat();
319 data = GeoTessData::getData(ifs, gtmd); };
325 virtual ~GeoTessProfileConstant() {
if (data != NULL)
delete data; };
330 virtual void write(IFStreamBinary& ofs)
332 ofs.writeByte((
byte) GeoTessProfileType::CONSTANT.ordinal());
333 ofs.writeFloat(radiusBottom);
334 ofs.writeFloat(radiusTop);
341 virtual void write(IFStreamAscii& ofs)
342 { ofs.writeInt(GeoTessProfileType::CONSTANT.ordinal());
343 ofs.writeString(
" ");
344 ofs.writeFloat(radiusBottom);
345 ofs.writeString(
" ");
346 ofs.writeFloat(radiusTop);
359 virtual int findClosestRadiusIndex(
double radius)
const
360 {
return abs(radiusTop - radius) < abs(radiusBottom - radius) ? 1 : 0; }
369 virtual void setPointIndex(
int nodeIndex,
int pntIndex)
370 { pointIndex = pntIndex; }
379 virtual void resetPointIndices() { pointIndex = -1; }
388 virtual int getPointIndex(
int nodeIndex)
const
389 {
return pointIndex; }
394 virtual GeoTessProfile* copy()
396 return new GeoTessProfileConstant(radiusBottom, radiusTop, data->copy());
405 #endif // PROFILECONSTANT_OBJECT_H