]> Creatis software - clitk.git/blob - vv/vvMesh.h
ce5db14b9830d1b8c5a0665b8ccf250bbb91a3b8
[clitk.git] / vv / vvMesh.h
1 /*=========================================================================
2
3  Program:   vv
4  Language:  C++
5  Author :   Joel Schaerer (joel.schaerer@insa-lyon.fr)
6  Program:   vv
7
8 Copyright (C) 2008
9 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
10 CREATIS-LRMN http://www.creatis.insa-lyon.fr
11
12 This program is free software: you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation, version 3 of the License.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
24 =========================================================================*/
25 #ifndef vvMesh_h
26 #define vvMesh_h
27
28 #include <string>
29 #include <utility>
30 #include <vector>
31
32 #include <itkObjectFactory.h>
33
34 #include "vvImage.h"
35
36 class vtkPolyData;
37 class vtkImageData;
38
39 /** A vvMesh is assumed to be either a 3D closed surface 
40  *  or a series of surfaces 
41  *  It uses a dual representation: both binary mask and mesh**/
42 class vvMesh : public itk::LightObject
43 {
44 public:
45     typedef vvMesh Self;
46     typedef itk::SmartPointer<Self> Pointer;
47     itkNewMacro(Self);
48
49     void ReadFromVTK(const char * filename);
50     std::string structure_name;
51     ///Contour color, [0,1]
52     double r,g,b;
53
54     vtkPolyData* GetMesh(unsigned int i) const {return meshes[i];}
55     void AddMesh(vtkPolyData* p);
56     ///Removes all meshes in the object
57     void RemoveMeshes();
58     unsigned int GetNumberOfMeshes() { return meshes.size(); }
59
60     vtkImageData* GetMask(unsigned int i) const {return masks[i];}
61     void AddMask(vtkImageData* im);
62     void RemoveMasks();
63     unsigned int GetNumberOfMasks() { return masks.size(); }
64
65     ///Pretty-print information about the mesh
66     void Print() const;
67     ///Copies the meta-informations from another mesh
68     void CopyInformation(vvMesh::Pointer input);
69     void SetSpacing(double spacing) {slice_spacing=spacing;}
70     double GetSpacing() {return slice_spacing;}
71     ///Recompute the meshes from the masks
72     void ComputeMeshes();
73     /**Recompute the masks from the meshes.
74      * extrude means that the mesh must be extruded before binarizing,
75      * which is useful when creating a mesh from a stack of slices */
76     void ComputeMasks(vtkImageData* sample,bool extrude=false);
77     ///Create a new vvMesh by propagating the mesh with a displacement VF
78     void propagateContour(vvImage::Pointer vf);
79 protected:
80     ///The spacing between the planar contour, assumed to be constant
81     double slice_spacing;
82     std::vector<vtkPolyData *> meshes;
83     std::vector<vtkImageData *> masks;
84
85     vvMesh();
86     ~vvMesh();
87 };
88
89 ///Propagate a contour using a vector of motion fields, returns a 4D contour
90
91 #endif