]> Creatis software - clitk.git/blob - vv/vvMesh.h
Debug RTStruct conversion with empty struc
[clitk.git] / vv / vvMesh.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef vvMesh_h
19 #define vvMesh_h
20 #include <string>
21 #include <utility>
22 #include <vector>
23
24 #include <itkObjectFactory.h>
25
26 #include "vvImage.h"
27
28 class vtkPolyData;
29 class vtkImageData;
30
31 /** A vvMesh is assumed to be either a 3D closed surface 
32  *  or a series of surfaces 
33  *  It uses a dual representation: both binary mask and mesh**/
34 class vvMesh : public itk::LightObject
35 {
36 public:
37     typedef vvMesh Self;
38     typedef itk::SmartPointer<Self> Pointer;
39     itkNewMacro(Self);
40
41     void ReadFromVTK(const char * filename);
42     std::string structure_name;
43     ///Contour color, [0,1]
44     double r,g,b;
45
46     vtkPolyData* GetMesh(unsigned int i) const {return meshes[i];}
47     void AddMesh(vtkPolyData* p);
48     ///Removes all meshes in the object
49     void RemoveMeshes();
50     unsigned int GetNumberOfMeshes() { return (unsigned int)meshes.size(); }
51
52     vtkImageData* GetMask(unsigned int i) const {return masks[i];}
53     void AddMask(vtkImageData* im);
54     void RemoveMasks();
55     unsigned int GetNumberOfMasks() { return (unsigned int)masks.size(); }
56
57     ///Pretty-print information about the mesh
58     void Print() const;
59     ///Copies the meta-informations from another mesh
60     void CopyInformation(vvMesh::Pointer input);
61     void SetSpacing(double spacing) {slice_spacing=spacing;}
62     double GetSpacing() {return slice_spacing;}
63     ///Recompute the meshes from the masks
64     void ComputeMeshes();
65     /**Recompute the masks from the meshes.
66      * extrude means that the mesh must be extruded before binarizing,
67      * which is useful when creating a mesh from a stack of slices */
68     void ComputeMasks(vtkImageData* sample,bool extrude=false);
69     ///Create a new vvMesh by propagating the mesh with a displacement VF
70     void propagateContour(vvImage::Pointer vf);
71 protected:
72     ///The spacing between the planar contour, assumed to be constant
73     double slice_spacing;
74     std::vector<vtkPolyData *> meshes;
75     std::vector<vtkImageData *> masks;
76
77     vvMesh();
78     ~vvMesh();
79 };
80
81 ///Propagate a contour using a vector of motion fields, returns a 4D contour
82
83 #endif