38 #ifndef OME_FILES_VARIANTPIXELBUFFER_H 39 #define OME_FILES_VARIANTPIXELBUFFER_H 43 #include <ome/files/PixelBuffer.h> 44 #include <ome/files/PixelProperties.h> 95 typedef boost::mpl::vector<PixelProperties<::ome::xml::model::enums::PixelType::INT8>,
104 typedef boost::mpl::vector< PixelProperties<::ome::xml::model::enums::PixelType::FLOAT>,
118 typedef std::shared_ptr<PixelBuffer<typename T::std_type>>
type;
128 typedef boost::mpl::insert_range<empty_types, boost::mpl::end<empty_types>::type, pixel_buffer_types_view>
::type pixel_buffer_types;
141 typedef std::array<boost::multi_array_types::index, PixelBufferBase::dimensions>
indices_type;
173 template<
class ExtentList>
244 const variant_buffer_type&
262 template<
class T,
class ExtentList>
263 static variant_buffer_type
265 const storage_order_type& storage,
283 static variant_buffer_type
285 const storage_order_type& storage,
295 # pragma GCC diagnostic push 296 # pragma GCC diagnostic ignored "-Wswitch-default" 299 #define OME_FILES_VARIANTPIXELBUFFER_CREATEEXTENTS_CASE(maR, maProperty, maType) \ 300 case ::ome::xml::model::enums::PixelType::maType: \ 301 buf = makeBuffer<PixelProperties<::ome::xml::model::enums::PixelType::maType>::std_type>(extents, storage, pixeltype); \ 315 template<
class ExtentList>
316 static variant_buffer_type
321 variant_buffer_type buf;
325 BOOST_PP_SEQ_FOR_EACH(OME_FILES_VARIANTPIXELBUFFER_CREATEEXTENTS_CASE, size, OME_XML_MODEL_ENUMS_PIXELTYPE_VALUES);
331 #undef OME_FILES_VARIANTPIXELBUFFER_CREATEEXTENTS_CASE 333 #define OME_FILES_VARIANTPIXELBUFFER_CREATERANGE_CASE(maR, maProperty, maType) \ 334 case ::ome::xml::model::enums::PixelType::maType: \ 335 buf = makeBuffer<PixelProperties<::ome::xml::model::enums::PixelType::maType>::std_type>(range, storage, pixeltype); \ 349 static variant_buffer_type
354 variant_buffer_type buf;
358 BOOST_PP_SEQ_FOR_EACH(OME_FILES_VARIANTPIXELBUFFER_CREATERANGE_CASE, size, OME_XML_MODEL_ENUMS_PIXELTYPE_VALUES);
364 #undef OME_FILES_VARIANTPIXELBUFFER_CREATERANGE_CASE 367 # pragma GCC diagnostic pop 381 template<
class ExtentList>
451 const boost::multi_array_types::index *
462 const boost::multi_array_types::index *
475 template <
typename T>
484 const storage_order_type&
617 template <
typename InputIterator>
619 assign(InputIterator begin,
632 template<
class charT,
class traits>
634 read(std::basic_istream<charT,traits>& stream);
646 template<
class charT,
class traits>
648 write(std::basic_ostream<charT,traits>& stream)
const;
673 throw std::runtime_error(
"Null pixel type");
683 template <
typename U>
685 operator() (U& )
const 687 throw std::runtime_error(
"Unsupported pixel type conversion for buffer");
706 throw std::runtime_error(
"Null pixel type");
716 template <
typename U>
718 operator() (U& )
const 720 throw std::runtime_error(
"Unsupported pixel type conversion for buffer");
725 template <
typename InputIterator>
740 begin(begin), end(end)
750 operator() (std::shared_ptr<
PixelBuffer<
typename std::iterator_traits<InputIterator>::value_type>>& v)
const 753 throw std::runtime_error(
"Null pixel type");
754 v->array().assign(begin, end);
762 template <
typename T>
764 operator() (T& )
const 766 throw std::runtime_error(
"Unsupported pixel type conversion for assignment");
771 template<
class charT,
class traits>
775 std::basic_istream<charT,traits>&
stream;
791 template <
typename T>
793 operator() (T& v)
const 796 throw std::runtime_error(
"Null pixel type");
802 template<
class charT,
class traits>
806 std::basic_ostream<charT,traits>&
stream;
822 template <
typename T>
824 operator() (
const T& v)
const 827 throw std::runtime_error(
"Null pixel type");
862 std::array<VariantPixelBuffer::size_type, 9> dest_shape;
875 dest.
setBuffer(dest_shape, v->pixelType(), order);
877 T& destbuf = boost::get<T>(dest.
vbuffer());
879 typename boost::multi_array_types::index_gen indices;
880 typedef boost::multi_array_types::index_range range;
881 destbuf->array() = v->array()[boost::indices[range()][range()][range()][range()][range()][range(subC,subC+1)][range()][range()][range()]];
914 T& destbuf = boost::get<T>(dest.
vbuffer());
916 typename boost::multi_array_types::index_gen indices;
917 typedef boost::multi_array_types::index_range range;
918 destbuf->array()[boost::indices[range()][range()][range()][range()][range()][range(subC,subC+1)][range()][range()][range()]] = v->array();
930 return boost::apply_visitor(v, buffer)->array();
939 return boost::apply_visitor(v, buffer)->array();
947 return boost::apply_visitor(v, buffer)->data();
955 return boost::apply_visitor(v, buffer)->data();
963 return boost::apply_visitor(v, buffer)->origin();
973 template <
typename InputIterator>
979 boost::apply_visitor(v, buffer);
982 template<
class charT,
class traits>
987 boost::apply_visitor(v, buffer);
990 template<
class charT,
class traits>
995 boost::apply_visitor(v, buffer);
1011 template<
class charT,
class traits>
1012 inline std::basic_istream<charT,traits>&
1013 operator>> (std::basic_istream<charT,traits>& is,
1027 template<
class charT,
class traits>
1028 inline std::basic_ostream<charT,traits>&
1029 operator<< (std::basic_ostream<charT,traits>& os,
1030 const ::ome::files::VariantPixelBuffer& buf)
1038 #endif // OME_FILES_VARIANTPIXELBUFFER_H VariantPixelBufferWriteVisitor(std::basic_ostream< charT, traits > &stream)
Constructor.
Definition: VariantPixelBuffer.h:813
boost::mpl::joint_view< integer_pixel_types, float_pixel_types >::type basic_pixel_types_view
Aggregate view of all numeric types.
Definition: VariantPixelBuffer.h:111
boost::multi_array_ref< value_type, dimensions > array_ref_type
Type for multi-dimensional pixel array view referencing external data.
Definition: PixelBuffer.h:246
VariantPixelBuffer & dest
Destination pixel buffer.
Definition: VariantPixelBuffer.h:889
void read(std::basic_istream< charT, traits > &stream)
Read raw pixel data from a stream in physical storage order.
Definition: VariantPixelBuffer.h:984
VariantPixelBuffer(const ExtentList &extents, ::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
Construct from extents (internal storage).
Definition: VariantPixelBuffer.h:175
Properties of BIT pixels.
Definition: PixelProperties.h:299
InputIterator end
Input end.
Definition: VariantPixelBuffer.h:731
Buffer for a specific pixel type.
Definition: PixelBuffer.h:235
void setBuffer(const range_type &range, ::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
Set the buffer from ranges (internal storage).
Definition: VariantPixelBuffer.h:401
boost::mpl::vector empty_types
Empty vector placeholder.
Definition: VariantPixelBuffer.h:125
std::size_t dimension_size_type
Size type for image dimensions.
Definition: Types.h:58
const storage_order_type & storage_order() const
Get the array storage order.
Definition: VariantPixelBuffer.cpp:375
static variant_buffer_type makeBuffer(const range_type &range, const storage_order_type &storage, ::ome::xml::model::enums::PixelType pixeltype)
Create buffer from ranges (helper).
Definition: VariantPixelBuffer.h:284
virtual ~VariantPixelBuffer()
Destructor.
Definition: VariantPixelBuffer.h:225
InputIterator begin
Input start.
Definition: VariantPixelBuffer.h:729
EndianType endianType() const
Get the endianness of the pixel type stored in the buffer.
Definition: VariantPixelBuffer.cpp:389
VariantPixelBufferReadVisitor(std::basic_istream< charT, traits > &stream)
Constructor.
Definition: VariantPixelBuffer.h:782
void setBuffer(const ExtentList &extents, ::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
Set the buffer from extents (helper).
Definition: VariantPixelBuffer.h:383
Map a given PixelPropertiesType enum to the corresponding language types.
Definition: PixelProperties.h:60
PixelBuffer< T >::array_ref_type & array()
Get the pixel data.
Definition: VariantPixelBuffer.h:927
bool valid() const
Check the buffer validity.
Definition: VariantPixelBuffer.cpp:326
variant_buffer_type & vbuffer()
Get a reference to the variant buffer.
Definition: VariantPixelBuffer.h:234
VariantPixelBuffer & dest
Destination pixel buffer.
Definition: VariantPixelBuffer.h:836
const T * origin() const
Get the origin of the array.
Definition: VariantPixelBuffer.h:960
std::basic_ostream< charT, traits > & stream
The output stream.
Definition: VariantPixelBuffer.h:806
Properties of COMPLEXFLOAT pixels.
Definition: PixelProperties.h:334
VariantPixelBuffer()
Default constructor.
Definition: VariantPixelBuffer.h:158
dimension_size_type subC
Subchannel to copy.
Definition: VariantPixelBuffer.h:838
::ome::xml::model::enums::PixelType pixelType() const
Get the type of pixels stored in the buffer.
Definition: VariantPixelBuffer.cpp:382
boost::mpl::vector< PixelProperties<::ome::xml::model::enums::PixelType::INT8 >, PixelProperties<::ome::xml::model::enums::PixelType::INT16 >, PixelProperties<::ome::xml::model::enums::PixelType::INT32 >, PixelProperties<::ome::xml::model::enums::PixelType::UINT8 >, PixelProperties<::ome::xml::model::enums::PixelType::UINT16 >, PixelProperties<::ome::xml::model::enums::PixelType::UINT32 >, PixelProperties<::ome::xml::model::enums::PixelType::BIT > > integer_pixel_types
Integer pixel types.
Definition: VariantPixelBuffer.h:101
boost::mpl::transform_view< basic_pixel_types_view, make_buffer< boost::mpl::_1 > >::type pixel_buffer_types_view
Aggregate view of all buffer types.
Definition: VariantPixelBuffer.h:122
Properties of UINT16 pixels.
Definition: PixelProperties.h:207
Convert T into a buffer.
Definition: VariantPixelBuffer.h:115
dimension_size_type subC
Subchannel to copy.
Definition: VariantPixelBuffer.h:891
Properties of INT32 pixels.
Definition: PixelProperties.h:161
VariantPixelBuffer & operator=(const VariantPixelBuffer &rhs)
Assign a pixel buffer.
Definition: VariantPixelBuffer.cpp:410
Open Microscopy Environment C++.
Copy a single subchannel from a PixelBuffer.
Definition: VariantPixelBuffer.h:833
const variant_buffer_type & vbuffer() const
Get a reference to the variant buffer.
Definition: VariantPixelBuffer.h:245
boost::general_storage_order< dimensions > storage_order_type
Storage ordering type for controlling pixel memory layout.
Definition: PixelBuffer.h:120
Native endian.
Definition: Types.h:71
static storage_order_type make_storage_order(ome::xml::model::enums::DimensionOrder order, bool interleaved)
Generate storage ordering for a given dimension order.
Definition: PixelBuffer.cpp:54
MergeSubchannelVisitor(VariantPixelBuffer &dest, dimension_size_type subC)
Constructor.
Definition: VariantPixelBuffer.h:899
void operator()(const T &v)
Copy subchannel.
Definition: VariantPixelBuffer.h:859
static variant_buffer_type createBuffer(const range_type &range, ::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
Create buffer from ranges (helper).
Definition: VariantPixelBuffer.h:350
boost::mpl::insert_range< empty_types, boost::mpl::end< empty_types >::type, pixel_buffer_types_view >::type pixel_buffer_types
List of all pixel buffer types.
Definition: VariantPixelBuffer.h:128
Read data into a PixelBuffer.
Definition: VariantPixelBuffer.h:772
Merge a single subchannel into a PixelBuffer.
Definition: VariantPixelBuffer.h:886
VariantPixelBuffer(std::shared_ptr< PixelBuffer< T >> &buffer)
Construct from existing pixel buffer.
Definition: VariantPixelBuffer.h:218
EndianType
Endianness.
Definition: Types.h:67
PixelProperties<::ome::xml::model::enums::PixelType::UINT8 >::std_type raw_type
Raw pixel type used in public interfaces.
Definition: VariantPixelBuffer.h:135
Properties of INT16 pixels.
Definition: PixelProperties.h:138
CopySubchannelVisitor(VariantPixelBuffer &dest, dimension_size_type subC)
Constructor.
Definition: VariantPixelBuffer.h:846
bool operator!=(const VariantPixelBuffer &rhs) const
Compare a pixel buffer for inequality.
Definition: VariantPixelBuffer.cpp:423
Find a PixelBuffer data array of a specific pixel type.
Definition: VariantPixelBuffer.h:693
VariantPixelBufferAssignVisitor(InputIterator begin, InputIterator end)
Constructor.
Definition: VariantPixelBuffer.h:739
boost::mpl::vector< PixelProperties<::ome::xml::model::enums::PixelType::FLOAT >, PixelProperties<::ome::xml::model::enums::PixelType::DOUBLE >, PixelProperties<::ome::xml::model::enums::PixelType::COMPLEXFLOAT >, PixelProperties<::ome::xml::model::enums::PixelType::COMPLEXDOUBLE > > float_pixel_types
Floating-point pixel types.
Definition: VariantPixelBuffer.h:107
size_type num_dimensions() const
Get the number of dimensions in the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:347
bool managed() const
Check if the buffer is internally managed.
Definition: VariantPixelBuffer.cpp:333
void operator()(const T &v)
Merge subchannel.
Definition: VariantPixelBuffer.h:912
Assign a PixelBuffer from an input iterator.
Definition: VariantPixelBuffer.h:726
void write(std::basic_ostream< charT, traits > &stream) const
Write raw pixel data to a stream in physical storage order.
Definition: VariantPixelBuffer.h:992
variant_buffer_type buffer
Pixel storage.
Definition: VariantPixelBuffer.h:652
Write data from a PixelBuffer.
Definition: VariantPixelBuffer.h:803
std::basic_istream< charT, traits > & stream
The input stream.
Definition: VariantPixelBuffer.h:775
VariantPixelBuffer(const range_type &range, ::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
Construct from ranges (internal storage).
Definition: VariantPixelBuffer.h:193
Properties of UINT32 pixels.
Definition: PixelProperties.h:230
boost::detail::multi_array::extent_gen< dimensions > range_type
Extent range type.
Definition: PixelBuffer.h:123
static variant_buffer_type createBuffer(const ExtentList &extents, ::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
Create buffer from extents (internal storage).
Definition: VariantPixelBuffer.h:317
const boost::multi_array_types::index * index_bases() const
Get the index bases of the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:368
Find a PixelBuffer data array of a specific pixel type.
Definition: VariantPixelBuffer.h:660
PixelBufferBase::range_type range_type
Extent range type.
Definition: VariantPixelBuffer.h:147
static const uint16_t dimensions
Total number of supported dimensions.
Definition: PixelBuffer.h:107
const size_type * shape() const
Get the shape of the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:354
bool operator==(const VariantPixelBuffer &rhs) const
Compare a pixel buffer for equality.
Definition: VariantPixelBuffer.cpp:417
size_type num_elements() const
Get the number of pixel elements in the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:340
const boost::multi_array_types::index * strides() const
Get the strides of the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:361
Properties of UINT8 pixels.
Definition: PixelProperties.h:184
static variant_buffer_type makeBuffer(const ExtentList &extents, const storage_order_type &storage, ::ome::xml::model::enums::PixelType pixeltype)
Create buffer from extents (helper).
Definition: VariantPixelBuffer.h:264
static storage_order_type default_storage_order()
Generate default storage ordering.
Definition: PixelBuffer.cpp:133
raw_type * data()
Get raw buffered data.
Definition: VariantPixelBuffer.cpp:396
std::shared_ptr< PixelBuffer< typename T::std_type > > type
Buffer type.
Definition: VariantPixelBuffer.h:118
Buffer for all pixel types.
Definition: VariantPixelBuffer.h:75
Properties of DOUBLE pixels.
Definition: PixelProperties.h:276
boost::multi_array_types::size_type size_type
Size type.
Definition: VariantPixelBuffer.h:138
void assign(InputIterator begin, InputIterator end)
Assign pixel values.
Definition: VariantPixelBuffer.h:975
boost::make_variant_over< pixel_buffer_types >::type variant_buffer_type
Buffer type, allowing assignment of all buffer types.
Definition: VariantPixelBuffer.h:132
PixelBufferBase::storage_order_type storage_order_type
Storage ordering type for controlling pixel memory layout.
Definition: VariantPixelBuffer.h:144
std::array< boost::multi_array_types::index, PixelBufferBase::dimensions > indices_type
Type used to index all dimensions in public interfaces.
Definition: VariantPixelBuffer.h:141
Properties of COMPLEXDOUBLE pixels.
Definition: PixelProperties.h:357
Logical sub-channel (typically used for RGB channel sub-components) (S).
Definition: PixelBuffer.h:85