SimpleGVXR Documentation

Contents

SimpleGVXR Documentation#

file acquisition.h
#include <vector>
#include <string>
#include “Utils.h

Expose here all the functions of SimpleGVXR related to the X-ray image acquisition, inc. radiographs, path lenghts and CT.

License BSD 3-Clause License.

Version

1.0

Date

08/05/2024

Author

Prof Franck P. Vidal

For details on use and redistribution please refer to http://opensource.org/licenses/BSD-3-Clause

Copyright (c) by Prof Franck P. Vidal (franck.vidal@stfc.ac.uk), UK Research and Innovation, May 2024-present, version 1.1, BSD 3-Clause License

Functions

std::vector<std::vector<float>> computeXRayImage(bool anIntegrateEnergyFlag = true)#

Compute the X-ray projection corresponding to the environment that has previously been set, i.e.

  • Detector position

  • Detector orientation

  • Detector size and resolution

  • Source position

  • Source shape

  • Beam spectrum

  • Scanned object geometries

  • Scanned object material properties

Parameters:

anIntegrateEnergyFlag – if true the energy fluence is returned, otherwise the number of photons is returned (default value: true)

Returns:

the corresponding X-ray image

std::vector<std::vector<std::vector<float>>> computeSpectralImage()#

Compute the spectral images corresponding to the environment that has previously been set, i.e.

  • Detector position

  • Detector orientation

  • Detector size and resolution

  • Source position

  • Source shape

  • Beam spectrum

  • Scanned object geometries

  • Scanned object material properties Note that there will be one 2D image per energy bin.

Returns:

the corresponding spectral images

std::vector<std::vector<float>> computeLBuffer(const std::string &aLabel)#

Compute the L-buffer, i.e. path length, of a polygon mesh corresponding to the environment that has previously been set, i.e.

  • Detector position

  • Detector orientation

  • Detector size and resolution

  • Source position

  • Source shape

  • Scanned object geometry

Parameters:

aLabel – the label of the polygon mesh

Returns:

the corresponding L-buffer

std::vector<std::vector<float>> computePathLength(const std::string &aLabel)#

Compute the L-buffer, i.e. path length, of a polygon mesh corresponding to the environment that has previously been set, i.e.

  • Detector position

  • Detector orientation

  • Detector size and resolution

  • Source position

  • Source shape

  • Scanned object geometry

Parameters:

aLabel – the label of the polygon mesh

Returns:

the corresponding L-buffer

std::vector<std::vector<std::vector<float>>> computeSinogram(double x, double y, double z, const std::string &aUnitOfLength, unsigned int aNumberOfAngle, double anAngleOffset)#

Compute the sinogram corresponding to the environment that has previously been set, i.e.

  • Detector position

  • Detector orientation

  • Detector size and resolution

  • Source position

  • Source shape

  • Beam spectrum

  • Scanned object geometries

  • Scanned object material properties Note that the rotation vector is the same as the up-vector of the detector.

Parameters:
  • x – the position of the rotation centre along the X-axis

  • y – the position of the rotation centre along the Y-axis

  • z – the position of the rotation centre along the Z-axis

  • aUnitOfLength – the unit of length corresponding to the x, y and z parameters. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

  • aNumberOfAngle – the total number of projections in the sinogram

  • anAngleOffset – the angle in degrees between two successive projections

Returns:

the corresponding sinogram

std::vector<std::vector<std::vector<float>>> computeProjectionSet(double x, double y, double z, const std::string &aUnitOfLength, unsigned int aNumberOfAngle, double anAngleOffset)#

Compute the projection set corresponding to the environment that has previously been set, i.e.

  • Detector position

  • Detector orientation

  • Detector size and resolution

  • Source position

  • Source shape

  • Beam spectrum

  • Scanned object geometries

  • Scanned object material properties Note that the rotation vector is the same as the up-vector of the detector.

Parameters:
  • x – the position of the rotation centre along the X-axis

  • y – the position of the rotation centre along the Y-axis

  • z – the position of the rotation centre along the Z-axis

  • aUnitOfLength – the unit of length corresponding to the x, y and z parameters. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

  • aNumberOfAngle – the total number of projections in the projection set

  • anAngleOffset – the angle in degrees between two successive projections

Returns:

the corresponding projection set

void computeCTAcquisition(const std::string &aProjectionOutputPath, const std::string &aScreenshotOutputPath, unsigned int aNumberOfProjections, float aFirstAngle, bool anIncludeLastAngleFlag, float aLastAngle, unsigned int aNumberOfWhiteImagesInFlatField, float aPositionOfCentreOfRotationX, float aPositionOfCentreOfRotationY, float aPositionOfCentreOfRotationZ, const std::string &aUnitOfLength, float aAxisOfRotationX, float aAxisOfRotationY, float aAxisOfRotationZ, bool anIntegrateEnergyFlag = true, unsigned int aVerboseLevel = 0)#

Compute the X-ray projections for a CT acquisition.

Parameters:
  • aProjectionOutputPath – the path where the X-ray projections will be saved. If the path is empty, the data will be stored in the main memory, but not saved on the disk. If the path is provided, the data will be saved on the disk, and the main memory released.

  • aScreenshotOutputPath – the path where the screenshots will be saved. If kept empty, not screenshot will be saved.

  • aNumberOfProjections – The total number of projections to simulate.

  • aFirstAngle – The rotation angle corresponding to the first projection.

  • anIncludeLastAngleFlag – A boolean flag to include or exclude the last angle. It is used to calculate the angular step between successive projections.

  • aLastAngle – The rotation angle corresponding to the last projection. Note that depending on the value of anIncludeLastAngleFlag, this angle may be included or excluded

  • aNumberOfWhiteImagesInFlatField – The number of white images used to perform the flat-field correction. If zero, then no correction will be performed.

  • aPositionOfCentreOfRotationX – The location of the rotation centre along the X-axis.

  • aPositionOfCentreOfRotationY – The location of the rotation centre along the Y-axis.

  • aPositionOfCentreOfRotationZ – The location of the rotation centre along the Z-axis.

  • aUnitOfLength – The corresponding unit of length

  • aAxisOfRotationX – The rotation axis along the X-axis.

  • aAxisOfRotationY – The rotation axis along the Y-axis.

  • aAxisOfRotationZ – The rotation axis along the Z-axis.

  • anIntegrateEnergyFlag – if true the energy fluence is returned, otherwise the number of photons is returned (default value: true)

  • aVerboseLevel – The verbose level. If greater than zero, details will be outputed (default value = 0)

std::vector<std::vector<float>> getSourcePositionSet(const std::string &aUnitOfLength)#

Accessor on the set of successive source positions during the CT scan acquisition.

Returns:

the set of successive source positions

std::vector<std::vector<float>> getDetectorPositionSet(const std::string &aUnitOfLength)#

Accessor on the set of successive detector centre positions during the CT scan acquisition.

Returns:

the set of successive detector centre positions

std::vector<std::vector<float>> getDetectorRightVectorSet()#

Accessor on the set of successive unit vector that defines the horizontal axis of the detector.

Returns:

the set of successive unit vector that defines the horizontal axis of the detector

std::vector<std::vector<float>> getDetectorUpVectorSet()#

Accessor on the set of successive unit vector that defines the vertical axis of the detector.

Returns:

the set of successive unit vector that defines the vertical axis of the detector

const std::string &getProjectionOutputPathCT()#

Accessor on the path where X-ray projections are saved during a CT scan acquisition simulation.

Returns:

the path where X-ray projections are saved

const std::string &getScreenshotOutputPathCT()#

Accessor on the path where screenshots are saved during a CT scan acquisition simulation.

Returns:

the path where screenshots are saved

unsigned int getNumberOfProjectionsCT()#

Accessor on the number of X-ray projections computed during a CT scan acquisition simulation.

Returns:

the number of X-ray projections

unsigned int getOptimalNumberOfProjectionsCT()#

Accessor on the number of X-ray projections needed to compute a CT scan acquisition that satisfies the Nyquist theorem. Note that the user may choose a different number.

Returns:

the optimal number of X-ray projections

float getFirstAngleCT()#

Accessor on the first angle of the CT scan acquisition simulation.

Returns:

the first angle

float getLastAngleCT()#

Accessor on the last angle of the CT scan acquisition simulation.

Returns:

the last angle

bool getIncludeLastAngleFlagCT()#

Accessor on the flag used to include the last angle or not during the CT scan acquisition simulation.

Returns:

the flag used to include the last angle or not

unsigned int getWhiteImagesInFlatFieldCT()#

Accessor on the number of white images used in the flat-field correction during the CT scan acquisition simulation. Zero means that the flat-field correction was not used.

Returns:

the number of white images

std::vector<float> getCentreOfRotationPositionCT(const std::string &aUnitOfLength)#

Accessor on the position of the centre of rotation used during the CT scan acquisition simulation.

Parameters:

aUnitOfLength – The corresponding unit of length

Returns:

the position of the centre of rotation

std::vector<float> getRotationAxisCT()#

Accessor on the axis of rotation used during the CT scan acquisition simulation.

Returns:

the axis of rotation

std::vector<float> getAngleSetCT()#

Accessor on the set of rotation angles used during the CT scan acquisition simulation.

Returns:

the set of rotation angles

std::vector<std::vector<float>> getLastXRayImage()#

Accessor on the last X-ray image that has been computed.

Returns:

the last X-ray image

std::vector<std::vector<float>> getLastLBuffer()#

Accessor on the last L-buffer that has been computed.

Returns:

the last L-buffer

std::vector<std::vector<std::vector<float>>> getLastSinogram()#

Accessor on the last sinogram that has been computed.

Returns:

the last sinogram

std::vector<std::vector<std::vector<float>>> getLastProjectionSet()#

Accessor on the last projection set that has been computed.

Returns:

the last projection set

void saveLastXRayImage(const std::string &aFileName = std::string(), bool useCompression = true)#

Save the last X-ray image that has been computed.

Parameters:
  • aFileName – the name of the output file (default: means that the filename will be automatically generated and the file saved in the current path)

  • useCompression – use data compression is possible (default: true)

void saveLastLBuffer(const std::string &aFileName = std::string(), bool useCompression = true)#

Save the last L-buffer, i.e. path length, that has been computed.

Parameters:
  • aFileName – the name of the output file (default: means that the filename will be automatically generated and the file saved in the current path)

  • useCompression – use data compression is possible (default: true)

void saveLastPathLength(const std::string &aFileName = std::string(), bool useCompression = true)#

Save the last L-buffer, i.e. path length, that has been computed.

Parameters:
  • aFileName – the name of the output file (default: means that the filename will be automatically generated and the file saved in the current path)

  • useCompression – use data compression is possible (default: true)

void saveLastCumulatedLBuffer(const std::string &aFileName = std::string(), bool useCompression = true)#

Save the last cumulated L-buffer that has been computed.

Parameters:
  • aFileName – the name of the output file (default: means that the filename will be automatically generated and the file saved in the current path)

  • useCompression – use data compression is possible (default: true)

void saveLastSinogram(const std::string &aFileName = std::string(), bool useCompression = true)#

Save the last sinogram that has been computed.

Parameters:
  • aFileName – the name of the output file (default: 0 means that the filename will be automatically generated and the file saved in the current path)

  • useCompression – use data compression is possible (default: true)

void saveLastProjectionSet(const std::string &aFileName = std::string(), bool useCompression = true)#

Save the last projection set that has been computed.

Parameters:
  • aFileName – the name of the output file (default: 0 means that the filename will be automatically generated and the file saved in the current path)

  • useCompression – use data compression is possible (default: true)

file detector.h
#include <vector>
#include <string>

Expose here all the functions of SimpleGVXR related to the X-ray detector. It includes it geometry and resolution as well as the scintilator.

License BSD 3-Clause License.

Version

1.0

Date

07/05/2024

Author

Prof Franck P. Vidal

For details on use and redistribution please refer to http://opensource.org/licenses/BSD-3-Clause

Copyright (c) by Prof Franck P. Vidal (franck.vidal@stfc.ac.uk), UK Research and Innovation, May 2024-present, version 1.1, BSD 3-Clause License

Functions

void setDetectorNumberOfPixels(int aWidth, int aHeight)#

Set the number of pixels of the X-ray detector.

Parameters:
  • aWidth – the number of pixels along the X-axis

  • aHeight – the number of pixels along the Y-axis

std::vector<int> getDetectorNumberOfPixels()#

Accessor on the number of pixels of the X-ray detector.

Returns:

the size of the detector in number of pixels

void setOversamplingFactor(int aFactor = 1)#

Set the multiplicative factor to oversample the L-buffers.

Parameters:

aFactor – the multiplicative factor (default value: 1, for no oversampling)

int getOversamplingFactor()#

Accessor on the multiplicative factor to oversample the L-buffers.

Returns:

the multiplicative factor

void setDetectorPixelSize(double aWidth, double aHeight, const std::string &aUnitOfLength)#

Set the pixel size. Same as the function setDetectorPixelPitch.

Parameters:
  • aWidth – the pixel size along the X-axis

  • aHeight – the pixel size along the Y-axis

  • aUnitOfLength – the unit of length corresponding to the aWidth and aHeight parameters. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

void setDetectorPixelPitch(double aWidth, double aHeight, const std::string &aUnitOfLength)#

Set the pixel pitch. It is the distance between the centre of two pixels. It is often assumed that the edge of pixels have no width. Same as the function setDetectorPixelSize.

Parameters:
  • aWidth – the pixel size along the X-axis

  • aHeight – the pixel size along the Y-axis

  • aUnitOfLength – the unit of length corresponding to the aWidth and aHeight parameters. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

std::vector<double> getDetectorPixelSpacing(const std::string &aUnitOfLength)#

Accessor on the pixel spacing of the X-ray detector.

Parameters:

aUnitOfLength – the unit of length corresponding to the returned value. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

Returns:

the size in a given unit of length

std::vector<double> getDetectorSize(const std::string &aUnitOfLength)#

Accessor on the size of the X-ray detector.

Parameters:

aUnitOfLength – the unit of length corresponding to the returned value. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

Returns:

the size in a given unit of length

double getDetectorPixelArea(const std::string &aUnitOfLength)#

Accessor on the area of a pixel of the X-ray detector.

Parameters:

aUnitOfLength – the unit of length corresponding to the returned value. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

Returns:

the size in a given unit of length

void setDetectorPosition(double x, double y, double z, const std::string &aUnitOfLength)#

Set the position of the X-ray detector.

Parameters:
  • x – the position along the X-axis

  • y – the position along the Y-axis

  • z – the position along the Z-axis

  • aUnitOfLength – the unit of length corresponding to the x, y and z parameters. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

std::vector<double> getDetectorPosition(const std::string &aUnitOfLength)#

Accessor on the position of the X-ray detector.

Parameters:

aUnitOfLength – the unit of length corresponding to the returned value. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

Returns:

the source position in a given unit of length

void setDetectorUpVector(double x, double y, double z)#

Set the up-vector defining the orientation of the X-ray detector.

Parameters:
  • x – the component of the vector along the X-axis

  • y – the component of the vector along the Y-axis

  • z – the component of the vector along the Z-axis

std::vector<double> getDetectorUpVector()#

Accessor on the up-vector defining the orientation of the X-ray detector.

Returns:

the up-vector

void setDetectorRightVector(double x, double y, double z)#

Set the right vector defining the orientation of the X-ray detector.

Parameters:
  • x – the component of the vector along the X-axis

  • y – the component of the vector along the Y-axis

  • z – the component of the vector along the Z-axis

std::vector<double> getDetectorRightVector()#

Accessor on the right-vector defining the orientation of the X-ray detector.

Returns:

the right-vector

void rotateDetector(double anAngle, double x, double y, double z)#

Rotate the detector around a given axis.

Parameters:
  • anAngle – the angle of rotation in degrees

  • x – the component of the rotation vector along the X-axis

  • y – the component of the rotation vector along the Y-axis

  • z – the component of the rotation vector along the Z-axis

void autoAlignDetector(bool aFlag = true)#

Set a flag to enable/disable the automatic alignment of the detector so that the ray from the middle of the source to the centre of the detector is perpendicular to both the unit vectors defining the horizontal and vertical axes of the detector.

Parameters:

aFlag – the boolean flag (default value: true)

std::vector<float> getDetectorVertices()#

Accessor on the four corners of the X-ray detector.

Returns:

the corresponding vertices

void setLSF(const std::string &aFileName)#

Set the line spread function from a file.

Parameters:

aFileName – the input file name

void setLSF(const std::vector<float> &aLSF)#

Set the line spread function from an array.

Parameters:

aLSF – the LSF coefficients

const std::vector<float> &getLSF()#

Accessor on the line spread function.

Returns:

the LSF coefficients

void clearLSF()#

Clear the LSF to use a Dirac as impulse response.

void setDetectorEnergyResponse(const std::vector<std::vector<float>> &anEnergyResponse, const std::string &aUnitOfEnergy)#

Load the energy response of the detector from an array in the memory.

Parameters:
  • anEnergyResponse – the energy response as an array. Each row of the array is formatted as follows: input_energy output_energy

  • aUnitOfEnergy – the unit of energy corresponding to the data in the array Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

void loadDetectorEnergyResponse(const std::string &aFileName, const std::string &aUnitOfEnergy)#

Load the energy response of the detector from a TSV file.

Parameters:
  • aFileName – name of the file. Each line of the file is formatted as follows: input_energy output_energy

  • aUnitOfEnergy – the unit of energy corresponding to the data in the file. Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

std::vector<std::vector<float>> getEnergyResponse(const std::string &aUnitOfEnergy)#

Accessor on the energy response of the detector.

Parameters:

aUnitOfEnergy – the unit of energy corresponding to the data in the array. Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

Returns:

the energy response as an array. Each row of the array is formatted as follows: input_energy output_energy

void clearDetectorEnergyResponse()#

Clear the energy response of the detector.

void setScintillator(const std::string &aMaterial, const float &aThickness, const std::string &aUnitOfLength)#

Set the scintillator material of the detector. It will generate the energy response of the detector.

Parameters:
  • aMaterial – the material of the scintillator. Acceptable values are: “CsI”, “Cesium iodine”, “CdWO4”, “CWO”, “Cadmium tungstate”, “Y2O3”, “Yttrium oxyde”, “Gd2O3”, “Gadolinum oxyde”, “(Y,Gd)2O3”, “YGO”, “Yttrium gadolinum oxyde”, “Gd2O2S”, “Gadox”, “Gadolinum silicate”, “GOS”, “Gd2O2S DRZ-Plus”, “Gadox DRZ-Plus”, “NaI”, “Sodium iodine”, “La2HfO7”, “Lanthanum hafnate”, “Gd3Ga5O12”, “Gadolinium gallium garnet”, “Y3Al5O12”, “Yttrium aluminium garnate”, “YAG”

  • aThickness – the thickness of the scintillator.

  • aUnitOfLength – the unit corresponding to the thickness of the scintillator. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

const std::string &getScintillatorMaterial()#

Accessor on the material of the scintillator of the detector.

Returns:

the material of the scintillator

std::vector<std::string> getSupportedScintillatorMaterials()#

Accessor on the list of scintillator materials currently supported.

Returns:

the list of supported scintillator materials

std::vector<std::vector<float>> getEnergyResponse(const std::string &aMaterial, const float &aThickness, const std::string &aUnitOfLength, const std::string &aUnitOfEnergy)#

Accessor on the energy response of a detector scintillator of a given material and thickness.

Parameters:
  • aMaterial – the material of the scintillator. Acceptable values are: “CsI”, “Cesium iodine”, “CdWO4”, “CWO”, “Cadmium tungstate”, “Y2O3”, “Yttrium oxyde”, “Gd2O3”, “Gadolinum oxyde”, “(Y,Gd)2O3”, “YGO”, “Yttrium gadolinum oxyde”, “Gd2O2S”, “Gadox”, “Gadolinum silicate”, “GOS”, “Gd2O2S DRZ-Plus”, “Gadox DRZ-Plus”, “NaI”, “Sodium iodine”, “La2HfO7”, “Lanthanum hafnate”, “Gd3Ga5O12”, “Gadolinium gallium garnet”, “Y3Al5O12”, “Yttrium aluminium garnate”, “YAG”

  • aThickness – the thickness of the scintillator.

  • aUnitOfLength – the unit corresponding to the thickness of the scintillator. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

  • aUnitOfEnergy – the unit of energy corresponding to the data in the array. Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

Returns:

the corresponding energy response

double getScintillatorThickness(const std::string aUnitOfLength)#

Accessor on the thickness of the scintillator of the detector.

Parameters:

aUnitOfLength – the unit corresponding to the thickness of the scintillator. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

Returns:

the thickness of the scintillator

void setPhotonCountingBands(double aMinEnergy, double aMaxEnergy, const std::string &aUnitOfEnergy, unsigned int aNumberOfBands)#

Define the energy bands of a spectral detector. Photon counting will be used.

Parameters:
  • aMinEnergy – the lower energy threshod

  • aMaxEnergy – the upper energy threshod

  • aUnitOfEnergy – the unit of energy corresponding to aMinEnergy and aMaxEnergy. Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

  • aNumberOfBands – the number of energy bands

unsigned int getNumberOfPhotonCountingBands()#

Accessor on the number of energy bands of the spectral detector.

Returns:

the number of energy bands of the spectral detector

void mergePhotonCountingBands()#

Merge all the energy bands. In this case a typical detector will be used and it’ll integrate the energy.

std::vector<double> getPhotonCountingBands(const std::string &aUnitOfEnergy)#

Accessor on the energy bands when a spectral detector is used.

Parameters:

aUnitOfEnergy – the unit of energy corresponding to energies in the bands. Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

Returns:

the set of energy bands

file ImplicitSurface.h
#include <string>
#include <vector>

Expose here all the functions of SimpleGVXR related to implicit modelling, e.g. metaballs, soft objects, blobby molecules. Both control points and line segments can be used.

License BSD 3-Clause License.

Version

1.0

Date

10/06/2024

Author

Prof Franck P. Vidal

For details on use and redistribution please refer to http://opensource.org/licenses/BSD-3-Clause

Copyright (c) by Prof Franck P. Vidal (franck.vidal@stfc.ac.uk), UK Research and Innovation, June 2024-present, version 1.1, BSD 3-Clause License

Functions

unsigned int getNumberOfImplicitSurfaces()#

Get the total number of implicit surfaces that have been added to the scenegraph.

Returns:

the number of implicit surfaces

std::vector<std::string> getImplicitSurfaceLabelSet()#

Get the labels of all the implicit surfaces that have been added to the scenegraph.

Returns:

the set of implicit surface labels

bool implicitSurfaceExists(const std::string &aLabel)#

Check whether a given label is used to identify an implicit surface.

Parameters:

aLabel – the label identifying a potential implicit surface

Returns:

true if the label identify an implicit surface, otherwise retrun false

void createImplicitSurface(const std::string &aLabel)#

Create a new implicit surface.

Parameters:

aLabel – the label identifying the new implicit surface

void destroyImplicitSurface(const std::string &aLabel)#

Destroy a given implicit surface.

Parameters:

aLabel – the label identifying the implicit surface

void destroyAllImplicitSurfaces()#

Destroy all the existing implicit surfaces.

void addControlPoint(const std::string &aLabel, float aPositionX, float aPositionY, float aPositionZ, const std::string &aUnitOfLength, const std::string &aDentityFunction, float aParameterA, float aParameterB = 0.0)#

Add a control point to an existing implicit surface. See the excellent webpage by Paul Bourke: https://paulbourke.net/geometry/implicitsurf/index.html.

Parameters:
  • aLabel – the label identifying the implicit surface

  • aPositionX – the position of the point along the X-axis

  • aPositionY – the position of the point along the Y-axis

  • aPositionZ – the position of the point along the Z-axis

  • aUnitOfLength – the unit of length corresponding to aPositionX, aPositionY and aPositionZ. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

  • aDentityFunction

    the name of the density function. Accepted values are:

    ”sphere”, which uses the density function

    \(D(r) = \frac{1}{r^2}\)

    .

    ”blobby molecule”, which uses the density density function

    \(a \mathrm{e}^{-b r^2}\)\(b\) is related to the standard deviation of the curve, \(a\) to the height. The function should be recognised as a Gaussian curve centered at the origin, actually a half Gaussian as \(r \geq 0\)

    .

    ”metaball”, which uses the density function

    \(\left\{ \begin{array}{ c l } a \left(1 - \frac{3 r^2}{b^2}\right) & \quad \textrm{if } 0 \leq r \leq b/3 \\ \frac{3 a}{2} \left(1 - \frac{r}{b}\right)^2 & \quad \textrm{if } b/3 \leq r \leq b \\ 0 & \quad \textrm{otherwise} \end{array} \right.\)\(a\) is a scaling factor, \(b\)

    is the maximum distance a control primitive contributes to the field.

    ”soft object”, which uses the density function

    \(\left\{ \begin{array}{ c l } a \left(1 - \frac{4r^6}{9b^6} + \frac{17r^4}{9b^4} - \frac{22r^2}{9b^2}\right) & \quad \textrm{if } 0 \leq r \leq b \\ 0 & \quad \textrm{otherwise} \end{array} \right.\)\(a\) scales the function, each control primitive has no influence after a distance \(b\). This function has a slight advantage over that for Meta balls as it only uses squares of the distance and so it isn’t necessary to compute square roots.

  • aParameterA\(a\) in the equations above

  • aParameterB\(b\) in the equations above (default value: 0.0)

void addControlLineSegment(const std::string &aLabel, float aPosition1X, float aPosition1Y, float aPosition1Z, float aPosition2X, float aPosition2Y, float aPosition2Z, const std::string &aUnitOfLength, const std::string &aDentityFunction, float aParameterA, float aParameterB = 0.0)#

Add a control point to an existing implicit surface. See the excellent webpage by Paul Bourke: https://paulbourke.net/geometry/implicitsurf/index.html.

Parameters:
  • aLabel – the label identifying the implicit surface

  • aPosition1X – the position of the 1st point defining the line segment along the X-axis

  • aPosition1Y – the position of the 1st point defining the line segment along the Y-axis

  • aPosition1Z – the position of the 1st point defining the line segment along the Z-axis

  • aPosition2X – the position of the 2nd point defining the line segment along the X-axis

  • aPosition2Y – the position of the 2nd point defining the line segment along the Y-axis

  • aPosition2Z – the position of the 2nd point defining the line segment along the Z-axis

  • aUnitOfLength – the unit of length corresponding to aPositionX, aPositionY and aPositionZ. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

  • aDentityFunction

    the name of the density function. Accepted values are:

    ”sphere”, which uses the density function

    \(D(r) = \frac{1}{r^2}\)

    .

    ”blobby molecule”, which uses the density density function

    \(a \mathrm{e}^{-b r^2}\)\(b\) is related to the standard deviation of the curve, \(a\) to the height. The function should be recognised as a Gaussian curve centered at the origin, actually a half Gaussian as \(r \geq 0\)

    .

    ”metaball”, which uses the density function

    \(\left\{ \begin{array}{ c l } a \left(1 - \frac{3 r^2}{b^2}\right) & \quad \textrm{if } 0 \leq r \leq b/3 \\ \frac{3 a}{2} \left(1 - \frac{r}{b}\right)^2 & \quad \textrm{if } b/3 \leq r \leq b \\ 0 & \quad \textrm{otherwise} \end{array} \right.\)\(a\) is a scaling factor, \(b\)

    is the maximum distance a control primitive contributes to the field.

    ”soft object”, which uses the density function

    \(\left\{ \begin{array}{ c l } a \left(1 - \frac{4r^6}{9b^6} + \frac{17r^4}{9b^4} - \frac{22r^2}{9b^2}\right) & \quad \textrm{if } 0 \leq r \leq b \\ 0 & \quad \textrm{otherwise} \end{array} \right.\)\(a\) scales the function, each control primitive has no influence after a distance \(b\). This function has a slight advantage over that for Meta balls as it only uses squares of the distance and so it isn’t necessary to compute square roots.

  • aParameterA\(a\) in the equations above

  • aParameterB\(b\) in the equations above (default value: 0.0)

unsigned int getNumberOfControlPoints(const std::string &aLabel)#

Accessor on the total number of control points in a given implicit surface.

Parameters:

aLabel – the label identifying the implicit surface

Returns:

the total number of control points in the implicit surface

unsigned int getNumberOfControlLineSegments(const std::string &aLabel)#

Accessor on the total number of control line segments in a given implicit surface.

Parameters:

aLabel – the label identifying the implicit surface

Returns:

the total number of line segments in the implicit surface

void setControlPointParameters(const std::string &aLabel, unsigned int aPointID, const std::string &aDentityFunction, float aParameterA, float aParameterB = 0.0)#

Change the density function and the parameters \(a\) and \(b\) of a given control point of a given implicit surface.

Parameters:
  • aLabel – the label identifying the implicit surface

  • aPointID – the numerial ID of the control point

  • aDentityFunction

    the name of the density function. Accepted values are:

    ”sphere”, which uses the density function

    \(D(r) = \frac{1}{r^2}\)

    .

    ”blobby molecule”, which uses the density density function

    \(a \mathrm{e}^{-b r^2}\)\(b\) is related to the standard deviation of the curve, \(a\) to the height. The function should be recognised as a Gaussian curve centered at the origin, actually a half Gaussian as \(r \geq 0\)

    .

    ”metaball”, which uses the density function

    \(\left\{ \begin{array}{ c l } a \left(1 - \frac{3 r^2}{b^2}\right) & \quad \textrm{if } 0 \leq r \leq b/3 \\ \frac{3 a}{2} \left(1 - \frac{r}{b}\right)^2 & \quad \textrm{if } b/3 \leq r \leq b \\ 0 & \quad \textrm{otherwise} \end{array} \right.\)\(a\) is a scaling factor, \(b\)

    is the maximum distance a control primitive contributes to the field.

    ”soft object”, which uses the density function

    \(\left\{ \begin{array}{ c l } a \left(1 - \frac{4r^6}{9b^6} + \frac{17r^4}{9b^4} - \frac{22r^2}{9b^2}\right) & \quad \textrm{if } 0 \leq r \leq b \\ 0 & \quad \textrm{otherwise} \end{array} \right.\)\(a\) scales the function, each control primitive has no influence after a distance \(b\). This function has a slight advantage over that for Meta balls as it only uses squares of the distance and so it isn’t necessary to compute square roots.

  • aParameterA\(a\) in the equations above

  • aParameterB\(b\) in the equations above

void setControlLineSegmentParameters(const std::string &aLabel, unsigned int aLineSegmentID, const std::string &aDentityFunction, float aParameterA, float aParameterB = 0.0)#

Change the density function and the parameters \(a\) and \(b\) of a given control line segment of a given implicit surface.

Parameters:
  • aLabel – the label identifying the implicit surface

  • aLineSegmentID – the numerial ID of the control line segment

  • aDentityFunction

    the name of the density function. Accepted values are:

    ”sphere”, which uses the density function

    \(D(r) = \frac{1}{r^2}\)

    .

    ”blobby molecule”, which uses the density density function

    \(a \mathrm{e}^{-b r^2}\)\(b\) is related to the standard deviation of the curve, \(a\) to the height. The function should be recognised as a Gaussian curve centered at the origin, actually a half Gaussian as \(r \geq 0\)

    .

    ”metaball”, which uses the density function

    \(\left\{ \begin{array}{ c l } a \left(1 - \frac{3 r^2}{b^2}\right) & \quad \textrm{if } 0 \leq r \leq b/3 \\ \frac{3 a}{2} \left(1 - \frac{r}{b}\right)^2 & \quad \textrm{if } b/3 \leq r \leq b \\ 0 & \quad \textrm{otherwise} \end{array} \right.\)\(a\) is a scaling factor, \(b\)

    is the maximum distance a control primitive contributes to the field.

    ”soft object”, which uses the density function

    \(\left\{ \begin{array}{ c l } a \left(1 - \frac{4r^6}{9b^6} + \frac{17r^4}{9b^4} - \frac{22r^2}{9b^2}\right) & \quad \textrm{if } 0 \leq r \leq b \\ 0 & \quad \textrm{otherwise} \end{array} \right.\)\(a\) scales the function, each control primitive has no influence after a distance \(b\). This function has a slight advantage over that for Meta balls as it only uses squares of the distance and so it isn’t necessary to compute square roots.

  • aParameterA\(a\) in the equations above

  • aParameterB\(b\) in the equations above

void voxeliseImplicitSurface(const std::string &aLabel, unsigned int aNumberOfVoxelX, unsigned int aNumberOfVoxelY, unsigned int aNumberOfVoxelZ, float aCentrePositionX, float aCentrePositionY, float aCentrePositionZ, float aVoxelWidth, float aVoxelHeight, float aVoxelDepth, const std::string &aUnitOfLength, unsigned char aVerboseLevel = 0)#

Compute the density function of a given implicit surface. It create a volume (i.e. voxels)

Parameters:
  • aLabel – the label identifying the implicit surface

  • aNumberOfVoxelX – the number of voxels along the X-axis

  • aNumberOfVoxelY – the number of voxels along the Y-axis

  • aNumberOfVoxelZ – the number of voxels along the Z-axis

  • aCentrePositionX – the position of the centre of the volume along the X-axis

  • aCentrePositionY – the position of the centre of the volume along the Y-axis

  • aCentrePositionZ – the position of the centre of the volume along the Z-axis

  • aVoxelWidth – the size of a voxel along the X-axis

  • aVoxelHeight – the size of a voxel along the Y-axis

  • aVoxelDepth – the size of a voxel along the Z-axis

  • aUnitOfLength – the unit of length corresponding to aCentrePositionX, aCentrePositionY, aCentrePositionZ, aVoxelWidth, aVoxelHeight and aVoxelDepth. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

  • aVerboseLevel – the level of statements in the standard output. For no output, use 0 (default value: 0)

void voxelizeImplicitSurface(const std::string &aLabel, unsigned int aNumberOfVoxelX, unsigned int aNumberOfVoxelY, unsigned int aNumberOfVoxelZ, float aCentrePositionX, float aCentrePositionY, float aCentrePositionZ, float aVoxelWidth, float aVoxelHeight, float aVoxelDepth, const std::string &aUnitOfLength, unsigned char aVerboseLevel = 0)#

Compute the density function of a given implicit surface. It create a volume (i.e. voxels)

Parameters:
  • aLabel – the label identifying the implicit surface

  • aNumberOfVoxelX – the number of voxels along the X-axis

  • aNumberOfVoxelY – the number of voxels along the Y-axis

  • aNumberOfVoxelZ – the number of voxels along the Z-axis

  • aCentrePositionX – the position of the centre of the volume along the X-axis

  • aCentrePositionY – the position of the centre of the volume along the Y-axis

  • aCentrePositionZ – the position of the centre of the volume along the Z-axis

  • aVoxelWidth – the size of a voxel along the X-axis

  • aVoxelHeight – the size of a voxel along the Y-axis

  • aVoxelDepth – the size of a voxel along the Z-axis

  • aUnitOfLength – the unit of length corresponding to aCentrePositionX, aCentrePositionY, aCentrePositionZ, aVoxelWidth, aVoxelHeight and aVoxelDepth. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

  • aVerboseLevel – the level of statements in the standard output. For no output, use 0 (default value: 0)

std::vector<std::vector<std::vector<float>>> getImplicitSurfaceLastVoxelisation(const std::string &aLabel)#

Accessor on the last voxelisation of a given iso-surface that has been computed.

Parameters:

aLabel – the label identifying the polygon mesh in the scenegraph

Returns:

the last voxelisation

std::vector<std::vector<std::vector<float>>> getImplicitSurfaceLastVoxelization(const std::string &aLabel)#

Accessor on the last voxelisation of a given iso-surface that has been computed.

Parameters:

aLabel – the label identifying the polygon mesh in the scenegraph

Returns:

the last voxelisation

void createMeshFromImplicitSurface(const std::string &aImplicitSurfaceLabel, const std::string &aMeshLabel, float anIsoValue, const std::string &aParent = "root", unsigned char aVerboseLevel = 0)#

Apply the marching cubes algorithm to extract the polygon mesh and add the node in the scenegraph.

Parameters:
  • aImplicitSurfaceLabel – the label identifying the implicit surface

  • aMeshLabel – the label identifying the polygon mesh in the scenegraph

  • anIsoValue – the iso value

  • aParent – the parent of the node in the scenegraph (default: “root”)

  • aVerboseLevel – the level of statements in the standard output. For no output, use 0 (default value: 0)

void createMeshFromImplicitSurface(const std::string &aImplicitSurfaceLabel, const std::string &aMeshLabel, float aLowerIsoValue, float anUpperIsoValue, const std::string &aParent = "root", unsigned char aVerboseLevel = 0)#

Apply the marching cubes algorithm to extract the polygon mesh and add the node in the scenegraph.

Parameters:
  • aImplicitSurfaceLabel – the label identifying the implicit surface

  • aMeshLabel – the label identifying the polygon mesh in the scenegraph

  • aLowerIsoValue – the lower limit of the iso value

  • anUpperIsoValue – the upper limit of the the iso value

  • aParent – the parent of the node in the scenegraph (default: “root”)

  • aVerboseLevel – the level of statements in the standard output. For no output, use 0 (default value: 0)

file internal.h
#include <vector>
#include “gVirtualXRay/Image.h”

Functions

void initialiseXRayRenderer()#
std::vector<std::vector<std::vector<float>>> getVectorImage3D(const gVirtualXRay::Image<float> &anImage)#
std::vector<std::vector<float>> getVectorImage2D(const gVirtualXRay::Image<float> &anImage)#
file sample.h

Expose here all the functions of SimpleGVXR related to the sample. It includes its geometry and material composition.

License BSD 3-Clause License.

Version

1.0

Date

10/07/2024

Author

Prof Franck P. Vidal

For details on use and redistribution please refer to http://opensource.org/licenses/BSD-3-Clause

Copyright (c) by Prof Franck P. Vidal (franck.vidal@stfc.ac.uk), UK Research and Innovation, May 2024-present, version 1.1, BSD 3-Clause License

Functions

void loadMeshFile(const std::string &aLabel, const std::string &aFileName, const std::string &aUnitOfLength, bool addToRendererAsInnerSurface = true, const std::string &aParent = "root")#

Load a polygon mesh from a file, set its label in the scenegraph (i.e. identifier) and add it to the X-ray renderer.

Parameters:
  • aLabel – the label in the scenegraph

  • aFileName – the file where the polygon mesh data is stored

  • aUnitOfLength – the unit of length corresponding to the data stored in the file. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

  • addToRendererAsInnerSurface – a flag to add the mesh to the X-ray renderer (as an inner surface) (default value: true)

  • aParent – the parent of the node in the scenegraph (default: “root”)

std::string getMeshFilename(const std::string &aLabel)#

Accessor on the filename of the mesh.

Parameters:

aLabel – the label in the scenegraph

Returns:

the filename

std::string getMeshUnitOfLength(const std::string &aLabel)#

Accessor on the unit of length of the mesh.

Parameters:

aLabel – the label in the scenegraph

Returns:

the unit of length

void loadSceneGraph(const std::string &aFileName, const std::string &aUnitOfLength)#

Load a scenegraph from a file and add its polygon meshes to the X-ray renderer.

Parameters:
  • aFileName – the file where the polygon mesh data is stored

  • aUnitOfLength – the unit of length corresponding to the data stored in the file. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

unsigned int getNumberOfPrimitives(const std::string &aLabel)#

Accessor on the number of primitives of a given node.

Parameters:

aLabel – the label in the scenegraph

Returns:

the number of primitives

unsigned int getNumberOfFaceNormalVectors(const std::string &aLabel)#

Accessor on the number of face normal vectors of a given node.

Parameters:

aLabel – the label in the scenegraph

Returns:

the number of face normal vectors

unsigned int getNumberOfVertexNormalVectors(const std::string &aLabel)#

Accessor on the number of vertex normal vectors of a given node.

Parameters:

aLabel – the label in the scenegraph

Returns:

the number of vertex normal vectors

unsigned int getVertexNumber(const std::string &aLabel)#

Accessor on the number of verticesof a given node.

Parameters:

aLabel – the label in the scenegraph

Returns:

the number of vertices

unsigned int getIndexNumber(const std::string &aLabel)#

Accessor on the number of indicesof a given node.

Parameters:

aLabel – the label in the scenegraph

Returns:

the number of indices

std::vector<float> getVertexSet(const std::string &aLabel)#

Accessor on the vertices of a given node.

Parameters:

aLabel – the label in the scenegraph

Returns:

the vertex

std::vector<float> getFaceNormalVectorSet(const std::string &aLabel)#

Accessor on the face normals of a given node.

Parameters:

aLabel – the label in the scenegraph

Returns:

the face normals

std::vector<float> getVertexNormalVectorSet(const std::string &aLabel)#

Accessor on the vertex normals of a given node.

Parameters:

aLabel – the label in the scenegraph

Returns:

the vertex normals

std::vector<int> getIndexSet(const std::string &aLabel)#

Accessor on the set of indices of a given node.

Parameters:

aLabel – the label in the scenegraph

Returns:

the set of indices

bool isInnerSurface(const std::string &aLabel)#

Check if a given node is an innersurface (“an” because there can be many).

Parameters:

aLabel – the label in the scenegraph

Returns:

true if the node is an inner surface, otherwise false

bool isOuterSurface(const std::string &aLabel)#

Check if a given node is the outer surface (“the” because there can only be one).

Parameters:

aLabel – the label in the scenegraph

Returns:

true if the node is the outer surface, otherwise false

void emptyMesh(const std::string &aLabel, const std::string &aParent = "root")#

Create an empty polygon mesh and set its label in the scenegraph (i.e. identifier). Note that it is not added to the X-ray renderer.

Parameters:
  • aLabel – the label in the scenegraph

  • aParent – the parent of the node in the scenegraph (default: “root”)

void removeMeshAndChildren(const std::string &aLabel)#

Remove and delete a polygon mesh from the scenegraph (i.e. identifier). Note that all its children, if any, will be removed too.

Parameters:

aLabel – the label in the scenegraph

void makeCube(const std::string &aLabel, double aLength = 1.0, const std::string &aUnitOfLength = "cm", const std::string &aParent = "root")#

Create a cube, centred on (0, 0, 0) and set its label in the scenegraph (i.e. identifier). Note that it is not added to the X-ray renderer.

Parameters:
  • aLabel – the label in the scenegraph

  • aLength – the size of an edge of the cube (default value: 1)

  • aUnitOfLength – the unit of length corresponding to aLength. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer” (default value: “cm”)

  • aParent – the parent of the node in the scenegraph (default: “root”)

void makeCuboid(const std::string &aLabel, double aWidth = 1.0, double aHeight = 1.0, double aDepth = 1.0, const std::string &aUnitOfLength = "cm", const std::string &aParent = "root")#

Create a cuboid, centred on (0, 0, 0) and set its label in the scenegraph (i.e. identifier). Note that it is not added to the X-ray renderer.

Parameters:
  • aLabel – the label in the scenegraph

  • aWidth – the width of the cuboid, i.e. its length along the X-axis (default value: 1)

  • aHeight – the height of the cuboid, i.e. its length along the Y-axis (default value: 1)

  • aDepth – the depth of the cuboid, i.e. its length along the Z-axis (default value: 1)

  • aUnitOfLength – the unit of length corresponding to aLength. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer” (default value: “cm”)

  • aParent – the parent of the node in the scenegraph (default: “root”)

void makeCylinder(const std::string &aLabel, unsigned int aNumberOfSectors = 10, double aHeight = 1.0, double aRadius = 0.5, const std::string &aUnitOfLength = "cm", const std::string &aParent = "root")#

Create a cylinder and set its label in the scenegraph (i.e. identifier). Note that it is not added to the X-ray renderer.

Parameters:
  • aLabel – the label in the scenegraph

  • aNumberOfSectors – the number of sectors defining the mesh (default value: 10)

  • aHeight – the height of the cylinder (default value: 1.0)

  • aRadius – the radius of the cylinder (default value: 0.5)

  • aUnitOfLength – the unit of length corresponding to aHeight and aRadius. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer” (default value: “cm”)

  • aParent – the parent of the node in the scenegraph (default: “root”)

void makeSphere(const std::string &aLabel, unsigned int aNumberOfRings = 10, unsigned int aNumberOfSectors = 10, double aRadius = 0.5, const std::string &aUnitOfLength = "cm", const std::string &aParent = "root")#

Create a sphere and set its label in the scenegraph (i.e. identifier). Note that it is not added to the X-ray renderer.

Parameters:
  • aLabel – the label in the scenegraph

  • aNumberOfRings – the number of rings defining the mesh (default value: 10)

  • aNumberOfSectors – the number of sectors defining the mesh (default value: 10)

  • aRadius – the radius of the sphere (default value: 0.5)

  • aUnitOfLength – the unit of length corresponding to aRadius. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer” (default value: “cm”)

  • aParent – the parent of the node in the scenegraph (default: “root”)

void makeStepWedge(const std::string &aLabel, unsigned int aNumberOfSteps = 2, float aTotalLength = 10.0, float aWidth = 1.0, float aFirstStepHeight = 1.0, float anOtherStepHeight = 0.1, const std::string &aUnitOfLength = "cm", const std::string &aParent = "root")#

Create a step wedge and set its label in the scenegraph (i.e. identifier). Note that it is not added to the X-ray renderer.

Parameters:
  • aLabel – the label in the scenegraph

  • aNumberOfSteps – the number of steps in the stepwedge (default value: 10)

  • aTotalLength – the length of the step wedge, i.e. its length along the X-axis (default value: 10)

  • aWidth – the width of the step wedge, i.e. its length along the Y-axis (default value: 1)

  • aFirstStepHeight – the height of the first step on the step wedge, i.e. its length along the Z-axis (default value: 1)

  • anOtherStepHeight – the height of the rest of the steps on the step wedge, i.e. its length along the Z-axis (default value: 0.1)

  • aUnitOfLength – the unit of length corresponding to aRadius. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer” (default value: “cm”)

  • aParent – the parent of the node in the scenegraph (default: “root”)

void makeIsoSurface(const std::string &aLabel, short anIsoValue, const std::vector<short> &aVoxelDataSet, unsigned int aWidth, unsigned int aHeight, unsigned int aDepth, double aSpacingX, double aSpacingY, double aSpacingZ, const std::string &aUnitOfLength = "cm", const std::string &aParent = "root")#

Create an iso-surface from a 3D image and set its label in the scenegraph (i.e. identifier). Note that it is not added to the X-ray renderer.

Parameters:
  • aLabel – the label in the scenegraph

  • anIsoValue – the iso-value

  • aVoxelDataSet – the voxel dataset

  • aWidth – the number of voxel along the X-axis

  • aHeight – the number of voxel along the Y-axis

  • aDepth – the number of voxel along the Z-axis

  • aSpacingX – the space between the centre of two successive voxels along the X-axis

  • aSpacingY – the space between the centre of two successive voxels along the Y-axis

  • aSpacingZ – the space between the centre of two successive voxels along the Z-axis

  • aUnitOfLength – the unit of length corresponding to aSpacingX, aSpacingY and aSpacingZ. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer” (default value: “cm”)

  • aParent – the parent of the node in the scenegraph (default: “root”)

void makeFoamInCuboid(const std::string &aPorosityName, const std::string &aBoundingVolumeName, double aCuboidWidth, double aCuboidHeight, double aCuboidDepth, float aPorosityRadius, float aPercentageOfVolume, float aPercentageDeviation, float aVoxelSpacing, const std::string &aUnitOfLength, unsigned char aVerboseLevel = 0)#

Create a foam structure, i.e. porosities into a bounding volume. Deprecated function: The parameter aBoundingVolumeName is not used. The function will be removed in future versions.

Parameters:
  • aPorosityName – the label of the prorosities in the scenegraph

  • aBoundingVolumeName – the label of the bounding volume in the scenegraph

  • aCuboidWidth – the width of the cuboid, i.e. its length along the X-axis

  • aCuboidHeight – the height of the cuboid, i.e. its length along the Y-axis

  • aCuboidDepth – the depth of the cuboid, i.e. its length along the Z-axis

  • aPorosityRadius – Tuple of the mean radius and statistical deviation for foam holes created.

  • aPercentageOfVolume – : Percentage of the enclosing volume occupied by foam pores

  • aPercentageDeviation – : The standard deviation relative to the radius in percentage (Default is 10%)

  • aVoxelSpacing – : Spacing (or resolution) of the voxels in cube.

  • aUnitOfLength – the unit of length corresponding to aRadius and aVoxelSpacing. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

  • aVerboseLevel – the level of statements in the standard output. For no output, use 0 (default value: 0)

void makeTriangularMesh(const std::string &aLabel, const std::vector<float> &aVertexSet, const std::string &aUnitOfLength = "cm", const std::string &aParent = "root")#

Create a triangular mesh structure from a set of vertices.

Parameters:
  • aLabel – the label of the node to create in the scenegraph

  • aVertexSet – the set of vertices

  • aUnitOfLength – the unit of length corresponding to aVertexSet. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

  • aParent – the parent of the node in the scenegraph (default: “root”)

void makeTriangularMesh(const std::string &aLabel, const std::vector<float> &aVertexSet, const std::vector<int> &aTriangleIndexSet, const std::string &aUnitOfLength = "cm", const std::string &aParent = "root")#

Create a triangular mesh structure from a set of vertices and a set of indices.

Parameters:
  • aLabel – the label of the node to create in the scenegraph

  • aVertexSet – the set of vertices

  • aTriangleIndexSet – the set of indices

  • aUnitOfLength – the unit of length corresponding to aVertexSet. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

  • aParent – the parent of the node in the scenegraph (default: “root”)

unsigned int makeSpheresInCylinder(const std::string &aCylinderLabel, unsigned int aCylinderNumberOfSectors, double aCylinderRadius, double aCylinderHeight, const std::string &aSphereLabel, unsigned int aSphereNumberOfRings, unsigned int aSphereNumberOfSectors, double aSphereRadius, double aPercentVolume, const std::string &aUnitOfLength = "cm", const std::string &aParent = "root")#

Create a cylinder in which spheres are embedded. The cylinder is centred on (0, 0, 0) and the spheres are randomly positioned in the cylinder. Note that it is not added to the X-ray renderer.

Parameters:
  • aCylinderLabel – the cylinder label in the scenegraph

  • aCylinderNumberOfSectors – the number of sectors defining the mesh

  • aCylinderRadius – the radius of the cylinder

  • aCylinderHeight – the height of the cylinder

  • aSphereLabel – the sphere label in the scenegraph

  • aSphereNumberOfRings – the number of rings defining the mesh

  • aSphereNumberOfSectors – the number of sectors defining the mesh

  • aSphereRadius – the radius of the cylinder

  • aPercentVolume – the percentage of the cylinder volume occupied by spheres

  • aUnitOfLength – the unit of length corresponding to aCylinderRadius, aCylinderHeight, and aSphereRadius. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer” (default value: “cm”)

  • aParent – the parent of the node in the scenegraph (default: “root”)

Returns:

the number of spheres

void addMesh(const std::string &aDestination, const std::string &aSource)#

Add a polygon mesh (aSource) to another one (aDestination). It corresponds to the operation as follows: aDestination += aSource. Both aSource and aDestination have to already exist in the scenegraph.

Parameters:
  • aDestination – the polygon mesh that is going to be modified

  • aSource – the polygon mesh that is going to be added to aDestination

void subtractMesh(const std::string &aDestination, const std::string &aSource)#

Subtract a polygon mesh (aSource) from another one (aDestination). It corresponds to the operation as follows: aDestination -= aSource. Both aSource and aDestination have to already exist in the scenegraph.

Parameters:
  • aDestination – the polygon mesh that is going to be modified

  • aSource – the polygon mesh that is going to be subtracted from aDestination

unsigned int getNumberOfChildren(const std::string &aLabel)#

Get the number of children of a node in the scenegraph.

Parameters:

aLabel – the label in the scenegraph

Returns:

the number of chidren

std::string getChildLabel(const std::string &aLabel, unsigned int i)#

Accessor on the i-th child’s label in the list of children of a given node in the scenegraph.

Parameters:
  • aLabel – the label in the scenegraph

  • i – the ID of the child

Returns:

the label corresponding to the i-th child

std::vector<double> getLocalTransformationMatrix(const std::string &aLabel)#

Accessor on the local transformation matrix of a given node in the scenegraph. If the node does not exist, the identity matrix is returned.

Parameters:

aLabel – the label in the scenegraph

Returns:

the corresponding local transformation matrix

void setLocalTransformationMatrix(const std::string &aLabel, const std::vector<double> &aMatrix)#

Set the local transformation matrix of a given node in the scenegraph.

Parameters:
  • aLabel – the label in the scenegraph

  • aMatrix – the local transformation matrix

void applyCurrentLocalTransformation(const std::string &aLabel)#

Apply the current local transformation to all the vertices of a given node in the scenegraph. Note the the local transformation is then reset to the identity matrix.

Parameters:

aLabel – the label in the scenegraph

std::vector<double> getNodeAndChildrenBoundingBox(const std::string &aLabel, const std::string &aUnitOfLength = "cm")#

Access the bounding box of a given node and all its children (if any). The bounding box is given in the world coordinate system.

Parameters:
  • aLabel – the label in the scenegraph

  • aUnitOfLength – the unit of length corresponding to the bounding box. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer” (default value: “cm”)

Returns:

the bounding box as: min_x, min_y, min_z, max_x, max_y, max_z

std::vector<double> getNodeOnlyBoundingBox(const std::string &aLabel, const std::string &aUnitOfLength = "cm")#

Access the bounding box of a given node (without its children). The bounding box is given in the world coordinate system.

Parameters:
  • aLabel – the label in the scenegraph

  • aUnitOfLength – the unit of length corresponding to the bounding box. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer” (default value: “cm”)

Returns:

the bounding box as: min_x, min_y, min_z, max_x, max_y, max_z

void invertNormalVectors(const std::string &aLabel)#

Invert the normal vectors of a given polygon mesh.

Parameters:

aLabel – the label of the polygon mesh

bool hasNormalVectorsInverted(const std::string &aLabel)#

Check if the normal vectors have been inverted.

Parameters:

aLabel – the label of the polygon mesh

Returns:

true if the normal vectors have been inverted; false otherwise.

void setColor(const std::string &aLabel, float R, float G, float B, float A)#

Set the color of a given polygon mesh.

Parameters:
  • aLabel – the label of the polygon mesh

  • R – the red channel

  • G – the green channel

  • B – the blue channel

  • A – the alpha channel

void setColour(const std::string &aLabel, float R, float G, float B, float A)#

Set the colour of a given polygon mesh. It will be applied to the ambiant, diffuse and specular colours.

Parameters:
  • aLabel – the label of the polygon mesh

  • R – the red channel

  • G – the green channel

  • B – the blue channel

  • A – the alpha channel

void setAmbiantColour(const std::string &aLabel, float R, float G, float B, float A)#

Set the ambiant colour of a given polygon mesh.

Parameters:
  • aLabel – the label of the polygon mesh

  • R – the red channel

  • G – the green channel

  • B – the blue channel

  • A – the alpha channel

std::vector<float> getAmbientColour(const std::string &aLabel)#

Accessor on the ambient colour of the material of a given polygon mesh.

Parameters:

aLabel – the label of the polygon mesh

Returns:

the ambient colour

void setDiffuseColour(const std::string &aLabel, float R, float G, float B, float A)#

Set the diffuse colour of a given polygon mesh.

Parameters:
  • aLabel – the label of the polygon mesh

  • R – the red channel

  • G – the green channel

  • B – the blue channel

  • A – the alpha channel

std::vector<float> getDiffuseColour(const std::string &aLabel)#

Accessor on the diffuse colour of the material of a given polygon mesh.

Parameters:

aLabel – the label of the polygon mesh

Returns:

the diffuse colour

void setSpecularColour(const std::string &aLabel, float R, float G, float B, float A)#

Set the specular colour of a given polygon mesh.

Parameters:
  • aLabel – the label of the polygon mesh

  • R – the red channel

  • G – the green channel

  • B – the blue channel

  • A – the alpha channel

std::vector<float> getSpecularColour(const std::string &aLabel)#

Accessor on the specular colour of the material of a given polygon mesh.

Parameters:

aLabel – the label of the polygon mesh

Returns:

the specular colour

void setShininess(const std::string &aLabel, float aShininessValue)#

Set the shininess of the material of a given polygon mesh.

Parameters:
  • aLabel – the label of the polygon mesh

  • aShininessValue – the shininess coefficient

float getShininess(const std::string &aLabel)#

Accessor on the shininess of the material of a given polygon mesh.

Parameters:

aLabel – the label of the polygon mesh

Returns:

the shininess coefficient

void addPolygonMeshAsInnerSurface(const std::string &aLabel)#

Add a polygon mesh, given its label, to the X-ray renderer as an inner surface.

Parameters:

aLabel – the label of the polygon mesh in the scenegraph

void addPolygonMeshAsOuterSurface(const std::string &aLabel)#

Add a polygon mesh, given its label, to the X-ray renderer as an outer surface.

Parameters:

aLabel – the label of the polygon mesh in the scenegraph

void removePolygonMeshesFromSceneGraph()#

Empty the scenegraph. Note that it also empties the X-ray renderer from all its meshes.

void removePolygonMeshesFromXRayRenderer()#

Empty the X-ray renderer from all its meshes. Note that the meshes are kept in the scenegraph.

file SimpleGVXR.h
#include <vector>
#include <utility>
#include <string>
#include “acquisition.h
#include “detector.h
#include “ImplicitSurface.h
#include “sample.h
#include “source.h
#include “Utils.h
#include “visualisation.h

SimpleGVXR is an API to the bulk functionalities and classes of gVirtualXRay. SimpleGVXR is used as the basis for the language bindings generated using SWIG.

Todo:

Write the equation for computeZNCC.

Version

1.0

Date

02/05/2024

Author

Prof Franck P. Vidal

License BSD 3-Clause License.

For details on use and redistribution please refer to http://opensource.org/licenses/BSD-3-Clause

Copyright (c) by Dr Franck P. Vidal, Bangor University, Apr 2019-Sept 2023, version 1.1, BSD 3-Clause License (c) by Prof Franck P. Vidal (franck.vidal@stfc.ac.uk), UK Research and Innovation, Oct 2023-present, version 1.1, BSD 3-Clause License

Functions

int getMajorVersionOfCoreGVXR()#

Accessor on the major version of the core gVirtualXRay library (gvxr). This number is changed when incompatible API changes have been made.

Returns:

the major version number

int getMinorVersionOfCoreGVXR()#

Accessor on the minor version of the core gVirtualXRay library (gvxr). This number is changed when new functionalities have been added in a backwards-compatible manner.

Returns:

the minor version number

int getPatchVersionOfCoreGVXR()#

Accessor on the minor version of the core gVirtualXRay library (gvxr). This number is changed when bug fixes have been added in a backwards-compatible manner.

Returns:

the patch version number

std::string getVersionOfCoreGVXR()#

Accessor on the full string version of the core gVirtualXRay library (gvxr).

Returns:

the full version number

int getMajorVersionOfSimpleGVXR()#

Accessor on the major version of SimpleGVXR. This number is changed when incompatible API changes have been made.

Returns:

the major version number

int getMinorVersionOfSimpleGVXR()#

Accessor on the minor version of SimpleGVXR. This number is changed when new functionalities have been added in a backwards-compatible manner.

Returns:

the minor version number

int getPatchVersionOfSimpleGVXR()#

Accessor on the minor version of SimpleGVXR. This number is changed when bug fixes have been added in a backwards-compatible manner.

Returns:

the patch version number

std::string getVersionOfSimpleGVXR()#

Accessor on the full string version of SimpleGVXR.

Returns:

the full version number

std::string getOpenGlRenderer()#

Accessor on the OpenGL renderer.

Returns:

a string displaying the OpenGL renderer

std::string getOpenGlVersion()#

Accessor on the OpenGL version.

Returns:

a string displaying the OpenGL version

std::string getOpenGlVendor()#

Accessor on the OpenGL vendor.

Returns:

a string displaying the OpenGL vendor

void useLogFile(const char *aFileName = "gvxr.log")#

Turn on/off the use of a log file.

Parameters:

aFileName – the name of the file in which the output will be saved. If it is equal to 0, NULL, or nullptr, the standard output, will be used (default value: “gvxr.log”)

void setSeed(unsigned int aRandomGeneratorSeed)#

Set the seed of the random number generator.

Parameters:

aRandomGeneratorSeed – the seed

void autoCreateOpenGLContext(bool aFlag = true)#

Create an OpenGL context automatically.

Parameters:

aFlag – true to create the OpenGL context automatically, false otherwise (default value: true)

std::vector<double> getIdentityMatrix4()#

Return a 4x4 identity matrix.

Returns:

a 4x4 identity matrix

void displayNode(const std::string &aLabel)#

Display the scenegraph node using OpenGL.

Parameters:

aLabel – the label of the polygon mesh

void moveToCenter()#

Move the scenegraph to the centre.

void moveToCentre()#

Move the scenegraph to the centre.

void moveToCenter(const std::string &aLabel)#

Move a polygon mesh to the centre.

Parameters:

aLabel – the label of the polygon mesh in the scenegraph

void moveToCentre(const std::string &aLabel)#

Move a polygon mesh to the centre.

Parameters:

aLabel – the label of the polygon mesh in the scenegraph

void scaleNode(const std::string &aLabel, double x, double y, double z)#

Scale a polygon mesh.

Parameters:
  • aLabel – the label of the polygon mesh to transform

  • x – the scaling factor along the X-axis

  • y – the scaling factor along the Y-axis

  • z – the scaling factor along the Z-axis

void rotateNode(const std::string &aLabel, double anAngle, double x, double y, double z)#

Rotate a polygon mesh.

Parameters:
  • aLabel – the label of the polygon mesh to transform

  • anAngle – the rotation angle in degrees

  • x – the component of the rotation vector along the X-axis

  • y – the component of the rotation vector along the Y-axis

  • z – the component of the rotation vector along the Z-axis

void rotateNode(const std::string &aLabel, double yaw, double pitch, double roll)#

Rotate a polygon mesh using the yaw, pitch, roll method.

Parameters:
  • aLabel – the label of the polygon mesh to transform

  • yaw – a counterclockwise rotation of yaw degrees about the z-axis

  • pitch – a counterclockwise rotation of yaw degrees about the y-axis

  • roll – a counterclockwise rotation of yaw degrees about the x-axis

void translateNode(const std::string &aLabel, double x, double y, double z, const std::string &aUnitOfLength)#

Translate a polygon mesh.

Parameters:
  • aLabel – the label of the polygon mesh to transform

  • x – the component of the translation vector along the X-axis

  • y – the component of the translation vector along the Y-axis

  • z – the component of the translation vector along the Z-axis

  • aUnitOfLength – the unit of length corresponding to the x, y and z parameters. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

void shearNode(const std::string &aLabel, double yx, double zx, double xy, double zy, double xz, double yz)#

Use a shear matrix to transform the node.

Parameters:
  • aLabel – the label of the polygon mesh to transform

  • yx – the yx component of the shear matrix

  • zx – the zx component of the shear matrix

  • xy – the xy component of the shear matrix

  • zy – the zy component of the shear matrix

  • xz – the xz component of the shear matrix

  • yz – the yz component of the shear matrix

void resetSceneTransformation()#

Replace the 3-D transformation matrix of the overall 3-D scene by an identity matrix.

void scaleScene(double x, double y, double z)#

Scale the 3-D scene (all the polygon meshes will be affected but not modified).

Parameters:
  • x – the scaling factor along the X-axis

  • y – the scaling factor along the Y-axis

  • z – the scaling factor along the Z-axis

void scaleScene(double x, double y, double z, const std::string &aUnitOfLength)#

Scale the 3-D scene (all the polygon meshes will be affected but not modified).

Parameters:
  • x – the scaling factor along the X-axis

  • y – the scaling factor along the Y-axis

  • z – the scaling factor along the Z-axis

  • aUnitOfLength – the unit of length corresponding to the x, y and z parameters. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

void rotateScene(double anAngle, double x, double y, double z)#

Rotate the 3-D scene (all the polygon meshes will be affected but not modified).

Parameters:
  • anAngle – the rotation angle in degrees

  • x – the component of the rotation vector along the X-axis

  • y – the component of the rotation vector along the Y-axis

  • z – the component of the rotation vector along the Z-axis

void rotateScene(double yaw, double pitch, double roll)#

Rotate the 3-D scene using the yaw, pitch, roll method (all the polygon meshes will be affected but not modified).

Parameters:
  • yaw – a counterclockwise rotation of yaw degrees about the z-axis

  • pitch – a counterclockwise rotation of yaw degrees about the y-axis

  • roll – a counterclockwise rotation of yaw degrees about the x-axis

void translateScene(double x, double y, double z, const std::string &aUnitOfLength)#

Translate the 3-D scene (all the polygon meshes will be affected but not modified).

Parameters:
  • x – the component of the translation vector along the X-axis

  • y – the component of the translation vector along the Y-axis

  • z – the component of the translation vector along the Z-axis

  • aUnitOfLength – the unit of length corresponding to the x, y and z parameters. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

std::vector<std::vector<float>> getSceneTransformationMatrix()#

Accessor on the 3-D scene transformation matrix.

Returns:

the 3-D scene transformation matrix as a 4x4 array

std::vector<std::vector<float>> getRootTransformationMatrix()#

Accessor on the transformation matrix of the scengraph’s root node.

Returns:

the scengraph’s root node transformation matrix as a 4x4 array

std::vector<std::vector<float>> getNodeLocalTransformationMatrix(const std::string &aLabel)#

Accessor on the transformation matrix of a given node.

Parameters:

aLabel – the label of the polygon mesh

Returns:

the scengraph’s root node transformation matrix as a 4x4 array

std::vector<std::vector<float>> getNodeWorldTransformationMatrix(const std::string &aLabel)#

Accessor on the transformation matrix of a given node.

Parameters:

aLabel – the label of the polygon mesh

Returns:

the scengraph’s root node transformation matrix as a 4x4 array

void setSceneTransformationMatrix(const std::vector<std::vector<float>> &aMatrix)#

Set the 3-D scene transformation matrix.

Parameters:

aMatrix – the transformation matrix as a 4x4 array

void setRootTransformationMatrix(const std::vector<std::vector<float>> &aMatrix)#

Set the transformation matrix of the scengraph’s root node.

Parameters:

aMatrix – the transformation matrix as a 4x4 array

void setNodeTransformationMatrix(const std::string &aLabel, const std::vector<std::vector<float>> &aMatrix)#

Set the transformation matrix of a given node.

Parameters:
  • aLabel – the label of the polygon mesh

  • aMatrix – the transformation matrix as a 4x4 array

void setHU(const std::string &aLabel, short HU)#

Set the Hounsfield value corresponding to the material properties of a polygon mesh.

Parameters:
  • aLabel – the label of the polygon mesh

  • HU – the Hounsfield value

void setHounsfieldUnit(const std::string &aLabel, short HU)#

Set the Hounsfield value corresponding to the material properties of a polygon mesh.

Parameters:
  • aLabel – the label of the polygon mesh

  • HU – the Hounsfield value

void setHounsfieldValue(const std::string &aLabel, short HU)#

Set the Hounsfield value corresponding to the material properties of a polygon mesh.

Parameters:
  • aLabel – the label of the polygon mesh

  • HU – the Hounsfield value

void setElement(const std::string &aLabel, unsigned short Z)#

Set the chemical element (or element) corresponding to the material properties of a polygon mesh.

Parameters:
  • aLabel – the label of the polygon mesh

  • Z – the atomic number (or Z number) corresponding to the element

void setElement(const std::string &aLabel, const std::string &aName)#

Set the chemical element (or element) corresponding to the material properties of a polygon mesh.

Parameters:
  • aLabel – the label of the polygon mesh

  • aName – the symbol or name corresponding to the element

void setMixture(const std::string &aLabel, const std::string &aMixture)#

Set the mixture corresponding to the material properties of a polygon mesh. Don’t forget to set the density of the material.

Parameters:
  • aLabel – the label of the polygon mesh

  • aMixture – the details about the mixture. It is given as a sequence of element symbol & relative weight, e.g. Ti90Al6V4.

void setMixture(const std::string &aLabel, const std::vector<int> &aZNumberSet, const std::vector<double> &aWeightSet)#

Set the mixture corresponding to the material properties of a polygon mesh. Don’t forget to set the density of the material.

Parameters:
  • aLabel – the label of the polygon mesh

  • aZNumberSet – the array of Z numbers

  • aWeightSet – the corresponding weights

void setMixture(const std::string &aLabel, const std::vector<std::string> &aSymbolSet, const std::vector<double> &aWeightSet)#

Set the mixture corresponding to the material properties of a polygon mesh. Don’t forget to set the density of the material.

Parameters:
  • aLabel – the label of the polygon mesh

  • aSymbolSet – the array of element symbols

  • aWeightSet – the corresponding weights

void setCompound(const std::string &aLabel, const std::string &aCompound)#

Set the compound corresponding to the material properties of a polygon mesh. Don’t forget to set the density of the material.

Parameters:
  • aLabel – the label of the polygon mesh

  • aCompound – the details about the compound. It is given as a sequence of element symbol & number of atoms, e.g. H2O for water and SiC for silicon carbide.

void setMassAttenuationCoefficient(const std::string &aLabel, double aCoefficient, const std::string &aUnit)#

Set the mass attenuation coefficient corresponding to the material properties of a polygon mesh. Don’t forget to set the density of the material.

Parameters:
  • aLabel – the label of the polygon mesh

  • aCoefficient – the mass attenuation coefficient

  • aUnit – the unit corresponding to aCoefficient. Acceptable values are: “cm2/g” and “cm2.g-1”

void setLinearAttenuationCoefficient(const std::string &aLabel, double aCoefficient, const std::string &aUnit)#

Set the linear attenuation coefficient corresponding to the material properties of a polygon mesh.

Parameters:
  • aLabel – the label of the polygon mesh

  • aCoefficient – the liner attenuation coefficient

  • aUnit – the unit corresponding to aCoefficient. Acceptable values are: “cm-1”

void setMu(const std::string &aLabel, double aCoefficient, const std::string &aUnit)#

Set the linear attenuation coefficient corresponding to the material properties of a polygon mesh.

Parameters:
  • aLabel – the label of the polygon mesh

  • aCoefficient – the liner attenuation coefficient

  • aUnit – the unit corresponding to aCoefficient. Acceptable values are: “cm-1”

void setDensity(const std::string &aLabel, double aDensity, const std::string &aUnit)#

Set the density corresponding to the material properties of a polygon mesh.

Parameters:
  • aLabel – the label of the polygon mesh

  • aDensity – the density

  • aUnit – the unit corresponding to aDensity. Acceptable values are: “g/cm3”, “g.cm-3”, “mg/cm3”, “mg.cm-3”, “kg/m3”, and “kg.m-3”.

double getDensity(const std::string &aLabel)#

Accessor on the density corresponding to the material properties of a polygon mesh.

Parameters:

aLabel – the label of the polygon mesh

Returns:

the density of the polygon mesh’s material in g/cm3

double getMassAttenuationCoefficient(const std::string &aLabel, double anEnergy, const std::string &aUnitOfEnergy)#

Accessor on the mass attenuation coefficient at a given energy corresponding to the material properties of a polygon mesh.

Parameters:
  • aLabel – the label of the polygon mesh

  • anEnergy – the photon energy of interest

  • aUnitOfEnergy – the unit of energy corresponding to anEnergy. Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

Returns:

the mass attenuation coefficient of the polygon mesh’s material in cm2/g

double getLinearAttenuationCoefficient(const std::string &aLabel, double anEnergy, const std::string &aUnitOfEnergy)#

Accessor on the linear attenuation coefficient at a given energy corresponding to the material properties of a polygon mesh.

Parameters:
  • aLabel – the label of the polygon mesh

  • anEnergy – the photon energy of interest

  • aUnitOfEnergy – the unit of energy corresponding to anEnergy. Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

Returns:

the linear attenuation coefficient of the polygon mesh’s material in cm-1

std::string getMaterialLabel(const std::string &aLabel)#

Accessor on the material label of a polygon mesh.

Parameters:

aLabel – the label of the polygon mesh

Returns:

the label of the material

void displayScene(bool aSceneRotationFlag = true, int aWindowID = -1)#

3-D visualisation of the 3-D scene (source, detector, and scanned objects). Note that there is no interactive loop running.

Parameters:
  • aSceneRotationFlag – true if the 3-D scene has to be rotated with the arc-ball method, false otherwise (default value: true)

  • aWindowID – the numerical ID of the corresponding context (default value: -1, means that the active context will be used)

void renderLoop(int aWindowID = -1)#

3-D visualisation of the 3-D scene (source, detector, and scanned objects). Note that there is interactive loop running. Keys are:

  • Q/Escape: to quit the event loop (does not close the window)

  • B: display/hide the X-ray beam

  • W: display the polygon meshes in solid or wireframe

  • N: display the X-ray image in negative or positive

  • L: switch lighting on/off

  • D: display/hide the X-ray detector

  • V: display/hide normal vectors

Parameters:

aWindowID – the numerical ID of the corresponding context (default value: -1, means that the active context will be used)

void startArcBallRotation(double x, double y)#

Call this function when the user starts an arc-ball rotation (e.g. left-mouse button click in the 3-D visualisation window).

Parameters:
  • x – the cursor x-axis position in the viewport coordinate system

  • y – the cursor y-axis position in the viewport coordinate system

void stopArcBallRotation()#

Call this function when the user stops an arc-ball rotation (e.g. release the left-mouse button click in the 3-D visualisation window).

bool usingArcBallRotation()#

Check if arc-ball rotation is currently in use.

Returns:

true if arc-ball rotation is currently in use, false otherwise

void cursorPositionCallback(double x, double y, int aViewportWidth, int aViewportHeight)#

Call this function when the user moves the mouse.

Parameters:
  • x – the cursor x-axis position in the viewport coordinate system

  • y – the cursor y-axis position in the viewport coordinate system

  • aViewportWidth – the size of the viewport along the x-axis

  • aViewportHeight – the size of the viewport along the y-axis

void scrollCallback(double xoffset, double yoffset)#

Call this function when the user scrolls.

Parameters:
  • xoffset – the scroll offset along the x-axis (not used)

  • yoffset – the scroll offset along the y-axis (used for zooming in and out)

void setZoom(float aZoomValue)#

Set the zoom value used in the 3D visualisation.

Parameters:

aZoomValue – the zoom value

float getZoom()#

Accessor on the zoom value used in the 3D visualisation.

Returns:

the zoom value

void setSceneRotationMatrix(const std::vector<double> &aRotationMatrix)#

Set the transformation matrix used in the 3D visualisation.

Parameters:

aRotationMatrix – the transformation matrix

std::vector<double> getSceneRotationMatrix()#

Accessor on the transformation matrix used in the 3D visualisation.

Returns:

the transformation matrix

void showWindow(int aWindowID = -1)#

Make an OpenGL context visible and display a window.

Parameters:

aWindowID – the numerical ID of the corresponding context (default value: -1, means that the active context will be used)

void hideWindow(int aWindowID = -1)#

Hide a window.

Parameters:

aWindowID – the numerical ID of the corresponding context (default value: -1, means that the active context will be used)

void setWindowPosition(int aPositionX, int aPositionY, int aWindowID = -1)#

Move a window.

Parameters:
  • aPositionX – the window position along the X axis of the screen

  • aPositionY – the window position along the Y axis of the screen

  • aWindowID – the numerical ID of the corresponding context (default value: -1, means that the active context will be used)

void setWindowBackGroundColour(float R, float G, float B, int aWindowID = -1)#

Set window background colour.

Parameters:
  • R – the red colour [0, 1]

  • G – the green colour [0, 1]

  • B – the blue colour [0, 1]

  • aWindowID – the numerical ID of the corresponding context (default value: -1, means that the active context will be used)

void setWindowBackGroundColor(float R, float G, float B, int aWindowID = -1)#

Set window background colour.

Parameters:
  • R – the red colour [0, 1]

  • G – the green colour [0, 1]

  • B – the blue colour [0, 1]

  • aWindowID – the numerical ID of the corresponding context (default value: -1, means that the active context will be used)

const std::vector<std::vector<std::vector<float>>> &takeScreenshot(int aWindowID = -1)#

Take screenshot.

Parameters:

aWindowID – the numerical ID of the corresponding context (default value: -1, means that the active context will be used)

Returns:

the 2D image in RGB

const std::vector<std::vector<std::vector<float>>> &getLatestScreenshot()#

Get the latest screenshot.

Returns:

the 2D image in RGB

std::vector<std::vector<float>> getWhiteImage(bool anIntegrateEnergyFlag = true)#

Get a flat field image that can be used in the flat-field correction (FFC). Note that if Poisson noise is used, the function will return a different image each time the function is called.

Parameters:

anIntegrateEnergyFlag – if true the energy fluence is returned, otherwise the number of photons is returned (default value: true)

Returns:

the 2D image in greyscale values

std::vector<std::vector<std::vector<float>>> getWhiteSpectralImage()#

Get a set of flat field images that can be used in the flat-field correction (FFC). When a spectral detector is used, a 2D image is generated for each energy band. Note that if Poisson noise is used, the function will return a different set each time the function is called.

Returns:

the set of 2D images in greyscale values

void saveSTLfile(const std::string &aLabel, const std::string &aFileName = std::string())#

Save the polygon mesh of a given node.

Parameters:
  • aLabel – the label of the polygon mesh

  • aFileName – the name of the output file (default: means that the filename will be automatically generated and the file saved in the current path)

unsigned int getMaxRadiusLbufferArtefactFilter()#

Accessor on the max radius of the L-buffer artefact correction filter.

Returns:

the radius in number of pixels

void setMaxRadiusLbufferArtefactFilter(unsigned int aRadius)#

Set the max radius of the L-buffer artefact correction filter.

Parameters:

aRadius – the radius in number of pixels

bool isArtefactFilteringOnGPUEnabled()#

Check whether the GPU implementation of the L-buffer artefact correction filter is enabled.

Returns:

true if the filter is active, otherwise return false

bool isArtefactFilteringOnCPUEnabled()#

Check whether the CPU implementation of the L-buffer artefact correction filter is enabled.

Returns:

true if the filter is active, otherwise return false

int getImageWidth(const std::vector<std::vector<float>> &anImage)#

Accessor on the width of a given image.

Parameters:

anImage – the image

Returns:

the width of the image (in number of pixels)

int getImageHeght(const std::vector<std::vector<float>> &anImage)#

Accessor on the height of a given image.

Parameters:

anImage – the image

Returns:

the height of the image (in number of pixels)

std::vector<float> getImageRow(const std::vector<std::vector<float>> &anImage, int j)#

Accessor on the j-th row of pixels of a given image.

Parameters:
  • anImage – the image

  • j – the row number

Returns:

the j-th row of pixels

std::string getElementName(unsigned short Z)#

Accessor on the chemical element’s name depending on its Z number.

Parameters:

Z – the atomic number of the element

Returns:

the name of the corresponding element

std::string getElementName(const std::string &aSymbol)#

Accessor on the chemical element’s name depending on its symbol.

Parameters:

aSymbol – the symbol of the element

Returns:

the name of the corresponding element

std::string getElementSymbol(unsigned short Z)#

Accessor on the chemical element’ symbol depending on its Z number.

Parameters:

Z – the atomic number of the element

Returns:

the name of the corresponding element

unsigned short getElementAtomicNumber(const std::string &anElement)#

Accessor on the chemical element’s Z number.

Parameters:

anElement – the name or symbol of the element

Returns:

the Z number of the corresponding element

double getDensityFromElement(const std::string &anElement)#

Accessor on the chemical element’s density.

Parameters:

anElement – the name or symbol of the element

Returns:

the density of the corresponding element (in g / cm3)

double getDensityFromElement(unsigned short Z)#

Accessor on the chemical element’s density.

Parameters:

Z – the Z number of the element

Returns:

the density of the corresponding element (in g / cm3)

double getDensityFromHU(double HU)#

Accessor on the HU’s density.

Parameters:

HU – the HU

Returns:

the density of the corresponding HU (in g / cm3)

double getMassAttenuationFromElement(const std::string &anElement, double anEnergy, const std::string &aUnitOfEnergy)#

Accessor on the chemical element’s mass attenuation.

Parameters:
  • anElement – the name or symbol of the element

  • anEnergy – the photon energy of interest

  • aUnitOfEnergy – the unit of energy corresponding to anEnergy. Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

Returns:

the mass attenuation of the corresponding element (in cm2/g)

double getMassAttenuationFromElement(unsigned short Z, double anEnergy, const std::string &aUnitOfEnergy)#

Accessor on the chemical element’s mass attenuation.

Parameters:
  • Z – the Z number of the element

  • anEnergy – the photon energy of interest

  • aUnitOfEnergy – the unit of energy corresponding to anEnergy. Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

Returns:

the mass attenuation of the corresponding element (in cm2/g)

double getMassAttenuationFromHU(double HU, double anEnergy, const std::string &aUnitOfEnergy)#

Accessor on the HU’s mass attenuation.

Parameters:
  • HU – the HU

  • anEnergy – the photon energy of interest

  • aUnitOfEnergy – the unit of energy corresponding to anEnergy. Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

Returns:

the density of the corresponding HU (in cm2/g)

double getMassAttenuationFromMixture(const std::string &aMixture, double anEnergy, const std::string &aUnitOfEnergy)#

Accessor on the mixture’s mass attenuation.

Parameters:
  • aMixture – the details about the mixture. It is given as a sequence of element symbol & relative weight, e.g. Ti90Al6V4.

  • anEnergy – the photon energy of interest

  • aUnitOfEnergy – the unit of energy corresponding to anEnergy. Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

Returns:

the mass attenuation of the corresponding mixture (in cm2/g)

double getMassAttenuationFromCompound(const std::string &aCompound, double anEnergy, const std::string &aUnitOfEnergy)#

Accessor on the compound’s mass attenuation.

Parameters:
  • aCompound – the details about the compound. It is given as a sequence of element symbol & number of atoms, e.g. H2O for water and SiC for silicon carbide.

  • anEnergy – the photon energy of interest

  • aUnitOfEnergy – the unit of energy corresponding to anEnergy. Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

Returns:

the mass attenuation of the corresponding compound (in cm2/g)

double getMuFromHU(double HU, double anEnergy, const std::string &aUnitOfEnergy)#

Accessor on the HU’s linear attenuation coefficient.

Parameters:
  • HU – the HU

  • anEnergy – the photon energy of interest

  • aUnitOfEnergy – the unit of energy corresponding to anEnergy. Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

Returns:

the linear attenuation coefficient (in cm-1)

std::vector<std::vector<std::vector<float>>> convertHU2mu(const std::vector<std::vector<std::vector<float>>> &anImage, double anEnergy, const std::string &aUnitOfEnergy)#

Convert a 3D volume in HU values into linear attenuation coefficients.

Parameters:
  • anImage – the 3D volume in HU values

  • anEnergy – the photon energy of interest

  • aUnitOfEnergy – the unit of energy corresponding to anEnergy. Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

Returns:

the 3D volume in linear attenuation coefficients (cm^-1)

std::vector<float> rayIntersect(const std::string &aLabel, double aRayOriginX, double aRayOriginY, double aRayOriginZ, double aRayDirectionX, double aRayDirectionY, double aRayDirectionZ)#

void setShiftFilter(double aValue); void setScaleFilter(double aValue); double getShiftFilter(); double getScaleFilter();

double getMean(const std::vector<float> &anImage)#

Compute the arithmetic mean of a 1D array.

Parameters:

anImage – the 1D array

Returns:

the arithmetic mean

double getStddev(const std::vector<float> &anImage)#

Compute the standard deviation of a 1D array.

Parameters:

anImage – the 1D array

Returns:

the standard deviation

double computeZNCC(const std::vector<float> &aReferenceSet, const std::vector<float> &aTestSet)#

Compute the zero-normalized cross-correlation (ZNCC) (also known as zero-mean unit-variance cross-correlation) between two 1D arrays aReferenceSet \((\theta)\) and aTestImage \(\left(\hat{\theta}\right)\). The ZNCC has a range of [-1, 1]. When the ZNCC is equal to -1, then \(\theta\) and \(\hat{\theta}\) are anticorrelated; when the ZNCC is equal to +1, then \(\theta\) and \(\hat{\theta}\) are fully correlated; and when the ZNCC is equal to 0, then \(\theta\) and \(\hat{\theta}\) are not correlated at all.

Parameters:
  • aReferenceSet – the 1st 1D array

  • aTestSet – the 2nd 1D array

Returns:

the ZNCC between aReferenceSet and aTestSet

double computeRMSE(const std::vector<float> &aReferenceSet, const std::vector<float> &aTestSet, bool normalise = false)#

Compute the root mean squared error (RMSE) (also known as root mean squared distance, RMSD) between two 1D arrays aReferenceSet \((\theta)\) and aTestImage \(\left(\hat{\theta}\right)\). When RMSE is close to zero, then \(\theta\) and \(\hat{\theta}\) are similar.

\[\begin{split}\begin{eqnarray*} MSE(\theta, \hat{\theta}) &=& \frac{\sum_{i = 0}^{I-1}\left(\theta(i) - \hat{\theta}(i)\right)^2}{I}\\ RMSE(\theta, \hat\theta) &=& \sqrt{MSE\left(\theta, \hat\theta\right)} \end{eqnarray*}\end{split}\]

Parameters:
  • aReferenceSet – the 1st 1D array

  • aTestSet – the 2nd 1D array

  • normalise – if the flag is true, the data will be normalised between 0 and 1. If it is false, the data is not normalised. (default value: false)

Returns:

the RMSE between aReferenceSet and aTestSet

void loadReference(const std::vector<float> &aReferenceSet)#

Load the reference data \((\theta)\) as a 1D array. It can be used with computeZNCC and computeRMSE.

Parameters:

aReferenceSet – the 1st 1D array

void loadTest(const std::vector<float> &aTestSet)#

Load the test data \(\left(\hat{\theta}\right)\) as a 1D array. It can be used with computeZNCC and computeRMSE.

Parameters:

aTestSet – the 2nd 1D array

void lineariseTest(float aThreshold, float aScalingFactor)#

Linearise the test data \(\left(\hat{\theta}\right)\) as follows:

\[\begin{eqnarray*} \hat{\theta}(i) = -\log(aScalingFactor \times \max(aThreshold, \hat{\theta}(i))) \end{eqnarray*}\]

Parameters:
  • aThreshold – the 2nd 1D array

  • aScalingFactor – the 2nd 1D array

double computeZNCC()#

Compute the zero-normalized cross-correlation (ZNCC) (also known as zero-mean unit-variance cross-correlation) between two 1D arrays ( \((\theta)\) and \(\left(\hat{\theta}\right)\)) that were previously loaded using loadReference and loadTest. The ZNCC has a range of [-1, 1]. When the ZNCC is equal to -1, then \(\theta\) and \(\hat{\theta}\) are anticorrelated; when the ZNCC is equal to +1, then \(\theta\) and \(\hat{\theta}\) are fully correlated; and when the ZNCC is equal to 0, then \(\theta\) and \(\hat{\theta}\) are not correlated at all.

Returns:

the ZNCC between \((\theta)\) and \(\left(\hat{\theta}\right)\)

double computeRMSE(bool normalise = false)#

Compute the root mean squared error (RMSE) (also known as root mean squared distance, RMSD) between two 1D arrays ( \((\theta)\) and \(\left(\hat{\theta}\right)\)) that were previously loaded using loadReference and loadTest. When RMSE is close to zero, then \(\theta\) and \(\hat{\theta}\) are similar.

\[\begin{split}\begin{eqnarray*} MSE(\theta, \hat{\theta}) &=& \frac{\sum_{i = 0}^{I-1}\left(\theta(i) - \hat{\theta}(i)\right)^2}{I}\\ RMSE(\theta, \hat\theta) &=& \sqrt{MSE\left(\theta, \hat\theta\right)} \end{eqnarray*}\end{split}\]

Parameters:

normalise – if the flag is true, the data will be normalised between 0 and 1. If it is false, the data is not normalised. (default value: false)

Returns:

the RMSE between \((\theta)\) and \(\left(\hat{\theta}\right)\)

std::vector<std::vector<float>> loadImage2D(const std::string &aFileName)#

Load a 2D image from a file.

Parameters:

aFileName – the file name of the 2D image

Returns:

the corresponding 2D image

std::vector<std::vector<std::vector<float>>> loadImage3D(const std::string &aFileName)#

Load a 3D volume from a file.

Parameters:

aFileName – the file name of the 3D volume

Returns:

the corresponding 3D volume

float getMinValue(const std::vector<std::vector<std::vector<float>>> &a3DVolume)#

Find the smallest voxel value in a 3D volume.

Parameters:

a3DVolume – the 3D volume

Returns:

the smallest voxel value

float getMaxValue(const std::vector<std::vector<std::vector<float>>> &a3DVolume)#

Find the largest voxel value in a 3D volume.

Parameters:

a3DVolume – the 3D volume

Returns:

the largest voxel value

double computeZNCC(const std::vector<std::vector<std::vector<float>>> &aReferenceSet, const std::vector<std::vector<std::vector<float>>> &aTestSet)#

Compute the zero-normalized cross-correlation (ZNCC) (also known as zero-mean unit-variance cross-correlation) between two 3D volumes. The ZNCC has a range of [-1, 1]. When the ZNCC is equal to -1, then the two volume are anticorrelated; when the ZNCC is equal to +1, then the two volume are fully correlated; and when the ZNCC is equal to 0, then the two volume are not correlated at all.

Parameters:
  • aReferenceSet – the 1st 3D volume

  • aTestSet – the 2nd 3D volume

Returns:

the ZNCC between aReferenceSet and aTestSet

double computeRMSE(const std::vector<std::vector<std::vector<float>>> &aReferenceSet, const std::vector<std::vector<std::vector<float>>> &aTestSet)#

Compute the root mean squared error (RMSE) (also known as root mean squared distance or root mean square deviation, RMSD) between two 3D volumes aReferenceSet \((\theta)\) and aTestSet \(\left(\hat{\theta}\right)\). When RMSE is close to zero, then \(\theta\) and \(\hat{\theta}\) are similar.

\[\begin{split}\begin{eqnarray*} MSE(\theta, \hat{\theta}) &=& \frac{\sum_{i = 0}^{I-1}\sum_{j = 0}^{J-1}\sum_{k = 0}^{K-1}\left(\theta(i,j,k) - \hat{\theta}(i,j,k)\right)^2}{I \times J \times K}\\ RMSE(\theta, \hat\theta) &=& \sqrt{MSE\left(\theta, \hat\theta\right)} \end{eqnarray*}\end{split}\]

Parameters:
  • aReferenceSet – the 1st 3D volume

  • aTestSet – the 2nd 3D volume

Returns:

the RMSE between aReferenceSet and aTestSet

file source.h

Expose here all the functions of SimpleGVXR related to the X-ray source. It includes the beam spectrum.

Todo:

The use of PythonLibs is disabled by default. All the functions related to the setting of the spectrum using voltage, mAs, tube angle and beam filtration may not have any visible effect.

Version

1.0

Date

07/05/2024

Author

Prof Franck P. Vidal

License BSD 3-Clause License.

For details on use and redistribution please refer to http://opensource.org/licenses/BSD-3-Clause

Copyright (c) by Prof Franck P. Vidal (franck.vidal@stfc.ac.uk), UK Research and Innovation, May 2024-present, version 1.1, BSD 3-Clause License

Functions

void setSourcePosition(double x, double y, double z, const std::string &aUnitOfLength)#

Set the position of the X-ray source.

Parameters:
  • x – the position along the X-axis

  • y – the position along the Y-axis

  • z – the position along the Z-axis

  • aUnitOfLength – the unit of length corresponding to the x, y and z parameters. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

std::string getSourceShape()#

Accessor on the shape of the X-ray source.

std::vector<double> getSourcePosition(const std::string &aUnitOfLength)#

Accessor on the position of the X-ray source.

Parameters:

aUnitOfLength – the unit of length corresponding to the returned value. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

Returns:

the source position in a given unit of length

void usePointSource()#

Use a point source, i.e. a cone-beam geometry.

void useConeBeam()#

Use a cone-beam geometry, i.e. a point source.

void useParallelBeam()#

Use a parallel source (e.g. to mimic a source that is extremely far from the scanned object and detector).

void useParallelSource()#

Use a parallel source (e.g. to mimic a source that is extremely far from the scanned object and detector).

bool isUsingParallelBeam()#

Check if the beam shape is parallel (e.g. to mimic a source that is extremely far from the scanned object and detector).

Returns:

true if the beam shape is parallel, false otherwise

bool isUsingParallelSource()#

Check if the beam shape is parallel (e.g. to mimic a source that is extremely far from the scanned object and detector).

Returns:

true if the beam shape is parallel, false otherwise

bool isUsingPointSource()#

Check if the beam shape is cone-beam and the source an infinitively small point.

Returns:

true if an infinitively small point source is used, false otherwise

bool isUsingConeBeam()#

Check if the beam shape is cone-beam. Note that an infinitively small point source or a finite size focal spot may have been used.

Returns:

true if a cone-beam shape is used, false otherwise

bool isUsingFocalSpot()#

Check if the beam shape is cone-beam and the source a finite size focal spot.

Returns:

true if a finite size focal spot is used, false otherwise

void setFocalSpot(float x, float y, float z, float l, const std::string &aUnitOfLength, int i)#

Set the size of the focal spot of the X-ray generator. A cube shape is used. The volume of the cube is sampled by i^3 point sources.

Parameters:
  • x – the position along the X-axis

  • y – the position along the Y-axis

  • z – the position along the Z-axis

  • l – the lenght of the cube along the 3 axes

  • aUnitOfLength – the unit of length. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

  • i – the number of point souces used along each axes.

void setFocalSpotAsSquare(float x, float y, float z, float l, const std::string &aUnitOfLength, int i)#

Set the size of the focal spot of the X-ray generator. A square shape is used. The area of the square is sampled by i*i point sources.

Parameters:
  • x – the position along the X-axis

  • y – the position along the Y-axis

  • z – the position along the Z-axis

  • l – the length of the square

  • aUnitOfLength – the unit of length. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

  • i – the number of point souces used along each axes.

void setFocalSpotAsRectangle(float x, float y, float z, float l, float k, const std::string &aUnitOfLength, int i, int j)#

Set the size of the focal spot of the X-ray generator. A rectangle shape is used. The area of the rectangle is sampled by i*j point sources.

Parameters:
  • x – the position along the X-axis

  • y – the position along the Y-axis

  • z – the position along the Z-axis

  • l – the length of the rectangle along the axis defined by the cross product between the source-detector centres and the detector up-vector

  • k – the height of the source along the detector up-vector direction

  • aUnitOfLength – the unit of length. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

  • i – the number of point sources along the axis defined by the cross product between the source-detector centres and the detector up-vector.

  • j – the number of point sources along the detector up-vector direction.

void rotateFocalSpot(const double &aRotationAngle, double u, double v, double w)#

Rotate the focal spot around its centre.

Parameters:
  • aRotationAngle – the rotation angle in degrees

  • u – the rotaton axis along the X-axis

  • v – the rotaton axis along the Y-axis

  • w – the rotaton axis along the Z-axis

void rotateSource(const double &aRotationAngle, double x, double y, double z, double u, double v, double w)#

Rotate the focal spot around an arbitrary point.

Parameters:
  • aRotationAngle – the rotation angle in degrees

  • x – the rotaton centre along the X-axis

  • y – the rotaton centre along the Y-axis

  • z – the rotaton centre along the Z-axis

  • u – the rotaton axis along the X-axis

  • v – the rotaton axis along the Y-axis

  • w – the rotaton axis along the Z-axis

void resetBeamSpectrum(bool aClearTubeParameterFlag = true)#

Empty the beam spectrum.

Parameters:

aClearTubeParameterFlag – if the flag is true, then the X-ray tubes parameters are reset too

void setMonoChromatic(double anEnergy, const std::string &aUnitOfEnergy, double aNumberOfPhotons)#

Use a monochromatic beam spectrum (i.e. one single energy).

Parameters:
  • anEnergy – the incident photon energy

  • aUnitOfEnergy – the unit of energy corresponding to anEnergy. Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

  • aNumberOfPhotons – the number of incident photons

void addEnergyBinToSpectrum(double anEnergy, const std::string &aUnitOfEnergy, double aNumberOfPhotons)#

Add an energy bin to the beam spectrum (useful to generate polychromatism).

Parameters:
  • anEnergy – the incident photon energy

  • aUnitOfEnergy – the unit of energy corresponding to anEnergy. Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

  • aNumberOfPhotons – the number of incident photons

void loadSpectrumFromTSV(const std::string &aFileName, const std::string &aUnitOfEnergy, bool aNormalisationFlag)#

Load the incident beam energy spectrum from a TSV file.

Parameters:
  • aFileName – name of the file to load

  • aUnitOfEnergy – the unit of energy corresponding to anEnergy. Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

  • aNormalisationFlag – true to normalise the total energy to 1, false otherwise

std::vector<double> getEnergyBins(const std::string &aUnitOfEnergy)#

Accessor on the energy bins of the beam spectrum.

Parameters:

aUnitOfEnergy – the unit of energy corresponding to the returned vector. Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

Returns:

the list of energy bins in aUnitOfEnergy

std::vector<double> getPhotonCountEnergyBins()#

Accessor on the number of photons per energy bin of the beam spectrum.

Returns:

the list of number of photons

double getTotalEnergyWithDetectorResponse()#

Accessor on a total energy of the beam when the detector response is applied.

Returns:

the total energy

void setVoltage(const float &aVoltage, const std::string &aUnitOfElectriPotential)#

Set the voltage of the X-ray tube.

Parameters:
  • aVoltage – the voltage

  • aUnitOfElectriPotential – the unit of electric potential to the voltage of the tube. Acceptable values are: “megavolt”, “MV”, “kilovolt”, “kV”, “volt”, “V”

float getVoltage(const std::string &aUnitOfElectriPotential)#

Accessor on the voltage of the X-ray tube.

Parameters:

aUnitOfElectriPotential – the unit of electric potential to the voltage of the tube. Acceptable values are: “megavolt”, “MV”, “kilovolt”, “kV”, “volt”, “V”

Returns:

the voltage of the X-ray tube

void setmAs(const float &an_mAs)#

Set the exposure in milliampere second (mA⋅s).

Parameters:

an_mAs – the exposure

float getmAs()#

Accessor on the exposure in milliampere second (mA⋅s).

Returns:

the exposure

void setTubeAngle(const float &anAngle)#

Set the angle of the X-ray tube (i.e. its anode’s target) in degrees.

Parameters:

anAngle – the angle

float getTubeAngle()#

Accessor on the angle of the X-ray tube (i.e. its anode’s target) in degrees.

Returns:

the angle

void clearFiltration()#

If the beam is filtered, remove all the filtration.

void setFiltration(const std::vector<std::pair<unsigned int, float>> &aSetOfFilters, const std::string &aUnitOfLength)#

Set the beam filtration.

Parameters:
  • aSetOfFilters – the set of filter. In the C++ notation, it is a vector of pairs of unsigned int and float. Each unsigned int value corresponds to the Z number of the material of the filter; and each float value corresponds to the thickness of the filter. Several filters can be used.

  • aUnitOfLength – the unit of length. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

void addFilter(const std::string &aMaterial, const double &aThickness, const std::string &aUnitOfLength)#

Add a filter.

Parameters:
  • aMaterial – The symbol of the material of the filter

  • aThickness – The thickness of the filter

  • aUnitOfLength – the unit of length. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

void addFilter(unsigned int aMaterial, const double &aThickness, const std::string &aUnitOfLength)#

Add a filter.

Parameters:
  • aMaterial – The Z number of the material of the filter

  • aThickness – The thickness of the filter

  • aUnitOfLength – the unit of length. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

std::vector<unsigned int> getFiltrationMaterial()#

Accessor on all the materials (Z numbers) of all the beam filters used.

Returns:

the Z numbers corresponding to the beam filters used. If none is used, an empty array is returned.

std::vector<float> getFiltrationThickness(const std::string &aUnitOfLength)#

Accessor on all the thickness of all the beam filters used.

Parameters:

aUnitOfLength – the unit of length corresponding to the thicknesses. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

Returns:

the thickness of all the beam filters used. If none is used, an empty array is returned.

bool hasSpekpy()#

Check if the Spekpy backend is available internally.

Returns:

true if the Spekpy backend is available, otherwise false

bool hasXpecgen()#

Check if the Xpecgen backend is available internally.

Returns:

true if the Xpecgen backend is available, otherwise false

void useSpekpy()#

Use Spekpy internally if possible.

void useXpecgen()#

Use Xpecgen internally if possible.

bool usingSpekpy()#

Check if the Spekpy backend is being used internally.

Returns:

true if the Spekpy backend is being used, otherwise false

bool usingXpecgen()#

Check if the Xpecgen backend is being used internally.

Returns:

true if the Xpecgen backend is being used, otherwise false

void enablePoissonNoise()#

Enable Poisson noise for the energy fluence.

void disablePoissonNoise()#

Disable Poisson noise for the energy fluence.

void setNumberOfPhotons(unsigned int aNumberOfPhotons)#

Set the total number of photons per pixel.

Parameters:

aNumberOfPhotons – the number of photons

void setNumberOfPhotonsPerPixel(unsigned int aNumberOfPhotons)#

Set the total number of photons per pixel.

Parameters:

aNumberOfPhotons – the number of photons

void setNumberOfPhotonsPerCM2(double aNumberOfPhotons)#

Set the total number of photons per square centimetre.

Parameters:

aNumberOfPhotons – the number of photons

unsigned int getNumberOfPhotons()#

Accessor on the total number of photons per pixel.

Returns:

the number of photons

unsigned int getNumberOfPhotonsPerPixel()#

Accessor on the total number of photons per pixel.

Returns:

the number of photons

unsigned int getNumberOfPhotonsPerCM2()#

Accessor on the total number of photons per square centimetre.

Returns:

the number of photons

void usePoissonNoise(bool aFlag)#

Enable or disable Poisson noise for the energy fluence.

Parameters:

aFlag – if true, then enable Poisson noise. If false, then disable it

bool usePoissonNoise()#

Check if Poisson noise for the energy fluence is enable or disable.

Returns:

true if Poisson noise is enable, or false if Poisson noise is disable

file Utils.h
#include <string>
#include <vector>

Utility functions that do not belong anywhere in particular.

License BSD 3-Clause License.

Version

1.0

Date

08/08/2024

Author

Prof Franck P. Vidal

For details on use and redistribution please refer to http://opensource.org/licenses/BSD-3-Clause

Copyright (c) by Prof Franck P. Vidal (franck.vidal@stfc.ac.uk), UK Research and Innovation, Aug 2024-present, version 1.1, BSD 3-Clause License

Functions

float radian2degree(float anAngle)#

Convert an angle given in radians into degrees.

Parameters:

anAngle – the angle in radians

Returns:

the corresponding angle in degrees

double getUnitOfEnergy(const std::string &aUnitOfEnergy)#

Accessor on the numerical value corresponding to a unit of energy.

Parameters:

aUnitOfEnergy – the unit of energy. Acceptable values are: “electronvolt”, “eV”, “kiloelectronvolt”, “keV”, “megaelectronvolt”, “MeV”

Returns:

the corresponding numerical value

double getUnitOfLength(const std::string &aUnitOfLength)#

Accessor on the numerical value corresponding to a unit of length.

Parameters:

aUnitOfLength – the unit of length. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

Returns:

the corresponding numerical value

double getUnitOfElectriPotential(const std::string &aUnitOfElectriPotential)#

Accessor on the numerical value corresponding to a unit of electric potential.

Parameters:

aUnitOfElectriPotential – the unit of electric potential. Acceptable values are: “V”, “volt”, “kV”, “kilovolt”, “MV”, “megavolt”

Returns:

the corresponding numerical value

void enableArtefactFilteringOnGPU(void)#

Enable artefact filtering on GPU (it is fast but can be inaccurate).

void enableArtifactFilteringOnGPU(void)#

Enable artefact filtering on GPU (it is fast but can be inaccurate).

void enableArtefactFilteringOnCPU(void)#

Enable artefact filtering on CPU (can be extremely slow as it makes use of ray-tracing).

void enableArtifactFilteringOnCPU(void)#

Enable artefact filtering on CPU (can be extremely slow as it makes use of ray-tracing).

void disableArtefactFiltering(void)#

Disable artefact filtering altogether.

void disableArtifactFiltering(void)#

Disable artefact filtering altogether.

unsigned int getNumberOfEGLDevices()#

Accessor on the number of EGL devices.

std::vector<std::string> findEGLClients()#

Accessor on the list of supported EGL clients.

void createOpenGLContext(int aWindowID = -1, int aRendererMajorVersion = 4, int aRendererMinorVersion = 3)#

Create an OpenGL context (the window won’t be shown).

Parameters:
  • aWindowID – the numerical ID of the context to create (default value: -1, means that the ID will be automatically generated)

  • aRendererMajorVersion – Select the major version of the renderer. (default value: 4)

  • aRendererMinorVersion – Select the minor version of the renderer. (default value: 3)

void createWindow(int aWindowID = -1, int aVisibilityFlag = 0, const std::string &aRenderer = "OPENGL", int aRendererMajorVersion = 4, int aRendererMinorVersion = 3)#

Create an OpenGL context and display it in a window.

Parameters:
  • aWindowID – the numerical ID of the context to create (default value: -1, means that the ID will be automatically generated)

  • aRenderer – Select the renderer to use, e.g. OpenGL or Vulkan. (default value: OPENGL)

  • aRendererMajorVersion – Select the major version of the renderer. (default value: 4)

  • aRendererMinorVersion – Select the minor version of the renderer. (default value: 3)

  • aVisibilityFlag – flag controling if the window should be visible (1) or hidden (0). (default value: 0)

void createNewContext(const std::string &aRenderer = "OPENGL", int aWindowID = -1, int aVisibilityFlag = 0, int aRendererMajorVersion = 4, int aRendererMinorVersion = 3)#

Create an OpenGL context.

Parameters:
  • aRenderer – Select the renderer to use, e.g. OpenGL or Vulkan. (default value: OPENGL)

  • aWindowID – the numerical ID of the context to create (default value: -1, means that the ID will be automatically generated)

  • aRendererMajorVersion – Select the major version of the renderer. (default value: 4)

  • aRendererMinorVersion – Select the minor version of the renderer. (default value: 3S)

  • aVisibilityFlag – flag controling if the window should be visible (1) or hidden (0). (default value: 0)

void setWindowSize(int aWidth, int aHeight, int aWindowID = -1)#

Set the size of the given window.

Parameters:
  • aWidth – the number of pixels along the X-axis

  • aHeight – the number of pixels along the Y-axis

  • aWindowID – the numerical ID of the corresponding context (default value: -1, means that the active context will be used)

std::vector<int> getWindowSize(int aWindowID = -1)#

Accessor on the size of a given window.

Returns:

the size of the window

void destroyWindow(int aWindowID = -1)#

Close and destroy a given window or OpenGL context.

void destroyAllWindows(void)#

Close and destroy all the windows and OpenGL contexts that have been created. Same as void terminate(void);.

void terminate(void)#

Close and destroy all the windows and OpenGL contexts that have been created. Same as void destroyAllWindows(void);.

file visualisation.h

Expose here all the functions of SimpleGVXR related to the 3D visualisation.

License BSD 3-Clause License.

Version

1.0

Date

07/05/2024

Author

Prof Franck P. Vidal

For details on use and redistribution please refer to http://opensource.org/licenses/BSD-3-Clause

Copyright (c) by Prof Franck P. Vidal (franck.vidal@stfc.ac.uk), UK Research and Innovation, May 2024-present, version 1.1, BSD 3-Clause License

Functions

void displayBeam(bool aState = true)#

Display the beam in the 3D visualisation.

Parameters:

aState – if true the beam will be displayed, otherwise it won’t be (default value: true)

void displayDetector(bool aState = true)#

Display the detector in the 3D visualisation.

Parameters:

aState – if true the detector will be displayed, otherwise it won’t be (default value: true)

void displayNormalVectors(bool aState = true)#

Display the normal vectors of the sample in the 3D visualisation.

Parameters:

aState – if true the normal vectors will be displayed, otherwise they won’t be (default value: true)

void useWireframe(bool aState = true)#

Use wireframe rendering in the 3D visualisation.

Parameters:

aState – if true the sample will be displayed in wireframe, otherwise it’ll be solid (default value: true)

void useLighing(bool aState = true)#

Use lighting in the 3D visualisation.

Parameters:

aState – if true lighting will be on, otherwise it’ll be off (default value: true)

void useNegative(bool aState = true)#

Use a negative LUT to show the X-ray projection in the 3D visualisation.

Parameters:

aState – if true the X-ray projection will be shown in negative, otherwise in positive (default value: true)

void setAxisLength(float aLength, const std::string &aUnitOfLength)#

Set the size of the axis widget in the 3D visualisation.

Parameters:
  • aLength – Size of the axis widget

  • aUnitOfLength – the unit of length corresponding to aLength. Acceptable values are: “um”, “micrometre”, “micrometer”, “mm”, “millimetre”, “millimeter”, “cm”, “centimetre”, “centimeter”, “dm”, “decimetre”, “decimeter”, “m”, “metre”, “meter”, “dam”, “decametre”, “decameter”, “hm”, “hectometre”, “hectometer”, “km”, “kilometre”, “kilometer”

void orthographic(double left, double right, double bottom, double top, double zNear, double zFar)#

Replace the projection matrix by a orthographic projection matrix. It behaves as the old glOrtho function.

Parameters:
  • left – Specify the coordinates for the left vertical clipping plane

  • right – Specify the coordinates for the right vertical clipping plane

  • bottom – Specify the coordinates for the bottom horizontal clipping plane

  • top – Specify the coordinates for the top horizontal clipping plane

  • zNear – Specify the distances to the near clipping plane. The value must be positive

  • zFar – Specify the distances to the far clipping plane. The value must be positive

void perspective(double fovy, double aspect, double zNear, double zFar)#

Replace the projection matrix by a perspective projection matrix. It behaves as the old gluPerspective function.

Parameters:
  • fovy – specifies the field of view angle, in degrees, in the y-direction.

  • aspect – Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).

  • zNear – Specifies the distance from the viewer to the near clipping plane (always positive)

  • zFar – Specifies the distance from the viewer to the far clipping plane (always positive).

void lookAt(double eyeX, double eyeY, double eyeZ, double lookAtX, double lookAtY, double lookAtZ, double upX, double upY, double upZ)#

Replace the modelling-viewing matrix by a viewing transformation matrix. It behaves as the old gluLookAt function.

Parameters:
  • eyeX – Specifies the position of the eye point along the X-axis

  • eyeY – Specifies the position of the eye point along the Y-axis

  • eyeZ – Specifies the position of the eye point along the Z-axis

  • lookAtX – Specifies the position of the reference point along the X-axis

  • lookAtY – Specifies the position of the reference point along the Y-axis

  • lookAtZ – Specifies the position of the reference point along the Z-axis

  • upX – Specifies the direction of the up vector along the X-axis

  • upY – Specifies the direction of the up vector along the Y-axis

  • upZ – Specifies the direction of the up vector along the Z-axis

void pushModelViewMatrix()#

Add the current matrix to the model/view matrix stack. It behaves as the combination of the old glMatrixMode(GL_MODELVIEW);glPushMatrix() functions.

void popModelViewMatrix()#

Restore the matrix from the model/view matrix stack, and remove the last matrix of the stack. glMatrixMode(GL_MODELVIEW);glPopMatrix() functions.

void rotateModelView(double anAngle, double x, double y, double z)#

Restore the matrix from the model/view matrix stack, and remove the last matrix of the stack. glMatrixMode(GL_MODELVIEW);glRotate() functions.

Parameters:
  • anAngle – the angle of rotation in degrees

  • x – the coordinate of the rotation axis along the X-axis

  • y – the coordinate of the rotation axis along the Y-axis

  • z – the coordinate of the rotation axis along the Z-axis

page todo

File SimpleGVXR.h

Write the equation for computeZNCC.

File source.h

The use of PythonLibs is disabled by default. All the functions related to the setting of the spectrum using voltage, mAs, tube angle and beam filtration may not have any visible effect.

dir /home/fpvidal/PROGRAMMING/gvirtualxray/SimpleGVXR/include
dir /home/fpvidal/PROGRAMMING/gvirtualxray/SimpleGVXR