STIR  6.2.0
Modules | Files | Functions
Collaboration diagram for Functions that implement IO for Array objects:

Modules

 Implementation details for functions that implement IO for Array objects
 

Files

file  read_data.h
 declarations of stir::read_data() functions for reading Arrays from file
 
file  read_data.inl
 Implementation of stir::read_data() functions for reading stir::Array's from file.
 
file  write_data.h
 declarations of stir::write_data() functions for writing Arrays to file
 
file  write_data.inl
 Implementation of stir::write_data() functions for writing stir::Array's to file.
 

Functions

template<int num_dimensions, class IStreamT , class elemT >
Succeeded stir::read_data (IStreamT &s, Array< num_dimensions, elemT > &data, const ByteOrder byte_order=ByteOrder::native)
 Read the data of an Array from file. More...
 
template<int num_dimensions, class IStreamT , class elemT , class InputType , class ScaleT >
Succeeded stir::read_data (IStreamT &s, Array< num_dimensions, elemT > &data, NumericInfo< InputType > input_type, ScaleT &scale_factor, const ByteOrder byte_order=ByteOrder::native)
 Read the data of an Array from file as a different type. More...
 
template<int num_dimensions, class IStreamT , class elemT , class ScaleT >
Succeeded stir::read_data (IStreamT &s, Array< num_dimensions, elemT > &data, NumericType type, ScaleT &scale, const ByteOrder byte_order=ByteOrder::native)
 Read the data of an Array from file as a different type. More...
 
template<int num_dimensions, class OStreamT , class elemT >
Succeeded stir::write_data (OStreamT &s, const Array< num_dimensions, elemT > &data, const ByteOrder byte_order=ByteOrder::native, const bool can_corrupt_data=false)
 Write the data of an Array to file. More...
 
template<int num_dimensions, class OStreamT , class elemT , class OutputType , class ScaleT >
Succeeded stir::write_data (OStreamT &s, const Array< num_dimensions, elemT > &data, NumericInfo< OutputType > output_type, 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. More...
 
template<int num_dimensions, class OStreamT , class elemT , class OutputType , class ScaleT >
Succeeded stir::write_data_with_fixed_scale_factor (OStreamT &s, const Array< 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. More...
 
template<int num_dimensions, class OStreamT , class elemT , class ScaleT >
Succeeded stir::write_data (OStreamT &s, const Array< num_dimensions, elemT > &data, NumericType type, ScaleT &scale, const ByteOrder byte_order=ByteOrder::native, const bool can_corrupt_data=false)
 Write the data of an Array to file as a different type. More...
 

Detailed Description

Function Documentation

◆ read_data() [1/3]

template<int num_dimensions, class IStreamT , class elemT >
Succeeded stir::read_data ( IStreamT &  s,
Array< num_dimensions, elemT > &  data,
const ByteOrder  byte_order = ByteOrder::native 
)
inline

Read the data of an Array from file.

Only the data will be written, not the dimensions, start indices, nor byte-order. Hence, this should only used for low-level IO.

IStreamT is supposed to be stream or file type (see implementations for read_data_1d()).

Warning
When an error occurs, the function immediately returns. However, the data might have been partially read from s.

Referenced by stir::ProjDataFromStream::get_bin_value(), stir::ProjDataFromStream::get_segment_by_sinogram(), stir::ProjDataFromStream::get_segment_by_view(), stir::ProjDataFromStream::get_sinogram(), stir::ProjDataFromStream::get_viewgram(), stir::VoxelsOnCartesianGrid< elemT >::grow_z_range(), stir::read_data(), stir::ProjMatrixByBinFromFile::set_up(), and stir::ecat::BinNormalisationFromECAT8::set_up().

◆ read_data() [2/3]

template<int num_dimensions, class IStreamT , class elemT , class InputType , class ScaleT >
Succeeded stir::read_data ( IStreamT &  s,
Array< num_dimensions, elemT > &  data,
NumericInfo< InputType >  input_type,
ScaleT &  scale_factor,
const ByteOrder  byte_order = ByteOrder::native 
)
inline

Read the data of an Array from file as a different type.

This function essentially first calls convert_data() to construct an array with elements of type InputType, and then calls read_data(IStreamT&, const Array<num_dimensions,elemT>&, const ByteOrder, const bool).

See also
read_data(IStreamT&, const Items relating to vectors and (multi-dimensional) arrays&, const ByteOrder, const bool)
find_scale_factor() for the meaning of scale_factor.

References stir::convert_array(), and stir::read_data().

◆ read_data() [3/3]

template<int num_dimensions, class IStreamT , class elemT , class ScaleT >
Succeeded stir::read_data ( IStreamT &  s,
Array< num_dimensions, elemT > &  data,
NumericType  type,
ScaleT &  scale,
const ByteOrder  byte_order = ByteOrder::native 
)
inline

Read the data of an Array from file as a different type.

See also
read_data(IStreamT&, const Items relating to vectors and (multi-dimensional) arrays&, NumericInfo<InputType>, ScaleT&, const ByteOrder, const bool) The only difference is that the input type is now specified using NumericType.

References stir::NumericType::id.

◆ write_data() [1/3]

template<int num_dimensions, class OStreamT , class elemT >
Succeeded stir::write_data ( OStreamT &  s,
const Array< num_dimensions, elemT > &  data,
const ByteOrder  byte_order = ByteOrder::native,
const bool  can_corrupt_data = false 
)
inline

Write the data of an Array to file.

Only the data will be written, not the dimensions, start indices, nor byte-order. Hence, this should only used for low-level IO.

OStreamT is supposed to be stream or file type (see implementations for detail::write_data_1d()).

If can_corrupt_data = true, the data in the array can be byte-swapped after writing, and hence should no longer be used. This is useful for saving (a little bit of) time.

Warning
When an error occurs, the function immediately returns. However, the data might have been partially written to s.
For deficient compilers (e.g. VC 6.0), work-arounds are necessary to get this to compile. In particular, this function is then not templated in num_dimensions, but explicitly defined for a few dimensions (see the source).

References stir::write_data_with_fixed_scale_factor().

Referenced by stir::ProjDataFromStream::set_bin_value(), stir::ProjDataFromStream::set_segment(), stir::ProjDataFromStream::set_sinogram(), stir::ColsherFilter::set_up(), and stir::write_data().

◆ write_data() [2/3]

template<int num_dimensions, class OStreamT , class elemT , class OutputType , class ScaleT >
Succeeded stir::write_data ( OStreamT &  s,
const Array< num_dimensions, elemT > &  data,
NumericInfo< OutputType >  output_type,
ScaleT &  scale_factor,
const ByteOrder  byte_order = ByteOrder::native,
const bool  can_corrupt_data = false 
)
inline

Write the data of an Array to file as a different type.

This function essentially first calls convert_data() to construct an array with elements of type OutputType, and then calls write_data(OstreamT&, const Array<num_dimensions,elemT>&, const ByteOrder, const bool).

See also
write_data(OstreamT&, const Items relating to vectors and (multi-dimensional) arrays&, const ByteOrder, const bool)
find_scale_factor() for the meaning of scale_factor.
Warning
For deficient compilers (e.g. VC 6.0), work-arounds are necessary to get this to compile. In particular, this function is then not templated in num_dimensions, but explicitly defined for a few dimensions (see the source).

References stir::find_scale_factor(), and stir::write_data_with_fixed_scale_factor().

◆ write_data_with_fixed_scale_factor()

template<int num_dimensions, class OStreamT , class elemT , class OutputType , class ScaleT >
Succeeded stir::write_data_with_fixed_scale_factor ( OStreamT &  s,
const Array< num_dimensions, elemT > &  data,
NumericInfo< OutputType >  output_type,
const ScaleT  scale_factor,
const ByteOrder  byte_order = ByteOrder::native,
const bool  can_corrupt_data = false 
)
inline

Write the data of an Array to file as a different type but using a given scale factor.

If scale_factor is such that the data/scale_factor does not fit in the range for OutputType, the writing will fail. However, data might have been partially written to file anyway.

See also
write_data(OStreamT&, const Items relating to vectors and (multi-dimensional) arrays&, NumericInfo<OutputType>, ScaleT&, const ByteOrder, const bool)
Warning
For deficient compilers (e.g. VC 6.0), work-arounds are necessary to get this to compile. In particular, this function is then not templated in num_dimensions, but explicitly defined for a few dimensions (see the source).

Referenced by stir::write_data().

◆ write_data() [3/3]

template<int num_dimensions, class OStreamT , class elemT , class ScaleT >
Succeeded stir::write_data ( OStreamT &  s,
const Array< num_dimensions, elemT > &  data,
NumericType  type,
ScaleT &  scale,
const ByteOrder  byte_order = ByteOrder::native,
const bool  can_corrupt_data = false 
)
inline

Write the data of an Array to file as a different type.

See also
write_data(OStreamT&, const Items relating to vectors and (multi-dimensional) arrays&, NumericInfo<OutputType>, ScaleT&, const ByteOrder, const bool) The only difference is that the output type is now specified using NumericType.
Warning
For deficient compilers (e.g. VC 6.0), work-arounds are necessary to get this to compile. In particular, this function is then not templated in num_dimensions, but explicitly defined for a few dimensions (see the source).

References stir::NumericType::id, and stir::write_data().