0031137: Modeling Data, BinTools_ShapeSet - avoid allocation of temporary arrays
[occt.git] / src / BinTools / BinTools.cxx
index 19f62f2..a02f717 100644 (file)
@@ -49,17 +49,34 @@ Standard_OStream& BinTools::PutInteger(Standard_OStream& OS, const Standard_Inte
 
 //=======================================================================
 //function : PutReal
-//purpose  : 
+//purpose  :
 //=======================================================================
+Standard_OStream& BinTools::PutReal (Standard_OStream& theOS,
+                                     const Standard_Real& theValue)
+{
+#if DO_INVERSE
+  const Standard_Real aRValue = InverseReal (theValue);
+  theOS.write((char*)&aRValue, sizeof(Standard_Real));
+#else
+  theOS.write((char*)&theValue, sizeof(Standard_Real));
+#endif
+  return theOS;
+}
 
-Standard_OStream& BinTools::PutReal(Standard_OStream& OS, const Standard_Real aValue)
+//=======================================================================
+//function : PutShortReal
+//purpose  :
+//=======================================================================
+Standard_OStream& BinTools::PutShortReal (Standard_OStream& theOS,
+                                          const Standard_ShortReal& theValue)
 {
-  Standard_Real aRValue = aValue;
 #if DO_INVERSE
-      aRValue = InverseReal (aValue);
+  const Standard_ShortReal aValue = InverseShortReal (theValue);
+  theOS.write ((char*)&aValue, sizeof(Standard_ShortReal));
+#else
+  theOS.write ((char*)&theValue, sizeof(Standard_ShortReal));
 #endif
-  OS.write((char*)&aRValue, sizeof(Standard_Real));  
-  return OS;
+  return theOS;
 }
 
 //=======================================================================
@@ -76,19 +93,39 @@ Standard_OStream& BinTools::PutExtChar(Standard_OStream& OS, const Standard_ExtC
   OS.write((char*)&aSValue, sizeof(Standard_ExtCharacter));  
   return OS;
 }
+
 //=======================================================================
 //function : GetReal
-//purpose  : 
+//purpose  :
 //=======================================================================
+Standard_IStream& BinTools::GetReal (Standard_IStream& theIS,
+                                     Standard_Real& theValue)
+{
+  if (!theIS.read ((char*)&theValue, sizeof(Standard_Real)))
+  {
+    throw Storage_StreamTypeMismatchError();
+  }
+#if DO_INVERSE
+  theValue = InverseReal (theValue);
+#endif
+  return theIS;
+}
 
-Standard_IStream& BinTools::GetReal(Standard_IStream& IS, Standard_Real& aValue)
+//=======================================================================
+//function : GetShortReal
+//purpose  :
+//=======================================================================
+Standard_IStream& BinTools::GetShortReal (Standard_IStream& theIS,
+                                          Standard_ShortReal& theValue)
 {
-  if(!IS.read ((char*)&aValue, sizeof(Standard_Real)))
+  if (!theIS.read ((char*)&theValue, sizeof(Standard_ShortReal)))
+  {
     throw Storage_StreamTypeMismatchError();
+  }
 #if DO_INVERSE
-  aValue = InverseReal (aValue);
+  theValue = InverseShortReal (theValue);
 #endif
-  return IS;
+  return theIS;
 }
 
 //=======================================================================