47 s <<
"center : " << val.
c << std::endl;
48 s <<
"i_vector : " << val.
i << std::endl;
49 s <<
"j_vector : " << val.
j << std::endl;
69 mGravityDirection(
Vector3D(0,0,-1)) ,
70 mUseViewOffset(false),
73 mUseConstrainedViewOffset(false)
83 void SliceComputer::initializeFromPlane(PLANE_TYPE plane,
bool useGravity,
const Vector3D& gravityDir,
bool useViewOffset,
double viewportHeight,
double toolViewOffset, CLINICAL_VIEW application,
bool useConstrainedViewOffset)
86 mClinicalApplication = application;
99 setToolViewOffset(useViewOffset, viewportHeight, toolViewOffset, useConstrainedViewOffset);
105 mClinicalApplication = application;
151 mFixedCenter = center;
169 mGravityDirection = dir;
185 mUseViewOffset = use;
186 mViewportHeight = viewportHeight;
187 mViewOffset = viewOffset;
188 mUseConstrainedViewOffset = useConstrainedViewOffset;
195 mViewportHeight = viewportHeight;
202 std::pair<Vector3D,Vector3D> basis = generateBasisVectors();
204 plane.
i = basis.first;
205 plane.
j = basis.second;
209 plane.
c = m_rMt.coord(plane.
c);
213 plane.
i = m_rMt.vector(plane.
i);
214 plane.
j = m_rMt.vector(plane.
j);
218 plane = orientToGravity(plane);
222 plane.
c = generateFixedIJCenter(mFixedCenter, plane.
c, plane.
i, plane.
j);
225 plane = applyViewOffset(plane);
248 double centerOffset = this->getViewOffsetAbsoluteFromCenter();
250 SlicePlane retval = base;
251 if (mUseConstrainedViewOffset)
254 Vector3D newCenter = toolOffsetCenter + centerOffset * base.
j;
255 double toolOffsetDistance =
dot(newCenter - base.
c, base.
j);
258 newCenter = toolCenter - centerOffset * base.
j;
259 double toolDistance =
dot(newCenter - base.
c, base.
j);
260 double usedDistance = std::min(toolOffsetDistance, toolDistance);
261 retval.c = base.
c + usedDistance * base.
j;
266 Vector3D newCenter = toolCenter - centerOffset * base.
j;
267 double distance =
dot(newCenter - base.
c, base.
j);
268 retval.c = base.
c + distance * base.
j;
273 double SliceComputer::getViewOffsetAbsoluteFromCenter()
const
278 return mViewportHeight*(0.5-mViewOffset);
287 std::pair<Vector3D,Vector3D> SliceComputer::generateBasisVectors()
const
289 switch (mClinicalApplication)
292 return this->generateBasisVectorsRadiology();
295 return this->generateBasisVectorsNeurology();
302 std::pair<Vector3D,Vector3D> SliceComputer::generateBasisVectorsNeurology()
const
316 throw std::exception();
323 std::pair<Vector3D,Vector3D> SliceComputer::generateBasisVectorsRadiology()
const
337 throw std::exception();
356 Vector3D center_s = M_sr.coord(center_r);
357 Vector3D cross_s = M_sr.coord(cross_r);
359 Vector3D q_s(center_s[0], center_s[1], cross_s[2]);
377 SlicePlane SliceComputer::orientToGravity(
const SlicePlane& base)
const
384 SlicePlane retval = base;
387 up = -mGravityDirection;
390 double w_n =
dot(up, k);
403 retval.i = i_g*(1.0-w_n) + i_n*w_n;
404 retval.i = retval.i.normal();
405 retval.j =
cross(k, retval.i);
Vector3D j
defines the second axis of the plane. unit vector
void setToolViewportHeight(double viewportHeight)
ptCORONAL
a slice seen from the front of the patient
A 2D slice plane in 3D. i,j are perpendicular unit vectors.
ftFOLLOW_TOOL
center follows tool
otOBLIQUE
orient planes relative to the tool space
ftFIXED_CENTER
center is set.
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
void setToolViewOffset(bool use, double viewportHeight, double viewOffset, bool useConstrainedViewOffset=false)
void setClinicalApplication(CLINICAL_VIEW application)
ptAXIAL
a slice seen from the top of the patient
PLANE_TYPE getPlaneType() const
void setOrientationType(ORIENTATION_TYPE val)
bool similar(const DoubleBoundingBox3D &a, const DoubleBoundingBox3D &b, double tol)
Vector3D cross(const Vector3D &a, const Vector3D &b)
compute cross product of a and b.
void setToolOffset(double val)
ptSAGITTAL
a slice seen from the side of the patient
Transform3D createTransformIJC(const Vector3D &ivec, const Vector3D &jvec, const Vector3D ¢er)
Vector3D c
defines the center of the plane
void initializeFromPlane(PLANE_TYPE plane, bool useGravity, const Vector3D &gravityDir, bool useViewOffset, double viewportHeight, double toolViewOffset, CLINICAL_VIEW application, bool useConstrainedViewOffset=false)
void setPlaneType(PLANE_TYPE val)
otORTHOGONAL
orient planes relative to the image/reference space.
void setFixedCenter(const Vector3D ¢er)
void setToolPosition(const Transform3D &rMt)
double dot(const Vector3D &a, const Vector3D &b)
compute inner product (or dot product) of a and b.
std::ostream & operator<<(std::ostream &s, const IntBoundingBox3D &data)
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
ptRADIALPLANE
y-rotated 90* relative to anyplane (bird's view)
Vector3D i
defines the first axis of the plane. unit vector
Transform3D getToolPosition() const
ptANYPLANE
a plane aligned with the tool base plane
void setFollowType(FOLLOW_TYPE val)
void setGravity(bool use, const Vector3D &dir)
ORIENTATION_TYPE getOrientationType() const
SlicePlane getPlane() const
ptSIDEPLANE
z-rotated 90* relative to anyplane (dual anyplane)