OTB  9.0.0
Orfeo Toolbox
otbVectorDataFileReader.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 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 <string>
27 
28 namespace otb
29 {
36 class VectorDataFileReaderException : public itk::ExceptionObject
37 {
38 public:
40  itkTypeMacro(VectorDataFileReaderException, itk::ExceptionObject);
41 
43  VectorDataFileReaderException(const char* file, unsigned int line, const char* message = "Error in IO", const char* loc = "Unknown")
44  : itk::ExceptionObject(file, line, message, loc)
45  {
46  }
47 
49  VectorDataFileReaderException(const std::string& file, unsigned int line, const char* message = "Error in IO", const char* loc = "Unknown")
50  : itk::ExceptionObject(file, line, message, loc)
51  {
52  }
53 
54  VectorDataFileReaderException(const std::string& file, unsigned int line, const std::string& message = "Error in IO", const char* loc = "Unknown")
55  : itk::ExceptionObject(file, line, message, loc)
56  {
57  }
58 };
59 
86 template <class TOutputVectorData>
87 class ITK_EXPORT VectorDataFileReader : public VectorDataSource<TOutputVectorData>
88 {
89 public:
93  typedef itk::SmartPointer<Self> Pointer;
94  typedef itk::SmartPointer<const Self> ConstPointer;
95 
97  itkNewMacro(Self);
98 
101 
102  typedef TOutputVectorData OutputVectorType;
104 
105  itkStaticConstMacro(VDimension, unsigned int, OutputVectorType::DataNodeType::Dimension);
106  typedef itk::Vector<double, VDimension> SpacingType;
107  typedef itk::Point<double, VDimension> PointType;
108 
110  itkSetStringMacro(FileName);
111  itkGetStringMacro(FileName);
113 
120  void SetVectorDataIO(VectorDataIOBaseType* vectorDataIO);
121  itkGetObjectMacro(VectorDataIO, VectorDataIOBaseType);
123 
126  void GenerateOutputInformation(void) override;
127 
129  void GenerateData() override;
130 
131 protected:
133  ~VectorDataFileReader() override;
134  std::string m_ExceptionMessage;
135 
137  bool m_UserSpecifiedVectorDataIO; // keep track whether the
138 
139  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
140 
141  std::string m_FileName; // The file to be read
142 
143 private:
144  VectorDataFileReader(const Self&) = delete;
145  void operator=(const Self&) = delete;
146 
150  void TestFileExistenceAndReadability();
151 };
152 
153 } // end namespace otb
154 
155 #ifndef OTB_MANUAL_INSTANTIATION
157 #endif
158 
159 #endif // otbVectorDataFileReader_h
otb::VectorDataFileReaderException::VectorDataFileReaderException
VectorDataFileReaderException(const char *file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
Definition: otbVectorDataFileReader.h:43
otb::VectorDataFileReader
Data source that reads vector data from a single file.
Definition: otbVectorDataFileReader.h:87
otbVectorDataIOBase.h
otb::VectorDataFileReaderException
Base exception class for IO conflicts.
Definition: otbVectorDataFileReader.h:36
otb::VectorDataFileReaderException::VectorDataFileReaderException
VectorDataFileReaderException(const std::string &file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
Definition: otbVectorDataFileReader.h:49
otb::VectorDataIOBase::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbVectorDataIOBase.h:66
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otbVectorDataFileReader.hxx
otb::VectorDataFileReader::m_VectorDataIO
VectorDataIOBaseType::Pointer m_VectorDataIO
Definition: otbVectorDataFileReader.h:136
otb::VectorDataFileReader::m_FileName
std::string m_FileName
Definition: otbVectorDataFileReader.h:141
otb::VectorDataFileReader::Self
VectorDataFileReader Self
Definition: otbVectorDataFileReader.h:91
otb::VectorDataFileReader::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbVectorDataFileReader.h:93
otb::VectorDataFileReader::SpacingType
itk::Vector< double, VDimension > SpacingType
Definition: otbVectorDataFileReader.h:106
otbVectorDataSource.h
otb::VectorDataFileReader::m_UserSpecifiedVectorDataIO
bool m_UserSpecifiedVectorDataIO
Definition: otbVectorDataFileReader.h:137
otb::VectorDataFileReader::m_ExceptionMessage
std::string m_ExceptionMessage
Definition: otbVectorDataFileReader.h:134
otb::VectorDataFileReader::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbVectorDataFileReader.h:94
itk
Definition: otbNoDataHelper.h:31
otb::VectorDataFileReaderException::VectorDataFileReaderException
VectorDataFileReaderException(const std::string &file, unsigned int line, const std::string &message="Error in IO", const char *loc="Unknown")
Definition: otbVectorDataFileReader.h:54
otb::VectorDataSource
Filter hierarchy for generating VectorData.
Definition: otbVectorDataSource.h:42
otb::VectorDataFileReader::PointType
itk::Point< double, VDimension > PointType
Definition: otbVectorDataFileReader.h:107
otb::VectorDataFileReader::Superclass
VectorDataSource< TOutputVectorData > Superclass
Definition: otbVectorDataFileReader.h:92
otb::VectorDataFileReader::OutputVectorType
TOutputVectorData OutputVectorType
Definition: otbVectorDataFileReader.h:100
otb::VectorDataIOBase
Abstract superclass defines VectorData IO interface.
Definition: otbVectorDataIOBase.h:60
otb::VectorDataFileReader::VectorDataIOBaseType
VectorDataIOBase VectorDataIOBaseType
Definition: otbVectorDataFileReader.h:103