binary read/write
This commit is contained in:
parent
8e53a8615c
commit
e06bf70095
@ -79,10 +79,9 @@ boundBox::boundBox(const pointField& points, const bool doReduce)
|
||||
|
||||
|
||||
boundBox::boundBox(Istream& is)
|
||||
:
|
||||
min_(is),
|
||||
max_(is)
|
||||
{}
|
||||
{
|
||||
operator>>(is, *this);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
||||
@ -113,7 +112,7 @@ Istream& operator>>(Istream& is, boundBox& bb)
|
||||
{
|
||||
if (is.format() == IOstream::ASCII)
|
||||
{
|
||||
return is >> bb.min_ >> bb.max_;
|
||||
return is >> bb.min_ >> bb.max_;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -141,6 +141,9 @@ inline label Hash<edge>::operator()(const edge& e) const
|
||||
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]);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool contiguous<triFace>() {return true;}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
@ -38,6 +38,8 @@ Description
|
||||
#ifndef contiguous_H
|
||||
#define contiguous_H
|
||||
|
||||
#include "label.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
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
|
||||
template<class T>
|
||||
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<>
|
||||
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<>
|
||||
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<>
|
||||
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<>
|
||||
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<>
|
||||
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<>
|
||||
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<>
|
||||
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<>
|
||||
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<>
|
||||
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<>
|
||||
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<>
|
||||
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<>
|
||||
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<>
|
||||
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<>
|
||||
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
|
||||
|
@ -58,16 +58,7 @@ inline labelledTri::labelledTri
|
||||
|
||||
inline labelledTri::labelledTri(Istream& is)
|
||||
{
|
||||
// Read beginning of labelledTri point pair
|
||||
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)");
|
||||
operator>>(is, *this);
|
||||
}
|
||||
|
||||
|
||||
@ -88,13 +79,20 @@ inline label& labelledTri::region()
|
||||
|
||||
inline Istream& operator>>(Istream& is, labelledTri& t)
|
||||
{
|
||||
// Read beginning of labelledTri point pair
|
||||
is.readBegin("labelledTri");
|
||||
if (is.format() == IOstream::ASCII)
|
||||
{
|
||||
// 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
|
||||
is.readEnd("labelledTri");
|
||||
// Read end of labelledTri point pair
|
||||
is.readEnd("labelledTri");
|
||||
}
|
||||
else
|
||||
{
|
||||
is.read(reinterpret_cast<char*>(&t), sizeof(labelledTri));
|
||||
}
|
||||
|
||||
// Check state of Ostream
|
||||
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)
|
||||
{
|
||||
os << token::BEGIN_LIST
|
||||
<< static_cast<const triFace&>(t) << token::SPACE << t.region_
|
||||
<< token::END_LIST;
|
||||
if (os.format() == IOstream::ASCII)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user