From 5e13b5d8ee8da3e370cf76423af7699b99d25cf0 Mon Sep 17 00:00:00 2001 From: stv Date: Wed, 27 May 2015 11:09:25 +0300 Subject: [PATCH] Fixes for binary storage of shape section. Conflicts: src/BinDrivers/BinDrivers_DocumentStorageDriver.cxx --- .../BinDrivers_DocumentRetrievalDriver.cxx | 2 +- .../BinDrivers_DocumentStorageDriver.cxx | 15 ++++++-- .../BinMNaming_NamedShapeDriver.cdl | 6 --- .../BinMNaming_NamedShapeDriver.cxx | 38 ------------------- 4 files changed, 13 insertions(+), 48 deletions(-) diff --git a/src/BinDrivers/BinDrivers_DocumentRetrievalDriver.cxx b/src/BinDrivers/BinDrivers_DocumentRetrievalDriver.cxx index feae712eb5..144f060ef5 100644 --- a/src/BinDrivers/BinDrivers_DocumentRetrievalDriver.cxx +++ b/src/BinDrivers/BinDrivers_DocumentRetrievalDriver.cxx @@ -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 ) diff --git a/src/BinDrivers/BinDrivers_DocumentStorageDriver.cxx b/src/BinDrivers/BinDrivers_DocumentStorageDriver.cxx index 8c6f7cc2f6..1ddfe99172 100644 --- a/src/BinDrivers/BinDrivers_DocumentStorageDriver.cxx +++ b/src/BinDrivers/BinDrivers_DocumentStorageDriver.cxx @@ -15,11 +15,15 @@ #include #include +#include #include #include #include #include #include + +#include + //======================================================================= //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()); } } diff --git a/src/BinMNaming/BinMNaming_NamedShapeDriver.cdl b/src/BinMNaming/BinMNaming_NamedShapeDriver.cdl index f19c7e57f2..32a2e7d728 100644 --- a/src/BinMNaming/BinMNaming_NamedShapeDriver.cdl +++ b/src/BinMNaming/BinMNaming_NamedShapeDriver.cdl @@ -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 diff --git a/src/BinMNaming/BinMNaming_NamedShapeDriver.cxx b/src/BinMNaming/BinMNaming_NamedShapeDriver.cxx index 037abf571b..fd9200ba0d 100644 --- a/src/BinMNaming/BinMNaming_NamedShapeDriver.cxx +++ b/src/BinMNaming/BinMNaming_NamedShapeDriver.cxx @@ -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()); - } -} -- 2.39.5