ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkMeshFileReader.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 
72 template< typename TOutputMesh,
73  typename ConvertPointPixelTraits = MeshConvertPixelTraits< typename TOutputMesh::PixelType >,
74  class ConvertCellPixelTraits = MeshConvertPixelTraits< typename TOutputMesh::CellPixelType > >
75 class ITK_TEMPLATE_EXPORT MeshFileReader:public MeshSource< TOutputMesh >
76 {
77 public:
78  ITK_DISALLOW_COPY_AND_ASSIGN(MeshFileReader);
79 
85 
87  itkNewMacro(Self);
88 
90  itkTypeMacro(MeshFileReader, MeshSource);
91 
93  using OutputMeshType = TOutputMesh;
94  using OutputCoordRepType = typename OutputMeshType::CoordRepType;
95  using OutputPointPixelType = typename OutputMeshType::PixelType;
96  using OutputCellPixelType = typename OutputMeshType::CellPixelType;
98  using OutputPointIdentifier = typename OutputMeshType::PointIdentifier;
99  using OutputCellIdentifier = typename OutputMeshType::CellIdentifier;
100  using OutputCellAutoPointer = typename OutputMeshType::CellAutoPointer;
101  using OutputCellType = typename OutputMeshType::CellType;
103 
113 
115  static constexpr unsigned int OutputPointDimension = OutputMeshType::PointDimension;
116 
118  itkSetStringMacro(FileName);
119  itkGetStringMacro(FileName);
121 
128  void SetMeshIO(MeshIOBase *meshIO);
129  itkGetModifiableObjectMacro(MeshIO, MeshIOBase);
131 
134  void GenerateOutputInformation() override;
135 
136  template< typename T >
137  void ReadPoints(T *buffer);
138 
139  template< typename T >
140  void ReadCells(T *buffer);
141 
142  void ReadPointData();
143 
144  void ReadCellData();
145 
146 protected:
147  MeshFileReader();
148  ~MeshFileReader() override = default;
149  void PrintSelf(std::ostream & os, Indent indent) const override;
150 
152  template< typename T >
153  void ConvertPointPixelBuffer(void *inputData, T *outputData, size_t numberOfPixels);
154 
155  template< typename T >
156  void ConvertCellPixelBuffer(void *inputData, T *outputData, size_t numberOfPixels);
157 
163  void TestFileExistanceAndReadability();
164 
166  void GenerateData() override;
167 
169  bool m_UserSpecifiedMeshIO; // keep track whether the MeshIO is
170  // user specified
171  std::string m_FileName; // The file to be read
172 
173 private:
174  std::string m_ExceptionMessage;
175 };
176 } // end namespace itk
177 
178 #ifndef ITK_MANUAL_INSTANTIATION
179 #include "itkMeshFileReader.hxx"
180 #endif
181 
182 #ifdef ITK_IO_FACTORY_REGISTER_MANAGER
183 #include "itkMeshIOFactoryRegisterManager.h"
184 #endif
185 
186 #endif
Represents a line segment for a Mesh.
Definition: itkLineCell.h:42
Light weight base class for most itk classes.
TOutputMesh OutputMeshType
Definition: itkMeshSource.h:68
IdentifierType SizeValueType
Definition: itkMeshIOBase.h:86
typename OutputMeshType::PointIdentifier OutputPointIdentifier
typename MeshIOBase::SizeValueType SizeValueType
Base class for all process objects that output mesh data.
Definition: itkMeshSource.h:49
typename OutputMeshType::CoordRepType OutputCoordRepType
std::string m_ExceptionMessage
typename OutputMeshType::PixelType OutputPointPixelType
Represents a second order triangular patch for a Mesh.
Represents a hexahedron (cuboid) for a Mesh.
typename OutputMeshType::PointType OutputPointType
Represents a second order line segment for a Mesh.
typename OutputMeshType::CellType OutputCellType
Represents a polygon in a Mesh.
TetrahedronCell represents a tetrahedron for a Mesh.
typename OutputMeshType::CellIdentifier OutputCellIdentifier
MeshIOBase::Pointer m_MeshIO
Represents a single vertex for a Mesh.
Definition: itkVertexCell.h:39
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Abstract superclass defines mesh IO interface.
Definition: itkMeshIOBase.h:69
typename OutputMeshType::CellPixelType OutputCellPixelType
Represents a quadrilateral for a Mesh.
Mesh source that reads mesh data from a single file.
typename OutputMeshType::CellAutoPointer OutputCellAutoPointer