1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0026229: Add the possibility in OCAF to open/save a document from/to a stream object

TDocStd_Application class extended to open/save a document of XmlOcaf and BinOcaf format
from/to standard SEEKABLE stream object which should support SEEK functionality.

Open and SaveAs DRAW commands got new additional argument "-stream" to turn on using of stream functionality.

The main changes for BinOcaf format applied in:
FSD_BinaryFile class (static method using standard stream added)
BinLDrivers_DocumentRetrievalDriver and BinLDrivers_DocumentStorageDriver classes use standard stream object as an argument

The main changes for XmlOcaf format applied in:
LDOMParser and LDOM_XmlWriter classes  use standard stream object as an argument

Unused class FSD_Archive and its siblings removed from MFC samples.
This commit is contained in:
ibs
2015-11-27 13:03:25 +03:00
committed by bugmaster
parent 77dbd1f155
commit 4ff92abe44
72 changed files with 2011 additions and 2462 deletions

View File

@@ -1,110 +0,0 @@
// ColoredShape.cpp: implementation of the CColoredShape class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ColoredShape.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CColoredShape::CColoredShape()
{
m_colorName = Quantity_NOC_RED;
}
CColoredShape::CColoredShape(const Quantity_NameOfColor aColor, const TopoDS_Shape& aShape)
{
m_colorName = aColor;
m_shapeObject = aShape;
}
IMPLEMENT_SERIAL(CColoredShape, CObject,1);
// This schema contains all the Persistent Geometry and Topology
#include <ShapeSchema.hxx>
// Tools to store TopoDS_Shape
#include <MgtBRep.hxx>
#include <PTopoDS_HShape.hxx>
#include <PTColStd_TransientPersistentMap.hxx>
#include <TopoDS_Shape.hxx>
// Tools to put Persistent Object in an archive
#include <FSD_Archive.hxx>
#include <Storage_Data.hxx>
#include <Storage_HSeqOfRoot.hxx>
#include <Storage_Root.hxx>
#include <PTColStd_PersistentTransientMap.hxx>
void CColoredShape::Serialize(CArchive & ar)
{
CObject::Serialize(ar);
// an I/O driver
FSD_Archive f( &ar );
// the applicative Schema containing Persistent Topology and Geometry
// Note that it inherits from the class Storage_Schema
Handle(ShapeSchema) s = new ShapeSchema;
if ( ar.IsStoring() )
{
// Store the color in the archive
ar << m_colorName;
//Create the persistent Shape
PTColStd_TransientPersistentMap aMap;
Handle(PTopoDS_HShape) aPShape =
MgtBRep::Translate(m_shapeObject, aMap, MgtBRep_WithoutTriangle);
// Store the Persistent shape in the archive
Handle(Storage_Data) d = new Storage_Data;
d->AddRoot("ObjectName", aPShape);
s->Write( f, d);
// Check
if (d->ErrorStatus() != Storage_VSOk)
{
::MessageBox(NULL, " Error while writing... ", " Error ",MB_OK) ;
}
}
else
{
// Read the Color from the archive
Standard_Integer tmp;
ar >> tmp;
m_colorName = (Quantity_NameOfColor) tmp;
// Read the Persistent Shape from the archive
Handle(Storage_Data) d = s->Read( f );
Handle(Storage_HSeqOfRoot) roots = d->Roots();
Handle(Standard_Persistent) p;
Handle(Storage_Root) r;
Handle(PTopoDS_HShape) aPShape;
r = roots->Value(1);
p = r->Object();
aPShape = Handle(PTopoDS_HShape)::DownCast(p);
// Create the shape
PTColStd_PersistentTransientMap aMap;
MgtBRep::Translate(aPShape,aMap,m_shapeObject,MgtBRep_WithoutTriangle);
}
}
void CColoredShape::Display(Handle(AIS_InteractiveContext)& anAIScontext)
{
Handle(AIS_Shape) ais = new AIS_Shape(m_shapeObject);
anAIScontext->SetColor(ais, m_colorName);
anAIScontext->Display(ais, Standard_False);
}

View File

@@ -1,34 +0,0 @@
// ColoredShape.h: interface for the CColoredShape class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_COLOREDSHAPE_H__C6419AF3_A78A_11D1_8C93_00AA00D10994__INCLUDED_)
#define AFX_COLOREDSHAPE_H__C6419AF3_A78A_11D1_8C93_00AA00D10994__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
class CColoredShape : public CObject
{
public:
CColoredShape( const Quantity_NameOfColor aColor, const TopoDS_Shape& aShape);
void Display( Handle(AIS_InteractiveContext)& anAIScontext);
// fields
Quantity_NameOfColor m_colorName;
TopoDS_Shape m_shapeObject;
protected:
CColoredShape();
// Declare CArchive >> operator
DECLARE_SERIAL(CColoredShape);
// mute CObject::Serialize
void Serialize(CArchive& ar);
};
#endif // !defined(AFX_COLOREDSHAPE_H__C6419AF3_A78A_11D1_8C93_00AA00D10994__INCLUDED_)

View File

@@ -39,10 +39,6 @@ IMPLEMENT_SERIAL(CColoredShapes, CObject,1);
#include <TopoDS_Shape.hxx>
// Tools to put Persistent Object in an archive
#include <FSD_Archive.hxx>
#include <Storage_Data.hxx>
#include <Storage_HSeqOfRoot.hxx>
#include <Storage_Root.hxx>
void CColoredShapes::Display(Handle(AIS_InteractiveContext)& anAIScontext)
{

File diff suppressed because it is too large Load Diff

View File

@@ -1,276 +0,0 @@
// File generated by CPPExt (Value)
// Copyright (C) 1991,1995 by
//
// MATRA DATAVISION, FRANCE
//
// This software is furnished in accordance with the terms and conditions
// of the contract and with the inclusion of the above copyright notice.
// This software or any other copy thereof may not be provided or otherwise
// be made available to any other person. No title to an ownership of the
// software is hereby transferred.
//
// At the termination of the contract, the software and all copies of this
// software must be deleted.
#ifndef _FSD_Archive_HeaderFile
#define _FSD_Archive_HeaderFile
#ifndef _FSD_CArchive_HeaderFile
#include <FSD_CArchive.hxx>
#endif
#ifndef _Standard_Address_HeaderFile
#include <Standard_Address.hxx>
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif
#ifndef _Storage_BaseDriver_HeaderFile
#include <Storage_BaseDriver.hxx>
#endif
#ifndef _Storage_Error_HeaderFile
#include <Storage_Error.hxx>
#endif
#ifndef _Storage_OpenMode_HeaderFile
#include <Storage_OpenMode.hxx>
#endif
#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#endif
#ifndef _Standard_Character_HeaderFile
#include <Standard_Character.hxx>
#endif
#ifndef _Standard_ExtCharacter_HeaderFile
#include <Standard_ExtCharacter.hxx>
#endif
#ifndef _Standard_Real_HeaderFile
#include <Standard_Real.hxx>
#endif
#ifndef _Standard_ShortReal_HeaderFile
#include <Standard_ShortReal.hxx>
#endif
#ifndef _Standard_CString_HeaderFile
#include <Standard_CString.hxx>
#endif
#include <TColStd_SequenceOfAsciiString.hxx>
#include <TColStd_SequenceOfExtendedString.hxx>
class Storage_StreamTypeMismatchError;
class Storage_StreamFormatError;
class Storage_StreamWriteError;
class Storage_StreamExtCharParityError;
class TCollection_AsciiString;
class TCollection_ExtendedString;
class Storage_BaseDriver;
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
class FSD_Archive : public Storage_BaseDriver {
public:
void* operator new(size_t,void* anAddress)
{
return anAddress;
}
void* operator new(size_t size)
{
return Standard::Allocate(size);
}
void operator delete(void *anAddress)
{
if (anAddress) Standard::Free((Standard_Address&)anAddress);
}
// Methods PUBLIC
//
Standard_EXPORT virtual long Tell();
Standard_EXPORT FSD_Archive();
Standard_EXPORT FSD_Archive(const FSD_CArchive& anArchive);
Standard_EXPORT Storage_Error Open(const TCollection_AsciiString& aName,const Storage_OpenMode aMode) ;
Standard_EXPORT Standard_Boolean IsEnd() ;
Standard_EXPORT static Storage_Error IsGoodFileType(const TCollection_AsciiString& aName) ;
Standard_EXPORT Storage_Error BeginWriteInfoSection() ;
Standard_EXPORT void WriteInfo(const Standard_Integer nbObj,const TCollection_AsciiString& dbVersion,const TCollection_AsciiString& date,const TCollection_AsciiString& schemaName,const TCollection_AsciiString& schemaVersion,const TCollection_ExtendedString& appName,const TCollection_AsciiString& appVersion,const TCollection_ExtendedString& objectType,const TColStd_SequenceOfAsciiString& userInfo) ;
Standard_EXPORT Storage_Error EndWriteInfoSection() ;
Standard_EXPORT Storage_Error BeginReadInfoSection() ;
Standard_EXPORT void ReadInfo(Standard_Integer& nbObj,TCollection_AsciiString& dbVersion,TCollection_AsciiString& date,TCollection_AsciiString& schemaName,TCollection_AsciiString& schemaVersion,TCollection_ExtendedString& appName,TCollection_AsciiString& appVersion,TCollection_ExtendedString& objectType,TColStd_SequenceOfAsciiString& userInfo) ;
Standard_EXPORT Storage_Error EndReadInfoSection() ;
Standard_EXPORT Storage_Error BeginWriteCommentSection() ;
Standard_EXPORT void WriteComment(const TColStd_SequenceOfExtendedString& userComments) ;
Standard_EXPORT Storage_Error EndWriteCommentSection() ;
Standard_EXPORT Storage_Error BeginReadCommentSection() ;
Standard_EXPORT void ReadComment(TColStd_SequenceOfExtendedString& userComments) ;
Standard_EXPORT Storage_Error EndReadCommentSection() ;
Standard_EXPORT Storage_Error BeginWriteTypeSection() ;
Standard_EXPORT void SetTypeSectionSize(const Standard_Integer aSize) ;
Standard_EXPORT void WriteTypeInformations(const Standard_Integer typeNum,const TCollection_AsciiString& typeName) ;
Standard_EXPORT Storage_Error EndWriteTypeSection() ;
Standard_EXPORT Storage_Error BeginReadTypeSection() ;
Standard_EXPORT Standard_Integer TypeSectionSize() ;
Standard_EXPORT void ReadTypeInformations(Standard_Integer& typeNum,TCollection_AsciiString& typeName) ;
Standard_EXPORT Storage_Error EndReadTypeSection() ;
Standard_EXPORT Storage_Error BeginWriteRootSection() ;
Standard_EXPORT void SetRootSectionSize(const Standard_Integer aSize) ;
Standard_EXPORT void WriteRoot(const TCollection_AsciiString& rootName,const Standard_Integer aRef,const TCollection_AsciiString& aType) ;
Standard_EXPORT Storage_Error EndWriteRootSection() ;
Standard_EXPORT Storage_Error BeginReadRootSection() ;
Standard_EXPORT Standard_Integer RootSectionSize() ;
Standard_EXPORT void ReadRoot(TCollection_AsciiString& rootName,Standard_Integer& aRef,TCollection_AsciiString& aType) ;
Standard_EXPORT Storage_Error EndReadRootSection() ;
Standard_EXPORT Storage_Error BeginWriteRefSection() ;
Standard_EXPORT void SetRefSectionSize(const Standard_Integer aSize) ;
Standard_EXPORT void WriteReferenceType(const Standard_Integer reference,const Standard_Integer typeNum) ;
Standard_EXPORT Storage_Error EndWriteRefSection() ;
Standard_EXPORT Storage_Error BeginReadRefSection() ;
Standard_EXPORT Standard_Integer RefSectionSize() ;
Standard_EXPORT void ReadReferenceType(Standard_Integer& reference,Standard_Integer& typeNum) ;
Standard_EXPORT Storage_Error EndReadRefSection() ;
Standard_EXPORT Storage_Error BeginWriteDataSection() ;
Standard_EXPORT void WritePersistentObjectHeader(const Standard_Integer aRef,const Standard_Integer aType) ;
Standard_EXPORT void BeginWritePersistentObjectData() ;
Standard_EXPORT void BeginWriteObjectData() ;
Standard_EXPORT void EndWriteObjectData() ;
Standard_EXPORT void EndWritePersistentObjectData() ;
Standard_EXPORT Storage_Error EndWriteDataSection() ;
Standard_EXPORT Storage_Error BeginReadDataSection() ;
Standard_EXPORT void ReadPersistentObjectHeader(Standard_Integer& aRef,Standard_Integer& aType) ;
Standard_EXPORT void BeginReadPersistentObjectData() ;
Standard_EXPORT void BeginReadObjectData() ;
Standard_EXPORT void EndReadObjectData() ;
Standard_EXPORT void EndReadPersistentObjectData() ;
Standard_EXPORT Storage_Error EndReadDataSection() ;
Standard_EXPORT void SkipObject() ;
Standard_EXPORT Storage_BaseDriver& PutReference(const Standard_Integer aValue) ;
Standard_EXPORT Storage_BaseDriver& PutCharacter(const Standard_Character aValue) ;
Storage_BaseDriver& operator <<(const Standard_Character aValue)
{
return PutCharacter(aValue);
}
Standard_EXPORT Storage_BaseDriver& PutExtCharacter(const Standard_ExtCharacter aValue) ;
Storage_BaseDriver& operator <<(const Standard_ExtCharacter aValue)
{
return PutExtCharacter(aValue);
}
Standard_EXPORT Storage_BaseDriver& PutInteger(const Standard_Integer aValue) ;
Storage_BaseDriver& operator <<(const Standard_Integer aValue)
{
return PutInteger(aValue);
}
Standard_EXPORT Storage_BaseDriver& PutBoolean(const Standard_Boolean aValue) ;
Storage_BaseDriver& operator <<(const Standard_Boolean aValue)
{
return PutBoolean(aValue);
}
Standard_EXPORT Storage_BaseDriver& PutReal(const Standard_Real aValue) ;
Storage_BaseDriver& operator <<(const Standard_Real aValue)
{
return PutReal(aValue);
}
Standard_EXPORT Storage_BaseDriver& PutShortReal(const Standard_ShortReal aValue) ;
Storage_BaseDriver& operator <<(const Standard_ShortReal aValue)
{
return PutShortReal(aValue);
}
Standard_EXPORT Storage_BaseDriver& GetReference(Standard_Integer& aValue) ;
Standard_EXPORT Storage_BaseDriver& GetCharacter(Standard_Character& aValue) ;
Storage_BaseDriver& operator >>(Standard_Character& aValue)
{
return GetCharacter(aValue);
}
Standard_EXPORT Storage_BaseDriver& GetExtCharacter(Standard_ExtCharacter& aValue) ;
Storage_BaseDriver& operator >>(Standard_ExtCharacter& aValue)
{
return GetExtCharacter(aValue);
}
Standard_EXPORT Storage_BaseDriver& GetInteger(Standard_Integer& aValue) ;
Storage_BaseDriver& operator >>(Standard_Integer& aValue)
{
return GetInteger(aValue);
}
Standard_EXPORT Storage_BaseDriver& GetBoolean(Standard_Boolean& aValue) ;
Storage_BaseDriver& operator >>(Standard_Boolean& aValue)
{
return GetBoolean(aValue);
}
Standard_EXPORT Storage_BaseDriver& GetReal(Standard_Real& aValue) ;
Storage_BaseDriver& operator >>(Standard_Real& aValue)
{
return GetReal(aValue);
}
Standard_EXPORT Storage_BaseDriver& GetShortReal(Standard_ShortReal& aValue) ;
Storage_BaseDriver& operator >>(Standard_ShortReal& aValue)
{
return GetShortReal(aValue);
}
Standard_EXPORT Storage_Error Close() ;
Standard_EXPORT void Destroy() ;
~FSD_Archive()
{
Destroy();
}
protected:
// Methods PROTECTED
//
Standard_EXPORT void ReadLine(TCollection_AsciiString& buffer) ;
Standard_EXPORT void WriteLine(const TCollection_AsciiString& buffer) ;
Standard_EXPORT void ReadExtendedLine(TCollection_ExtendedString& buffer) ;
Standard_EXPORT void WriteExtendedLine(const TCollection_ExtendedString& buffer) ;
Standard_EXPORT void ReadChar(TCollection_AsciiString& buffer,const Standard_Integer rsize) ;
Standard_EXPORT Storage_Error FindTag(const Standard_CString aTag) ;
// Fields PROTECTED
//
private:
// Methods PRIVATE
//
Standard_EXPORT static const Standard_CString MagicNumber() ;
// Fields PRIVATE
//
FSD_CArchive myStream;
Standard_Address myCFile;
Standard_Boolean myEof;
Standard_Boolean myExternFlag;
Standard_Boolean myFormat;
};
// other Inline functions and methods (like "C++: function call" methods)
//
#endif

View File

@@ -1,19 +0,0 @@
// File generated by CPPExt (Value)
// Copyright (C) 1991,1995 by
//
// MATRA DATAVISION, FRANCE
//
// This software is furnished in accordance with the terms and conditions
// of the contract and with the inclusion of the above copyright notice.
// This software or any other copy thereof may not be provided or otherwise
// be made available to any other person. No title to an ownership of the
// software is hereby transferred.
//
// At the termination of the contract, the software and all copies of this
// software must be deleted.
//
#include <FSD_Archive.jxx>

View File

@@ -1,30 +0,0 @@
#ifndef _Storage_StreamTypeMismatchError_HeaderFile
#include <Storage_StreamTypeMismatchError.hxx>
#endif
#ifndef _Storage_StreamFormatError_HeaderFile
#include <Storage_StreamFormatError.hxx>
#endif
#ifndef _Storage_StreamWriteError_HeaderFile
#include <Storage_StreamWriteError.hxx>
#endif
#ifndef _Storage_StreamExtCharParityError_HeaderFile
#include <Storage_StreamExtCharParityError.hxx>
#endif
#ifndef _TCollection_AsciiString_HeaderFile
#include <TCollection_AsciiString.hxx>
#endif
#ifndef _TCollection_ExtendedString_HeaderFile
#include <TCollection_ExtendedString.hxx>
#endif
#ifndef _TColStd_SequenceOfAsciiString_HeaderFile
#include <TColStd_SequenceOfAsciiString.hxx>
#endif
#ifndef _TColStd_SequenceOfExtendedString_HeaderFile
#include <TColStd_SequenceOfExtendedString.hxx>
#endif
#ifndef _Storage_BaseDriver_HeaderFile
#include <Storage_BaseDriver.hxx>
#endif
#ifndef _FSD_Archive_HeaderFile
#include <FSD_Archive.hxx>
#endif

View File

@@ -1,9 +0,0 @@
#ifndef _FSD_CArchive_HeaderFile
#define _FSD_CArchive_HeaderFile
//#define _MBCS
#include <afx.h>
typedef CArchive* FSD_CArchive;
#endif

View File

@@ -1,9 +0,0 @@
#ifndef _FSD_CFile_HeaderFile
#define _FSD_CFile_HeaderFile
//#define _MBCS
#include <afx.h>
typedef CFile FSD_CFile;
#endif