Commit 9d9aabc7 authored by Emmanuel Promayon's avatar Emmanuel Promayon

NEW picking in any orientation update all other orientation

It works in all direction. Even picking in orthogonal slice
update the picked pixel in the arbiratry slice (translation along
the z vector of the arbitrary slice)
parent 6001277f
......@@ -211,23 +211,12 @@ void ArbitrarySingleImageComponent::setTransformTranslation(double x, double y,
// -------------------- updateTranslationExtremity --------------------
void ArbitrarySingleImageComponent::updateTranslationExtremity() {
// compute C in image coordinates
double C_L[4] = {dimensions[0]* spacing[0] / 2.0 - spacing[0] / 2.0,
dimensions[1]* spacing[1] / 2.0 - spacing[1] / 2.0,
0.0,
1.0
};
double C_P[4];
getTransform()->GetMatrix()->MultiplyPoint(C_L, C_P);
// Compute the z direction vector in local coordinate system
double V_L[4] = { C_L[0], C_L[1], C_L[3] + 1.0, 1.0};
double V_P[4];
getTransform()->GetMatrix()->MultiplyPoint(V_L, V_P);
double Z_P[4];
getImageCenterAndTranslationVectorInParent(C_P, Z_P);
// compute intersection of line C_P + k vec(C_P, V_P) with the image
QVector3D lineVector(V_P[0] - C_P[0], V_P[1] - C_P[1], V_P[2] - C_P[2]);
QVector3D lineVector(Z_P[0] - C_P[0], Z_P[1] - C_P[1], Z_P[2] - C_P[2]);
QVector3D startPoint(C_P[0], C_P[1], C_P[2]);
double xCenter = dimensions[0] * spacing[0] / 2.0;
......@@ -323,7 +312,20 @@ void ArbitrarySingleImageComponent::getImageCenterInParent(double C_P[4]) {
getTransform()->GetMatrix()->MultiplyPoint(C_L, C_P);
}
// -------------------- getImageCenterAndTranslationVectorInParent --------------------
void ArbitrarySingleImageComponent::getImageCenterAndTranslationVectorInParent(double C_P[4], double Z_P[4]) {
// compute C in image coordinates
double C_L[4] = {dimensions[0]* spacing[0] / 2.0 - spacing[0] / 2.0,
dimensions[1]* spacing[1] / 2.0 - spacing[1] / 2.0,
0.0,
1.0
};
getTransform()->GetMatrix()->MultiplyPoint(C_L, C_P);
// Compute the z direction vector in local coordinate system
double Z_L[4] = { C_L[0], C_L[1], C_L[3] + 1.0, 1.0};
getTransform()->GetMatrix()->MultiplyPoint(Z_L, Z_P);
}
......@@ -365,8 +367,24 @@ void ArbitrarySingleImageComponent::setSlice(double x, double y, double z) {
// - when a point is picked on the arbitrary slice
// - when a point is picked in another slice orientation (axial, sagittal, coronal)
// Update the position without changing the orientation
// 1. compute (x,y,z) in local coordinates
double C_P[4];
double Z_P[4];
getImageCenterAndTranslationVectorInParent(C_P, Z_P);
// compute intersection of line C_P + k vec(C_P, V_P) with the slice that contains pixel_P
QVector3D lineVector(Z_P[0] - C_P[0], Z_P[1] - C_P[1], Z_P[2] - C_P[2]);
QVector3D startPoint(C_P[0], C_P[1], C_P[2]);
QVector3D pickedPoint(x, y, z);
QVector3D intersection;
bool intersect = linePlaneIntersectionPoint(lineVector, startPoint, lineVector, pickedPoint, intersection);
if (intersect) {
// compute the ratio on the line and translate to it
updateTranslationExtremity();
double k = QVector3D(intersection - cMinus_P).length() / QVector3D(cPlus_P - cMinus_P).length();
setTransformTranslation(0.0, 0.0, k);
}
// translate to the plane that is parallel to z direction
// Update the pick point actor
// Set pixel position in current slice
setPixelRealPosition(x, y, z);
......
......@@ -143,6 +143,10 @@ private:
/// i.e the image frame (given as homogeneous point, hence 4D)
void getImageCenterInParent(double[4]);
/// Compute the current position of the image center
/// and the z direction vector in the parent coordinate system (i.e. image frame)
void getImageCenterAndTranslationVectorInParent(double C_P[4], double Z_P[4]);
/// dimension of the whole image (kept here for simplifying code)
int* dimensions;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment