/** Set the box widget bounding box to the input box (given in data space) */ void InteractiveCropper::setBoxWidgetSize(const DoubleBoundingBox3D& bb_d) { if (!mImage || !mBoxWidget) return; double bb_hard[6] = { -0.5, 0.5, -0.5, 0.5, -0.5, 0.5 }; DoubleBoundingBox3D bb_unit(bb_hard); Transform3D M = createTransformNormalize(bb_unit, bb_d); Transform3D rMd = mImage->get_rMd(); M = rMd * M; vtkTransformPtr transform = vtkTransformPtr::New(); transform->SetMatrix(M.getVtkMatrix()); mBoxWidget->SetTransform(transform); }
void GraphicalArrow3D::setValue(Vector3D base, Vector3D normal, double length) { // find an arbitrary vector k perpendicular to normal: Vector3D k = cross(Vector3D(1,0,0), normal); if (similar(k, Vector3D(0,0,0))) k = cross(Vector3D(0,1,0), normal); k = k.normalized(); Transform3D M = createTransformIJC(normal, k, base); // std::cout << "GraphicalArrow3D::setValue " << base << " - " << normal << std::endl; Transform3D S = createTransformScale(Vector3D(length,1,1)); M = M * S; // let arrow shape increase slowly with length: // source->SetTipLength(0.35/sqrt(length)); // source->SetTipRadius(0.1*sqrt(length)); // source->SetShaftRadius(0.03*sqrt(length)); source->SetTipLength(0.35); source->SetTipRadius(0.1*(length)); source->SetShaftRadius(0.03*(length)); actor->SetUserMatrix(M.getVtkMatrix()); }
void GraphicalAxes3D::rescale() { if (!mViewportListener->isListening()) return; double size = mViewportListener->getVpnZoom(); double axisSize = mSize/size; double scale = axisSize / m_vtkAxisLength; // NOTE: vtkAxesActor dislikes small values for SetTotalLength, thus we // keep that value constant at m_vtkAxisLength and instead scale the transform. Transform3D rMq = m_rMt * createTransformScale(Vector3D(scale,scale,scale)); mActor->SetUserMatrix(rMq.getVtkMatrix()); for (unsigned i=0; i<mCaption.size(); ++i) { Vector3D pos = rMq.coord(axisSize*mCaptionPos[i]); mCaption[i]->SetAttachmentPoint(pos.begin()); } }
igstk::Transform IgstkTool::toIgstkTransform(Transform3D transform) { igstk::Transform retval; retval.ImportTransform(*transform.getVtkMatrix()); return retval; }