1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
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
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.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef clitkSelectPointsGenericFilter_cxx
19 #define clitkSelectPointsGenericFilter_cxx
21 /* =================================================
22 * @file clitkSelectPointsGenericFilter.cxx
28 ===================================================*/
30 #include "clitkSelectPointsGenericFilter.h"
37 //-----------------------------------------------------------
39 //-----------------------------------------------------------
40 SelectPointsGenericFilter::SelectPointsGenericFilter()
46 //-----------------------------------------------------------
48 //-----------------------------------------------------------
49 void SelectPointsGenericFilter::Update()
51 //-----------------------------
53 //-----------------------------
54 typedef double ValueType;
55 typedef std::vector<ValueType> MeasureListType;
57 typedef itk::Point<double, 3> PointType;
58 typedef clitk::List<PointType> PointListType;
59 typedef clitk::Lists<PointType> PointListsType;
62 //-----------------------------
64 //-----------------------------
65 PointListsType pointLists;
66 unsigned int numberOfPoints=0;
67 unsigned int numberOfLists=m_ArgsInfo.input_given;
68 for (unsigned int i=0; i<numberOfLists; i++)
71 pointLists.push_back(PointListType(m_ArgsInfo.input_arg[i], m_Verbose) );
73 // Verify the number of points
74 if (i==0) numberOfPoints=pointLists[i].size();
77 if (numberOfPoints!=pointLists[i].size())
79 std::cerr<<"Size of first list ("<<numberOfPoints
80 <<") is different from size of list "<<i
81 <<" ("<<pointLists[i].size()<<")..."<<std::endl;
87 //-----------------------------
88 // Reference point list
89 //-----------------------------
90 PointListType referencePointList;
91 if (m_Verbose) std::cout<<"Reference point list:"<<std::endl;
92 referencePointList=PointListType(m_ArgsInfo.ref_arg, m_Verbose);
93 if (numberOfPoints!=referencePointList.size())
95 std::cerr<<"Size of the first list ("<<numberOfPoints
96 <<") is different from size of the reference list ("
97 << referencePointList.size() <<")..."<<std::endl;
102 //-----------------------------
104 //-----------------------------
105 PointListType sReferencePointList;
106 PointListsType sPointLists(numberOfLists);
107 unsigned int counter=0;
108 for (unsigned int number=0; number< referencePointList.size(); number++)
110 for (unsigned int component=0; component< m_ArgsInfo.component_given; component++)
112 if ( (referencePointList[number][m_ArgsInfo.component_arg[component]] >= m_ArgsInfo.lower_arg[component])
113 && (referencePointList[number][m_ArgsInfo.component_arg[component]] <= m_ArgsInfo.upper_arg[component]) )
115 if(m_Verbose) std::cout<<"Selecting point "<<number<<": "<<referencePointList[number]<<std::endl;
116 sReferencePointList.push_back(referencePointList[number]);
117 for (unsigned int i=0;i<pointLists.size();i++)
118 sPointLists[i].push_back(pointLists[i][number]);
123 if (m_Verbose) std::cout<<"Selected "<<counter<<" points..."<<std::endl;
127 //-----------------------------
129 //-----------------------------
130 sReferencePointList.Write(m_ArgsInfo.sRef_arg,m_Verbose);
131 std::vector<std::string> filenames;
132 for (unsigned int i=0;i<pointLists.size();i++)
133 filenames.push_back(m_ArgsInfo.sInput_arg[i]);
134 sPointLists.Write(filenames,m_Verbose);
141 #endif //#define clitkSelectPointsGenericFilter_cxx