USGS

Isis 3.0 Object Programmers' Reference

Home

IdealCamera.cpp
Go to the documentation of this file.
1 
23 #include "IdealCamera.h"
24 
25 #include <iomanip>
26 #include <string>
27 
28 #include <QDebug>
29 
30 #include "CameraDistortionMap.h"
31 #include "CameraFocalPlaneMap.h"
32 #include "IException.h"
33 #include "IString.h"
34 #include "iTime.h"
37 #include "LineScanCameraSkyMap.h"
38 #include "NaifStatus.h"
39 #include "Pvl.h"
40 
41 using namespace std;
42 namespace Isis {
75  IdealCamera::IdealCamera(Cube &cube) : Camera(cube) {
77  // Get required keywords from instrument group
78  PvlGroup &inst = cube.label()->findGroup("Instrument", Pvl::Traverse);
79 
80  // Setup camera characteristics from instrument
81 
82  if (inst.hasKeyword("FocalLength")) {
83  SetFocalLength(inst["FocalLength"]);
84  }
85  else {
86  SetFocalLength(readValue("IDEAL_FOCAL_LENGTH", SpiceDoubleType).toDouble());
87  }
88 
89  if (inst.hasKeyword("PixelPitch")) {
90  SetPixelPitch(inst["PixelPitch"]);
91  }
92  else {
93  SetPixelPitch(readValue("IDEAL_PIXEL_PITCH", SpiceDoubleType).toDouble());
94  }
95 
96  double et = inst["EphemerisTime"];
97 
98  double exposureDuration = 0.0;
99  if (inst.hasKeyword("ExposureDuration")) {
100  exposureDuration = ((double) inst["ExposureDuration"]) / 1000.0;
101  }
102 
103  double sampleDetectors = inst["SampleDetectors"];
104  double lineDetectors = inst["LineDetectors"];
105 
106  // These variables are used for maintaining compatibility with older versions of the
107  // ideal camera (noproj before it modified the naif keywords group) and for cubes without the
108  // naif keywords group at all.
109  int xDependency = inst["FocalPlaneXDependency"];
110  int yDependency = CameraFocalPlaneMap::Line;
111  // Pixel direction
112  double xdir = 1.0;
113  double ydir = 1.0;
114  double sdir = xdir;
115  double ldir = ydir;
116 
117  if (inst.hasKeyword("TransX")) xdir = inst["TransX"];
118  if (inst.hasKeyword("TransY")) ydir = inst["TransY"];
119 
120  if (xDependency == CameraFocalPlaneMap::Line) {
121  yDependency = CameraFocalPlaneMap::Sample;
122  sdir = ydir;
123  ldir = xdir;
124  }
125 
126  // Put the translation coefficients into the Naif kernel pool so the
127  // CameraFocalPlaneClass can find them
128  try {
129  readValue("IDEAL_TRANSX", SpiceDoubleType);
130  }
131  catch (IException &) {
132  double keyval[3];
133  keyval[0] = 0.;
134  if (inst.hasKeyword("TransX0")) {
135  keyval[0] = inst["TransX0"];
136  }
137 
138  keyval[xDependency] = PixelPitch() * xdir;
139  keyval[yDependency] = 0.;
140 
141  storeValue("IDEAL_TRANSX", 0, SpiceDoubleType, keyval[0]);
142  storeValue("IDEAL_TRANSX", 1, SpiceDoubleType, keyval[1]);
143  storeValue("IDEAL_TRANSX", 2, SpiceDoubleType, keyval[2]);
144  pdpool_c("IDEAL_TRANSX", 3, keyval);
145  }
146 
147  try {
148  readValue("IDEAL_TRANSY", SpiceDoubleType);
149  }
150  catch (IException &) {
151  double keyval[3];
152  keyval[0] = 0.;
153  if (inst.hasKeyword("TransY0")) {
154  keyval[0] = inst["TransY0"];
155  }
156 
157  keyval[yDependency] = PixelPitch() * ydir;
158  keyval[xDependency] = 0.;
159 
160  storeValue("IDEAL_TRANSY", 0, SpiceDoubleType, keyval[0]);
161  storeValue("IDEAL_TRANSY", 1, SpiceDoubleType, keyval[1]);
162  storeValue("IDEAL_TRANSY", 2, SpiceDoubleType, keyval[2]);
163  pdpool_c("IDEAL_TRANSY", 3, keyval);
164  }
165 
166  try {
167  readValue("IDEAL_TRANSS", SpiceDoubleType);
168  }
169  catch (IException &) {
170  double keyval[3];
171  keyval[0] = 0.;
172  if (inst.hasKeyword("TransS0")) {
173  keyval[0] = inst["TransS0"];
174  }
175 
176  keyval[xDependency] = 1 / PixelPitch() * sdir;
177  keyval[yDependency] = 0.;
178 
179  storeValue("IDEAL_TRANSS", 0, SpiceDoubleType, keyval[0]);
180  storeValue("IDEAL_TRANSS", 1, SpiceDoubleType, keyval[1]);
181  storeValue("IDEAL_TRANSS", 2, SpiceDoubleType, keyval[2]);
182  pdpool_c("IDEAL_TRANSS", 3, keyval);
183  }
184 
185  try {
186  readValue("IDEAL_TRANSL", SpiceDoubleType);
187  }
188  catch (IException &) {
189  double keyval[3];
190  keyval[0] = 0.;
191  if (inst.hasKeyword("TransL0")) {
192  keyval[0] = inst["TransL0"];
193  }
194 
195  keyval[yDependency] = 1 / PixelPitch() * ldir;
196  keyval[xDependency] = 0.0;
197 
198  storeValue("IDEAL_TRANSL", 0, SpiceDoubleType, keyval[0]);
199  storeValue("IDEAL_TRANSL", 1, SpiceDoubleType, keyval[1]);
200  storeValue("IDEAL_TRANSL", 2, SpiceDoubleType, keyval[2]);
201  pdpool_c("IDEAL_TRANSL", 3, keyval);
202  }
203 
204  // Create correct camera type
205  QString type = (QString) inst["InstrumentType"];
206  if (type.toUpper() == "FRAMING") {
207  p_framing = true;
208  new CameraDetectorMap(this);
209  CameraFocalPlaneMap *fmap = new CameraFocalPlaneMap(this, 0);
210  fmap->SetDetectorOrigin(sampleDetectors / 2.0 + 0.5,
211  lineDetectors / 2.0 + 0.5);
212  new CameraDistortionMap(this);
213  new CameraGroundMap(this);
214  new CameraSkyMap(this);
215 
216  setTime(et);
217  LoadCache();
218  }
219  else if (type.toUpper() == "LINESCAN") {
220  p_framing = false;
221  new LineScanCameraDetectorMap(this, et, exposureDuration);
222  CameraFocalPlaneMap *fmap = new CameraFocalPlaneMap(this, 0);
223  fmap->SetDetectorOrigin(sampleDetectors / 2.0 + 0.5,
224  0.0);
225  new CameraDistortionMap(this);
226  new LineScanCameraGroundMap(this);
227  new LineScanCameraSkyMap(this);
228 
229  LoadCache();
231  }
232  else {
233  QString msg = "Unknown InstrumentType [" +
234  (QString) inst["InstrumentType"] + "]";
236  }
237  }
238 
241 
242 
250  string msg = "No CK Frame ID for Ideal Camera class";
252  }
253 
254 
262  string msg = "No CK Reference ID for Ideal Camera class";
264  }
265 
273  string msg = "No SPK Target ID for Ideal Camera class";
275  }
276 
284  string msg = "No SPK Center ID for Ideal Camera class";
286  }
287 
295  string msg = "No SPK Reference ID for Ideal Camera class";
297  }
298 }
299 
310  return new Isis::IdealCamera(cube);
311 }