Fraxinus  17.12-rc2
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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 
35 
36 namespace cx
37 {
38 
40  mInputSpacing(0),
41  mMaxVolumeSize(32*1000),
42  mValid(false)
43 {
44 
45 }
48 OutputVolumeParams::OutputVolumeParams(DoubleBoundingBox3D extent, double inputSpacing, double maxVolumeSize) :
49  mInputSpacing(inputSpacing), mMaxVolumeSize(maxVolumeSize), mValid(false)
50 {
51  mImage.setSpacingKeepDim(Eigen::Array3d(inputSpacing, inputSpacing, inputSpacing));
52  mImage.setDimKeepBoundsAlignSpacing(extent.range());
53 
54  this->constrainVolumeSize();
55 
56  if(mImage.getDim().minCoeff() <= 1) //At least one of the dimensions <= 1
57  mValid = false;
58  else
59  mValid = true;
60 }
61 
62 unsigned long OutputVolumeParams::getVolumeSize() const
63 {
64  return mImage.getNumVoxels();
65 }
66 
69 void OutputVolumeParams::setSpacing(double spacing)
70 {
71  this->suggestSpacingKeepBounds(spacing);
72 }
74 {
75  return mImage.getSpacing()[0];
76 }
79 void OutputVolumeParams::setDim(int index, int newDim)
80 {
81  double newSpacing = mImage.getBounds()[index] / (newDim);
82  this->setSpacing(newSpacing);
83 }
84 Eigen::Array3i OutputVolumeParams::getDim() const
85 {
86  return mImage.getDim();
87 }
91 {
92  this->suggestSpacingKeepBounds(mInputSpacing);
94  mImage.changeToUniformSpacing();
95 }
96 
97 void OutputVolumeParams::suggestSpacingKeepBounds(double spacing)
98 {
99  Eigen::Array3d bounds = mImage.getBounds();
100  mImage.setSpacingKeepDim(Eigen::Array3d(spacing, spacing, spacing));
101  mImage.setDimKeepBoundsAlignSpacing(bounds);
102 }
103 
105 {
106  mMaxVolumeSize = maxSize;
107 }
108 
110 {
111  return mMaxVolumeSize;
112 }
113 
114 
116 {
117  mImage.m_rMd = rMd;
118 }
119 
121 {
122  return mImage.m_rMd;
123 }
124 
125 
127 {
128  return DoubleBoundingBox3D(Vector3D::Zero(), mImage.getBounds());
129 }
130 
132 {
133  return mInputSpacing;
134 }
135 
136 } // 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.