ngc 1.4.0
 
Loading...
Searching...
No Matches
ngcdcsSUBFRM.hpp
Go to the documentation of this file.
1
7#ifndef ngcdcsSUBFRM_H
8#define ngcdcsSUBFRM_H
9
10
11#ifndef __cplusplus
12#error This is a C++ include file and cannot be used from plain C
13#endif
14
18#define ngcdcsMAX_SUBFRM 32
19
24 int x1; //< Lower left X
25 int y1; //< Lower left Y
26 int nx; //< X-dimension
27 int ny; //< Y-dimension
28 int x2; //< Upper right X
29 int y2; //< Upper right Y
30
33
35 int Valid() {return ((x1 >= 0) && (y1 >= 0) && (x2 >= x1) && (y2 >= y1));}
36
38 void Clear() {x1 = -1; y1 = -1; x2 = -1; y2 = -1; nx = 0; ny = 0;}
39
41 void Validate() {x2 = x1 + nx - 1; y2 = y1 + ny - 1;}
42};
43
48{
49public:
52
54 int dimX;
55
57 int dimY;
58
60 ngcdcsSUBFRM() {dimX = 0; dimY = 0;}
61
63 virtual ~ngcdcsSUBFRM() {}
64
66 void Clear() {
67 int i;
68 for (i=0;i<ngcdcsMAX_SUBFRM;i++) win[i].Clear();
69 dimX = 0; dimY = 0;
70 }
71
73 void Validate() {
74 int i;
75 for (i=0;i<ngcdcsMAX_SUBFRM;i++) win[i].Validate();
76 }
77
79 int NumFrm() {
80 int i;
81 for (i=0;(i<ngcdcsMAX_SUBFRM) && (win[i].Valid());i++);
82 return (i);
83 }
84
86 void Apply(void *buffer, int nx, int ny, int bitPix) {
87 int n = NumFrm();
88
89 if (n > 0)
90 {
91 int bytes = abs(bitPix) / 8;
92 char *pIn = (char *)buffer;
93 char *pOut = (char *)buffer;
94 int x, y;
95
96 dimY = 0; dimX = 0;
97 for (y=0;y<ny;y++)
98 {
99 int dx = 0;
100 for (x=0;x<nx;x++)
101 {
102 if (Mask_(x, y, n))
103 {
104 dx++;
105 memcpy(pOut, pIn, bytes);
106 pOut += bytes;
107 }
108 pIn += bytes;
109 }
110 if (dx > 0)
111 {
112 dimX = dx;
113 dimY++;
114 }
115 }
116
117 if (dimX == 0)
118 {
119 /*
120 * No operation has been done on the buffer
121 */
122 dimX = nx; dimY = ny;
123 }
124 }
125 else
126 {
127 /*
128 * No operation has been done on the buffer
129 */
130 dimX = nx; dimY = ny;
131 }
132 }
133
134protected:
135
136private:
138 int Mask_(int x, int y, int n) {
139 int i;
140
141 for (i=0;i<n;i++)
142 {
143 if ((x >= win[i].x1) && (x <= win[i].x2) &&
144 (y >= win[i].y1) && (y <= win[i].y2))
145 {
146 return (1);
147 }
148 }
149
150 return (0);
151 }
152
153};
154
155#endif
156
157
158
159
void Clear()
Clear.
Definition ngcdcsSUBFRM.hpp:66
void Validate()
Validate.
Definition ngcdcsSUBFRM.hpp:73
ngcdcs_subwin_t win[ngcdcsMAX_SUBFRM]
Window array.
Definition ngcdcsSUBFRM.hpp:51
int NumFrm()
Return number of valid sub-frames.
Definition ngcdcsSUBFRM.hpp:79
void Apply(void *buffer, int nx, int ny, int bitPix)
Apply sub-frames to buffer (glue image)
Definition ngcdcsSUBFRM.hpp:86
int dimY
Y-dimension (glued image)
Definition ngcdcsSUBFRM.hpp:57
ngcdcsSUBFRM()
Constructor.
Definition ngcdcsSUBFRM.hpp:60
int dimX
X-dimension (glued image)
Definition ngcdcsSUBFRM.hpp:54
virtual ~ngcdcsSUBFRM()
Destructor.
Definition ngcdcsSUBFRM.hpp:63
#define ngcdcsMAX_SUBFRM
Definition ngcdcsSUBFRM.hpp:18
Definition ngcdcsSUBFRM.hpp:23
int y2
Definition ngcdcsSUBFRM.hpp:29
int y1
Definition ngcdcsSUBFRM.hpp:25
int x1
Definition ngcdcsSUBFRM.hpp:24
int ny
Definition ngcdcsSUBFRM.hpp:27
ngcdcs_subwin_t()
Constructor.
Definition ngcdcsSUBFRM.hpp:32
void Validate()
Validate coordinates.
Definition ngcdcsSUBFRM.hpp:41
void Clear()
Clear.
Definition ngcdcsSUBFRM.hpp:38
int Valid()
Window valid.
Definition ngcdcsSUBFRM.hpp:35
int nx
Definition ngcdcsSUBFRM.hpp:26
int x2
Definition ngcdcsSUBFRM.hpp:28