26 s <<
"center : " << val.
c << std::endl;
27 s <<
"i_vector : " << val.
i << std::endl;
28 s <<
"j_vector : " << val.
j << std::endl;
48 mGravityDirection(
Vector3D(0,0,-1)) ,
49 mUseViewOffset(false),
64 mClinicalApplication = application;
89 mClinicalApplication = application;
140 mFixedCenter = center;
158 mGravityDirection = dir;
174 mUseViewOffset = use;
175 mViewportHeight = viewportHeight;
176 mViewOffset = viewOffset;
183 mViewportHeight = viewportHeight;
190 std::pair<Vector3D,Vector3D> basis = generateBasisVectors();
192 plane.
i = basis.first;
193 plane.
j = basis.second;
197 plane.
c = m_rMt.coord(plane.
c);
201 plane.
i = m_rMt.vector(plane.
i);
202 plane.
j = m_rMt.vector(plane.
j);
207 plane = this->orientToGravityAroundToolZAxisAndAlongTheOperatingTable(plane);
211 plane = orientToGravity(plane);
216 plane.
c = generateFixedIJCenter(mFixedCenter, plane.
c, plane.
i, plane.
j);
219 plane = applyViewOffset(plane);
240 double centerOffset = this->getViewOffsetAbsoluteFromCenter();
242 SlicePlane retval = base;
246 Vector3D newCenter = toolOffsetCenter + centerOffset * base.
j;
247 double toolOffsetDistance =
dot(newCenter - base.
c, base.
j);
251 newCenter = toolCenter - centerOffset * base.
j;
252 double toolDistance =
dot(newCenter - base.
c, base.
j);
255 double usedDistance = std::min(toolOffsetDistance, toolDistance);
256 retval.c = base.
c + usedDistance * base.
j;
261 double SliceComputer::getViewOffsetAbsoluteFromCenter()
const
266 return mViewportHeight*(0.5-mViewOffset);
275 std::pair<Vector3D,Vector3D> SliceComputer::generateBasisVectors()
const
277 switch (mClinicalApplication)
280 return this->generateBasisVectorsRadiology();
283 return this->generateBasisVectorsNeurology();
290 std::pair<Vector3D,Vector3D> SliceComputer::generateBasisVectorsNeurology()
const
306 throw std::exception();
313 std::pair<Vector3D,Vector3D> SliceComputer::generateBasisVectorsRadiology()
const
329 throw std::exception();
347 Vector3D center_s = M_sr.coord(center_r);
348 Vector3D cross_s = M_sr.coord(cross_r);
350 Vector3D q_s(center_s[0], center_s[1], cross_s[2]);
368 SlicePlane SliceComputer::orientToGravity(
const SlicePlane& base)
const
375 SlicePlane retval = base;
378 up = -mGravityDirection;
381 double w_n =
dot(up, k);
393 retval.i = i_g*(1.0-w_n) + i_n*w_n;
394 retval.i = retval.i.normal();
395 retval.j =
cross(k, retval.i);
423 SlicePlane SliceComputer::orientToGravityAroundToolZAxisAndAlongTheOperatingTable(
const SlicePlane &base)
const
430 SlicePlane retval = base;
437 double w_n = this->getWeightForAngularDifference(up, toolVector);
439 i_perpendicular = i_perpendicular*(1.0-w_n) + k_neg*w_n;
455 double SliceComputer::getWeightForAngularDifference(
Vector3D a,
Vector3D b)
const
457 double w_n =
dot(a, b);
462 double cutoff = sqrt(3.0)/2.0;
466 w_n = (w_n-cutoff)/(1.0-cutoff);