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
134 {
return GeoTessProfileType::CONSTANT; };
140 {
return (GeoTessProfile::operator==(p) &&
150 virtual float getRadius(
int i)
const
151 {
return i == 0 ? radiusBottom : radiusTop; };
166 virtual float* getRadii()
167 {
float* fa =
new float [2]; fa[0] = radiusBottom; fa[1] = radiusTop;
return fa; };
188 virtual void setData(
const vector<GeoTessData*>& inData)
189 {
delete data; data = inData[0]; }
195 {
delete data; data = inData; }
205 virtual double getValue(
int attributeIndex,
int nodeIndex)
const
206 {
return nodeIndex <= 1 ? data->
getDouble(attributeIndex) : NaN_DOUBLE; }
218 int attributeIndex,
double radius,
bool allowRadiusOutOfRange)
const
220 if (!allowRadiusOutOfRange &&
221 ((radius < getRadiusBottom()) || (radius > getRadiusTop())))
230 return getValue(attributeIndex, 0);
239 virtual double getValueTop(
int attributeIndex)
const
240 {
return data->getDouble(attributeIndex); }
252 virtual bool isNaN(
int nodeIndex,
int attributeIndex)
254 return nodeIndex != 0 || data->isNaN(attributeIndex);
260 virtual void setRadii(
const vector<float>& newRadii)
261 { radiusBottom = newRadii[0]; radiusTop = newRadii[1]; }
263 virtual void setRadius(
int index,
float radius)
268 radiusBottom = radius;
313 data = GeoTessData::getData(ifs, gtmd); };
318 GeoTessProfileConstant(IFStreamAscii& ifs, GeoTessMetaData& gtmd) : GeoTessProfile()
319 { radiusBottom = ifs.readFloat();
320 radiusTop = ifs.readFloat();
321 data = GeoTessData::getData(ifs, gtmd); };
327 virtual ~GeoTessProfileConstant() {
if (data != NULL)
delete data; };
332 virtual void write(IFStreamBinary& ofs)
334 ofs.writeByte((
byte) GeoTessProfileType::CONSTANT.ordinal());
335 ofs.writeFloat(radiusBottom);
336 ofs.writeFloat(radiusTop);
343 virtual void write(IFStreamAscii& ofs)
344 { ofs.writeInt(GeoTessProfileType::CONSTANT.ordinal());
345 ofs.writeString(
" ");
346 ofs.writeFloat(radiusBottom);
347 ofs.writeString(
" ");
348 ofs.writeFloat(radiusTop);
361 virtual int findClosestRadiusIndex(
double radius)
const
362 {
return abs(radiusTop - radius) < abs(radiusBottom - radius) ? 1 : 0; }
371 virtual void setPointIndex(
int nodeIndex,
int pntIndex)
372 { pointIndex = pntIndex; }
381 virtual void resetPointIndices() { pointIndex = -1; }
390 virtual int getPointIndex(
int nodeIndex)
const
391 {
return pointIndex; }
396 virtual GeoTessProfile* copy()
398 return new GeoTessProfileConstant(radiusBottom, radiusTop, data->copy());
407 #endif // PROFILECONSTANT_OBJECT_H