ITK  5.0.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 
22 #include "itkProcessObject.h"
23 #include "itkMeshIOBase.h"
24 
25 namespace itk
26 {
27 
50 template< typename TInputMesh >
51 class ITK_TEMPLATE_EXPORT MeshFileWriter: public ProcessObject
52 {
53 public:
54  ITK_DISALLOW_COPY_AND_ASSIGN(MeshFileWriter);
55 
61 
63  itkNewMacro(Self);
64 
66  itkTypeMacro(MeshFileWriter, ProcessObject);
67 
69  using InputMeshType = TInputMesh;
70  using InputMeshPointer = typename InputMeshType::Pointer;
72  using InputMeshPixelType = typename InputMeshType::PixelType;
73  using InputMeshCellType = typename InputMeshType::CellType;
75 
77  using Superclass::SetInput;
78  void SetInput(const InputMeshType *input);
79 
80  const InputMeshType * GetInput();
81 
82  const InputMeshType * GetInput(unsigned int idx);
83 
85  itkSetStringMacro(FileName);
86  itkGetStringMacro(FileName);
88 
99  {
100  if ( this->m_MeshIO != io )
101  {
102  this->Modified();
103  this->m_MeshIO = io;
104  }
105  m_FactorySpecifiedMeshIO = false;
106  m_UserSpecifiedMeshIO = true;
107  }
108  itkGetModifiableObjectMacro(MeshIO, MeshIOBase);
110 
111  void SetFileTypeAsASCII(){m_FileTypeIsBINARY = false; }
112  void SetFileTypeAsBINARY(){m_FileTypeIsBINARY = true; }
113 
117  virtual void Write();
118 
121  void Update() override
122  {
123  this->Write();
124  }
125 
127  itkSetMacro(UseCompression, bool);
128  itkGetConstReferenceMacro(UseCompression, bool);
129  itkBooleanMacro(UseCompression);
131 
132 protected:
133  MeshFileWriter();
134  ~MeshFileWriter() override = default;
135  void PrintSelf(std::ostream & os, Indent indent) const override;
136 
137  template< typename Output >
138  void CopyPointsToBuffer(Output *data);
139 
140  template< typename Output >
141  void CopyCellsToBuffer(Output *data);
142 
143  template< typename Output >
144  void CopyPointDataToBuffer(Output *data);
145 
146  template< typename Output >
147  void CopyCellDataToBuffer(Output *data);
148 
149  void WritePoints();
150 
151  void WriteCells();
152 
153  void WritePointData();
154 
155  void WriteCellData();
156 
157 private:
158  std::string m_FileName;
160  bool m_UserSpecifiedMeshIO; // track whether the MeshIO is
161  // user specified
162  bool m_FactorySpecifiedMeshIO; // track whether the factory
163  // mechanism set the MeshIO
166 };
167 } // end namespace itk
168 
169 #ifndef ITK_MANUAL_INSTANTIATION
170 #include "itkMeshFileWriter.hxx"
171 #endif
172 
173 #ifdef ITK_IO_FACTORY_REGISTER_MANAGER
174 #include "itkMeshIOFactoryRegisterManager.h"
175 #endif
176 
177 #endif // itkMeshFileWriter_h
Light weight base class for most itk classes.
MeshIOBase::Pointer m_MeshIO
IdentifierType SizeValueType
Definition: itkMeshIOBase.h:86
typename MeshIOBase::SizeValueType SizeValueType
typename InputMeshType::CellType InputMeshCellType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
typename InputMeshType::PixelType InputMeshPixelType
class ITK_FORWARD_EXPORT ProcessObject
Definition: itkDataObject.h:40
void SetMeshIO(MeshIOBase *io)
Writes mesh data to a single file.
typename InputMeshType::RegionType InputMeshRegionType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename InputMeshType::Pointer InputMeshPointer
Abstract superclass defines mesh IO interface.
Definition: itkMeshIOBase.h:69
void Update() override