1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
// $Id: TabulatedConstituent.cc,v 1.4 2002/12/23 18:53:56 flaterco Exp $
// TabulatedConstituent: definition of a constituent that uses tabulated
// equilibrium arguments and node factors.
/*
Copyright (C) 1998 David Flater.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "common.hh"
TabulatedConstituent::Argfac::Argfac () {
arg = Radians (0.0);
nod = 1.0;
}
TabulatedConstituent::Argfac::Argfac (Angle in_arg, double in_nod) {
arg = in_arg;
nod = in_nod;
}
TabulatedConstituent::TabulatedConstituent () {
myname = "Anonymous";
myspeed = DegreesPerHour (0.0);
myargfacs = NULL;
}
TabulatedConstituent::TabulatedConstituent (Dstr &in_name) {
myname = in_name;
myspeed = DegreesPerHour (0.0);
myargfacs = NULL;
}
TabulatedConstituent &
TabulatedConstituent::operator= (Constituent &in_con) {
if (myargfacs)
delete [] myargfacs;
myname = in_con.name();
myspeed = in_con.speed();
myfirstvalidyear = in_con.firstvalidyear();
mylastvalidyear = in_con.lastvalidyear();
nargs = mylastvalidyear.val() - myfirstvalidyear.val() + 1;
assert (myargfacs = new Argfac [nargs]);
for (unsigned looper=0; looper<nargs; looper++) {
Year ty (myfirstvalidyear + looper);
myargfacs[looper].arg = in_con.arg(ty);
myargfacs[looper].nod = in_con.nod(ty);
}
return (*this);
}
// Workaround for funky overload resolution problem.
TabulatedConstituent &
TabulatedConstituent::operator= (TabulatedConstituent &in_con) {
(*this) = *((Constituent*)&in_con); // You forth me to use forth!
return (*this);
}
void
TabulatedConstituent::speed (Speed in_speed) {
myspeed = in_speed;
}
// This should be redundant -- workaround for bug in
// Sun WorkShop Compiler C++ SPARC Version 5.000
// Error: Could not find a match for TabulatedConstituent::speed(DegreesPerHour).
/*
void
TabulatedConstituent::speed (DegreesPerHour in_speed) {
myspeed = in_speed;
}
*/
Speed TabulatedConstituent::speed () {
return myspeed;
}
Year
TabulatedConstituent::firstvalidyear() {
return myfirstvalidyear;
}
Year
TabulatedConstituent::lastvalidyear() {
return mylastvalidyear;
}
void
TabulatedConstituent::check_valid (Year in_year) {
if (in_year < myfirstvalidyear ||
in_year > mylastvalidyear) {
Dstr details ("The years supported by the harmonics file are ");
details += (int)myfirstvalidyear.val();
details += " through ";
details += (int)mylastvalidyear.val();
details += ".\n";
details += "The offending year was ";
details += (int)in_year.val();
details += ".\n";
barf (YEAR_NOT_IN_TABLE, details);
}
}
Angle
TabulatedConstituent::arg (Year in_year) {
check_valid (in_year);
assert (myargfacs);
return myargfacs[in_year.val()-myfirstvalidyear.val()].arg;
}
double
TabulatedConstituent::nod (Year in_year) {
check_valid (in_year);
assert (myargfacs);
return myargfacs[in_year.val()-myfirstvalidyear.val()].nod;
}
void TabulatedConstituent::readboth (int i, Year first_year, Year last_year)
{
assert (!myargfacs);
assert (last_year >= first_year);
nargs = last_year.val() - first_year.val() + 1;
assert (myargfacs = new Argfac [nargs]);
myfirstvalidyear = first_year;
mylastvalidyear = last_year;
for (unsigned looper=0; looper<nargs; looper++) {
myargfacs[looper].arg =
Degrees(get_equilibrium (i, looper));
myargfacs[looper].nod = get_node_factor (i, looper);
}
}
TabulatedConstituent::~TabulatedConstituent() {
if (myargfacs)
delete [] myargfacs;
}
|