ITK  5.1.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 
78 template <typename TOutputMesh,
79  typename ConvertPointPixelTraits = MeshConvertPixelTraits<typename TOutputMesh::PixelType>,
80  class ConvertCellPixelTraits = MeshConvertPixelTraits<typename TOutputMesh::CellPixelType>>
81 class ITK_TEMPLATE_EXPORT MeshFileReader : public MeshSource<TOutputMesh>
82 {
83 public:
84  ITK_DISALLOW_COPY_AND_ASSIGN(MeshFileReader);
85 
91 
93  itkNewMacro(Self);
94 
96  itkTypeMacro(MeshFileReader, MeshSource);
97 
99  using OutputMeshType = TOutputMesh;
100  using OutputCoordRepType = typename OutputMeshType::CoordRepType;
101  using OutputPointPixelType = typename OutputMeshType::PixelType;
102  using OutputCellPixelType = typename OutputMeshType::CellPixelType;
104  using OutputPointIdentifier = typename OutputMeshType::PointIdentifier;
105  using OutputCellIdentifier = typename OutputMeshType::CellIdentifier;
106  using OutputCellAutoPointer = typename OutputMeshType::CellAutoPointer;
107  using OutputCellType = typename OutputMeshType::CellType;
109 
119 
121  static constexpr unsigned int OutputPointDimension = OutputMeshType::PointDimension;
122 
124  itkSetStringMacro(FileName);
125  itkGetStringMacro(FileName);
127 
134  void
135  SetMeshIO(MeshIOBase * meshIO);
136  itkGetModifiableObjectMacro(MeshIO, MeshIOBase);
138 
141  void
142  GenerateOutputInformation() override;
143 
144  template <typename T>
145  void
146  ReadPoints(T * buffer);
147 
148  template <typename T>
149  void
150  ReadCells(T * buffer);
151 
152  void
153  ReadPointData();
154 
155  void
156  ReadCellData();
157 
158 protected:
159  MeshFileReader();
160  ~MeshFileReader() override = default;
161  void
162  PrintSelf(std::ostream & os, Indent indent) const override;
163 
165  template <typename T>
166  void
167  ConvertPointPixelBuffer(void * inputData, T * outputData, size_t numberOfPixels);
168 
169  template <typename T>
170  void
171  ConvertCellPixelBuffer(void * inputData, T * outputData, size_t numberOfPixels);
172 
178  void
179  TestFileExistanceAndReadability();
180 
182  void
183  GenerateData() override;
184 
186  bool m_UserSpecifiedMeshIO; // keep track whether the MeshIO is
187  // user specified
188  std::string m_FileName; // The file to be read
189 
190 private:
191  std::string m_ExceptionMessage;
192 };
193 } // end namespace itk
194 
195 #ifndef ITK_MANUAL_INSTANTIATION
196 # include "itkMeshFileReader.hxx"
197 #endif
198 
199 #ifdef ITK_IO_FACTORY_REGISTER_MANAGER
200 # include "itkMeshIOFactoryRegisterManager.h"
201 #endif
202 
203 #endif
itk::MeshFileReader::m_MeshIO
MeshIOBase::Pointer m_MeshIO
Definition: itkMeshFileReader.h:185
itk::MeshFileReader::OutputCellIdentifier
typename OutputMeshType::CellIdentifier OutputCellIdentifier
Definition: itkMeshFileReader.h:105
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:100
itk::MeshFileReader::SizeValueType
typename MeshIOBase::SizeValueType SizeValueType
Definition: itkMeshFileReader.h:108
itk::MeshFileReader
Mesh source that reads mesh data from a single file.
Definition: itkMeshFileReader.h:81
itk::MeshFileReader::m_FileName
std::string m_FileName
Definition: itkMeshFileReader.h:188
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:104
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:44
itk::TriangleCell
Definition: itkTriangleCell.h:45
itk::MeshFileReader::m_ExceptionMessage
std::string m_ExceptionMessage
Definition: itkMeshFileReader.h:191
itkMeshFileReaderException.h
itk::MeshFileReader::OutputPointPixelType
typename OutputMeshType::PixelType OutputPointPixelType
Definition: itkMeshFileReader.h:101
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:103
itk::MeshFileReader::OutputCellPixelType
typename OutputMeshType::CellPixelType OutputCellPixelType
Definition: itkMeshFileReader.h:102
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itkPolygonCell.h
itkQuadraticEdgeCell.h
itk::MeshSource::OutputMeshType
TOutputMesh OutputMeshType
Definition: itkMeshSource.h:68
itk::MeshFileReader::OutputCellType
typename OutputMeshType::CellType OutputCellType
Definition: itkMeshFileReader.h:107
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:106
itkTetrahedronCell.h
itk::MeshFileReader::m_UserSpecifiedMeshIO
bool m_UserSpecifiedMeshIO
Definition: itkMeshFileReader.h:186