18 mDim(Eigen::Array3i(0,0,0)),
45 return (mDim - 1).cast<
double>() * mSpacing;
55 Eigen::Array3d dim = bounds / mSpacing;
56 mDim =
round(dim).cast<
int>();
58 this->alignSpacingKeepDim(bounds);
61 void ImageParameters::alignSpacingKeepDim(Eigen::Array3d bounds)
63 for (
unsigned i = 0; i < 3; ++i)
66 if((mDim[i] == 1) &&
similar(bounds[i], 0.0))
69 mSpacing[i] = bounds[i] / double(mDim[i]-1);
78 void ImageParameters::setDimFromExtent(Eigen::Array3i extent)
92 if(mDim.minCoeff() == 1)
94 reportError(
"ImageParameters::limitVoxelsKeepBounds() only work with 3D images");
131 double f1 = i[1] / i[0];
132 double f2 = i[2] / i[0];
133 double Vb = b.prod();
134 double Ve = pow(pow(
double(maxVoxels),1.0/3)-1, 3);
138 s[0] = pow(Vb/(Ve*f1*f2), 1.0/3);
144 Eigen::Array3i e = (b/s).cast<int>();
147 this->setDimFromExtent(e);
148 this->alignSpacingKeepDim(b);
159 double Vb = b.prod();
160 double Ve = pow(pow(
double(voxelCount),1.0/3)-1, 3);
161 double spacing = pow(Vb/Ve, 1.0/3);
162 Eigen::Array3d s(spacing,spacing,spacing);
165 mSpacing = Eigen::Array3d(spacing,spacing,spacing);
166 Eigen::Array3i e = (b/s).cast<int>();
167 this->setDimFromExtent(e);
172 s << indent <<
"Dim: " << mDim << std::endl;
173 s << indent <<
"Spacing: " << mSpacing << std::endl;
174 s << indent <<
"Bounds: " << this->
getBounds() << std::endl;
175 s << indent <<
"NumVoxels: " << this->
getNumVoxels() << std::endl;
176 s << indent <<
"Parent Volume: " <<
mParentVolume << std::endl;
177 s << indent <<
"rMd:\n" <<
m_rMd << std::endl;
void reportError(QString msg)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
void print(std::ostream &s, vtkIndent indent)
void limitVoxelsKeepBounds(unsigned long maxVolumeSize)
void setDimKeepBoundsAlignSpacing(Eigen::Array3d bounds)
Eigen::Array3i getDim() const
unsigned long getNumVoxels() const
Eigen::Array3d getBounds()
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)
Eigen::Array3d getSpacing() const
void changeToUniformSpacing()
Vector3D round(const Vector3D &a)
void setSpacingKeepDim(Eigen::Array3d spacing)
Namespace for all CustusX production code.