1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-08 14:17:06 +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

6
src/LibCtl/FILES Executable file
View File

@@ -0,0 +1,6 @@
LibCtl.cdl
LibCtl_GlobalNode.gxx
LibCtl_Library.cdl
LibCtl_Library.gxx
LibCtl_Node.gxx
LibCtl_ProtocolTemplate.cdl

76
src/LibCtl/LibCtl.cdl Executable file
View File

@@ -0,0 +1,76 @@
-- File: LibCtl.cdl
-- Created: Fri Jan 29 10:59:42 1993
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1993
package LibCtl
---Purpose : This package gives tools to describe and control Libraries
-- defined as sets of Execution Modules, which can be sorted
-- to work on a specific Working Protocol.
--
-- This is intended to attach functions on Objects, when these
-- functions can be defined by prototypes, but not as methods
-- directly bound to the concerned classes of objects (classes
-- with a minimum list of methods, or optionnal functionnalities
-- for a non-predefined list of classes).
--
--
-- In this scheme, to a category (basic class) of Protocol,
-- corresponds a general kind of object classes, e.g. Entities
-- processed by Interfaces, Transient Objects, or any other
-- (a general definition makes easier further extensions).
--
-- Each particular Protocol class is a sub-class of the basic
-- Protocol class (e.g. Application Protocol of STEP).
-- Its own definition comprises :
-- - As necessary, a list of other Protocol classes, of which it
-- depends (this list can be empty) : the Resources
-- - The list of Object Classes it identifies DIRECTLY, i.e. not
-- through its Resources.
-- For each directly identified Object Class, the Protocol
-- gives a positive Case Number.
-- This is why a Protocol class must comply with ProtocolTemplate
-- from this Package (even if not defined from it)
--
--
-- On the other hand, for a given category of Protocols, to each
-- functionnality (or set of ...) is attached a Library. It is
-- defined with a basic Class of Module, forecast to perform the
-- functionnality. It can use the Case Number computed by the
-- Protocol, to work faster (optimization).
--
-- Hence, one specific Module Class is attached to each specific
-- Protocol Class. It works on the group of Object Classes
-- identified by the Protocol (e.g. a specific part of STEP).
--
-- This basic set of couples (Module,Protocol Class) is filled
-- before action : this can be done by static declaration.
--
-- A Library can then be created to comply with a general Protocol
-- Class by getting the Modules from its basic set, those which
-- correspond to this Protocol and its Resources.
--
--
-- A Library is defined by instantiating Library with : the basic
-- class of Objects to be processed, the basic Protocol Class
-- (which must work on the basic class of Objects), the basic
-- Module Class, which brings the desired functions (deferred).
--
-- Once defined, a Library can be used by any Tool to work on the
-- objects concerned by the Protocol. A Tool can be defined to
-- Manage an "active Protocol", that is a Protocol which is taken
-- by default to build the library (in this case, it must control
-- the consistency of data between active Protocol and the
-- objects it runs on).
uses MMgt, Standard
is
generic class Library,GlobalNode,Node;
deferred generic class ProtocolTemplate; -- take it as a Template
end LibCtl;

View File

@@ -0,0 +1,34 @@
//#include <LibCtl_GlobalNode.ixx>
// Classe generique imbriquee dans Library : utilisee pour construire les
// listes globales de Modules attaches a une classe instanciee de Library
// (cf Library pour plus de details)
LibCtl_GlobalNode::LibCtl_GlobalNode () { }
// ATTENTION, Add agit en substitution : pour un Protocol donne, c est le
// dernier appel qui l emporte
void LibCtl_GlobalNode::Add
(const Handle(TheModule)& amodule, const Handle(TheProtocol)& aprotocol)
{
if (themod == amodule) return;
if (theprot == aprotocol) themod = amodule;
else if (thenext.IsNull()) {
if (themod.IsNull()) { themod = amodule; theprot = aprotocol; }
else {
thenext = new LibCtl_GlobalNode;
thenext->Add (amodule,aprotocol);
}
}
else thenext->Add (amodule,aprotocol);
}
const Handle(TheModule)& LibCtl_GlobalNode::Module () const
{ return themod; }
const Handle(TheProtocol)& LibCtl_GlobalNode::Protocol () const
{ return theprot; }
const Handle(LibCtl_GlobalNode)& LibCtl_GlobalNode::Next () const
{ return thenext; }

179
src/LibCtl/LibCtl_Library.cdl Executable file
View File

@@ -0,0 +1,179 @@
-- File: LibCtl_Library.cdl
-- Created: Fri Jan 29 15:48:51 1993
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1993
generic class Library from LibCtl
(TheObject as any;
TheModule as Transient;
TheProtocol as Transient) -- must comply with Protocol template
---Purpose : Manages a list of Execution Modules attached to Protocols
-- to perform a specific set of functionnalities.
--
-- Each instantiated class of Library has a global set a Modules.
-- These Modules are put in this set before working, for instance
-- by static construction (using method SetGlobal). One Module
-- is bound which each Protocol (considered as a class).
--
-- To work, a Library is created by taking the Modules which
-- comply with a Protocol (bound with its class and the classes
-- of its Resources), given as parameter of its creation.
--
-- Thus, any tool can use it to get the suitable Modules
---Warning : The order of the Modules in the Library has assumed to be
-- useless, and is not managed.
raises NoSuchObject
-- -- Nested class : Node of Module -- --
private class GlobalNode inherits Transient
---Purpose : Manages a (possibly static) Global List of Modules bound to
-- Protocols.
-- Remark that it requires independance from Memory Management
-- (because a Global List of Modules can be build through static
-- declarations, i.e. before any sequential execution)
-- Remark there will not be many many GlobalNodes created
is
Create returns mutable GlobalNode;
---Purpose : Creates an empty GlobalNode, with no Next
Add (me : mutable; amodule : TheModule; aprotocol : TheProtocol)
is static;
---Purpose : Adds a Module bound with a Protocol to the list : does
-- nothing if already in the list, THAT IS, Same Type (exact
-- match) and Same State (that is, IsEqual is not required)
-- Once added, stores its attached Protocol in correspondance
Module (me) returns any TheModule is static;
---Purpose : Returns the Module stored in a given GlobalNode
---C++ : return const &
Protocol (me) returns any TheProtocol is static;
---Purpose : Returns the attached Protocol stored in a given GlobalNode
---C++ : return const &
Next (me) returns any GlobalNode is static;
---Purpose : Returns the Next GlobalNode. If none is defined, returned
-- value is a Null Handle
---C++ : return const &
fields
themod : TheModule;
theprot : TheProtocol;
thenext : GlobalNode;
end GlobalNode;
private class Node inherits TShared
---Purpose : Manages a list of Modules for a Library (as an instance) :
-- Designates a GlobalNode (couple Module-Protocol)
is
Create returns mutable Node;
---Purpose : Creates an empty Node, with no Next
AddNode (me : mutable; anode : any GlobalNode) is static;
---Purpose : Adds a couple (Module,Protocol), that is, stores it into
-- itself if not yet done, else creates a Next Node to do it
Module (me) returns any TheModule is static;
---Purpose : Returns the Module designated by a precise Node
---C++ : return const &
Protocol (me) returns any TheProtocol is static;
---Purpose : Returns the Protocol designated by a precise Node
---C++ : return const &
Next (me) returns mutable Node is static;
---Purpose : Returns the Next Node. If none was defined, returned value
-- is a Null Handle
---C++ : return const &
fields
thenode : GlobalNode;
thenext : Node;
end Node;
is
SetGlobal (myclass; amodule : TheModule; aprotocol : TheProtocol);
---Purpose : Adds a couple (Module-Protocol) into the global definition set
-- for this class of Library.
Create (aprotocol : TheProtocol) returns Library;
---Purpose : Creates a Library which complies with a Protocol, that is :
-- Same class (criterium IsInstance)
-- This creation gets the Modules from the global set, those
-- which are bound to the given Protocol and its Resources
Create returns Library;
---Purpose : Creates an empty Library : it will later by filled by method
-- AddProtocol
AddProtocol (me : in out; aprotocol : Transient) is static;
---Purpose : Adds a couple (Module-Protocol) to the Library, given the
-- class of a Protocol. Takes Resources into account.
-- (if <aprotocol> is not of type TheProtocol, it is not added)
Clear (me : in out) is static;
---Purpose : Clears the list of Modules of a library (can be used to
-- redefine the order of Modules before action : Clear then
-- refill the Library by calls to AddProtocol)
SetComplete (me : in out);
---Purpose : Sets a library to be defined with the complete Global list
-- (all the couples Protocol/Modules recorded in it)
Select (me; obj : any TheObject; module : out any TheModule; CN : out Integer)
returns Boolean;
---Purpose : Selects a Module from the Library, given an Object.
-- Returns True if Select has succeeded, False else.
-- Also Returns (as arguments) the selected Module and the Case
-- Number determined by the associated Protocol.
-- If Select has failed, <module> is Null Handle and CN is zero.
-- (Select can work on any criterium, such as Object DynamicType)
Start (me : in out) is static;
---Purpose : Starts Iteration on the Modules (sets it on the first one)
More (me) returns Boolean is static;
---Purpose : Returns True if there are more Modules to iterate on
Next (me : in out) is static;
---Purpose : Iterates by getting the next Module in the list
-- If there is none, the exception will be raised by Value
Module (me) returns any TheModule
---Purpose : Returns the current Module in the Iteration
raises NoSuchObject is static;
-- Error if there is no current Module to iterate on
---C++ : return const &
Protocol (me) returns any TheProtocol
---Purpose : Returns the current Protocol in the Iteration
raises NoSuchObject is static;
-- Error if there is no current Protocol to iterate on
---C++ : return const &
fields
thelist : Node;
thecurr : Node; -- for iteration
-- there are also "class variables" which describe global set
end Library;

143
src/LibCtl/LibCtl_Library.gxx Executable file
View File

@@ -0,0 +1,143 @@
//#include <LibCtl_Library.ixx>
#include <Standard_NoSuchObject.hxx>
// Liste Globale des Modules, dans laquelle on va se servir
static Handle(LibCtl_GlobalNode) theglobal;
// Donnees pour optimisation (dernier Protocole demande)
static Handle(TheProtocol) theprotocol;
static Handle(LibCtl_Node) thelast;
// Alimentation de la liste globale
// ATTENTION : SetGlobal fait de la substitution, c-a-d que c est le dernier
// qui a raison pour un Protocol donne
void LibCtl_Library::SetGlobal
(const Handle(TheModule)& amodule, const Handle(TheProtocol)& aprotocol)
{
if (theglobal.IsNull()) theglobal = new LibCtl_GlobalNode;
theglobal->Add(amodule,aprotocol);
}
// Constructeur d apres Protocole
LibCtl_Library::LibCtl_Library (const Handle(TheProtocol)& aprotocol)
{
Standard_Boolean last = Standard_False;
if (aprotocol.IsNull()) return; // PAS de protocole = Lib VIDE
if (!theprotocol.IsNull()) last =
(theprotocol == aprotocol);
if (last) thelist = thelast;
// Si Pas d optimisation disponible : construire la liste
else {
AddProtocol(aprotocol);
// Ceci definit l optimisation (pour la fois suivante)
thelast = thelist;
theprotocol = aprotocol;
}
}
// Constructeur vide
LibCtl_Library::LibCtl_Library () { }
// Ajout d un Protocol : attention, desoptimise (sinon risque de confusion !)
void LibCtl_Library::AddProtocol
(const Handle(Standard_Transient)& aprotocol)
{
// DownCast car Protocol->Resources, meme redefini et utilise dans d autres
// librairies, doit toujours renvoyer le type le plus haut
Handle(TheProtocol) aproto = Handle(TheProtocol)::DownCast(aprotocol);
if (aproto.IsNull()) return;
// D abord, ajouter celui-ci a la liste : chercher le Node
Handle(LibCtl_GlobalNode) curr;
for (curr = theglobal; !curr.IsNull(); ) { // curr->Next : plus loin
const Handle(TheProtocol)& protocol = curr->Protocol();
if (!protocol.IsNull()) {
// Match Protocol ?
if (protocol->DynamicType() == aprotocol->DynamicType()) {
if (thelist.IsNull()) thelist = new LibCtl_Node;
thelist->AddNode(curr);
break; // UN SEUL MODULE PAR PROTOCOLE
}
}
curr = curr->Next(); // cette formule est refusee dans "for"
}
// Ensuite, Traiter les ressources
Standard_Integer nb = aproto->NbResources();
for (Standard_Integer i = 1; i <= nb; i ++) {
AddProtocol (aproto->Resource(i));
}
// Ne pas oublier de desoptimiser
theprotocol.Nullify();
thelast.Nullify();
}
void LibCtl_Library::Clear ()
{ thelist = new LibCtl_Node; }
void LibCtl_Library::SetComplete ()
{
thelist = new LibCtl_Node;
// On prend chacun des Protocoles de la Liste Globale et on l ajoute
Handle(LibCtl_GlobalNode) curr;
for (curr = theglobal; !curr.IsNull(); ) { // curr->Next : plus loin
const Handle(TheProtocol)& protocol = curr->Protocol();
// Comme on prend tout tout tout, on ne se preoccupe pas des Ressources !
if (!protocol.IsNull()) thelist->AddNode(curr);
curr = curr->Next(); // cette formule est refusee dans "for"
}
}
// Selection : Tres fort, on retourne le Module correspondant a un Type
// (ainsi que le CaseNumber retourne par le protocole correspondant)
Standard_Boolean LibCtl_Library::Select
(const TheObject& obj,
Handle(TheModule)& module, Standard_Integer& CN) const
{
module.Nullify(); CN = 0; // Reponse "pas trouve"
if (thelist.IsNull()) return Standard_False;
Handle(LibCtl_Node) curr = thelist;
for (curr = thelist; !curr.IsNull(); ) { // curr->Next : plus loin
const Handle(TheProtocol)& protocol = curr->Protocol();
if (!protocol.IsNull()) {
CN = protocol->CaseNumber(obj);
if (CN > 0) {
module = curr->Module();
return Standard_True;
}
}
curr = curr->Next(); // cette formule est refusee dans "for"
}
return Standard_False; // ici, pas trouce
}
// .... Iteration ....
void LibCtl_Library::Start ()
{ thecurr = thelist; }
Standard_Boolean LibCtl_Library::More () const
{ return (!thecurr.IsNull()); }
void LibCtl_Library::Next ()
{ if (!thecurr.IsNull()) thecurr = thecurr->Next(); }
const Handle(TheModule)& LibCtl_Library::Module () const
{
if (thecurr.IsNull()) Standard_NoSuchObject::Raise("Library from LibCtl");
return thecurr->Module();
}
const Handle(TheProtocol)& LibCtl_Library::Protocol () const
{
if (thecurr.IsNull()) Standard_NoSuchObject::Raise("Library from LibCtl");
return thecurr->Protocol();
}

31
src/LibCtl/LibCtl_Node.gxx Executable file
View File

@@ -0,0 +1,31 @@
//#include <LibCtl_Node.ixx>
// Classe generique imbriquee dans Library : utilisee pour construire la
// listes de Modules d une librairie (cf Library pour plus de details)
// (En fait : Liste de Global Nodes -> Module + Protocol)
LibCtl_Node::LibCtl_Node () { }
void LibCtl_Node::AddNode (const Handle(LibCtl_GlobalNode)& anode)
{
if (thenode == anode) return;
if (thenext.IsNull()) {
if (thenode.IsNull()) thenode = anode;
else {
thenext = new LibCtl_Node;
thenext->AddNode (anode);
}
}
else thenext->AddNode (anode);
}
const Handle(TheModule)& LibCtl_Node::Module () const
{ return thenode->Module(); }
const Handle(TheProtocol)& LibCtl_Node::Protocol () const
{ return thenode->Protocol(); }
const Handle(LibCtl_Node)& LibCtl_Node::Next () const
{ return thenext; }

View File

@@ -0,0 +1,50 @@
-- File: LibCtl_ProtocolTemplate.cdl
-- Created: Wed Mar 17 17:23:19 1993
-- Author: Christian CAILLET
-- <cky@phylox>
---Copyright: Matra Datavision 1993
deferred generic class ProtocolTemplate from LibCtl
(TheObject as any)
inherits Transient
---Purpose : This class is a Template class for Library : there is no
-- obligation to inherit it for instantiate a Library class.
--
-- A Protocol class defines a data scheme by gathering a set of
-- Object Classes. This set is made of :
-- - As necessary, other sets already defined by other Protocols.
-- These Protocols are the Resources of <myclass>
-- This definition can be recurrent : each Protocol class
-- defines its Resources at immediate level
-- - The list of Object Classes it identifies DIRECTLY (itself),
-- i.e. not through its Resources.
--
-- A classic Selection criterium is DynamicType (for a Transient
-- or Persistent Object), this gives a Case Number per Class. If
-- another criterium is taken, it must assume unique and non-
-- ambiguous binding between an object state and a Cse Number.
--
-- For each Object Class (or recognized state) it identifies
-- directly, it provides a unique positive Number, which can be
-- used as Case Number.
--
-- A Module bound with a Protocol class is assumed to accept any
-- Object of a Class it defines DIRECTLY (not its Resources).
uses Type
is
NbResources (me) returns Integer is deferred;
---Purpose : Gives the count of Protocols used as Resource (can be zero)
Resource (me; num : Integer) returns ProtocolTemplate is deferred;
---Purpose : Returns a Resource, given a rank.
CaseNumber (me; obj : any TheObject) returns Integer is deferred;
---Purpose : Returns a Case Number, specific of each recognized Object
-- This is a positive number. Zero means "<obj> not recognized"
end ProtocolTemplate;

View File