Skip to content

Commit ab54e82

Browse files
committed
STYLE: Use MeshIOBase::OpenInputFile() in BYUMeshIO
Reduced duplicate code by simplifying `inputFile` initialization.
1 parent d1a9c2c commit ab54e82

1 file changed

Lines changed: 3 additions & 28 deletions

File tree

Modules/IO/MeshBYU/src/itkBYUMeshIO.cxx

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,7 @@ void
6565
BYUMeshIO::ReadMeshInformation()
6666
{
6767
// Define input file stream and attach it to input file
68-
std::ifstream inputFile;
69-
70-
// Due to the windows couldn't work well for tellg() and seekg() for ASCII mode, hence we
71-
// open the file with std::ios::binary
72-
inputFile.open(this->m_FileName.c_str(), std::ios::in | std::ios::binary);
73-
74-
if (!inputFile.is_open())
75-
{
76-
itkExceptionMacro("Unable to open input file " << this->m_FileName);
77-
}
68+
std::ifstream inputFile = MeshIOBase::OpenInputFile();
7869

7970
// Read the ASCII file information
8071
unsigned int numberOfParts = 0;
@@ -183,16 +174,7 @@ void
183174
BYUMeshIO::ReadPoints(void * buffer)
184175
{
185176
// Define input file stream and attach it to input file
186-
std::ifstream inputFile;
187-
188-
/** Due to the windows couldn't work well for tellg() and seekg() for ASCII mode, hence we
189-
open the file with std::ios::binary */
190-
inputFile.open(this->m_FileName.c_str(), std::ios::in | std::ios::binary);
191-
192-
if (!inputFile.is_open())
193-
{
194-
itkExceptionMacro("Unable to open input file " << this->m_FileName);
195-
}
177+
std::ifstream inputFile = MeshIOBase::OpenInputFile();
196178

197179
// Set the position to points start
198180
inputFile.seekg(m_FilePosition, std::ios::beg);
@@ -221,14 +203,7 @@ void
221203
BYUMeshIO::ReadCells(void * buffer)
222204
{
223205
// Define input file stream and attach it to input file
224-
std::ifstream inputFile;
225-
226-
inputFile.open(this->m_FileName.c_str(), std::ios::in | std::ios::binary);
227-
228-
if (!inputFile.is_open())
229-
{
230-
itkExceptionMacro("Unable to open input file " << this->m_FileName);
231-
}
206+
std::ifstream inputFile = MeshIOBase::OpenInputFile();
232207

233208
// Set the position to current position
234209
inputFile.seekg(m_FilePosition, std::ios::beg);

0 commit comments

Comments
 (0)