GeoTessCPP  2.0.0
Software to facilitate storage and retrieval of 3D information about the Earth.
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines
include/ProfileSurface.h
Go to the documentation of this file.
00001 //- ****************************************************************************
00002 //- 
00003 //- Copyright 2009 Sandia Corporation. Under the terms of Contract
00004 //- DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
00005 //- retains certain rights in this software.
00006 //- 
00007 //- BSD Open Source License.
00008 //- All rights reserved.
00009 //- 
00010 //- Redistribution and use in source and binary forms, with or without
00011 //- modification, are permitted provided that the following conditions are met:
00012 //- 
00013 //-    * Redistributions of source code must retain the above copyright notice,
00014 //-      this list of conditions and the following disclaimer.
00015 //-    * Redistributions in binary form must reproduce the above copyright
00016 //-      notice, this list of conditions and the following disclaimer in the
00017 //-      documentation and/or other materials provided with the distribution.
00018 //-    * Neither the name of Sandia National Laboratories nor the names of its
00019 //-      contributors may be used to endorse or promote products derived from
00020 //-      this software without specific prior written permission.
00021 //- 
00022 //- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00023 //- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024 //- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00025 //- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00026 //- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00027 //- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00028 //- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00029 //- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00030 //- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00031 //- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032 //- POSSIBILITY OF SUCH DAMAGE.
00033 //-
00034 //- ****************************************************************************
00035 
00036 #ifndef PROFILESURFACE_OBJECT_H
00037 #define PROFILESURFACE_OBJECT_H
00038 
00039 // **** _SYSTEM INCLUDES_ ******************************************************
00040 
00041 #include <iostream>
00042 #include <string>
00043 #include <fstream>
00044 
00045 // use standard library objects
00046 using namespace std;
00047 
00048 // **** _LOCAL INCLUDES_ *******************************************************
00049 
00050 #include "GeoTessUtils.h"
00051 #include "Data.h"
00052 #include "Profile.h"
00053 #include "ProfileType.h"
00054 #include "IFStreamAscii.h"
00055 #include "IFStreamBinary.h"
00056 
00057 // **** _BEGIN GEOTESS NAMESPACE_ **********************************************
00058 
00059 namespace geotess {
00060 
00061 // **** _FORWARD REFERENCES_ ***************************************************
00062 
00063 class GeoTessMetaData;
00064 
00065 // **** _CLASS DEFINITION_ *****************************************************
00066 
00076 class GEOTESS_EXP_IMP ProfileSurface: virtual public Profile
00077 {
00078   private:
00079 
00083                 Data*                                   data;
00084 
00088                 int                                                                                     pointIndex;
00089 
00093                                                                                                                 ProfileSurface() : Profile(), data(NULL),
00094                                                                                                                                                                                          pointIndex(-1) {};
00095 
00096         public:
00097 
00101                                                                                                                 ProfileSurface(Data* dat) : Profile(), data(dat),
00102                                                                                                                                                                                                                                 pointIndex(-1) {};
00103 
00107                 static  string                                  class_name() { return "ProfileSurface"; };
00108 
00112                 virtual int                                                     class_size() const
00113                                                                                                                 { return (int) sizeof(ProfileSurface); };
00114 
00120                 virtual const ProfileType&      getType() const
00121                                                                                                                 { return ProfileType::SURFACE; };
00122 
00126                 virtual bool                                            operator == (const Profile& p) const
00127                                                                                                                 {       return (Profile::operator==(p) &&
00128                                                                                                                                 (*data == p.getData(0)));
00129                                                                                                                 }
00130 
00139                 virtual double getValue(int attributeIndex, int nodeIndex) const
00140                 {
00141                         return nodeIndex == 0 ? data->getDouble(attributeIndex) : NaN_DOUBLE;
00142                 }
00143 
00150                 virtual double getValueTop(int attributeIndex) const
00151                 {       return data->getDouble(attributeIndex); }
00152 
00163                 virtual bool isNaN(int nodeIndex, int attributeIndex)
00164                 {
00165                         return nodeIndex != 0 || data->isNaN(attributeIndex);
00166                 }
00167 
00172                 virtual double                                  getValue(const InterpolatorType& rInterpType,
00173                                                                                                                                                  int attributeIndex, double radius,
00174                                                                                                                                                  bool allowRadiusOutOfRange) const
00175                 {
00176                         return getData(0).getDouble(attributeIndex);
00177                 }
00178 
00183                 virtual float                                           getRadius(int i) const
00184                                                                                                                 { return NaN_FLOAT; };
00185 
00189                 virtual int                                                     getNRadii() const { return 0; };
00190 
00194                 virtual int                                                     getNData() const { return 1; };
00195 
00199                 virtual float*                                  getRadii() { return NULL; };
00200 
00204                 virtual Data**                                  getData()
00205                 { Data** da = new Data* [1]; da[0] = data; return da; };
00206 
00210                 virtual Data*                                           getData(int i) { return data; };
00211 
00215                 virtual const Data&                     getData(int i) const { return *data; };
00216 
00220                 virtual void                                            setData(const vector<Data*>& inData)
00221                                                                                                                 { delete data; data = inData[0]; }
00222 
00226                 virtual void              setData(int index, Data* inData)
00227                                                                                                                 { delete data; data = inData; }
00228 
00229                 // TODO: added by sb 9/27/2012
00233                 virtual void                                    setRadii(const vector<float>& newRadii)
00234                 { /* do nothing */ };
00235 
00239                 virtual float                                           getRadiusTop() const
00240                                                                                                                 { return NaN_FLOAT; };
00241 
00245                 virtual const Data&                     getDataTop() const { return *data; };
00246 
00250                 virtual Data*                                           getDataTop() { return data; };
00251 
00255                 virtual float                                           getRadiusBottom() const
00256                                                                                                                 { return NaN_FLOAT; };
00257 
00261                 virtual const Data&                     getDataBottom() const { return *data; };
00262 
00266                 virtual Data*                                           getDataBottom() { return data; };
00267 
00269 
00273                                                                                                                 ProfileSurface(IFStreamBinary& ifs, GeoTessMetaData& gtmd) : Profile(),
00274                                                                                                                                                                          data(NULL), pointIndex(-1)
00275                                                                                                                 { data = Data::getData(ifs, gtmd); };
00276 
00280                                                                                                                 ProfileSurface(IFStreamAscii& ifs, GeoTessMetaData& gtmd) : Profile(),
00281                                                                                                                                                                          data(NULL), pointIndex(-1)
00282                                                                                                                 { data = Data::getData(ifs, gtmd); };
00283 
00288                 virtual                                                                 ~ProfileSurface() { if (data != NULL) delete data; };
00289 
00293                 virtual void                                            write(IFStreamBinary& ofs)
00294                                                                                                                 { ofs.writeByte((byte) ProfileType::SURFACE.ordinal());
00295                                                                                                                         data->write(ofs); };
00296 
00300                 virtual void                                            write(IFStreamAscii& ofs)
00301                                                                                                                 { ofs.writeInt(ProfileType::SURFACE.ordinal());
00302                                                                                                                         data->write(ofs);
00303                                                                                                                         ofs.writeNL(); };
00304 
00305                 // *** TODO added 7/20/2012
00314                 virtual int                                                     findClosestRadiusIndex(double radius) const
00315                                                                                                                 {       return -1; }
00316 
00317                 // *** TODO added 7/20/2012
00325                 virtual void                                            setPointIndex(int nodeIndex, int pntIndex)
00326                                                                                                                 {       pointIndex = pntIndex; }
00327 
00328                 // *** TODO added 10/14/2012
00336                 virtual void resetPointIndices() { pointIndex = -1; }
00337 
00338                 // *** TODO added 7/20/2012
00346                 virtual int                                                     getPointIndex(int nodeIndex) const
00347                                                                                                                 {       return pointIndex; }
00348 
00349                 // *** TODO added 8/20/2012
00353                 virtual Profile*      copy()
00354                 {
00355                         return new ProfileSurface(data->copy());
00356                 }
00357 
00359 
00360 }; // end class ProfileSurface
00361 
00362 } // end namespace geotess
00363 
00364 #endif  // PROFILESURFACE_OBJECT_H