Fraxinus  2023.01.05-dev+develop.0da12
An IGT application
cxReconstructedOutputVolumeParams.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 
14 
15 namespace cx
16 {
17 
19  mInputSpacing(0),
20  mMaxVolumeSize(32*1000),
21  mValid(false)
22 {
23 
24 }
27 OutputVolumeParams::OutputVolumeParams(DoubleBoundingBox3D extent, double inputSpacing, double maxVolumeSize) :
28  mInputSpacing(inputSpacing), mMaxVolumeSize(maxVolumeSize), mValid(false)
29 {
30  mImage.setSpacingKeepDim(Eigen::Array3d(inputSpacing, inputSpacing, inputSpacing));
31  mImage.setDimKeepBoundsAlignSpacing(extent.range());
32 
33  this->constrainVolumeSize();
34 
35  if(mImage.getDim().minCoeff() <= 1) //At least one of the dimensions <= 1
36  mValid = false;
37  else
38  mValid = true;
39 }
40 
41 unsigned long OutputVolumeParams::getVolumeSize() const
42 {
43  return mImage.getNumVoxels();
44 }
45 
48 void OutputVolumeParams::setSpacing(double spacing)
49 {
50  this->suggestSpacingKeepBounds(spacing);
51 }
53 {
54  return mImage.getSpacing()[0];
55 }
58 void OutputVolumeParams::setDim(int index, int newDim)
59 {
60  double newSpacing = mImage.getBounds()[index] / (newDim);
61  this->setSpacing(newSpacing);
62 }
63 Eigen::Array3i OutputVolumeParams::getDim() const
64 {
65  return mImage.getDim();
66 }
70 {
71  this->suggestSpacingKeepBounds(mInputSpacing);
73  mImage.changeToUniformSpacing();
74 }
75 
76 void OutputVolumeParams::suggestSpacingKeepBounds(double spacing)
77 {
78  Eigen::Array3d bounds = mImage.getBounds();
79  mImage.setSpacingKeepDim(Eigen::Array3d(spacing, spacing, spacing));
80  mImage.setDimKeepBoundsAlignSpacing(bounds);
81 }
82 
84 {
85  mMaxVolumeSize = maxSize;
86 }
87 
89 {
90  return mMaxVolumeSize;
91 }
92 
93 
95 {
96  mImage.m_rMd = rMd;
97 }
98 
100 {
101  return mImage.m_rMd;
102 }
103 
104 
106 {
107  return DoubleBoundingBox3D(Vector3D::Zero(), mImage.getBounds());
108 }
109 
111 {
112  return mInputSpacing;
113 }
114 
115 } // namespace cx
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
void limitVoxelsKeepBounds(unsigned long maxVolumeSize)
void setDimKeepBoundsAlignSpacing(Eigen::Array3d bounds)
Eigen::Array3i getDim() const
unsigned long getNumVoxels() const
Eigen::Array3d getBounds()
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
Eigen::Array3d getSpacing() const
void setSpacingKeepDim(Eigen::Array3d spacing)
Namespace for all CustusX production code.