Skip to content

Commit

Permalink
MetaIO 2024-02-15 (8bd99f13)
Browse files Browse the repository at this point in the history
Code extracted from:

    https://github.com/Kitware/MetaIO.git

at commit 8bd99f13cbb40666639154be9ad712b507ad995e (master).
  • Loading branch information
MetaIO Maintainers authored and dzenanz committed Feb 15, 2024
1 parent c42090c commit 7c8f3bb
Show file tree
Hide file tree
Showing 36 changed files with 952 additions and 806 deletions.
38 changes: 19 additions & 19 deletions src/metaArray.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -120,25 +120,25 @@ MetaArray::PrintInfo() const
{
MetaForm::PrintInfo();

std::cout << "Length = " << m_Length << std::endl;
std::cout << "Length = " << m_Length << '\n';

std::cout << "BinaryData = " << ((m_BinaryData) ? "True" : "False") << std::endl;
std::cout << "BinaryData = " << ((m_BinaryData) ? "True" : "False") << '\n';

std::cout << "BinaryDataByteOrderMSB = " << ((m_BinaryDataByteOrderMSB) ? "True" : "False") << std::endl;
std::cout << "BinaryDataByteOrderMSB = " << ((m_BinaryDataByteOrderMSB) ? "True" : "False") << '\n';

char str[255];
MET_TypeToString(m_ElementType, str);
std::cout << "ElementType = " << str << std::endl;
std::cout << "ElementType = " << str << '\n';

std::cout << "ElementNumberOfChannels = " << m_ElementNumberOfChannels << std::endl;
std::cout << "ElementNumberOfChannels = " << m_ElementNumberOfChannels << '\n';

std::cout << "AutoFreeElementData = " << ((m_AutoFreeElementData) ? "True" : "False") << std::endl;
std::cout << "AutoFreeElementData = " << ((m_AutoFreeElementData) ? "True" : "False") << '\n';

std::cout << "CompressedElementDataSize = " << m_CompressedElementDataSize << std::endl;
std::cout << "CompressedElementDataSize = " << m_CompressedElementDataSize << '\n';

std::cout << "ElementDataFileName = " << m_ElementDataFileName << std::endl;
std::cout << "ElementDataFileName = " << m_ElementDataFileName << '\n';

std::cout << "ElementData = " << ((m_ElementData == nullptr) ? "NULL" : "Valid") << std::endl;
std::cout << "ElementData = " << ((m_ElementData == nullptr) ? "NULL" : "Valid") << '\n';
}

void
Expand Down Expand Up @@ -591,7 +591,7 @@ MetaArray::Read(const char * _headerName, bool _readElements, void * _elementDat

if (!tmpStream->rdbuf()->is_open())
{
std::cout << "MetaArray: Read: Cannot open file _" << m_FileName << "_" << std::endl;
std::cout << "MetaArray: Read: Cannot open file _" << m_FileName << "_" << '\n';
delete tmpStream;
return false;
}
Expand Down Expand Up @@ -634,15 +634,15 @@ MetaArray::ReadStream(std::ifstream * _stream, bool _readElements, void * _eleme

if (m_ReadStream)
{
std::cout << "MetaArray: ReadStream: two files open?" << std::endl;
std::cout << "MetaArray: ReadStream: two files open?" << '\n';
delete m_ReadStream;
}

m_ReadStream = _stream;

if (!M_Read())
{
std::cout << "MetaArray: Read: Cannot parse file" << std::endl;
std::cout << "MetaArray: Read: Cannot parse file" << '\n';
m_ReadStream = nullptr;
return false;
}
Expand Down Expand Up @@ -680,7 +680,7 @@ MetaArray::ReadStream(std::ifstream * _stream, bool _readElements, void * _eleme
#endif
if (!readStreamTemp->rdbuf()->is_open())
{
std::cout << "MetaArray: Read: Cannot open data file" << std::endl;
std::cout << "MetaArray: Read: Cannot open data file" << '\n';
m_ReadStream = nullptr;
return false;
}
Expand Down Expand Up @@ -799,7 +799,7 @@ MetaArray::WriteStream(std::ofstream * _stream, bool _writeElements, const void
{
if (m_WriteStream != nullptr)
{
std::cout << "MetaArray: WriteStream: two files open?" << std::endl;
std::cout << "MetaArray: WriteStream: two files open?" << '\n';
delete m_WriteStream;
}

Expand Down Expand Up @@ -941,7 +941,7 @@ MetaArray::M_Read()
META_DEBUG_PRINT( "MetaArray: M_Read: Loading Header" );
if (!MetaForm::M_Read())
{
std::cout << "MetaArray: M_Read: Error parsing file" << std::endl;
std::cout << "MetaArray: M_Read: Error parsing file" << '\n';
return false;
}

Expand All @@ -962,7 +962,7 @@ MetaArray::M_Read()
}
else
{
std::cout << "MetaArray: M_Read: Error: Length required" << std::endl;
std::cout << "MetaArray: M_Read: Error: Length required" << '\n';
return false;
}
}
Expand Down Expand Up @@ -1033,8 +1033,8 @@ MetaArray::M_ReadElements(std::ifstream * _fstream, void * _data, int _dataQuant
int gc = static_cast<int>(_fstream->gcount());
if (gc != readSize)
{
std::cout << "MetaArray: M_ReadElements: data not read completely" << std::endl;
std::cout << " ideal = " << readSize << " : actual = " << gc << std::endl;
std::cout << "MetaArray: M_ReadElements: data not read completely" << '\n';
std::cout << " ideal = " << readSize << " : actual = " << gc << '\n';
return false;
}
}
Expand Down Expand Up @@ -1091,7 +1091,7 @@ MetaArray::M_WriteElements(std::ofstream * _fstream, const void * _data, std::st
MET_ValueToDouble(m_ElementType, _data, i, &tf);
if ((i + 1) / 10 == (i + 1.0) / 10.0)
{
(*tmpWriteStream) << tf << std::endl;
(*tmpWriteStream) << tf << '\n';
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions src/metaArrow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ void
MetaArrow::PrintInfo() const
{
MetaObject::PrintInfo();
std::cout << "Length = " << M_Length << std::endl;
std::cout << "Length = " << M_Length << '\n';
std::cout << "Direction = ";
for (int i = 0; i < m_NDims; i++)
{
std::cout << M_Direction[i] << " ";
}
std::cout << std::endl;
std::cout << '\n';
}

void
Expand Down Expand Up @@ -192,7 +192,7 @@ MetaArrow::M_Read()

if (!MetaObject::M_Read())
{
std::cout << "MetaArrow: M_Read: Error parsing file" << std::endl;
std::cout << "MetaArrow: M_Read: Error parsing file" << '\n';
return false;
}

Expand Down
31 changes: 16 additions & 15 deletions src/metaBlob.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ BlobPnt::BlobPnt(int dim)
}

// Color is red by default
m_Color[0] = 1.0f;
m_Color[1] = 0.0f;
m_Color[2] = 0.0f;
m_Color[3] = 1.0f;
m_Color[0] = 1.0F;
m_Color[1] = 0.0F;
m_Color[2] = 0.0F;
m_Color[3] = 1.0F;
}

BlobPnt::~BlobPnt()
Expand Down Expand Up @@ -92,11 +92,11 @@ void
MetaBlob::PrintInfo() const
{
MetaObject::PrintInfo();
std::cout << "PointDim = " << m_PointDim << std::endl;
std::cout << "NPoints = " << m_NPoints << std::endl;
std::cout << "PointDim = " << m_PointDim << '\n';
std::cout << "NPoints = " << m_NPoints << '\n';
char str[255];
MET_TypeToString(m_ElementType, str);
std::cout << "ElementType = " << str << std::endl;
std::cout << "ElementType = " << str << '\n';
}

void
Expand Down Expand Up @@ -236,7 +236,7 @@ MetaBlob::M_Read()

if (!MetaObject::M_Read())
{
std::cout << "MetaBlob: M_Read: Error parsing file" << std::endl;
std::cout << "MetaBlob: M_Read: Error parsing file" << '\n';
return false;
}

Expand Down Expand Up @@ -312,8 +312,8 @@ MetaBlob::M_Read()
auto gc = static_cast<size_t>(m_ReadStream->gcount());
if (gc != readSize)
{
std::cout << "MetaBlob: m_Read: data not read completely" << std::endl;
std::cout << " ideal = " << readSize << " : actual = " << gc << std::endl;
std::cout << "MetaBlob: m_Read: data not read completely" << '\n';
std::cout << " ideal = " << readSize << " : actual = " << gc << '\n';
delete[] _data;
delete[] posDim;
return false;
Expand Down Expand Up @@ -407,7 +407,7 @@ MetaBlob::M_Write()

if (!MetaObject::M_Write())
{
std::cout << "MetaBlob: M_Read: Error parsing file" << std::endl;
std::cout << "MetaBlob: M_Read: Error parsing file" << '\n';
return false;
}

Expand All @@ -419,7 +419,8 @@ MetaBlob::M_Write()
int elementSize;
MET_SizeOfType(m_ElementType, &elementSize);

char * data = new char[(m_NDims + 4) * m_NPoints * elementSize];
const size_t dataSize = (m_NDims + 4) * m_NPoints * elementSize;
char * data = new char[dataSize];
int i = 0;
int d;
while (it != itEnd)
Expand All @@ -428,14 +429,14 @@ MetaBlob::M_Write()
{
float pntX = (*it)->m_X[d];
MET_SwapByteIfSystemMSB(&pntX, MET_FLOAT);
MET_DoubleToValue(static_cast<double>(pntX), m_ElementType, data, i++);
MET_DoubleToValueN(static_cast<double>(pntX), m_ElementType, data, dataSize, i++);
}

for (d = 0; d < 4; d++)
{
float c = (*it)->m_Color[d];
MET_SwapByteIfSystemMSB(&c, MET_FLOAT);
MET_DoubleToValue(static_cast<double>(c), m_ElementType, data, i++);
MET_DoubleToValueN(static_cast<double>(c), m_ElementType, data, dataSize, i++);
}
++it;
}
Expand All @@ -461,7 +462,7 @@ MetaBlob::M_Write()
*m_WriteStream << (*it)->m_Color[d] << " ";
}

*m_WriteStream << std::endl;
*m_WriteStream << '\n';
++it;
}
}
Expand Down
Loading

0 comments on commit 7c8f3bb

Please sign in to comment.