39 mDim(Eigen::Array3i(0,0,0)),
66 return (mDim - 1).cast<
double>() * mSpacing;
76 Eigen::Array3d dim = bounds / mSpacing;
77 mDim =
round(dim).cast<
int>();
79 this->alignSpacingKeepDim(bounds);
82 void ImageParameters::alignSpacingKeepDim(Eigen::Array3d bounds)
84 for (
unsigned i = 0; i < 3; ++i)
87 if((mDim[i] == 1) &&
similar(bounds[i], 0.0))
90 mSpacing[i] = bounds[i] / double(mDim[i]-1);
99 void ImageParameters::setDimFromExtent(Eigen::Array3i extent)
113 if(mDim.minCoeff() == 1)
115 reportError(
"ImageParameters::limitVoxelsKeepBounds() only work with 3D images");
152 double f1 = i[1] / i[0];
153 double f2 = i[2] / i[0];
154 double Vb = b.prod();
155 double Ve = pow(pow(
double(maxVoxels),1.0/3)-1, 3);
159 s[0] = pow(Vb/(Ve*f1*f2), 1.0/3);
165 Eigen::Array3i e = (b/s).cast<int>();
168 this->setDimFromExtent(e);
169 this->alignSpacingKeepDim(b);
180 double Vb = b.prod();
181 double Ve = pow(pow(
double(voxelCount),1.0/3)-1, 3);
182 double spacing = pow(Vb/Ve, 1.0/3);
183 Eigen::Array3d s(spacing,spacing,spacing);
186 mSpacing = Eigen::Array3d(spacing,spacing,spacing);
187 Eigen::Array3i e = (b/s).cast<int>();
188 this->setDimFromExtent(e);
193 s << indent <<
"Dim: " << mDim << std::endl;
194 s << indent <<
"Spacing: " << mSpacing << std::endl;
195 s << indent <<
"Bounds: " << this->
getBounds() << std::endl;
196 s << indent <<
"NumVoxels: " << this->
getNumVoxels() << std::endl;
197 s << indent <<
"Parent Volume: " <<
mParentVolume << std::endl;
198 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.