36 #ifndef PROFILECONSTANT_OBJECT_H
37 #define PROFILECONSTANT_OBJECT_H
62 class GeoTessMetaData;
104 data(NULL), pointIndex(-1) {};
112 Profile(), radiusBottom(radBot), radiusTop(radTop),
113 data(dat), pointIndex(-1) {};
123 virtual int class_size()
const
132 {
return ProfileType::CONSTANT; };
137 virtual bool operator == (
const Profile& p)
const
138 {
return (Profile::operator==(p) &&
148 virtual float getRadius(
int i)
const
149 {
return i == 0 ? radiusBottom : radiusTop; };
156 {
Data** da =
new Data* [1]; da[0] = data;
return da; };
171 virtual void setData(
const vector<Data*>& inData)
172 {
delete data; data = inData[0]; }
177 virtual void setData(
int index,
Data* inData)
178 {
delete data; data = inData; }
188 virtual double getValue(
int attributeIndex,
int nodeIndex)
const
190 return nodeIndex == 0 ? data->
getDouble(attributeIndex) : NaN_DOUBLE;
203 int attributeIndex,
double radius,
bool allowRadiusOutOfRange)
const
205 if (!allowRadiusOutOfRange &&
206 ((radius < getRadiusBottom()) || (radius > getRadiusTop())))
215 return getValue(attributeIndex, 0);
224 virtual double getValueTop(
int attributeIndex)
const
225 {
return data->getDouble(attributeIndex); }
237 virtual bool isNaN(
int nodeIndex,
int attributeIndex)
239 return nodeIndex != 0 || data->isNaN(attributeIndex);
245 virtual void setRadii(
const vector<float>& newRadii)
246 { radiusBottom = newRadii[0]; radiusTop = newRadii[1]; }
291 virtual float* getRadii()
292 {
float* fa =
new float [2]; fa[0] = radiusBottom;\
293 fa[1] = radiusTop;
return fa; };
302 data = Data::getData(ifs, gtmd); };
307 ProfileConstant(IFStreamAscii& ifs, GeoTessMetaData& gtmd) : Profile()
308 { radiusBottom = ifs.readFloat();
309 radiusTop = ifs.readFloat();
310 data = Data::getData(ifs, gtmd); };
316 virtual ~ProfileConstant() {
if (data != NULL)
delete data; };
321 virtual void write(IFStreamBinary& ofs)
323 ofs.writeByte((
byte) ProfileType::CONSTANT.ordinal());
324 ofs.writeFloat(radiusBottom);
325 ofs.writeFloat(radiusTop);
332 virtual void write(IFStreamAscii& ofs)
333 { ofs.writeInt(ProfileType::CONSTANT.ordinal());
334 ofs.writeString(
" ");
335 ofs.writeFloat(radiusBottom);
336 ofs.writeString(
" ");
337 ofs.writeFloat(radiusTop);
350 virtual int findClosestRadiusIndex(
double radius)
const
351 {
return abs(radiusTop - radius) < abs(radiusBottom - radius) ? 1 : 0; }
360 virtual void setPointIndex(
int nodeIndex,
int pntIndex)
361 { pointIndex = pntIndex; }
370 virtual void resetPointIndices() { pointIndex = -1; }
379 virtual int getPointIndex(
int nodeIndex)
const
380 {
return pointIndex; }
385 virtual Profile* copy()
387 return new ProfileConstant(radiusBottom, radiusTop, data->copy());
396 #endif // PROFILECONSTANT_OBJECT_H