]> Creatis software - clitk.git/blob - common/clitkImage2DicomRTStructFilter.txx
Merge branch 'master' of /home/dsarrut/clitk3.server
[clitk.git] / common / clitkImage2DicomRTStructFilter.txx
1 /*=========================================================================
2   Program:         vv http://www.creatis.insa-lyon.fr/rio/vv
3   Main authors :   XX XX XX
4
5   Authors belongs to:
6   - University of LYON           http://www.universite-lyon.fr/
7   - Léon Bérard cancer center    http://www.centreleonberard.fr
8   - CREATIS CNRS laboratory      http://www.creatis.insa-lyon.fr
9
10   This software is distributed WITHOUT ANY WARRANTY; without even
11   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12   PURPOSE.  See the copyright notices for more information.
13
14   It is distributed under dual licence
15   - BSD       http://www.opensource.org/licenses/bsd-license.php
16   - CeCILL-B  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17
18   =========================================================================*/
19
20 // std
21 #include <iterator>
22 #include <algorithm>
23
24 // clitk
25 #include "clitkImage2DicomRTStructFilter.h"
26 #include "clitkImageCommon.h"
27 #include "vvFromITK.h"
28
29 // vtk
30 #include <vtkPolyDataToImageStencil.h>
31 #include <vtkSmartPointer.h>
32 #include <vtkImageStencil.h>
33 #include <vtkLinearExtrusionFilter.h>
34 #include <vtkMetaImageWriter.h>
35 #include <vtkImageData.h>
36
37 // itk
38 #include <itkImage.h>
39 #include <itkVTKImageToImageFilter.h>
40
41 //--------------------------------------------------------------------
42 template<class PixelType>
43 clitk::Image2DicomRTStructFilter<PixelType>::Image2DicomRTStructFilter()
44 {
45   DD("Image2DicomRTStructFilter Const");
46 }
47 //--------------------------------------------------------------------
48
49
50 //--------------------------------------------------------------------
51 template<class PixelType>
52 clitk::Image2DicomRTStructFilter<PixelType>::~Image2DicomRTStructFilter()
53 {
54   DD("Image2DicomRTStructFilter Destructor");
55 }
56 //--------------------------------------------------------------------
57
58
59 //--------------------------------------------------------------------
60 template<class PixelType>
61 void clitk::Image2DicomRTStructFilter<PixelType>::Update() 
62 {
63   DD("Image2DicomRTStructFilter::GenerateData");
64
65   // Read DicomRTStruct
66   std::string filename = "RS.zzQAnotmt_french01_.dcm";
67   clitk::DicomRT_StructureSet::Pointer structset = clitk::DicomRT_StructureSet::New();
68   structset->Read(filename);
69   
70   DD(structset->GetName());
71   clitk::DicomRT_ROI * roi = structset->GetROIFromROINumber(1); // Aorta
72   DD(roi->GetName());
73   DD(roi->GetROINumber());
74
75   // Add an image to the roi
76   vvImage::Pointer im = vvImageFromITK<3, PixelType>(m_Input);
77   roi->SetImage(im);
78
79   // Get one contour
80   DD("Compute Mesh");
81   roi->ComputeMeshFromImage();
82   vtkSmartPointer<vtkPolyData> mesh = roi->GetMesh();
83   DD("done");
84   
85   // Change the mesh (shift by 10);
86   // const vtkSmartPointer<vtkPoints> & points = mesh->GetPoints();
87   // for(uint i=0; i<mesh->GetNumberOfVerts (); i++) {
88   //   DD(i);
89   //   double * p = points->GetPoint(i);
90   //   p[0] += 30;
91   //   points->SetPoint(i, p);
92   // }
93   roi->SetName("TOTO");
94   roi->SetDicomUptodateFlag(false); // indicate that dicom info must be updated from the mesh.
95     
96   // Convert to dicom ?
97   DD("TODO");
98   
99   // Write
100   structset->Write("toto.dcm");
101 }
102 //--------------------------------------------------------------------
103
104
105
106