//=====
void HeartAngles::Process()
{
+ std::cout << "CFT HeartAngles::Process() Start"<<std::endl;
creaVtkHeartAngles ha;
- ha.calculateImages (bbGetInputImage(), bbGetInputPx(), bbGetInputPy(), bbGetInputPz(), bbGetInputVx(), bbGetInputVy(), bbGetInputVz(), bbGetInputNx(), bbGetInputNy(), bbGetInputNz(), bbGetInputp2x(), bbGetInputp2y(), bbGetInputp2z());
+
+ //ha.calculateImages (bbGetInputImage(), bbGetInputPlanePoint()[0], bbGetInputPlanePoint()[1], bbGetInputPlanePoint()[2], bbGetInputVector()[0], bbGetInputVector()[1], bbGetInputVector()[2], bbGetInputNormal()[0], bbGetInputNormal()[1], bbGetInputNormal()[2], bbGetInputPoint2()[0], bbGetInputPoint2()[1], bbGetInputPoint2()[2]);
+// bbSetOutputAlphaImage(ha.getAlphaImage());
+ double p2x = bbGetInputNormal()[0]+ bbGetInputPlanePoint()[0];
+ double p2y = bbGetInputNormal()[1]+ bbGetInputPlanePoint()[1];
+ double p2z = bbGetInputNormal()[2]+ bbGetInputPlanePoint()[2];
+
+ double Nx = bbGetInputNormal()[0];
+ double Ny = bbGetInputNormal()[1];
+ double Nz = bbGetInputNormal()[2];
+
+ double Px = bbGetInputPlanePoint()[0];
+ double Py = bbGetInputPlanePoint()[1];
+ double Pz = bbGetInputPlanePoint()[2];
+
+ ha.calculateImages (bbGetInputImage(), Px, Py, Pz, Nx, Ny, Nz, p2x, p2y, p2z);
bbSetOutputAlphaImage(ha.getAlphaImage());
bbSetOutputBetaImage(ha.getBetaImage());
+ std::cout << "CFT HeartAngles::Process() End"<<std::endl;
}
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
#include "bbtkAtomicBlackBox.h"
#include "iostream"
#include "vtkImageData.h"
+#include <vector>
namespace bbcreaVtk
{
//vtkImageData* image, double Px, double Py, double Pz, double Vx, double Vy, double Vz, double Nx, double Ny, double Nz, double p2x, double p2y, double p2z
BBTK_DECLARE_INPUT(Image, vtkImageData*);
- BBTK_DECLARE_INPUT(Px,double);
- BBTK_DECLARE_INPUT(Py,double);
- BBTK_DECLARE_INPUT(Pz,double);
- BBTK_DECLARE_INPUT(Vx,double);
- BBTK_DECLARE_INPUT(Vy,double);
- BBTK_DECLARE_INPUT(Vz,double);
- BBTK_DECLARE_INPUT(Nx,double);
- BBTK_DECLARE_INPUT(Ny,double);
- BBTK_DECLARE_INPUT(Nz,double);
- BBTK_DECLARE_INPUT(p2x,double);
- BBTK_DECLARE_INPUT(p2y,double);
- BBTK_DECLARE_INPUT(p2z,double);
+ BBTK_DECLARE_INPUT(PlanePoint,std::vector<double>);
+ BBTK_DECLARE_INPUT(Vector,std::vector<double>);
+ BBTK_DECLARE_INPUT(Normal,std::vector<double>);
+ BBTK_DECLARE_INPUT(Point2,std::vector<double>);
BBTK_DECLARE_OUTPUT(AlphaImage, vtkImageData*);
BBTK_DECLARE_OUTPUT(BetaImage, vtkImageData*);
BBTK_PROCESS(Process);
BBTK_DESCRIPTION("No Description.");
BBTK_CATEGORY("empty");
BBTK_INPUT(HeartAngles,Image,"Image",vtkImageData*,"");
-BBTK_INPUT(HeartAngles,Px,"Punto en el plano componente X",double,"");
-BBTK_INPUT(HeartAngles,Py,"Punto en el plano componente Y",double,"");
-BBTK_INPUT(HeartAngles,Pz,"Punto en el plano componente Z",double,"");
-BBTK_INPUT(HeartAngles,Vx,"Vector componente X",double,"");
-BBTK_INPUT(HeartAngles,Vy,"Vector componente Y",double,"");
-BBTK_INPUT(HeartAngles,Vz,"Vector componente Z",double,"");
-BBTK_INPUT(HeartAngles,Nx,"Normal componente X",double,"");
-BBTK_INPUT(HeartAngles,Ny,"Normal componente Y",double,"");
-BBTK_INPUT(HeartAngles,Nz,"Normal componente Z",double,"");
-BBTK_INPUT(HeartAngles,p2x,"Punto P2 componente X",double,"");
-BBTK_INPUT(HeartAngles,p2y,"Punto P2 componente Y",double,"");
-BBTK_INPUT(HeartAngles,p2z,"Punto P2 componente Z",double,"");
+BBTK_INPUT(HeartAngles,PlanePoint,"Punto en el plano componente X",std::vector<double>,"");
+BBTK_INPUT(HeartAngles,Vector,"Vector componente X",std::vector<double>,"");
+BBTK_INPUT(HeartAngles,Normal,"Normal componente X",std::vector<double>,"");
+BBTK_INPUT(HeartAngles,Point2,"Punto P2 componente X",std::vector<double>,"");
BBTK_OUTPUT(HeartAngles,AlphaImage,"Alpha Image",vtkImageData*,"");
BBTK_OUTPUT(HeartAngles,BetaImage,"Beta Image",vtkImageData*,"");
BBTK_END_DESCRIBE_BLACK_BOX(HeartAngles);
#include "creaVtkHeartAngles.h"
#include <math.h>
#include <iostream>
+#include "vtkDoubleArray.h"
+#include "vtkStructuredPoints.h"
+#include "vtkPointData.h"
+#include "vtkDataArray.h"
creaVtkHeartAngles::creaVtkHeartAngles()
{
double al = alpha - ent;
double min = al * 60;
//std::cout << "minutos: " << min << std::endl;
- std::cout << "Grados: "<< ent <<" minutos: " << floor(min) << std::endl;
+ //std::cout << "Alpha grados: "<< ent <<" minutos: " << floor(min) << " cos: " << cosAlpha << std::endl;
return alpha;
}
double al = beta - ent;
double min = al * 60;
//std::cout << "minutos: " << min << std::endl;
- std::cout << "Grados: "<< ent <<" minutos: " << floor(min) << std::endl;
+ //std::cout << "Beta grados: "<< ent <<" minutos: " << floor(min) << " cos: " << cosBeta << std::endl;
return beta;
}
-double * creaVtkHeartAngles::vectorProjection (double plX, double plY, double plZ, double nX, double nY, double nZ, double vX, double vY, double vZ)
+double * creaVtkHeartAngles::vectorProjection (double nX, double nY, double nZ, double vX, double vY, double vZ)
{
- //punto del plano
- double plx=plX, ply=plY, plz=plZ;
+
//normalPlano
double nx=nX, ny=nY, nz=nZ;
//vector V
double vx=vX, vy=vY, vz=vZ;
- //distancia del punto al plano
- double dist;
//vector proyectado
- double vpx, vpy, vpz;
double proj [3];
- dist = ply - vy;
- //std::cout << dist << std
- vpx = vx - (dist * nx);
- vpy = vy - (dist * ny);
- vpz = vz - (dist * nz);
-
- proj[0]=vpx;
- proj[1]=vpy;
- proj[2]=vpz;
+ proj[0]= vX - (nX*vX);
+ proj[1]= vY - (nY*vY);
+ proj[2]= vZ - (nZ*vZ);
return proj;
}
return puntoCorte;
}
-void creaVtkHeartAngles::calculateImages (vtkImageData* image, double Px, double Py, double Pz, double Vx, double Vy, double Vz, double Nx, double Ny, double Nz, double p2x, double p2y, double p2z)
+void creaVtkHeartAngles::calculateImages (vtkImageData* image, double Px, double Py, double Pz, double Nx, double Ny, double Nz, double p2x, double p2y, double p2z)
{
- alphaImage = image;
+std::cout << "CFT creaVtkHeartAngles::calculateImages Start"<<std::endl;
+
+ alphaImage = vtkImageData::New();
alphaImage->SetExtent( image->GetExtent() );
alphaImage->SetOrigin( image->GetOrigin() );
alphaImage->SetSpacing( image->GetSpacing() );
alphaImage->SetNumberOfScalarComponents( image->GetNumberOfScalarComponents() );
alphaImage->AllocateScalars();
- betaImage = image;
+ int ext[6];
+ image->GetWholeExtent(ext);
+ int dim[3];
+ dim[0]=ext[1]-ext[0]+1;
+ dim[1]=ext[3]-ext[2]+1;
+ dim[2]=ext[5]-ext[4]+1;
+
+ std::cout<<"dim0 "<<dim[0]<<" dim1 "<<dim[1]<<" dim2 "<<dim[2]<<std::endl;
+
+ betaImage = vtkImageData::New();
betaImage->SetExtent( image->GetExtent() );
+ betaImage->SetWholeExtent( image->GetWholeExtent() );
betaImage->SetOrigin( image->GetOrigin() );
betaImage->SetSpacing( image->GetSpacing() );
betaImage->SetScalarTypeToUnsignedChar();
double a;
double b;
- for( int i = 0 ; i < image->GetExtent()[1] ; i++ )
+ int numberOfPoints = dim[0]*dim[1]*dim[2];
+
+ vtkDoubleArray *array;
+ array = (vtkDoubleArray*) image->GetPointData()->GetVectors();
+ //for(int i = 0 ; i < 8600 ; i++) {
+ // std::cout<<" arreglo #"<< i << " "<< array->GetValue(i)<<" tuple3 "<< array->GetTuple3(i)[0]<<" "<< array->GetTuple3(i)[1]<<" "<<array->GetTuple3(i)[2]<< std::endl;
+ //}
+
+ int i, j, k;
+ int numTuple=0;
+
+
+ for( i = 0 ; i < dim[0] ; i++ )
{
- for( int j = 0 ; j < image->GetExtent()[3] ; j++ )
+ for( j = 0 ; j < dim[1] ; j++ )
{
- for( int k = 0 ; k < image->GetExtent()[5] ; k++ )
+ for( k = 0 ; k < dim[2] ; k++ )
{
- unsigned char* pPix = (unsigned char *)image->GetScalarPointer( i , j , k );
- int p1 = pPix[0];
- int p2 = pPix[1];
- int p3 = pPix[2];
-
+ //unsigned char* pPix = (unsigned char *)image->GetScalarPointer( i , j , k );
+
+ double p1 = array->GetTuple3(numTuple)[0];
+ double p2 = array->GetTuple3(numTuple)[1];
+ double p3 = array->GetTuple3(numTuple)[2];
+ numTuple++;
+
+ //std::cout << " p1: " << p1 << " p2: " << p2 <<" p3: " << p3 << std::endl;
+ //std::cout << " Px: " << Px << " Py: " << Py <<" Pz: " << Pz << std::endl;
+ //std::cout << " p2x: " << p2x << " p2y: " << p2y <<" p2z: " << p2z << std::endl;
+
double* vecProj;
- vecProj = vectorProjection (Px, Py, Pz,
- Nx, Ny, Nz,
+ vecProj = vectorProjection (Nx, Ny, Nz,
p1, p2, p3);
+ //std::cout << " vecProj[0]: " << vecProj[0] << " vecProj[1]: " << vecProj[1] <<" vecProj[2]: " << vecProj[2] << std::endl;
a = alpha (Px, Py, Pz,
p1, p2, p3,
vecProj[0], vecProj[1], vecProj[2]);
b = beta (Px, Py, Pz,
p2x, p2y, p2z,
vecProj[0], vecProj[1], vecProj[2]);
-
+ //std::cout << " a: " << a << " b: " << b << std::endl;
unsigned char *zPtr1 = (unsigned char *) alphaImage->GetScalarPointer( i , j , k );
- *zPtr1 = a;
+ *zPtr1 = (unsigned char)a;
unsigned char *zPtr2 = (unsigned char *) betaImage->GetScalarPointer( i , j , k );
- *zPtr2 = b;
- }
- }
- }
+ *zPtr2 = (unsigned char)b;
+ } //for k
+ } // for j
+ } // for i
+
+
+std::cout << "CFT creaVtkHeartAngles::calculateImages End"<<std::endl;
}
double alpha (double P0a, double P0b,double P0c, double vx, double vy, double vz, double vxp, double vyp, double vzp);
//Parametros: Punto P0, Punto P2, Punto P4 (proyection de V)
double beta (double P0a, double P0b,double P0c, double P2x, double P2y, double P2z, double P4x, double P4y, double P4z);
- //Parametros: punto del plano, normalPlano, vector V.
- double * vectorProjection (double plx, double ply, double plz, double nx, double ny, double nz, double vx, double vy, double vz);
+ //Parametros: normalPlano, vector V.
+ double * vectorProjection (double nx, double ny, double nz, double vx, double vy, double vz);
//Parametros: Tres puntos del plano, dos puntos de la recta.
double *intersectionPlaneLine(double plx1, double ply1, double plz1, double plx2, double ply2, double plz2, double plx3, double ply3, double plz3, double px1, double py1, double pz1,double px2, double py2, double pz2);
- //Parametros: Imagen 3D, Punto en el plano, Vector, Normal, p2.
- void calculateImages (vtkImageData* image, double Px, double Py, double Pz, double Vx, double Vy, double Vz, double Nx, double Ny, double Nz, double p2x, double p2y, double p2z);
+ //Parametros: Imagen 3D, Punto en el plano, Normal, p2.
+ void calculateImages (vtkImageData* image, double Px, double Py, double Pz, double Nx, double Ny, double Nz, double p2x, double p2y, double p2z);
protected: