Loading...
Searching...
No Matches
ImageLike.h
1/*
2
3MIT License
4
5Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25 */
26/*
27Part of Rack development has been done in the BALTRAD projects part-financed
28by the European Union (European Regional Development Fund and European
29Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30 */
31#ifndef IMAGELIKE_H_
32#define IMAGELIKE_H_ "ImageLike 1.1, 2020/02 Markus.Peura@fmi.fi"
33
34/*
35#include <stddef.h> // size_t
36
37##include "../util/Caster.h"
38#include "../util/ValueScaling.h"
39
40#include "Geometry.h"
41#include "Coordinates.h"
42*/
43#include "ImageConf.h"
44
45namespace drain
46{
47
49namespace image
50{
51
52
54
58// Consider: in future, may be merged to ImageConf ?
59// Consider : ImageLike<CONF> : protected CONF {
60
61class ImageLike { // public ImageConf { // or rename ImageBase
62
63public:
64
65 inline
66 ImageLike() {};
67
68 // TODO: CHECK: -Wdeprecated-copy fires because this copy constructor is user-declared but
69 // operator= is not; note the constructor's own debug message already flags
70 // "setConf/Geom has no effect" as a known/suspected problem, so this whole copy-semantics
71 // area (both constructor and any operator=) looks unfinished rather than just missing a
72 // warning-silencing declaration. Needs a real look, not a blind `=default`.
73 inline
74 ImageLike(const ImageLike &image){
75 std::cerr << __FILE__ << __FUNCTION__ << " setConf/Geom has no effect\n";
76 conf.setConf(image.conf);
77 //conf.setEncoding(image.getEncoding());
78 //conf.setCoordinatePolicy(image.getCoordinatePolicy());
79 };
80
81 /*
82 inline
83 ImageLike(const ImageConf &conf){
84 std::cerr << __FILE__ << __FUNCTION__ << " setConf has no effect\n";
85 //setConf(conf);
86 }
87 */
88
89 virtual inline
90 ~ImageLike(){};
91
92 /*
93 inline
94 const ImageConf & getConf() const {
95 return conf; // *this;
96 }
97
98 virtual inline
99 const Encoding & getEncoding() const {
100 return conf; // *this;
101 }
102 */
104 inline
105 const std::type_info & getType() const {
106 return conf.caster.getType();
107 }
108
109 inline
110 bool typeIsSet() const {
111 return conf.caster.typeIsSet();
112 };
113
114
115 virtual inline // CHECK if virtual needed
116 const Geometry & getGeometry() const {
117 return conf;
118 }
119
120
121 inline
122 size_t getWidth() const {
123 return conf.getWidth();
124 };
125
126 inline
127 size_t getHeight() const {
128 return conf.getHeight();
129 };
130
131 inline
132 size_t getArea() const {
133 return conf.getArea();
134 };
135
136 inline
137 size_t getChannelCount() const {
138 return conf.getChannelCount(); // getGeometry unneeded?
139 };
140
141
142 inline
143 size_t getImageChannelCount() const {
144 return conf.getImageChannelCount();
145 };
146
147
148 inline
149 size_t getAlphaChannelCount() const {
150 return conf.getAlphaChannelCount();
151 };
152
153
154 inline
155 bool hasAlphaChannel() const {
156 return conf.hasAlphaChannel();
157 };
158
159
160 inline
161 size_t getVolume() const {
162 return conf.getVolume();
163 };
164
165 inline
166 bool isEmpty() const {
167 return conf.isEmpty();
168 };
169
170 // 2025
172 inline
173 operator bool() const {
174 return !conf.isEmpty();
175 };
176
178 inline
180 return conf.coordinatePolicy;
181 }
182
184 inline
188
189 // TODO: lower?
190 template <class T>
191 inline
192 void setCoordinatePolicy(const T & policy){
193 conf.coordinatePolicy.set(policy);
194 }
195
196 // TODO: lower?
197 inline
198 void setCoordinatePolicy(EdgePolicy::index_t xUnderFlowPolicy, EdgePolicy::index_t yUnderFlowPolicy, EdgePolicy::index_t xOverFlowPolicy, EdgePolicy::index_t yOverFlowPolicy){
199 conf.coordinatePolicy.set(xUnderFlowPolicy, yUnderFlowPolicy, xOverFlowPolicy, yOverFlowPolicy);
200 }
201
202 virtual inline
203 const drain::ValueScaling & getScaling() const {
204 return conf.getScaling();
205 }
206
207
208 // Notice: scaling is modifiable.
209 virtual inline
210 drain::ValueScaling & getScaling() {
211 return conf.getScaling();
212 }
213
214 // Notice: scaling is modifiable.
215 virtual inline
216 void setScaling(const drain::ValueScaling & scaling){
217 conf.setScaling(scaling);
218 }
219
220 // Notice: scaling is modifiable.
221 virtual inline
222 void setScaling(double scale, double offset){
223 conf.setScaling(scale, offset);
224 }
225
226
227
228 template <class T>
229 inline
230 typename drain::typeLimiter<T>::value_t getLimiter() const {
231 return drain::Type::call<drain::typeLimiter<T> >(conf.caster.getType());
232 }
233
234
235
236
237
238protected:
239
240 ImageConf conf;
241
242};
243
244
245} // image::
246} // drain::
247
248#endif /* IMAGELIKE_H_*/
const std::type_info & getType() const
Returns type_info of the current type.
Definition Caster.h:154
Linear scaling and physical range for image intensities.
Definition ValueScaling.h:63
virtual void setScaling(double scale, double offset)
Set linear scaling.
Definition ValueScaling.h:136
virtual const ValueScaling & getScaling() const
Get linear scaling.
Definition ValueScaling.h:147
Policies for coordinate underflows and overflows.
Definition CoordinatePolicy.h:100
Caster caster
In base class(es), mainly for storing storage type. In derived classes, also for value conversions.
Definition ImageConf.h:97
Definition Geometry.h:143
size_t getChannelCount() const
Set...
Definition Geometry.h:260
CoordinatePolicy coordinatePolicy
Rules to handle under- and overflows of horizontal and vertical coordinates.
Definition ImageConf.h:383
A base class for images.
Definition ImageLike.h:61
CoordinatePolicy & getCoordinatePolicy()
Coord policy.
Definition ImageLike.h:185
const CoordinatePolicy & getCoordinatePolicy() const
Coord policy.
Definition ImageLike.h:179
const std::type_info & getType() const
Get the storage type.
Definition ImageLike.h:105
Class for ensuring that variable of type D remains within limits of type S.
Definition TypeUtils.h:98
Definition Data.h:1473