]> OCCT Git - occt-copy.git/commitdiff
Fixes for binary storage of shape section.
authorstv <stv@opencascade.com>
Wed, 27 May 2015 08:09:25 +0000 (11:09 +0300)
committerstv <stv@opencascade.com>
Wed, 27 May 2015 09:06:27 +0000 (12:06 +0300)
Conflicts:
src/BinDrivers/BinDrivers_DocumentStorageDriver.cxx

src/BinDrivers/BinDrivers_DocumentRetrievalDriver.cxx
src/BinDrivers/BinDrivers_DocumentStorageDriver.cxx
src/BinMNaming/BinMNaming_NamedShapeDriver.cdl
src/BinMNaming/BinMNaming_NamedShapeDriver.cxx

index feae712eb5fad88c080fb88742a544413d3bd39f..144f060ef5a47616141f26af8e5ed2129d677636 100644 (file)
@@ -73,7 +73,7 @@ void BinDrivers_DocumentRetrievalDriver::ReadShapeSection( BinLDrivers_DocumentS
           aNamedShapeDriver->ReadShapeSection( aStrStream );
       }
       else
-        WriteMessage( "BinDrivers_DocumentRetrievalDriver: can't read all section data." );
+        WriteMessage( "BinDrivers_DocumentRetrievalDriver: can't read all shape section data." );
     }
     catch(Standard_Failure) {
       if ( aBuf )
index 8c6f7cc2f652a3c709f8707f8123b8c41f4f99bd..1ddfe991729c9830530d52c097c60fe3fb862f65 100644 (file)
 
 #include <BinDrivers_DocumentStorageDriver.ixx>
 #include <Standard_ErrorHandler.hxx>
+#include <Standard_SStream.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <BinDrivers.hxx>
 #include <BinMDF_ADriver.hxx>
 #include <BinMNaming_NamedShapeDriver.hxx>
 #include <TNaming_NamedShape.hxx>
+
+#include <string>
+
 //=======================================================================
 //function : BinDrivers_DocumentStorageDriver
 //purpose  : Constructor
@@ -60,13 +64,18 @@ void BinDrivers_DocumentStorageDriver::WriteShapeSection
     try { 
       OCC_CATCH_SIGNALS
 
-      aNamedShapeDriver->WriteShapeSection (theDevice);
+      Standard_SStream aStrStream( Standard_SStream::out | Standard_SStream::binary );
+      aNamedShapeDriver->WriteShapeSection( aStrStream );
+
+      std::string aData = aStrStream.str();
+      Standard_Size aSize = theDevice->Write( (Standard_Address)aData.c_str(), aData.length() );
+      if ( aSize < aData.length() )
+        WriteMessage( "BinDrivers_DocumentRetrievalDriver: can't write all shape section data." );
     }
     catch(Standard_Failure) {
       TCollection_ExtendedString anErrorStr ("Error: ");
       Handle(Standard_Failure) aFailure = Standard_Failure::Caught();
-      TCollection_ExtendedString aStr = 
-       anErrorStr + aMethStr + "Shape Section :";
+      TCollection_ExtendedString aStr = anErrorStr + "BinDrivers_DocumentStorageDriver, Shape Section :";
       WriteMessage (aStr  + aFailure->GetMessageString());
     }
   }
index f19c7e57f2296de7f850714c149a9b7b172b6374..32a2e7d728b2be5fe9edffc843b6ac405ba3f48d 100644 (file)
@@ -45,15 +45,9 @@ is
     ReadShapeSection (me: mutable; theIS: in out IStream from Standard);
       ---Purpose: Input the shapes from Bin Document file
       
-    ReadShapeSection (me: mutable; theDevice : IODevice from Storage);
-      ---Purpose: Input the shapes from Bin Document file
-
     WriteShapeSection (me: mutable; theOS: in out OStream from Standard);
       ---Purpose: Output the shapes into Bin Document file
       
-    WriteShapeSection (me: mutable; theDevice : IODevice from Storage);
-      ---Purpose: Output the shapes into Bin Document file
-
     Clear (me:mutable);
       ---Purpose: Clear myShapeSet 
        
index 037abf571b0602a10e34cdf9791f1ab3c34dc7f8..fd9200ba0de59f8711b09a26244baa45ff112f93 100644 (file)
@@ -276,25 +276,6 @@ void BinMNaming_NamedShapeDriver::WriteShapeSection (Standard_OStream& theOS)
   myShapeSet.Clear();
 }
 
-//=======================================================================
-//function : WriteShapeSection
-//purpose  : 
-//=======================================================================
-
-void BinMNaming_NamedShapeDriver::WriteShapeSection (const Handle(Storage_IODevice)& theDevice)
-{
-  if (!theDevice->CanWrite())
-  {
-    return;
-  }
-
-  Handle(Storage_OStream) aStream = Handle(Storage_OStream)::DownCast(theDevice);
-  if (!aStream.IsNull())
-  {
-    WriteShapeSection (*aStream->Stream());
-  }
-}
-
 //=======================================================================
 //function : Clear
 //purpose  : 
@@ -325,22 +306,3 @@ void BinMNaming_NamedShapeDriver::ReadShapeSection (Standard_IStream& theIS)
   else
     theIS.seekg(aPos); // no shape section is present, try to return to initial point
 }
-
-//=======================================================================
-//function : ReadShapeSection
-//purpose  : 
-//=======================================================================
-
-void BinMNaming_NamedShapeDriver::ReadShapeSection (const Handle(Storage_IODevice)& theDevice)
-{
-  if (!theDevice->CanRead())
-  {
-    return;
-  }
-
-  Handle(Storage_IStream) aStream = Handle(Storage_IStream)::DownCast(theDevice);
-  if (!aStream.IsNull())
-  {
-    ReadShapeSection (*aStream->Stream());
-  }
-}