ITK  4.9.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 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;
96  typedef typename OutputMeshType::PointType OutputPointType;
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(){}
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 
163 
165  virtual void GenerateData() ITK_OVERRIDE;
166 
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  MeshFileReader(const Self &) ITK_DELETE_FUNCTION;
174  void operator=(const Self &) ITK_DELETE_FUNCTION;
175 
176  std::string m_ExceptionMessage;
177 };
178 } // namespace ITK
179 
180 #ifndef ITK_MANUAL_INSTANTIATION
181 #include "itkMeshFileReader.hxx"
182 #endif
183 
184 #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
void ReadCells(T *buffer)
TriangleCell< OutputCellType > OutputTriangleCellType
SmartPointer< const Self > ConstPointer
void TestFileExistanceAndReadability()
virtual void GenerateOutputInformation() override
IdentifierType SizeValueType
Definition: itkMeshIOBase.h:84
void ConvertCellPixelBuffer(void *inputData, T *outputData, vcl_size_t numberOfPixels)
OutputMeshType::CellPixelType OutputCellPixelType
Base class for all process objects that output mesh data.
Definition: itkMeshSource.h:49
MeshSource< TOutputMesh > Superclass
TetrahedronCell< OutputCellType > OutputTetrahedronCellType
std::string m_ExceptionMessage
QuadraticTriangleCell< OutputCellType > OutputQuadraticTriangleCellType
PolygonCell< OutputCellType > OutputPolygonCellType
void PrintSelf(std::ostream &os, Indent indent) const override
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
virtual void GenerateData() override
MeshIOBase::Pointer m_MeshIO
OutputMeshType::CoordRepType OutputCoordRepType
Represents a single vertex for a Mesh.
Definition: itkVertexCell.h:39
QuadraticEdgeCell< OutputCellType > OutputQuadraticEdgeCellType
void ConvertPointPixelBuffer(void *inputData, T *outputData, vcl_size_t numberOfPixels)
HexahedronCell< OutputCellType > OutputHexahedronCellType
static const unsigned int OutputPointDimension
void ReadPoints(T *buffer)
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.
void SetMeshIO(MeshIOBase *meshIO)
OutputMeshType::CellType OutputCellType
Mesh source that reads mesh data from a single file.