mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
binary read/write
This commit is contained in:
@ -79,10 +79,9 @@ boundBox::boundBox(const pointField& points, const bool doReduce)
|
|||||||
|
|
||||||
|
|
||||||
boundBox::boundBox(Istream& is)
|
boundBox::boundBox(Istream& is)
|
||||||
:
|
{
|
||||||
min_(is),
|
operator>>(is, *this);
|
||||||
max_(is)
|
}
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
||||||
@ -113,7 +112,7 @@ Istream& operator>>(Istream& is, boundBox& bb)
|
|||||||
{
|
{
|
||||||
if (is.format() == IOstream::ASCII)
|
if (is.format() == IOstream::ASCII)
|
||||||
{
|
{
|
||||||
return is >> bb.min_ >> bb.max_;
|
return is >> bb.min_ >> bb.max_;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -141,6 +141,9 @@ inline label Hash<edge>::operator()(const edge& e) const
|
|||||||
return e[0]*e[1] + e[0]+e[1];
|
return e[0]*e[1] + e[0]+e[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<edge>() {return true;}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
@ -166,6 +166,9 @@ inline label Hash<triFace>::operator()(const triFace& t) const
|
|||||||
return (t[0]*t[1]*t[2] + t[0]+t[1]+t[2]);
|
return (t[0]*t[1]*t[2] + t[0]+t[1]+t[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<triFace>() {return true;}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
@ -38,6 +38,8 @@ Description
|
|||||||
#ifndef contiguous_H
|
#ifndef contiguous_H
|
||||||
#define contiguous_H
|
#define contiguous_H
|
||||||
|
|
||||||
|
#include "label.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
@ -45,54 +47,117 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Forward declaration of friend functions and operators
|
||||||
|
template<class T, label Size> class FixedList;
|
||||||
|
template<class T> class Pair;
|
||||||
|
|
||||||
|
|
||||||
// Assume the data associated with type T is not contiguous
|
// Assume the data associated with type T is not contiguous
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool contiguous() {return false;}
|
inline bool contiguous() {return false;}
|
||||||
|
|
||||||
|
|
||||||
// Specify data associated with primitive types is contiguous
|
|
||||||
|
// Specify data associated with primitive types (and simple fixed size
|
||||||
|
// containers - only size 2 defined here) is contiguous
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline bool contiguous<bool>() {return true;}
|
inline bool contiguous<bool>() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<FixedList<bool, 2> >() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<Pair<bool> >() {return true;}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline bool contiguous<char>() {return true;}
|
inline bool contiguous<char>() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<FixedList<char, 2> >() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<Pair<char> >() {return true;}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline bool contiguous<unsigned char>() {return true;}
|
inline bool contiguous<unsigned char>() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<FixedList<unsigned char, 2> >() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<Pair<unsigned char> >() {return true;}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline bool contiguous<short>() {return true;}
|
inline bool contiguous<short>() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<FixedList<short, 2> >() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<Pair<short> >() {return true;}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline bool contiguous<unsigned short>() {return true;}
|
inline bool contiguous<unsigned short>() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<FixedList<unsigned short, 2> >() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<Pair<unsigned short> >() {return true;}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline bool contiguous<int>() {return true;}
|
inline bool contiguous<int>() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<FixedList<int, 2> >() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<Pair<int> >() {return true;}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline bool contiguous<unsigned int>() {return true;}
|
inline bool contiguous<unsigned int>() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<FixedList<unsigned int, 2> >() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<Pair<unsigned int> >() {return true;}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline bool contiguous<long>() {return true;}
|
inline bool contiguous<long>() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<FixedList<long, 2> >() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<Pair<long> >() {return true;}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline bool contiguous<unsigned long>() {return true;}
|
inline bool contiguous<unsigned long>() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<FixedList<unsigned long, 2> >() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<Pair<unsigned long> >() {return true;}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline bool contiguous<long long>() {return true;}
|
inline bool contiguous<long long>() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<FixedList<long long, 2> >() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<Pair<long long> >() {return true;}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline bool contiguous<unsigned long long>() {return true;}
|
inline bool contiguous<unsigned long long>() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<FixedList<unsigned long long, 2> >() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<Pair<unsigned long long> >() {return true;}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline bool contiguous<float>() {return true;}
|
inline bool contiguous<float>() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<FixedList<float, 2> >() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<Pair<float> >() {return true;}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline bool contiguous<double>() {return true;}
|
inline bool contiguous<double>() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<FixedList<double, 2> >() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<Pair<double> >() {return true;}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline bool contiguous<long double>() {return true;}
|
inline bool contiguous<long double>() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<FixedList<long double, 2> >() {return true;}
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<Pair<long double> >() {return true;}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -105,6 +105,10 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline bool contiguous<labelledTri>() {return true;}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|||||||
@ -58,16 +58,7 @@ inline labelledTri::labelledTri
|
|||||||
|
|
||||||
inline labelledTri::labelledTri(Istream& is)
|
inline labelledTri::labelledTri(Istream& is)
|
||||||
{
|
{
|
||||||
// Read beginning of labelledTri point pair
|
operator>>(is, *this);
|
||||||
is.readBegin("labelledTri");
|
|
||||||
|
|
||||||
is >> static_cast<triFace&>(*this) >> region_;
|
|
||||||
|
|
||||||
// Read end of labelledTri point pair
|
|
||||||
is.readEnd("labelledTri");
|
|
||||||
|
|
||||||
// Check state of Istream
|
|
||||||
is.check("labelledTri::labelledTri(Istream& is)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -88,13 +79,20 @@ inline label& labelledTri::region()
|
|||||||
|
|
||||||
inline Istream& operator>>(Istream& is, labelledTri& t)
|
inline Istream& operator>>(Istream& is, labelledTri& t)
|
||||||
{
|
{
|
||||||
// Read beginning of labelledTri point pair
|
if (is.format() == IOstream::ASCII)
|
||||||
is.readBegin("labelledTri");
|
{
|
||||||
|
// Read beginning of labelledTri point pair
|
||||||
|
is.readBegin("labelledTri");
|
||||||
|
|
||||||
is >> static_cast<triFace&>(t) >> t.region_;
|
is >> static_cast<triFace&>(t) >> t.region_;
|
||||||
|
|
||||||
// Read end of labelledTri point pair
|
// Read end of labelledTri point pair
|
||||||
is.readEnd("labelledTri");
|
is.readEnd("labelledTri");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
is.read(reinterpret_cast<char*>(&t), sizeof(labelledTri));
|
||||||
|
}
|
||||||
|
|
||||||
// Check state of Ostream
|
// Check state of Ostream
|
||||||
is.check("Istream& operator>>(Istream&, labelledTri&)");
|
is.check("Istream& operator>>(Istream&, labelledTri&)");
|
||||||
@ -105,9 +103,24 @@ inline Istream& operator>>(Istream& is, labelledTri& t)
|
|||||||
|
|
||||||
inline Ostream& operator<<(Ostream& os, const labelledTri& t)
|
inline Ostream& operator<<(Ostream& os, const labelledTri& t)
|
||||||
{
|
{
|
||||||
os << token::BEGIN_LIST
|
if (os.format() == IOstream::ASCII)
|
||||||
<< static_cast<const triFace&>(t) << token::SPACE << t.region_
|
{
|
||||||
<< token::END_LIST;
|
os << token::BEGIN_LIST
|
||||||
|
<< static_cast<const triFace&>(t) << token::SPACE << t.region_
|
||||||
|
<< token::END_LIST;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
os.write
|
||||||
|
(
|
||||||
|
reinterpret_cast<const char*>(&t),
|
||||||
|
sizeof(labelledTri)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check state of Ostream
|
||||||
|
os.check("Ostream& operator<<(Ostream&, const labelledTri&)");
|
||||||
|
|
||||||
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user