]> Creatis software - bbtk.git/commitdiff
*** empty log message ***
authorJuan Prieto <Juan.Prieto@creatis.insa-lyon.fr>
Thu, 2 Jul 2009 07:17:31 +0000 (07:17 +0000)
committerJuan Prieto <Juan.Prieto@creatis.insa-lyon.fr>
Thu, 2 Jul 2009 07:17:31 +0000 (07:17 +0000)
packages/std/src/bbstdFilesFromDirectory.cxx
packages/vtk/src/bbvtkImagePlanes.cxx
packages/vtk/src/bbvtkImagePlanes.h

index cf4030e0e224ccf4b3d4df0663981aba8d03f2b4..9b7ac504d77f59f9be6998fdff5a316fa5d174d8 100644 (file)
@@ -97,7 +97,7 @@ int FilesFromDirectory::Explore(std::string const &dirpath, bool recursive)
       {
          std::string temp = "\"" +dirName+fileName + "\"";
          std::string::size_type spacePosition = temp.find_first_of(' ');
-         if (spacePosition != string::npos) 
+                if (spacePosition != std::string::npos) 
         {
    std::cout << "=========================================== File name : [" <<temp << 
               "] contains space(s); Discarted !" << std::endl;
index 45de5378260954a0400cde25205c4f8f5ca2471a..24d9f36a6243a5d205e6dfe44e76beb7cfc963ad 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbvtkImagePlanes.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/06/24 07:56:02 $
-  Version:   $Revision: 1.28 $
+  Date:      $Date: 2009/07/02 07:17:33 $
+  Version:   $Revision: 1.29 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -38,6 +38,7 @@
 #include "bbvtkPackage.h"
 #include "vtkCellPicker.h"
 #include "vtkProperty.h"
+#include "vtkPolyData.h"
 
 
 #include "vtkMetaImageWriter.h"
@@ -136,7 +137,7 @@ namespace bbvtk
  };
   //================================================================
 
-  //vtkCxxRevisionMacro(ImagePlanes::VtkCallbackType, "$Revision: 1.28 $");
+  //vtkCxxRevisionMacro(ImagePlanes::VtkCallbackType, "$Revision: 1.29 $");
 
   //================================================================
 
@@ -171,6 +172,8 @@ namespace bbvtk
 
         _imageReslicer = NULL;
         image=NULL;
+        _transform =NULL;
+       _matrix =NULL;
    }
    
 
@@ -270,12 +273,13 @@ void ImagePlanes::Process()
        if (bbGetInputIn()!=0)
        {
 
+               int xMin, xMax, yMin, yMax, zMin, zMax;
+               bbGetInputIn()->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax);
+
                if ( image != bbGetInputIn()){//bbGetInputStatus("In") != bbtk::UPTODATE ){
                        // Input image has changed : reinitialize planes
-                       image = bbGetInputIn();
-
-                       int xMin, xMax, yMin, yMax, zMin, zMax;
-                       bbGetInputIn()->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax);
+                       image = bbGetInputIn();                 
+                       
 
                        // Initial values : center of the volume (in real world, not in pixels!)
                        double xSpacing, ySpacing, zSpacing;
@@ -324,33 +328,8 @@ void ImagePlanes::Process()
                std::cout<<pointsx.size()<<pointsy.size()<<pointsz.size()<<std::endl;
 
                if(pointsx.size()==pointsy.size() && pointsx.size()==pointsz.size()&&pointsx.size()>=3){
-                       vtkImagePlaneWidget* plane3pts = (vtkImagePlaneWidget*)bbGetOutputPlane3Pts();
-                       //vtkPlaneWidget* plane3pts = (vtkPlaneWidget*)bbGetOutputPlane3Pts();
-
-                       plane3pts->SetInput(bbGetInputIn());
-
-                       //xSpacing = ySpacing = zSpacing = 1;
-                       double xSpacing, ySpacing, zSpacing;
-                       bbGetInputIn()->GetSpacing(xSpacing, ySpacing, zSpacing);
-
-                       plane3pts->SetOrigin(pointsx[0]*xSpacing,pointsy[0]*ySpacing,pointsz[0]*zSpacing);                              
-                       plane3pts->SetPoint1(pointsx[1]*xSpacing,pointsy[1]*ySpacing,pointsz[1]*zSpacing);
-                       //plane3pts->SetPoint1((pointsx[1]-pointsx[0])*xSpacing,(pointsy[1]-pointsy[0])*ySpacing,(pointsz[1]-pointsz[0])*zSpacing);
-                       plane3pts->SetPoint2(pointsx[2]*xSpacing,pointsy[2]*ySpacing,pointsz[2]*zSpacing);
-                       //plane3pts->SetPoint2((pointsx[2]-pointsx[0])*xSpacing,(pointsy[2]-pointsy[0])*ySpacing,(pointsz[2]-pointsz[0])*zSpacing);
-                       plane3pts->GetResliceOutput()->Update();
-
 
 
-                       if (_imageReslicer==NULL){
-                               _imageReslicer = vtkImageReslice::New();                                        
-                               _imageReslicer->SetOutputDimensionality(2);
-                               _imageReslicer->SetInterpolationModeToLinear();
-                       }
-
-                       _imageReslicer->SetInput( bbGetInputIn() );
-                       _imageReslicer->SetInformationInput(bbGetInputIn());
-
                        double origin[3];
                        origin[0] = pointsx[0];
                        origin[1] = pointsy[0];
@@ -363,31 +342,77 @@ void ImagePlanes::Process()
                        double point2[3];
                        point2[0]= pointsx[2];
                        point2[1]= pointsy[2];
-                       point2[2]= pointsz[2];                          
+                       point2[2]= pointsz[2];  
 
                        double* vect1= getNormal(makeVector(origin, point1));
                        double* vect2= getNormal(makeVector(origin, point2));                           
                        double* crossp = getCrossProduct(vect1, vect2);
 
-                       /*std::cout<<"origin "<<origin[0]<<" "<<origin[1]<<" "<<origin[2]<<" "<<std::endl;
-                       std::cout<<"point1 "<<point1[0]<<" "<<point1[1]<<" "<<point1[2]<<" "<<std::endl;
-                       std::cout<<"point2 "<<point2[0]<<" "<<point2[1]<<" "<<point2[2]<<" "<<std::endl;
-                       std::cout<<"vect1 "<<vect1[0]<<" "<<vect1[1]<<" "<<vect1[2]<<" "<<std::endl;                            
-                       std::cout<<"vect2 "<<vect2[0]<<" "<<vect2[1]<<" "<<vect2[2]<<" "<<std::endl;
-                       std::cout<<"crossp "<<crossp[0]<<" "<<crossp[1]<<" "<<crossp[2]<<" "<<std::endl;*/
+                       double *newx = getCrossProduct(vect2, crossp);
+                       
+                       int ext[6],factor=0;
+                       bbGetInputIn()->GetExtent(ext);
 
+                       factor = ext[0]<ext[3]? ext[3] : ext[0];
+                       factor = factor<ext[5]? ext[5] : factor;
 
-                       _imageReslicer->SetResliceAxesDirectionCosines(vect1[0],vect1[1],vect1[2],
-                                                                       vect2[0],vect2[1],vect2[2],
-                                                                       crossp[0],crossp[1],crossp[2]);
-                       //_imageReslicer->SetResliceAxesOrigin(0,0,0);
-                       _imageReslicer->SetResliceAxesOrigin(origin[0],origin[1],origin[2]);
 
+                       vtkImagePlaneWidget* plane3pts = (vtkImagePlaneWidget*)bbGetOutputPlane3Pts();
+                       plane3pts->SetInput(bbGetInputIn());                    
+                       double xSpacing, ySpacing, zSpacing;
+                       bbGetInputIn()->GetSpacing(xSpacing, ySpacing, zSpacing);
+                       plane3pts->SetOrigin(pointsx[0]*xSpacing,pointsy[0]*ySpacing,pointsz[0]*zSpacing);      
+                       plane3pts->SetPoint1((origin[0]+newx[0]*factor)*xSpacing,
+                                                                       (origin[1]+newx[1]*factor)*ySpacing,
+                                                                       (origin[2]+newx[2]*factor)*zSpacing);
+                       plane3pts->SetPoint2((origin[0]+vect2[0]*factor)*xSpacing,
+                                                                       (origin[1]+vect2[1]*factor)*ySpacing,
+                                                                       (origin[2]+vect2[2]*factor)*zSpacing);
+                       plane3pts->GetResliceOutput()->Update();
+
+                       if (_imageReslicer==NULL){
+                               _imageReslicer = vtkImageReslice::New();                                        
+                               _imageReslicer->SetOutputDimensionality(2);
+                               _imageReslicer->SetInterpolationModeToLinear();
+                               _transform = vtkTransform::New();
+                               _matrix = vtkMatrix4x4::New();  
+                       }
+                       _imageReslicer->SetInput( bbGetInputIn() );
+                       _imageReslicer->SetInformationInput(bbGetInputIn());    
+                       _imageReslicer->SetResliceAxesDirectionCosines(newx[0],newx[1],newx[2],
+                                                                       vect2[0],vect2[1],vect2[2],
+                                                                       crossp[0],crossp[1],crossp[2]);                 
+                       _imageReslicer->SetResliceAxesOrigin(origin[0]*xSpacing,origin[1]*ySpacing,origin[2]*zSpacing);
                        _imageReslicer->GetOutput()->Update();
                        _imageReslicer->GetOutput()->UpdateInformation();
 
+                       
                        bbSetOutputImage3Pts(_imageReslicer->GetOutput());
+
+
+                        
+                       _matrix->Identity();    
+
+                       _matrix->SetElement(0,0,newx[0]);
+                       _matrix->SetElement(1,0,newx[1]);
+                       _matrix->SetElement(2,0,newx[2]);
+                       _matrix->SetElement(0,1,vect2[0]);
+                       _matrix->SetElement(1,1,vect2[1]);
+                       _matrix->SetElement(2,1,vect2[2]);
+                       _matrix->SetElement(0,2,crossp[0]);
+                       _matrix->SetElement(1,2,crossp[1]);
+                       _matrix->SetElement(2,2,crossp[2]);
+                       _matrix->SetElement(0,3,origin[0]);
+                       _matrix->SetElement(1,3,origin[1]);
+                       _matrix->SetElement(2,3,origin[2]);
+
                        
+                       _transform->SetMatrix(_matrix);
+
+                       bbSetOutputTransform3Pts((vtkLinearTransform*)_transform);
+
+
+                                               
                }               
        }
 }
@@ -464,9 +489,9 @@ double* ImagePlanes::makeVector(double podouble0[3], double podouble1[3]){
        double *vect;
        vect = new double[3];
 
-       vect[0]= podouble0[0]-podouble1[0];
-       vect[1]= podouble0[1]-podouble1[1];
-       vect[2]= podouble0[2]-podouble1[2];
+       vect[0]= podouble1[0]-podouble0[0];
+       vect[1]= podouble1[1]-podouble0[1];
+       vect[2]= podouble1[2]-podouble0[2];
 
        return vect;
 
index d2f03feb1321f7e2ba39996561b4195ad69364de..aec9cba2e891264657b090272eba34c3a74e5bab 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbvtkImagePlanes.h,v $
   Language:  C++
-  Date:      $Date: 2009/06/24 07:56:02 $
-  Version:   $Revision: 1.18 $
+  Date:      $Date: 2009/07/02 07:17:33 $
+  Version:   $Revision: 1.19 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -56,6 +56,7 @@ class vtkImagePlaneWidget;
 
 #include "vtkPlaneWidget.h"
 #include "vtkImageReslice.h"
+#include <vtkTransform.h>
 
 namespace bbvtk
 {
@@ -79,7 +80,9 @@ namespace bbvtk
     BBTK_DECLARE_OUTPUT(ImageX,    vtkImageData*);
     BBTK_DECLARE_OUTPUT(ImageY,    vtkImageData*);        
     BBTK_DECLARE_OUTPUT(ImageZ,    vtkImageData*);  
-    BBTK_DECLARE_OUTPUT(Image3Pts, vtkImageData*);  
+    BBTK_DECLARE_OUTPUT(Image3Pts, vtkImageData*);     
+       BBTK_DECLARE_OUTPUT(Transform3Pts, vtkLinearTransform*);        
+
     BBTK_PROCESS(Process);
     void Process();
     
@@ -91,6 +94,9 @@ namespace bbvtk
     vtkImageData* image;
     vtkImageReslice* _imageReslicer;
 
+       vtkTransform* _transform;
+       vtkMatrix4x4* _matrix;
+
     double* getCrossProduct(double* vect0,double* vect1);
     double getPodoubleProduct(double* vect0,double* vect1);
     double* getNormal(double* vect);
@@ -120,6 +126,9 @@ namespace bbvtk
   BBTK_OUTPUT(ImagePlanes,ImageY,    "The image in Y direction",               vtkImageData*,          "");
   BBTK_OUTPUT(ImagePlanes,ImageZ,    "The image in Z direction",               vtkImageData*,          "");    
   BBTK_OUTPUT(ImagePlanes,Image3Pts, "The image (3 points plane definition)",  vtkImageData*,          "");    
+  BBTK_OUTPUT(ImagePlanes,Transform3Pts, "The Tranform of the image",  vtkLinearTransform*,          "");    
+     
   BBTK_END_DESCRIBE_BLACK_BOX(ImagePlanes);
   //=================================================================