1
0
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:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

100
src/StepData/StepData.cdl Executable file
View File

@@ -0,0 +1,100 @@
-- File: StepData.cdl
-- Created: Tue Feb 11 15:39:51 1992
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1992
package StepData
---Purpose : Gives basic data definition for Step Interface.
-- Any class of a data model described in EXPRESS Language
-- is candidate to be managed by a Step Interface
uses Standard, MMgt, TCollection, TColStd, Dico, LibCtl, Interface, Message
is
class StepModel;
class UndefinedEntity;
deferred class SelectType;
enumeration Logical is LFalse, LTrue, LUnknown;
---Purpose : A Standard Definition for STEP (which knows Boolean too)
class Field;
class SelectMember;
class SelectInt;
class SelectReal;
class SelectNamed;
class SelectArrReal;
class PDescr;
class FieldList; -- basic one (no field)
class FieldList1;
class FieldListN;
class FieldListD;
deferred class EDescr;
class ESDescr;
class ECDescr;
deferred class Described;
class Simple;
class Plex;
class FreeFormEntity;
class Protocol; -- basic protocol for Step
deferred class GeneralModule; -- general services
deferred class FileRecognizer instantiates
Recognizer from Interface (AsciiString from TCollection, Transient);
class FileProtocol;
class HeaderTool;
class EnumTool;
class DescrProtocol;
class DescrGeneral;
class DescrReadWrite;
class StepReaderData; -- litteral description of Step File
class StepReaderTool;
deferred class ReadWriteModule;
class StepWriter; -- idem but in the other sense
class StepDumper;
class WriterLib instantiates Library from LibCtl
(Transient, ReadWriteModule, Protocol from StepData);
class DefaultGeneral; -- Default Module which processes UnknownEntity
-- General Routines --
-- HeaderProtocol/AddHeaderProtocol are used to handle Header items :
-- Reading/Writing but also Copying,Checking,Dumping
--
--
-- Init & Protocol encapsulate the general actions required to work with
-- this package. While their use is not mandatory, it makes work easier.
class Array1OfField instantiates Array1 from TCollection
(Field from StepData);
class HArray1OfField instantiates HArray1 from TCollection
(Field from StepData,Array1OfField from StepData);
HeaderProtocol returns Protocol from StepData;
---Purpose : Returns the recorded HeaderProtocol, which can be :
-- - a Null Handle if no Header Protocol was yet defined
-- - a simple Protocol if only one was defined
-- - a FileProtocol if more than one Protocol was yet defined
AddHeaderProtocol (headerproto : Protocol from StepData);
---Purpose : Adds a new Header Protocol to the Header Definition
Init;
---Purpose : Prepares General Data required to work with this package,
-- which are the Protocol and Modules to be loaded into Libraries
Protocol returns Protocol from StepData;
---Purpose : Returns a Protocol from StepData (avoids to create it)
end StepData;

56
src/StepData/StepData.cxx Executable file
View File

@@ -0,0 +1,56 @@
// abv 09.04.99 S4136: eliminate parameter step.readaccept.void
// svv #2 23.02.00: porting on SIL
#include <StepData.ixx>
# include <StepData_Protocol.hxx>
# include <StepData_DefaultGeneral.hxx>
# include <StepData_FileProtocol.hxx>
#include <Interface_Static.hxx>
#include <Interface_Statics.hxx>
#include <Interface_Macros.hxx>
StaticHandle(StepData_Protocol,proto);
//svv #2: StaticHandle(StepData_DefaultGeneral,stmod);
StaticHandleA(StepData_Protocol,theheader);
void StepData::Init ()
{
// InitHandleVoid(StepData_Protocol,proto);
// InitHandleVoid(StepData_DefaultGeneral,stmod);
//:S4136 Interface_Static::Init("step","step.readaccept.void",'i',"1");
// if (proto.IsNull()) proto = new StepData_Protocol;
// if (stmod.IsNull()) stmod = new StepData_DefaultGeneral;
}
Handle(StepData_Protocol) StepData::Protocol ()
{
InitHandleVoid(StepData_Protocol,proto);// svv #2
// UseHandle(StepData_Protocol,proto);
return proto;
}
void StepData::AddHeaderProtocol (const Handle(StepData_Protocol)& header)
{
InitHandle(StepData_Protocol,theheader);
if (theheader.IsNull()) theheader = header;
else {
DeclareAndCast(StepData_FileProtocol,headmult,theheader);
if (headmult.IsNull()) {
headmult = new StepData_FileProtocol;
headmult->Add(theheader);
}
headmult->Add(header);
theheader = headmult;
}
}
Handle(StepData_Protocol) StepData::HeaderProtocol ()
{
UseHandle(StepData_Protocol,theheader);
return theheader;
}

View File

@@ -0,0 +1,44 @@
-- File: StepData_DefaultGeneral.cdl
-- Created: Fri Mar 26 10:22:38 1993
-- Author: Christian CAILLET
-- <cky@phylox>
---Copyright: Matra Datavision 1993
class DefaultGeneral from StepData inherits GeneralModule from StepData
---Purpose : DefaultGeneral defines a GeneralModule which processes
-- Unknown Entity from StepData only
uses OStream, Transient ,
EntityIterator , CopyTool, Check, ShareTool
is
Create returns mutable DefaultGeneral;
---Purpose : Creates a Default General Module
-- Reconduction because limitation cdl --
FillSharedCase (me; casenum : Integer; ent : Transient;
iter : in out EntityIterator);
---Purpose : Specific filling of the list of Entities shared by an Entity
-- <ent>, which is an UnknownEntity from StepData.
CheckCase (me; casenum : Integer; ent : Transient; shares : ShareTool;
ach : in out Check);
---Purpose : Specific Checking of an Entity <ent>
NewVoid (me; CN : Integer; entto : out mutable Transient)
returns Boolean;
---Purpose : Specific creation of a new void entity
CopyCase (me; casenum : Integer;
entfrom : Transient; entto : mutable Transient;
TC : in out CopyTool);
---Purpose : Specific Copy ("Deep") from <entfrom> to <entto> (same type)
-- by using a CopyTool which provides its working Map.
-- Use method Transferred from TransferControl to work
end DefaultGeneral;

View File

@@ -0,0 +1,62 @@
#include <StepData_DefaultGeneral.ixx>
#include <StepData.hxx>
#include <Interface_GeneralLib.hxx>
#include <StepData_UndefinedEntity.hxx>
#include <Interface_UndefinedContent.hxx>
#include <Interface_Macros.hxx>
#include <Interface_ParamType.hxx>
// DefaultGeneral de StepData reconnait UN SEUL TYPE : UndefinedEntity
StepData_DefaultGeneral::StepData_DefaultGeneral ()
{
Interface_GeneralLib::SetGlobal (this, StepData::Protocol());
}
void StepData_DefaultGeneral::FillSharedCase
(const Standard_Integer casenum, const Handle(Standard_Transient)& ent,
Interface_EntityIterator& iter) const
{
if (casenum != 1) return;
DeclareAndCast(StepData_UndefinedEntity,undf,ent);
Handle(Interface_UndefinedContent) cont = undf->UndefinedContent();
Standard_Integer nb = cont->NbParams();
for (Standard_Integer i = 1; i <= nb; i ++) {
Interface_ParamType ptype = cont->ParamType(i);
if (ptype == Interface_ParamSub) {
DeclareAndCast(StepData_UndefinedEntity,subent,cont->ParamEntity(i));
FillSharedCase(casenum,cont->ParamEntity(i),iter);
} else if (ptype == Interface_ParamIdent) {
iter.GetOneItem(cont->ParamEntity(i));
}
}
}
void StepData_DefaultGeneral::CheckCase(const Standard_Integer casenum,
const Handle(Standard_Transient)& ent,
const Interface_ShareTool& shares,
Handle(Interface_Check)& ach) const
{
} // pas de Check sur une UndefinedEntity
Standard_Boolean StepData_DefaultGeneral::NewVoid
(const Standard_Integer CN, Handle(Standard_Transient)& ent) const
{
if (CN != 1) return Standard_False;
ent = new StepData_UndefinedEntity;
return Standard_True;
}
void StepData_DefaultGeneral::CopyCase
(const Standard_Integer casenum, const Handle(Standard_Transient)& entfrom,
const Handle(Standard_Transient)& entto, Interface_CopyTool& TC) const
{
if (casenum != 1) return;
DeclareAndCast(StepData_UndefinedEntity,undfrom,entfrom);
DeclareAndCast(StepData_UndefinedEntity,undto,entto);
undto->GetFromAnother(undfrom,TC); // On pourrait rapatrier cela
}

View File

@@ -0,0 +1,39 @@
-- File: StepData_DescrGeneral.cdl
-- Created: Wed May 21 15:15:08 1997
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class DescrGeneral from StepData inherits GeneralModule from StepData
---Purpose : Works with a Protocol by considering its entity descriptions
uses Transient,
EntityIterator from Interface,
ShareTool from Interface,
Check from Interface,
CopyTool from Interface,
Protocol from StepData
is
Create (proto : Protocol from StepData) returns DescrGeneral;
FillSharedCase (me; CN : Integer; ent : Transient;
iter : in out EntityIterator);
CheckCase (me; CN : Integer; ent : Transient; shares : ShareTool;
ach : in out Check);
CopyCase (me; CN : Integer; entfrom : Transient; entto : mutable Transient;
TC : in out CopyTool);
NewVoid (me; CN : Integer; ent : out mutable Transient) returns Boolean;
fields
theproto : Protocol from StepData;
end DescrGeneral;

View File

@@ -0,0 +1,38 @@
#include <StepData_DescrGeneral.ixx>
#include <StepData_EDescr.hxx>
#include <StepData_Described.hxx>
StepData_DescrGeneral::StepData_DescrGeneral
(const Handle(StepData_Protocol)& proto)
: theproto (proto) { }
void StepData_DescrGeneral::FillSharedCase
(const Standard_Integer CN, const Handle(Standard_Transient)& ent,
Interface_EntityIterator& iter) const
{
Handle(StepData_Described) ds = Handle(StepData_Described)::DownCast(ent);
if (!ds.IsNull()) ds->Shared (iter);
}
void StepData_DescrGeneral::CheckCase(const Standard_Integer CN,
const Handle(Standard_Transient)& ent,
const Interface_ShareTool& shares,
Handle(Interface_Check)& ach) const
{
} // pour l instant
void StepData_DescrGeneral::CopyCase
(const Standard_Integer CN, const Handle(Standard_Transient)& entfrom,
const Handle(Standard_Transient)& entto, Interface_CopyTool& TC) const
{ } // pour l instant
Standard_Boolean StepData_DescrGeneral::NewVoid
(const Standard_Integer CN, Handle(Standard_Transient)& ent) const
{
ent = theproto->Descr(CN)->NewEntity();
return (!ent.IsNull());
}

View File

@@ -0,0 +1,44 @@
-- File: StepData_DescrProtocol.cdl
-- Created: Wed May 21 15:00:44 1997
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class DescrProtocol from StepData inherits FileProtocol from StepData
---Purpose : A DescrProtocol is a protocol dynamically (at execution time)
-- defined with :
-- - a list of resources (inherits FileProtocol)
-- - a list of entity descriptions
-- i.e. it can be defined with only C++ writing to initialize it
-- Its initialization must :
-- - set its schema name
-- - define its resources (which can also be other DescrProtocol)
-- - define its entity descriptions
-- - record it in the system by calling RecordLib
uses CString, AsciiString from TCollection
is
Create returns mutable DescrProtocol;
SetSchemaName (me : mutable; name : CString);
---Purpose : Defines a specific Schema Name for this Protocol
LibRecord (me);
---Purpose : Records this Protocol in the service libraries, with a
-- DescrGeneral and a DescrReadWrite
-- Does nothing if the Protocol brings no proper description
SchemaName (me) returns CString is redefined;
---Purpose : Returns the Schema Name attached to each class of Protocol
-- here, returns the SchemaName set by SetSchemaName
-- was C++ : return const
fields
thename : AsciiString;
end DescrProtocol;

View File

@@ -0,0 +1,25 @@
#include <StepData_DescrProtocol.ixx>
#include <StepData_DescrGeneral.hxx>
#include <StepData_DescrReadWrite.hxx>
#include <Interface_GeneralLib.hxx>
#include <Interface_ReaderLib.hxx>
#include <StepData_WriterLib.hxx>
StepData_DescrProtocol::StepData_DescrProtocol () { }
void StepData_DescrProtocol::SetSchemaName (const Standard_CString name)
{ thename.Clear(); thename.AssignCat (name); }
void StepData_DescrProtocol::LibRecord () const
{
if (!HasDescr()) return; // rien a recorder dans la lib ?
Handle(StepData_DescrGeneral) gen = new StepData_DescrGeneral (this);
Handle(StepData_DescrReadWrite) rwm = new StepData_DescrReadWrite (this);
Interface_GeneralLib::SetGlobal (gen,this);
Interface_ReaderLib::SetGlobal (rwm,this);
StepData_WriterLib::SetGlobal (rwm,this);
}
Standard_CString StepData_DescrProtocol::SchemaName () const
{ return thename.ToCString(); }

View File

@@ -0,0 +1,45 @@
-- File: StepData_DescrReadWrite.cdl
-- Created: Wed May 21 15:26:13 1997
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class DescrReadWrite from StepData inherits ReadWriteModule from StepData
uses Transient,
SequenceOfAsciiString from TColStd,
AsciiString from TCollection,
Check from Interface,
StepReaderData from StepData,
StepWriter from StepData,
Protocol from StepData
is
Create (proto : Protocol from StepData) returns DescrReadWrite from StepData;
CaseStep (me; atype : AsciiString from TCollection) returns Integer;
CaseStep(me; types : SequenceOfAsciiString from TColStd) returns Integer
is redefined;
IsComplex (me; CN : Integer) returns Boolean is redefined;
StepType (me; CN : Integer) returns AsciiString from TCollection;
---C++ : return const &
ComplexType (me; CN : Integer;
types : in out SequenceOfAsciiString from TColStd)
returns Boolean is redefined;
ReadStep (me; CN : Integer; data : StepReaderData; num : Integer;
ach : in out Check; ent : mutable Transient);
WriteStep (me; CN : Integer; SW : in out StepWriter; ent : Transient);
fields
theproto : Protocol from StepData;
end DescrReadWrite;

View File

@@ -0,0 +1,120 @@
#include <StepData_DescrReadWrite.ixx>
#include <StepData_EDescr.hxx>
#include <StepData_ECDescr.hxx>
#include <StepData_ESDescr.hxx>
#include <StepData_Simple.hxx>
#include <StepData_Plex.hxx>
#include <StepData_FieldListN.hxx>
#include <TColStd_HSequenceOfAsciiString.hxx>
#include <Interface_Macros.hxx>
static TCollection_AsciiString nocp("?");
StepData_DescrReadWrite::StepData_DescrReadWrite
(const Handle(StepData_Protocol)& proto)
: theproto (proto) { }
Standard_Integer StepData_DescrReadWrite::CaseStep
(const TCollection_AsciiString& atype) const
{
Handle(StepData_ESDescr) descr = theproto->ESDescr (atype.ToCString(),Standard_False);
if (descr.IsNull()) return 0;
return theproto->DescrNumber (descr);
}
Standard_Integer StepData_DescrReadWrite::CaseStep
(const TColStd_SequenceOfAsciiString& types) const
{
Handle(StepData_ECDescr) descr = theproto->ECDescr (types,Standard_False);
if (descr.IsNull()) return 0;
return theproto->DescrNumber (descr);
}
Standard_Boolean StepData_DescrReadWrite::IsComplex
(const Standard_Integer CN) const
{
Handle(StepData_EDescr) descr = theproto->Descr (CN);
if (descr.IsNull()) return Standard_False;
return descr->IsComplex();
}
const TCollection_AsciiString& StepData_DescrReadWrite::StepType
(const Standard_Integer CN) const
{
Handle(StepData_ESDescr) descr = Handle(StepData_ESDescr)::DownCast
(theproto->Descr (CN));
if (descr.IsNull()) return nocp;
return descr->StepType();
}
Standard_Boolean StepData_DescrReadWrite::ComplexType
(const Standard_Integer CN, TColStd_SequenceOfAsciiString& types) const
{
Handle(StepData_ECDescr) descr = Handle(StepData_ECDescr)::DownCast
(theproto->Descr (CN));
if (descr.IsNull()) return Standard_False;
Handle(TColStd_HSequenceOfAsciiString) list = descr->TypeList();
if (list.IsNull()) return Standard_False;
Standard_Integer i, nb = list->Length();
for (i = 1; i <= nb; i ++) types.Append (list->Value(i));
return Standard_True;
}
void StepData_DescrReadWrite::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;
DeclareAndCast(StepData_Simple,sent,ent);
if (!sent.IsNull()) {
Handle(StepData_ESDescr) sdescr = sent->ESDescr();
StepData_FieldListN& fl = sent->CFields();
data->ReadList (num,ach,sdescr,fl);
return;
}
DeclareAndCast(StepData_Plex,cent,ent);
Standard_Integer i, nb=0;
if (!cent.IsNull()) nb = cent->NbMembers();
Standard_Integer n0 = num;
for (i = 1; i <= nb; i ++) {
Handle(StepData_Simple) si = cent->Member(i);
Handle(StepData_ESDescr) sdescr = si->ESDescr();
StepData_FieldListN& fl = si->CFields();
data->ReadList (n0,ach,sdescr,fl);
if (i < nb) n0 = data->NextForComplex(n0);
}
}
void StepData_DescrReadWrite::WriteStep
(const Standard_Integer CN,
StepData_StepWriter& SW,
const Handle(Standard_Transient)&ent) const
{
if (CN == 0) return;
DeclareAndCast(StepData_Simple,sent,ent);
if (!sent.IsNull()) {
Handle(StepData_ESDescr) sdescr = sent->ESDescr();
const StepData_FieldListN& fl = sent->Fields();
SW.SendList (fl,sdescr);
return;
}
DeclareAndCast(StepData_Plex,cent,ent);
Standard_Integer i, nb=0;
if (!cent.IsNull()) nb = cent->NbMembers();
for (i = 1; i <= nb; i ++) {
Handle(StepData_Simple) si = cent->Member(i);
Handle(StepData_ESDescr) sdescr = si->ESDescr();
const StepData_FieldListN& fl = si->Fields();
SW.StartEntity (sdescr->TypeName());
SW.SendList (fl,sdescr);
}
}

View File

@@ -0,0 +1,68 @@
-- File: StepData_Described.cdl
-- Created: Fri May 9 15:17:42 1997
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
deferred class Described from StepData inherits TShared from MMgt
---Purpose : General frame to describe entities with Description (Simple or
-- Complex)
uses CString,
Check from Interface, EntityIterator from Interface,
Field from StepData, EDescr from StepData, Simple from StepData
raises InterfaceMismatch from Interface
is
Initialize (descr : EDescr);
---Purpose : Initializes a Described Entity from a Description
-- (i.e. puts it in a field ...)
Description (me) returns EDescr;
---Purpose : Returns the Description used to define this entity
IsComplex (me) returns Boolean is deferred;
---Purpose : Tells if a described entity is complex
Matches (me; steptype : CString) returns Boolean is deferred;
---Purpose : Tells if a step type is matched by <me>
-- For a Simple Entity : own type or super type
-- For a Complex Entity : one of the members
As (me; steptype : CString) returns mutable Simple is deferred;
---Purpose : Returns a Simple Entity which matches with a Type in <me> :
-- For a Simple Entity : me if it matches, else a null handle
-- For a Complex Entity : the member which matches, else null
HasField (me; name : CString) returns Boolean is deferred;
---Purpose : Tells if a Field brings a given name
Field (me; name : CString) returns Field
---Purpose : Returns a Field from its name; read-only
raises InterfaceMismatch is deferred;
-- raises if no Field for <name>
---C++ : return const &
CField (me : mutable; name : CString) returns Field
---Purpose : Returns a Field from its name; read or write
raises InterfaceMismatch is deferred;
-- raises if no Field for <name>
---C++ : return &
--
Check (me; ach : in out Check from Interface) is deferred;
---Purpose : Fills a Check by using its Description
Shared (me; list : in out EntityIterator from Interface) is deferred;
---Purpose : Fills an EntityIterator with entities shared by <me>
fields
thedescr : EDescr;
end Described;

View File

@@ -0,0 +1,7 @@
#include <StepData_Described.ixx>
StepData_Described::StepData_Described (const Handle(StepData_EDescr)& descr)
: thedescr (descr) { }
Handle(StepData_EDescr) StepData_Described::Description () const
{ return thedescr; }

View File

@@ -0,0 +1,50 @@
-- File: StepData_ECDescr.cdl
-- Created: Fri May 9 15:46:04 1997
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class ECDescr from StepData inherits EDescr from StepData
---Purpose : Describes a Complex Entity (Plex) as a list of Simple ones
uses HSequenceOfAsciiString from TColStd, SequenceOfTransient from TColStd,
ESDescr from StepData, Described from StepData
is
Create returns mutable ECDescr;
---Purpose : Creates an ECDescr, empty
Add (me : mutable; member : ESDescr);
---Purpose : Adds a member
-- Warning : members are added in alphabetic order
NbMembers (me) returns Integer;
---Purpose : Returns the count of members
Member (me; num : Integer) returns ESDescr;
---Purpose : Returns a Member from its rank
TypeList (me) returns HSequenceOfAsciiString;
---Purpose : Returns the ordered list of types
-- inherited
Matches (me; steptype : CString) returns Boolean;
---Purpose : Tells if a ESDescr matches a step type : exact or super type
IsComplex (me) returns Boolean;
---Purpose : Returns True
NewEntity (me) returns mutable Described;
---Purpose : Creates a described entity (i.e. a complex one, made of one
-- simple entity per member)
fields
thelist : SequenceOfTransient;
end ECDescr;

View File

@@ -0,0 +1,61 @@
#include <StepData_ECDescr.ixx>
#include <TCollection_AsciiString.hxx>
#include <StepData_Plex.hxx>
StepData_ECDescr::StepData_ECDescr () { }
void StepData_ECDescr::Add (const Handle(StepData_ESDescr)& member)
{
if (member.IsNull()) return;
Standard_CString name = member->TypeName();
TCollection_AsciiString nam (name);
for (Standard_Integer i = NbMembers(); i > 0; i --) {
Handle(StepData_ESDescr) mem = Member(i);
if (nam.IsLess (mem->TypeName())) { thelist.InsertBefore (i,member); return; }
}
thelist.Append (member);
}
Standard_Integer StepData_ECDescr::NbMembers () const
{ return thelist.Length(); }
Handle(StepData_ESDescr) StepData_ECDescr::Member
(const Standard_Integer num) const
{ return Handle(StepData_ESDescr)::DownCast (thelist.Value(num)); }
Handle(TColStd_HSequenceOfAsciiString) StepData_ECDescr::TypeList () const
{
Handle(TColStd_HSequenceOfAsciiString) tl = new TColStd_HSequenceOfAsciiString();
Standard_Integer i, nb = NbMembers();
for (i = 1; i <= nb; i ++) {
TCollection_AsciiString nam (Member(i)->TypeName());
tl->Append(nam);
}
return tl;
}
Standard_Boolean StepData_ECDescr::Matches (const Standard_CString name) const
{
Standard_Integer i, nb = NbMembers();
for (i = 1; i <= nb; i ++) {
Handle(StepData_ESDescr) member = Member(i);
if (member->Matches(name)) return Standard_True;
}
return Standard_False;
}
Standard_Boolean StepData_ECDescr::IsComplex () const
{ return Standard_True; }
Handle(StepData_Described) StepData_ECDescr::NewEntity () const
{
Handle(StepData_Plex) ent = new StepData_Plex (this);
Standard_Integer i, nb = NbMembers();
for (i = 1; i <= nb; i ++) {
Handle(StepData_ESDescr) member = Member(i);
Handle(StepData_Simple) mem = Handle(StepData_Simple)::DownCast(member->NewEntity());
if (!mem.IsNull()) ent->Add (mem);
}
return ent;
}

View File

@@ -0,0 +1,27 @@
-- File: StepData_EDescr.cdl
-- Created: Wed Apr 2 09:04:40 1997
-- Author: Administrateur Atelier XSTEP
-- <xstep@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
deferred class EDescr from StepData inherits TShared
---Purpose : This class is intended to describe the authorized form for an
-- entity, either Simple or Plex
uses CString,
Described from StepData
is
Matches (me; steptype : CString) returns Boolean is deferred;
---Purpose : Tells if a ESDescr matches a step type : exact or super type
IsComplex (me) returns Boolean is deferred;
---Purpose : Tells if a EDescr is complex (ECDescr) or simple (ESDescr)
NewEntity (me) returns mutable Described is deferred;
---Purpose : Creates a described entity (i.e. a simple one)
end EDescr;

View File

@@ -0,0 +1 @@
#include <StepData_EDescr.ixx>

View File

@@ -0,0 +1,89 @@
-- File: StepData_ESDescr.cdl
-- Created: Fri May 9 15:34:51 1997
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class ESDescr from StepData inherits EDescr
---Purpose : This class is intended to describe the authorized form for a
-- Simple (not Plex) Entity, as a list of fields
uses CString, AsciiString from TCollection,
HArray1OfTransient from TColStd, DictionaryOfInteger from Dico,
PDescr from StepData, Described from StepData
is
Create (name : CString) returns mutable ESDescr;
---Purpose : Creates an ESDescr with a type name
SetNbFields (me : mutable; nb : Integer);
---Purpose : Sets a new count of fields
-- Each one is described by a PDescr
SetField (me : mutable; num : Integer; name : CString; descr : PDescr);
---Purpose : Sets a PDescr to describe a field
-- A Field is designated by its rank and name
SetBase (me : mutable; base : ESDescr);
---Purpose : Sets an ESDescr as based on another one
-- Hence, if there are inherited fields, the derived ESDescr
-- cumulates all them, while the base just records its own ones
SetSuper (me : mutable; super : ESDescr);
---Purpose : Sets an ESDescr as "super-type". Applies an a base (non
-- derived) ESDescr
TypeName (me) returns CString;
---Purpose : Returns the type name given at creation time
StepType (me) returns AsciiString from TCollection;
---Purpose : Returns the type name as an AsciiString
---C++ : return const &
Base (me) returns ESDescr;
---Purpose : Returns the basic ESDescr, null if <me> is not derived
Super (me) returns ESDescr;
---Purpose : Returns the super-type ESDescr, null if <me> is root
IsSub (me; other : ESDescr) returns Boolean;
---Purpose : Tells if <me> is sub-type of (or equal to) another one
NbFields (me) returns Integer;
---Purpose : Returns the count of fields
Rank (me; name : CString) returns Integer;
---Purpose : Returns the rank of a field from its name. 0 if unknown
Name (me; num : Integer) returns CString;
---Purpose : Returns the name of a field from its rank. empty if outofrange
Field (me; num : Integer) returns PDescr;
---Purpose : Returns the PDescr for the field <num> (or Null)
NamedField (me; name : CString) returns PDescr;
---Purpose : Returns the PDescr for the field named <name> (or Null)
-- inherited
Matches (me; steptype : CString) returns Boolean;
---Purpose : Tells if a ESDescr matches a step type : exact or super type
IsComplex (me) returns Boolean;
---Purpose : Returns False
NewEntity (me) returns mutable Described;
---Purpose : Creates a described entity (i.e. a simple one)
fields
thenom : AsciiString;
thedescr : HArray1OfTransient;
thenames : DictionaryOfInteger;
thebase : ESDescr;
thesuper : ESDescr;
end ESDescr;

122
src/StepData/StepData_ESDescr.cxx Executable file
View File

@@ -0,0 +1,122 @@
#include <StepData_ESDescr.ixx>
#include <StepData_Simple.hxx>
#include <Interface_Macros.hxx>
StepData_ESDescr::StepData_ESDescr (const Standard_CString name)
: thenom (name) { thenames = new Dico_DictionaryOfInteger; }
void StepData_ESDescr::SetNbFields (const Standard_Integer nb)
{
Standard_Integer minb,i, oldnb = NbFields();
thenames->Clear();
if (nb == 0) { thedescr.Nullify(); return; }
Handle(TColStd_HArray1OfTransient) li = new TColStd_HArray1OfTransient(1,nb);
if (oldnb == 0) { thedescr = li; return; }
minb = (oldnb > nb ? nb : oldnb);
for (i = 1; i <= minb; i ++) {
DeclareAndCast(StepData_PDescr,pde,thedescr->Value(i));
if (!pde.IsNull()) thenames->SetItem (pde->Name(),i);
li->SetValue (i, pde);
}
thedescr = li;
}
void StepData_ESDescr::SetField
(const Standard_Integer num, const Standard_CString name,
const Handle(StepData_PDescr)& descr)
{
if (num < 1 || num > NbFields()) return;
Handle(StepData_PDescr) pde = new StepData_PDescr;
pde->SetFrom (descr);
pde->SetName (name);
thedescr->SetValue (num,pde);
thenames->SetItem (name,num);
}
void StepData_ESDescr::SetBase (const Handle(StepData_ESDescr)& base)
{
thebase = base;
// il faut CUMULER les fields de la base et ses supers
}
void StepData_ESDescr::SetSuper (const Handle(StepData_ESDescr)& super)
{
Handle(StepData_ESDescr) sup = super->Base();
if (sup.IsNull()) sup = super;
if (!thebase.IsNull()) thebase->SetSuper (sup);
else thesuper = sup;
}
Standard_CString StepData_ESDescr::TypeName () const
{ return thenom.ToCString(); }
const TCollection_AsciiString& StepData_ESDescr::StepType () const
{ return thenom; }
Handle(StepData_ESDescr) StepData_ESDescr::Base () const
{ return thebase; }
Handle(StepData_ESDescr) StepData_ESDescr::Super () const
{ return thesuper; }
Standard_Boolean StepData_ESDescr::IsSub (const Handle(StepData_ESDescr)& other) const
{
Handle(StepData_ESDescr) oth = other->Base();
if (oth.IsNull()) oth = other;
if (!thebase.IsNull()) return thebase->IsSub (oth);
Handle(Standard_Transient) t1 = this;
if (oth == t1) return Standard_True;
if (oth == thesuper) return Standard_True;
else if (thesuper.IsNull()) return Standard_False;
return thesuper->IsSub (oth);
}
Standard_Integer StepData_ESDescr::NbFields () const
{ return (thedescr.IsNull() ? 0 : thedescr->Length()); }
Standard_Integer StepData_ESDescr::Rank (const Standard_CString name) const
{
Standard_Integer rank;
if (!thenames->GetItem (name,rank)) return 0;
return rank;
}
Standard_CString StepData_ESDescr::Name (const Standard_Integer num) const
{
if (num < 1) return "";
if (num > NbFields()) return "";
DeclareAndCast(StepData_PDescr,pde,thedescr->Value(num));
return pde->Name();
}
Handle(StepData_PDescr) StepData_ESDescr::Field (const Standard_Integer num) const
{ return GetCasted(StepData_PDescr,thedescr->Value(num)); }
Handle(StepData_PDescr) StepData_ESDescr::NamedField
(const Standard_CString name) const
{
Handle(StepData_PDescr) pde;
Standard_Integer rank = Rank(name);
if (rank > 0) pde = GetCasted(StepData_PDescr,thedescr->Value(rank));
return pde;
}
Standard_Boolean StepData_ESDescr::Matches (const Standard_CString name) const
{
if (thenom.IsEqual(name)) return Standard_True;
if (thesuper.IsNull()) return Standard_False;
return thesuper->Matches (name);
}
Standard_Boolean StepData_ESDescr::IsComplex () const
{ return Standard_False; }
Handle(StepData_Described) StepData_ESDescr::NewEntity () const
{
Handle(StepData_Simple) ent = new StepData_Simple(this);
return ent;
}

View File

@@ -0,0 +1,103 @@
-- File: StepData_EnumTool.cdl
-- Created: Wed Oct 25 10:49:31 1995
-- Author: Christian CAILLET
-- <cky@anion>
---Copyright: Matra Datavision 1995
class EnumTool from StepData
---Purpose : This class gives a way of conversion between the value of an
-- enumeration and its representation in STEP
-- An enumeration corresponds to an integer with reserved values,
-- which begin to 0
-- In STEP, it is represented by a name in capital letter and
-- limited by two dots, e.g. .UNKNOWN.
--
-- EnumTool works with integers, it is just required to cast
-- between an integer and an enumeration of required type.
--
-- Its definition is intended to allow static creation in once,
-- without having to recreate once for each use.
--
-- It is possible to define subclasses on it, which directly give
-- the good list of definition texts, and accepts a enumeration
-- of the good type instead of an integer
uses CString, AsciiString, SequenceOfAsciiString
is
Create (e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26,e27,e28,e29,e30,e31,e32,e33,e34,e35,e36,e37,e38,e39 : CString = "")
returns EnumTool;
---Purpose : Creates an EnumTool with definitions given by e0 .. e<max>
-- Each definition string can bring one term, or several
-- separated by blanks. Each term corresponds to one value of the
-- enumeration, if dots are not presents they are added
--
-- Such a static constructor allows to build a static description
-- as : static StepData_EnumTool myenumtool("e0","e1"...);
-- then use it without having to initialise it
--
-- A null definition can be input by given "$" :the corresponding
-- position is attached to "null/undefined" value (as one
-- particular item of the enumeration list)
AddDefinition (me : in out; term : CString);
---Purpose : Processes a definition, splits it according blanks if any
-- empty definitions are ignored
-- A null definition can be input by given "$" :the corresponding
-- position is attached to "null/undefined" value (as one
-- particular item of the enumeration list)
-- See also IsSet
IsSet (me) returns Boolean;
---Purpose : Returns True if at least one definition has been entered after
-- creation time (i.e. by AddDefinition only)
--
-- This allows to build a static description by a first pass :
-- static StepData_EnumTool myenumtool("e0" ...);
-- ...
-- if (!myenumtool.IsSet()) { for further inits
-- myenumtool.AddDefinition("e21");
-- ...
-- }
MaxValue (me) returns Integer;
---Purpose : Returns the maximum integer for a suitable value
-- Remark : while values begin at zero, MaxValue is the count of
-- recorded values minus one
Optional (me : in out; mode : Boolean);
---Purpose : Sets or Unsets the EnumTool to accept undefined value (for
-- optional field). Ignored if no null value is defined (by "$")
-- Can be changed during execution (to read each field),
-- Default is True (if a null value is defined)
NullValue (me) returns Integer;
---Purpose : Returns the value attached to "null/undefined value"
-- If none is specified or if Optional has been set to False,
-- returns -1
-- Null Value has been specified by definition "$"
Text (me; num : Integer) returns AsciiString;
---Purpose : Returns the text which corresponds to a given numeric value
-- It is limited by dots
-- If num is out of range, returns an empty string
---C++ : return const &
Value (me; txt : CString) returns Integer;
---Purpose : Returns the numeric value found for a text
-- The text must be in capitals and limited by dots
-- A non-suitable text gives a negative value to be returned
Value (me; txt : AsciiString) returns Integer;
---Purpose : Same as above but works on an AsciiString
fields
thetexts : SequenceOfAsciiString;
theinit : Integer;
theopt : Boolean;
end EnumTool;

View File

@@ -0,0 +1,109 @@
#include <StepData_EnumTool.ixx>
static TCollection_AsciiString nulstr("");
StepData_EnumTool::StepData_EnumTool
(const Standard_CString e0, const Standard_CString e1,
const Standard_CString e2, const Standard_CString e3,
const Standard_CString e4, const Standard_CString e5,
const Standard_CString e6, const Standard_CString e7,
const Standard_CString e8, const Standard_CString e9,
const Standard_CString e10,const Standard_CString e11,
const Standard_CString e12,const Standard_CString e13,
const Standard_CString e14,const Standard_CString e15,
const Standard_CString e16,const Standard_CString e17,
const Standard_CString e18,const Standard_CString e19,
const Standard_CString e20,const Standard_CString e21,
const Standard_CString e22,const Standard_CString e23,
const Standard_CString e24,const Standard_CString e25,
const Standard_CString e26,const Standard_CString e27,
const Standard_CString e28,const Standard_CString e29,
const Standard_CString e30,const Standard_CString e31,
const Standard_CString e32,const Standard_CString e33,
const Standard_CString e34,const Standard_CString e35,
const Standard_CString e36,const Standard_CString e37,
const Standard_CString e38,const Standard_CString e39)
{
AddDefinition (e0); AddDefinition (e1); AddDefinition (e2);
AddDefinition (e3); AddDefinition (e4); AddDefinition (e5);
AddDefinition (e6); AddDefinition (e7); AddDefinition (e8);
AddDefinition (e9); AddDefinition (e10); AddDefinition (e11);
AddDefinition (e12); AddDefinition (e13); AddDefinition (e14);
AddDefinition (e15); AddDefinition (e16); AddDefinition (e17);
AddDefinition (e18); AddDefinition (e19); AddDefinition (e20);
AddDefinition (e21); AddDefinition (e22); AddDefinition (e23);
AddDefinition (e24); AddDefinition (e25); AddDefinition (e26);
AddDefinition (e27); AddDefinition (e28); AddDefinition (e29);
AddDefinition (e30); AddDefinition (e31); AddDefinition (e32);
AddDefinition (e33); AddDefinition (e34); AddDefinition (e35);
AddDefinition (e36); AddDefinition (e37); AddDefinition (e38);
AddDefinition (e39);
theinit = thetexts.Length(); theopt = Standard_True;
}
void StepData_EnumTool::AddDefinition (const Standard_CString term)
{
char text[80];
if (!term) return;
if (term[0] == '\0') return;
Standard_Integer n0 = 0, n1 = 0;
for (; term[n0] != '\0'; n0 ++) {
if (term[n0] <= 32) {
if (n1 == 0) continue;
if (n1 > 1 || text[0] != '$') {
if (text[n1-1] != '.') { text[n1] = '.'; n1 ++; }
text[n1] = '\0';
}
thetexts.Append ( TCollection_AsciiString(text) );
n1 = 0;
}
if (n1 == 0 && term[n0] != '.' && term[n0] != '$') { text[0] = '.'; n1 ++; }
text[n1] = term[n0]; n1 ++;
}
if (n1 > 0 || text[0] != '$') {
if (text[n1-1] != '.') { text[n1] = '.'; n1 ++; }
text[n1] = '\0';
}
if (text[n1-1] != '.') { text[n1] = '.'; n1 ++; }
text[n1] = '\0';
thetexts.Append ( TCollection_AsciiString(text) );
}
Standard_Boolean StepData_EnumTool::IsSet () const
{ return (thetexts.Length() > theinit); }
Standard_Integer StepData_EnumTool::MaxValue () const
{ return thetexts.Length() - 1; }
void StepData_EnumTool::Optional (const Standard_Boolean mode)
{ theopt = mode; }
Standard_Integer StepData_EnumTool::NullValue () const
{ return (theopt ? Value("$") : Standard_False); }
const TCollection_AsciiString& StepData_EnumTool::Text
(const Standard_Integer num) const
{
if (num < 0 || num >= thetexts.Length()) return nulstr;
return thetexts.Value (num+1);
}
Standard_Integer StepData_EnumTool::Value
(const Standard_CString txt) const
{
Standard_Integer nb = thetexts.Length();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (thetexts.Value(i).IsEqual(txt)) return i-1;
}
return (-1);
}
Standard_Integer StepData_EnumTool::Value
(const TCollection_AsciiString& txt) const
{
Standard_Integer nb = thetexts.Length();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (thetexts.Value(i).IsEqual(txt)) return i-1;
}
return (-1);
}

179
src/StepData/StepData_Field.cdl Executable file
View File

@@ -0,0 +1,179 @@
-- File: StepData_Field.cdl
-- Created: Mon Dec 16 14:15:32 1996
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class Field from StepData
---Purpose : Defines a generally defined Field for STEP data : can be used
-- either in any kind of entity to implement it or in free format
-- entities in a "late-binding" mode
-- A field can have : no value (or derived), a single value of
-- any kind, a list of value : single or double list
--
-- When a field is set, this defines its new kind (Integer etc..)
-- A single value is immediately set. A list of value is, firstly
-- declared as for a kind (Integer String etc), then declared as
-- a list with its initial size, after this its items are set
-- Also it can be set in once if the HArray is ready
uses Transient, HAsciiString, CString,
HArray1OfInteger from TColStd, HArray1OfReal from TColStd,
HArray1OfTransient from TColStd, HArray1OfHAsciiString from Interface,
Logical from StepData, SelectMember from StepData
is
Create returns Field;
---Purpose : Creates a Field, empty ("no value defined")
Create (other : Field; copy : Boolean = Standard_False) returns Field;
---Purpose : Creates a Field from another one. If <copy> is True, Handled
-- data (Select,String,List, not entities) are copied
CopyFrom (me : in out; other : Field);
---Purpose : Gets the copy of the values of another field
Clear (me : in out; kind : Integer = 0);
---Purpose : Clears the field, to set it as "no value defined"
-- Just before SetList, predeclares it as "any"
-- A Kind can be directly set here to declare a type
-- Setting a Single Value, or predeclaring a list
SetDerived (me : in out);
---Purpose : Codes a Field as derived (no proper value)
SetInt (me : in out; val : Integer);
---Purpose : Directly sets the Integer value, if its Kind matches
-- Integer, Boolean, Logical, or Enum (does not change Kind)
SetInteger (me : in out; val : Integer = 0);
---Purpose : Sets an Integer value (before SetList* declares it as Integer)
SetBoolean (me : in out; val : Boolean = Standard_False);
---Purpose : Sets a Boolean value (or predeclares a list as boolean)
SetLogical (me : in out; val : Logical = StepData_LFalse);
---Purpose : Sets a Logical Value (or predeclares a list as logical)
SetReal (me : in out; val : Real = 0.0);
---Purpose : Sets a Real Value (or predeclares a list as Real);
SetString (me : in out; val : CString = "");
---Purpose : Sets a String Value (or predeclares a list as String)
-- Does not redefine the Kind if it is alread String or Enum
SetEnum (me : in out; val : Integer = -1; text : CString = "");
---Purpose : Sets an Enum Value (as its integer counterpart)
-- (or predeclares a list as Enum)
-- If <text> is given , also sets its textual expression
-- <val> negative means unknown (known values begin at 0)
SetSelectMember (me : in out; val : SelectMember);
---Purpose : Sets a SelectMember (for Integer,Boolean,Enum,Real,Logical)
-- Hence, the value of the field is accessed through this member
SetEntity (me : in out; val : Transient);
---Purpose : Sets an Entity Value
SetEntity (me : in out);
---Purpose : Predeclares a list as of entity
SetList (me : in out; size : Integer; first : Integer = 1);
---Purpose : Declares a field as a list, with an initial size
-- Initial lower is defaulted as 1, can be defined
-- The list starts empty, typed by the last Set*
-- If no Set* before, sets it as "any" (transient/select)
SetList2 (me : in out; siz1, siz2 : Integer; f1,f2 : Integer = 1);
---Purpose : Declares a field as an homogeneous square list, with initial\
-- sizes, and initial lowers
Set (me : in out; val : Transient);
---Purpose : Sets an undetermined value : can be String, SelectMember,
-- HArray(1-2) ... else, an Entity
-- In case of an HArray, determines and records its size(s)
-- Setting List Items : Single List
ClearItem (me : in out; num : Integer);
---Purpose : Declares an item of the list as undefined
-- (ignored if list not defined as String,Entity or Any)
SetInt (me : in out; num : Integer; val : Integer; kind : Integer);
---Purpose : Internal access to an Integer Value for a list, plus its kind
SetInteger (me : in out; num : Integer; val : Integer);
---Purpose : Sets an Integer Value for a list (rank num)
-- (recognizes a SelectMember)
SetBoolean (me : in out; num : Integer; val : Boolean);
SetLogical (me : in out; num : Integer; val : Logical);
SetEnum (me : in out; num : Integer; val : Integer; text: CString = "");
---Purpose : Sets an Enum Value (Integer counterpart), also its text
-- expression if known (if list has been set as "any")
SetReal (me : in out; num : Integer; val : Real);
SetString (me : in out; num : Integer; val : CString);
SetEntity (me : in out; num : Integer; val : Transient);
-- Quering Value
-- For a Single field, n1 and n2 are ignored
-- For a Single List, n1 is considered and n2 is ignored
IsSet (me; n1, n2 : Integer = 1) returns Boolean;
ItemKind (me; n1, n2 : Integer = 1) returns Integer;
---Purpose : Returns the kind of an item in a list or double list
-- It is the kind of the list, except if it is "Any", in such a
-- case the true kind is determined and returned
Kind (me; type : Boolean = Standard_True) returns Integer; -- enum ?
---Purpose : Returns the kind of the field
-- <type> True (D) : returns only the type itself
-- else, returns the complete kind
Arity (me) returns Integer; -- 0:single 1:list 2:list2
Length (me; index : Integer = 1) returns Integer; -- for index 1 or 2
-- True Length, not simply the reserved one
Lower (me; index : Integer = 1) returns Integer; -- for index 1 or 2
-- Single :
Int (me) returns Integer; -- the field Integer itself
Integer (me; n1, n2 : Integer = 1) returns Integer;
Boolean (me; n1, n2 : Integer = 1) returns Boolean;
Logical (me; n1, n2 : Integer = 1) returns Logical;
Real (me; n1, n2 : Integer = 1) returns Real;
String (me; n1, n2 : Integer = 1) returns CString;
Enum (me; n1, n2 : Integer = 1) returns Integer;
EnumText (me; n1, n2 : Integer = 1) returns CString; -- "" if unknown
Entity (me; n1, n2 : Integer = 1) returns Transient;
Transient (me) returns Transient; -- the fields itself
fields
thekind : Integer;
theint : Integer;
thereal : Real;
theany : Transient;
end Field;

686
src/StepData/StepData_Field.cxx Executable file
View File

@@ -0,0 +1,686 @@
#include <StepData_Field.ixx>
#include <Interface_Macros.hxx>
#include <StepData_SelectMember.hxx>
#include <StepData_SelectInt.hxx>
#include <StepData_SelectReal.hxx>
#include <StepData_SelectNamed.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_HArray1OfTransient.hxx>
#include <Interface_HArray1OfHAsciiString.hxx>
#include <TColStd_HArray2OfInteger.hxx>
#include <TColStd_HArray2OfReal.hxx>
#include <TColStd_HArray2OfTransient.hxx>
// Le kind code le type de donnee, le mode d acces (direct ou via Select),
// l arite (simple, liste, carre)
// Valeurs pour Kind : 0 = Clear/Undefined
// KindInteger KindBoolean KindLogical KindEnum KindReal KindString KindEntity
// + KindSelect qui s y substitue et peut s y combiner
// + KindList et KindList2 qui peuvent s y combiner
// (sur masque KindArity et decalage ShiftArity)
#define KindInteger 1
#define KindBoolean 2
#define KindLogical 3
#define KindEnum 4
#define KindReal 5
#define KindString 6
#define KindEntity 7
#define KindAny 8
#define KindDerived 9
#define KindType 15
#define KindSelect 16
#define KindArity 192
#define KindList 64
#define KindList2 128
#define ShiftArity 6
static Standard_Integer TrueKind (const Standard_Integer kind)
{ return (kind & KindType); }
StepData_Field::StepData_Field () { Clear(); }
StepData_Field::StepData_Field
(const StepData_Field& other, const Standard_Boolean copy)
{
if (copy) { CopyFrom(other); return; }
thekind = other.Kind(Standard_False); theint = other.Int();
thereal = other.Real(); theany = other.Transient();
}
void StepData_Field::CopyFrom (const StepData_Field& other)
{
thekind = other.Kind(Standard_False); theint = other.Int();
thereal = other.Real(); theany = other.Transient();
if (thekind == KindString || thekind == KindEnum) {
DeclareAndCast(TCollection_HAsciiString,str,theany);
if (!str.IsNull()) theany = new TCollection_HAsciiString (str->ToCString());
return;
}
if (thekind == KindSelect) {
// Differents cas
DeclareAndCast(StepData_SelectReal,sr,theany);
if (!sr.IsNull()) {
Standard_Real val = sr->Real();
sr = new StepData_SelectReal; sr->SetReal(val);
theany = sr; return;
}
DeclareAndCast(StepData_SelectInt,si,theany);
if (!si.IsNull()) {
Standard_Integer ival = si->Int(), ik = si->Kind();
si = new StepData_SelectInt; si->SetKind(ik); si->SetInt(ival);
theany = si; return;
}
DeclareAndCast(StepData_SelectNamed,sn,theany);
if (!sn.IsNull()) {
Handle(StepData_SelectNamed) sn2 = new StepData_SelectNamed;
if (sn->HasName()) sn2->SetName(sn2->Name());
sn2->CField().CopyFrom(*this);
theany = sn2; return;
}
}
// Les listes ...
if ((thekind & KindArity) == KindList) {
Standard_Integer i, low, up;
DeclareAndCast(TColStd_HArray1OfInteger,hi,theany);
if (!hi.IsNull()) {
low = hi->Lower(); up = hi->Upper();
Handle(TColStd_HArray1OfInteger) hi2 = new TColStd_HArray1OfInteger (low,up);
for (i = low; i <= up; i ++) hi2->SetValue (i,hi->Value(i));
return;
}
DeclareAndCast(TColStd_HArray1OfReal,hr,theany);
if (!hr.IsNull()) {
low = hr->Lower(); up = hr->Upper();
Handle(TColStd_HArray1OfReal) hr2 = new TColStd_HArray1OfReal (low,up);
for (i = low; i <= up; i ++) hr2->SetValue (i,hr->Value(i));
return;
}
DeclareAndCast(Interface_HArray1OfHAsciiString,hs,theany);
if (!hs.IsNull()) {
low = hs->Lower(); up = hs->Upper();
Handle(Interface_HArray1OfHAsciiString) hs2 = new Interface_HArray1OfHAsciiString (low,up);
for (i = low; i <= up; i ++) hs2->SetValue (i,new TCollection_HAsciiString(hs->Value(i)));
return;
}
DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
if (!ht.IsNull()) {
low = ht->Lower(); up = ht->Upper();
Handle(TColStd_HArray1OfTransient) ht2 = new TColStd_HArray1OfTransient (low,up);
// faudrait reprendre les cas SelectMember ...
for (i = low; i <= up; i ++) ht2->SetValue (i,ht->Value(i));
return;
}
}
// Reste la liste 2 ...
// if ((thekind & KindArity) == KindList2) {
// DeclareAndCast(TColStd_HArray2OfTransient,ht,theany);
// }
}
void StepData_Field::Clear (const Standard_Integer kind)
{
thekind = kind;
theint = 0; thereal = 0.; theany.Nullify();
}
void StepData_Field::SetDerived ()
{ Clear(KindDerived); }
void StepData_Field::SetInt (const Standard_Integer val)
{
if (thekind == KindSelect) {
DeclareAndCast(StepData_SelectMember,sm,theany);
if (!sm.IsNull()) { sm->SetInteger(val); return; }
}
if (thekind == KindInteger || thekind == KindBoolean ||
thekind == KindLogical || thekind == KindEnum) theint = val;
// else ?
}
void StepData_Field::SetInteger (const Standard_Integer val)
{
if (thekind == KindSelect) {
DeclareAndCast(StepData_SelectMember,sm,theany);
if (!sm.IsNull()) { sm->SetInteger(val); return; }
}
Clear(KindInteger);
theint = val;
}
void StepData_Field::SetBoolean (const Standard_Boolean val)
{
if (thekind == KindSelect) {
DeclareAndCast(StepData_SelectMember,sm,theany);
if (!sm.IsNull()) { sm->SetBoolean(val); return; }
}
Clear(KindBoolean);
theint = (val ? 1 : 0);
}
void StepData_Field::SetLogical (const StepData_Logical val)
{
if (thekind == KindSelect) {
DeclareAndCast(StepData_SelectMember,sm,theany);
if (!sm.IsNull()) { sm->SetLogical(val); return; }
}
Clear(KindLogical);
if (val == StepData_LFalse) theint = 0;
if (val == StepData_LTrue) theint = 1;
if (val == StepData_LUnknown) theint = 2;
}
void StepData_Field::SetReal (const Standard_Real val)
{
if (thekind == KindSelect) {
DeclareAndCast(StepData_SelectMember,sm,theany);
if (!sm.IsNull()) { sm->SetReal(val); return; }
}
Clear(KindReal);
thereal = val;
}
void StepData_Field::SetString (const Standard_CString val)
{
if (thekind == KindSelect) {
DeclareAndCast(StepData_SelectMember,sm,theany);
if (!sm.IsNull()) { sm->SetString (val); return; }
}
if (thekind != KindEnum) Clear(KindString);
theany = new TCollection_HAsciiString(val);
}
void StepData_Field::SetEnum
(const Standard_Integer val, const Standard_CString text)
{
Clear(KindEnum);
SetInt(val);
if (text && text[0] != '\0') SetString(text);
}
void StepData_Field::SetSelectMember
(const Handle(StepData_SelectMember)& val)
{
if (val.IsNull()) return;
Clear (KindSelect);
theany = val;
}
void StepData_Field::SetEntity (const Handle(Standard_Transient)& val)
{ Clear(KindEntity); theany = val; }
void StepData_Field::SetEntity ()
{ Handle(Standard_Transient) nulent; SetEntity(nulent); }
void StepData_Field::SetList
(const Standard_Integer size, const Standard_Integer first)
{
// ATTENTION, on ne traite pas l agrandissement ...
theint = size; thereal = 0.0; theany.Nullify(); // ?? agrandissement ??
switch (thekind) {
case KindInteger :
case KindBoolean :
case KindLogical : theany = new TColStd_HArray1OfInteger(first,first+size-1);
break;
case KindReal : theany = new TColStd_HArray1OfReal (first,first+size-1);
break;
case KindEnum :
case KindString : theany = new Interface_HArray1OfHAsciiString (first,first+size-1);
break;
// default : en particulier si "non specifie" (any)
default : theany = new TColStd_HArray1OfTransient(first,first+size-1);
}
if (thekind == 0) thekind = KindAny;
thekind |= KindList;
}
void StepData_Field::SetList2
(const Standard_Integer siz1, const Standard_Integer siz2,
const Standard_Integer f1, const Standard_Integer f2)
{
// ATTENTION, on ne traite pas l agrandissement ...
theint = siz1; thereal = Standard_Real(siz2); theany.Nullify();
Standard_Integer kind = thekind;
if (thekind == KindSelect) {
DeclareAndCast(StepData_SelectMember,sm,theany);
if (!sm.IsNull()) kind = sm->Kind();
}
switch (kind) {
case KindInteger :
case KindBoolean :
case KindLogical : theany = new TColStd_HArray2OfInteger(f1,f1+siz1-1,f2,f2+siz2-1);
break;
case KindReal : theany = new TColStd_HArray2OfReal (f1,f1+siz1-1,f2,f2+siz2-1);
break;
case KindEnum :
case KindString : theany = new TColStd_HArray2OfTransient (f1,f1+siz1-1,f2,f2+siz2-1);
break;
// default : en particulier si "non specifie" (any)
default : theany = new TColStd_HArray2OfTransient(f1,f1+siz1-1,f2,f2+siz2-1);
}
if (thekind == 0) thekind = KindAny;
thekind |= KindList2;
}
void StepData_Field::Set (const Handle(Standard_Transient)& val)
{
Standard_Integer kind = thekind;
Clear(); theany = val;
if (val.IsNull()) return;
if (val->IsKind(STANDARD_TYPE(TCollection_HAsciiString)))
{ thekind = KindString; return; }
DeclareAndCast(StepData_SelectMember,sm,val);
if (!sm.IsNull()) { thekind = KindSelect; return; }
DeclareAndCast(TColStd_HArray1OfInteger,hi,val);
if (!hi.IsNull())
{ if (kind == 0) kind = KindInteger;
thekind = kind | KindList; theint = hi->Length(); return; }
DeclareAndCast(TColStd_HArray1OfReal,hr,val);
if (!hr.IsNull())
{ thekind = KindReal | KindList; theint = hr->Length(); return; }
DeclareAndCast(Interface_HArray1OfHAsciiString,hs,val);
if (!hs.IsNull())
{ thekind = KindString | KindList; theint = hs->Length(); return; }
DeclareAndCast(TColStd_HArray1OfTransient,ht,val);
if (!ht.IsNull())
{ if (kind == 0) kind = KindAny;
thekind = kind | KindList; theint = ht->Length(); return; }
DeclareAndCast(TColStd_HArray2OfInteger,hi2,val);
if (!hi2.IsNull())
{ if (kind == 0) kind = KindInteger;
thekind = kind | KindList2; theint = hi2->ColLength();
thereal = Standard_Real(hi2->RowLength()); return; }
DeclareAndCast(TColStd_HArray2OfReal,hr2,val);
if (!hr2.IsNull())
{ thekind = KindInteger | KindList2; theint = hr2->ColLength();
thereal = Standard_Real(hi2->RowLength()); return; }
DeclareAndCast(TColStd_HArray2OfTransient,ht2,val);
if (!ht2.IsNull())
{ if (kind == 0) kind = KindAny;
thekind = kind | KindList2; theint = ht2->ColLength();
thereal = Standard_Real(hi2->RowLength()); return; }
}
void StepData_Field::ClearItem (const Standard_Integer num)
{
DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
if (!ht.IsNull()) ht->ChangeValue(num).Nullify();
DeclareAndCast(Interface_HArray1OfHAsciiString,hs,theany);
if (!hs.IsNull()) hs->ChangeValue(num).Nullify();
}
void StepData_Field::SetInt
(const Standard_Integer num, const Standard_Integer val, const Standard_Integer kind)
{
DeclareAndCast(TColStd_HArray1OfInteger,hi,theany);
if (!hi.IsNull()) { hi->SetValue(num,val); return; }
// Si deja commence sur autre chose, changer et mettre des select
DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
if (ht.IsNull()) return; // yena erreur, ou alors OfReal
thekind = KindAny | KindList;
DeclareAndCast(StepData_SelectMember,sm,ht->Value(num));
if (sm.IsNull()) { sm = new StepData_SelectInt; ht->SetValue(num,sm); }
sm->SetKind(kind); sm->SetInt (val);
}
void StepData_Field::SetInteger
(const Standard_Integer num, const Standard_Integer val)
{ SetInt (num,val,KindInteger); }
void StepData_Field::SetBoolean
(const Standard_Integer num, const Standard_Boolean val)
{ SetInt (num, (val ? 1 : 0),KindBoolean); }
void StepData_Field::SetLogical
(const Standard_Integer num, const StepData_Logical val)
{
if (val == StepData_LFalse) SetInt (num, 0,KindLogical);
if (val == StepData_LTrue) SetInt (num, 1,KindLogical);
if (val == StepData_LUnknown) SetInt (num, 2,KindLogical);
}
void StepData_Field::SetEnum
(const Standard_Integer num, const Standard_Integer val, const Standard_CString text)
{
DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
if (ht.IsNull()) { SetInteger (num,val); return; }
DeclareAndCast(StepData_SelectMember,sm,ht->Value(num));
thekind = KindAny | KindList;
if (sm.IsNull()) { sm = new StepData_SelectNamed; ht->SetValue(num,sm); }
sm->SetEnum (val,text);
}
void StepData_Field::SetReal
(const Standard_Integer num, const Standard_Real val)
{
DeclareAndCast(TColStd_HArray1OfReal,hr,theany);
if (!hr.IsNull()) { hr->SetValue(num,val); return; }
// Si deja commence sur autre chose, changer et mettre des select
DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
if (ht.IsNull()) return; // yena erreur, ou alors OfInteger
thekind = KindAny | KindList;
DeclareAndCast(StepData_SelectMember,sm,ht->Value(num));
if (sm.IsNull()) { sm = new StepData_SelectReal; ht->SetValue(num,sm); }
sm->SetReal (val);
}
void StepData_Field::SetString
(const Standard_Integer num, const Standard_CString val)
{
DeclareAndCast(Interface_HArray1OfHAsciiString,hs,theany);
if (!hs.IsNull()) { hs->SetValue (num,new TCollection_HAsciiString(val)); return; }
// et si OfInteger ou OfReal ?
DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
if ( ht.IsNull()) return;
thekind = KindAny | KindList;
ht->SetValue (num,new TCollection_HAsciiString(val));
}
void StepData_Field::SetEntity
(const Standard_Integer num, const Handle(Standard_Transient)& val)
{
DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
if (!ht.IsNull()) { ht->SetValue (num,val); return; }
DeclareAndCast(TColStd_HArray1OfInteger,hi,theany);
if (!hi.IsNull()) {
Standard_Integer low = hi->Lower(), up = hi->Upper();
Handle(TColStd_HArray1OfTransient) ht = new TColStd_HArray1OfTransient(low,up);
Handle(StepData_SelectMember) sm;
Standard_Integer kind = Kind();
for (Standard_Integer i = low; i <= up; i ++) {
if (i == num) ht->SetValue(i,val);
else {
sm = new StepData_SelectInt;
sm->SetKind(kind); sm->SetInt(hi->Value(i));
ht->SetValue(i,sm);
}
}
thekind = KindAny | KindList;
return;
}
DeclareAndCast(TColStd_HArray1OfReal,hr,theany);
if (!hr.IsNull()) {
Standard_Integer low = hr->Lower(), up = hr->Upper();
Handle(TColStd_HArray1OfTransient) ht = new TColStd_HArray1OfTransient(low,up);
Handle(StepData_SelectMember) sm;
for (Standard_Integer i = low; i <= up; i ++) {
if (i == num) ht->SetValue(i,val);
else {
sm = new StepData_SelectReal;
sm->SetReal(hr->Value(i));
ht->SetValue(i,sm);
}
}
thekind = KindAny | KindList;
return;
}
DeclareAndCast(Interface_HArray1OfHAsciiString,hs,theany);
if (!hs.IsNull()) {
Standard_Integer low = hs->Lower(), up = hs->Upper();
Handle(TColStd_HArray1OfTransient) ht = new TColStd_HArray1OfTransient(low,up);
for (Standard_Integer i = low; i <= up; i ++) {
if (i == num) ht->SetValue(i,val);
else ht->SetValue(i,hs->Value(i));
}
thekind = KindAny | KindList;
return;
}
}
// QUERIES
Standard_Boolean StepData_Field::IsSet
(const Standard_Integer n1, const Standard_Integer n2) const
{
if (thekind == 0) return Standard_False;
if (thekind == KindSelect) {
DeclareAndCast(StepData_SelectMember,sm,theany);
if (sm.IsNull()) return Standard_False;
return (sm->Kind() != 0);
}
if ((thekind & KindArity) == KindList) {
DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
if (!ht.IsNull()) return (!ht->Value(n1).IsNull());
DeclareAndCast(Interface_HArray1OfHAsciiString,hs,theany);
if (!hs.IsNull()) return (!hs->Value(n1).IsNull());
}
if ((thekind & KindArity) == KindList2) {
DeclareAndCast(TColStd_HArray2OfTransient,ht,theany);
if (!ht.IsNull()) return (!ht->Value(n1,n2).IsNull());
}
return Standard_True;
}
Standard_Integer StepData_Field::ItemKind
(const Standard_Integer n1, const Standard_Integer n2) const
{
if ((thekind & KindArity) == 0) return Kind(Standard_True);
Standard_Integer kind = TrueKind(thekind); // si Any, evaluer ...
if (kind != KindAny) return kind;
// Sinon, chercher un Transient
Handle(Standard_Transient) item;
if ((thekind & KindArity) == KindList) {
DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
if (!ht.IsNull()) return kind;
item = ht->Value(n1);
} else if ((thekind & KindArity) == KindList2) {
DeclareAndCast(TColStd_HArray2OfTransient,ht,theany);
if (!ht.IsNull()) return kind;
item = ht->Value(n1,n2);
}
if (item.IsNull()) return 0;
if (item->IsKind(STANDARD_TYPE(TCollection_HAsciiString))) return KindString;
DeclareAndCast(StepData_SelectMember,sm,item);
if (sm.IsNull()) return KindEntity;
return sm->Kind();
}
Standard_Integer StepData_Field::Kind (const Standard_Boolean type) const
{
if (!type) return thekind;
if (thekind == KindSelect) {
DeclareAndCast(StepData_SelectMember,sm,theany);
if (!sm.IsNull()) return TrueKind(sm->Kind());
}
return TrueKind (thekind);
}
Standard_Integer StepData_Field::Arity () const
{ return (thekind & KindArity) >> ShiftArity; }
Standard_Integer StepData_Field::Length (const Standard_Integer index) const
{
if ((thekind & KindArity) == KindList) return theint;
if ((thekind & KindArity) == KindList2) {
if (index == 2) return Standard_Integer (thereal);
else return theint;
}
return 0;
}
Standard_Integer StepData_Field::Lower (const Standard_Integer index) const
{
if ((thekind & KindArity) == KindList) {
DeclareAndCast(TColStd_HArray1OfInteger,hi,theany);
if (!hi.IsNull()) return hi->Lower();
DeclareAndCast(TColStd_HArray1OfReal,hr,theany);
if (!hr.IsNull()) return hr->Lower();
DeclareAndCast(Interface_HArray1OfHAsciiString,hs,theany);
if (!hs.IsNull()) return hs->Lower();
DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
if (!ht.IsNull()) return ht->Lower();
}
if ((thekind & KindArity) == KindList2) {
DeclareAndCast(TColStd_HArray2OfTransient,ht,theany);
if ( ht.IsNull()) return 0;
if (index == 1) return ht->LowerCol();
if (index == 2) return ht->LowerRow();
}
return 0;
}
Standard_Integer StepData_Field::Int () const
{ return theint; }
Standard_Integer StepData_Field::Integer
(const Standard_Integer n1, const Standard_Integer n2) const
{
if ((thekind & KindArity) == 0) {
if (thekind == KindSelect) {
DeclareAndCast(StepData_SelectMember,sm,theany);
if (!sm.IsNull()) return sm->Int();
}
return theint;
}
if ((thekind & KindArity) == KindList) {
DeclareAndCast(TColStd_HArray1OfInteger,hi,theany);
if (!hi.IsNull()) return hi->Value(n1);
DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
if (ht.IsNull()) return 0;
DeclareAndCast(StepData_SelectMember,sm,ht->Value(n1));
if (!sm.IsNull()) return sm->Int();
}
if ((thekind & KindArity) == KindList2) {
DeclareAndCast(TColStd_HArray2OfTransient,ht,theany);
if (ht.IsNull()) return 0;
DeclareAndCast(StepData_SelectMember,sm,ht->Value(n1,n2));
if (!sm.IsNull()) return sm->Int();
}
return 0;
}
Standard_Boolean StepData_Field::Boolean
(const Standard_Integer n1, const Standard_Integer n2) const
{ return (Integer(n1,n2) > 0); }
StepData_Logical StepData_Field::Logical
(const Standard_Integer n1, const Standard_Integer n2) const
{
Standard_Integer ival = Integer(n1,n2);
if (ival == 0) return StepData_LFalse;
if (ival == 1) return StepData_LTrue;
return StepData_LUnknown;
}
Standard_Real StepData_Field::Real
(const Standard_Integer n1, const Standard_Integer n2) const
{
if ((thekind & KindArity) == 0) {
if (thekind == KindSelect) {
DeclareAndCast(StepData_SelectMember,sm,theany);
if (!sm.IsNull()) return sm->Real();
}
return thereal;
}
if ((thekind & KindArity) == KindList) {
DeclareAndCast(TColStd_HArray1OfReal,hr,theany);
if (!hr.IsNull()) return hr->Value(n1);
DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
if (ht.IsNull()) return 0;
DeclareAndCast(StepData_SelectMember,sm,ht->Value(n1));
if (!sm.IsNull()) return sm->Real();
}
if ((thekind & KindArity) == KindList2) {
DeclareAndCast(TColStd_HArray2OfReal,hr,theany);
if (!hr.IsNull()) return hr->Value(n1,n2);
DeclareAndCast(TColStd_HArray2OfTransient,ht,theany);
if (ht.IsNull()) return 0;
DeclareAndCast(StepData_SelectMember,sm,ht->Value(n1,n2));
if (!sm.IsNull()) return sm->Int();
}
return 0.0;
}
Standard_CString StepData_Field::String
(const Standard_Integer n1, const Standard_Integer n2) const
{
if (thekind == KindString || thekind == KindEnum) {
DeclareAndCast(TCollection_HAsciiString,str,theany);
if (!str.IsNull()) return str->ToCString();
else return "";
}
if (thekind == KindSelect) {
DeclareAndCast(StepData_SelectMember,sm,theany);
if (!sm.IsNull()) return sm->String();
}
if ((thekind & KindArity) == KindList) {
DeclareAndCast(Interface_HArray1OfHAsciiString,hs,theany);
if (!hs.IsNull()) {
if (hs->Value(n1).IsNull()) return "";
else return hs->Value(n1)->ToCString();
}
DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
if (ht.IsNull()) return "";
DeclareAndCast(TCollection_HAsciiString,str,ht->Value(n1));
if (!str.IsNull()) return str->ToCString();
DeclareAndCast(StepData_SelectMember,sm,ht->Value(n1));
if (!sm.IsNull()) return sm->String();
}
if ((thekind & KindArity) == KindList2) {
DeclareAndCast(TColStd_HArray2OfTransient,ht,theany);
if (ht.IsNull()) return "";
DeclareAndCast(TCollection_HAsciiString,str,ht->Value(n1,n2));
if (!str.IsNull()) return str->ToCString();
DeclareAndCast(StepData_SelectMember,sm,ht->Value(n1,n2));
if (!sm.IsNull()) return sm->String();
}
return "";
}
Standard_Integer StepData_Field::Enum
(const Standard_Integer n1, const Standard_Integer n2) const
{ return Integer(n1,n2); }
Standard_CString StepData_Field::EnumText
(const Standard_Integer n1, const Standard_Integer n2) const
{ return String (n1,n2); }
Handle(Standard_Transient) StepData_Field::Entity
(const Standard_Integer n1, const Standard_Integer n2) const
{
Handle(Standard_Transient) nulval; // null handle
if ((thekind & KindArity) == 0) {
if (thekind == KindEntity) return theany;
return nulval;
}
if ((thekind & KindArity) == KindList) {
DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
if (ht.IsNull()) return nulval;
nulval = ht->Value(n1);
if (nulval.IsNull()) return nulval;
if (nulval->IsKind(STANDARD_TYPE(StepData_SelectMember)) ||
nulval->IsKind(STANDARD_TYPE(TCollection_HAsciiString)) )
nulval.Nullify();
return nulval;
}
if ((thekind & KindArity) == KindList2) {
DeclareAndCast(TColStd_HArray2OfTransient,ht,theany);
if (ht.IsNull()) return nulval;
nulval = ht->Value(n1,n2);
if (nulval.IsNull()) return nulval;
if (nulval->IsKind(STANDARD_TYPE(StepData_SelectMember))
|| nulval->IsKind(STANDARD_TYPE(TCollection_HAsciiString)) )
nulval.Nullify();
return nulval;
}
return nulval;
}
Handle(Standard_Transient) StepData_Field::Transient () const
{ return theany; }

View File

@@ -0,0 +1,44 @@
-- File: StepData_FieldList.cdl
-- Created: Tue Apr 1 13:11:37 1997
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class FieldList from StepData
---Purpose : Describes a list of fields, in a general way
-- This basic class is for a null size list
-- Subclasses are for 1, N (fixed) or Dynamic sizes
uses Field from StepData, EntityIterator from Interface
raises OutOfRange
is
Create returns FieldList;
---Purpose : Creates a FieldList of 0 Field
NbFields (me) returns Integer is virtual;
---Purpose : Returns the count of fields. Here, returns 0
Field (me; num : Integer) returns Field
---Purpose : Returns the field n0 <num> between 1 and NbFields (read only)
raises OutOfRange
-- Error if <num> out of range
is virtual;
---C++ : return const &
CField (me : in out; num : Integer) returns Field
---Purpose : Returns the field n0 <num> between 1 and NbFields, in order to
-- modify its content
raises OutOfRange
-- Error if <num> out of range
is virtual;
---C++ : return &
FillShared (me; iter : in out EntityIterator);
---Purpose : Fills an iterator with the entities shared by <me>
end FieldList;

View File

@@ -0,0 +1,38 @@
#include <StepData_FieldList.ixx>
#include <Standard_OutOfRange.hxx>
static StepData_Field nulfild;
StepData_FieldList::StepData_FieldList () { }
Standard_Integer StepData_FieldList::NbFields () const
{ return 0; }
const StepData_Field& StepData_FieldList::Field (const Standard_Integer num) const
{
Standard_OutOfRange::Raise("StepData_FieldList : Field");
return nulfild;
}
StepData_Field& StepData_FieldList::CField (const Standard_Integer num)
{
Standard_OutOfRange::Raise("StepData_FieldList : CField");
return nulfild;
}
void StepData_FieldList::FillShared (Interface_EntityIterator& iter) const
{
Standard_Integer i, nb = NbFields();
for (i = 1; i <= nb; i ++) {
const StepData_Field& fi = Field(i);
if (fi.Kind() != 7) continue; // KindEntity
Standard_Integer i1,i2, nb1 = 1, nb2 = 1, ari = fi.Arity();
if (ari == 1) nb1 = fi.Length();
if (ari == 2) { nb1 = fi.Length(1); nb2 = fi.Length(2); }
for (i1 = 1; i1 <= nb1; i1 ++)
for (i2 = 1; i2 <= nb2; i2 ++)
iter.AddItem (fi.Entity(i1,i2));
}
}

View File

@@ -0,0 +1,46 @@
-- File: StepData_FieldList1.cdl
-- Created: Tue Apr 1 13:18:59 1997
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class FieldList1 from StepData inherits FieldList from StepData
---Purpose : Describes a list of ONE field
uses Field from StepData
raises OutOfRange
is
Create returns FieldList1;
---Purpose : Creates a FieldList of 1 Field
NbFields (me) returns Integer is redefined;
---Purpose : Returns the count of fields. Here, returns 1
Field (me; num : Integer) returns Field
---Purpose : Returns the field n0 <num> between 1 and NbFields (read only)
raises OutOfRange
-- Error if <num> out of range
is redefined;
---C++ : return const &
CField (me : in out; num : Integer) returns Field
---Purpose : Returns the field n0 <num> between 1 and NbFields, in order to
-- modify its content
raises OutOfRange
-- Error if <num> out of range
is redefined;
---C++ : return &
Destroy (me: in out) is virtual;
---C++ : alias "Standard_EXPORT virtual ~StepData_FieldList1() { Destroy(); }"
fields
thefield : Field from StepData;
end FieldList1;

View File

@@ -0,0 +1,23 @@
#include <StepData_FieldList1.ixx>
#include <Standard_OutOfRange.hxx>
StepData_FieldList1::StepData_FieldList1 () { }
Standard_Integer StepData_FieldList1::NbFields () const
{ return 1; }
const StepData_Field& StepData_FieldList1::Field (const Standard_Integer num) const
{
if (num != 1) Standard_OutOfRange::Raise("StepData_FieldList1 : Field");
return thefield;
}
StepData_Field& StepData_FieldList1::CField (const Standard_Integer num)
{
if (num != 1) Standard_OutOfRange::Raise("StepData_FieldList1 : CField");
return thefield;
}
void StepData_FieldList1::Destroy () {}

View File

@@ -0,0 +1,52 @@
-- File: StepData_FieldListD.cdl
-- Created: Tue Apr 1 13:25:35 1997
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class FieldListD from StepData inherits FieldList from StepData
---Purpose : Describes a list of fields, in a general way
-- This basic class is for a null size list
-- Subclasses are for 1, N (fixed) or Dynamic sizes
uses Field from StepData, HArray1OfField from StepData
raises OutOfRange
is
Create (nb : Integer) returns FieldListD;
---Purpose : Creates a FieldListD of <nb> Fields
SetNb (me : in out; nb : Integer);
---Purpose : Sets a new count of Fields. Former contents are lost
NbFields (me) returns Integer is redefined;
---Purpose : Returns the count of fields. Here, returns starting <nb>
Field (me; num : Integer) returns Field
---Purpose : Returns the field n0 <num> between 1 and NbFields (read only)
raises OutOfRange
-- Error if <num> out of range
is redefined;
---C++ : return const &
CField (me : in out; num : Integer) returns Field
---Purpose : Returns the field n0 <num> between 1 and NbFields, in order to
-- modify its content
raises OutOfRange
-- Error if <num> out of range
is redefined;
---C++ : return &
Destroy (me: in out) is virtual;
---C++ : alias "Standard_EXPORT virtual ~StepData_FieldListD() { Destroy(); }"
fields
thefields : HArray1OfField;
end FieldListD;

View File

@@ -0,0 +1,30 @@
#include <StepData_FieldListD.ixx>
#include <Standard_OutOfRange.hxx>
StepData_FieldListD::StepData_FieldListD (const Standard_Integer nb)
{ if (nb > 0) thefields = new StepData_HArray1OfField (1,nb); }
void StepData_FieldListD::SetNb (const Standard_Integer nb)
{
thefields.Nullify();
if (nb > 0) thefields = new StepData_HArray1OfField (1,nb);
}
Standard_Integer StepData_FieldListD::NbFields () const
{ return (thefields.IsNull() ? 0 : thefields->Length()); }
const StepData_Field& StepData_FieldListD::Field (const Standard_Integer num) const
{
if (thefields.IsNull()) Standard_OutOfRange::Raise("StepData_FieldListD::Field");
return thefields->Value(num);
}
StepData_Field& StepData_FieldListD::CField (const Standard_Integer num)
{
if (thefields.IsNull()) Standard_OutOfRange::Raise("StepData_FieldListD::Field");
return thefields->ChangeValue(num);
}
void StepData_FieldListD::Destroy () {}

View File

@@ -0,0 +1,49 @@
-- File: StepData_FieldListN.cdl
-- Created: Tue Apr 1 13:21:43 1997
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class FieldListN from StepData inherits FieldList from StepData
---Purpose : Describes a list of fields, in a general way
-- This basic class is for a null size list
-- Subclasses are for 1, N (fixed) or Dynamic sizes
uses Field from StepData, Array1OfField from StepData
raises OutOfRange
is
Create (nb : Integer) returns FieldListN;
---Purpose : Creates a FieldListN of <nb> Fields
NbFields (me) returns Integer is redefined;
---Purpose : Returns the count of fields. Here, returns starting <nb>
Field (me; num : Integer) returns Field
---Purpose : Returns the field n0 <num> between 1 and NbFields (read only)
raises OutOfRange
-- Error if <num> out of range
is redefined;
---C++ : return const &
CField (me : in out; num : Integer) returns Field
---Purpose : Returns the field n0 <num> between 1 and NbFields, in order to
-- modify its content
raises OutOfRange
-- Error if <num> out of range
is redefined;
---C++ : return &
Destroy (me: in out) is virtual;
---C++ : alias "Standard_EXPORT virtual ~StepData_FieldListN() { Destroy(); }"
fields
thefields : Array1OfField;
end FieldListN;

View File

@@ -0,0 +1,22 @@
#include <StepData_FieldListN.ixx>
#include <Standard_OutOfRange.hxx>
StepData_FieldListN::StepData_FieldListN (const Standard_Integer nb)
: thefields ( (nb == 0 ? 0 : 1),nb) { }
Standard_Integer StepData_FieldListN::NbFields () const
{ return thefields.Upper(); }
const StepData_Field& StepData_FieldListN::Field (const Standard_Integer num) const
{
return thefields.Value(num);
}
StepData_Field& StepData_FieldListN::CField (const Standard_Integer num)
{
return thefields.ChangeValue(num);
}
void StepData_FieldListN::Destroy() {}

View File

@@ -0,0 +1,59 @@
-- File: StepData_FileProtocol.cdl
-- Created: Fri Jul 23 10:13:04 1993
-- Author: Christian CAILLET
-- <cky@meteox>
---Copyright: Matra Datavision 1993
class FileProtocol from StepData inherits Protocol from StepData
---Purpose : A FileProtocol is defined as the addition of several already
-- existing Protocols. It corresponds to the definition of a
-- SchemaName with several Names, each one being attached to a
-- specific Protocol. Thus, a File defined with a compound Schema
-- is processed as any other one, once built the equivalent
-- compound Protocol, a FileProtocol
uses Type, CString, SequenceOfTransient,
Graph from Interface, Check from Interface,
Protocol from Interface, Protocol from StepData
is
Create returns mutable FileProtocol;
---Purpose : Creates an empty FileProtocol
Add (me : mutable; protocol : Protocol from StepData);
---Purpose : Adds a Protocol to the definition list of the FileProtocol
-- But ensures that each class of Protocol is present only once
-- in this list
NbResources (me) returns Integer is redefined;
---Purpose : Gives the count of Protocols used as Resource (can be zero)
-- i.e. the count of Protocol recorded by calling the method Add
Resource (me; num : Integer) returns Protocol from Interface is redefined;
---Purpose : Returns a Resource, given a rank. Here, rank of calling Add
TypeNumber (me; atype : any Type) returns Integer is redefined;
---Purpose : Returns a Case Number, specific of each recognized Type
-- Here, NO Type at all is recognized properly : all Types are
-- recognized by the resources
GlobalCheck (me; G : Graph; ach : in out Check)
returns Boolean is redefined;
---Purpose : Calls GlobalCheck for each of its recorded ressources
-- -- Specific for StepData -- --
SchemaName (me) returns CString is redefined;
---Purpose : Returns the Schema Name attached to each class of Protocol
-- To be redefined by each sub-class
-- Here, SchemaName returns "" (empty String)
-- was C++ : return const
fields
thecomps : SequenceOfTransient;
end FileProtocol;

View File

@@ -0,0 +1,48 @@
#include <StepData_FileProtocol.ixx>
//static TCollection_AsciiString thename("");
static Standard_CString thename = "";
// Protocol fabrique a la demande avec d autres Protocoles
StepData_FileProtocol::StepData_FileProtocol () { }
void StepData_FileProtocol::Add (const Handle(StepData_Protocol)& protocol)
{
if (protocol.IsNull()) return;
Handle(Standard_Type) ptype = protocol->DynamicType();
Standard_Integer nb = thecomps.Length();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (thecomps.Value(i)->IsInstance(ptype)) return;
}
thecomps.Append(protocol);
}
Standard_Integer StepData_FileProtocol::NbResources () const
{ return thecomps.Length(); }
Handle(Interface_Protocol) StepData_FileProtocol::Resource
(const Standard_Integer num) const
{ return Handle(Interface_Protocol)::DownCast(thecomps.Value(num)); }
Standard_Integer StepData_FileProtocol::TypeNumber
(const Handle(Standard_Type)& atype) const
{ return 0; }
Standard_Boolean StepData_FileProtocol::GlobalCheck(const Interface_Graph& G,
Handle(Interface_Check)& ach) const
{
Standard_Boolean res = Standard_False;
Standard_Integer i,nb = NbResources();
for (i = 1; i <= nb; i ++) res |= Resource(i)->GlobalCheck (G,ach);
return res;
}
Standard_CString StepData_FileProtocol::SchemaName () const
{ return thename; }

View File

@@ -0,0 +1,82 @@
-- File: StepData_FreeFormEntity.cdl
-- Created: Fri Jan 3 10:51:01 1997
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class FreeFormEntity from StepData inherits TShared
---Purpose : A Free Form Entity allows to record any kind of STEP
-- parameters, in any way of typing
-- It is implemented with an array of fields
-- A Complex entity can be defined, as a chain of FreeFormEntity
-- (see Next and As)
uses CString, AsciiString from TCollection,
HSequenceOfAsciiString from TColStd,
Field from StepData, HArray1OfField from StepData
is
Create returns mutable FreeFormEntity;
---Purpose : Creates a FreeFormEntity, with no field, no type
SetStepType (me : mutable; typenam : CString);
---Purpose : Sets the type of an entity
-- For a complex one, the type of this member
StepType (me) returns CString;
---Purpose : Returns the recorded StepType
-- For a complex one, the type of this member
SetNext (me : mutable; next : FreeFormEntity; last : Boolean = Standard_True);
---Purpose : Sets a next member, in order to define or complete a Complex
-- entity
-- If <last> is True (D), this next will be set as last of list
-- Else, it is inserted just as next of <me>
-- If <next> is Null, Next is cleared
Next (me) returns FreeFormEntity;
---Purpose : Returns the next member of a Complex entity
-- (remark : the last member has none)
IsComplex (me) returns Boolean;
---Purpose : Returns True if a FreeFormEntity is Complex (i.e. has Next)
Typed (me; typenam : CString) returns FreeFormEntity;
---Purpose : Returns the member of a FreeFormEntity of which the type name
-- is given (exact match, no sub-type)
TypeList (me) returns HSequenceOfAsciiString;
---Purpose : Returns the list of types (one type for a simple entity),
-- as is (non reordered)
Reorder (myclass; ent : in out mutable FreeFormEntity) returns Boolean;
---Purpose : Reorders a Complex entity if required, i.e. if member types
-- are not in alphabetic order
-- Returns False if nothing done (order was OK or simple entity),
-- True plus modified <ent> if <ent> has been reordered
SetNbFields (me : mutable; nb : Integer);
---Purpose : Sets a count of Fields, from scratch
NbFields (me) returns Integer;
---Purpose : Returns the count of fields
Field (me; num : Integer) returns Field;
---Purpose : Returns a field from its rank, for read-only use
---C++ : return const &
CField (me : mutable; num : Integer) returns Field;
---Purpose : Returns a field from its rank, in order to modify it
---C++ : return &
fields
thetype : AsciiString from TCollection;
thefields : HArray1OfField;
thenext : FreeFormEntity;
end FreeFormEntity;

View File

@@ -0,0 +1,107 @@
#include <StepData_FreeFormEntity.ixx>
#include <Dico_DictionaryOfTransient.hxx>
#include <Dico_IteratorOfDictionaryOfTransient.hxx>
#include <Interface_Macros.hxx>
void StepData_FreeFormEntity::SetStepType (const Standard_CString typenam)
{ thetype.Clear(); thetype.AssignCat (typenam); }
Standard_CString StepData_FreeFormEntity::StepType () const
{ return thetype.ToCString(); }
void StepData_FreeFormEntity::SetNext
(const Handle(StepData_FreeFormEntity)& next, const Standard_Boolean last)
{
if (next.IsNull()) thenext.Nullify();
else if (thenext.IsNull()) thenext = next;
else if (last) thenext->SetNext(next);
else {
next->SetNext(thenext,last);
thenext = next;
}
}
Handle(StepData_FreeFormEntity) StepData_FreeFormEntity::Next () const
{ return thenext; }
Standard_Boolean StepData_FreeFormEntity::IsComplex () const
{ return (!thenext.IsNull()); }
Handle(StepData_FreeFormEntity) StepData_FreeFormEntity::Typed
(const Standard_CString typenam) const
{
Handle(StepData_FreeFormEntity) res;
if (thetype.IsEqual (typenam)) return this;
if (thenext.IsNull()) return res;
return thenext->Typed (typenam);
}
Handle(TColStd_HSequenceOfAsciiString) StepData_FreeFormEntity::TypeList
() const
{
Handle(TColStd_HSequenceOfAsciiString) li = new TColStd_HSequenceOfAsciiString();
li->Append (thetype);
Handle(StepData_FreeFormEntity) next = thenext;
while (!next.IsNull()) {
li->Append (TCollection_AsciiString (next->StepType()) );
next = next->Next();
}
return li;
}
Standard_Boolean StepData_FreeFormEntity::Reorder
(Handle(StepData_FreeFormEntity)& ent)
{
if (ent.IsNull()) return Standard_False;
if (!ent->IsComplex()) return Standard_False;
Standard_Boolean afr = Standard_False;
Handle(StepData_FreeFormEntity) e1 = ent; Handle(StepData_FreeFormEntity) e2 = ent->Next();
while (!e2.IsNull()) {
if (strcmp (e1->StepType(), e2->StepType()) > 0) { afr = Standard_True; break; }
e1 = e2; e2 = e1->Next();
}
if (!afr) return afr;
// remise en ordre avec un dictionnaire
e1 = ent; e2.Nullify();
Handle(Dico_DictionaryOfTransient) dic = new Dico_DictionaryOfTransient;
while (!e1.IsNull()) {
dic->SetItem (e1->StepType(), e1);
e1 = e1->Next();
}
// d abord effacer les next en cours ...
Dico_IteratorOfDictionaryOfTransient iter(dic);
for (iter.Start(); iter.More(); iter.Next()) {
e1 = GetCasted(StepData_FreeFormEntity,iter.Value());
if (!e1.IsNull()) e1->SetNext(e2);
}
// ... puis les remettre dans l ordre
e1.Nullify();
for (iter.Start(); iter.More(); iter.Next()) {
e2 = GetCasted(StepData_FreeFormEntity,iter.Value());
if (!e1.IsNull()) e1->SetNext(e2);
e1 = e2;
}
ent = e1;
return afr;
}
void StepData_FreeFormEntity::SetNbFields (const Standard_Integer nb)
{
if (nb <= 0) thefields.Nullify();
else thefields = new StepData_HArray1OfField (1,nb);
}
Standard_Integer StepData_FreeFormEntity::NbFields () const
{ return (thefields.IsNull() ? 0 : thefields->Length()); }
const StepData_Field& StepData_FreeFormEntity::Field
(const Standard_Integer num) const
{ return thefields->Value(num); }
StepData_Field& StepData_FreeFormEntity::CField
(const Standard_Integer num)
{ return thefields->ChangeValue(num); }

View File

@@ -0,0 +1,44 @@
-- File: StepData_GeneralModule.cdl
-- Created: Tue Feb 2 19:17:12 1993
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1993
deferred class GeneralModule from StepData
inherits GeneralModule from Interface
---Purpose : Specific features for General Services adapted to STEP
uses Transient ,
EntityIterator , CopyTool, Check, ShareTool
is
-- Reconduction because limitation cdl --
FillSharedCase (me; casenum : Integer; ent : Transient;
iter : in out EntityIterator) is deferred;
---Purpose : Specific filling of the list of Entities shared by an Entity
-- <ent>. Can use the internal utility method Share, below
CheckCase (me; casenum : Integer; ent : Transient; shares : ShareTool;
ach : in out Check) is deferred;
---Purpose : Specific Checking of an Entity <ent>
CopyCase (me; casenum : Integer;
entfrom : Transient; entto : mutable Transient;
TC : in out CopyTool) is deferred;
---Purpose : Specific Copy ("Deep") from <entfrom> to <entto> (same type)
-- by using a TransferControl which provides its working Map.
-- Use method Transferred from TransferControl to work
-- ImpliedCase (me; casenum : Integer;
-- entfrom : Transient; entto : mutable Transient;
-- TC : CopyTool);
---Purpose : Specific Copying of Implied References
-- A Default is provided which does nothing (must current case !)
-- Already copied references (by CopyFrom) must remain unchanged
-- Use method Search from TransferControl to work
end GeneralModule;

View File

@@ -0,0 +1 @@
#include <StepData_GeneralModule.ixx>

View File

@@ -0,0 +1,79 @@
-- File: StepData_HeaderTool.cdl
-- Created: Fri Jul 23 10:35:17 1993
-- Author: Christian CAILLET
-- <cky@meteox>
---Copyright: Matra Datavision 1993
class HeaderTool from StepData
---Purpose : HeaderTool exploits data from Header to build a Protocol :
-- it uses the Header Entity FileSchema to do this.
-- It builds a Protocol from the Global List of Protocols
-- stored in the Library ReaderLib
uses OStream, AsciiString from TCollection, SequenceOfAsciiString from TColStd,
StepReaderData, Protocol from StepData, FileProtocol
is
Create (data : StepReaderData) returns HeaderTool;
---Purpose : Creates a HeaderTool from data read from a File. Computes the
-- list of Schema Names. The Protocol will be computed later
-- (because there are several options)
Create (names : SequenceOfAsciiString from TColStd) returns HeaderTool;
---Purpose : Creates a HeaderTool directly from a list of Schema Names
NbSchemaNames (me) returns Integer;
---Purpose : Returns the count of SchemaNames
SchemaName (me; num : Integer) returns AsciiString from TCollection;
---Purpose : Returns a SchemaName, given its rank
---C++ : return const &
NamedProtocol (me; name : AsciiString from TCollection)
returns Protocol from StepData;
---Purpose : Returns the Protocol which corresponds to a Schema Name
-- Returns a Null Handle if this Schema Name is attached to no
-- Protocol recorded in the Global List of ReaderLib
-- Building a Protocol --
Build (me : in out; protocol : mutable FileProtocol);
---Purpose : Fills a FileProtocol with the list of Protocols attached to
-- the list of Schema Names. It can remain empty ...
Protocol (me : in out) returns Protocol from StepData;
---Purpose : Returns a Protocol computed from the list of Schema Names :
-- - a Null Handle if no SchemaName has been recognized (or list
-- empty)
-- - a single Protocol if only one SchemaName has been recognized
-- - a FileProtocol with its componants if several SchemaNames
-- have been recognized
---See also : method Ignored, to see if some SchemaNames were not
-- recognized, then they remain Ignored
IsDone (me) returns Boolean;
---Purpose : Returns True if either Build or Protocol has been called
-- If it is False, Ignored and NbIgnored should not be called
NbIgnoreds (me) returns Integer;
---Purpose : Returns the count of ignored SchemaNames (0 if all were OK)
Ignored (me; num : Integer) returns AsciiString from TCollection;
---Purpose : Returns an ignored SchemaName, given its rank in the list of
-- Ignored SchemaNames (not in the total list)
---C++ : return const &
Print (me; S : in out OStream);
---Purpose : Sends the state of the HeaderTool in a comprehensive way,
-- to an output stream
fields
thenames : SequenceOfAsciiString from TColStd;
thedone : Boolean;
theignored : SequenceOfAsciiString from TColStd;
end HeaderTool;

View File

@@ -0,0 +1,139 @@
#include <StepData_HeaderTool.ixx>
#include <Interface_ReaderLib.hxx>
#include <Interface_Protocol.hxx>
// HeaderTool prend en charge le Schema de Donnees utilise pour un Fichier
// Ce Schema peut etre compose de un ou plusieurs Protocoles, chacun etant
// designe par une String. Les Strings correspondent au type "SCHEMA_NAME"
// (typedef) et le Schema est une entite de Header de type "FILE_SCHEMA",
// il a cette forme dans le fichier :
// FILE_SCHEMA ( ( 'NAME_1' [, 'NAME_2' ...] ) );
static Interface_ReaderLib lib;
StepData_HeaderTool::StepData_HeaderTool
(const Handle(StepData_StepReaderData)& data)
{
lib.SetComplete();
thedone = Standard_False;
Standard_Integer num = 0;
while ( (num = data->FindNextRecord(num)) != 0) {
const TCollection_AsciiString& headertype = data->RecordType(num);
if (headertype == "FILE_SCHEMA") {
Standard_Integer numsub = data->SubListNumber(num,1,Standard_True);
Standard_Integer nb = data->NbParams(numsub);
for (Standard_Integer i = 1; i <= nb; i ++) {
TCollection_AsciiString unom = data->ParamCValue(numsub,i);
unom.Remove(unom.Length());
unom.Remove(1); // quotes debut et fin
thenames.Append(unom);
}
}
}
}
StepData_HeaderTool::StepData_HeaderTool
(const TColStd_SequenceOfAsciiString& names)
{
lib.SetComplete();
thedone = Standard_False;
Standard_Integer nb = names.Length();
for (Standard_Integer i = 1; i <= nb; i ++) thenames.Append(names.Value(i));
}
Standard_Integer StepData_HeaderTool::NbSchemaNames () const
{ return thenames.Length(); }
const TCollection_AsciiString& StepData_HeaderTool::SchemaName
(const Standard_Integer num) const
{ return thenames.Value(num); }
Handle(StepData_Protocol) StepData_HeaderTool::NamedProtocol
(const TCollection_AsciiString& name) const
{
Handle(StepData_Protocol) proto;
for (lib.Start(); lib.More(); lib.Next()) {
proto = Handle(StepData_Protocol)::DownCast(lib.Protocol());
if ( name.IsEqual(proto->SchemaName()) ) return proto;
}
return proto;
}
void StepData_HeaderTool::Build
(const Handle(StepData_FileProtocol)& proto)
{
thedone = Standard_True;
theignored.Clear();
Standard_Integer nb = thenames.Length();
for (Standard_Integer i = 1; i <= nb; i ++) {
Handle(StepData_Protocol) unproto = NamedProtocol(thenames.Value(i));
if (unproto.IsNull()) theignored.Append(thenames.Value(i));
else proto->Add(unproto);
}
}
Handle(StepData_Protocol) StepData_HeaderTool::Protocol ()
{
thedone = Standard_True;
theignored.Clear();
Handle(StepData_Protocol) unproto;
if (thenames.IsEmpty()) return unproto;
if (thenames.Length() == 1) {
unproto = NamedProtocol (thenames.Value(1));
if (unproto.IsNull()) theignored.Append (thenames.Value(1));
return unproto;
}
Handle(StepData_FileProtocol) proto = new StepData_FileProtocol;
Build(proto);
return proto;
}
Standard_Boolean StepData_HeaderTool::IsDone () const
{ return thedone; }
Standard_Integer StepData_HeaderTool::NbIgnoreds () const
{ return theignored.Length(); }
const TCollection_AsciiString& StepData_HeaderTool::Ignored
(const Standard_Integer num) const
{ return theignored.Value(num); }
void StepData_HeaderTool::Print (Standard_OStream& S) const
{
Standard_Integer nb = thenames.Length();
Standard_Integer lng = 0; Standard_Integer ln1;
S << " --- StepData_HeaderTool : List of Protocol Names --- Count : "
<< nb << endl;
Standard_Integer i; // svv Jan11 2000 : porting on DEC
for (i = 1; i <= nb; i ++) {
ln1 = thenames.Value(i).Length() + 8; lng += ln1;
if (lng > 80) { S << endl; lng = ln1; }
S << " " << i << " : " << thenames.Value(i);
}
if (lng == 0) S << endl;
nb = theignored.Length();
if (!thedone) {
S << " --- Evaluation of Protocol not Done ---" << endl;
} else if (nb == 0) {
S << " --- All Names correspond to a known Protocol ---" << endl;
} else {
lng = ln1 = 0;
S << " --- Among them, " << nb << " remain unrecognized ---" << endl;
for (i = 1; i <= nb; i ++) {
ln1 = theignored.Value(i).Length() + 3; lng += ln1;
if (lng > 80) { S << endl; lng = ln1; }
S << " : " << theignored.Value(i);
}
if (lng == 0) S << endl;
}
}

209
src/StepData/StepData_PDescr.cdl Executable file
View File

@@ -0,0 +1,209 @@
-- File: StepData_PDescr.cdl
-- Created: Fri Jan 3 11:08:27 1997
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class PDescr from StepData inherits TShared
---Purpose : This class is intended to describe the authorized form for a
-- parameter, as a type or a value for a field
--
-- A PDescr firstly describes a type, which can be SELECT, i.e.
-- have several members
uses CString, Type from Standard, AsciiString from TCollection,
Check from Interface,
EnumTool from StepData, Field from StepData, EDescr from StepData
is
Create returns PDescr;
SetName (me : mutable; name : CString);
Name (me) returns CString;
-- basic settings
Kind (me) returns Integer is private;
SetSelect (me : mutable);
---Purpose : Declares this PDescr to be a Select, hence to have members
-- <me> itself can be the first member
AddMember (me : mutable; member : PDescr);
---Purpose : Adds a member to a SELECT description
SetMemberName (me : mutable; memname : CString);
---Purpose : Sets a name for SELECT member. To be used if a member is for
-- an immediate type
SetInteger (me : mutable);
---Purpose : Sets <me> for an Integer value
SetReal (me : mutable);
---Purpose : Sets <me> for a Real value
SetString (me : mutable);
---Purpose : Sets <me> for a String value
SetBoolean (me : mutable);
---Purpose : Sets <me> for a Boolean value (false,true)
SetLogical (me : mutable);
---Purpose : Sets <me> for a Logical value (false,true,unknown)
SetEnum (me : mutable);
---Purpose : Sets <me> for an Enum value
-- Then, call AddEnumDef ordered from the first one (value 0)
AddEnumDef (me : mutable; enumdef : CString);
---Purpose : Adds an enum value as a string
SetType (me : mutable; atype : Type from Standard);
---Purpose : Sets <me> for an Entity which must match a Type (early-bound)
SetDescr (me : mutable; dscnam : CString);
---Purpose : Sets <me> for a Described Entity, whose Description must match
-- the type name <dscnam>
AddArity (me : mutable; arity : Integer = 1);
---Purpose : Adds an arity count to <me>, by default 1
-- 1 : a simple field passes to a LIST/ARRAY etc
-- or a LIST to a LIST OF LIST
-- 2 : a simple field passes to a LIST OF LIST
SetArity (me : mutable; arity : Integer = 1);
---Purpose : Directly sets the arity count
-- 0 : simple field
-- 1 : LIST or ARRAY etc
-- 2 : LIST OF LIST
-- complements
SetFrom (me : mutable; other : PDescr);
---Purpose : Sets <me> as <other> but duplicated
-- Hence, some definition may be changed
SetOptional (me : mutable; opt : Boolean = Standard_True);
---Purpose : Sets/Unsets <me> to accept undefined values
SetDerived (me : mutable; der : Boolean = Standard_True);
---Purpose : Sets/Unsets <me> to be for a derived field
SetField (me : mutable; name : CString; rank : Integer);
---Purpose : Sets <me> to describe a field of an entity
-- With a name and a rank
-- querying
IsSelect (me) returns Boolean;
---Purpose : Tells if <me> is for a SELECT
Member (me; name : CString) returns PDescr;
---Purpose : For a SELECT, returns the member whose name matches <name>
-- To this member, the following question can then be asked
-- Null Handle if <name> not matched or <me> not a SELECT
--
-- Remark : not to be asked for an entity type
-- Hence, following IsInteger .. Enum* only apply on <me> and
-- require Member
-- While IsType applies on <me> and all Select Members
IsInteger (me) returns Boolean;
---Purpose : Tells if <me> is for an Integer
IsReal (me) returns Boolean;
---Purpose : Tells if <me> is for a Real value
IsString (me) returns Boolean;
---Purpose : Tells if <me> is for a String value
IsBoolean (me) returns Boolean;
---Purpose : Tells if <me> is for a Boolean value (false,true)
IsLogical (me) returns Boolean;
---Purpose : Tells if <me> is for a Logical value (false,true,unknown)
IsEnum (me) returns Boolean;
---Purpose : Tells if <me> is for an Enum value
-- Then, call AddEnumDef ordered from the first one (value 0)
-- Managed by an EnumTool
EnumMax (me) returns Integer;
---Purpose : Returns the maximum integer for a suitable value (count - 1)
EnumValue (me; name : CString) returns Integer;
---Purpose : Returns the numeric value found for an enum text
-- The text must be in capitals and limited by dots
-- A non-suitable text gives a negative value to be returned
EnumText (me; val : Integer) returns CString;
---Purpose : Returns the text which corresponds to a numeric value,
-- between 0 and EnumMax. It is limited by dots
IsEntity (me) returns Boolean;
---Purpose : Tells if <me> is for an Entity, either Described or CDL Type
IsType (me; atype : Type from Standard) returns Boolean;
---Purpose : Tells if <me> is for an entity of a given CDL type (early-bnd)
-- (works for <me> + nexts if <me> is a Select)
Type (me) returns Type from Standard;
---Purpose : Returns the type to match (IsKind), for a CDL Entity
-- (else, null handle)
IsDescr (me; descr : EDescr from StepData) returns Boolean;
---Purpose : Tells if <me> is for a Described entity of a given EDescr
-- (does this EDescr match description name ?). For late-bnd
-- (works for <me> + nexts if <me> is a Select)
DescrName (me) returns CString;
---Purpose : Returns the description (type name) to match, for a Described
-- (else, empty string)
Arity (me) returns Integer;
---Purpose : Returns the arity of <me>
Simple (me) returns PDescr;
---Purpose : For a LIST or LIST OF LIST, Returns the PDescr for the simpler
-- PDescr. Else, returns <me>
-- This allows to have different attributes for Optional for
-- instance, on a field, and on the parameter of a LIST :
-- [OPTIONAL] LIST OF [OPTIONAL] ...
IsOptional (me) returns Boolean;
---Purpose : Tells if <me> is Optional
IsDerived (me) returns Boolean;
---Purpose : Tells if <me> is Derived
IsField (me) returns Boolean;
---Purpose : Tells if <me> is a Field. Else it is a Type
FieldName (me) returns CString;
FieldRank (me) returns Integer;
Check (me; afild : Field; ach : in out Check) is virtual;
---Purpose : Semantic Check of a Field : does it complies with the given
-- description ?
fields
thename : AsciiString from TCollection;
thesel : Integer; -- 0 no 1 entity 2 immediate 3 heterog. 4 unknown
thesnam : AsciiString from TCollection;
thenext : PDescr; -- list of members
thekind : Integer; -- as Field
theenum : EnumTool from StepData;
thetype : Type from Standard;
thednam : AsciiString from TCollection;
thearit : Integer;
thefrom : PDescr; -- for SetFrom
theopt : Boolean;
theder : Boolean;
thefnam : AsciiString from TCollection;
thefnum : Integer;
end PDescr;

213
src/StepData/StepData_PDescr.cxx Executable file
View File

@@ -0,0 +1,213 @@
#include <StepData_PDescr.ixx>
#define KindInteger 1
#define KindBoolean 2
#define KindLogical 3
#define KindEnum 4
#define KindReal 5
#define KindString 6
#define KindEntity 7
StepData_PDescr::StepData_PDescr ()
: thesel (0), thekind (0), thearit (0),
theopt (Standard_False), theder (Standard_False), thefnum (0)
{ }
void StepData_PDescr::SetName (const Standard_CString name)
{ thename.Clear(); thename.AssignCat (name); }
Standard_CString StepData_PDescr::Name () const
{ return thename.ToCString(); }
Standard_Integer StepData_PDescr::Kind () const
{ return thekind; }
void StepData_PDescr::SetSelect ()
{ thesel = 4; }
void StepData_PDescr::AddMember (const Handle(StepData_PDescr)& member)
{
if (member.IsNull()) return;
if (thenext.IsNull()) thenext = member;
else thenext->AddMember (member);
if (thesel == 3) return;
if (thekind < KindEntity && thenext->Kind() >= KindEntity) thesel = 3;
else if (thekind < KindEntity && (thesel == 2 || thesel == 4)) thesel = 3;
else if (thekind >= KindEntity && (thesel == 1 || thesel == 4)) thesel = 2;
}
void StepData_PDescr::SetMemberName (const Standard_CString memname)
{ thesnam.Clear(); thesnam.AssignCat (memname); }
void StepData_PDescr::SetInteger ()
{ thekind = KindInteger; }
void StepData_PDescr::SetReal ()
{ thekind = KindReal; }
void StepData_PDescr::SetString ()
{ thekind = KindString; }
void StepData_PDescr::SetBoolean ()
{ thekind = KindBoolean; }
void StepData_PDescr::SetLogical ()
{ thekind = KindLogical; }
void StepData_PDescr::SetEnum ()
{ thekind = KindEnum; }
void StepData_PDescr::AddEnumDef (const Standard_CString enumdef)
{ theenum.AddDefinition (enumdef); }
void StepData_PDescr::SetType (const Handle(Standard_Type)& atype)
{ thekind = KindEntity; thetype = atype; thednam.Clear(); }
void StepData_PDescr::SetDescr (const Standard_CString dscnam)
{ thekind = KindEntity; thetype.Nullify();
thednam.Clear(); thednam.AssignCat(dscnam); }
void StepData_PDescr::AddArity (const Standard_Integer arity)
{ thearit += arity; }
void StepData_PDescr::SetArity (const Standard_Integer arity)
{ thearit = arity; }
void StepData_PDescr::SetFrom (const Handle(StepData_PDescr)& other)
{
if (other.IsNull()) return;
thekind = other->Kind();
Standard_Integer i, maxenum = other->EnumMax ();
for (i = 0; i <= maxenum; i ++) AddEnumDef (other->EnumText(i));
// ne sont pas reprises : les SELECT
thetype = other->Type();
thearit = other->Arity();
thefrom = other;
theopt = other->IsOptional ();
theder = other->IsDerived ();
thefnam.Clear(); thefnam.AssignCat (other->FieldName());
thefnum = other->FieldRank ();
}
void StepData_PDescr::SetOptional (const Standard_Boolean opt)
{ theopt = opt; }
void StepData_PDescr::SetDerived (const Standard_Boolean der)
{ theder = der; }
void StepData_PDescr::SetField
(const Standard_CString name, const Standard_Integer rank)
{
thefnam.Clear(); thefnam.AssignCat (name);
thefnum = rank;
}
// ###### INTERRO ######
Standard_Boolean StepData_PDescr::IsSelect () const
{
if (!thefrom.IsNull()) return thefrom->IsSelect();
return (thesel > 0);
}
Handle(StepData_PDescr) StepData_PDescr::Member (const Standard_CString name) const
{
if (!thefrom.IsNull()) return thefrom->Member (name);
Handle(StepData_PDescr) descr;
if (thesnam.IsEqual (name)) return this;
if (thenext.IsNull()) return descr; // null
return thenext->Member (name);
}
Standard_Boolean StepData_PDescr::IsInteger () const
{ return (thekind == KindInteger); }
Standard_Boolean StepData_PDescr::IsReal () const
{ return (thekind == KindReal); }
Standard_Boolean StepData_PDescr::IsString () const
{ return (thekind == KindString); }
Standard_Boolean StepData_PDescr::IsBoolean () const
{ return (thekind == KindBoolean || thekind == KindLogical); }
Standard_Boolean StepData_PDescr::IsLogical () const
{ return (thekind == KindLogical); }
Standard_Boolean StepData_PDescr::IsEnum () const
{ return (thekind == KindEnum); }
Standard_Integer StepData_PDescr::EnumMax () const
{ return theenum.MaxValue(); }
Standard_Integer StepData_PDescr::EnumValue (const Standard_CString name) const
{ return theenum.Value (name); }
Standard_CString StepData_PDescr::EnumText (const Standard_Integer val) const
{ return theenum.Text (val).ToCString(); }
Standard_Boolean StepData_PDescr::IsEntity () const
{ return (thekind == KindEntity); }
Standard_Boolean StepData_PDescr::IsType (const Handle(Standard_Type)& atype) const
{
if (atype.IsNull()) return Standard_False;
if (!thetype.IsNull()) {
if (atype->SubType(thetype)) return Standard_True;
}
if (!thenext.IsNull()) return thenext->IsType(atype);
if (!thefrom.IsNull()) return thefrom->IsType(atype);
return Standard_False;
}
Handle(Standard_Type) StepData_PDescr::Type () const
{ return thetype; }
Standard_Boolean StepData_PDescr::IsDescr
(const Handle(StepData_EDescr)& descr) const
{
if (descr.IsNull()) return Standard_False;
if (thednam.Length() > 0) {
if (descr->Matches (thednam.ToCString())) return Standard_True;
}
if (!thenext.IsNull()) return thenext->IsDescr (descr);
if (!thefrom.IsNull()) return thefrom->IsDescr (descr);
return Standard_False;
}
Standard_CString StepData_PDescr::DescrName () const
{ return thednam.ToCString(); }
Standard_Integer StepData_PDescr::Arity () const
{ return thearit; }
Handle(StepData_PDescr) StepData_PDescr::Simple () const
{
if (thearit == 0) return this;
if (thefrom.IsNull()) return this;
return thefrom;
}
Standard_Boolean StepData_PDescr::IsOptional () const
{ return theopt; }
Standard_Boolean StepData_PDescr::IsDerived () const
{ return theder; }
Standard_Boolean StepData_PDescr::IsField () const
{ return (thefnum > 0); }
Standard_CString StepData_PDescr::FieldName () const
{ return thefnam.ToCString (); }
Standard_Integer StepData_PDescr::FieldRank () const
{ return thefnum; }
void StepData_PDescr::Check(const StepData_Field& afild,
Handle(Interface_Check)& ach) const
{
// pour l instant ...
}

88
src/StepData/StepData_Plex.cdl Executable file
View File

@@ -0,0 +1,88 @@
-- File: StepData_Plex.cdl
-- Created: Fri May 9 16:35:59 1997
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class Plex from StepData inherits Described from StepData
---Purpose : A Plex (for Complex) Entity is defined as a list of Simple
-- Members ("external mapping")
-- The types of these members must be in alphabetic order
uses CString,
SequenceOfTransient from TColStd,
HSequenceOfAsciiString from TColStd,
Check from Interface, EntityIterator from Interface,
ECDescr from StepData, Simple from StepData, Field from StepData
raises InterfaceMismatch
is
Create (descr : ECDescr) returns mutable Plex;
---Purpose : Creates a Plex (empty). The complete creation is made by the
-- ECDescr itself, by calling Add
Add (me : mutable; member : Simple);
---Purpose : Adds a member to <me>
ECDescr (me) returns ECDescr;
---Purpose : Returns the Description as for a Plex
-- inherited
IsComplex (me) returns Boolean;
---Purpose : Returns False
Matches (me; steptype : CString) returns Boolean;
---Purpose : Tells if a step type is matched by <me>
-- For a Simple Entity : own type or super type
-- For a Complex Entity : one of the members
As (me; steptype : CString) returns mutable Simple;
---Purpose : Returns a Simple Entity which matches with a Type in <me> :
-- For a Simple Entity : me if it matches, else a null handle
-- For a Complex Entity : the member which matches, else null
HasField (me; name : CString) returns Boolean;
---Purpose : Tells if a Field brings a given name
Field (me; name : CString) returns Field
---Purpose : Returns a Field from its name; read-only
raises InterfaceMismatch;
-- raises if no Field for <name>
---C++ : return const &
CField (me : mutable; name : CString) returns Field
---Purpose : Returns a Field from its name; read or write
raises InterfaceMismatch;
-- raises if no Field for <name>
---C++ : return &
-- more specific
NbMembers (me) returns Integer;
---Purpose : Returns the count of simple members
Member (me; num : Integer) returns Simple;
---Purpose : Returns a simple member from its rank
TypeList (me) returns HSequenceOfAsciiString;
---Purpose : Returns the actual list of members types
--
Check (me; ach : in out Check from Interface);
---Purpose : Fills a Check by using its Description
Shared (me; list : in out EntityIterator from Interface);
---Purpose : Fills an EntityIterator with entities shared by <me>
fields
themembers : SequenceOfTransient;
end Plex;

112
src/StepData/StepData_Plex.cxx Executable file
View File

@@ -0,0 +1,112 @@
#include <StepData_Plex.ixx>
#include <TCollection_AsciiString.hxx>
#include <Interface_InterfaceMismatch.hxx>
static StepData_Field bid;
StepData_Plex::StepData_Plex (const Handle(StepData_ECDescr)& descr)
: StepData_Described (descr) { }
void StepData_Plex::Add (const Handle(StepData_Simple)& member)
{ themembers.Append (member); }
Handle(StepData_ECDescr) StepData_Plex::ECDescr () const
{ return Handle(StepData_ECDescr)::DownCast(Description()); }
Standard_Boolean StepData_Plex::IsComplex () const
{ return Standard_True; }
Standard_Boolean StepData_Plex::Matches (const Standard_CString steptype) const
{
Standard_Integer i, nb = NbMembers();
for (i = 1; i <= nb; i ++) {
if (Member(i)->Matches (steptype)) return Standard_True;
}
return Standard_False;
}
Handle(StepData_Simple) StepData_Plex::As (const Standard_CString steptype) const
{
Handle(StepData_Simple) ent;
Standard_Integer i, nb = NbMembers();
for (i = 1; i <= nb; i ++) {
ent = Member(i);
if (ent->Matches(steptype)) return ent;
}
ent.Nullify();
return ent;
}
Standard_Boolean StepData_Plex::HasField (const Standard_CString name) const
{
Standard_Integer i, nb = NbMembers();
for (i = 1; i <= nb; i ++) {
if (Member(i)->HasField (name)) return Standard_True;
}
return Standard_False;
}
const StepData_Field& StepData_Plex::Field (const Standard_CString name) const
{
Handle(StepData_Simple) ent;
Standard_Integer i, nb = NbMembers();
for (i = 1; i <= nb; i ++) {
ent = Member(i);
if (ent->HasField (name)) return ent->Field (name);
}
Interface_InterfaceMismatch::Raise("StepData_Plex : Field");
return bid; // pour faire plaisir au compilo
}
StepData_Field& StepData_Plex::CField (const Standard_CString name)
{
Handle(StepData_Simple) ent;
Standard_Integer i, nb = NbMembers();
for (i = 1; i <= nb; i ++) {
ent = Member(i);
if (ent->HasField (name)) return ent->CField (name);
}
Interface_InterfaceMismatch::Raise("StepData_Plex : Field");
return bid; // pour faire plaisir au compilo
}
Standard_Integer StepData_Plex::NbMembers () const
{ return themembers.Length(); }
Handle(StepData_Simple) StepData_Plex::Member (const Standard_Integer num) const
{ return Handle(StepData_Simple)::DownCast (themembers.Value(num)); }
Handle(TColStd_HSequenceOfAsciiString) StepData_Plex::TypeList () const
{
Handle(TColStd_HSequenceOfAsciiString) tl = new TColStd_HSequenceOfAsciiString();
Standard_Integer i, nb = NbMembers();
for (i = 1; i <= nb; i ++) {
TCollection_AsciiString nam (Member(i)->StepType());
tl->Append (nam);
}
return tl;
}
void StepData_Plex::Check(Handle(Interface_Check)& ach) const
{
Standard_Integer i, nb = NbMembers();
for (i = 1; i <= nb; i ++) {
Handle(StepData_Simple) si = Member(i);
si->Check(ach);
}
}
void StepData_Plex::Shared (Interface_EntityIterator& list) const
{
Standard_Integer i, nb = NbMembers();
for (i = 1; i <= nb; i ++) {
Handle(StepData_Simple) si = Member(i);
si->Shared (list);
}
}

View File

@@ -0,0 +1,128 @@
-- File: StepData_Protocol.cdl
-- Created: Wed Feb 3 11:01:48 1993
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1993
class Protocol from StepData inherits Protocol from Interface
---Purpose : Description of Basic Protocol for Step
-- The class Protocol from StepData itself describes a default
-- Protocol, which recognizes only UnknownEntities.
-- Sub-classes will redefine CaseNumber and, if necessary,
-- NbResources and Resources.
uses CString, Type,
SequenceOfAsciiString from TColStd, DictionaryOfTransient from Dico,
DataMapOfTransientInteger from Interface,
InterfaceModel from Interface,
EDescr from StepData, ESDescr from StepData, ECDescr from StepData,
PDescr from StepData
is
Create returns mutable Protocol from StepData;
NbResources (me) returns Integer;
---Purpose : Gives the count of Protocols used as Resource (can be zero)
-- Here, No resource
Resource (me; num : Integer) returns Protocol from Interface;
---Purpose : Returns a Resource, given a rank. Here, none
CaseNumber (me; obj : any Transient) returns Integer is redefined;
---Purpose : Returns a unique positive number for any recognized entity
-- Redefined to work by calling both TypeNumber and, for a
-- Described Entity (late binding) DescrNumber
TypeNumber (me; atype : any Type) returns Integer;
---Purpose : Returns a Case Number, specific of each recognized Type
-- Here, only Unknown Entity is recognized
-- -- Specific for StepData -- --
SchemaName (me) returns CString is virtual;
---Purpose : Returns the Schema Name attached to each class of Protocol
-- To be redefined by each sub-class
-- Here, SchemaName returns "(DEFAULT)"
-- was C++ : return const
-- -- General Services (defined at Norm level) -- --
NewModel (me) returns mutable InterfaceModel;
---Purpose : Creates an empty Model for Step Norm
IsSuitableModel (me; model : InterfaceModel) returns Boolean;
---Purpose : Returns True if <model> is a Model of Step Norm
UnknownEntity (me) returns mutable Transient;
---Purpose : Creates a new Unknown Entity for Step (UndefinedEntity)
IsUnknownEntity (me; ent : Transient) returns Boolean;
---Purpose : Returns True if <ent> is an Unknown Entity for the Norm, i.e.
-- Type UndefinedEntity, status Unknown
-- -- About Descriptions (late binding)
DescrNumber (me; adescr : any EDescr) returns Integer is virtual;
---Purpose : Returns a unique positive CaseNumber for types described by
-- an EDescr (late binding)
-- Warning : TypeNumber and DescrNumber must give together a unique
-- positive case number for each distinct case, type or descr
AddDescr (me : mutable; adescr : EDescr; CN : Integer);
---Purpose : Records an EDescr with its case number
-- Also records its name for an ESDescr (simple type): an ESDescr
-- is then used, for case number, or for type name
HasDescr (me) returns Boolean;
---Purpose : Tells if a Protocol brings at least one ESDescr, i.e. if it
-- defines at least one entity description by ESDescr mechanism
Descr (me; num : Integer) returns EDescr;
---Purpose : Returns the description attached to a case number, or null
Descr (me; name : CString; anylevel : Boolean = Standard_True)
returns EDescr;
---Purpose : Returns a description according to its name
-- <anylevel> True (D) : for <me> and its resources
-- <anylevel> False : for <me> only
ESDescr (me; name : CString; anylevel : Boolean = Standard_True)
returns ESDescr;
---Purpose : Idem as Descr but cast to simple description
ECDescr (me; names : SequenceOfAsciiString from TColStd;
anylevel : Boolean = Standard_True) returns ECDescr;
---Purpose : Returns a complex description according to list of names
-- <anylevel> True (D) : for <me> and its resources
-- <anylevel> False : for <me> only
AddPDescr (me : mutable; pdescr : PDescr);
---Purpose : Records an PDescr
PDescr (me; name : CString; anylevel : Boolean = Standard_True)
returns PDescr;
---Purpose : Returns a parameter description according to its name
-- <anylevel> True (D) : for <me> and its resources
-- <anylevel> False : for <me> only
AddBasicDescr (me : mutable; esdescr : ESDescr);
---Purpose : Records an ESDescr, intended to build complex descriptions
BasicDescr (me; name : CString; anylevel : Boolean = Standard_True)
returns EDescr;
---Purpose : Returns a basic description according to its name
-- <anylevel> True (D) : for <me> and its resources
-- <anylevel> False : for <me> only
fields
thedscnum : DataMapOfTransientInteger from Interface;
thedscnam : DictionaryOfTransient from Dico;
thepdescr : DictionaryOfTransient from Dico;
thedscbas : DictionaryOfTransient from Dico;
end Protocol;

View File

@@ -0,0 +1,241 @@
#include <StepData_Protocol.ixx>
#include <StepData_StepModel.hxx>
#include <StepData_UndefinedEntity.hxx>
#include <StepData_Described.hxx>
#include <Interface_DataMapIteratorOfDataMapOfTransientInteger.hxx>
#include <stdio.h>
// Le Protocol de base reconnait UnknownEntity
//static TCollection_AsciiString thename("(DEFAULT)");
static Standard_CString thename = "(DEFAULT)";
StepData_Protocol::StepData_Protocol ()
{
}
Standard_Integer StepData_Protocol::NbResources () const
{
return 0;
}
Handle(Interface_Protocol) StepData_Protocol::Resource
(const Standard_Integer /*num*/) const
{
Handle(Interface_Protocol) nulproto;
return nulproto;
}
Standard_Integer StepData_Protocol::CaseNumber
(const Handle(Standard_Transient)& obj) const
{
if (obj.IsNull()) return 0;
Standard_Integer num = TypeNumber (obj->DynamicType());
if (num > 0) return num;
Handle(StepData_Described) dc = Handle(StepData_Described)::DownCast(obj);
if (dc.IsNull()) return 0;
return DescrNumber (dc->Description());
}
Standard_Integer StepData_Protocol::TypeNumber
(const Handle(Standard_Type)& atype) const
{
if (atype == STANDARD_TYPE(StepData_UndefinedEntity)) return 1;
return 0;
}
Standard_CString StepData_Protocol::SchemaName () const
{
return thename;
}
Handle(Interface_InterfaceModel) StepData_Protocol::NewModel () const
{
return new StepData_StepModel;
}
Standard_Boolean StepData_Protocol::IsSuitableModel
(const Handle(Interface_InterfaceModel)& model) const
{
return model->IsKind(STANDARD_TYPE(StepData_StepModel));
}
Handle(Standard_Transient) StepData_Protocol::UnknownEntity () const
{
return new StepData_UndefinedEntity;
}
Standard_Boolean StepData_Protocol::IsUnknownEntity
(const Handle(Standard_Transient)& ent) const
{
if (!ent.IsNull())
return ent->IsKind(STANDARD_TYPE(StepData_UndefinedEntity));
return Standard_False;
}
// #### Description pour LateBinding
Standard_Integer StepData_Protocol::DescrNumber
(const Handle(StepData_EDescr)& adescr) const
{
if (thedscnum.IsBound(adescr)) return thedscnum.Find(adescr);
return 0;
}
void StepData_Protocol::AddDescr
(const Handle(StepData_EDescr)& adescr, const Standard_Integer CN)
{
Handle(StepData_ESDescr) sd = Handle(StepData_ESDescr)::DownCast(adescr);
thedscnum.Bind (adescr,CN);
// Simple : memorisee selon son nom
// sinon que faire ? on memorise selon le numero passe en alpha-num ...
// (temporaire)
if (thedscnam.IsNull()) thedscnam = new Dico_DictionaryOfTransient;
if (!sd.IsNull()) thedscnam->SetItem (sd->TypeName(),sd);
char fonom[10];
sprintf(fonom,"%d",CN);
thedscnam->SetItem (fonom,adescr);
}
Standard_Boolean StepData_Protocol::HasDescr () const
{
return !thedscnam.IsNull();
}
Handle(StepData_EDescr) StepData_Protocol::Descr
(const Standard_Integer num) const
{
Handle(StepData_EDescr) dsc;
if (thedscnam.IsNull()) return dsc;
char fonom[10];
sprintf(fonom,"%d",num);
if (!thedscnam->GetItem (fonom,dsc)) dsc.Nullify();
return dsc;
}
Handle(StepData_EDescr) StepData_Protocol::Descr
(const Standard_CString name, const Standard_Boolean anylevel) const
{
Handle(StepData_EDescr) sd;
if (!thedscnam.IsNull()) {
if (thedscnam->GetItem (name,sd)) return sd;
}
if (!anylevel) return sd;
Standard_Integer i, nb = NbResources();
for (i = 1; i <= nb; i ++) {
Handle(StepData_Protocol) sp = Handle(StepData_Protocol)::DownCast(Resource(i));
if (sp.IsNull()) continue;
sd = sp->Descr (name,anylevel);
if (!sd.IsNull()) return sd;
}
return sd;
}
Handle(StepData_ESDescr) StepData_Protocol::ESDescr
(const Standard_CString name, const Standard_Boolean anylevel) const
{
return Handle(StepData_ESDescr)::DownCast(Descr(name,anylevel));
}
Handle(StepData_ECDescr) StepData_Protocol::ECDescr
(const TColStd_SequenceOfAsciiString& names, const Standard_Boolean anylevel) const
{
Standard_Integer i, nb = names.Length();
Handle(StepData_ECDescr) cd;
Interface_DataMapIteratorOfDataMapOfTransientInteger iter(thedscnum);
for (; iter.More(); iter.Next()) {
cd = Handle(StepData_ECDescr)::DownCast (iter.Key());
if (cd.IsNull()) continue;
if (cd->NbMembers() != nb) continue;
Standard_Boolean ok = Standard_True;
for (i = 1; i <= nb; i ++) {
if (!names(i).IsEqual (cd->Member(i)->TypeName())) { ok = Standard_False; break; }
}
if (ok) return cd;
}
cd.Nullify();
if (!anylevel) return cd;
nb = NbResources();
for (i = 1; i <= nb; i ++) {
Handle(StepData_Protocol) sp = Handle(StepData_Protocol)::DownCast(Resource(i));
if (sp.IsNull()) continue;
cd = sp->ECDescr (names,anylevel);
if (!cd.IsNull()) return cd;
}
return cd;
}
void StepData_Protocol::AddPDescr
(const Handle(StepData_PDescr)& pdescr)
{
if (thepdescr.IsNull()) thepdescr = new Dico_DictionaryOfTransient;
thepdescr->SetItem (pdescr->Name(),pdescr);
}
Handle(StepData_PDescr) StepData_Protocol::PDescr
(const Standard_CString name, const Standard_Boolean anylevel) const
{
Handle(StepData_PDescr) sd;
if (!thepdescr.IsNull()) {
if (thepdescr->GetItem (name,sd)) return sd;
}
if (!anylevel) return sd;
Standard_Integer i, nb = NbResources();
for (i = 1; i <= nb; i ++) {
Handle(StepData_Protocol) sp = Handle(StepData_Protocol)::DownCast(Resource(i));
if (sp.IsNull()) continue;
sd = sp->PDescr (name,anylevel);
if (!sd.IsNull()) return sd;
}
return sd;
}
void StepData_Protocol::AddBasicDescr
(const Handle(StepData_ESDescr)& esdescr)
{
if (thedscbas.IsNull()) thedscbas = new Dico_DictionaryOfTransient;
thedscbas->SetItem (esdescr->TypeName(),esdescr);
}
Handle(StepData_EDescr) StepData_Protocol::BasicDescr
(const Standard_CString name, const Standard_Boolean anylevel) const
{
Handle(StepData_EDescr) sd;
if (!thedscbas.IsNull()) {
if (thedscbas->GetItem (name,sd)) return sd;
}
if (!anylevel) return sd;
Standard_Integer i, nb = NbResources();
for (i = 1; i <= nb; i ++) {
Handle(StepData_Protocol) sp = Handle(StepData_Protocol)::DownCast(Resource(i));
if (sp.IsNull()) continue;
sd = sp->BasicDescr (name,anylevel);
if (!sd.IsNull()) return sd;
}
return sd;
}

View File

@@ -0,0 +1,98 @@
-- File: StepData_ReadWriteModule.cdl
-- Created: Mon Jan 25 18:44:05 1993
-- Author: Christian CAILLET
-- <cky@sdsun2>
---Copyright: Matra Datavision 1993
deferred class ReadWriteModule from StepData inherits
ReaderModule from Interface
---Purpose : Defines basic File Access Module (Recognize, Read, Write)
-- That is : ReaderModule (Recognize & Read) + Write for
-- StepWriter (for a more centralized description)
-- Warning : A sub-class of ReadWriteModule, which belongs to a particular
-- Protocol, must use the same definition for Case Numbers (give
-- the same Value for a StepType defined as a String from a File
-- as the Protocol does for the corresponding Entity)
uses Transient, AsciiString from TCollection,
SequenceOfAsciiString from TColStd,
Check, FileReaderData, StepReaderData, StepWriter
raises DomainError
is
CaseNum (me; data : FileReaderData; num : Integer) returns Integer;
---Purpose : Translate the Type of record <num> in <data> to a positive
-- Case Number, or 0 if failed.
-- Works with a StepReaderData, in which the Type of an Entity
-- is defined as a String : Reads the RecordType <num> then calls
-- CaseNum (this type)
-- Warning : The methods CaseStep, StepType and Recognize,
-- must be in phase (triplets CaseNum-StepType-Type of Object)
CaseStep (me; atype : AsciiString from TCollection) returns Integer
is deferred;
---Purpose : Defines Case Numbers corresponding to the recognized Types
-- Called by CaseNum (data,num) above for a Simple Type Entity
-- Warning : CaseStep must give the same Value as Protocol does for the
-- Entity type which corresponds to this Type given as a String
CaseStep (me; types : SequenceOfAsciiString from TColStd) returns Integer
is virtual;
---Purpose : Same a above but for a Complex Type Entity ("Plex")
-- The provided Default recognizes nothing
IsComplex (me; CN : Integer) returns Boolean is virtual;
---Purpose : Returns True if the Case Number corresponds to a Complex Type
-- ("Plex"). Remember that all possible combinations must be
-- aknowledged to be processed
-- Default is False for all cases. For a Protocol which defines
-- possible Plexes, this method must be redefined.
StepType (me; CN : Integer) returns AsciiString from TCollection
is deferred;
---Purpose : Function specific to STEP, which delivers the StepType as it
-- is recorded in and read from a File compliant with STEP.
-- This method is symmetric to the method CaseStep.
-- StepType can be different from Dynamic Type's name, but
-- belongs to the same class of Object.
-- Returns an empty String if <CN> is zero.
-- Warning : For a Complex Type Entity, returns an Empty String
-- (Complex Type must be managed by users)
---C++ : return const &
ShortType (me; CN : Integer) returns AsciiString from TCollection
is virtual;
---Purpose : Function specific to STEP. Some STEP Types have a short form
-- This method can be redefined to fill it
-- By default, returns an empty string, which is then interpreted
-- to take normal form from StepType
ComplexType (me; CN : Integer;
types : in out SequenceOfAsciiString from TColStd)
returns Boolean is virtual;
---Purpose : Function specific to STEP, which delivers the list of types
-- which corresponds to a complex type. If <CN> is not for a
-- complex type, this method returns False. Else it returns True
-- and fills the list in alphabetic order.
-- The default returns False. To be redefined as required.
Read (me; CN : Integer; data : FileReaderData; num : Integer;
ach : in out Check; ent : mutable Transient)
raises DomainError;
---Purpose : General Read Function, calls ReadStep
ReadStep (me; CN : Integer; data : StepReaderData; num : Integer;
ach : in out Check; ent : mutable Transient)
raises DomainError is deferred;
---Purpose : Specific Read Function. Works with StepReaderData
WriteStep (me; CN : Integer; SW : in out StepWriter; ent : Transient)
is deferred;
---Purpose : Write Function, switched by CaseNum
end ReadWriteModule;

View File

@@ -0,0 +1,55 @@
#include <StepData_ReadWriteModule.ixx>
#include <StepData_StepReaderData.hxx>
#include <Interface_Macros.hxx>
Standard_Integer StepData_ReadWriteModule::CaseNum
(const Handle(Interface_FileReaderData)& data,
const Standard_Integer num) const
{
DeclareAndCast(StepData_StepReaderData,stepdat,data);
if (stepdat.IsNull()) return 0;
if (stepdat->IsComplex(num)) {
TColStd_SequenceOfAsciiString types;
stepdat->ComplexType (num,types);
if (types.IsEmpty()) return 0;
if (types.Length() == 1) return CaseStep (types.Value(1));
else return CaseStep (types);
}
return CaseStep (stepdat->RecordType(num));
}
Standard_Integer StepData_ReadWriteModule::CaseStep
(const TColStd_SequenceOfAsciiString& types) const
{ return 0; } // par defaut
Standard_Boolean StepData_ReadWriteModule::IsComplex
(const Standard_Integer CN) const
{ return Standard_False; } // par defaut
TCollection_AsciiString StepData_ReadWriteModule::ShortType
(const Standard_Integer ) const
{ return TCollection_AsciiString(""); } // par defaut vide
Standard_Boolean StepData_ReadWriteModule::ComplexType
(const Standard_Integer ,
TColStd_SequenceOfAsciiString& ) const
{ return Standard_False; }
//=======================================================================
//function : Read
//purpose :
//=======================================================================
void StepData_ReadWriteModule::Read(const Standard_Integer CN,
const Handle(Interface_FileReaderData)& data,
const Standard_Integer num,
Handle(Interface_Check)& ach,
const Handle(Standard_Transient)& ent) const
{
DeclareAndCast(StepData_StepReaderData,stepdat,data);
if (stepdat.IsNull()) return;
ReadStep (CN,stepdat,num,ach,ent);
}

View File

@@ -0,0 +1,39 @@
-- File: StepData_SelectArrReal.cdl
-- Created: Wed Dec 18 09:07:30 2002
-- Author: data exchange team
-- <det@petrox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 2002
class SelectArrReal from StepData inherits SelectNamed from StepData
---Purpose :
uses
AsciiString from TCollection,
HArray1OfReal from TColStd
is
Create returns mutable SelectArrReal;
-- HasName (me) returns Boolean is redefined;
-- Name (me) returns CString is redefined;
-- SetName (me : mutable; name : CString) returns Boolean is redefined;
-- redefined to accept any name
Kind(me) returns Integer is redefined;
-- fixed kind : ArrReal
ArrReal(me) returns HArray1OfReal from TColStd;
SetArrReal(me:mutable; arr : HArray1OfReal from TColStd);
fields
theArr : HArray1OfReal from TColStd;
end SelectArrReal;

View File

@@ -0,0 +1,49 @@
#include <StepData_SelectArrReal.ixx>
// Definitions : cf Field
#define myKindArrReal 8
//=======================================================================
//function : StepData_SelectSeqReal
//purpose :
//=======================================================================
StepData_SelectArrReal::StepData_SelectArrReal ()
{
}
//=======================================================================
//function : Kind
//purpose :
//=======================================================================
Standard_Integer StepData_SelectArrReal::Kind () const
{
return myKindArrReal;
}
//=======================================================================
//function : ArrReal
//purpose :
//=======================================================================
Handle(TColStd_HArray1OfReal) StepData_SelectArrReal::ArrReal () const
{
return theArr;
}
//=======================================================================
//function : SetArrReal
//purpose :
//=======================================================================
void StepData_SelectArrReal::SetArrReal (const Handle(TColStd_HArray1OfReal)& arr)
{
theArr = arr;
}

View File

@@ -0,0 +1,36 @@
-- File: StepData_SelectInt.cdl
-- Created: Mon Dec 16 16:23:07 1996
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class SelectInt from StepData inherits SelectMember
---Purpose : A SelectInt is a SelectMember specialised for a basic integer
-- type in a select which also accepts entities : this one has
-- NO NAME.
-- For a named select, see SelectNamed
uses CString, Logical
is
Create returns mutable SelectInt;
Kind (me) returns Integer is redefined;
-- possible kind for Int : integer boolean logical enum(without text)
SetKind (me : mutable; kind : Integer) is redefined;
-- called by various Set*
Int (me) returns Integer is redefined;
SetInt (me : mutable; val : Integer) is redefined;
fields
thekind : Integer;
theval : Integer;
end SelectInt;

View File

@@ -0,0 +1,9 @@
#include <StepData_SelectInt.ixx>
StepData_SelectInt::StepData_SelectInt () { thekind = 0; theval = 0; }
Standard_Integer StepData_SelectInt::Kind () const { return thekind; }
void StepData_SelectInt::SetKind (const Standard_Integer kind) { thekind = kind; }
Standard_Integer StepData_SelectInt::Int () const { return theval; }
void StepData_SelectInt::SetInt (const Standard_Integer val) { theval = val; }

View File

@@ -0,0 +1,102 @@
-- File: StepData_SelectMember.cdl
-- Created: Mon Dec 16 16:01:41 1996
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class SelectMember from StepData inherits TShared
---Purpose : The general form for a Select Member. A Select Member can,
-- either define a value of a basic type (such as an integer)
-- with an additional information : a name or list of names
-- which precise the meaning of this value
-- or be an alternate value in a select, which also accepts an
-- entity (in this case, the name is not mandatory)
--
-- Several sub-types of SelectMember are defined for integer and
-- real value, plus an "universal" one for any, and one more to
-- describe a select with several names
--
-- It is also possible to define a specific subtype by redefining
-- virtual method, then give a better control
--
-- Remark : this class itself could be deferred, because at least
-- one of its virtual methods must be redefined to be usable
uses CString, ParamType from Interface, Logical from StepData
is
Create returns mutable SelectMember;
-- this constructor is useless, the class is empty
HasName (me) returns Boolean is virtual;
---Purpose : Tells if a SelectMember has a name. Default is False
Name (me) returns CString is virtual;
---Purpose : Returns the name of a SelectMember. Default is empty
SetName (me : mutable; name : CString) returns Boolean is virtual;
---Purpose : Sets the name of a SelectMember, returns True if done, False
-- if no name is allowed
-- Default does nothing and returns False
Matches (me; name : CString) returns Boolean is virtual;
---Purpose : Tells if the name of a SelectMember matches a given one
-- By default, compares the strings, can be redefined (optimised)
Kind (me) returns Integer is virtual;
-- see Field for Kind (same codes)
SetKind (me : mutable; kind : Integer) is virtual;
-- called by various Set*
ParamType (me) returns ParamType from Interface;
---Purpose : Returns the Kind of the SelectMember, under the form of an
-- enum ParamType
Int (me) returns Integer is virtual;
---Purpose : This internal method gives access to a value implemented by an
-- Integer (to read it)
SetInt (me : mutable; val : Integer) is virtual;
---Purpose : This internal method gives access to a value implemented by an
-- Integer (to set it)
Integer (me) returns Integer;
---Purpose : Gets the value as an Integer
SetInteger (me : mutable; val : Integer);
Boolean (me) returns Boolean;
SetBoolean (me : mutable; val : Boolean);
Logical (me) returns Logical;
SetLogical (me : mutable; val : Logical);
Real (me) returns Real is virtual;
SetReal (me : mutable; val : Real) is virtual;
String (me) returns CString is virtual;
SetString (me : mutable; val : CString) is virtual;
Enum (me) returns Integer;
EnumText (me) returns CString is virtual;
-- By default, returns the String
-- Can be redefined to return a String for instance bound with int value
SetEnum (me : mutable; val : Integer; text : CString = "");
-- calls SetInt (for val) and SetEnumText (see below)
SetEnumText (me : mutable; val : Integer; text : CString) is virtual;
-- By default, calls SetString and disregards val
-- It is enough for standard subtypes
-- Can be redefined for a check on text and/or control of val and/or set
-- val according to text
end SelectMember;

View File

@@ -0,0 +1,84 @@
#include <StepData_SelectMember.ixx>
// Definitions reprises de Field :
#define KindInteger 1
#define KindBoolean 2
#define KindLogical 3
#define KindEnum 4
#define KindReal 5
#define KindString 6
StepData_SelectMember::StepData_SelectMember () { }
Standard_Boolean StepData_SelectMember::HasName () const { return Standard_False; }
Standard_CString StepData_SelectMember::Name () const { return ""; }
Standard_Boolean StepData_SelectMember::SetName (const Standard_CString bid)
{ return Standard_False; }
Standard_Boolean StepData_SelectMember::Matches (const Standard_CString name) const
{ return !strcmp (name,Name()); }
Standard_Integer StepData_SelectMember::Kind () const { return 0; }
void StepData_SelectMember::SetKind (const Standard_Integer ) { }
Interface_ParamType StepData_SelectMember::ParamType () const
{
Standard_Integer kind = Kind();
if (kind == 0) return Interface_ParamVoid;
if (kind == 1) return Interface_ParamInteger;
if (kind == 2 || kind == 3) return Interface_ParamLogical;
if (kind == 4) return Interface_ParamEnum;
if (kind == 5) return Interface_ParamReal;
if (kind == 6) return Interface_ParamText;
return Interface_ParamMisc;
}
Standard_Integer StepData_SelectMember::Int () const { return 0; }
void StepData_SelectMember::SetInt (const Standard_Integer ) { }
Standard_Integer StepData_SelectMember::Integer () const { return Int(); }
void StepData_SelectMember::SetInteger (const Standard_Integer val)
{ SetKind(KindInteger); SetInt(val); }
Standard_Boolean StepData_SelectMember::Boolean () const { return (Int() > 0); }
void StepData_SelectMember::SetBoolean (const Standard_Boolean val)
{ SetKind(KindBoolean); SetInt((val ? 1 : 0)); }
StepData_Logical StepData_SelectMember::Logical () const
{
Standard_Integer ival = Int();
if (ival == 0) return StepData_LFalse;
if (ival == 1) return StepData_LTrue;
return StepData_LUnknown;
}
void StepData_SelectMember::SetLogical (const StepData_Logical val)
{
SetKind(KindLogical);
if (val == StepData_LFalse) SetInt(0);
if (val == StepData_LTrue) SetInt(0);
if (val == StepData_LUnknown) SetInt(0);
}
Standard_Real StepData_SelectMember::Real () const { return 0.0; }
void StepData_SelectMember::SetReal (const Standard_Real ) { }
Standard_CString StepData_SelectMember::String () const { return ""; }
void StepData_SelectMember::SetString (const Standard_CString ) { }
Standard_Integer StepData_SelectMember::Enum () const { return Int(); }
Standard_CString StepData_SelectMember::EnumText () const { return String(); }
void StepData_SelectMember::SetEnum
(const Standard_Integer val, const Standard_CString text)
{
SetKind(KindEnum);
SetInt(val);
if (text && text[0] != '\0') SetEnumText(val,text);
}
void StepData_SelectMember::SetEnumText
(const Standard_Integer val, const Standard_CString text)
{ SetString(text); }

View File

@@ -0,0 +1,61 @@
-- File: StepData_SelectNamed.cdl
-- Created: Mon Dec 16 16:44:07 1996
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class SelectNamed from StepData inherits SelectMember
---Purpose : This select member can be of any kind, and be named
-- But its takes more memory than some specialised ones
-- This class allows one name for the instance
uses CString, Logical, AsciiString from TCollection, Field from StepData
is
Create returns mutable SelectNamed;
HasName (me) returns Boolean is redefined;
Name (me) returns CString is redefined;
SetName (me : mutable; name : CString) returns Boolean is redefined;
-- redefined to accept any name
Field (me) returns Field;
---C++ : return const &
CField (me : mutable) returns Field;
---C++ : return &
Kind (me) returns Integer is redefined;
-- see Field for Kind (same codes)
SetKind (me : mutable; kind : Integer) is redefined;
-- called by various Set*
Int (me) returns Integer is redefined;
---Purpose : This internal method gives access to a value implemented by an
-- Integer (to read it)
SetInt (me : mutable; val : Integer) is redefined;
---Purpose : This internal method gives access to a value implemented by an
-- Integer (to set it)
Real (me) returns Real is redefined;
SetReal (me : mutable; val : Real) is redefined;
String (me) returns CString is redefined;
SetString (me : mutable; val : CString) is redefined;
fields
thename : AsciiString;
theval : Field from StepData;
end SelectNamed;

View File

@@ -0,0 +1,53 @@
#include <StepData_SelectNamed.ixx>
// Definitions reprises de Field :
#define KindInteger 1
#define KindBoolean 2
#define KindLogical 3
#define KindEnum 4
#define KindReal 5
#define KindString 6
StepData_SelectNamed::StepData_SelectNamed ()
{ theval.Clear(); thename.Clear(); }
Standard_Boolean StepData_SelectNamed::HasName () const
{ return (thename.Length() > 0); }
Standard_CString StepData_SelectNamed::Name () const
{ return thename.ToCString(); }
Standard_Boolean StepData_SelectNamed::SetName (const Standard_CString name)
{ thename.Clear(); thename.AssignCat (name); return Standard_True; }
const StepData_Field& StepData_SelectNamed::Field () const
{ return theval; }
StepData_Field& StepData_SelectNamed::CField ()
{ return theval; }
Standard_Integer StepData_SelectNamed::Kind () const
{ return theval.Kind(); }
void StepData_SelectNamed::SetKind (const Standard_Integer kind)
{ theval.Clear (kind); }
Standard_Integer StepData_SelectNamed::Int () const
{ return theval.Int(); }
void StepData_SelectNamed::SetInt (const Standard_Integer val)
{ theval.SetInt (val); }
Standard_Real StepData_SelectNamed::Real () const
{ return theval.Real(); }
void StepData_SelectNamed::SetReal (const Standard_Real val)
{ theval.SetReal (val); }
Standard_CString StepData_SelectNamed::String () const
{ return theval.String(); }
void StepData_SelectNamed::SetString (const Standard_CString val)
{ theval.SetString (val); }

View File

@@ -0,0 +1,32 @@
-- File: StepData_SelectReal.cdl
-- Created: Mon Dec 16 16:34:16 1996
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class SelectReal from StepData inherits SelectMember
---Purpose : A SelectReal is a SelectMember specialised for a basic real
-- type in a select which also accepts entities : this one has
-- NO NAME
-- For a named select, see SelectNamed
uses CString, Logical
is
Create returns mutable SelectReal;
Kind (me) returns Integer is redefined;
-- fixed kind : Real
Real (me) returns Real is redefined;
SetReal (me : mutable; val : Real) is redefined;
fields
theval : Real;
end SelectReal;

View File

@@ -0,0 +1,11 @@
#include <StepData_SelectReal.ixx>
// Definitions : cf Field
#define KindReal 5
StepData_SelectReal::StepData_SelectReal () { theval = 0.0; }
Standard_Integer StepData_SelectReal::Kind () const { return KindReal; }
Standard_Real StepData_SelectReal::Real () const { return theval; }
void StepData_SelectReal::SetReal (const Standard_Real val) { theval = val; }

View File

@@ -0,0 +1,154 @@
-- File: StepData_SelectType.cdl
-- Created: Fri Mar 26 10:27:25 1993
-- Author: Christian CAILLET
-- <cky@phylox>
---Copyright: Matra Datavision 1993
deferred class SelectType from StepData -- inherits Storable
---Purpose : SelectType is the basis used for SELECT_TYPE definitions from
-- the EXPRESS form. A SELECT_TYPE in EXPRESS is an enumeration
-- of Types, it corresponds in a way to a Super-Type, but with
-- no specific Methods, and no exclusivity (a given Type can be
-- member of several SELECT_TYPES, plus be itself a SUB_TYPE).
--
-- A SelectType can be field of a Transient Entity (it is itself
-- Storable) or only used to control an input Argument
--
-- This class implies to designate each member Type by a Case
-- Number which is a positive Integer value (this allows a faster
-- treatement).
--
-- With this class, a specific SelectType can :
-- - recognize an Entity as complying or not with its definition,
-- - storing it, with the garanty that the stored Entity complies
-- with the definition of the SelectType
-- - and (if judged useful) give the stored Entity under the good
-- Type rather than simply "Transient".
uses CString, Transient, Type, Logical, SelectMember, PDescr
raises TypeMismatch
is
CaseNum (me; ent : Transient) returns Integer is deferred;
---Purpose : Recognizes the Type of an Entity. Returns a positive Number
-- which identifies the Type in the definition List of the
-- SelectType. Returns Zero if its Type in not in this List.
Matches (me; ent : Transient) returns Boolean;
---Purpose : Returns True if the Type of an Entity complies with the
-- definition list of the SelectType.
-- Also checks for a SelectMember
-- Default Implementation looks for CaseNum or CaseMem positive
SetValue (me : in out; ent : any Transient)
---Purpose : Stores an Entity. This allows to define a specific SelectType
-- class with one read method per member Type, which returns the
-- Value casted with the good Type.
raises TypeMismatch is static;
-- Error if <ent> does not match the definition List of Types.
Nullify (me : in out) is static;
---Purpose : Nullifies the Stored Entity
Value (me) returns any Transient is static;
---Purpose : Returns the Stored Entity. Can be used to define specific
-- read methods (see above)
---C++ : return const &
IsNull (me) returns Boolean is static;
---Purpose : Returns True if there is no Stored Entity (i.e. it is Null)
-- Entity (plain Transient)
Type (me) returns Type is static;
---Purpose : Returns the Effective (Dynamic) Type of the Stored Entity
-- If it is Null, returns TYPE(Transient)
CaseNumber (me) returns Integer is static;
---Purpose : Recognizes the Type of the stored Entity, or zero if it is
-- Null or SelectMember. Calls the first method CaseNum on Value
-- Others (through a SelectMember)
Description (me) returns PDescr is virtual;
---Purpose : Returns the Description which corresponds to <me>
-- Null if no specific description to give. This description is
-- used to control reading an check validity.
-- Default returns a Null Handle, i.e. undefined description
-- It can suffice if CaseNum and CaseMem give enough control
NewMember (me) returns SelectMember is virtual;
---Purpose : Returns a preferred SelectMember. Default returns a Null
-- By default, a SelectMember can be set according to data type
-- and Name : it is a SelectNamed if Name is defined
--
-- This method allows to define, for a specific SelectType, a
-- specific SelectMember than SelectNamed. For instance for a
-- Real plus a Name, a SelectReal plus a case number is a good
-- solution, lighter than SelectNamed which is very multipurpose
CaseMem (me; ent : SelectMember) returns Integer is virtual;
---Purpose : Recognize a SelectMember (kind, name). Returns a positive
-- value which identifies the case in the List of immediate cases
-- (distinct from the List of Entity Types). Zero if not
-- recognizes
-- Default returns 0, saying that no immediate value is allowed
CaseMember (me) returns Integer;
---Purpose : Returns the Type of the stored SelectMember, or zero if it is
-- Null or Entity. Calls the method CaseMem on Value
Member (me) returns SelectMember;
---Purpose : Returns Value as a SelectMember. Null if not a SelectMember
SelectName (me) returns CString;
---Purpose : Returns the type name of SelectMember. If no SelectMember or
-- with no type name, returns an empty string
-- To change it, pass through the SelectMember itself
Int (me) returns Integer;
---Purpose : This internal method gives access to a value implemented by an
-- Integer (to read it)
SetInt (me : in out; val : Integer)
---Purpose : This internal method gives access to a value implemented by an
-- Integer (to set it) : a SelectMember MUST ALREADY BE THERE !
raises TypeMismatch is static;
Integer (me) returns Integer;
---Purpose : Gets the value as an Integer
SetInteger (me : in out; val : Integer; name : CString = "")
---Purpose : Sets a new Integer value, with an optional type name
-- Warning : If a SelectMember is already set, works on it : value and
-- name must then be accepted by this SelectMember
raises TypeMismatch is static;
-- Error if no Integer value is accepted (see CaseMem)
Boolean (me) returns Boolean;
SetBoolean (me : in out; val : Boolean; name : CString = "")
raises TypeMismatch is static;
Logical (me) returns Logical;
SetLogical (me : in out; val : Logical; name : CString = "")
raises TypeMismatch is static;
Real (me) returns Real;
SetReal (me : in out; val : Real; name : CString = "")
raises TypeMismatch is static;
Destroy (me: in out) is virtual;
---C++ : alias "Standard_EXPORT virtual ~StepData_SelectType() { Destroy(); }"
fields
thevalue : Transient;
end SelectType;

View File

@@ -0,0 +1,176 @@
#include <StepData_SelectType.ixx>
#include <Standard_TypeMismatch.hxx>
#include <StepData_SelectNamed.hxx>
#include <StepData_SelectReal.hxx>
#include <StepData_SelectInt.hxx>
#include <Interface_Macros.hxx>
Standard_Boolean StepData_SelectType::Matches
(const Handle(Standard_Transient)& ent) const
{
if (CaseNum(ent) > 0) return Standard_True;
DeclareAndCast(StepData_SelectMember,sm,ent);
if (sm.IsNull()) return Standard_False;
if (CaseMem(sm) > 0) return Standard_True;
return Standard_False;
}
void StepData_SelectType::SetValue (const Handle(Standard_Transient)& ent)
{
if (ent.IsNull()) thevalue.Nullify();
else if (!Matches(ent))
Standard_TypeMismatch::Raise ("StepData : SelectType, SetValue");
else thevalue = ent;
}
void StepData_SelectType::Nullify ()
{ thevalue.Nullify(); }
const Handle(Standard_Transient)& StepData_SelectType::Value () const
{ return thevalue; }
Standard_Boolean StepData_SelectType::IsNull () const
{ return thevalue.IsNull(); }
Handle(Standard_Type) StepData_SelectType::Type () const
{
if (thevalue.IsNull()) return STANDARD_TYPE(Standard_Transient);
return thevalue->DynamicType();
}
Standard_Integer StepData_SelectType::CaseNumber () const
{ if (thevalue.IsNull()) return 0; return CaseNum(thevalue); }
// ********** Types Immediats ***********
Handle(StepData_PDescr) StepData_SelectType::Description () const
{ Handle(StepData_PDescr) nuldescr; return nuldescr; }
Handle(StepData_SelectMember) StepData_SelectType::NewMember () const
{ Handle(StepData_SelectMember) nulmem; return nulmem; }
Standard_Integer StepData_SelectType::CaseMem (const Handle(StepData_SelectMember)& ent) const
{ return 0; }
Standard_Integer StepData_SelectType::CaseMember () const
{
DeclareAndCast(StepData_SelectMember,sm,thevalue);
if (sm.IsNull()) return 0;
return CaseMem (sm);
}
Handle(StepData_SelectMember) StepData_SelectType::Member () const
{ return GetCasted(StepData_SelectMember,thevalue); }
Standard_CString StepData_SelectType::SelectName () const
{
DeclareAndCast(StepData_SelectMember,sm,thevalue);
if (sm.IsNull()) return "";
return sm->Name();
}
Standard_Integer StepData_SelectType::Int () const
{
DeclareAndCast(StepData_SelectMember,sm,thevalue);
if (sm.IsNull()) return 0;
return sm->Int();
}
void StepData_SelectType::SetInt (const Standard_Integer val)
{
DeclareAndCast(StepData_SelectMember,sm,thevalue);
if (sm.IsNull()) Standard_TypeMismatch::Raise ("StepData : SelectType, SetInt");
sm->SetInt (val);
}
// ********** Types Immediats : Differents Cas ***********
static Handle(StepData_SelectMember) SelectVal
(const Handle(Standard_Transient)& thevalue, const Standard_CString name,
const int mode)
{
DeclareAndCast(StepData_SelectMember,sm,thevalue);
if (!sm.IsNull()) {
if (name && name[0] != '\0')
if (!sm->SetName(name)) Standard_TypeMismatch::Raise ("StepData : SelectType, SetInteger");
}
else if (name && name[0] != '\0') {
Handle(StepData_SelectNamed) sn = new StepData_SelectNamed;
sn->SetName (name);
sm = sn;
} else {
if (mode == 0) sm = new StepData_SelectInt;
if (mode == 1) sm = new StepData_SelectReal;
}
return sm;
}
Standard_Integer StepData_SelectType::Integer () const
{
DeclareAndCast(StepData_SelectMember,sm,thevalue);
if (sm.IsNull()) return 0;
return sm->Integer();
}
void StepData_SelectType::SetInteger
(const Standard_Integer val, const Standard_CString name)
{
Handle(StepData_SelectMember) sm = SelectVal (thevalue,name,0);
sm->SetInteger (val);
if (CaseMem (sm) == 0) Standard_TypeMismatch::Raise ("StepData : SelectType, SetInteger");
thevalue = sm;
}
Standard_Boolean StepData_SelectType::Boolean () const
{
DeclareAndCast(StepData_SelectMember,sm,thevalue);
if (sm.IsNull()) return Standard_False;
return sm->Boolean();
}
void StepData_SelectType::SetBoolean
(const Standard_Boolean val, const Standard_CString name)
{
Handle(StepData_SelectMember) sm = SelectVal (thevalue,name,0);
sm->SetBoolean (val);
if (CaseMem (sm) == 0) Standard_TypeMismatch::Raise ("StepData : SelectType, SetBoolean");
thevalue = sm;
}
StepData_Logical StepData_SelectType::Logical () const
{
DeclareAndCast(StepData_SelectMember,sm,thevalue);
if (sm.IsNull()) return StepData_LUnknown;
return sm->Logical();
}
void StepData_SelectType::SetLogical
(const StepData_Logical val, const Standard_CString name)
{
Handle(StepData_SelectMember) sm = SelectVal (thevalue,name,0);
sm->SetLogical (val);
if (CaseMem (sm) == 0) Standard_TypeMismatch::Raise ("StepData : SelectType, SetLogical");
thevalue = sm;
}
Standard_Real StepData_SelectType::Real () const
{
DeclareAndCast(StepData_SelectMember,sm,thevalue);
if (sm.IsNull()) return 0.0;
return sm->Real();
}
void StepData_SelectType::SetReal
(const Standard_Real val, const Standard_CString name)
{
Handle(StepData_SelectMember) sm = SelectVal (thevalue,name,1);
sm->SetReal (val);
if (CaseMem (sm) == 0) Standard_TypeMismatch::Raise ("StepData : SelectType, SetReal");
thevalue = sm;
}
void StepData_SelectType::Destroy(){}

View File

@@ -0,0 +1,95 @@
-- File: StepData_Simple.cdl
-- Created: Fri May 9 16:17:26 1997
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class Simple from StepData inherits Described from StepData
---Purpose : A Simple Entity is defined by a type (which can heve super
-- types) and a list of parameters
uses CString,
Check from Interface, EntityIterator from Interface,
ESDescr from StepData,
Field from StepData, FieldListN from StepData
raises InterfaceMismatch
is
Create (descr : ESDescr) returns mutable Simple;
---Purpose : Creates a Simple Entity
ESDescr (me) returns ESDescr;
---Purpose : Returns description, as for simple
StepType (me) returns CString;
---Purpose : Returns the recorded StepType (TypeName of its ESDescr)
-- inherited
IsComplex (me) returns Boolean;
---Purpose : Returns False
Matches (me; steptype : CString) returns Boolean;
---Purpose : Tells if a step type is matched by <me>
-- For a Simple Entity : own type or super type
-- For a Complex Entity : one of the members
As (me; steptype : CString) returns mutable Simple;
---Purpose : Returns a Simple Entity which matches with a Type in <me> :
-- For a Simple Entity : me if it matches, else a null handle
-- For a Complex Entity : the member which matches, else null
HasField (me; name : CString) returns Boolean;
---Purpose : Tells if a Field brings a given name
Field (me; name : CString) returns Field
---Purpose : Returns a Field from its name; read-only
raises InterfaceMismatch;
-- raises if no Field for <name>
---C++ : return const &
CField (me : mutable; name : CString) returns Field
---Purpose : Returns a Field from its name; read or write
raises InterfaceMismatch;
-- raises if no Field for <name>
---C++ : return &
-- more specific
NbFields (me) returns Integer;
---Purpose : Returns the count of fields
FieldNum (me; num : Integer) returns Field;
---Purpose : Returns a field from its rank, for read-only use
---C++ : return const &
CFieldNum (me : mutable; num : Integer) returns Field;
---Purpose : Returns a field from its rank, in order to modify it
---C++ : return &
Fields (me) returns FieldListN;
---Purpose : Returns the entire field list, read-only
---C++ : return const &
CFields (me : mutable) returns FieldListN;
---Purpose : Returns the entire field list, read or write
---C++ : return &
--
Check (me; ach : in out Check from Interface);
---Purpose : Fills a Check by using its Description
Shared (me; list : in out EntityIterator from Interface);
---Purpose : Fills an EntityIterator with entities shared by <me>
fields
thefields : FieldListN;
end Simple;

View File

@@ -0,0 +1,84 @@
#include <StepData_Simple.ixx>
#include <Interface_InterfaceMismatch.hxx>
StepData_Simple::StepData_Simple (const Handle(StepData_ESDescr)& descr)
: StepData_Described (descr) , thefields (descr->NbFields()) { }
Handle(StepData_ESDescr) StepData_Simple::ESDescr () const
{ return Handle(StepData_ESDescr)::DownCast (Description()); }
Standard_CString StepData_Simple::StepType () const
{ return ESDescr()->TypeName(); }
Standard_Boolean StepData_Simple::IsComplex () const
{ return Standard_False; }
Standard_Boolean StepData_Simple::Matches (const Standard_CString steptype) const
{ return ESDescr()->Matches (steptype); }
Handle(StepData_Simple) StepData_Simple::As (const Standard_CString steptype) const
{
Handle(StepData_Simple) nulent;
if (Matches(steptype)) return this;
return nulent;
}
Standard_Boolean StepData_Simple::HasField (const Standard_CString name) const
{
Standard_Integer num = ESDescr()->Rank (name);
return (num > 0);
}
const StepData_Field& StepData_Simple::Field (const Standard_CString name) const
{
Standard_Integer num = ESDescr()->Rank (name);
if (num == 0) Interface_InterfaceMismatch::Raise("StepData_Simple : Field");
return FieldNum (num);
}
StepData_Field& StepData_Simple::CField (const Standard_CString name)
{
Standard_Integer num = ESDescr()->Rank (name);
if (num == 0) Interface_InterfaceMismatch::Raise("StepData_Simple : Field");
return CFieldNum (num);
}
Standard_Integer StepData_Simple::NbFields () const
{ return thefields.NbFields(); }
const StepData_Field& StepData_Simple::FieldNum (const Standard_Integer num) const
{ return thefields.Field(num); }
StepData_Field& StepData_Simple::CFieldNum (const Standard_Integer num)
{ return thefields.CField(num); }
const StepData_FieldListN& StepData_Simple::Fields () const
{ return thefields; }
StepData_FieldListN& StepData_Simple::CFields ()
{ return thefields; }
void StepData_Simple::Check(Handle(Interface_Check)& ach) const
{
} // qq chose ? cf la description
void StepData_Simple::Shared (Interface_EntityIterator& list) const
{
Standard_Integer i, nb = thefields.NbFields();
for (i = 1; i <= nb; i ++) {
const StepData_Field& fi = thefields.Field(i);
Standard_Integer j1,j2,l1,l2; l1 = l2 = 1;
if (fi.Arity() >= 1) l1 = fi.Length(1);
if (fi.Arity() > 1) l2 = fi.Length(2);
for (j1 = 1; j1 <= l1; j1 ++) {
for (j2 = 1; j2 <= l2; j2 ++) {
Handle(Standard_Transient) ent = fi.Entity(j1,j2);
if (!ent.IsNull()) list.AddItem(ent);
}
}
}
}

View File

@@ -0,0 +1,80 @@
-- File: StepData_StepDumper.cdl
-- Created: Mon Mar 14 10:38:08 1994
-- Author: Christian CAILLET
-- <cky@ecolox>
---Copyright: Matra Datavision 1994
class StepDumper from StepData
---Purpose : Provides a way to dump entities processed through STEP, with
-- these features :
-- - same form as for writing a STEP File (because it is clear
-- and compact enough, even if the names of the fields do not
-- appear) : thus, no additionnal resource is required
-- - possibility to look for an entity itself (only its Type or
-- with its content), an entity and it shared items (one level)
-- or all the entities its refers to, directly or recursively.
uses Messenger from Message, Transient, Protocol from StepData, StepModel,
GeneralLib, StepWriter, WriterLib
raises InterfaceMismatch
is
Create (amodel : StepModel; protocol : Protocol from StepData; mode : Integer = 0)
returns StepDumper;
---Purpose : Creates a StepDumper, able to work on a given StepModel
-- (which defines the total scope for dumping entities) and
-- a given Protocol from Step (which defines the authorized
-- types to be dumped)
-- <mode> commands what is to be displayed (number or label)
-- 0 for number (and corresponding labels are displayed apart)
-- 1 for label (and corresponding numbers are displayed apart)
-- 2 for label without anymore
StepWriter (me : in out) returns StepWriter is static;
---Purpose : Gives an access to the tool which is used to work : this allow
-- to acts on some parameters : Floating Format, Scopes ...
---C++ : return &
Dump (me : in out; S : Messenger from Message; ent : Transient; level : Integer)
returns Boolean
---Purpose : Dumps a Entity on an Messenger. Returns True if
-- sucess, False, if the entity to dump has not been recognized
-- by the Protocol. <level> can have one of these values :
-- - 0 : prints the TYPE only, as known in STEP Files (StepType)
-- If <ent> has not been regognized by the Protocol, or if its
-- type is Complex, the StepType is replaced by the display of
-- the cdl type. Complex Type are well processed by level 1.
-- - 1 : dumps the entity, completely (whatever it has simple or
-- complex type) but alone.
-- - 2 : dumps the entity completely, plus the item its refers to
-- at first level (a header message designates the starting
-- entity of the dump) <Lists Shared and Implied>
-- - 3 : dumps the entity and its refered items at any levels
--
-- For levels 1,2,3, the numbers displayed (form #nnn) are the
-- numbers of the corresponding entities in the Model
raises InterfaceMismatch;
-- Errors come from StepWriter, they especially occur when an
-- entity does not come from the starting Model.
-- Level 0 accepts an entity which does not come from the Model.
Dump (me : in out; S : Messenger from Message; num : Integer; level : Integer)
returns Boolean
---Purpose : Works as Dump with a Transient, but directly takes the
-- entity designated by its number in the Model
-- Returns False, also if <num> is out of range
raises InterfaceMismatch;
-- Errors : same as above
fields
themodel : StepModel;
theslib : GeneralLib;
thewlib : WriterLib;
thewriter : StepWriter;
end StepDumper;

View File

@@ -0,0 +1,181 @@
#include <StepData_StepDumper.ixx>
#include <StepData_ReadWriteModule.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <Interface_GeneralModule.hxx>
#include <Interface_EntityIterator.hxx>
#include <TColStd_SequenceOfAsciiString.hxx>
#include <Message_Messenger.hxx>
#include <Message.hxx>
#include <stdio.h>
StepData_StepDumper::StepData_StepDumper
(const Handle(StepData_StepModel)& amodel,
const Handle(StepData_Protocol)& protocol,
const Standard_Integer mode)
: theslib (protocol) , thewlib (protocol) , thewriter (amodel)
{
themodel = amodel;
if (mode > 0) thewriter.LabelMode () = 2;
}
StepData_StepWriter& StepData_StepDumper::StepWriter ()
{
return thewriter;
}
Standard_Boolean StepData_StepDumper::Dump
(const Handle(Message_Messenger)& S, const Handle(Standard_Transient)& ent,
const Standard_Integer level)
{
Standard_Integer i, nb = themodel->NbEntities();
TColStd_Array1OfInteger ids(0,nb); ids.Init(0);
Standard_Integer num = themodel->Number(ent);
Standard_Integer nlab = themodel->IdentLabel(ent);
ids.SetValue(num, (nlab > 0 ? nlab : -1) );
if (level <= 0) {
Handle(StepData_ReadWriteModule) module;
Standard_Integer CN;
if (num > 0) S << "#" << num << " = ";
else S << "#??? = ";
if (thewlib.Select(ent,module,CN)) {
if (module->IsComplex(CN)) {
TColStd_SequenceOfAsciiString listypes;
if (!module->ComplexType(CN,listypes))
S << "(Complex Type : ask level > 0) cdl = "
<< ent->DynamicType()->Name() << " (...);" << endl;
else {
Standard_Integer n = listypes.Length();
for (i = 1; i <= n; i ++) S << listypes.Value(i) << " (...)";
S << endl;
}
}
else S << module->StepType(CN) << " (...);" << endl;
}
else S << "(Unrecognized Type for protocol) cdl = "
<< ent->DynamicType()->Name() << " (...);" << endl;
if (nlab > 0) S << "/* Ident in file for "<<num<<" : #"<<nlab<<" */"<<endl;
}
else if (level == 1) {
// ... Idents ...
Handle(Standard_Transient) anent;
Handle(Interface_GeneralModule) module; Standard_Integer CN;
if (theslib.Select(ent,module,CN)) {
Interface_EntityIterator iter;
module->FillSharedCase (CN,ent,iter);
module->ListImpliedCase (CN,ent,iter); // on cumule ...
for (; iter.More(); iter.Next()) {
anent = iter.Value();
nlab = themodel->IdentLabel(anent);
ids.SetValue (themodel->Number(anent), (nlab > 0 ? nlab : -1) );
}
}
// ... Envoi ...
thewriter.SendEntity (num,thewlib);
//// thewriter.Print(S);
}
else {
Handle(Standard_Transient) anent;
// S << " -- Dumping Entity n0 " << num << " --" << endl;
// ... Envoi ...
TColStd_Array1OfInteger tab(0,nb); tab.Init(0);
tab.SetValue(num,1);
Handle(Interface_GeneralModule) module; Standard_Integer CN;
if (theslib.Select(ent,module,CN)) {
Interface_EntityIterator iter;
module->FillSharedCase (CN,ent,iter);
module->ListImpliedCase (CN,ent,iter); // on cumule ...
for (; iter.More(); iter.Next()) {
tab.SetValue(themodel->Number(iter.Value()),1);
}
}
for (i = 1; i <= nb; i ++) {
// ... Listes des idents ...
if (tab.Value(i) == 0) continue;
anent = themodel->Value(i);
thewriter.SendEntity(i,thewlib);
if (theslib.Select(anent,module,CN)) {
Interface_EntityIterator iter;
module->FillSharedCase (CN,anent,iter);
module->ListImpliedCase (CN,anent,iter); // on cumule ...
for (; iter.More(); iter.Next()) {
anent = iter.Value();
nlab = themodel->IdentLabel(anent);
ids.SetValue (themodel->Number(anent), (nlab > 0 ? nlab : -1) );
}
}
}
//// thewriter.Print(S);
}
// .... Affichage des idents silya ....
Standard_Integer nbi = 0 , nbe = 0 , nbq = 0 , nbu = 0;
for (i = 1; i <= nb; i ++) {
nlab = ids.Value(i);
if (nlab == 0) continue;
nbe ++;
if (nlab < 0) nbu = 0;
else if (nlab == i) nbq = 0;
else if (nlab > 0) nbi ++;
}
if (nbe > 0) {
// S <<" -- Displayed nums:"<<nbe<<" with ident=num:"<<nbq<<" , distinct proper ident:"<<nbi<<"\n";
if (nbu > 0) {
S<<" (no ident): ";
for (i = 1; i <= nb; i ++)
{ if (ids.Value(i) >= 0) continue; S<<" #"<<i; }
S<<endl;
}
if (nbq > 0) {
S<<" (ident = num): ";
for (i = 1; i <= nb; i ++) { if (ids.Value(i) == i) S<<" #"<<i; }
S<<endl;
}
if (nbi < 0) { // on n affiche plus num:#id , on envoie un petit help
Standard_Integer nbl = 0, nbr = 0, nbr0 = 0, nbc = 0;
char unid[30];
// S<<" (proper ident): #num #ident"<<endl;
S<<" (proper ident): num:#ident num:#ident ..."<<endl;
for (i = 1; i <= nb; i ++) {
if (ids.Value(i) <= 0 || ids.Value(i) == i) continue;
sprintf (unid,"%d:#%d",i,ids.Value(i));
nbc = strlen (unid); nbr = ((80-nbc) %4) +2;
nbl += nbc;
if (nbl+nbr0 > 79) { nbl = nbc; S<<endl; }
else { nbl += nbr0; for (; nbr0 > 0; nbr0 --) S << " "; }
S<<unid;
nbr0 = nbr;
// if (nbl+nbc > 79) { S<<endl<<unid; nbl = 0; }
// else { S<<unid; }
// nbl += (nbc+nbr);
// nbr = ((80-nbc) % 4) +1;
// S<<" "<<i<<" ->#"<<ids.Value(i);
// nbl ++; if (nbl > 5) { nbl = nbr = 0; S<<endl; }
}
if (nbl > 0) S<<endl;
}
if (nbi > 0) S<<"In dump, iii:#jjj means : entity rank iii has step ident #jjj"<<endl;
// S <<" -- Dumping data, entity "<<num<<" level "<<level<<" :"<<endl;
}
if (level > 0)
{
Standard_SStream aStream;
thewriter.Print(aStream);
S << aStream;
}
return Standard_True;
}
Standard_Boolean StepData_StepDumper::Dump
(const Handle(Message_Messenger)& S, const Standard_Integer num,
const Standard_Integer level)
{
if (num <= 0 || num > themodel->NbEntities()) return Standard_False;
Handle(Standard_Transient) ent = themodel->Value(num);
return Dump (S,ent,level);
}

View File

@@ -0,0 +1,92 @@
-- File: StepModel.cdl
-- Created: Tue Feb 11 16:01:53 1992
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1992
class StepModel from StepData inherits InterfaceModel
---Purpose : Gives access to
-- - entities in a STEP file,
-- - the STEP file header.
uses Type, HAsciiString from TCollection,
Messenger from Message,
DataMapOfTransientInteger,
EntityList, EntityIterator, Check
raises NoSuchObject
is
Create returns mutable StepModel;
---Purpose: Creates an empty STEP model with an empty header.
Reservate (me : mutable; nbent : Integer) is redefined;
---Purpose : The standard reservation is completed for the map (id-num)
Entity (me; num : Integer) returns Transient;
---Purpose : returns entity given its rank.
-- Same as InterfaceEntity, but with a shorter name
GetFromAnother (me : mutable; other : InterfaceModel);
---Purpose : gets header from another Model (uses Header Protocol)
NewEmptyModel (me) returns mutable InterfaceModel;
---Purpose : Returns a New Empty Model, same type as <me>, i.e. StepModel
-- -- Header management -- --
Header (me) returns EntityIterator;
---Purpose : returns Header entities under the form of an iterator
HasHeaderEntity(me; atype : any Type) returns Boolean;
---Purpose : says if a Header entity has a specifed type
HeaderEntity (me; atype : any Type) returns mutable Transient
---Purpose : Returns Header entity with specified type, if there is
raises NoSuchObject;
-- Error if no Header Entity matches <atype>
ClearHeader (me : mutable);
---Purpose : Clears the Header
AddHeaderEntity (me : mutable; ent : mutable Transient);
---Purpose : Adds an Entity to the Header
VerifyCheck (me; ach : in out Check) is redefined;
---Purpose : Specific Check, checks Header Items with HeaderProtocol
DumpHeader (me; S : Messenger from Message; level : Integer = 0);
---Purpose : Dumps the Header, with the Header Protocol of StepData.
-- If the Header Protocol is not defined, for each Header Entity,
-- prints its Type. Else sends the Header under the form of
-- HEADER Section of an Ascii Step File
-- <level> is not used because Header is not so big
ClearLabels (me : mutable);
---Purpose : erases specific labels, i.e. clears the map (entity-ident)
SetIdentLabel (me : mutable; ent : Transient; ident : Integer);
---Purpose : Attaches an ident to an entity to produce a label
-- (does nothing if <ent> is not in <me>)
IdentLabel (me; ent : Transient) returns Integer;
---Purpose : returns the label ident attached to an entity, 0 if not in me
PrintLabel (me; ent : Transient; S : Messenger from Message);
---Purpose : Prints label specific to STEP norm for a given entity, i.e.
-- if a LabelIdent has been recorded, its value with '#', else
-- the number in the model with '#' and between ()
StringLabel (me; ent : Transient) returns HAsciiString from TCollection;
---Purpose : Returns a string with the label attached to a given entity,
-- same form as for PrintLabel
fields
theheader : EntityList;
theidnums : DataMapOfTransientInteger;
end StepModel;

View File

@@ -0,0 +1,163 @@
#include <StepData_StepModel.ixx>
#include <Standard_NoSuchObject.hxx>
#include <StepData_Protocol.hxx>
#include <StepData_StepWriter.hxx>
#include <StepData.hxx>
#include <Interface_CopyTool.hxx>
#include <Interface_GeneralLib.hxx>
#include <Interface_ShareTool.hxx>
#include <Interface_GeneralModule.hxx>
#include <Interface_Macros.hxx>
#include <stdio.h>
// Entete de fichier : liste d entites
StepData_StepModel::StepData_StepModel () { }
void StepData_StepModel::Reservate (const Standard_Integer nbent)
{
Interface_InterfaceModel::Reservate(nbent);
if (nbent > theidnums.NbBuckets()) theidnums.ReSize (nbent);
}
Handle(Standard_Transient) StepData_StepModel::Entity
(const Standard_Integer num) const
{ return Value(num); } // nom plus joli
void StepData_StepModel::GetFromAnother
(const Handle(Interface_InterfaceModel)& other)
{
theheader.Clear();
DeclareAndCast(StepData_StepModel,another,other);
if (another.IsNull()) return;
Interface_EntityIterator iter = another->Header();
// recopier le header. Attention, header distinct du contenu ...
Interface_CopyTool TC (this,StepData::HeaderProtocol());
for (; iter.More(); iter.Next()) {
Handle(Standard_Transient) newhead;
if (!TC.Copy(iter.Value(),newhead,Standard_False,Standard_False)) continue;
if (!newhead.IsNull()) theheader.Append(newhead);
}
}
Handle(Interface_InterfaceModel) StepData_StepModel::NewEmptyModel () const
{ return new StepData_StepModel; }
Interface_EntityIterator StepData_StepModel::Header () const
{
Interface_EntityIterator iter;
theheader.FillIterator(iter);
return iter;
}
Standard_Boolean StepData_StepModel::HasHeaderEntity
(const Handle(Standard_Type)& atype) const
{ return (theheader.NbTypedEntities(atype) == 1); }
Handle(Standard_Transient) StepData_StepModel::HeaderEntity
(const Handle(Standard_Type)& atype) const
{ return theheader.TypedEntity(atype); }
// Remplissage du Header
void StepData_StepModel::ClearHeader ()
{ theheader.Clear(); }
void StepData_StepModel::AddHeaderEntity
(const Handle(Standard_Transient)& ent)
{ theheader.Append(ent); }
void StepData_StepModel::VerifyCheck(Handle(Interface_Check)& ach) const
{
Interface_GeneralLib lib(StepData::HeaderProtocol());
Interface_ShareTool sh(this,StepData::HeaderProtocol());
Handle(Interface_GeneralModule) module; Standard_Integer CN;
for (Interface_EntityIterator iter = Header(); iter.More(); iter.Next()) {
Handle(Standard_Transient) head = iter.Value();
if (!lib.Select(head,module,CN)) continue;
module->CheckCase(CN,head,sh,ach);
}
}
void StepData_StepModel::DumpHeader
(const Handle(Message_Messenger)& S, const Standard_Integer /*level*/) const
{
// NB : level n est pas utilise
Handle(StepData_Protocol) stepro = StepData::HeaderProtocol();
Standard_Boolean iapro = !stepro.IsNull();
if (!iapro) S<<" -- WARNING : StepModel DumpHeader, Protocol not defined\n";
Interface_EntityIterator iter = Header();
Standard_Integer nb = iter.NbEntities();
S << " -- Step Model Header : " <<iter.NbEntities() << " Entities :\n";
for (iter.Start(); iter.More(); iter.Next()) {
S << " " << iter.Value()->DynamicType()->Name() << "\n";
}
if (!iapro || nb == 0) return;
S << " -- -- STEP MODEL HEADER CONTENT -- --" << endl;
S << " -- Dumped with Protocol : " << stepro->DynamicType()->Name()
<< " --"<<endl;
Standard_SStream aSStream;
StepData_StepWriter SW(this);
SW.SendModel(stepro,Standard_True); // envoi HEADER seul
SW.Print(aSStream);
S << aSStream.str().c_str();
}
void StepData_StepModel::ClearLabels ()
{ theidnums.Clear(); }
void StepData_StepModel::SetIdentLabel
(const Handle(Standard_Transient)& ent, const Standard_Integer ident)
{
if (Number(ent) == 0) return;
if (theidnums.NbBuckets() < NbEntities()) theidnums.ReSize (NbEntities());
if (theidnums.IsBound(ent)) theidnums.ChangeFind(ent) = ident;
else theidnums.Bind (ent,ident);
}
Standard_Integer StepData_StepModel::IdentLabel
(const Handle(Standard_Transient)& ent) const
{
if (theidnums.IsBound(ent)) return theidnums.Find(ent);
return 0;
}
void StepData_StepModel::PrintLabel
(const Handle(Standard_Transient)& ent, const Handle(Message_Messenger)& S) const
{
Standard_Integer num = 0 , nid = 0;
if (theidnums.IsBound(ent)) nid = theidnums.Find(ent);
if (nid <= 0) num = Number(ent);
if (nid > 0) S<<"#"<<nid;
else if (num > 0) S<<"(#"<<num<<")";
else S<<"(#0..)";
}
Handle(TCollection_HAsciiString) StepData_StepModel::StringLabel
(const Handle(Standard_Transient)& ent) const
{
Handle(TCollection_HAsciiString) label;
char text[20];
Standard_Integer num = 0 , nid = 0;
if (theidnums.IsBound(ent)) nid = theidnums.Find(ent);
if (nid <= 0) num = Number(ent);
if (nid > 0) sprintf (text, "#%d",nid);
else if (num > 0) sprintf (text, "(#%d)",num);
else sprintf (text, "(#0..)");
label = new TCollection_HAsciiString(text);
return label;
}

View File

@@ -0,0 +1,344 @@
-- File: StepReaderData.cdl
-- Created: Tue Feb 11 16:48:58 1992
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1992
class StepReaderData from StepData inherits FileReaderData
---Purpose : Specific FileReaderData for Step
-- Contains litteral description of entities (for each one : type
-- as a string, ident, parameter list)
-- provides references evaluation, plus access to litteral data
-- and specific access methods (Boolean, XY, XYZ)
uses Integer, Boolean, CString, Transient, Type, HAsciiString from TCollection,
Array1OfInteger from TColStd, AsciiString from TCollection,
Array1OfAsciiString, SequenceOfAsciiString from TColStd,
Check from Interface, ParamType from Interface,
Logical from StepData, SelectType from StepData, EnumTool from StepData,
SelectMember from StepData, Field from StepData, PDescr from StepData,
FieldList from StepData, ESDescr from StepData,
IndexedMapOfAsciiString from Interface,
DataMapOfIntegerInteger from TColStd
is
-- -- File data storing and access (specific) -- --
Create (nbheader,nbtotal,nbpar : Integer) returns mutable StepReaderData;
---Purpose : creates StepReaderData correctly dimensionned (necessary at
-- creation time, because it contains arrays)
-- nbheader is nb of records for Header, nbtotal for Header+Data
-- and nbpar gives the total count of parameters
SetRecord (me : mutable; num : Integer;
ident : CString; type : CString; nbpar : Integer)
is static;
---Purpose : Fills the fields of a record
AddStepParam (me : mutable; num : Integer;
aval : CString; atype : ParamType; nument : Integer = 0)
is static;
---Purpose : Fills the fields of a parameter of a record. This is a variant
-- of AddParam, Adapted to STEP (optimized for specific values)
RecordType (me; num : Integer) returns AsciiString from TCollection
is static;
---Purpose : Returns Record Type
---C++ : return const &
CType (me; num : Integer) returns CString is static;
---Purpose : Returns Record Type as a CString
-- was C++ : return const
RecordIdent (me; num : Integer) returns Integer is static;
---Purpose : Returns record identifier (Positive number)
-- If returned ident is not positive : Sub-List or Scope mark
SubListNumber (me; num, nump : Integer; aslast : Boolean) returns Integer
is static;
---Purpose : Returns SubList numero designated by a parameter (nump) in a
-- record (num), or zero if the parameter does not exist or is
-- not a SubList address. Zero too If aslast is True and nump
-- is not for the last parameter
IsComplex (me; num : Integer) returns Boolean is static;
---Purpose : Returns True if <num> corresponds to a Complex Type Entity
-- (as can be defined by ANDOR Express clause)
ComplexType (me; num : Integer;
types : in out SequenceOfAsciiString from TColStd)
is static;
---Purpose : Returns the List of Types which correspond to a Complex Type
-- Entity. If not Complex, there is just one Type in it
-- For a SubList or a Scope mark, <types> remains empty
NextForComplex (me; num : Integer) returns Integer is static;
---Purpose : Returns the Next "Componant" for a Complex Type Entity, of
-- which <num> is already a Componant (the first one or a next one)
-- Returns 0 for a Simple Type or for the last Componant
NamedForComplex (me; name : CString; num0 : Integer;
num : in out Integer; ach : in out Check)
returns Boolean;
---Purpose : Determines the first component which brings a given name, for
-- a Complex Type Entity
-- <num0> is the very first record of this entity
-- <num> is given the last NextNamedForComplex, starts at zero
-- it is returned as the newly found number
-- Hence, in the normal case, NextNamedForComplex starts by num0
-- if <num> is zero, else by NextForComplex(num)
-- If the alphabetic order is not respected, it restarts from
-- num0 and loops on NextForComplex until finding <name>
-- In case of "non-alphabetic order", <ach> is filled with a
-- Warning for this name
-- In case of "not-found at all", <ach> is filled with a Fail,
-- and <num> is returned as zero
--
-- Returns True if alphabetic order, False else
-- -- Some Useful Accesses which are provided -- --
CheckNbParams (me; num : Integer; nbreq : Integer; ach : in out Check;
mess : CString = "") returns Boolean is static;
---Purpose : Checks Count of Parameters of record <num> to equate <nbreq>
-- If this Check is successful, returns True
-- Else, fills <ach> with an Error Message then returns False
-- <mess> is included in the Error message if given non empty
ReadSubList (me; num, nump : Integer; mess : CString; ach : in out Check;
numsub : out Integer;
optional : Boolean = Standard_False;
lenmin : Integer = 0; lenmax : Integer = 0)
returns Boolean is static;
---Purpose : reads parameter <nump> of record <num> as a sub-list (may be
-- typed, see ReadTypedParameter in this case)
-- Returns True if OK. Else (not a LIST), returns false and
-- feeds Check with appropriate check
-- If <optional> is True and Param is not defined, returns True
-- with <ach> not filled and <numsub> returned as 0
-- Works with SubListNumber with <aslast> false (no specific case
-- for last parameter)
ReadSub (me; numsub : Integer; mess : CString; ach : in out Check;
descr : PDescr; val : out Transient) returns Integer;
---Purpose : reads the content of a sub-list into a transient :
-- SelectNamed, or HArray1 of Integer,Real,String,Transient ...
-- recursive call if list of list ...
-- If a sub-list has mixed types, an HArray1OfTransient is
-- produced, it may contain SelectMember
-- Intended to be called by ReadField
-- The returned status is : negative if failed, 0 if empty.
-- Else the kind to be recorded in the field
ReadMember (me; num, nump : Integer; mess : CString; ach : in out Check;
val : in out mutable SelectMember) returns Boolean;
---Purpose : Reads parameter <nump> of record <num> into a SelectMember,
-- self-sufficient (no Description needed)
-- If <val> is already created, it will be filled, as possible
-- And if reading does not match its own description, the result
-- will be False
-- If <val> is not it not yet created, it will be (SelectNamed)
-- Usefull if a field is defined as a SelectMember, directly
-- (SELECT with no Entity as member)
-- But SelectType also manages SelectMember (for SELECT with
-- some members as Entity, some other not)
ReadField (me; num, nump : Integer; mess : CString; ach : in out Check;
descr : PDescr; fild : in out Field) returns Boolean;
---Purpose : reads parameter <nump> of record <num> into a Field,
-- controlled by a Parameter Descriptor (PDescr), which controls
-- its allowed type(s) and value
-- <ach> is filled if the read parameter does not match its
-- description (but the field is read anyway)
-- If the description is not defined, no control is done
-- Returns True when done
ReadList (me; num : Integer; ach : in out Check;
descr : ESDescr; list : in out FieldList) returns Boolean;
---Purpose : reads a list of fields controlled by an ESDescr
ReadAny (me; num, nump : Integer; mess : CString; ach : in out Check;
descr : PDescr; val : in out mutable Transient) returns Boolean;
---Purpose : Reads parameter <nump> of record <num> into a Transient Value
-- according to the type of the parameter :
-- Named for Integer,Boolean,Logical,Enum,Real : SelectNamed
-- Immediate Integer,Boolean,Logical,Enum,Real : SelectInt/Real
-- Text : HAsciiString
-- Ident : the referenced Entity
-- Sub-List not processed, see ReadSub
-- This value is controlled by a Parameter Descriptor (PDescr),
-- which controls its allowed type and value
-- <ach> is filled if the read parameter does not match its
-- description (the select is nevertheless created if possible)
--
-- Warning : val is in out, hence it is possible to predefine a specific
-- SelectMember then to fill it. If <val> is Null or if the
-- result is not a SelectMember, val itself is returned a new ref
-- For a Select with a Name, <val> must then be a SelectNamed
ReadXY (me; num, nump : Integer; mess : CString; ach : in out Check;
X,Y : out Real) returns Boolean is static;
---Purpose : reads parameter <nump> of record <num> as a sub-list of
-- two Reals X,Y. Returns True if OK. Else, returns false and
-- feeds Check with appropriate Fails (parameter not a sub-list,
-- not two Reals in the sub-list) composed with "mess" which
-- gives the name of the parameter
ReadXYZ (me; num, nump : Integer; mess : CString; ach : in out Check;
X,Y,Z : out Real) returns Boolean is static;
---Purpose : reads parameter <nump> of record <num> as a sub-list of
-- three Reals X,Y,Z. Return value and Check managed as by
-- ReadXY (demands a sub-list of three Reals)
ReadReal (me; num, nump : Integer; mess : CString; ach : in out Check;
val : out Real) returns Boolean is static;
---Purpose : reads parameter <nump> of record <num> as a single Real value.
-- Return value and Check managed as by ReadXY (demands a Real)
ReadEntity (me; num, nump : Integer; mess : CString; ach : in out Check;
atype : Type; ent : out mutable Transient)
returns Boolean is static;
---Purpose : Reads parameter <nump> of record <num> as a single Entity.
-- Return value and Check managed as by ReadReal (demands a
-- reference to an Entity). In Addition, demands read Entity
-- to be Kind of a required Type <atype>.
-- Remark that returned status is False and <ent> is Null if
-- parameter is not an Entity, <ent> remains Not Null is parameter
-- is an Entity but is not Kind of required type
ReadEntity (me; num, nump : Integer; mess : CString; ach : in out Check;
sel : in out SelectType) returns Boolean is static;
---Purpose : Same as above, but a SelectType checks Type Matching, and
-- records the read Entity (see method Value from SelectType)
ReadInteger (me; num, nump : Integer; mess : CString; ach : in out Check;
val : out Integer) returns Boolean is static;
---Purpose : reads parameter <nump> of record <num> as a single Integer.
-- Return value & Check managed as by ReadXY (demands an Integer)
ReadBoolean (me; num, nump : Integer; mess : CString; ach : in out Check;
flag : out Boolean) returns Boolean is static;
---Purpose : reads parameter <nump> of record <num> as a Boolean
-- Return value and Check managed as by ReadReal (demands a
-- Boolean enum, i.e. text ".T." for True or ".F." for False)
ReadLogical (me; num, nump : Integer; mess : CString; ach : in out Check;
flag : out Logical from StepData) returns Boolean is static;
---Purpose : reads parameter <nump> of record <num> as a Logical
-- Return value and Check managed as by ReadBoolean (demands a
-- Logical enum, i.e. text ".T.", ".F.", or ".U.")
ReadString (me; num, nump : Integer; mess : CString; ach : in out Check;
val : out mutable HAsciiString from TCollection)
returns Boolean is static;
---Purpose : reads parameter <nump> of record <num> as a String (text
-- between quotes, quotes are removed by the Read operation)
-- Return value and Check managed as by ReadXY (demands a String)
ReadEnumParam (me; num, nump : Integer; mess : CString; ach : in out Check;
text : out CString)
returns Boolean is static;
---Puroise : Reads parameter <nump> of record <num>, checks if it is an
-- Enumeration, if yes returns its text value
-- Returns True if OK, False (+ empty string) if not an enum
-- (also fills <ach>
FailEnumValue (me; num, nump : Integer; mess : CString; ach : in out Check);
---Purpose : Fills a check with a fail message if enumeration value does
-- match parameter definition
-- Just a help to centralize message definitions
ReadEnum (me; num, nump : Integer; mess : CString; ach : in out Check;
enumtool : EnumTool from StepData; val : out Integer)
returns Boolean is static;
---Purpose : Reads parameter <nump> of record <num> as an Enumeration (text
-- between dots) and converts it to an integer value, by an
-- EnumTool. Returns True if OK, false if : this parameter is not
-- enumeration, or is not recognized by the EnumTool (with fail)
ReadTypedParam (me; num,nump : Integer; mustbetyped : Boolean;
mess : CString; ach : in out Check;
numr,numrp : out Integer; typ : out AsciiString)
returns Boolean is static;
---Purpose : Resolves a parameter which can be enclosed in a type def., as
-- TYPE(val). The parameter must then be read normally according
-- its type. Parameter to be resolved is <nump> of record <num>
-- <mustbetyped> True demands a typed parameter
-- <mustbetyped> False accepts a non-typed parameter as option
-- mess and ach as usual
-- <numr>,<numrp> are the resolved record and parameter numbers
-- = num,nump if no type, else numrp=1
-- <typ> returns the recorded type, or empty string
-- Remark : a non-typed list is considered as "non-typed"
CheckDerived (me; num, nump : Integer; mess : CString; ach : in out Check;
errstat : Boolean = Standard_False)
returns Boolean is static;
---Purpose : Checks if parameter <nump> of record <num> is given as Derived
-- If this Check is successful (i.e. Param = "*"), returns True
-- Else, fills <ach> with a Message which contains <mess> and
-- returns False. According to <errstat>, this message is Warning
-- if errstat is False (Default), Fail if errstat is True
-- -- General exploitation methods -- --
NbEntities (me) returns Integer is redefined;
---Purpose : Returns total count of Entities (including Header)
FindNextRecord (me; num : Integer) returns Integer;
---Purpose : determines the first suitable record following a given one
-- that is, skips SCOPE,ENDSCOPE and SUBLIST records
-- Note : skips Header records, which are accessed separately
FindEntityNumber (me; num, id : Integer) returns Integer is static private;
---Purpose : Searches for a Parameter of the record <num>, which refers to
-- the Ident <id> (form #nnn). [Used by SetEntityNumbers]
-- If found, returns its EntityNumber, else returns Zero.
-- -- Preparation before loading model -- --
SetEntityNumbers (me : mutable; withmap : Boolean = Standard_True);
---Purpose : determines reference numbers in EntityNumber fields
-- called by Prepare from StepReaderTool to prepare later using
-- by a StepModel. This method is attached to StepReaderData
-- because it needs a massive amount of data accesses to work
--
-- If <withmap> is given False, the basic exploration algorithm
-- is activated, otherwise a map is used as far as it is possible
-- this option can be used only to test this algorithm
-- -- Managing Header -- --
-- Header is defined as a list of StepEntities (without ident)
FindNextHeaderRecord (me; num : Integer) returns Integer;
---Purpose : determine first suitable record of Header
-- works as FindNextRecord, but treats only Header records
PrepareHeader (me : mutable);
---Purpose : Works as SetEntityNumbers but for Header : more simple because
-- there are no Reference, only Sub-Lists
GlobalCheck (me) returns Check;
---Purpose : Returns the Global Check. It can record Fail messages about
-- Undefined References (detected by SetEntityNumbers)
---C++ : return const
fields
theidents : Array1OfInteger from TColStd;
-- ident (entity/sub) or indicates SCOPE/END.
-- thetypes : Array1OfAsciiString;
thetypes : Array1OfInteger;
thenametypes : IndexedMapOfAsciiString from Interface;
themults : DataMapOfIntegerInteger from TColStd;
--themults : Array1OfInteger from TColStd; -- For Complex Type Entities
thenbents : Integer; -- internal data used for optimization
thelastn : Integer;
thenbhead : Integer; -- nb of records taken by Header
thenbscop : Integer;
thecheck : Check;
end StepReaderData;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,86 @@
-- File: StepReaderTool.cdl
-- Created: Tue Feb 11 16:48:58 1992
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1992
class StepReaderTool from StepData inherits FileReaderTool
---Purpose : Specific FileReaderTool for Step; works with FileReaderData
-- provides references evaluation, plus access to litteral data
-- and specific methods defined by FileReaderTool
-- Remarks : works with a ReaderLib to load Entities
uses Integer, Boolean, Transient,
InterfaceModel, Check, GeneralLib, ReaderLib,
StepReaderData, FileRecognizer, Protocol from StepData
is
-- -- File data storing and access (specific) -- --
Create (reader : mutable StepReaderData; protocol : Protocol from StepData)
returns StepReaderTool;
---Purpose : creates StepReaderTool to work with a StepReaderData according
-- to a Step Protocol. Defines the ReaderLib at this time
-- -- setting empty entities before loading model -- --
Prepare (me : in out; optimize : Boolean = Standard_True);
---Purpose : Bounds empty entities to records, uses default Recognition
-- provided by ReaderLib and ReaderModule. Also calls computation
-- of references (SetEntityNumbers from StepReaderData)
-- Works only on data entities (skips header)
-- <optimize> given False allows to test some internal algorithms
-- which are normally avoided (see also StepReaderData)
Prepare (me : in out; reco : mutable FileRecognizer;
optimize : Boolean = Standard_True);
---Purpose : Bounds empty entities to records, works with a specific
-- FileRecognizer, stored and later used in Recognize
-- Works only on data entities (skips header)
-- <optimize : same as above
Recognize (me : in out; num : Integer;
ach : in out Check; ent : out mutable Transient)
returns Boolean;
---Purpose : recognizes records, by asking either ReaderLib (default) or
-- FileRecognizer (if defined) to do so. <ach> is to call
-- RecognizeByLib
-- -- managing Header -- --
-- Header is defined as a list of StepEntities (without ident)
PrepareHeader (me : in out; reco : mutable FileRecognizer);
---Purpose : bounds empty entities and sub-lists to header records
-- works like Prepare + SetEntityNumbers, but for header
-- (N.B.: in Header, no Ident and no reference)
-- FileRecognizer is to specify Entities which are allowed to be
-- defined in the Header (not every type can be)
-- -- loading entities into the model -- --
BeginRead (me : in out; amodel : mutable InterfaceModel);
---Purpose : fills model's header; that is, gives to it Header entities
-- and commands their loading. Also fills StepModel's Global
-- Check from StepReaderData's GlobalCheck
AnalyseRecord (me : in out;
num : Integer; anent : mutable Transient; acheck : in out Check)
returns Boolean;
---Purpose : fills an entity, given record no; works by using a ReaderLib
-- to load each entity, which must be a Transient
-- Actually, returned value is True if no fail, False else
EndRead (me : in out; amodel : mutable InterfaceModel) is redefined;
---Purpose : Ends file reading after reading all the entities
-- Here, it binds in the model, Idents to Entities (for checks)
fields
thereco : FileRecognizer;
theglib : GeneralLib;
therlib : ReaderLib;
end StepReaderTool;

View File

@@ -0,0 +1,227 @@
#include <StepData_StepReaderTool.ixx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <StepData_StepModel.hxx>
#include <Standard_Transient.hxx>
#include <StepData_ReadWriteModule.hxx>
#include <StepData_UndefinedEntity.hxx>
#include <Message_Messenger.hxx>
#include <Message.hxx>
#include <Interface_Macros.hxx>
#include <TCollection_AsciiString.hxx>
//=======================================================================
//function : StepData_StepReaderTool
//purpose :
//=======================================================================
StepData_StepReaderTool::StepData_StepReaderTool
(const Handle(StepData_StepReaderData)& reader,
const Handle(StepData_Protocol)& protocol)
: theglib(protocol) , therlib(protocol)
{
SetData(reader,protocol);
}
//=======================================================================
//function : Recognize
//purpose :
//=======================================================================
Standard_Boolean StepData_StepReaderTool::Recognize(const Standard_Integer num,
Handle(Interface_Check)& ach,
Handle(Standard_Transient)& ent)
{
// Handle(Standard_Transient) bid; // pas exploite
// return thereco->Evaluate(thetypes.Value(num),bid);
// Recognizer : C est lui qui assure la Reconnaissance (-> Liste limitative)
if (!thereco.IsNull()) {
DeclareAndCast(StepData_StepReaderData,stepdat,Data());
return thereco->Evaluate(stepdat->RecordType(num),ent);
}
// Pas de Recognizer : Reconnaissance par la librairie
return RecognizeByLib (num,theglib,therlib,ach,ent);
}
// .... Methodes de preparations propres a StepReaderTool ....
//=======================================================================
//function : Prepare
//purpose :
//=======================================================================
void StepData_StepReaderTool::Prepare
(const Handle(StepData_FileRecognizer)& reco, const Standard_Boolean optim)
{
thereco = reco;
Prepare(optim);
}
//=======================================================================
//function : Prepare
//purpose :
//=======================================================================
void StepData_StepReaderTool::Prepare (const Standard_Boolean optim)
{
// SetEntityNumbers a ete mis du cote de ReaderData, because beaucoup acces
Standard_Boolean erh = ErrorHandle();
DeclareAndCast(StepData_StepReaderData,stepdat,Data());
if (erh) {
try {
OCC_CATCH_SIGNALS
stepdat->SetEntityNumbers(optim);
SetEntities();
}
catch(Standard_Failure) {
Handle(Message_Messenger) sout = Message::DefaultMessenger();
sout << " Exception Raised during Preparation :\n";
sout << Standard_Failure::Caught()->GetMessageString();
sout << "\n Now, trying to continue, but with presomption of failure\n";
}
}
else {
stepdat->SetEntityNumbers(optim);
SetEntities();
}
}
// .... Gestion du Header : Preparation, lecture .... //
//=======================================================================
//function : PrepareHeader
//purpose :
//=======================================================================
void StepData_StepReaderTool::PrepareHeader
(const Handle(StepData_FileRecognizer)& reco)
{
Standard_Integer i = 0;
// Reconnaissance des types
DeclareAndCast(StepData_StepReaderData,stepdat,Data());
while ( (i = stepdat->FindNextHeaderRecord(i)) != 0) {
Handle(Standard_Transient) ent;
// On a donne un Recognizer : il fixe une liste limitative de types reconnus
if (!reco.IsNull()) {
if (!reco->Evaluate(stepdat->RecordType(i),ent)) {
ent = Protocol()->UnknownEntity();
}
} else {
// Pas de Recognizer : Reconnaissance par la librairie
Handle(Interface_Check) ach = new Interface_Check; // faudrait le lister ... ?
RecognizeByLib (i,theglib,therlib,ach,ent);
}
if (ent.IsNull()) ent = Protocol()->UnknownEntity();
stepdat->BindEntity(i,ent);
}
// Reste la Resolution des references : ne concerne que les sous-listes
// Assuree par ReaderData
stepdat->PrepareHeader();
}
// .... Methodes pour la lecture du Modele (apres preparation) .... //
//=======================================================================
//function : BeginRead
//purpose :
//=======================================================================
void StepData_StepReaderTool::BeginRead
(const Handle(Interface_InterfaceModel)& amodel)
{
Handle(Message_Messenger) sout = Message::DefaultMessenger();
DeclareAndCast(StepData_StepModel,model,amodel);
DeclareAndCast(StepData_StepReaderData,stepdat,Data());
model->ClearHeader();
model->SetGlobalCheck(stepdat->GlobalCheck());
Standard_Integer i = 0;
while ( (i = stepdat->FindNextHeaderRecord(i)) != 0) {
Handle(Standard_Transient) ent = stepdat->BoundEntity(i);
Handle(Interface_Check) ach = new Interface_Check(ent);
AnalyseRecord(i,ent,ach);
if (ent->IsKind(STANDARD_TYPE(StepData_UndefinedEntity))) {
TCollection_AsciiString mess("Header Entity not Recognized, StepType: ");
mess.AssignCat(stepdat->RecordType(i));
ach->AddWarning(mess.ToCString());
}
if (ach->HasFailed() || ach->HasWarnings()) {
Handle(Interface_Check) mch = model->GlobalCheck();
mch->GetMessages(ach); model->SetGlobalCheck(mch);
}
model->AddHeaderEntity(ent);
if (ach->HasWarnings()) {
Handle(Interface_Check) mch = model->GlobalCheck();
Standard_Integer nbmess = ach->NbWarnings();
sout<<nbmess<<" Warnings on Reading Header Entity N0."<<i<<":";
if (!ent.IsNull()) sout << ent->DynamicType()->Name() << endl;
for (Standard_Integer nf = 1; nf <= nbmess; nf ++)
sout << ach->CWarning(nf) << "\n";
}
if (ach->HasFailed()) {
Handle(Interface_Check) mch = model->GlobalCheck();
Standard_Integer nbmess = ach->NbFails();
sout << " Errors on Reading Header Entity N0."<<i<<":";
if (!ent.IsNull()) sout << ent->DynamicType()->Name() << endl;
for (Standard_Integer nf = 1; nf <= nbmess; nf ++)
sout << ach->CFail(nf) << "\n";
}
}
}
//=======================================================================
//function : AnalyseRecord
//purpose :
//=======================================================================
Standard_Boolean StepData_StepReaderTool::AnalyseRecord
(const Standard_Integer num,
const Handle(Standard_Transient)& anent,
Handle(Interface_Check)& acheck)
{
DeclareAndCast(StepData_StepReaderData,stepdat,Data());
Handle(StepData_ReadWriteModule) module; Standard_Integer CN;
if (therlib.Select(anent,module,CN))
module->ReadStep(CN,stepdat,num,acheck,anent);
else {
// Pas trouve : tenter UndefinedEntity de StepData
DeclareAndCast(StepData_UndefinedEntity,und,anent);
if (und.IsNull()) acheck->AddFail
("# Entity neither Recognized nor set as UndefinedEntity from StepData #");
else und->ReadRecord(stepdat,num,acheck);
}
return (!acheck->HasFailed());
}
//=======================================================================
//function : EndRead
//purpose :
//=======================================================================
void StepData_StepReaderTool::EndRead
(const Handle(Interface_InterfaceModel)& amodel)
{
DeclareAndCast(StepData_StepReaderData,stepdat,Data());
DeclareAndCast(StepData_StepModel,stepmodel,amodel);
if (stepmodel.IsNull()) return;
Standard_Integer i = 0;
while ( (i = stepdat->FindNextRecord(i)) != 0) {
stepmodel->SetIdentLabel(stepdat->BoundEntity(i),stepdat->RecordIdent(i));
}
}

View File

@@ -0,0 +1,299 @@
-- File: StepWriter.cdl
-- Created: Tue Feb 11 19:54:04 1992
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1992
class StepWriter from StepData
---Purpose : manages atomic file writing, under control of StepModel (for
-- general organisation of file) and each class of Transient
-- (for its own parameters) : prepares text to be written then
-- writes it
-- A stream cannot be used because Step limits line length at 72
-- In more, a specific object offers more appropriate functions
uses Integer, Boolean, Real, Character, Transient, Logical from StepData, -- OStream,
AsciiString from TCollection, HAsciiString from TCollection,
HSequenceOfHAsciiString, HArray1OfInteger,
LineBuffer, FloatWriter, CheckIterator,
StepModel, WriterLib, Protocol from StepData,
SelectMember from StepData, Field from StepData, PDescr from StepData,
FieldList from StepData, ESDescr from StepData,
HArray1OfReal from TColStd
raises InterfaceMismatch
is
Create (amodel : StepModel) returns StepWriter;
---Purpose : Creates an empty StepWriter from a StepModel. The StepModel
-- provides the Number of Entities, as identifiers for File
-- Options for Sending Forms --
LabelMode (me : in out) returns Integer;
---Purpose : ModeLabel controls how to display entity ids :
-- 0 (D) gives entity number in the model
-- 1 gives the already recorded label (else, its number)
-- Warning : conflicts are not controlled
---C++ : return &
TypeMode (me : in out) returns Integer;
---Purpose : TypeMode controls the type form to use :
-- 0 (D) for normal long form
-- 1 for short form (if a type name has no short form, normal
-- long form is then used)
---C++ : return &
FloatWriter (me : in out) returns FloatWriter;
---Purpose : Returns the embedded FloatWriter, which controls sending Reals
-- Use this method to access FloatWriter in order to consult or
-- change its options (MainFormat, FormatForRange,ZeroSuppress),
-- because it is returned as the address of its field
---C++ : return &
-- -- Description of Scopes -- -- (to be done before sending)
SetScope (me : in out; numscope,numin : Integer)
---Purpose : Declares the Entity Number <numscope> to correspond to a Scope
-- which contains the Entity Number <numin>. Several calls to the
-- same <numscope> add Entities in this Scope, in this order.
raises InterfaceMismatch;
---Purpose: Error if <numin> is already declared in the Scope
-- Warning : the declaration of the Scopes is assumed to be consistent,
-- i.e. <numin> is not referenced from outside this Scope
-- (not checked here)
IsInScope (me; num : Integer) returns Boolean;
---Purpose : Returns True if an Entity identified by its Number is in a Scope
-- -- Sending Parts of a Model -- --
SendModel (me : in out; protocol : Protocol from StepData;
headeronly : Boolean = Standard_False)
---Purpose : Sends the complete Model, included HEADER and DATA Sections
-- Works with a WriterLib defined through a Protocol
-- If <headeronly> is given True, only the HEADER Section is sent
-- (used to Dump the Header of a StepModel)
raises InterfaceMismatch;
-- Error if any of the called Send's falls in Error
SendHeader (me : in out);
---Purpose : Begins model header
SendData (me : in out) raises InterfaceMismatch;
---Purpose : Begins data section; error if EndSec was not set
SendEntity (me : in out; nument : Integer; lib : WriterLib)
---Purpose : Send an Entity of the Data Section. If it corresponds to a
-- Scope, also Sends the Scope informations and contained Items
raises InterfaceMismatch;
-- Error if any of the called Send's falls in Error
EndSec (me : in out);
---Purpose : sets end of section; to be done before passing to next one
EndFile (me : in out) raises InterfaceMismatch;
---Purpose : sets end of file; error is EndSec was not set
-- -- Managing line -- --
AddString (me : in out; str : AsciiString from TCollection; more : Integer = 0)
is private;
---Purpose : adds a string to current line; first flushes it if full
-- (72 char); more allows to ask a reserve at end of line : flush
-- is done if remaining length (to 72) is less than <more>
AddString (me : in out; str : CString; lnstr : Integer; more : Integer = 0)
is private;
---Purpose : Same as above, but the string is given by CString + Length
NewLine (me : in out; evenempty : Boolean);
---Purpose : flushes current line; if empty, flushes it (defines a new
-- empty line) if evenempty is True; else, skips it
JoinLast (me : in out; newline : Boolean);
---Purpose : joins current line to last one, only if new length is 72 max
-- if newline is True, a new current line begins; else, current
-- line is set to the last line (once joined) itself an can be
-- completed
Indent (me : in out; onent : Boolean);
---Purpose : asks that further indentations will begin at position of
-- entity first opening bracket; else they begin at zero (def)
-- for each sublist level, two more blancks are added at beginning
-- (except for text continuation, which must begin at true zero)
-- -- Sending entities -- --
SendIdent (me : in out; ident : Integer);
---Purpose : begins an entity with an ident plus '=' (at beginning of line)
-- entity ident is its Number given by the containing Model
-- Warning : <ident> must be, either Number or Label, according LabelMode
SendScope (me : in out);
---Purpose : sets a begin of Scope (ends this line)
SendEndscope (me : in out);
---Purpose : sets an end of Scope (on a separate line)
Comment (me : in out; mode : Boolean);
---Purpose : sets a comment mark : if mode is True, begins Comment zone,
-- if mode is False, ends Comment zone (if one is begun)
SendComment (me : in out; text : HAsciiString from TCollection)
raises InterfaceMismatch;
---Purpose : sends a comment. Error if we are not inside a comment zone
SendComment (me : in out; text : CString) raises InterfaceMismatch;
---Purpose : same as above but accepts a CString (ex.: "..." directly)
StartEntity (me : in out; atype : AsciiString from TCollection);
---Purpose : sets entity's StepType, opens brakets, starts param no to 0
-- params are separated by comma
-- Remark : for a Multiple Type Entity (see Express ANDOR clause)
-- StartComplex must be called before sending componants, then
-- each "Componant" must be send separately (one call to
-- StartEntity for each one) : the Type which preceeds is then
-- automaticaly closed. Once all the componants have been sent,
-- EndComplex must be called, then and only then EndEntity
StartComplex (me : in out);
---Purpose : sends the start of a complex entity, which is a simple open
-- bracket (without increasing braket level)
-- It must be called JUST AFTER SendEntity and BEFORE sending
-- componants, each one begins by StartEntity
EndComplex (me : in out);
---Purpose : sends the end of a complex entity : a simple closed bracket
-- It must be called AFTER sending all the componants and BEFORE
-- the final call to EndEntity
-- -- Sending Parameters -- --
SendField (me : in out; fild : Field; descr : PDescr);
---Purpose : Sends the content of a field, controlled by its descriptor
-- If the descriptor is not defined, follows the description
-- detained by the field itself
SendSelect (me : in out; sm : SelectMember; descr : PDescr);
---Purpose : Sends a SelectMember, which cab be named or not
SendList (me : in out; list : FieldList; descr : ESDescr);
---Purpose : Send the content of an entity as being a FieldList controlled
-- by its descriptor. This includes start and end brackets but
-- not the entity type
OpenSub (me : in out);
---Purpose : open a sublist by a '('
OpenTypedSub (me : in out; subtype : CString);
---Purpose : open a sublist with its type then a '('
CloseSub (me : in out);
---Purpose : closes a sublist by a ')'
AddParam (me : in out);
---Purpose : prepares adding a parameter (that is, adds ',' except for
-- first one); normally for internal use; can be used to send
-- a totally empty parameter (with no litteral value)
Send (me : in out; val : Integer);
---Purpose : sends an integer parameter
Send (me : in out; val : Real);
---Purpose : sends a real parameter (wroks with FloatWriter)
Send (me : in out; val : AsciiString from TCollection);
---Purpose : sends a text given as string (it will be set between '...')
Send (me : in out; val : Transient);
---Purpose : sends a reference to an entity (its identifier with '#')
-- REMARK 1 : a Null <val> is interpreted as "Undefined"
-- REMARK 2 : for an HAsciiString which is not recorded in the
-- Model, it is send as its String Content, between quotes
SendBoolean (me : in out; val : Boolean);
---Purpose : sends a Boolean as .T. for True or .F. for False
-- (it is an useful case of Enum, which is built-in)
SendLogical (me : in out; val : Logical from StepData);
---Purpose : sends a Logical as .T. or .F. or .U. according its Value
-- (it is a standard case of Enum for Step, and is built-in)
SendString (me : in out; val : AsciiString from TCollection);
---Purpose : sends a string exactly as it is given
SendString (me : in out; val : CString);
---Purpose : sends a string exactly as it is given
SendEnum (me : in out; val : AsciiString from TCollection);
---Purpose : sends an enum given by String (litteral expression)
-- adds '.' around it if not done
-- Remark : val can be computed by class EnumTool from StepData:
-- StepWriter.SendEnum (myenum.Text(enumval));
SendEnum (me : in out; val : CString);
---Purpose : sends an enum given by String (litteral expression)
-- adds '.' around it if not done
SendArrReal(me : in out; anArr : HArray1OfReal from TColStd);
---Purpose : sends an array of real
SendUndef (me : in out);
---Purpose : sends an undefined (optionnal absent) parameter (by '$')
SendDerived (me : in out);
---Purpose : sends a "Derived" parameter (by '*'). A Derived Parameter has
-- been inherited from a Super-Type then redefined as being
-- computed by a function. Hence its value in file is senseless.
EndEntity (me : in out) raises InterfaceMismatch;
---Purpose : sends end of entity (closing bracket plus ';')
-- Error if count of opened-closed brackets is not null
-- -- Printing on an output -- --
CheckList (me) returns CheckIterator;
---Purpose : Returns the check-list, which has received possible checks :
-- for unknown entities, badly loaded ones, null or unknown
-- references
NbLines (me) returns Integer;
---Purpose : Returns count of Lines
Line (me; num : Integer) returns HAsciiString from TCollection;
---Purpose : Returns a Line given its rank in the File
Print (me : in out; S : in out OStream) returns Boolean;
---Purpose : writes result on an output defined as an OStream
-- then clears it
fields
themodel : StepModel;
thefile : HSequenceOfHAsciiString;
thecurr : LineBuffer;
thesect : Boolean; -- False at very start or after EndSec
thecomm : Boolean; -- are we in inside a comment
thefirst : Boolean; -- True on first parameter, False on following ones
themult : Boolean; -- True after sending first type (for Multiple Type)
thelevel : Integer; -- current sublist level
theindent : Boolean; -- True to indent at entity opening bracket
theindval : Integer; -- position of entity opening bracket
thetypmode : Integer;
thefloatw : FloatWriter; -- control of sending Reals
thechecks : CheckIterator;
thenum : Integer;
thelabmode : Integer;
thescopebeg : HArray1OfInteger;
thescopeend : HArray1OfInteger;
thescopenext : HArray1OfInteger;
end StepWriter;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,76 @@
-- File: UndefinedEntity.cdl
-- Created: Tue Feb 11 15:51:36 1992
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1992
class UndefinedEntity from StepData inherits TShared
---Purpose : Undefined entity specific to Step Interface, in which StepType
-- is defined at each instance, or is a SubList of another one
-- Uses an UndefinedContent, that from Interface is suitable.
-- Also an Entity defined by STEP can be "Complex Type" (see
-- ANDOR clause in Express).
uses AsciiString from TCollection, HAsciiString from TCollection,
UndefinedContent, Check, CopyTool, EntityIterator,
StepReaderData, StepWriter
is
Create returns mutable UndefinedEntity;
---Purpose : creates an Unknown entity
Create (issub : Boolean) returns mutable UndefinedEntity;
---Purpose : Creates a SubList of an Unknown entity : it is an Unknown
-- Entity with no Type, but flagged as "SUB" if issub is True
UndefinedContent (me) returns mutable UndefinedContent;
---Purpose : Returns the UndefinedContent which brings the Parameters
IsSub (me) returns Boolean;
---Purpose : Returns True if an Unndefined Entity is SubPart of another one
Super (me) returns mutable UndefinedEntity;
---Purpose : Returns the "super-entity" of a sub-part
IsComplex (me) returns Boolean;
---Purpose : Returns True if <me> defines a Multiple Type Entity (see ANDOR)
Next (me) returns mutable UndefinedEntity;
---Purpose : For a Multiple Type Entity, returns the Next "Componant"
-- For more than two Types, iterative definition (Next->Next...)
-- Returns a Null Handle for the end of the List
StepType (me) returns CString;
---Purpose : gives entity type, read from file
-- For a Complex Type Entity, gives the first Type read, each
-- "Next" gives its "partial" type
-- was C++ : return const
ReadRecord (me : mutable;
SR : StepReaderData; num : Integer; ach : in out Check);
---Purpose : reads data from StepReaderData (i.e. from file), by filling
-- StepType and parameters stored in the UndefinedContent
WriteParams (me; SW : in out StepWriter);
---Purpose : write data to StepWriter, taken from UndefinedContent
GetFromAnother (me : mutable; other : like me;
TC : in out CopyTool);
---Purpose : reads another UndefinedEntity from StepData
FillShared (me; list : in out EntityIterator from Interface);
---Purpose : Fills the list of shared entities
fields
thetype : HAsciiString from TCollection;
thecont : UndefinedContent;
thesub : Boolean;
thenext : UndefinedEntity; -- for a Multiple Type Entity
end UndefinedEntity;

View File

@@ -0,0 +1,141 @@
#include <StepData_UndefinedEntity.ixx>
#include <Interface_ParamType.hxx>
#include <TCollection_AsciiString.hxx>
#include <Interface_Macros.hxx>
StepData_UndefinedEntity::StepData_UndefinedEntity ()
{ thecont = new Interface_UndefinedContent; thesub = Standard_False; }
StepData_UndefinedEntity::StepData_UndefinedEntity
(const Standard_Boolean issub)
{ thesub = issub; thecont = new Interface_UndefinedContent; }
Handle(Interface_UndefinedContent)
StepData_UndefinedEntity::UndefinedContent () const
{ return thecont; }
Standard_Boolean StepData_UndefinedEntity::IsSub () const
{ return thesub; }
Standard_Boolean StepData_UndefinedEntity::IsComplex () const
{ return (!thenext.IsNull()); }
Handle(StepData_UndefinedEntity) StepData_UndefinedEntity::Next () const
{ return thenext; }
Standard_CString StepData_UndefinedEntity::StepType () const
{ if (thetype.IsNull()) return ""; return thetype->ToCString(); }
void StepData_UndefinedEntity::ReadRecord(const Handle(StepData_StepReaderData)& SR,
const Standard_Integer num,
Handle(Interface_Check)& ach)
{
thetype = new TCollection_HAsciiString(SR->RecordType(num));
Standard_Integer nb = SR->NbParams(num);
thecont->Reservate (nb,4);
for (Standard_Integer i = 1; i <= nb; i ++) {
Handle(Standard_Transient) anent;
Handle(TCollection_HAsciiString) hval;
Standard_CString val = SR->ParamCValue(num,i);
Interface_ParamType partyp = SR->ParamType(num,i);
Standard_Integer nume = 0;
if (partyp == Interface_ParamIdent) {
nume = SR->ParamNumber(num,i);
if (nume <= 0) {
ach->AddFail("A reference to another entity is unresolved");
partyp = Interface_ParamVoid;
}
else {
anent = SR->BoundEntity(nume);
}
}
else if (partyp == Interface_ParamSub) {
nume = SR->ParamNumber(num,i);
Handle(StepData_UndefinedEntity) und = new StepData_UndefinedEntity (Standard_True);
anent = und;
und->ReadRecord(SR,nume,ach);
}
else if (partyp == Interface_ParamText) {
// Return integre a supprimer silya
Standard_Integer lval = strlen(val); Standard_Integer mval = -1;
for (Standard_Integer j = 0; j < lval; j ++) {
if (val[j] == '\n') { mval = i; break; }
}
if (mval > 0) {
nume = -1;
hval = new TCollection_HAsciiString (val);
hval->RemoveAll('\n');
}
}
if (nume == 0) hval = new TCollection_HAsciiString (val);
if (nume > 0) thecont->AddEntity(partyp,anent);
else thecont->AddLiteral (partyp,hval);
}
Standard_Integer nextyp = SR->NextForComplex(num);
if (nextyp == 0) return;
thenext = new StepData_UndefinedEntity;
thenext->ReadRecord(SR,nextyp,ach);
}
void StepData_UndefinedEntity::WriteParams (StepData_StepWriter& SW) const
{
if (!IsSub()) SW.StartEntity(TCollection_AsciiString(StepType()));
Standard_Integer nb = thecont->NbParams();
Handle(Standard_Transient) anent;
for (Standard_Integer i = 1; i <= nb; i ++) {
Interface_ParamType partyp = thecont->ParamType(i);
if (partyp == Interface_ParamSub) {
DeclareAndCast(StepData_UndefinedEntity,und,thecont->ParamEntity(i));
und->StepType(); //svv #2
if (und->IsSub()) SW.OpenTypedSub (und->StepType());
und->WriteParams(SW);
if (und->IsSub()) SW.CloseSub();
}
else if (partyp == Interface_ParamIdent) {
anent = thecont->ParamEntity(i);
SW.Send(anent);
}
else SW.SendString (thecont->ParamValue(i)->ToCString());
}
// if (IsSub()) return;
// SW.NewLine(Standard_True);
if (thenext.IsNull()) return;
thenext->WriteParams(SW);
}
void StepData_UndefinedEntity::GetFromAnother
(const Handle(StepData_UndefinedEntity)& another,
Interface_CopyTool& TC)
{
// DeclareAndCast(StepData_UndefinedEntity,another,other);
thetype = new TCollection_HAsciiString (another->StepType());
thecont = new Interface_UndefinedContent;
thecont->GetFromAnother(another->UndefinedContent(),TC);
thesub = another->IsSub();
if (another->IsComplex()) thenext =
GetCasted(StepData_UndefinedEntity,TC.Transferred(another->Next()));
else thenext.Nullify();
}
void StepData_UndefinedEntity::FillShared
(Interface_EntityIterator& list) const
{
Standard_Integer i, nb = thecont->NbParams();
for (i = 1; i <= nb; i ++) {
Interface_ParamType ptype = thecont->ParamType(i);
if (ptype == Interface_ParamSub) {
DeclareAndCast(StepData_UndefinedEntity,subent,thecont->ParamEntity(i));
subent->FillShared (list);
} else if (ptype == Interface_ParamIdent) {
list.AddItem(thecont->ParamEntity(i));
}
}
if (!thenext.IsNull()) thenext->FillShared (list);
}