From bd27a662989b6bc5dedc56fcc2b764f73e2c47bc Mon Sep 17 00:00:00 2001
From: mattijs <mattijs@hunt.opencfd.co.uk>
Date: Wed, 27 Aug 2008 18:01:31 +0100
Subject: [PATCH] binary output

---
 src/meshTools/octree/PointIndexHit.H | 44 ++++++++++++++++++++++++++--
 src/meshTools/octree/pointIndexHit.H |  9 +++++-
 2 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/src/meshTools/octree/PointIndexHit.H b/src/meshTools/octree/PointIndexHit.H
index 9b72d996053..f29965748c8 100644
--- a/src/meshTools/octree/PointIndexHit.H
+++ b/src/meshTools/octree/PointIndexHit.H
@@ -94,6 +94,12 @@ public:
             index_(-1)
         {}
 
+        //- Construct from Istream
+        PointIndexHit(Istream& is)
+        {
+            is >> *this;
+        }
+
 
     // Member Functions
 
@@ -193,13 +199,45 @@ public:
 
         friend Ostream& operator<< (Ostream& os, const PointIndexHit& pHit)
         {
-            return os << pHit.hit_ << token::SPACE << pHit.hitPoint_
-                << token::SPACE << pHit.index_;
+            if (os.format() == IOstream::ASCII)
+            {
+                os  << pHit.hit_ << token::SPACE << pHit.hitPoint_
+                    << token::SPACE << pHit.index_;
+            }
+            else
+            {
+                os.write
+                (
+                    reinterpret_cast<const char*>(&pHit),
+                    sizeof(PointIndexHit)
+                );
+            }
+
+            // Check state of Ostream
+            os.check("Ostream& operator<<(Ostream&, const PointIndexHit&)");
+
+            return os;
         }
 
         friend Istream& operator>>(Istream& is, PointIndexHit& pHit)
         {
-            return is >> pHit.hit_ >> pHit.hitPoint_ >> pHit.index_;
+            if (is.format() == IOstream::ASCII)
+            {
+                return is >> pHit.hit_ >> pHit.hitPoint_ >> pHit.index_;
+            }
+            else
+            {
+                is.read
+                (
+                    reinterpret_cast<char*>(&pHit),
+                    sizeof(PointIndexHit)
+                );
+            }
+
+            // Check state of Istream
+            is.check("Istream& operator>>(Istream&, PointIndexHit&)");
+
+            return is;
         }
 
 };
diff --git a/src/meshTools/octree/pointIndexHit.H b/src/meshTools/octree/pointIndexHit.H
index e41fd28499c..b43f12d5515 100644
--- a/src/meshTools/octree/pointIndexHit.H
+++ b/src/meshTools/octree/pointIndexHit.H
@@ -39,7 +39,14 @@ Description
 
 namespace Foam
 {
-    typedef PointIndexHit<point> pointIndexHit;
+
+typedef PointIndexHit<point> pointIndexHit;
+
+
+//- Specify data associated with pointIndexHit type is contiguous
+template<>
+inline bool contiguous<pointIndexHit>() {return true;}
+
 }
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-- 
GitLab