1 /*=========================================================================
5 Author : Joel Schaerer (joel.schaerer@insa-lyon.fr)
9 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
10 CREATIS-LRMN http://www.creatis.insa-lyon.fr
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.
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.
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/>.
24 =========================================================================*/
32 #include <itkObjectFactory.h>
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
46 typedef itk::SmartPointer<Self> Pointer;
49 void ReadFromVTK(const char * filename);
50 std::string structure_name;
51 ///Contour color, [0,1]
54 vtkPolyData* GetMesh(unsigned int i) const {return meshes[i];}
55 void AddMesh(vtkPolyData* p);
56 ///Removes all meshes in the object
58 unsigned int GetNumberOfMeshes() { return meshes.size(); }
60 vtkImageData* GetMask(unsigned int i) const {return masks[i];}
61 void AddMask(vtkImageData* im);
63 unsigned int GetNumberOfMasks() { return masks.size(); }
65 ///Pretty-print information about the mesh
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
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);
80 ///The spacing between the planar contour, assumed to be constant
82 std::vector<vtkPolyData *> meshes;
83 std::vector<vtkImageData *> masks;
89 ///Propagate a contour using a vector of motion fields, returns a 4D contour