bioformats  5.1.5
length.h
Go to the documentation of this file.
1 /*
2  * #%L
3  * OME-COMMON C++ library for C++ compatibility/portability
4  * %%
5  * Copyright © 2015 Open Microscopy Environment:
6  * - Massachusetts Institute of Technology
7  * - National Institutes of Health
8  * - University of Dundee
9  * - Board of Regents of the University of Wisconsin-Madison
10  * - Glencoe Software, Inc.
11  * %%
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions are met:
14  *
15  * 1. Redistributions of source code must retain the above copyright notice,
16  * this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright notice,
18  * this list of conditions and the following disclaimer in the documentation
19  * and/or other materials provided with the distribution.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  * The views and conclusions contained in the software and documentation are
34  * those of the authors and should not be interpreted as representing official
35  * policies, either expressed or implied, of any organization.
36  * #L%
37  */
38 
47 #ifndef OME_COMMON_UNITS_LENGTH_H
48 #define OME_COMMON_UNITS_LENGTH_H
49 
50 #include <ome/common/config.h>
51 #include <ome/common/units/types.h>
52 
53 #include <boost/units/base_units/astronomical/astronomical_unit.hpp>
54 #include <boost/units/base_units/astronomical/light_year.hpp>
55 #include <boost/units/base_units/astronomical/parsec.hpp>
56 #include <boost/units/base_units/imperial/thou.hpp>
57 #include <boost/units/base_units/imperial/inch.hpp>
58 #include <boost/units/base_units/imperial/foot.hpp>
59 #include <boost/units/base_units/imperial/yard.hpp>
60 #include <boost/units/base_units/imperial/mile.hpp>
61 #include <boost/units/base_units/metric/micron.hpp>
62 #include <boost/units/base_units/metric/angstrom.hpp>
63 #include <boost/units/unit.hpp>
64 #include <boost/units/quantity.hpp>
65 #include <boost/units/systems/si.hpp>
66 
67 namespace ome
68 {
69  namespace common
70  {
71  namespace units
72  {
73 
74  // Length types, constants and quantities.
75 
77  typedef si::length length_unit;
79  typedef quantity<si::length> length_quantity;
80 
82  typedef make_scaled_unit<si::length,scale<10,static_rational<-24> > >::type yoctometre_unit;
84  typedef make_scaled_unit<si::length,scale<10,static_rational<-21> > >::type zeptometre_unit;
86  typedef make_scaled_unit<si::length,scale<10,static_rational<-18> > >::type attometre_unit;
88  typedef make_scaled_unit<si::length,scale<10,static_rational<-15> > >::type femtometre_unit;
90  typedef make_scaled_unit<si::length,scale<10,static_rational<-12> > >::type picometre_unit;
92  typedef make_scaled_unit<si::length,scale<10,static_rational< -9> > >::type nanometre_unit;
94  typedef make_scaled_unit<si::length,scale<10,static_rational< -6> > >::type micrometre_unit;
96  typedef make_scaled_unit<si::length,scale<10,static_rational< -3> > >::type millimetre_unit;
98  typedef make_scaled_unit<si::length,scale<10,static_rational< -2> > >::type centimetre_unit;
100  typedef make_scaled_unit<si::length,scale<10,static_rational< -1> > >::type decimetre_unit;
102  typedef make_scaled_unit<si::length,scale<10,static_rational< 0> > >::type metre_unit;
104  typedef make_scaled_unit<si::length,scale<10,static_rational< 1> > >::type dekametre_unit;
106  typedef make_scaled_unit<si::length,scale<10,static_rational< 1> > >::type decametre_unit;
108  typedef make_scaled_unit<si::length,scale<10,static_rational< 2> > >::type hectometre_unit;
110  typedef make_scaled_unit<si::length,scale<10,static_rational< 3> > >::type kilometre_unit;
112  typedef make_scaled_unit<si::length,scale<10,static_rational< 6> > >::type megametre_unit;
114  typedef make_scaled_unit<si::length,scale<10,static_rational< 9> > >::type gigametre_unit;
116  typedef make_scaled_unit<si::length,scale<10,static_rational< 12> > >::type terametre_unit;
118  typedef make_scaled_unit<si::length,scale<10,static_rational< 15> > >::type petametre_unit;
120  typedef make_scaled_unit<si::length,scale<10,static_rational< 18> > >::type exametre_unit;
122  typedef make_scaled_unit<si::length,scale<10,static_rational< 21> > >::type zettametre_unit;
124  typedef make_scaled_unit<si::length,scale<10,static_rational< 24> > >::type yottametre_unit;
125 
127  typedef yoctometre_unit yoctometer_unit;
129  typedef zeptometre_unit zeptometer_unit;
131  typedef attometre_unit attometer_unit;
133  typedef femtometre_unit femtometer_unit;
135  typedef picometre_unit picometer_unit;
137  typedef nanometre_unit nanometer_unit;
139  typedef micrometre_unit micrometer_unit;
141  typedef millimetre_unit millimeter_unit;
143  typedef centimetre_unit centimeter_unit;
145  typedef decimetre_unit decimeter_unit;
147  typedef metre_unit meter_unit;
149  typedef dekametre_unit dekameter_unit;
151  typedef decametre_unit decameter_unit;
153  typedef hectometre_unit hectometer_unit;
155  typedef kilometre_unit kilometer_unit;
157  typedef megametre_unit megameter_unit;
159  typedef gigametre_unit gigameter_unit;
161  typedef terametre_unit terameter_unit;
163  typedef petametre_unit petameter_unit;
165  typedef exametre_unit exameter_unit;
167  typedef zettametre_unit zettameter_unit;
169  typedef yottametre_unit yottameter_unit;
170 
172  BOOST_UNITS_STATIC_CONSTANT(yoctometre, yoctometre_unit);
174  BOOST_UNITS_STATIC_CONSTANT(zeptometre, zeptometre_unit);
176  BOOST_UNITS_STATIC_CONSTANT(attometre, attometre_unit);
178  BOOST_UNITS_STATIC_CONSTANT(femtometre, femtometre_unit);
180  BOOST_UNITS_STATIC_CONSTANT(picometre, picometre_unit);
182  BOOST_UNITS_STATIC_CONSTANT(nanometre, nanometre_unit);
184  BOOST_UNITS_STATIC_CONSTANT(micrometre, micrometre_unit);
186  BOOST_UNITS_STATIC_CONSTANT(millimetre, millimetre_unit);
188  BOOST_UNITS_STATIC_CONSTANT(centimetre, centimetre_unit);
190  BOOST_UNITS_STATIC_CONSTANT(decimetre, decimetre_unit);
192  BOOST_UNITS_STATIC_CONSTANT(metre, metre_unit);
194  BOOST_UNITS_STATIC_CONSTANT(dekametre, dekametre_unit);
196  BOOST_UNITS_STATIC_CONSTANT(decametre, decametre_unit);
198  BOOST_UNITS_STATIC_CONSTANT(hectometre, hectometre_unit);
200  BOOST_UNITS_STATIC_CONSTANT(kilometre, kilometre_unit);
202  BOOST_UNITS_STATIC_CONSTANT(megametre, megametre_unit);
204  BOOST_UNITS_STATIC_CONSTANT(gigametre, gigametre_unit);
206  BOOST_UNITS_STATIC_CONSTANT(terametre, terametre_unit);
208  BOOST_UNITS_STATIC_CONSTANT(petametre, petametre_unit);
210  BOOST_UNITS_STATIC_CONSTANT(exametre, exametre_unit);
212  BOOST_UNITS_STATIC_CONSTANT(zettametre, zettametre_unit);
214  BOOST_UNITS_STATIC_CONSTANT(yottametre, yottametre_unit);
215 
217  BOOST_UNITS_STATIC_CONSTANT(yoctometres, yoctometre_unit);
219  BOOST_UNITS_STATIC_CONSTANT(zeptometres, zeptometre_unit);
221  BOOST_UNITS_STATIC_CONSTANT(attometres, attometre_unit);
223  BOOST_UNITS_STATIC_CONSTANT(femtometres, femtometre_unit);
225  BOOST_UNITS_STATIC_CONSTANT(picometres, picometre_unit);
227  BOOST_UNITS_STATIC_CONSTANT(nanometres, nanometre_unit);
229  BOOST_UNITS_STATIC_CONSTANT(micrometres, micrometre_unit);
231  BOOST_UNITS_STATIC_CONSTANT(millimetres, millimetre_unit);
233  BOOST_UNITS_STATIC_CONSTANT(centimetres, centimetre_unit);
235  BOOST_UNITS_STATIC_CONSTANT(decimetres, decimetre_unit);
237  BOOST_UNITS_STATIC_CONSTANT(metres, metre_unit);
239  BOOST_UNITS_STATIC_CONSTANT(dekametres, dekametre_unit);
241  BOOST_UNITS_STATIC_CONSTANT(decametres, decametre_unit);
243  BOOST_UNITS_STATIC_CONSTANT(hectometres, hectometre_unit);
245  BOOST_UNITS_STATIC_CONSTANT(kilometres, kilometre_unit);
247  BOOST_UNITS_STATIC_CONSTANT(megametres, megametre_unit);
249  BOOST_UNITS_STATIC_CONSTANT(gigametres, gigametre_unit);
251  BOOST_UNITS_STATIC_CONSTANT(terametres, terametre_unit);
253  BOOST_UNITS_STATIC_CONSTANT(petametres, petametre_unit);
255  BOOST_UNITS_STATIC_CONSTANT(exametres, exametre_unit);
257  BOOST_UNITS_STATIC_CONSTANT(zettametres, zettametre_unit);
259  BOOST_UNITS_STATIC_CONSTANT(yottametres, yottametre_unit);
260 
262  BOOST_UNITS_STATIC_CONSTANT(yoctometer, yoctometer_unit);
264  BOOST_UNITS_STATIC_CONSTANT(zeptometer, zeptometer_unit);
266  BOOST_UNITS_STATIC_CONSTANT(attometer, attometer_unit);
268  BOOST_UNITS_STATIC_CONSTANT(femtometer, femtometer_unit);
270  BOOST_UNITS_STATIC_CONSTANT(picometer, picometer_unit);
272  BOOST_UNITS_STATIC_CONSTANT(nanometer, nanometer_unit);
274  BOOST_UNITS_STATIC_CONSTANT(micrometer, micrometer_unit);
276  BOOST_UNITS_STATIC_CONSTANT(millimeter, millimeter_unit);
278  BOOST_UNITS_STATIC_CONSTANT(centimeter, centimeter_unit);
280  BOOST_UNITS_STATIC_CONSTANT(decimeter, decimeter_unit);
282  BOOST_UNITS_STATIC_CONSTANT(meter, meter_unit);
284  BOOST_UNITS_STATIC_CONSTANT(dekameter, dekameter_unit);
286  BOOST_UNITS_STATIC_CONSTANT(decameter, decameter_unit);
288  BOOST_UNITS_STATIC_CONSTANT(hectometer, hectometer_unit);
290  BOOST_UNITS_STATIC_CONSTANT(kilometer, kilometer_unit);
292  BOOST_UNITS_STATIC_CONSTANT(megameter, megameter_unit);
294  BOOST_UNITS_STATIC_CONSTANT(gigameter, gigameter_unit);
296  BOOST_UNITS_STATIC_CONSTANT(terameter, terameter_unit);
298  BOOST_UNITS_STATIC_CONSTANT(petameter, petameter_unit);
300  BOOST_UNITS_STATIC_CONSTANT(exameter, exameter_unit);
302  BOOST_UNITS_STATIC_CONSTANT(zettameter, zettameter_unit);
304  BOOST_UNITS_STATIC_CONSTANT(yottameter, yottameter_unit);
305 
307  BOOST_UNITS_STATIC_CONSTANT(yoctometers, yoctometer_unit);
309  BOOST_UNITS_STATIC_CONSTANT(zeptometers, zeptometer_unit);
311  BOOST_UNITS_STATIC_CONSTANT(attometers, attometer_unit);
313  BOOST_UNITS_STATIC_CONSTANT(femtometers, femtometer_unit);
315  BOOST_UNITS_STATIC_CONSTANT(picometers, picometer_unit);
317  BOOST_UNITS_STATIC_CONSTANT(nanometers, nanometer_unit);
319  BOOST_UNITS_STATIC_CONSTANT(micrometers, micrometer_unit);
321  BOOST_UNITS_STATIC_CONSTANT(millimeters, millimeter_unit);
323  BOOST_UNITS_STATIC_CONSTANT(centimeters, centimeter_unit);
325  BOOST_UNITS_STATIC_CONSTANT(decimeters, decimeter_unit);
327  BOOST_UNITS_STATIC_CONSTANT(meters, meter_unit);
329  BOOST_UNITS_STATIC_CONSTANT(dekameters, dekameter_unit);
331  BOOST_UNITS_STATIC_CONSTANT(decameters, decameter_unit);
333  BOOST_UNITS_STATIC_CONSTANT(hectometers, hectometer_unit);
335  BOOST_UNITS_STATIC_CONSTANT(kilometers, kilometer_unit);
337  BOOST_UNITS_STATIC_CONSTANT(megameters, megameter_unit);
339  BOOST_UNITS_STATIC_CONSTANT(gigameters, gigameter_unit);
341  BOOST_UNITS_STATIC_CONSTANT(terameters, terameter_unit);
343  BOOST_UNITS_STATIC_CONSTANT(petameters, petameter_unit);
345  BOOST_UNITS_STATIC_CONSTANT(exameters, exameter_unit);
347  BOOST_UNITS_STATIC_CONSTANT(zettameters, zettameter_unit);
349  BOOST_UNITS_STATIC_CONSTANT(yottameters, yottameter_unit);
350 
352  typedef quantity<yoctometre_unit> yoctometre_quantity;
354  typedef quantity<zeptometre_unit> zeptometre_quantity;
356  typedef quantity<attometre_unit> attometre_quantity;
358  typedef quantity<femtometre_unit> femtometre_quantity;
360  typedef quantity<picometre_unit> picometre_quantity;
362  typedef quantity<nanometre_unit> nanometre_quantity;
364  typedef quantity<micrometre_unit> micrometre_quantity;
366  typedef quantity<millimetre_unit> millimetre_quantity;
368  typedef quantity<centimetre_unit> centimetre_quantity;
370  typedef quantity<decimetre_unit> decimetre_quantity;
372  typedef quantity<metre_unit> metre_quantity;
374  typedef quantity<dekametre_unit> dekametre_quantity;
376  typedef quantity<decametre_unit> decametre_quantity;
378  typedef quantity<hectometre_unit> hectometre_quantity;
380  typedef quantity<kilometre_unit> kilometre_quantity;
382  typedef quantity<megametre_unit> megametre_quantity;
384  typedef quantity<gigametre_unit> gigametre_quantity;
386  typedef quantity<terametre_unit> terametre_quantity;
388  typedef quantity<petametre_unit> petametre_quantity;
390  typedef quantity<exametre_unit> exametre_quantity;
392  typedef quantity<zettametre_unit> zettametre_quantity;
394  typedef quantity<yottametre_unit> yottametre_quantity;
395 
397  typedef quantity<yoctometer_unit> yoctometer_quantity;
399  typedef quantity<zeptometer_unit> zeptometer_quantity;
401  typedef quantity<attometer_unit> attometer_quantity;
403  typedef quantity<femtometer_unit> femtometer_quantity;
405  typedef quantity<picometer_unit> picometer_quantity;
407  typedef quantity<nanometer_unit> nanometer_quantity;
409  typedef quantity<micrometer_unit> micrometer_quantity;
411  typedef quantity<millimeter_unit> millimeter_quantity;
413  typedef quantity<centimeter_unit> centimeter_quantity;
415  typedef quantity<decimeter_unit> decimeter_quantity;
417  typedef quantity<meter_unit> meter_quantity;
419  typedef quantity<dekameter_unit> dekameter_quantity;
421  typedef quantity<decameter_unit> decameter_quantity;
423  typedef quantity<hectometer_unit> hectometer_quantity;
425  typedef quantity<kilometer_unit> kilometer_quantity;
427  typedef quantity<megameter_unit> megameter_quantity;
429  typedef quantity<gigameter_unit> gigameter_quantity;
431  typedef quantity<terameter_unit> terameter_quantity;
433  typedef quantity<petameter_unit> petameter_quantity;
435  typedef quantity<exameter_unit> exameter_quantity;
437  typedef quantity<zettameter_unit> zettameter_quantity;
439  typedef quantity<yottameter_unit> yottameter_quantity;
440 
442  typedef boost::units::metric::angstrom_base_unit::unit_type angstrom_unit;
444  BOOST_UNITS_STATIC_CONSTANT(angstrom, angstrom_unit);
446  BOOST_UNITS_STATIC_CONSTANT(angstroms, angstrom_unit);
448  typedef quantity<angstrom_unit> angstrom_quantity;
449 
451  typedef boost::units::imperial::thou_base_unit::unit_type thou_unit;
453  BOOST_UNITS_STATIC_CONSTANT(thou, thou_unit);
455  BOOST_UNITS_STATIC_CONSTANT(thous, thou_unit);
457  typedef quantity<thou_unit> thou_quantity;
458 
460  typedef scaled_base_unit<boost::units::imperial::inch_base_unit, scale<12, static_rational<-1> > > line_base_unit;
462  typedef line_base_unit::unit_type line_unit;
464  BOOST_UNITS_STATIC_CONSTANT(line, line_unit);
466  BOOST_UNITS_STATIC_CONSTANT(lines, line_unit);
468  typedef quantity<line_unit> line_quantity;
469 
471  typedef boost::units::imperial::inch_base_unit::unit_type inch_unit;
473  BOOST_UNITS_STATIC_CONSTANT(inch, inch_unit);
475  BOOST_UNITS_STATIC_CONSTANT(inches, inch_unit);
477  typedef quantity<inch_unit> inch_quantity;
478 
480  typedef boost::units::imperial::foot_base_unit::unit_type foot_unit;
482  BOOST_UNITS_STATIC_CONSTANT(foot, foot_unit);
484  BOOST_UNITS_STATIC_CONSTANT(feet, foot_unit);
486  typedef quantity<foot_unit> foot_quantity;
487 
489  typedef boost::units::imperial::yard_base_unit::unit_type yard_unit;
491  BOOST_UNITS_STATIC_CONSTANT(yard, yard_unit);
493  BOOST_UNITS_STATIC_CONSTANT(yards, yard_unit);
495  typedef quantity<yard_unit> yard_quantity;
496 
498  typedef boost::units::imperial::mile_base_unit::unit_type mile_unit;
500  BOOST_UNITS_STATIC_CONSTANT(mile, mile_unit);
502  BOOST_UNITS_STATIC_CONSTANT(miles, mile_unit);
504  typedef quantity<mile_unit> mile_quantity;
505 
507  typedef boost::units::astronomical::astronomical_unit_base_unit::unit_type astronomical_unit_unit;
509  BOOST_UNITS_STATIC_CONSTANT(astronomical_unit, astronomical_unit_unit);
511  BOOST_UNITS_STATIC_CONSTANT(astronomical_units, astronomical_unit_unit);
513  typedef quantity<astronomical_unit_unit> astronomical_unit_quantity;
514 
516  typedef boost::units::astronomical::light_year_base_unit::unit_type light_year_unit;
518  BOOST_UNITS_STATIC_CONSTANT(light_year, light_year_unit);
520  BOOST_UNITS_STATIC_CONSTANT(light_years, light_year_unit);
522  typedef quantity<light_year_unit> light_year_quantity;
523 
525  typedef boost::units::astronomical::parsec_base_unit::unit_type parsec_unit;
527  BOOST_UNITS_STATIC_CONSTANT(parsec, parsec_unit);
529  BOOST_UNITS_STATIC_CONSTANT(parsecs, parsec_unit);
531  typedef quantity<parsec_unit> parsec_quantity;
532 
534  typedef scaled_base_unit<boost::units::imperial::inch_base_unit, scale<72, static_rational<-1> > > point_base_unit;
536  typedef point_base_unit::unit_type point_unit;
538  BOOST_UNITS_STATIC_CONSTANT(point, point_unit);
540  BOOST_UNITS_STATIC_CONSTANT(points, point_unit);
542  typedef quantity<point_unit> point_quantity;
543 
545  struct pixel_base_unit : boost::units::base_unit<pixel_base_unit,
546  boost::units::length_dimension, 1> { };
548  typedef boost::units::make_system<
549  pixel_base_unit>::type pixel_system;
551  typedef boost::units::unit<boost::units::length_dimension, pixel_system> pixel_unit;
553  BOOST_UNITS_STATIC_CONSTANT(pixel, pixel_unit);
555  BOOST_UNITS_STATIC_CONSTANT(pixels, pixel_unit);
557  typedef quantity<pixel_unit> pixel_quantity;
558 
560  struct reference_frame_base_unit : boost::units::base_unit<reference_frame_base_unit,
561  boost::units::length_dimension, 2> { };
563  typedef boost::units::make_system<
564  reference_frame_base_unit>::type reference_frame_system;
566  typedef boost::units::unit<boost::units::length_dimension, reference_frame_system> reference_frame_unit;
568  BOOST_UNITS_STATIC_CONSTANT(reference_frame, reference_frame_unit);
570  typedef quantity<reference_frame_unit> reference_frame_quantity;
571 
572  }
573  }
574 }
575 
576 namespace boost
577 {
578  namespace units
579  {
580 
582  template<> struct base_unit_info<ome::common::units::line_base_unit>
583  {
585  static std::string name() { return "line"; }
587  static std::string symbol() { return "li"; }
588  };
589 
591  template<> struct base_unit_info<ome::common::units::point_base_unit>
592  {
594  static std::string name() { return "point"; }
596  static std::string symbol() { return "pt"; }
597  };
598 
600  template<> struct base_unit_info<ome::common::units::pixel_base_unit>
601  {
603  static std::string name() { return "pixel"; }
605  static std::string symbol() { return "px"; }
606  };
607 
609  template<> struct base_unit_info<ome::common::units::reference_frame_base_unit>
610  {
612  static std::string name() { return "reference frame"; }
614  static std::string symbol() { return "r.f."; }
615  };
616 
617  }
618 }
619 
620 #endif // OME_COMMON_UNITS_LENGTH_H
621 
622 /*
623  * Local Variables:
624  * mode:C++
625  * End:
626  */
static std::string name()
Unit name.
Definition: length.h:612
Definition: length.h:576
static std::string symbol()
Unit symbol.
Definition: length.h:614
Base unit for pixel length.
Definition: length.h:545
Base unit for reference frame.
Definition: length.h:560
static std::string symbol()
Unit symbol.
Definition: length.h:605
Open Microscopy Environment C++ implementation.
Definition: CoreMetadata.cpp:40
static std::string symbol()
Unit symbol.
Definition: length.h:596
static std::string symbol()
Unit symbol.
Definition: length.h:587
static std::string name()
Unit name.
Definition: length.h:603
static std::string name()
Unit name.
Definition: length.h:585
static std::string name()
Unit name.
Definition: length.h:594