From: ctorres Date: Wed, 18 Dec 2013 16:00:37 +0000 (+0100) Subject: 2217 creaVtk Support New Normal Correction of Heart Angles Box 2013-12-18 17:00 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=22c43ba33062a0628472d1111a72fd0ecf895c48;p=creaVtk.git 2217 creaVtk Support New Normal Correction of Heart Angles Box 2013-12-18 17:00 --- diff --git a/lib/creaVtk/creaVtkHeartAngles.cpp b/lib/creaVtk/creaVtkHeartAngles.cpp index c70472e..7633c1e 100644 --- a/lib/creaVtk/creaVtkHeartAngles.cpp +++ b/lib/creaVtk/creaVtkHeartAngles.cpp @@ -59,10 +59,15 @@ double creaVtkHeartAngles::alpha (double P0a, double P0b,double P0c, double vx, double alpha; //Calcular el ángulo que forman las rectas, sabiendo sus vectores directores. - double cosAlpha = ( ( (x-a)*(xp-a) )+( (y-b)*(yp-b) )+( (z-c)*(zp-c) ) )/sqrt((( (pow(x,2.0)-pow(a,2.0)) + (pow(y,2.0)-pow(b,2.0)) + (pow(z,2.0)-pow(c,2.0)) )*( (pow(xp,2.0)-pow(a,2.0)) + (pow(yp,2.0)-pow(b,2.0)) + (pow(zp,2.0)-pow(c,2.0)) ) )); + //double cosAlpha = ( ( (x-a)*(xp-a) )+( (y-b)*(yp-b) )+( (z-c)*(zp-c) ) )/sqrt((( (pow(x,2.0)-pow(a,2.0)) + (pow(y,2.0)-pow(b,2.0)) + (pow(z,2.0)-pow(c,2.0)) )*( (pow(xp,2.0)-pow(a,2.0)) + (pow(yp,2.0)-pow(b,2.0)) + (pow(zp,2.0)-pow(c,2.0)) ) )); + double cosAlpha = ( ( x*xp )+( y*yp )+( z*zp ) )/(sqrt( pow(x,2.0) + pow(y,2.0) + pow(z,2.0) )*sqrt ( pow(xp,2.0) + pow(yp,2.0) + pow(zp,2.0) ) ); alpha = (180 * acos(fabs(cosAlpha)))/M_PI; - //std::cout << "Angulo Alpha: " << alpha << std::endl; + /*if((alpha<=90)&&(alpha>=0)){ + std::cout << " " << a << " " << b <<" " << c <<" " << x <<" " << y <<" " << z <<" " << xp <<" " << yp <<" " << zp; + std::cout << " cosAlpha: " << cosAlpha; + std::cout << " acos(fabs(cosalpha)) " << acos(fabs(cosAlpha)); + std::cout << " Angulo Alpha: " << alpha << std::endl ; }*/ double ent = floor(alpha); double al = alpha - ent; double min = al * 60; @@ -79,8 +84,8 @@ double creaVtkHeartAngles::beta (double P0a, double P0b,double P0c, double P3x, double beta; //Calcular el ángulo que forman las rectas, sabiendo sus vectores directores. - double cosBeta = ( ( (x-a)*(xp-a) )+( (y-b)*(yp-b) )+( (z-c)*(zp-c) ) )/sqrt((( (pow(x,2.0)-pow(a,2.0)) + (pow(y,2.0)-pow(b,2.0)) + (pow(z,2.0)-pow(c,2.0)) )*( (pow(xp,2.0)-pow(a,2.0)) + (pow(yp,2.0)-pow(b,2.0)) + (pow(zp,2.0)-pow(c,2.0)) ) )); - + //double cosBeta = ( ( (x-a)*(xp-a) )+( (y-b)*(yp-b) )+( (z-c)*(zp-c) ) )/sqrt((( (pow(x,2.0)-pow(a,2.0)) + (pow(y,2.0)-pow(b,2.0)) + (pow(z,2.0)-pow(c,2.0)) )*( (pow(xp,2.0)-pow(a,2.0)) + (pow(yp,2.0)-pow(b,2.0)) + (pow(zp,2.0)-pow(c,2.0)) ) )); + double cosBeta = ( ( x*xp )+( y*yp )+( z*zp ) )/(sqrt( pow(x,2.0) + pow(y,2.0) + pow(z,2.0) )*sqrt ( pow(xp,2.0) + pow(yp,2.0) + pow(zp,2.0) ) ); beta = (180 * acos(fabs(cosBeta)))/M_PI; //std::cout << "Angulo Beta: " << beta << std::endl; double ent = floor(beta); @@ -212,11 +217,11 @@ std::cout << "CFT creaVtkHeartAngles::calculateImages Start"<GetScalarPointer( i , j , k ); @@ -240,14 +245,22 @@ std::cout << "CFT creaVtkHeartAngles::calculateImages Start"<GetScalarPointer( i , j , k ); - *zPtr1 = (unsigned char)a; - unsigned char *zPtr2 = (unsigned char *) betaImage->GetScalarPointer( i , j , k ); - *zPtr2 = (unsigned char)b; - } //for k + + //if(a>=90&&a<=360) { std::cout << " numTuple: " << numTuple << " a: " << a << " b: " << b << std::endl; } + if(p1==0&&p2==0&&p3==0){ + unsigned char *zPtr1 = (unsigned char *) alphaImage->GetScalarPointer( i , j , k ); + *zPtr1 = (unsigned char)255; + unsigned char *zPtr2 = (unsigned char *) betaImage->GetScalarPointer( i , j , k ); + *zPtr2 = (unsigned char)255; + }else{ + unsigned char *zPtr1 = (unsigned char *) alphaImage->GetScalarPointer( i , j , k ); + *zPtr1 = (unsigned char)a; + unsigned char *zPtr2 = (unsigned char *) betaImage->GetScalarPointer( i , j , k ); + *zPtr2 = (unsigned char)b; + } + } //for i } // for j - } // for i + } // for k std::cout << "CFT creaVtkHeartAngles::calculateImages End"<