35template <
int num_dimensions,
class OStreamT,
class elemT,
class OutputType,
class ScaleT>
37write_data_with_fixed_scale_factor_help(is_not_1d,
39 const ArrayType<num_dimensions, elemT>& data,
40 NumericInfo<OutputType> output_type,
41 const ScaleT scale_factor,
42 const ByteOrder byte_order,
43 const bool can_corrupt_data)
45 for (
auto iter = data.begin(); iter != data.end(); ++iter)
50 return Succeeded::yes;
54template <
class OStreamT,
class elemT,
class OutputType,
class ScaleT>
56write_data_with_fixed_scale_factor_help(is_1d,
58 const ArrayType<1, elemT>& data,
59 NumericInfo<OutputType>,
60 const ScaleT scale_factor,
61 const ByteOrder byte_order,
62 const bool can_corrupt_data)
64 if (
typeid(OutputType) !=
typeid(elemT) || scale_factor != 1)
66 ScaleT new_scale_factor = scale_factor;
67 auto data_tmp =
convert_array(new_scale_factor, data, NumericInfo<OutputType>());
68 if (std::fabs(new_scale_factor - scale_factor) > scale_factor * .001)
80template <
int num_dimensions,
class OStreamT,
class elemT,
class OutputType,
class ScaleT>
85 const ScaleT scale_factor,
87 const bool can_corrupt_data)
89 return detail::write_data_with_fixed_scale_factor_help(
93template <
int num_dimensions,
class OStreamT,
class elemT,
class OutputType,
class ScaleT>
100 const bool can_corrupt_data)
106template <
int num_dimensions,
class OStreamT,
class elemT>
113template <
int num_dimensions,
class OStreamT,
class elemT,
class ScaleT>
120 const bool can_corrupt_data)
127 return write_data(s, data, byte_order, can_corrupt_data);
132#define CASE(NUMERICTYPE) \
134 return write_data(s, data, NumericInfo<typename TypeForNumericType<NUMERICTYPE>::type>(), scale, byte_order, can_corrupt_data)
137 CASE(NumericType::SCHAR);
138 CASE(NumericType::UCHAR);
139 CASE(NumericType::SHORT);
140 CASE(NumericType::USHORT);
141 CASE(NumericType::INT);
142 CASE(NumericType::UINT);
143 CASE(NumericType::LONG);
144 CASE(NumericType::ULONG);
145 CASE(NumericType::FLOAT);
146 CASE(NumericType::DOUBLE);
149 warning(
"write_data : type not yet supported\n, at line %d in file %s", __LINE__, __FILE__);
150 return Succeeded::no;
defines the stir::Array class for multi-dimensional (numeric) arrays
This file declares the stir::ByteOrder class.
This file declares the class stir::NumericInfo.
This file declares the stir::NumericType class.
Declaration of class stir::Succeeded.
This class provides member functions to find out what byte-order your machine is and to swap numbers.
Definition ByteOrder.h:100
class NumericInfo<NUMBER> defines properties for the type NUMBER.
Definition NumericInfo.h:68
provides names for some numeric types and methods for finding their properties.
Definition NumericType.h:55
This file declares the stir::convert_array functions. This is a function to convert stir::Array objec...
Succeeded write_data_1d(std::ostream &s, const Array< num_dimensions, elemT > &data, const ByteOrder byte_order, const bool can_corrupt_data)
This is an internal function called by write_data(). It does the actual writing to std::ostream.
Definition write_data_1d.inl:33
Succeeded write_data_with_fixed_scale_factor(OStreamT &s, const ArrayType< num_dimensions, elemT > &data, NumericInfo< OutputType > output_type, const ScaleT scale_factor, const ByteOrder byte_order=ByteOrder::native, const bool can_corrupt_data=false)
Write the data of an Array to file as a different type but using a given scale factor.
Definition write_data.inl:82
Succeeded write_data(OStreamT &s, const ArrayType< num_dimensions, elemT > &data, const ByteOrder byte_order=ByteOrder::native, const bool can_corrupt_data=false)
Write the data of an Array to file.
Definition write_data.inl:108
void find_scale_factor(scaleT &scale_factor, const Array< num_dimensions, T1 > &data_in, const NumericInfo< T2 > info_for_out_type)
A function that finds a scale factor to use when converting data to a new type.
Definition convert_array.inl:28
Array< num_dimensions, T2 > convert_array(scaleT &scale_factor, const Array< num_dimensions, T1 > &data_in, const NumericInfo< T2 > info2)
A function that returns a new Array (of the same dimension) with elements of type T2.
Definition convert_array.inl:35
void warning(const char *const s,...)
Print warning with format string a la printf.
Definition warning.cxx:41
Array< num_dimensions, elemT > ArrayType
type alias for future-proofing for "large" rectangular arrays
Definition ArrayFwd.h:25
a templated class used to check if it's a 1D array or not This class only exists to allow a work-arou...
Definition test_if_1d.h:71
Classes for use in implementation of stir::Array, stir::BasicCoordinate etc to test if it's a 1D arra...
Declaration of stir::warning()
Declaration of stir::write_data_1d() functions for writing 1D stir::Array objects to file.