]> Creatis software - clitk.git/blob - registration/clitkPointListReader.txx
Debug RTStruct conversion with empty struc
[clitk.git] / registration / clitkPointListReader.txx
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 __clitkPointListReader_txx
19 #define __clitkPointListReader_txx
20 #include "clitkPointListReader.h"
21
22 namespace clitk
23 {
24
25   template<unsigned int Dimension>
26   PointListReader< Dimension >
27   ::PointListReader()
28   {
29     m_Verbose=false;
30   }
31
32   template<unsigned int Dimension>
33   typename PointListReader< Dimension >::PointListType
34   PointListReader< Dimension >
35   ::Read(const std::string& filename)
36   {
37     std::ifstream is;
38     openFileForReading(is, filename);
39     PointListType list;
40     PointType point;
41     double x;
42
43     if(m_Verbose)std::cout<<"Reading "<<filename<<"..."<<std::endl;
44     for (unsigned int dim=0; dim<Dimension; dim++)
45       {
46         skipComment(is);
47         is >> x;
48         point[dim]=x;
49       }
50     while (!is.eof()) 
51       {
52         list.push_back(point);
53         for (unsigned int dim=0; dim<Dimension; dim++)
54           {
55             skipComment(is);
56             is >> x;
57             point[dim]=x;
58           }
59       }
60     return list;
61   }
62     
63   template<unsigned int Dimension>
64   typename PointListReader< Dimension >::PointListsType
65   PointListReader< Dimension >
66   ::Read(char** filename, const unsigned int& n)
67   {
68     PointListsType lists;
69     for (unsigned int number=0; number<n; number++)
70       lists.push_back(Read(filename[number]) );
71     return lists;
72   }
73
74 }// clitk
75 #endif // PointListReader