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