Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/buildblock/ProjDataInMemory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,26 @@ ProjDataInMemory::ProjDataInMemory(shared_ptr<const ExamInfo> const& exam_info_s
segment_sequence(ProjData::standard_segment_sequence(*proj_data_info_ptr))
{
this->create_buffer(initialise_with_0);
this->initialise_layout_metadata();
}

ProjDataInMemory::ProjDataInMemory(shared_ptr<const ExamInfo> const& exam_info_sptr,
shared_ptr<const ProjDataInfo> const& proj_data_info_ptr,
Array<1, float>&& buffer_v)
: ProjData(exam_info_sptr, proj_data_info_ptr),
buffer(std::move(buffer_v)),
segment_sequence(ProjData::standard_segment_sequence(*proj_data_info_ptr))
{
if (this->buffer.size_all() != this->size_all())
error("ProjDataInMemory: supplied buffer has wrong size (%d instead of %d)",
static_cast<int>(this->buffer.size_all()),
static_cast<int>(this->size_all()));
this->initialise_layout_metadata();
}

void
ProjDataInMemory::initialise_layout_metadata()
{
int sum = 0;
for (int segment_num = proj_data_info_sptr->get_min_segment_num(); segment_num <= proj_data_info_sptr->get_max_segment_num();
++segment_num)
Expand Down
11 changes: 11 additions & 0 deletions src/include/stir/ProjDataInMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ class ProjDataInMemory : public ProjData
shared_ptr<const ProjDataInfo> const& proj_data_info_ptr,
const bool initialise_with_0 = true);

//! constructor using externally allocated storage
/*!
The supplied buffer must have exactly `size_all()` elements for the
projection-data geometry.
*/
ProjDataInMemory(shared_ptr<const ExamInfo> const& exam_info_sptr,
shared_ptr<const ProjDataInfo> const& proj_data_info_ptr,
Array<1, float>&& buffer);

//! constructor that copies data from another ProjData
ProjDataInMemory(const ProjData& proj_data);

Expand Down Expand Up @@ -281,6 +290,8 @@ class ProjDataInMemory : public ProjData

//! allocates buffer for storing the data. Has to be called by constructors
void create_buffer(const bool initialise_with_0 = false);
//! computes the offset and timing metadata after the geometry is known
void initialise_layout_metadata();
//! offset of the whole 3d sinogram in the stream
std::streamoff offset;
//! offset of a complete non-tof sinogram
Expand Down
Loading