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/ProfileEmpty.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 PROFILEEMPTY_OBJECT_H
00037 #define PROFILEEMPTY_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 "Profile.h"
00051 #include "ProfileType.h"
00052 #include "IFStreamAscii.h"
00053 #include "IFStreamBinary.h"
00054 
00055 // **** _BEGIN GEOTESS NAMESPACE_ **********************************************
00056 
00057 namespace geotess {
00058 
00059 // **** _FORWARD REFERENCES_ ***************************************************
00060 
00061 class Data;
00062 
00063 // **** _CLASS DEFINITION_ *****************************************************
00064 
00074 class GEOTESS_EXP_IMP ProfileEmpty : virtual public Profile
00075 {
00076   private:
00077 
00081                 float                                                                   radiusTop;
00082 
00086                 float                                   radiusBottom;
00087 
00091                                                                                                         ProfileEmpty() : Profile(), radiusTop(0.0), radiusBottom(0.0) {};
00092 
00093         public:
00094 
00098                                                                                                         ProfileEmpty(float radBot, float radTop) : Profile(),
00099                                                                                                                                                         radiusTop(radTop), radiusBottom(radBot)
00100                                                                                                         {}
00101 
00105                                                                                                         ProfileEmpty(IFStreamBinary& ifs) : Profile()
00106                                                                                                         { radiusBottom = ifs.readFloat();
00107                                                                                                                 radiusTop = ifs.readFloat();
00108                                                                                                         }
00109 
00113                                                                                                         ProfileEmpty(IFStreamAscii& ifs) : Profile()
00114                                                                                                         { radiusBottom = ifs.readFloat();
00115                                                                                                                 radiusTop = ifs.readFloat();
00116                                                                                                         }
00117 
00121                                                                                                         ProfileEmpty(float radii[], int &rIndex) : Profile()
00122                                                                                                         { radiusBottom = radii[rIndex++];
00123                                                                                                                 radiusTop = radii[rIndex++];
00124                                                                                                         }
00125 
00129                 virtual                                                         ~ProfileEmpty() {};
00130 
00134                 static  string                          class_name() { return "ProfileEmpty"; };
00135 
00139                 virtual int                                             class_size() const
00140                                                                                                         { return (int) sizeof(ProfileEmpty); };
00141 
00147                 virtual const ProfileType&               getType() const
00148                                                                                                         { return ProfileType::EMPTY; };
00149 
00153                 virtual bool                                    operator == (const Profile& p) const
00154                                                                                                         {       return (Profile::operator==(p) &&
00155                                                                                                                                                 (radiusBottom == p.getRadiusBottom()) &&
00156                                                                                                                                                 (radiusTop == p.getRadiusTop()));
00157                                                                                                         }
00158 
00163                 virtual double getValue(const InterpolatorType& rInterpType,
00164                         int attributeIndex, double radius,
00165                         bool allowRadiusOutOfRange) const;
00166 
00175                 virtual double getValue(int attributeIndex, int nodeIndex) const
00176                 { return NaN_DOUBLE; }
00177 
00188                 virtual bool isNaN(int nodeIndex, int attributeIndex)
00189                 {
00190                         return true;
00191                 }
00192 
00193                 // *** TODO added 7/20/2012
00200                 virtual double                    getValueTop(int attributeIndex) const
00201                 {
00202                         return NaN_DOUBLE;
00203                 }
00204 
00205                 // *** TODO added 7/20/2012
00212                 virtual double                    getValueBottom(int attributeIndex) const
00213                 {
00214                         return NaN_DOUBLE;
00215                 }
00216 
00221                 virtual float                                   getRadius(int i) const
00222                                                                                                         { return i == 0 ? radiusBottom : radiusTop; };
00223 
00227                 virtual int                                             getNRadii() const { return 2; };
00228 
00232                 virtual int                                             getNData() const { return 0; };
00233 
00237                 virtual float*                          getRadii()
00238                  { float* fa = new float [2]; fa[0] = radiusBottom; fa[1] = radiusTop; return fa; };
00239 
00244                 virtual Data**                          getData();
00245 
00249                 virtual Data*                                   getData(int i);
00250 
00254                 virtual const Data&             getData(int i) const;
00255 
00259                 virtual void                                    setData(const vector<Data*>& inData)
00260                                                                                                         {/* do nothing*/ };
00261 
00262                 // TODO: added by sb 9/27/2012
00266                 virtual void                                    setRadii(const vector<float>& newRadii)
00267                 { radiusBottom = newRadii[0]; radiusTop = newRadii[1]; }
00268 
00269                 // *** TODO added 7/19/2012
00273                 virtual void          setData(int index, Data* inData)
00274                                                                                                         { /* do nothing*/ };
00275 
00279                 virtual float                                   getRadiusTop() const { return radiusTop; };
00280 
00284                 virtual const Data&     getDataTop() const;
00285 
00289                 virtual Data*                                   getDataTop() { return NULL; }
00290 
00294                 virtual float                                   getRadiusBottom() const { return radiusBottom; };
00295 
00299                 virtual const Data&             getDataBottom() const;
00300 
00304                 virtual Data*                                   getDataBottom() { return NULL; }
00305 
00309                 virtual void                                    write(IFStreamBinary& ofs)
00310                                                                                                         { ofs.writeByte((byte) ProfileType::EMPTY.ordinal());
00311                                                                                                                 ofs.writeFloat(radiusBottom);
00312                                                                                                                 ofs.writeFloat(radiusTop); };
00313 
00317                 virtual void                                    write(IFStreamAscii& ofs)
00318                                                                                                         { ofs.writeInt(ProfileType::EMPTY.ordinal());
00319                                                                                                                 ofs.writeString(" ");
00320                                                                                                                 ofs.writeFloat(radiusBottom);
00321                                                                                                                 ofs.writeString(" ");
00322                                                                                                                 ofs.writeFloatNL(radiusTop); };
00323 
00324                 // *** TODO added 7/20/2012
00333                 virtual int                                             findClosestRadiusIndex(double radius) const
00334                 {       return abs(radiusTop - radius) < abs(radiusBottom - radius) ? 1 : 0; }
00335 
00336                 // *** TODO added 7/20/2012
00344                 virtual void                                    setPointIndex(int nodeIndex, int pointIndex)
00345                 {
00346                         // do nothing.  empty profiles have no data, hence pointIndex is always -1.
00347                 }
00348 
00349                 // *** TODO added 10/14/2012
00357                 virtual void resetPointIndices() { /* empty profiles have no data, hence pointIndex is always -1. */ }
00358 
00359                 // *** TODO added 7/20/2012
00367                 virtual int                                             getPointIndex(int nodeIndex) const
00368                                                                                                         { return -1; }
00369 
00370                 // *** TODO added 7/20/2012
00377           virtual void                                  getWeights(map<int, double>& weights,
00378                                                      double dkm, double radius, double hcoefficient) const
00379                 {
00380                         // do nothing.
00381                 }
00382 
00383                 // *** TODO added 7/26/2012
00387                 virtual void                                    getCoefficients(map<int, double>& coefficients, double radius,
00388                                                                   double horizontalCoefficient) const
00389                 {
00390                         // do nothing.
00391                 }
00392 
00393                 virtual void setInterpolationCoefficients(const InterpolatorType& interpType,
00394                                 vector<int>& nodeIndexes, vector<double>& coefficients,
00395                                 double& radius, bool& allowOutOfRange)
00396                 {
00397                         // POISON!
00398                         nodeIndexes.push_back(0);
00399                         coefficients.push_back(NaN_DOUBLE);
00400                 }
00401 
00402                 // *** TODO added 8/20/2012
00406                 virtual Profile*      copy()
00407                 {
00408                         return new ProfileEmpty(radiusBottom, radiusTop);
00409                 }
00410 
00412 
00414 
00415 }; // end class ProfileEmpty
00416 
00417 } // end namespace geotess
00418 
00419 #endif  // PROFILEEMPTY_OBJECT_H