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/HorizonRadius.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 HORIZONRADIUS_H_
00037 #define HORIZONRADIUS_H_
00038 
00039 // **** _SYSTEM INCLUDES_ ******************************************************
00040 
00041 #include <iostream>
00042 #include <fstream>
00043 #include <string>
00044 #include <climits>
00045 
00046 // use standard library objects
00047 using namespace std;
00048 
00049 // **** _LOCAL INCLUDES_ *******************************************************
00050 
00051 #include "Horizon.h"
00052 #include "Profile.h"
00053 #include "GeoTessPosition.h"
00054 
00055 // **** _BEGIN GEOTESS NAMESPACE_ *********************************************
00056 
00057 namespace geotess {
00058 
00059 // **** _FORWARD REFERENCES_ ***************************************************
00060 
00061 // **** _CLASS DEFINITION_ *****************************************************
00062 
00071 class GEOTESS_EXP_IMP HorizonRadius : public Horizon
00072 {
00073 
00074 private:
00075 
00079         double radius;
00080 
00081 public:
00082 
00090         HorizonRadius(const double& r) : Horizon(-1), radius(r)
00091         {};
00092 
00102         HorizonRadius(const double& r, const int& lyrIndex) : Horizon(lyrIndex), radius(r)
00103         {};
00104 
00108         virtual ~HorizonRadius() {};
00109 
00113         HorizonRadius(HorizonRadius& other) : Horizon(other.getLayerIndex()), radius(other.radius)
00114         {
00115         }
00116 
00120         HorizonRadius& operator=(const HorizonRadius& other)
00121         {
00122                 layerIndex = other.layerIndex;
00123                 radius = other.radius;
00124                 return *this;
00125         }
00126 
00127         virtual string class_name() { return "HorizonRadius"; };
00128 
00129         virtual double getValue() { return radius; };
00130 
00131         virtual double getRadius(const double* position, Profile** profiles)
00132         {
00133                 if (layerIndex < 0)
00134                         return radius;
00135                 double bottom = profiles[layerIndex]->getRadiusBottom();
00136                 if (radius <= bottom)
00137                         return bottom;
00138                 double top = profiles[layerIndex]->getRadiusTop();
00139                 if (radius >= top)
00140                         return top;
00141                 return radius;
00142         }
00143 
00144         virtual double getRadius(GeoTessPosition& position)
00145         {
00146                 if (layerIndex < 0)
00147                         return radius;
00148                 double bottom = position.getRadiusBottom(layerIndex);
00149                 if (radius <= bottom)
00150                         return bottom;
00151                 double top = position.getRadiusTop(layerIndex);
00152                 if (radius >= top)
00153                         return top;
00154                 return radius;
00155         }
00156 
00157         virtual string str()
00158         {
00159                 string s = "radius " + CPPUtils::dtos(radius) + " " + CPPUtils::itos(layerIndex);
00160                 return s;
00161         }
00162 
00163 }; // end class DataValue
00164 
00165 } // end namespace geotess
00166 
00167 #endif /* HORIZONRADIUS_H_ */