ITK  4.12.0
Insight Segmentation and Registration Toolkit
itkMeshFileWriter.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 itkMeshFileWriter_h
19 #define itkMeshFileWriter_h
20 #include "ITKIOMeshExport.h"
21 
23 #include "itkProcessObject.h"
24 #include "itkMeshIOBase.h"
25 
26 namespace itk
27 {
28 
51 template< typename TInputMesh >
52 class ITKIOMesh_HIDDEN MeshFileWriter:public ProcessObject
53 {
54 public:
60 
62  itkNewMacro(Self);
63 
65  itkTypeMacro(MeshFileWriter, ProcessObject);
66 
68  typedef TInputMesh InputMeshType;
70  typedef typename InputMeshType::RegionType InputMeshRegionType;
71  typedef typename InputMeshType::PixelType InputMeshPixelType;
72  typedef typename InputMeshType::CellType InputMeshCellType;
74 
76  using Superclass::SetInput;
77  void SetInput(const InputMeshType *input);
78 
79  const InputMeshType * GetInput();
80 
81  const InputMeshType * GetInput(unsigned int idx);
82 
84  itkSetStringMacro(FileName);
85  itkGetStringMacro(FileName);
87 
98  {
99  if ( this->m_MeshIO != io )
100  {
101  this->Modified();
102  this->m_MeshIO = io;
103  }
104  m_FactorySpecifiedMeshIO = false;
105  m_UserSpecifiedMeshIO = true;
106  }
107  itkGetModifiableObjectMacro(MeshIO, MeshIOBase);
109 
110  void SetFileTypeAsASCII(){m_FileTypeIsBINARY = false; }
111  void SetFileTypeAsBINARY(){m_FileTypeIsBINARY = true; }
112 
116  virtual void Write();
117 
120  virtual void Update() ITK_OVERRIDE
121  {
122  this->Write();
123  }
124 
126  itkSetMacro(UseCompression, bool);
127  itkGetConstReferenceMacro(UseCompression, bool);
128  itkBooleanMacro(UseCompression);
130 
131 protected:
132  MeshFileWriter();
133  ~MeshFileWriter();
134  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
135 
136  template< typename Output >
137  void CopyPointsToBuffer(Output *data);
138 
139  template< typename Output >
140  void CopyCellsToBuffer(Output *data);
141 
142  template< typename Output >
143  void CopyPointDataToBuffer(Output *data);
144 
145  template< typename Output >
146  void CopyCellDataToBuffer(Output *data);
147 
148  void WritePoints();
149 
150  void WriteCells();
151 
152  void WritePointData();
153 
154  void WriteCellData();
155 
156 private:
157  ITK_DISALLOW_COPY_AND_ASSIGN(MeshFileWriter);
158 
159  std::string m_FileName;
161  bool m_UserSpecifiedMeshIO; // track whether the MeshIO is
162  // user specified
163  bool m_FactorySpecifiedMeshIO; // track whether the factory
164  // mechanism set the MeshIO
167 };
168 } // end namespace itk
169 
170 #ifndef ITK_MANUAL_INSTANTIATION
171 #include "itkMeshFileWriter.hxx"
172 #endif
173 
174 #endif // itkMeshFileWriter_h
virtual void Update() override
virtual void PrintSelf(std::ostream &os, Indent indent) const override
Light weight base class for most itk classes.
MeshIOBase::Pointer m_MeshIO
MeshIOBase::SizeValueType SizeValueType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
IdentifierType SizeValueType
Definition: itkMeshIOBase.h:84
InputMeshType::CellType InputMeshCellType
SmartPointer< Self > Pointer
InputMeshType::PixelType InputMeshPixelType
ProcessObject Superclass
void SetMeshIO(MeshIOBase *io)
InputMeshType::Pointer InputMeshPointer
SmartPointer< const Self > ConstPointer
InputMeshType::RegionType InputMeshRegionType
SmartPointer< Self > Pointer
Writes mesh data to a single file.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Abstract superclass defines mesh IO interface.
Definition: itkMeshIOBase.h:69