ITK  5.3.0
Insight Toolkit
itkMeshFileReader.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkMeshFileReader_h
19 #define itkMeshFileReader_h
20 
22 #include "itkMacro.h"
23 #include "itkHexahedronCell.h"
24 #include "itkLineCell.h"
25 #include "itkMeshIOBase.h"
26 #include "itkMeshSource.h"
27 #include "itkPolygonCell.h"
28 #include "itkQuadrilateralCell.h"
29 #include "itkQuadraticEdgeCell.h"
31 #include "itkTetrahedronCell.h"
32 #include "itkTriangleCell.h"
33 #include "itkVertexCell.h"
34 
37 
38 namespace itk
39 {
40 
77 template <typename TOutputMesh,
78  typename ConvertPointPixelTraits = MeshConvertPixelTraits<typename TOutputMesh::PixelType>,
79  class ConvertCellPixelTraits = MeshConvertPixelTraits<typename TOutputMesh::CellPixelType>>
80 class ITK_TEMPLATE_EXPORT MeshFileReader : public MeshSource<TOutputMesh>
81 {
82 public:
83  ITK_DISALLOW_COPY_AND_MOVE(MeshFileReader);
84 
90 
92  itkNewMacro(Self);
93 
95  itkTypeMacro(MeshFileReader, MeshSource);
96 
98  using OutputMeshType = TOutputMesh;
99  using OutputCoordRepType = typename OutputMeshType::CoordRepType;
100  using OutputPointPixelType = typename OutputMeshType::PixelType;
101  using OutputCellPixelType = typename OutputMeshType::CellPixelType;
103  using OutputPointIdentifier = typename OutputMeshType::PointIdentifier;
104  using OutputCellIdentifier = typename OutputMeshType::CellIdentifier;
105  using OutputCellAutoPointer = typename OutputMeshType::CellAutoPointer;
106  using OutputCellType = typename OutputMeshType::CellType;
108 
118 
120  static constexpr unsigned int OutputPointDimension = OutputMeshType::PointDimension;
121 
123  itkSetStringMacro(FileName);
124  itkGetStringMacro(FileName);
126 
133  void
134  SetMeshIO(MeshIOBase * meshIO);
135  itkGetModifiableObjectMacro(MeshIO, MeshIOBase);
137 
140  void
141  GenerateOutputInformation() override;
142 
143  template <typename T>
144  void
145  ReadPoints(T * buffer);
146 
147  template <typename T>
148  void
149  ReadCells(T * buffer);
150 
151  void
152  ReadPointData();
153 
154  void
155  ReadCellData();
156 
157 protected:
158  MeshFileReader();
159  ~MeshFileReader() override = default;
160  void
161  PrintSelf(std::ostream & os, Indent indent) const override;
162 
164  template <typename T>
165  void
166  ConvertPointPixelBuffer(void * inputData, T * outputData, size_t numberOfPixels);
167 
168  template <typename T>
169  void
170  ConvertCellPixelBuffer(void * inputData, T * outputData, size_t numberOfPixels);
171 
177  void
178  TestFileExistanceAndReadability();
179 
181  void
182  GenerateData() override;
183 
185  bool m_UserSpecifiedMeshIO; // keep track whether the MeshIO is
186  // user specified
187  std::string m_FileName; // The file to be read
188 
189 private:
190  std::string m_ExceptionMessage;
191 };
192 } // end namespace itk
193 
194 #ifndef ITK_MANUAL_INSTANTIATION
195 # include "itkMeshFileReader.hxx"
196 #endif
197 
198 #ifdef ITK_IO_FACTORY_REGISTER_MANAGER
199 # include "itkMeshIOFactoryRegisterManager.h"
200 #endif
201 
202 #endif
itk::MeshFileReader::m_MeshIO
MeshIOBase::Pointer m_MeshIO
Definition: itkMeshFileReader.h:184
itk::MeshFileReader::OutputCellIdentifier
typename OutputMeshType::CellIdentifier OutputCellIdentifier
Definition: itkMeshFileReader.h:104
itkHexahedronCell.h
itk::VertexCell
Represents a single vertex for a Mesh.
Definition: itkVertexCell.h:39
itk::QuadrilateralCell
Represents a quadrilateral for a Mesh.
Definition: itkQuadrilateralCell.h:39
itkQuadrilateralCell.h
itk::MeshIOBase::SizeValueType
IdentifierType SizeValueType
Definition: itkMeshIOBase.h:88
itk::MeshFileReader::OutputCoordRepType
typename OutputMeshType::CoordRepType OutputCoordRepType
Definition: itkMeshFileReader.h:99
itk::MeshFileReader::SizeValueType
typename MeshIOBase::SizeValueType SizeValueType
Definition: itkMeshFileReader.h:107
itk::MeshFileReader
Mesh source that reads mesh data from a single file.
Definition: itkMeshFileReader.h:80
itk::MeshFileReader::m_FileName
std::string m_FileName
Definition: itkMeshFileReader.h:187
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::MeshIOBase
Abstract superclass defines mesh IO interface.
Definition: itkMeshIOBase.h:71
itkLineCell.h
itk::PolygonCell
Represents a polygon in a Mesh.
Definition: itkPolygonCell.h:53
itk::SmartPointer< const Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::QuadraticEdgeCell
Represents a second order line segment for a Mesh.
Definition: itkQuadraticEdgeCell.h:37
itkDefaultConvertPixelTraits.h
itk::TetrahedronCell
TetrahedronCell represents a tetrahedron for a Mesh.
Definition: itkTetrahedronCell.h:37
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::MeshFileReader::OutputPointIdentifier
typename OutputMeshType::PointIdentifier OutputPointIdentifier
Definition: itkMeshFileReader.h:103
itk::MeshSource
Base class for all process objects that output mesh data.
Definition: itkMeshSource.h:49
itkMacro.h
itkMeshSource.h
itk::HexahedronCell
Represents a hexahedron (cuboid) for a Mesh.
Definition: itkHexahedronCell.h:47
itk::TriangleCell
Definition: itkTriangleCell.h:45
itk::MeshFileReader::m_ExceptionMessage
std::string m_ExceptionMessage
Definition: itkMeshFileReader.h:190
itkMeshFileReaderException.h
itk::MeshFileReader::OutputPointPixelType
typename OutputMeshType::PixelType OutputPointPixelType
Definition: itkMeshFileReader.h:100
itk::LineCell
Represents a line segment for a Mesh.
Definition: itkLineCell.h:42
itkVertexCell.h
itkMeshIOBase.h
itk::MeshFileReader::OutputPointType
typename OutputMeshType::PointType OutputPointType
Definition: itkMeshFileReader.h:102
itk::MeshFileReader::OutputCellPixelType
typename OutputMeshType::CellPixelType OutputCellPixelType
Definition: itkMeshFileReader.h:101
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itkPolygonCell.h
itkQuadraticEdgeCell.h
itk::MeshSource::OutputMeshType
TOutputMesh OutputMeshType
Definition: itkMeshSource.h:68
itk::MeshFileReader::OutputCellType
typename OutputMeshType::CellType OutputCellType
Definition: itkMeshFileReader.h:106
itkQuadraticTriangleCell.h
itk::QuadraticTriangleCell
Represents a second order triangular patch for a Mesh.
Definition: itkQuadraticTriangleCell.h:38
itkTriangleCell.h
itkMeshConvertPixelTraits.h
itk::MeshFileReader::OutputCellAutoPointer
typename OutputMeshType::CellAutoPointer OutputCellAutoPointer
Definition: itkMeshFileReader.h:105
itkTetrahedronCell.h
itk::MeshFileReader::m_UserSpecifiedMeshIO
bool m_UserSpecifiedMeshIO
Definition: itkMeshFileReader.h:185