//=====
#include "bbcreaVtkHeartAngles.h"
#include "bbcreaVtkPackage.h"
+#include "creaVtkHeartAngles.h"
+
namespace bbcreaVtk
{
//=====
void HeartAngles::Process()
{
-
+ creaVtkHeartAngles ha;
+ ha.calculateImages (bbGetInputImage(), bbGetInputPx(), bbGetInputPy(), bbGetInputPz(), bbGetInputVx(), bbGetInputVy(), bbGetInputVz(), bbGetInputNx(), bbGetInputNy(), bbGetInputNz(), bbGetInputp2x(), bbGetInputp2y(), bbGetInputp2z());
+ bbSetOutputAlphaImage(ha.getAlphaImage());
+ bbSetOutputBetaImage(ha.getBetaImage());
}
//=====
// 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 "bbcreaVtk_EXPORT.h"
#include "bbtkAtomicBlackBox.h"
#include "iostream"
-
+#include "vtkImageData.h"
namespace bbcreaVtk
{
public bbtk::AtomicBlackBox
{
BBTK_BLACK_BOX_INTERFACE(HeartAngles,bbtk::AtomicBlackBox);
-//=====
-// 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)
-//=====
- BBTK_DECLARE_INPUT(In,double);
- BBTK_DECLARE_OUTPUT(Out,double);
+
+//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_OUTPUT(AlphaImage, vtkImageData*);
+ BBTK_DECLARE_OUTPUT(BetaImage, vtkImageData*);
BBTK_PROCESS(Process);
void Process();
//=====
BBTK_AUTHOR("carlos torres");
BBTK_DESCRIPTION("No Description.");
BBTK_CATEGORY("empty");
-BBTK_INPUT(HeartAngles,In,"First input",double,"");
-BBTK_OUTPUT(HeartAngles,Out,"First output",double,"");
+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_OUTPUT(HeartAngles,AlphaImage,"Alpha Image",vtkImageData*,"");
+BBTK_OUTPUT(HeartAngles,BetaImage,"Beta Image",vtkImageData*,"");
BBTK_END_DESCRIBE_BLACK_BOX(HeartAngles);
//=====
// 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)
{
}
+vtkImageData* creaVtkHeartAngles::getAlphaImage ()
+{
+ return alphaImage;
+}
+
+vtkImageData* creaVtkHeartAngles::getBetaImage ()
+{
+ return betaImage;
+};
+
double creaVtkHeartAngles::alpha (double P0a, double P0b,double P0c, double vx, double vy, double vz, double vxp, double vyp, double vzp)
{
double a=P0a,b=P0b,c=P0c;
return puntoCorte;
}
-vtkImageData* creaVtkHeartAngles::calculateAngleAlpha (vtkImageData* image, double Px, double Py, double Pz, double Vx, double Vy, double Vz, double Nx, double Ny, double Nz /*, double* pPlane*/)
+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)
{
- unsigned char* pPix;
- pPix = (unsigned char*)image->GetScalarPointer();
-
- for(int i=0;i<1041;i=i+3){
- int p1 = pPix[i];
- int p2 = pPix[i+1];
- int p3 = pPix[i+2];
-
- double* vecProj;
- vecProj = vectorProjection (Px, Py, Pz, Nx, Ny, Nz, p1, p2, p3);
- double a, b;
-
- //double* cutPoint;
- //cutPoint = intersectionPlaneLine(pPlane[0], pPlane[1], pPlane[2], pPlane[3], pPlane[4], pPlane[5], pPlane[6], pPlane[7], pPlane[8], px1, py1, pz1, px2, py2, pz2);
-
- a = alpha (p1, p2, p3,
- p1, p2, p3, //?? es el vector?
- vecProj[0], vecProj[1], vecProj[2]);
-
- }
-
-
-}
+ alphaImage = image;
+ alphaImage->SetExtent( image->GetExtent() );
+ alphaImage->SetOrigin( image->GetOrigin() );
+ alphaImage->SetSpacing( image->GetSpacing() );
+ alphaImage->SetScalarTypeToUnsignedChar();
+ alphaImage->SetNumberOfScalarComponents( image->GetNumberOfScalarComponents() );
+ alphaImage->AllocateScalars();
+
+ betaImage = image;
+ betaImage->SetExtent( image->GetExtent() );
+ betaImage->SetOrigin( image->GetOrigin() );
+ betaImage->SetSpacing( image->GetSpacing() );
+ betaImage->SetScalarTypeToUnsignedChar();
+ betaImage->SetNumberOfScalarComponents( image->GetNumberOfScalarComponents() );
+ betaImage->AllocateScalars();
-vtkImageData* creaVtkHeartAngles::calculateAngleBeta (vtkImageData* image, double Px, double Py, double Pz, double Vx, double Vy, double Vz, double Nx, double Ny, double Nz /*, double* pPlane*/)
-{
unsigned char* pPix;
pPix = (unsigned char*)image->GetScalarPointer();
+ double a;
+ double b;
+
+ for( int i = 0 ; i < image->GetExtent()[1] ; i++ )
+ {
+ for( int j = 0 ; j < image->GetExtent()[3] ; j++ )
+ {
+ for( int k = 0 ; k < image->GetExtent()[5] ; k++ )
+ {
+ unsigned char* pPix = (unsigned char *)image->GetScalarPointer( i , j , k );
+ int p1 = pPix[0];
+ int p2 = pPix[1];
+ int p3 = pPix[2];
+
+ double* vecProj;
+ vecProj = vectorProjection (Px, Py, Pz,
+ Nx, Ny, Nz,
+ p1, p2, p3);
+ 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]);
+
+ unsigned char *zPtr1 = (unsigned char *) alphaImage->GetScalarPointer( i , j , k );
+ *zPtr1 = a;
+ unsigned char *zPtr2 = (unsigned char *) betaImage->GetScalarPointer( i , j , k );
+ *zPtr2 = b;
+ }
+ }
+ }
+}
- for(int i=0;i<1041;i=i+3){
- int p1 = pPix[i];
- int p2 = pPix[i+1];
- int p3 = pPix[i+2];
-
- double* vecProj;
- vecProj = vectorProjection (Px, Py, Pz, Nx, Ny, Nz, p1, p2, p3);
- double a, b;
-
- //double* cutPoint;
- //cutPoint = intersectionPlaneLine(pPlane[0], pPlane[1], pPlane[2], pPlane[3], pPlane[4], pPlane[5], pPlane[6], pPlane[7], pPlane[8], px1, py1, pz1, px2, py2, pz2);
- b = beta (0, 0, 0,
- p1, p2, p3, //?? es el vector?
- vecProj[0], vecProj[1], vecProj[2]);
-
- }
-
-
-}
public :
creaVtkHeartAngles();
~creaVtkHeartAngles();
+ vtkImageData* getAlphaImage ();
+ vtkImageData* getBetaImage ();
//Parametros: Punto P0, vector V, Vector V'(proyection de V)
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 * vectorProjection (double plx, double ply, double plz, 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, 3 puntos el plano.
- vtkImageData* calculateAngleAlpha (vtkImageData* image, double Px, double Py, double Pz, double Vx, double Vy, double Vz, double Nx, double Ny, double Nz/*, double* pPlane*/);
- vtkImageData* calculateAngleBeta (vtkImageData* image, double Px, double Py, double Pz, double Vx, double Vy, double Vz, double Nx, double Ny, double Nz/*, double* pPlane*/);
+ //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);
+
protected:
private:
-
+ vtkImageData* alphaImage;
+ vtkImageData* betaImage;
};
//-end of _CREAVTKHEARTANGLES_H_------------------------------------------------------