OTB  10.0.0
Orfeo Toolbox
otbVectorDataFileReader.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbVectorDataFileReader_h
22 #define otbVectorDataFileReader_h
23 
24 #include "otbVectorDataSource.h"
25 #include "otbVectorDataIOBase.h"
26 #include "OTBVectorDataIOExport.h"
27 #include <string>
28 
29 namespace otb
30 {
37 class VectorDataFileReaderException : public itk::ExceptionObject
38 {
39 public:
41  itkTypeMacro(VectorDataFileReaderException, itk::ExceptionObject);
42 
44  VectorDataFileReaderException(const char* file, unsigned int line, const char* message = "Error in IO", const char* loc = "Unknown")
45  : itk::ExceptionObject(file, line, message, loc)
46  {
47  }
48 
50  VectorDataFileReaderException(const std::string& file, unsigned int line, const char* message = "Error in IO", const char* loc = "Unknown")
51  : itk::ExceptionObject(file, line, message, loc)
52  {
53  }
54 
55  VectorDataFileReaderException(const std::string& file, unsigned int line, const std::string& message = "Error in IO", const char* loc = "Unknown")
56  : itk::ExceptionObject(file, line, message, loc)
57  {
58  }
59 };
60 
87 template <class TOutputVectorData>
88 class ITK_TEMPLATE_EXPORT VectorDataFileReader : public VectorDataSource<TOutputVectorData>
89 {
90 public:
94  typedef itk::SmartPointer<Self> Pointer;
95  typedef itk::SmartPointer<const Self> ConstPointer;
96 
98  itkNewMacro(Self);
99 
102 
103  typedef TOutputVectorData OutputVectorType;
105 
106  itkStaticConstMacro(VDimension, unsigned int, OutputVectorType::DataNodeType::Dimension);
107  typedef itk::Vector<double, VDimension> SpacingType;
108  typedef itk::Point<double, VDimension> PointType;
109 
111  itkSetStringMacro(FileName);
112  itkGetStringMacro(FileName);
114 
121  void SetVectorDataIO(VectorDataIOBaseType* vectorDataIO);
124 
127  void GenerateOutputInformation(void) override;
128 
130  void GenerateData() override;
131 
132 protected:
134  ~VectorDataFileReader() override;
135  std::string m_ExceptionMessage;
136 
138  bool m_UserSpecifiedVectorDataIO; // keep track whether the
139 
140  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
141 
142  std::string m_FileName; // The file to be read
143 
144 private:
145  VectorDataFileReader(const Self&) = delete;
146  void operator=(const Self&) = delete;
147 
151  void TestFileExistenceAndReadability();
152 };
153 
154 } // end namespace otb
155 
156 #ifndef OTB_MANUAL_INSTANTIATION
158 #endif
159 
160 #endif // otbVectorDataFileReader_h
Base exception class for IO conflicts.
VectorDataFileReaderException(const std::string &file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
VectorDataFileReaderException(const char *file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
VectorDataFileReaderException(const std::string &file, unsigned int line, const std::string &message="Error in IO", const char *loc="Unknown")
Data source that reads vector data from a single file.
VectorDataSource< TOutputVectorData > Superclass
VectorDataIOBaseType::Pointer m_VectorDataIO
itk::Point< double, VDimension > PointType
VectorDataFileReader(const Self &)=delete
itkGetObjectMacro(VectorDataIO, VectorDataIOBaseType)
itk::SmartPointer< const Self > ConstPointer
itk::SmartPointer< Self > Pointer
void operator=(const Self &)=delete
itk::Vector< double, VDimension > SpacingType
Abstract superclass defines VectorData IO interface.
itk::SmartPointer< Self > Pointer
Filter hierarchy for generating VectorData.
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.