#pragma once#include<fstream>#include<string>#include<vector>#include"itkDataObject.h"#include"itkObjectFactory.h"#include"itkPoint.h"#include"itkWeakPointer.h"namespaceitk{classITK_EXPORTParticlePositionReader:publicDataObject{public:typedefParticlePositionReaderSelf;typedefDataObjectSuperclass;typedefSmartPointer<Self>Pointer;typedefSmartPointer<constSelf>ConstPointer;typedefWeakPointer<constSelf>ConstWeakPointer;typedefPoint<double,3>PointType;itkNewMacro(Self);itkTypeMacro(ParticlePositionReader,DataObject);conststd::vector<PointType>&GetOutput()const{returnm_Output;}itkSetStringMacro(FileName);itkGetStringMacro(FileName);inlinevoidRead(){this->Update();}voidUpdate(){intcounter=0;// Open the ascii file.std::ifstreamin(m_FileName.c_str());if(!in){itkExceptionMacro("Could not open point file for input: "<<m_FileName.c_str());}// Read all of the points, one point per line.while(in){PointTypept;for(unsignedintd=0;d<3;d++){in>>pt[d];}m_Output.push_back(pt);counter++;}// this algorithm pushes the last point twicem_Output.pop_back();in.close();};protected:ParticlePositionReader(){}voidPrintSelf(std::ostream&os,Indentindent)const{Superclass::PrintSelf(os,indent);os<<indent<<"ParticlePositionReader: "<<std::endl;}virtual~ParticlePositionReader(){};private:ParticlePositionReader(constSelf&);// purposely not implementedvoidoperator=(constSelf&);// purposely not implementedstd::vector<PointType>m_Output;std::stringm_FileName;};}// end namespace itk