40 ProcessExport::ProcessExport() : Isis::
Process() {
71 for(
unsigned int i = 0; i <
p_str.size(); i++) {
101 double middle = (minimum + maximum) / 2.0;
130 double middle = (minimum + maximum) / 2.0;
161 const double maximum) {
162 if(minimum >= middle) {
164 "minimum must be less than the middle [ProcessExport::SetInputRange]";
167 if(middle >= maximum) {
169 "middle must be less than the maximum [ProcessExport::SetInputRange]";
209 const double maximum,
const int index) {
210 if(minimum >= middle) {
212 "minimum must be less than the middle [ProcessExport::SetInputRange]";
215 if(middle >= maximum) {
217 "middle must be less than the maximum [ProcessExport::SetInputRange]";
220 if(index >= (
int)
InputCubes.size() || index < 0) {
222 "index out of bounds";
371 for(
unsigned int i = 0; i <
InputCubes.size(); i++) {
374 if(strType ==
"MANUAL") {
382 else if(strType !=
"NONE") {
394 if(strType ==
"PIECEWISE") {
414 bool ProcessExport::HasInputRange()
const {
423 "There is no input minimum for channel " +
IString((
int) n),
434 "There is no input maximum for channel " +
IString((
int) n),
457 if(minimum >= maximum) {
459 "minimum must be less than the maximum [ProcessExport::SetOutputRange]";
613 if(p_format < 0 || p_format > 3) {
615 "Format of the output file must be set prior to calling this method [ProcessExport::SetOutputType]";
618 if(pixelIn == Isis::UnsignedByte)
620 else if(pixelIn == Isis::UnsignedWord)
622 else if(pixelIn == Isis::SignedWord)
624 else if(pixelIn == Isis::Real)
627 "Unsupported bit type for JP2 formatted files [ProcessExport::SetOutputType]";
635 "Unsupported bit type [ProcessExport::SetOutputType]";
656 if(byteOrderIn == Isis::NoByteOrder) {
659 else if(byteOrderIn == Isis::Lsb) {
662 else if(byteOrderIn == Isis::Msb) {
680 string m =
"You have not specified any input cubes";
700 for(
unsigned int i = 0; i <
InputCubes.size(); i++) {
756 string m =
"Invalid storage order.";
765 for(
int i = 0; i < buff->
size(); i++) {
766 (*buff)[i] =
p_str[0]->Map((*buff)[i]);
798 vector<BufferManager *> imgrs = GetBuffers();
799 for (
int k = 1; k <= length; k++) {
800 vector<Buffer *> ibufs;
802 for (
unsigned int j = 0; j <
InputCubes.size(); j++) {
807 for (
int i = 0; i <
InputCubes[0]->sampleCount(); i++)
808 (*imgrs[j])[i] =
p_str[j]->Map((*imgrs[j])[i]);
810 ibufs.push_back(imgrs[j]);
816 for (
unsigned int i = 0; i < imgrs.size(); i++) imgrs[i]->next();
822 vector<BufferManager *> ProcessExport::GetBuffers() {
824 vector<BufferManager *> imgrs;
835 string m =
"Invalid storage order.";
861 vector<BufferManager *> imgrs;
862 for (
unsigned int i = 0; i <
InputCubes.size(); i++) {
863 if((
InputCubes[i]->sampleCount() == samples) &&
868 imgrs.push_back(iline);
871 string m =
"All input cubes must have the same dimensions";
900 vector<BufferManager *> imgrs;
901 for (
unsigned int i = 0; i <
InputCubes.size(); i++) {
902 if ((
InputCubes[i]->sampleCount() == samples) &&
907 imgrs.push_back(iline);
910 string m =
"All input cubes must have the same dimensions";
938 vector<BufferManager *> imgrs;
939 for(
unsigned int i = 0; i <
InputCubes.size(); i++) {
943 imgrs.push_back(iband);
946 string m =
"All input cubes must have the same dimensions";
983 string m =
"Output stream cannot be generated for requested storage order type.";
992 for(
int i = 0; i < buff->
size(); i++) {
993 (*buff)[i] =
p_str[0]->Map((*buff)[i]);
1027 char *out8 =
new char[in.
size()];
1028 for(
int samp = 0; samp < in.
size(); samp++) {
1029 double pixel = in[samp];
1033 else if(pixel >= 255.0) {
1037 out8[samp] = (char)(in[samp] + 0.5);
1040 fout.write(out8, in.
size());
1064 short *out16s =
new short[in.
size()];
1065 for(
int samp = 0; samp < in.
size(); samp++) {
1066 double pixel = in[samp];
1068 if(pixel <= -32768.0) {
1069 tempShort = -(short)32768;
1071 else if(pixel >= 32767.0) {
1072 tempShort = (short)32767;
1076 if(in[samp] < 0.0) {
1077 tempShort = (short)(in[samp] - 0.5);
1080 tempShort = (short)(in[samp] + 0.5);
1083 void *p_swap = &tempShort;
1086 fout.write((
char *)out16s, in.
size() * 2);
1110 unsigned short *out16u =
new unsigned short[in.
size()];
1111 for(
int samp = 0; samp < in.
size(); samp++) {
1112 double pixel = in[samp];
1113 unsigned short tempShort;
1117 else if(pixel >= 65535.0) {
1121 tempShort = (
unsigned short)(in[samp] + 0.5);
1123 unsigned short *p_swap = &tempShort;
1127 fout.write((
char *)out16u, in.
size() * 2);
1150 int *out32 =
new int[in.
size()];
1151 for(
int samp = 0; samp < in.
size(); samp++) {
1152 double pixel = in[samp];
1154 if(pixel <= -((
double)FLT_MAX)) {
1155 tempFloat = -((double)FLT_MAX);
1157 else if(pixel >= (
double)FLT_MAX) {
1158 tempFloat = (double)FLT_MAX;
1161 tempFloat = (double)in[samp];
1163 void *p_swap = &tempFloat;
1166 fout.write((
char *)out32, in.
size() * 4);
1187 os.open(worldFile.toAscii().data(), ios::out);
1190 os << std::fixed << setprecision(15)
1197 os << std::fixed << setprecision(15)
1201 os << std::fixed << setprecision(15)
1202 << proj->
XCoord() << endl;
1205 os << std::fixed << setprecision(15)
1206 << proj->
YCoord() << endl;