ITK  4.13.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 #include "ITKIOMeshExport.h"
21 
23 #include "itkMacro.h"
24 #include "itkHexahedronCell.h"
25 #include "itkLineCell.h"
26 #include "itkMeshIOBase.h"
27 #include "itkMeshSource.h"
28 #include "itkPolygonCell.h"
29 #include "itkQuadrilateralCell.h"
30 #include "itkQuadraticEdgeCell.h"
32 #include "itkTetrahedronCell.h"
33 #include "itkTriangleCell.h"
34 #include "itkVertexCell.h"
35 
38 
39 namespace itk
40 {
41 
73 template< typename TOutputMesh,
74  typename ConvertPointPixelTraits = MeshConvertPixelTraits< typename TOutputMesh::PixelType >,
75  class ConvertCellPixelTraits = MeshConvertPixelTraits< typename TOutputMesh::CellPixelType > >
76 class ITK_TEMPLATE_EXPORT MeshFileReader:public MeshSource< TOutputMesh >
77 {
78 public:
84 
86  itkNewMacro(Self);
87 
89  itkTypeMacro(MeshFileReader, MeshSource);
90 
92  typedef TOutputMesh OutputMeshType;
93  typedef typename OutputMeshType::CoordRepType OutputCoordRepType;
94  typedef typename OutputMeshType::PixelType OutputPointPixelType;
95  typedef typename OutputMeshType::CellPixelType OutputCellPixelType;
97  typedef typename OutputMeshType::PointIdentifier OutputPointIdentifier;
98  typedef typename OutputMeshType::CellIdentifier OutputCellIdentifier;
99  typedef typename OutputMeshType::CellAutoPointer OutputCellAutoPointer;
100  typedef typename OutputMeshType::CellType OutputCellType;
102 
112 
114  itkStaticConstMacro(OutputPointDimension, unsigned int, OutputMeshType::PointDimension);
115 
117  itkSetStringMacro(FileName);
118  itkGetStringMacro(FileName);
120 
127  void SetMeshIO(MeshIOBase *meshIO);
128  itkGetModifiableObjectMacro(MeshIO, MeshIOBase);
130 
133  virtual void GenerateOutputInformation() ITK_OVERRIDE;
134 
135  template< typename T >
136  void ReadPoints(T *buffer);
137 
138  template< typename T >
139  void ReadCells(T *buffer);
140 
141  void ReadPointData();
142 
143  void ReadCellData();
144 
145 protected:
146  MeshFileReader();
147  ~MeshFileReader() ITK_OVERRIDE {}
148  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
149 
151  template< typename T >
152  void ConvertPointPixelBuffer(void *inputData, T *outputData, size_t numberOfPixels);
153 
154  template< typename T >
155  void ConvertCellPixelBuffer(void *inputData, T *outputData, size_t numberOfPixels);
156 
162  void TestFileExistanceAndReadability();
163 
165  virtual void GenerateData() ITK_OVERRIDE;
166 
167  MeshIOBase::Pointer m_MeshIO;
168  bool m_UserSpecifiedMeshIO; // keep track whether the MeshIO is
169  // user specified
170  std::string m_FileName; // The file to be read
171 
172 private:
173  ITK_DISALLOW_COPY_AND_ASSIGN(MeshFileReader);
174 
175  std::string m_ExceptionMessage;
176 };
177 } // namespace ITK
178 
179 #ifndef ITK_MANUAL_INSTANTIATION
180 #include "itkMeshFileReader.hxx"
181 #endif
182 
183 #endif
MeshIOBase::SizeValueType SizeValueType
Represents a line segment for a Mesh.
Definition: itkLineCell.h:42
Light weight base class for most itk classes.
TOutputMesh OutputMeshType
OutputMeshType::CellIdentifier OutputCellIdentifier
TriangleCell< OutputCellType > OutputTriangleCellType
SmartPointer< const Self > ConstPointer
IdentifierType SizeValueType
Definition: itkMeshIOBase.h:84
OutputMeshType::CellPixelType OutputCellPixelType
Base class for all process objects that output mesh data.
Definition: itkMeshSource.h:49
MeshSource< TOutputMesh > Superclass
TetrahedronCell< OutputCellType > OutputTetrahedronCellType
QuadraticTriangleCell< OutputCellType > OutputQuadraticTriangleCellType
PolygonCell< OutputCellType > OutputPolygonCellType
Represents a second order triangular patch for a Mesh.
Represents a hexahedron for a Mesh.
OutputMeshType::CellAutoPointer OutputCellAutoPointer
Represents a second order line segment for a Mesh.
OutputMeshType::PointIdentifier OutputPointIdentifier
SmartPointer< Self > Pointer
OutputMeshType::PointType OutputPointType
QuadrilateralCell< OutputCellType > OutputQuadrilateralCellType
LineCell< OutputCellType > OutputLineCellType
VertexCell< OutputCellType > OutputVertexCellType
Represents a polygon in a Mesh.
TetrahedronCell represents a tetrahedron for a Mesh.
OutputMeshType::PixelType OutputPointPixelType
OutputMeshType::CoordRepType OutputCoordRepType
Represents a single vertex for a Mesh.
Definition: itkVertexCell.h:39
QuadraticEdgeCell< OutputCellType > OutputQuadraticEdgeCellType
HexahedronCell< OutputCellType > OutputHexahedronCellType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Abstract superclass defines mesh IO interface.
Definition: itkMeshIOBase.h:69
Represents a quadrilateral for a Mesh.
OutputMeshType::CellType OutputCellType
Mesh source that reads mesh data from a single file.