CTL  0.6.1
Computed Tomography Library
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
CTL::ModuleLayout Class Reference

Simple class that holds the layout of a multi module detector. More...

#include <modulelayout.h>

Public Member Functions

 ModuleLayout (uint nbRows=0, uint nbCols=0)
 
int & operator() (uint row, uint col)
 
const int & operator() (uint row, uint col) const
 
uint columns () const
 
uint rows () const
 
uint nbNonEmptyModules () const
 Returns the number of entries that is larger than zero. More...
 
bool isEmpty () const
 
bool hasUniqueIndices () const
 Returns true if all indices in this instance appear at maximum once.
 
int largestModuleIdx () const
 Returns the largest module index in this layout or -1 if the layout is empty.
 
std::vector< uintuniqueIndices () const
 Returns a set (i.e. no repetitions) of all indices appearing in this layout. Does not list negative values (i.e. gaps) if they should appear in the layout.
 

Static Public Member Functions

static ModuleLayout canonicLayout (uint nbRows, uint nbCols, bool rowMajorOrder=true)
 

Private Attributes

uint _rows
 The number of rows in the layout.
 
uint _cols
 The number of columns in the layout.
 
std::vector< int > _layout
 The internal data vector.
 

Detailed Description

Simple class that holds the layout of a multi module detector.

The ModuleLayout class stores the layout of a detector that consists of multiple individual flat panel modules. That means it holds the information about the arrangement of the individual modules on the entire detector unit. For means of simplicity, this is limited to arrangement patterns with a rectangular grid shape.

A ModuleLayout is required if you want to combine projection data of individual modules to a single projection. This can be done using SingleViewData::combined().

To define a layout, the number of rows and columns of the grid need to be specified. Then, for each position on the grid, the index of the flat panel module that is located at that spot must be defined. This information is stored internally in a std::vector<int> with row-major order. Negative module indices can be used to define gaps in the layout (see also SingleViewData::combined()).

For simple arrangements, the convenience factory method canonicLayout() can be used to easily create the corresponding ModuleLayout.

Constructor & Destructor Documentation

◆ ModuleLayout()

CTL::ModuleLayout::ModuleLayout ( uint  nbRows = 0,
uint  nbCols = 0 
)

Constructs a ModuleLayout object for a module arrangement with nbRows rows and nbCols columns. The entire layout is initialized with index -1. Use operator() to assign module indices to the layout positions.

For simple layouts, consider using canonicLayout() for easy construction.

// setting up a linear layout with five modules by hand
ModuleLayout linearLayout(1,5);
for(uint col = 0; col < linearLayout.columns(); ++col)
linearLayout(0, col) = col;
// The resulting layout is: | 0 || 1 || 2 || 3 || 4 |
// The same result can be achieved with canonicLayout(1,5).
// arrange eight modules in a 3x3 square layout that has a gap in the center
ModuleLayout squareLayout(3, 3);
squareLayout(0,0) = 0, squareLayout(0,1) = 1, squareLayout(0,2) = 2; // first row
squareLayout(1,0) = 3; // center row
// squareLayout(1,1); <- this is the gap (already initialized with -1) // center row
squareLayout(1,2) = 4; // center row
squareLayout(2,0) = 5, squareLayout(2,1) = 6, squareLayout(2,2) = 7; // last row
// The resulting layout is:
// | 0 || 1 || 2 |
// -------------
// | 3 || || 4 |
// -------------
// | 5 || 6 || 7 |
See also
canonicLayout().

Member Function Documentation

◆ canonicLayout()

ModuleLayout CTL::ModuleLayout::canonicLayout ( uint  nbRows,
uint  nbCols,
bool  rowMajorOrder = true 
)
static

Constructs and returns a ModuleLayout object for a module arrangement with nbRows rows and nbCols columns. The layout is initialized with increasing module index across the layout. By default, this will be done in row mayor order. To change this behavior to column major order, set rowMajorOrder to false.

// setting up a linear layout (e.g. for cylindrical detectors) with ten modules
for(uint col = 0; col < linearLayout.columns(); ++col)
std::cout << linearLayout(0, col) << " "; // output: 0 1 2 3 4 5 6 7 8 9
// setting up a square layout with 3x3 modules in column major order.
ModuleLayout squareLayout = ModuleLayout::canonicLayout(3, 3, false);
for(uint row = 0; row < squareLayout.rows(); ++row){ // output:
for(uint col = 0; col < squareLayout.columns(); ++col) // 0 3 6
std::cout << squareLayout(row, col) << " "; // 1 4 7
std::cout << std::endl; // 2 5 8
}

◆ columns()

uint CTL::ModuleLayout::columns ( ) const

Returns the number of columns in the layout.

◆ isEmpty()

bool CTL::ModuleLayout::isEmpty ( ) const

Returns true if either the number of rows or columns in this layout is zero.

◆ nbNonEmptyModules()

uint CTL::ModuleLayout::nbNonEmptyModules ( ) const

Returns the number of entries that is larger than zero.

This refers to the number of modules not considered a gap (negative index value).

◆ operator()() [1/2]

int & CTL::ModuleLayout::operator() ( uint  row,
uint  col 
)

Returns a (modifiable) reference to the module index at layout position [row, col].

// setting up a linear layout with five modules
ModuleLayout linearLayout = ModuleLayout::canonicLayout(1, 6); // layout: | 0 || 1 || 2 || 3 || 4 || 5 |
// replace the odd numbered modules by their predecessors
for(uint m = 1; m < linearLayout.columns(); m += 2)
linearLayout(0, m) = m-1; // layout: | 0 || 0 || 2 || 2 || 4 || 4 |
// remove all modules at these positions
for(uint m = 1; m < linearLayout.columns(); m += 2)
linearLayout(0, m) = -1; // layout: | 0 || || 2 || || 4 || |

◆ operator()() [2/2]

const int & CTL::ModuleLayout::operator() ( uint  row,
uint  col 
) const

Returns a constant reference to the module index at layout position [row, col].

◆ rows()

uint CTL::ModuleLayout::rows ( ) const

Returns the number of rows in the layout.


The documentation for this class was generated from the following files: