USGS

Isis 3.0 Application Source Code Reference

Home

cosi.cpp

Go to the documentation of this file.
00001 #include <cmath>
00002 
00003 #include "Isis.h"
00004 #include "ProcessByLine.h"
00005 #include "Camera.h"
00006 #include "SpecialPixel.h"
00007 
00008 using namespace std;
00009 using namespace Isis;
00010 
00011 Camera *cam;
00012 double maxinc;
00013 void divide(Buffer &in, Buffer &out);
00014 
00015 void IsisMain () {
00016 
00017   ProcessByLine p;
00018   Cube *icube = p.SetInputCube("FROM");
00019   cam = icube->Camera();
00020   maxinc = Application::GetUserInterface().GetDouble("MAXINC");
00021   p.SetOutputCube("TO");
00022   p.StartProcess(divide);
00023   p.EndProcess();
00024 }
00025 
00026 void divide(Buffer &in, Buffer &out) {
00027   for (int i=0; i<in.size(); i++) {
00028     if (cam->SetImage(i+1,in.Line())) {
00029       if (IsSpecial(in[i])) {
00030         out[i] = in[i];
00031       }
00032       else {
00033         double incidence = cam->IncidenceAngle();
00034         if (abs(incidence) >= maxinc) {
00035           out[i] = Isis::Null;
00036         }
00037         else {
00038           out[i] = in[i] / cos(incidence*Isis::PI/180.0);
00039         }
00040       }
00041     }
00042     else {
00043       out[i] = Isis::Null;
00044     }
00045   }
00046 }