Debian Codegraph @

src/imageclasses/Mia.cc

raw symbols SCIP
1 /**********************************************************************
2 Mia.c: class to test MIA functions in C++
3 Author(s): [email protected] [email protected]
4 Copyright (C) 2016-2020 European Union (Joint Research Centre)
5
6 This file is part of jiplib.
7
8 jiplib is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 jiplib is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with jiplib. If not, see <https://www.gnu.org/licenses/>.
20 ***********************************************************************/
21 #include "Mia.h"
22
23 void set_seq_shift(long int nx, long int ny, long int nz, long int graph, long int *shift){
24 if (graph == 2){ /* added 20110310 for shadow ray processing */
25 shift[0] = -1;
26 shift[1] = 1;
27 }
28 else if (graph == 4){ /* && nz == 1: suppressed on 2004-11-18 (side effects?) */
29 shift[0] = -nx;
30 shift[1] = -1;
31 shift[2] = nx;
32 shift[3] = 1;
33 }
34 else if (graph == 8){ /* && nz == 1: suppressed on 2004-11-18 (side effects?) */
35 shift[0] = -nx; shift[1] = -1;
36 shift[2] = -nx + 1; shift[3] = -nx - 1;
37 shift[4] = 1; shift[5] = nx;
38 shift[6] = nx - 1; shift[7] = nx + 1;
39 }
40 else if (graph == 6 && nz > 1){
41 shift[0] = -nx; shift[1] = -1;
42 shift[2] = -(nx * ny);
43 shift[3] = nx; shift[4] = 1;
44 shift[5] = -shift[2];
45 }
46 else if (graph == 18 && nz > 1){
47 shift[0] = -nx; shift[1] = -1;
48 shift[2] = shift[0] + 1; shift[3] = shift[0] - 1;
49 shift[4] = -(nx * ny);
50 shift[5] = shift[4] + shift[0]; shift[6] = shift[4] - 1;
51 shift[7] = shift[4] + 1; shift[8] = shift[4] - shift[0];
52 shift[9] = -shift[0]; shift[10] = 1;
53 shift[11] = -shift[2]; shift[12] = -shift[3];
54 shift[13] = -shift[4]; shift[14] = -shift[5];
55 shift[15] = -shift[6]; shift[16] = -shift[7];
56 shift[17] = -shift[8];
57 }
58 else if (graph == 26 && nz > 1){
59 shift[0] = -nx; shift[1] = -1;
60 shift[2] = shift[0] + 1; shift[3] = shift[0] - 1;
61 shift[4] = -(nx * ny);
62 shift[5] = shift[4] + shift[0]; shift[6] = shift[4] - 1;
63 shift[7] = shift[4] + 1; shift[8] = shift[4] - shift[0];
64 shift[9] = shift[5] - 1; shift[10] = shift[5] + 1;
65 shift[11] = shift[8] - 1; shift[12] = shift[8] + 1;
66 shift[13] = -shift[0]; shift[14] = -shift[1];
67 shift[15] = -shift[2]; shift[16] = -shift[3];
68 shift[17] = -shift[4]; shift[18] = -shift[5];
69 shift[19] = -shift[6]; shift[20] = -shift[7];
70 shift[21] = -shift[8]; shift[22] = -shift[9];
71 shift[23] = -shift[10]; shift[24] = -shift[11];
72 shift[25] = -shift[12];
73 }
74 else{
75 std::ostringstream s;
76 s << "Error: set_seq_shift(): invalid parameters";
77 throw(s.str());
78 }
79 }
80
81 void Jim::d_jlframebox(std::vector<int> box, double val, std::size_t band){
82 switch(getDataType()){
83 case(GDT_Byte):
84 d_jlframebox_t<unsigned char>(box,static_cast<unsigned char>(val),band);
85 break;
86 case(GDT_Int16):
87 d_jlframebox_t<short>(box,static_cast<short>(val),band);
88 break;
89 case(GDT_UInt16):
90 d_jlframebox_t<unsigned short>(box,static_cast<unsigned short>(val),band);
91 break;
92 case(GDT_Int32):
93 d_jlframebox_t<int>(box,static_cast<int>(val),band);
94 break;
95 case(GDT_UInt32):
96 d_jlframebox_t<unsigned int>(box,static_cast<unsigned int>(val),band);
97 break;
98 case(GDT_Float32):
99 d_jlframebox_t<float>(box,static_cast<float>(val),band);
100 break;
101 case(GDT_Float64):
102 d_jlframebox_t<double>(box,static_cast<double>(val),band);
103 break;
104 default:
105 std::string errorString="Error: data type not supported";
106 throw(errorString);
107 break;
108 }
109 }
110
111 void Jim::d_jldistanceGeodesic(Jim& reference, std::size_t graph, std::size_t band){
112 switch(getDataType()){
113 case(GDT_Byte):
114 d_jldistanceGeodesic_t<unsigned char>(reference,graph,band);
115 break;
116 case(GDT_Int16):
117 d_jldistanceGeodesic_t<short>(reference,graph,band);
118 break;
119 case(GDT_UInt16):
120 d_jldistanceGeodesic_t<unsigned short>(reference,graph,band);
121 break;
122 case(GDT_Int32):
123 d_jldistanceGeodesic_t<int>(reference,graph,band);
124 break;
125 case(GDT_UInt32):
126 d_jldistanceGeodesic_t<unsigned int>(reference,graph,band);
127 break;
128 default:
129 std::string errorString="Error: data type not supported";
130 throw(errorString);
131 break;
132 }
133 }
134
135 std::shared_ptr<Jim> Jim::jldistanceGeodesic(Jim& reference, std::size_t graph, std::size_t band){
136 try{
137 std::shared_ptr<Jim> copyImg=this->clone();
138 copyImg->d_jldistanceGeodesic(reference,graph,band);
139 return(copyImg);
140 }
141 catch(std::string errorString){
142 std::cerr << errorString << std::endl;
143 throw;
144 }
145 catch(...){
146 throw;
147 }
148 }