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);
111 if (type==mOrientType)
114 PLANE_TYPE newType = mPlaneType;
137 initializeFromPlane(newType, mUseGravity, mGravityDirection, mUseViewOffset, mViewportHeight, mViewOffset, mClinicalApplication);
142 mClinicalApplication = application;
188 mFixedCenter = center;
206 mGravityDirection = dir;
222 mUseViewOffset = use;
223 mViewportHeight = viewportHeight;
224 mViewOffset = viewOffset;
225 mUseConstrainedViewOffset = useConstrainedViewOffset;
232 mViewportHeight = viewportHeight;
239 std::pair<Vector3D,Vector3D> basis = generateBasisVectors();
241 plane.
i = basis.first;
242 plane.
j = basis.second;
246 plane.
c = m_rMt.coord(plane.
c);
250 plane.
i = m_rMt.vector(plane.
i);
251 plane.
j = m_rMt.vector(plane.
j);
255 plane = orientToGravity(plane);
259 plane.
c = generateFixedIJCenter(mFixedCenter, plane.
c, plane.
i, plane.
j);
262 plane = applyViewOffset(plane);
285 double centerOffset = this->getViewOffsetAbsoluteFromCenter();
287 SlicePlane retval = base;
288 if (mUseConstrainedViewOffset)
291 Vector3D newCenter = toolOffsetCenter + centerOffset * base.
j;
292 double toolOffsetDistance =
dot(newCenter - base.
c, base.
j);
295 newCenter = toolCenter - centerOffset * base.
j;
296 double toolDistance =
dot(newCenter - base.
c, base.
j);
297 double usedDistance = std::min(toolOffsetDistance, toolDistance);
298 retval.c = base.
c + usedDistance * base.
j;
303 Vector3D newCenter = toolCenter - centerOffset * base.
j;
304 double distance =
dot(newCenter - base.
c, base.
j);
305 retval.c = base.
c + distance * base.
j;
310 double SliceComputer::getViewOffsetAbsoluteFromCenter()
const
315 return mViewportHeight*(0.5-mViewOffset);
324 std::pair<Vector3D,Vector3D> SliceComputer::generateBasisVectors()
const
326 switch (mClinicalApplication)
329 return this->generateBasisVectorsRadiology();
332 return this->generateBasisVectorsNeurology();
339 std::pair<Vector3D,Vector3D> SliceComputer::generateBasisVectorsNeurology()
const
353 throw std::exception();
360 std::pair<Vector3D,Vector3D> SliceComputer::generateBasisVectorsRadiology()
const
374 throw std::exception();
393 Vector3D center_s = M_sr.coord(center_r);
394 Vector3D cross_s = M_sr.coord(cross_r);
396 Vector3D q_s(center_s[0], center_s[1], cross_s[2]);
414 SlicePlane SliceComputer::orientToGravity(
const SlicePlane& base)
const
421 SlicePlane retval = base;
424 up = -mGravityDirection;
427 double w_n =
dot(up, k);
440 retval.i = i_g*(1.0-w_n) + i_n*w_n;
441 retval.i = retval.i.normal();
442 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)
void switchOrientationMode(ORIENTATION_TYPE type)
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)