X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vtk%2FvtkgdcmViewer.cxx;h=95da0fa0faf98538d2882e3246124ffd01376156;hb=6f03d7978c122dfc2c7a0ee6bc9f2fd019d98ca3;hp=9e1b6a5993dfbd0d69f4314b36f4d7166d06421f;hpb=bd2c6b9f9fa4b815153b200081de0450429a882e;p=gdcm.git diff --git a/vtk/vtkgdcmViewer.cxx b/vtk/vtkgdcmViewer.cxx index 9e1b6a59..95da0fa0 100644 --- a/vtk/vtkgdcmViewer.cxx +++ b/vtk/vtkgdcmViewer.cxx @@ -1,3 +1,20 @@ +/*========================================================================= + + Program: gdcm + Module: $RCSfile: vtkgdcmViewer.cxx,v $ + Language: C++ + Date: $Date: 2009/11/03 14:05:23 $ + Version: $Revision: 1.32 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ // This example illustrates how the vtkGdcmReader vtk class can be // used in order to: // * produce a simple (vtk based) Dicom image STACK VIEWER. @@ -12,8 +29,6 @@ // * the produced vtk file is named "foo.vtk" (in the invocation directory). // //---------------------------------------------------------------------------- -#include - #include #include #include @@ -24,7 +39,7 @@ #include #include "vtkGdcmReader.h" - +#include "gdcmDocument.h" // for NO_SHADOWSEQ #ifndef vtkFloatingPointType #define vtkFloatingPointType float #endif @@ -55,7 +70,6 @@ public: int max = ImageViewer->GetWholeZMax(); int slice = (ImageViewer->GetZSlice() + 1 ) % ++max; ImageViewer->SetZSlice( slice ); - ImageViewer->GetRenderer()->ResetCameraClippingRange(); ImageViewer->Render(); } } @@ -78,8 +92,22 @@ int main(int argc, char *argv[]) for(int i=1; i< argc; i++) reader->AddFileName( argv[i] ); +// TODO : allow user to choose Load Mode + reader->SetLoadMode(GDCM_NAME_SPACE::LD_NOSHADOWSEQ); reader->Update(); + + +std::cout << "[0][0]==========" << +reader->GetOutput()->GetScalarComponentAsFloat(0,0,0,0) << +"====================" +<< std::endl; +std::cout << "[127][127]==========" << +reader->GetOutput()->GetScalarComponentAsFloat(0,127,0,0) << +"====================" +<< std::endl; + + //print debug info: reader->GetOutput()->Print( cout ); @@ -99,7 +127,13 @@ int main(int argc, char *argv[]) } else { - double *range = reader->GetOutput()->GetScalarRange(); + + // For a single medical image, it would be more efficient to use + // 0028|1050 [DS] [Window Center] + // 0028|1051 [DS] [Window Width] + // but vtkgdcmReader doesn't know about them :-( + + vtkFloatingPointType *range = reader->GetOutput()->GetScalarRange(); viewer->SetColorLevel (0.5 * (range[1] + range[0])); viewer->SetColorWindow (range[1] - range[0]); @@ -121,12 +155,22 @@ int main(int argc, char *argv[]) iren->Initialize(); iren->Start(); - //if you wish you can export dicom to a vtk file + //if you wish you can export dicom to a vtk file + vtkStructuredPointsWriter *writer = vtkStructuredPointsWriter::New(); writer->SetInput( reader->GetOutput()); writer->SetFileName( "foo.vtk" ); writer->SetFileTypeToBinary(); - writer->Write(); + //writer->Write(); + +std::cout << "==========" << std::endl; + +std::cout << "==========" << +reader->GetOutput()->GetScalarComponentAsFloat(0,0,0,0) << +"====================" +<< std::endl; + + reader->Delete(); iren->Delete();