예제 #1
0
Transform3D SliceProxy::get_sMr()
{
	SlicePlane plane = mCutplane->getPlane();
	//std::cout << "---" << " proxy get transform.c : " << plane.c << std::endl;
	//std::cout << "proxy get transform -" << getName() <<":\n" << plane << std::endl;
	return createTransformIJC(plane.i, plane.j, plane.c).inv();
}
예제 #2
0
/**Generate a viewdata containing a slice that always keeps the center 
 * of the observed image at center, but the z-component varies according 
 * to cross.
 * Input is the i,j vectors defining the slice, and center,cross positions,
 * all in ref space. 
 * 
 */
Vector3D SliceComputer::generateFixedIJCenter(const Vector3D& center_r, const Vector3D& cross_r, const Vector3D& i, const Vector3D& j) const
{
	if (mFollowType==ftFIXED_CENTER)
	{
		// r is REF, s is SLICE
		Transform3D M_rs = createTransformIJC(i, j, Vector3D(0,0,0)); // transform from data to slice, zero center.
		Transform3D M_sr = M_rs.inv();
		Vector3D center_s = M_sr.coord(center_r);
		Vector3D cross_s = M_sr.coord(cross_r);
		// in SLICE space, use {xy} values from center and {z} value from cross.
		Vector3D q_s(center_s[0], center_s[1], cross_s[2]);
		Vector3D q_r = M_rs.coord(q_s);
		return q_r;
	}
	return cross_r;
}
예제 #3
0
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());
}
예제 #4
0
void PlaneMetricRep::drawRectangleForPlane(Vector3D p0_r, Vector3D n_r, double size)
{
	if (!mRect)
		return;
	// draw a rectangle showing the plane:
	Vector3D e_z = n_r;
	Vector3D k1(1,0,0);
	Vector3D k2(0,1,0);
	Vector3D e_x;
	if (cross(k2,e_z).length() > cross(k1,e_z).length())
		e_x = cross(k2,e_z)/cross(k2,e_z).length();
	else
		e_x = cross(k1,e_z)/cross(k1,e_z).length();

	Vector3D e_y = cross(e_z,e_x);
	Transform3D rMb = createTransformIJC(e_x, e_y, p0_r);
	double bb_size = 0.10/size;
	DoubleBoundingBox3D bb(-bb_size,bb_size,-bb_size,bb_size,0,0);

	mRect->updatePosition(bb, rMb);
}
예제 #5
0
Transform3D CustomMetric::calculateRotation(Vector3D dir, Vector3D vup) const
{
	Transform3D R = Transform3D::Identity();
	bool directionAlongUp = similar(dot(vup, dir.normal()), 1.0);
	if (!directionAlongUp)
	{
		Vector3D jvec = dir.normal();
		Vector3D kvec = cross(vup, dir).normal();
		Vector3D ivec = cross(jvec, kvec).normal();
		Vector3D center = Vector3D::Zero();
		R = createTransformIJC(ivec, jvec, center);

		Transform3D rotateY = cx::createTransformRotateY(M_PI_2);
		R = R*rotateY;//Let the models X-axis align with patient X-axis

		if(this->modelIsImage())
		{
			Transform3D rotateX = cx::createTransformRotateX(M_PI_2);
			R = R*rotateX;
		}
	}
	return R;
}