mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
188
src/RWHeaderSection/RWHeaderSection_ReadWriteModule.cxx
Executable file
188
src/RWHeaderSection/RWHeaderSection_ReadWriteModule.cxx
Executable file
@@ -0,0 +1,188 @@
|
||||
#include <RWHeaderSection_ReadWriteModule.ixx>
|
||||
#include <Interface_ReaderLib.hxx>
|
||||
#include <StepData_WriterLib.hxx>
|
||||
#include <HeaderSection_Protocol.hxx>
|
||||
#include <Interface_Macros.hxx>
|
||||
#include <Interface_ParamType.hxx>
|
||||
|
||||
|
||||
#include <HeaderSection_FileName.hxx>
|
||||
#include <HeaderSection_FileDescription.hxx>
|
||||
#include <HeaderSection_FileSchema.hxx>
|
||||
|
||||
#include <StepData_UndefinedEntity.hxx>
|
||||
|
||||
|
||||
#include <RWHeaderSection_RWFileName.hxx>
|
||||
#include <RWHeaderSection_RWFileDescription.hxx>
|
||||
#include <RWHeaderSection_RWFileSchema.hxx>
|
||||
|
||||
// -- General Declarations (Recognize, StepType) ---
|
||||
|
||||
static TCollection_AsciiString PasReco(""); // neutralise StartEntity de SW
|
||||
static TCollection_AsciiString Reco_FileName ("FILE_NAME");
|
||||
static TCollection_AsciiString Reco_FileDescription ("FILE_DESCRIPTION");
|
||||
static TCollection_AsciiString Reco_FileSchema ("FILE_SCHEMA");
|
||||
|
||||
// -- Definition of the libraries --
|
||||
|
||||
RWHeaderSection_ReadWriteModule::RWHeaderSection_ReadWriteModule ()
|
||||
{
|
||||
Handle(HeaderSection_Protocol) protocol = new HeaderSection_Protocol;
|
||||
StepData_WriterLib::SetGlobal(this,protocol);
|
||||
Interface_ReaderLib::SetGlobal(this,protocol);
|
||||
}
|
||||
|
||||
// --- Case Recognition ---
|
||||
|
||||
Standard_Integer RWHeaderSection_ReadWriteModule::CaseStep
|
||||
(const TCollection_AsciiString& key) const
|
||||
{
|
||||
if (key.IsEqual(Reco_FileName)) return 1;
|
||||
if (key.IsEqual(Reco_FileDescription)) return 2;
|
||||
if (key.IsEqual(Reco_FileSchema)) return 3;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// --- External Mapping Case Recognition ---
|
||||
|
||||
Standard_Integer RWHeaderSection_ReadWriteModule::CaseStep
|
||||
(const TColStd_SequenceOfAsciiString& types) const
|
||||
{
|
||||
|
||||
Standard_Integer NbComp = types.Length();
|
||||
#ifdef DEB
|
||||
if (NbComp < 2) {
|
||||
cout << "Plex Instance illegal " << endl;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// --- External Mapping Recognition ---
|
||||
|
||||
Standard_Boolean RWHeaderSection_ReadWriteModule::IsComplex
|
||||
(const Standard_Integer CN) const
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const TCollection_AsciiString& RWHeaderSection_ReadWriteModule::StepType
|
||||
(const Standard_Integer CN) const
|
||||
{
|
||||
switch (CN) {
|
||||
case 1 : return Reco_FileName;
|
||||
case 2 : return Reco_FileDescription;
|
||||
case 3 : return Reco_FileSchema;
|
||||
default : return PasReco;
|
||||
}
|
||||
}
|
||||
|
||||
// -- Reading of a file --
|
||||
|
||||
void RWHeaderSection_ReadWriteModule::ReadStep
|
||||
(const Standard_Integer CN,
|
||||
const Handle(StepData_StepReaderData)& data,
|
||||
const Standard_Integer num,
|
||||
Handle(Interface_Check)& ach,
|
||||
const Handle(Standard_Transient)&ent) const
|
||||
{
|
||||
if (CN == 0) return;
|
||||
switch (CN) {
|
||||
case 1 :
|
||||
{
|
||||
DeclareAndCast(HeaderSection_FileName, anent, ent);
|
||||
RWHeaderSection_RWFileName tool;
|
||||
if (anent.IsNull()) ach->AddFail("Type Mismatch on FileName");
|
||||
else tool.ReadStep (data,num,ach,anent);
|
||||
}
|
||||
|
||||
break;
|
||||
case 2 :
|
||||
{
|
||||
DeclareAndCast(HeaderSection_FileDescription, anent, ent);
|
||||
RWHeaderSection_RWFileDescription tool;
|
||||
if (anent.IsNull()) ach->AddFail("Type Mismatch on FileDescription");
|
||||
else tool.ReadStep (data,num,ach,anent);
|
||||
}
|
||||
|
||||
break;
|
||||
case 3 :
|
||||
{
|
||||
DeclareAndCast(HeaderSection_FileSchema, anent, ent);
|
||||
RWHeaderSection_RWFileSchema tool;
|
||||
if (anent.IsNull()) ach->AddFail("Type Mismatch on FileSchema");
|
||||
else tool.ReadStep (data,num,ach,anent);
|
||||
}
|
||||
|
||||
break;
|
||||
case 4 :
|
||||
{
|
||||
DeclareAndCast(StepData_UndefinedEntity,und,ent);
|
||||
if (und.IsNull()) ach->AddFail
|
||||
("# Entity neither Recognized nor set as UndefinedEntity from StepData #");
|
||||
else und->ReadRecord(data,num,ach);
|
||||
}
|
||||
|
||||
break;
|
||||
default : ach->AddFail("Type Mismatch when reading - Entity");
|
||||
}
|
||||
|
||||
return;}
|
||||
|
||||
// -- Writing of a file --
|
||||
|
||||
void RWHeaderSection_ReadWriteModule::WriteStep
|
||||
(const Standard_Integer CN,
|
||||
StepData_StepWriter& SW,
|
||||
const Handle(Standard_Transient)&ent) const
|
||||
{
|
||||
if (CN == 0) return;
|
||||
switch (CN) {
|
||||
case 1 :
|
||||
{
|
||||
DeclareAndCast(HeaderSection_FileName, anent, ent);
|
||||
RWHeaderSection_RWFileName tool;
|
||||
if (anent.IsNull()) return;
|
||||
else tool.WriteStep (SW,anent);
|
||||
}
|
||||
|
||||
break;
|
||||
case 2 :
|
||||
{
|
||||
DeclareAndCast(HeaderSection_FileDescription, anent, ent);
|
||||
RWHeaderSection_RWFileDescription tool;
|
||||
if (anent.IsNull()) return;
|
||||
else tool.WriteStep (SW,anent);
|
||||
}
|
||||
|
||||
break;
|
||||
case 3 :
|
||||
{
|
||||
DeclareAndCast(HeaderSection_FileSchema, anent, ent);
|
||||
RWHeaderSection_RWFileSchema tool;
|
||||
if (anent.IsNull()) return;
|
||||
else tool.WriteStep (SW,anent);
|
||||
}
|
||||
|
||||
break;
|
||||
case 4 :
|
||||
{
|
||||
DeclareAndCast(StepData_UndefinedEntity,und,ent);
|
||||
if (und.IsNull()) break;
|
||||
// Parentheses gerees par StepWriter lui-meme
|
||||
// car en recevant le type PasReco, StepWriter ne l'affiche pas,
|
||||
// mais il gere les parentheses comme si de rien n etait
|
||||
if (und->IsComplex()) SW.StartComplex();
|
||||
und->WriteParams(SW);
|
||||
if (und->IsComplex()) SW.EndComplex();
|
||||
}
|
||||
|
||||
break;
|
||||
default : return;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user