1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +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

44
src/XSControl/XSControl.cdl Executable file
View File

@@ -0,0 +1,44 @@
-- File: XSControl.cdl
-- Created: Mon Mar 13 15:36:04 1995
-- Author: Christian CAILLET
-- <cky@anion>
---Copyright: Matra Datavision 1995
package XSControl
---Purpose : This package provides complements to IFSelect & Co for
-- control of a session
uses Standard , MMgt, TCollection , TColStd, Dico,
Interface, Transfer, IFSelect, Message,
TopoDS, TopTools, TopAbs , Geom, Geom2d, gp
is
deferred class Controller;
class TransferReader;
class TransferWriter;
class WorkSession;
class SelectForTransfer;
class SignTransferStatus;
class ConnectedShapes;
class Reader;
class Writer;
class Functions;
class FuncShape;
class Utils;
class Vars;
Session (pilot : SessionPilot from IFSelect) returns WorkSession from XSControl;
---Purpose : Returns the WorkSession of a SessionPilot, but casts it as
-- from XSControl : it then gives access to Control & Transfers
Vars (pilot : SessionPilot from IFSelect) returns Vars from XSControl;
---Purpose : Returns the Vars of a SessionPilot, it is brought by Session
-- it provides access to external variables
end XSControl;

15
src/XSControl/XSControl.cxx Executable file
View File

@@ -0,0 +1,15 @@
#include <XSControl.ixx>
Handle(XSControl_WorkSession) XSControl::Session
(const Handle(IFSelect_SessionPilot)& pilot)
{ return Handle(XSControl_WorkSession)::DownCast(pilot->Session()); }
Handle(XSControl_Vars) XSControl::Vars
(const Handle(IFSelect_SessionPilot)& pilot)
{
Handle(XSControl_Vars) avars;
Handle(XSControl_WorkSession) WS = XSControl::Session(pilot);
if (!WS.IsNull()) avars = WS->Vars();
return avars;
}

View File

@@ -0,0 +1,57 @@
-- File: XSControl_ConnectedShapes.cdl
-- Created: Wed Feb 24 17:53:29 1999
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class ConnectedShapes from XSControl inherits SelectExplore from IFSelect
---Purpose : From a TopoDS_Shape, or from the entity which has produced it,
-- searches for the shapes, and the entities which have produced
-- them in last transfer, which are adjacent to it by VERTICES
uses AsciiString, Transient, Graph, EntityIterator,
HSequenceOfTransient from TColStd,
Shape from TopoDS, ShapeEnum from TopAbs,
TransientProcess from Transfer, TransferReader from XSControl
is
Create returns ConnectedShapes;
---Purpose : Creates a Selection ConnectedShapes. It remains to be set a
-- TransferReader
Create (TR : TransferReader) returns ConnectedShapes;
---Purpose : Creates a Selection ConnectedShapes, which will work with the
-- current TransferProcess brought by the TransferReader
SetReader (me : mutable; TR : TransferReader);
---Purpose : Sets a TransferReader to sort entities : it brings the
-- TransferProcess which may change, while the TransferReader does not
Explore (me; level : Integer; ent : Transient; G : Graph;
explored : in out EntityIterator)
returns Boolean;
---Purpose : Explores an entity : entities from which are connected to that
-- produced by this entity, including itself
ExploreLabel (me) returns AsciiString from TCollection;
---Purpose : Returns a text defining the criterium.
-- "Connected Entities through produced Shapes"
AdjacentEntities (myclass;
ashape : Shape from TopoDS;
TP : TransientProcess from Transfer;
type : ShapeEnum from TopAbs)
returns HSequenceOfTransient;
---Purpose : This functions considers a shape from a transfer and performs
-- the search function explained above
fields
theTR : TransferReader;
end ConnectedShapes;

View File

@@ -0,0 +1,67 @@
#include <XSControl_ConnectedShapes.ixx>
#include <TopExp_Explorer.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TransferBRep.hxx>
XSControl_ConnectedShapes::XSControl_ConnectedShapes ()
: IFSelect_SelectExplore (1) { }
XSControl_ConnectedShapes::XSControl_ConnectedShapes
(const Handle(XSControl_TransferReader)& TR)
: IFSelect_SelectExplore (1) , theTR (TR) { }
void XSControl_ConnectedShapes::SetReader
(const Handle(XSControl_TransferReader)& TR)
{ theTR = TR; }
Standard_Boolean XSControl_ConnectedShapes::Explore
(const Standard_Integer /*level*/, const Handle(Standard_Transient)& ent,
const Interface_Graph& /*G*/, Interface_EntityIterator& explored) const
{
Handle(Transfer_TransientProcess) TP;
if (!theTR.IsNull()) TP = theTR->TransientProcess();
if (TP.IsNull()) return Standard_False;
TopoDS_Shape Shape = TransferBRep::ShapeResult (TP,ent);
if (Shape.IsNull()) return Standard_False;
Handle(TColStd_HSequenceOfTransient) li = AdjacentEntities (Shape,TP,TopAbs_FACE);
explored.AddList (li);
return Standard_True;
}
TCollection_AsciiString XSControl_ConnectedShapes::ExploreLabel () const
{
TCollection_AsciiString lab("Connected Entities through produced Shapes");
return lab;
}
Handle(TColStd_HSequenceOfTransient) XSControl_ConnectedShapes::AdjacentEntities
(const TopoDS_Shape& ashape,
const Handle(Transfer_TransientProcess)& TP,
const TopAbs_ShapeEnum type)
{
Handle(TColStd_HSequenceOfTransient) li = new TColStd_HSequenceOfTransient();
Standard_Integer i, nb = TP->NbMapped();
// TopTools_MapOfShape adj (nb);
TopTools_MapOfShape vtx(20);
for (TopExp_Explorer vert(ashape,TopAbs_VERTEX); vert.More(); vert.Next()) {
vtx.Add (vert.Current());
}
for (i = 1; i <= nb; i ++) {
Handle(Transfer_Binder) bnd = TP->MapItem(i);
TopoDS_Shape sh = TransferBRep::ShapeResult (bnd);
if (sh.IsNull()) continue;
if (sh.ShapeType() != type) continue;
for (TopExp_Explorer vsh(sh,TopAbs_VERTEX); vsh.More(); vsh.Next()) {
TopoDS_Shape avtx = vsh.Current();
if (vtx.Contains(avtx)) {
li->Append (TP->Mapped(i));
break; // break de ce for interieur, entite suivante
}
}
}
return li;
}

View File

@@ -0,0 +1,327 @@
-- File: XSControl_Controller.cdl
-- Created: Mon Mar 13 15:37:52 1995
-- Author: Christian CAILLET
-- <cky@anion>
---Copyright: Matra Datavision 1995
deferred class Controller from XSControl inherits TShared
---Purpose : This class allows a general X-STEP engine to run generic
-- functions on any interface norm, in the same way. It includes
-- the transfer operations. I.e. it gathers the already available
-- general modules, the engine has just to know it
--
-- The important point is that a given X-STEP Controller is
-- attached to a given couple made of an Interface Norm (such as
-- IGES-5.1) and an application data model (CasCade Shapes for
-- instance).
--
-- A Controller brings a Profile, this allows to have several
-- variants on the same basic definition, for instance keep the
-- norm definition but give several transfer actors, etc
--
-- Finally, Controller can be gathered in a general dictionary then
-- retreived later by a general call (method Recorded)
--
-- It does not manage the produced data, but the Actors make the
-- link between the norm and the application
uses CString, AsciiString, SequenceOfTransient, SequenceOfInteger,
DictionaryOfTransient, DictionaryOfInteger,
HArray1OfHAsciiString from Interface,
HSequenceOfHAsciiString from TColStd,
Protocol from Interface,
Signature from IFSelect,
InterfaceModel from Interface,
CheckIterator from Interface,
ActorOfTransientProcess from Transfer,
ActorOfFinderProcess from Transfer,
FinderProcess from Transfer,
Shape from TopoDS,
WorkLibrary from IFSelect,
Profile from IFSelect,
WorkSession from XSControl,
ReturnStatus from IFSelect
raises DomainError
is
Initialize (longname, shortname : CString);
---Purpose : Initializing with names
-- <longname> is for the complete, official, long name
-- <shortname> is for the short name used for resources
SetNames (me : mutable; longname, shortname : CString);
---Purpose : Changes names
-- if a name is empty, the formerly set one remains
-- Remark : Does not call Record or AutoRecord
AutoRecord (me) raises DomainError;
---Purpose : Records <me> is a general dictionary under Short and Long
-- Names (see method Name)
Record (me; name : CString) raises DomainError;
---Purpose : Records <me> in a general dictionary under a name
-- Error if <name> already used for another one
Recorded (myclass; name : CString) returns mutable Controller;
---Purpose : Returns the Controller attached to a given name
-- Returns a Null Handle if <name> is unknown
ListRecorded (myclass; mode : Integer = 0) returns HSequenceOfHAsciiString;
---Purpose : Returns the list of names of recorded norms, according to mode
-- = 0 (D) : all the recorded names
-- < 0 : for each distinct norm, its resource (short) name
-- > 0 : for each distinct norm, its complete (long) name
Name (me; rsc : Boolean = Standard_False) returns CString;
---Purpose : Returns a name, as given when initializing :
-- rsc = False (D) : True Name attached to the Norm (long name)
-- rsc = True : Name of the ressource set (i.e. short name)
Profile (me) returns Profile from IFSelect;
---Purpose : Returns the Profile
-- It starts with a first configuration Base (empty) and the
-- following options :
-- protocol for the Protocol
-- sign-type for the SignType (Default Signature for Type)
-- access for the WorkLibrary
-- tr-read for ActorRead (import processor)
-- tr-write for ActorWrite (export processor)
DefineProfile (me : mutable; confname : CString);
---Purpose : Considers the current state of the Controller as defining a
-- configuration, newly created or already existing
SetProfile (me : mutable; confname : CString) returns Boolean;
---Purpose : Sets the Controller in a given Configuration of its Profile
-- Calls SettingProfile (which can be redefined)
--
-- Returns True if done, False if <confname> unknown
SettingProfile (me : mutable; confname : CString)
returns Boolean is virtual;
---Purpose : This method is called by SetProfile, it can be redefined
-- for specific sub-class of Controller
-- The default does nothing
ApplyProfile (me : mutable; WS : WorkSession from XSControl; confname : CString)
returns Boolean;
---Purpose : Applies a Configuration of the Profile to the WorkSession
-- I.E. calls SetProfile then fills WorkSession with definitions
ApplyingProfile (me : mutable; WS : WorkSession from XSControl; confname : CString)
returns Boolean is virtual;
---Purpose : Called by ApplyProfile, can be redefined for specific
-- sub-class of Controller
-- The default does nothing
Protocol (me) returns Protocol from Interface;
---Purpose : Returns the Protocol attached to the Norm (from field)
SignType (me) returns Signature from IFSelect;
---Purpose : Returns the SignType attached to the norm (from field)
WorkLibrary (me) returns WorkLibrary from IFSelect;
---Purpose : Returns the WorkLibrary attached to the Norm. Remark that it
-- has to be in phase with the Protocol (read from field)
NewModel (me) returns mutable InterfaceModel from Interface is deferred;
---Purpose : Creates a new empty Model ready to receive data of the Norm
-- Used to write data from Imagine to an interface file
ActorRead (me; model : InterfaceModel)
returns mutable ActorOfTransientProcess from Transfer is deferred;
---Purpose : Returns the Actor for Read attached to the pair (norm,appli)
-- It can be adapted for data of the input Model, as required
-- Can be read from field then adapted with Model as required
ActorWrite (me) returns mutable ActorOfFinderProcess from Transfer
is virtual;
---Purpose : Returns the Actor for Write attached to the pair (norm,appli)
-- Read from field. Can be redefined
UpdateStatics (me; mode : Integer; criter : CString = "") is virtual;
---Purpose : Updates static values
-- <mode> precises the kind of updating : (see Items from Static)
-- -1 : a precise static item : criter = its name
-- 0 : all items of a family : criter = the family name
-- 1 : all items which match regexp name : criter = regexp name
-- By default (criter empty) should consider all relevant statics
-- If <name> is defined, can consider only this static item
-- The provided default method does nothing, to be redefined
-- Writing Actions (can be redefined from ActorWrite using)
-- These actions are ran under control of a TransferWriter
SetModeWrite (me : mutable; modemin, modemax : Integer; shape : Boolean = Standard_True);
---Purpose : Sets mininum and maximum values for modetrans (write)
-- Erases formerly recorded bounds and values
-- Actually only for shape
-- Then, for each value a little help can be attached
SetModeWriteHelp (me : mutable; modetrans : Integer; help : CString;
shape : Boolean = Standard_True);
---Purpose : Attaches a short line of help to a value of modetrans (write)
ModeWriteBounds (me; modemin, modemax : out Integer;
shape : Boolean = Standard_True) returns Boolean;
---Purpose : Returns recorded min and max values for modetrans (write)
-- Actually only for shapes
-- Returns True if bounds are set, False else (then, free value)
IsModeWrite (me; modetrans : Integer; shape : Boolean = Standard_True)
returns Boolean;
---Purpose : Tells if a value of <modetrans> is a good value(within bounds)
-- Actually only for shapes
ModeWriteHelp (me; modetrans : Integer; shape : Boolean = Standard_True)
returns CString;
---Purpose : Returns the help line recorded for a value of modetrans
-- empty if help not defined or not within bounds or if values are free
RecognizeWriteTransient (me; obj : Transient; modetrans : Integer = 0)
returns Boolean is virtual;
---Purpose : Tells if <obj> (an application object) is a valid candidate
-- for a transfer to a Model.
-- By default, asks the ActorWrite if known (through a
-- TransientMapper). Can be redefined
TransferWriteTransient (me; obj : Transient;
FP : mutable FinderProcess from Transfer;
model : mutable InterfaceModel from Interface;
modetrans : Integer = 0)
returns ReturnStatus is virtual;
---Purpose : Takes one Transient Object and transfers it to an
-- InterfaceModel (already created, e.g. by NewModel)
-- (result is recorded in the model by AddWithRefs)
-- FP records produced results and checks
--
-- Default uses ActorWrite; can be redefined as necessary
-- Returned value is a status, as follows :
-- 0 OK , 1 No Result , 2 Fail (e.g. exception raised)
-- -1 bad conditions , -2 bad model or null model
-- For type of object not recognized : should return 1
RecognizeWriteShape (me; shape : Shape from TopoDS; modetrans: Integer = 0)
returns Boolean is virtual;
---Purpose : Tells if a shape is valid for a transfer to a model
-- Asks the ActorWrite (through a ShapeMapper)
TransferWriteShape (me; shape : Shape from TopoDS;
FP : mutable FinderProcess from Transfer;
model : mutable InterfaceModel from Interface;
modetrans : Integer = 0)
returns ReturnStatus is virtual;
---Purpose : Takes one Shape and transfers it to an
-- InterfaceModel (already created, e.g. by NewModel)
-- Default uses ActorWrite; can be redefined as necessary
-- Returned value is a status, as follows :
-- Done OK , Void : No Result , Fail : Fail (e.g. exception)
-- Error : bad conditions , bad model or null model
-- Resolution of file clusters
-- According to each norm, there can (or not) be files of which
-- definition is not complete but refers to other files : this defines
-- a file cluster.
-- It can then be resolved by two calls :
-- - ClusterContext prepares the resolution, specific of each case
-- - ResolveCluster performs the resolution, its result consists in
-- having all data gathered in one final model
ClusterContext (me; WS : WorkSession) returns mutable Transient is virtual;
---Purpose : Prepares and returns a context to resolve a cluster
-- All data to be used are detained by the WorkSession
-- The definition of this context is free and proper to each case
-- remark that it is aimed to be used in ResolveCluster
--
-- The context must be prepared, but resolution must not have
-- began
--
-- If no cluster has to be resolved, should return a null handle
-- This is the default case, which can be redefined
ResolveCluster (me; WS : mutable WorkSession; context : mutable Transient)
returns CheckIterator is virtual;
---Purpose : Performs the resolution itself, from the starting data and
-- the cluster context
--
-- Can fill a CheckList as necessary (especially when one or
-- more references remain unresolved)
--
-- Default does nothing and returns an empty CheckList
-- Additional Items as required (free list), each item is named
AddControlItem (me : mutable; item : any Transient; name : CString);
---Purpose : Adds an item in the control list
-- A control item of a controller is accessed by its name which
-- is specific of a kind of item (i.e. a kind of functionnality)
-- Adds or replaces if <name> is already recorded
ControlItem (me; name : CString) returns any Transient;
---Purpose : Returns a control item from its name, Null if <name> unknown
-- To be used then, it just remains to be down-casted
-- To Help Session Customising --
TraceStatic (me : mutable; name : CString; use : Integer);
---Purpose : Records the name of a Static to be traced for a given use
AddSessionItem (me : mutable; item : Transient; name : CString;
setapplied : CString = "");
---Purpose : Records a Session Item, to be added for customisation of the
-- Work Session. It must have a specific name.
-- <setapplied> is used if <item> is a GeneralModifier, to decide
-- to which hook list it will be applied, if not empty (else,
-- not applied to any hook list)
-- ACTUAL : only one hook list is managed : "send"
-- Remark : this method is to be called at Create time, the
-- recorded items will be used by Customise
-- Warning : if <name> conflicts, the last recorded item is kept
SessionItem (me; name : CString) returns Transient;
---Purpose : Returns an item given its name to record in a Session
-- If <name> is unknown, returns a Null Handle
IsApplied (me; item : Transient) returns Boolean;
---Purpose : Returns True if <item> is recorded as <setapplied = True>
Customise (me: mutable; WS : in out WorkSession) is virtual;
---Purpose : Customises a WorkSession, by adding to it the recorded items
-- (by AddSessionItem), then by calling a specific method
-- Customising, set by default to do nothing
Customising (me : mutable; WS : in out WorkSession); -- is virtual
---Purpose : Specific customisation method, which can be redefined
-- Default does nothing
AdaptorSession(me) returns DictionaryOfTransient;
fields
theProfile : Profile;
theShortName : AsciiString is protected;
theLongName : AsciiString is protected;
theAdaptorLibrary : WorkLibrary is protected;
theAdaptorProtocol : Protocol is protected;
theSignType : Signature is protected;
theAdaptorRead : ActorOfTransientProcess is protected;
theAdaptorWrite : ActorOfFinderProcess is protected;
theItems : DictionaryOfTransient;
theAdaptorSession : DictionaryOfTransient is protected;
theAdaptorApplied : SequenceOfTransient;
theAdaptorHooks : HSequenceOfHAsciiString from TColStd;
theParams : SequenceOfTransient from TColStd;
theParamUses : SequenceOfInteger from TColStd;
theModeWriteShapeN : HArray1OfHAsciiString from Interface;
end Controller;

View File

@@ -0,0 +1,650 @@
#include <XSControl_Controller.ixx>
#include <IFSelect_GeneralModifier.hxx>
#include <Dico_IteratorOfDictionaryOfTransient.hxx>
#include <Dico_IteratorOfDictionaryOfInteger.hxx>
#include <TColStd_IndexedMapOfTransient.hxx>
#include <IFSelect_Option.hxx>
#include <IFSelect_SelectModelEntities.hxx>
#include <IFSelect_SelectModelRoots.hxx>
#include <IFSelect_SelectPointed.hxx>
#include <IFSelect_SelectSharing.hxx>
#include <IFSelect_SelectShared.hxx>
#include <IFSelect_GraphCounter.hxx>
#include <XSControl_SelectForTransfer.hxx>
#include <XSControl_ConnectedShapes.hxx>
#include <XSControl_SignTransferStatus.hxx>
#include <XSControl_TransferReader.hxx>
#include <XSControl_WorkSession.hxx>
#include <IFSelect_SignType.hxx>
#include <IFSelect_SignCounter.hxx>
#include <IFSelect_SignCategory.hxx>
#include <IFSelect_SignValidity.hxx>
#include <IFSelect_SignAncestor.hxx>
#include <IFSelect_DispPerOne.hxx>
#include <IFSelect_DispPerCount.hxx>
#include <IFSelect_DispPerFiles.hxx>
#include <IFSelect_DispPerSignature.hxx>
#include <IFSelect_IntParam.hxx>
// ParamEditor
#include <TColStd_HSequenceOfHAsciiString.hxx>
#include <Interface_Static.hxx>
#include <IFSelect_ParamEditor.hxx>
#include <IFSelect_EditForm.hxx>
#include <IFSelect_SelectModelRoots.hxx>
// Transferts
#include <Transfer_Binder.hxx>
#include <Transfer_SimpleBinderOfTransient.hxx>
#include <Transfer_TransientMapper.hxx>
#include <TransferBRep_ShapeMapper.hxx>
#include <Standard_DomainError.hxx>
#include <TCollection_HAsciiString.hxx>
#include <Interface_Macros.hxx>
#include <Message_Messenger.hxx>
#include <Message.hxx>
static Handle(Dico_DictionaryOfTransient)& listadapt()
{
static Handle(Dico_DictionaryOfTransient) listad;
if (listad.IsNull()) listad = new Dico_DictionaryOfTransient;
return listad;
}
static TColStd_IndexedMapOfTransient& mapadapt()
{
static TColStd_IndexedMapOfTransient mapad;
return mapad;
}
XSControl_Controller::XSControl_Controller
(const Standard_CString longname, const Standard_CString shortname)
: theShortName (shortname) , theLongName (longname)
{
theAdaptorApplied.Clear();
theAdaptorHooks = new TColStd_HSequenceOfHAsciiString();
// Parametres Standard
Interface_Static::Standards();
// TraceStatic ("read.stdsameparameter.mode",5);
TraceStatic ("read.precision.mode" , 5);
TraceStatic ("read.precision.val" , 5);
TraceStatic ("write.precision.mode" , 6);
TraceStatic ("write.precision.val" , 6);
// Initialisation du Profile
theProfile = new IFSelect_Profile;
/* essai option sur parametre
Handle(IFSelect_Option) optrdprec = new IFSelect_Option
(Interface_Static::Static ("read.precision.mode"),"readprecision.mode");
optrdprec->AddBasic("default","File");
optrdprec->AddBasic("Session");
optrdprec->Switch ("default");
theProfile->AddOption (optrdprec);
*/
// Handle(IFSelect_Option) optproto = new IFSelect_Option
// (STANDARD_TYPE(Interface_Protocol),"protocol");
// theProfile->AddOption (optproto);
Handle(IFSelect_Option) optsign = new IFSelect_Option
(STANDARD_TYPE(IFSelect_Signature),"sign-type");
optsign->Add ("default",theSignType);
theProfile->AddOption (optsign);
// Handle(IFSelect_Option) optwlib = new IFSelect_Option
// (STANDARD_TYPE(IFSelect_WorkLibrary),"access");
// theProfile->AddOption (optwlib);
Handle(IFSelect_Option) optactrd = new IFSelect_Option
(STANDARD_TYPE(Transfer_ActorOfTransientProcess),"tr-read");
theProfile->AddOption (optactrd);
Handle(IFSelect_Option) optactwr = new IFSelect_Option
(STANDARD_TYPE(Transfer_ActorOfFinderProcess),"tr-write");
theProfile->AddOption (optactwr);
// Definition de la config de base : suite a la customisation
}
void XSControl_Controller::SetNames
(const Standard_CString longname, const Standard_CString shortname)
{
if (longname && longname[0] != '\0') {
theLongName.Clear(); theLongName.AssignCat (longname);
}
if (shortname && shortname[0] != '\0') {
theShortName.Clear(); theShortName.AssignCat (shortname);
}
}
void XSControl_Controller::AutoRecord () const
{
Record (Name(Standard_True));
Record (Name(Standard_False));
}
void XSControl_Controller::Record (const Standard_CString name) const
{
Standard_Boolean deja;
Handle(Standard_Transient)& newadapt = listadapt()->NewItem (name,deja);
if (deja) {
Handle(Standard_Transient) thisadapt = this;
if (newadapt->IsKind(thisadapt->DynamicType()))
{
}
else if (thisadapt->IsKind(newadapt->DynamicType()))
{
newadapt = this;
if (mapadapt().FindIndex(newadapt) == 0) mapadapt().Add(newadapt);
}
else
if (thisadapt != newadapt) Standard_DomainError::Raise
("XSControl_Controller : Record");
}
else {
newadapt = this;
if (mapadapt().FindIndex(newadapt) == 0) mapadapt().Add(newadapt);
}
}
Handle(XSControl_Controller) XSControl_Controller::Recorded
(const Standard_CString name)
{
Handle(XSControl_Controller) recorded;
if (!listadapt()->GetItem (name,recorded)) recorded.Nullify();
return recorded;
}
Handle(TColStd_HSequenceOfHAsciiString) XSControl_Controller::ListRecorded
(const Standard_Integer mode)
{
Handle(TColStd_HSequenceOfHAsciiString) list = new TColStd_HSequenceOfHAsciiString();
if (mode == 0) {
Dico_IteratorOfDictionaryOfTransient iter (listadapt());
for (; iter.More(); iter.Next()) {
Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString
(iter.Name());
list->Append(name);
}
} else {
Standard_Integer i, nb = mapadapt().Extent();
for (i = 1; i <= nb; i ++) {
DeclareAndCast(XSControl_Controller,ctl,mapadapt().FindKey(i));
if (ctl.IsNull()) continue;
Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString
(ctl->Name( (mode < 0) ));
list->Append(name);
}
}
return list;
}
Standard_CString XSControl_Controller::Name (const Standard_Boolean rsc) const
{ return (rsc ? theShortName.ToCString() : theLongName.ToCString()); }
// #### PROFILE ####
Handle(IFSelect_Profile) XSControl_Controller::Profile () const
{ return theProfile; }
void XSControl_Controller::DefineProfile
(const Standard_CString confname)
{
if (!theProfile->HasConf(confname)) theProfile->AddConf (confname);
theProfile->SetFromCurrent (confname);
}
Standard_Boolean XSControl_Controller::SetProfile
(const Standard_CString confname)
{
if (!theProfile->SetCurrent (confname)) return Standard_False;
// theProfile->Value("protocol",theAdaptorProtocol);
theProfile->Value("sign-type",theSignType);
// theProfile->Value("access",theAdaptorLibrary);
theProfile->Value("tr-read",theAdaptorRead);
theProfile->Value("tr-write",theAdaptorWrite);
return SettingProfile (confname);
}
Standard_Boolean XSControl_Controller::SettingProfile
(const Standard_CString )
{ return Standard_True; }
Standard_Boolean XSControl_Controller::ApplyProfile
(const Handle(XSControl_WorkSession)& WS, const Standard_CString confname)
{
if (!SetProfile (confname)) return Standard_False;
// Typed Values : toutes
theProfile->SetTypedValues();
// SignType
Handle(IFSelect_Signature) signtype;
theProfile->Value ("sign-type",signtype);
WS->SetSignType (signtype);
// ActorRead
Handle(Transfer_ActorOfTransientProcess) actrd;
theProfile->Value ("tr-read",actrd);
WS->TransferReader()->SetActor (actrd);
// ActorWrite : dans le Controller meme
Handle(Transfer_ActorOfFinderProcess) actwr;
theProfile->Value ("tr-write",actwr);
theAdaptorWrite = actwr;
return ApplyingProfile (WS,confname);
}
Standard_Boolean XSControl_Controller::ApplyingProfile
(const Handle(XSControl_WorkSession)& , const Standard_CString )
{ return Standard_True; }
// #### DEFINITION ####
Handle(Interface_Protocol) XSControl_Controller::Protocol () const
{ return theAdaptorProtocol; }
Handle(IFSelect_Signature) XSControl_Controller::SignType () const
{ return theSignType; }
Handle(IFSelect_WorkLibrary) XSControl_Controller::WorkLibrary () const
{ return theAdaptorLibrary; }
Handle(Transfer_ActorOfFinderProcess) XSControl_Controller::ActorWrite () const
{ return theAdaptorWrite; }
void XSControl_Controller::UpdateStatics
(const Standard_Integer, const Standard_CString ) const
{ } // a redefinir si besoin
// ###########################
// Help du Transfer : controle de valeur + help
void XSControl_Controller::SetModeWrite
(const Standard_Integer modemin, const Standard_Integer modemax,
const Standard_Boolean )
{
if (modemin > modemax) { theModeWriteShapeN.Nullify(); return; }
theModeWriteShapeN = new Interface_HArray1OfHAsciiString (modemin,modemax);
}
void XSControl_Controller::SetModeWriteHelp
(const Standard_Integer modetrans, const Standard_CString help,
const Standard_Boolean )
{
if (theModeWriteShapeN.IsNull()) return;
if (modetrans < theModeWriteShapeN->Lower() ||
modetrans > theModeWriteShapeN->Upper()) return;
Handle(TCollection_HAsciiString) hl = new TCollection_HAsciiString (help);
theModeWriteShapeN->SetValue (modetrans,hl);
}
Standard_Boolean XSControl_Controller::ModeWriteBounds
(Standard_Integer& modemin, Standard_Integer& modemax,
const Standard_Boolean ) const
{
modemin = modemax = 0;
if (theModeWriteShapeN.IsNull()) return Standard_False;
modemin = theModeWriteShapeN->Lower();
modemax = theModeWriteShapeN->Upper();
return Standard_True;
}
Standard_Boolean XSControl_Controller::IsModeWrite
(const Standard_Integer modetrans, const Standard_Boolean ) const
{
if (theModeWriteShapeN.IsNull()) return Standard_True;
if (modetrans < theModeWriteShapeN->Lower()) return Standard_False;
if (modetrans > theModeWriteShapeN->Upper()) return Standard_False;
return Standard_True;
}
Standard_CString XSControl_Controller::ModeWriteHelp
(const Standard_Integer modetrans, const Standard_Boolean ) const
{
if (theModeWriteShapeN.IsNull()) return "";
if (modetrans < theModeWriteShapeN->Lower()) return "";
if (modetrans > theModeWriteShapeN->Upper()) return "";
Handle(TCollection_HAsciiString) str = theModeWriteShapeN->Value(modetrans);
if (str.IsNull()) return "";
return str->ToCString();
}
// ###########################
// Transfer : on fait ce qu il faut par defaut (avec ActorWrite)
// peut etre redefini ...
Standard_Boolean XSControl_Controller::RecognizeWriteTransient
(const Handle(Standard_Transient)& obj,
const Standard_Integer modetrans) const
{
if (theAdaptorWrite.IsNull()) return Standard_False;
theAdaptorWrite->ModeTrans() = modetrans;
return theAdaptorWrite->Recognize (new Transfer_TransientMapper(obj));
}
// Fonction interne
static IFSelect_ReturnStatus TransferFinder
(const Handle(Transfer_ActorOfFinderProcess)& actor,
const Handle(Transfer_Finder)& mapper,
const Handle(Transfer_FinderProcess)& FP,
const Handle(Interface_InterfaceModel)& model,
const Standard_Integer modetrans)
{
if (actor.IsNull()) return IFSelect_RetError;
if (model.IsNull()) return IFSelect_RetError;
actor->ModeTrans() = modetrans;
FP->SetModel (model);
FP->SetActor (actor);
FP->Transfer (mapper);
IFSelect_ReturnStatus stat = IFSelect_RetFail;
Handle(Transfer_Binder) binder = FP->Find (mapper);
Handle(Transfer_SimpleBinderOfTransient) bindtr;
while (!binder.IsNull()) {
bindtr = Handle(Transfer_SimpleBinderOfTransient)::DownCast (binder);
if (!bindtr.IsNull()) {
Handle(Standard_Transient) ent = bindtr->Result();
if (!ent.IsNull()) {
stat = IFSelect_RetDone;
model->AddWithRefs (ent);
}
}
binder = binder->NextResult();
}
return stat;
}
IFSelect_ReturnStatus XSControl_Controller::TransferWriteTransient
(const Handle(Standard_Transient)& obj,
const Handle(Transfer_FinderProcess)& FP,
const Handle(Interface_InterfaceModel)& model,
const Standard_Integer modetrans) const
{
if (obj.IsNull()) return IFSelect_RetVoid;
return TransferFinder
(theAdaptorWrite,new Transfer_TransientMapper(obj), FP,model,modetrans);
}
Standard_Boolean XSControl_Controller::RecognizeWriteShape
(const TopoDS_Shape& shape,
const Standard_Integer modetrans) const
{
if (theAdaptorWrite.IsNull()) return Standard_False;
theAdaptorWrite->ModeTrans() = modetrans;
return theAdaptorWrite->Recognize (new TransferBRep_ShapeMapper(shape));
}
IFSelect_ReturnStatus XSControl_Controller::TransferWriteShape
(const TopoDS_Shape& shape,
const Handle(Transfer_FinderProcess)& FP,
const Handle(Interface_InterfaceModel)& model,
const Standard_Integer modetrans) const
{
if (shape.IsNull()) return IFSelect_RetVoid;
IFSelect_ReturnStatus theReturnStat = TransferFinder
(theAdaptorWrite,new TransferBRep_ShapeMapper(shape), FP,model,modetrans);
return theReturnStat;
}
// ###########################
// File Cluster : quand un ensemble de donnees n est pas envoye d un coup mais
// en plusieurs petits paquets ...
// D abord, on detecte la chose et on prepare un contexte de resolution
// specifique du cas a traiter. Null Handle si rien a faire (par defaut)
// Ensuite on resoud
// Les formules par defaut ne font rien (redefinissables)
Handle(Standard_Transient) XSControl_Controller::ClusterContext
(const Handle(XSControl_WorkSession)& ) const
{ Handle(Standard_Transient) nulctx; return nulctx; }
Interface_CheckIterator XSControl_Controller::ResolveCluster
(const Handle(XSControl_WorkSession)& , const Handle(Standard_Transient)& ) const
{ Interface_CheckIterator nulist; return nulist; }
// ###########################
// ControlItems : si ActorWrite etc... ne suffisent meme plus, on peut en
// rajouter, Controller ne fait alors que les accueillir
void XSControl_Controller::AddControlItem
(const Handle(Standard_Transient)& item, const Standard_CString name)
{
if (item.IsNull() || name[0] == '\0') return;
if (theItems.IsNull()) theItems = new Dico_DictionaryOfTransient;
theItems->SetItem (name,item);
}
Handle(Standard_Transient) XSControl_Controller::ControlItem
(const Standard_CString name) const
{
Handle(Standard_Transient) item;
if (theItems.IsNull()) return item;
theItems->GetItem (name,item);
return item;
}
// ###########################
// Cutomisation ! On enregistre des Items pour une WorkSession
// (annule et remplace)
// Ensuite, on les remet en place a la demande
void XSControl_Controller::TraceStatic
(const Standard_CString name, const Standard_Integer use)
{
Handle(Interface_Static) val = Interface_Static::Static(name);
if (val.IsNull()) return;
theParams.Append (val);
theParamUses.Append(use);
}
void XSControl_Controller::AddSessionItem
(const Handle(Standard_Transient)& item, const Standard_CString name,
const Standard_CString setapplied)
{
if (item.IsNull() || name[0] == '\0') return;
if (theAdaptorSession.IsNull()) theAdaptorSession =
new Dico_DictionaryOfTransient;
theAdaptorSession->SetItem (name,item);
if (!setapplied || setapplied[0] == '\0') return;
if (item->IsKind(STANDARD_TYPE(IFSelect_GeneralModifier))) {
// cout<<" -- Xstep Controller : SetApplied n0."<<theAdaptorApplied.Length()+1
// <<" Name:"<<name<<endl;
theAdaptorApplied.Append(item);
Handle(TCollection_HAsciiString) hook = new TCollection_HAsciiString(setapplied);
theAdaptorHooks->Append (hook);
}
}
Handle(Standard_Transient) XSControl_Controller::SessionItem
(const Standard_CString name) const
{
Handle(Standard_Transient) item;
if (theAdaptorSession.IsNull()) return item;
theAdaptorSession->GetItem (name,item);
return item;
}
Standard_Boolean XSControl_Controller::IsApplied
(const Handle(Standard_Transient)& item) const
{
if (item.IsNull()) return Standard_False;
for (Standard_Integer i = theAdaptorApplied.Length(); i >= 1; i --)
if (item == theAdaptorApplied.Value(i)) return Standard_True;
return Standard_False;
}
void XSControl_Controller::Customise
( Handle(XSControl_WorkSession)& WS)
{
WS->SetParams (theParams,theParamUses);
// General
if(!theAdaptorSession.IsNull()) {
Dico_IteratorOfDictionaryOfTransient iter(theAdaptorSession);
for (iter.Start(); iter.More(); iter.Next()) {
WS->AddNamedItem (iter.Name().ToCString() , iter.Value());
}
}
Customising(WS);
// Applied Modifiers
Standard_Integer i, nb = theAdaptorApplied.Length();
for (i = 1; i <= nb; i ++) {
Handle(Standard_Transient) anitem = theAdaptorApplied.Value(i);
Handle(TCollection_HAsciiString) name = WS->Name(anitem);
// Handle(Message_Messenger) sout = Message::DefaultMessenger();
// sout<<" -- Customise applied n0."<<i<<" type:"<<anitem->DynamicType()->Name();
// if (name.IsNull()) sout<<" no name"<<endl;
// else sout<<" name:"<<name->ToCString()<<endl;
WS->SetAppliedModifier
(GetCasted(IFSelect_GeneralModifier,theAdaptorApplied.Value(i)),
WS->ShareOut() );
}
// Editeurs de Parametres
// Ici car les constructeurs specifiques des controlleurs ont pu creer des
// Parametres : attendre donc ici
Handle(TColStd_HSequenceOfHAsciiString) listat = Interface_Static::Items();
Handle(IFSelect_ParamEditor) paramed =
IFSelect_ParamEditor::StaticEditor (listat,"All Static Parameters");
WS->AddNamedItem ("xst-static-params-edit",paramed);
Handle(IFSelect_EditForm) paramform = paramed->Form(Standard_False);
WS->AddNamedItem ("xst-static-params",paramform);
// Norm Specific
//Customising (WS);
// Loading Options of the Profile
// Available Signatures
Handle(IFSelect_Option) optsign = theProfile->Option ("sign-type");
// Handle(TColStd_HSequenceOfHAsciiString) signs =
// WS->ItemNames (STANDARD_TYPE(IFSelect_Signature));
// Standard_Integer isign, nbsign = (signs.IsNull() ? 0 : signs->Length());
// for (isign = 1; isign <= nbsign; isign ++) {
// Handle(TCollection_HAsciiString) signame = signs->Value(isign);
// Handle(Standard_Transient) asign = WS->NamedItem (signame);
// optsign->Add (signame->ToCString(),asign);
// }
optsign->Add ("default",theSignType); // defaut specifique
optsign->Switch ("default"); // garder courante la definition par defaut !
// Actor Read
Handle(IFSelect_Option) optacrd = theProfile->Option ("tr-read");
optacrd->Add ("default",theAdaptorRead);
optacrd->Switch ("default");
// Actor Write
Handle(IFSelect_Option) optacwr = theProfile->Option ("tr-write");
optacwr->Add ("default",theAdaptorWrite);
optacwr->Switch ("default");
// Basic configuration
theProfile->AddConf ("Base");
theProfile->AddSwitch ("Base","sign-type","default");
theProfile->AddSwitch ("Base","tr-read","default");
theProfile->AddSwitch ("Base","tr-write","default");
theProfile->SetCurrent ("Base");
}
void XSControl_Controller::Customising
( Handle(XSControl_WorkSession)& WS)
{
//ndle(IFSelect_SelectModelRoots) slr = new IFSelect_SelectModelRoots;
///WS->AddNamedItem ("xst-model-roots",slr);
if(!WS->NamedItem("xst-model-all").IsNull()) return;
Handle(IFSelect_SelectModelEntities) sle = new IFSelect_SelectModelEntities;
WS->AddNamedItem ("xst-model-all",sle);
Handle(IFSelect_SelectModelRoots) slr;
slr = new IFSelect_SelectModelRoots;
WS->AddNamedItem ("xst-model-roots",slr);
if(strcasecmp(WS->SelectedNorm(),"STEP")) {
Handle(XSControl_SelectForTransfer) st1 = new XSControl_SelectForTransfer;
st1->SetInput (slr);
st1->SetReader (WS->TransferReader());
WS->AddNamedItem ("xst-transferrable-roots",st1);
}
//else slr = Handle(IFSelect_SelectModelRoots)::DownCast(WS->NamedItem("xst-model-roots"));
Handle(XSControl_SelectForTransfer) st2 = new XSControl_SelectForTransfer;
st2->SetInput (sle);
st2->SetReader (WS->TransferReader());
WS->AddNamedItem ("xst-transferrable-all",st2);
Handle(XSControl_SignTransferStatus) strs = new XSControl_SignTransferStatus;
strs->SetReader (WS->TransferReader());
WS->AddNamedItem ("xst-transfer-status",strs);
Handle(XSControl_ConnectedShapes) scs = new XSControl_ConnectedShapes;
scs->SetReader (WS->TransferReader());
WS->AddNamedItem ("xst-connected-faces",scs);
Handle(IFSelect_SignType) stp = new IFSelect_SignType (Standard_False);
WS->AddNamedItem ("xst-long-type",stp);
Handle(IFSelect_SignType) stc = new IFSelect_SignType (Standard_True);
WS->AddNamedItem ("xst-type",stc);
Handle(IFSelect_SignAncestor) sta = new IFSelect_SignAncestor;
WS->AddNamedItem ("xst-ancestor-type",sta);
Handle(IFSelect_SignCounter) tc1 =
new IFSelect_SignCounter(stp,Standard_False,Standard_True);
WS->AddNamedItem ("xst-types",tc1);
Handle(IFSelect_SignCategory) sca = new IFSelect_SignCategory;
WS->AddNamedItem ("xst-category",sca);
Handle(IFSelect_SignValidity) sva = new IFSelect_SignValidity;
WS->AddNamedItem ("xst-validity",sva);
Handle(IFSelect_DispPerOne) dispone = new IFSelect_DispPerOne;
dispone->SetFinalSelection(slr);
WS->AddNamedItem ("xst-disp-one",dispone);
Handle(IFSelect_DispPerCount) dispcount = new IFSelect_DispPerCount;
Handle(IFSelect_IntParam) intcount = new IFSelect_IntParam;
intcount->SetValue(5);
dispcount->SetCount(intcount);
dispcount->SetFinalSelection(slr);
WS->AddNamedItem ("xst-disp-count",dispcount);
Handle(IFSelect_DispPerFiles) dispfiles = new IFSelect_DispPerFiles;
Handle(IFSelect_IntParam) intfiles = new IFSelect_IntParam;
intfiles->SetValue(10);
dispfiles->SetCount(intfiles);
dispfiles->SetFinalSelection(slr);
WS->AddNamedItem ("xst-disp-files",dispfiles);
Handle(IFSelect_DispPerSignature) dispsign = new IFSelect_DispPerSignature;
dispsign->SetSignCounter(new IFSelect_SignCounter(stc));
dispsign->SetFinalSelection(slr);
WS->AddNamedItem ("xst-disp-sign",dispsign);
// Pas utilisables directement mais bien utiles quand meme
WS->AddNamedItem ("xst-pointed",new IFSelect_SelectPointed);
WS->AddNamedItem ("xst-sharing",new IFSelect_SelectSharing);
WS->AddNamedItem ("xst-shared",new IFSelect_SelectShared);
WS->AddNamedItem ("xst-nb-selected",new IFSelect_GraphCounter);
theSignType = stp;
// au moins cela
}
Handle(Dico_DictionaryOfTransient) XSControl_Controller::AdaptorSession() const
{
return theAdaptorSession;
}

View File

@@ -0,0 +1,60 @@
-- File: XSControl_FuncShape.cdl
-- Created: Thu Mar 16 17:48:13 1995
-- Author: Christian CAILLET
-- <cky@anion>
---Copyright: Matra Datavision 1995
class FuncShape from XSControl
---Purpose : Defines additionnal commands for XSControl to :
-- - control of initialisation (xinit, xnorm, newmodel)
-- - analyse of the result of a transfer (recorded in a
-- TransientProcess for Read, FinderProcess for Write) :
-- statistics, various lists (roots,complete,abnormal), what
-- about one specific entity, producing a model with the
-- abnormal result
--
-- This appendix of XSControl is compiled separately to distinguish
-- basic features from user callable forms
uses CString, AsciiString from TCollection,
WorkSession from XSControl, HSequenceOfShape from TopTools
is
Init (myclass);
---Purpose : Defines and loads all functions which work on shapes for XSControl (as ActFunc)
MoreShapes (myclass; session : WorkSession from XSControl;
list : in out mutable HSequenceOfShape from TopTools;
name : CString) returns Integer;
---Purpose : Analyses a name as designating Shapes from a Vars or from
-- XSTEP transfer (last Transfer on Reading). <name> can be :
-- "*" : all the root shapes produced by last Transfer (Read)
-- i.e. considers roots of the TransientProcess
-- a name : a name of a variable DRAW
--
-- Returns the count of designated Shapes. Their list is put in
-- <list>. If <list> is null, it is firstly created. Then it is
-- completed (Append without Clear) by the Shapes found
-- Returns 0 if no Shape could be found
FileAndVar (myclass; session : WorkSession from XSControl;
file, var, def : CString;
resfile, resvar : out AsciiString from TCollection)
returns Boolean;
---Purpose : Analyses given file name and variable name, with a default
-- name for variables. Returns resulting file name and variable
-- name plus status "file to read"(True) or "already read"(False)
-- In the latter case, empty resfile means no file available
--
-- If <file> is null or empty or equates ".", considers Session
-- and returned status is False
-- Else, returns resfile = file and status is True
-- If <var> is neither null nor empty, resvar = var
-- Else, the root part of <resfile> is considered, if defined
-- Else, <def> is taken
end FuncShape;

View File

@@ -0,0 +1,833 @@
#include <XSControl_FuncShape.ixx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <XSControl.hxx>
#include <XSControl_Controller.hxx>
#include <XSControl_WorkSession.hxx>
#include <XSControl_Vars.hxx>
#include <IFSelect_Act.hxx>
#include <IFSelect_SessionPilot.hxx>
#include <IFSelect_Functions.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Transfer_TransientProcess.hxx>
#include <Transfer_FinderProcess.hxx>
#include <Transfer_Finder.hxx>
#include <Transfer_Binder.hxx>
#include <Interface_CheckIterator.hxx>
//#include <TransferBRep_Analyzer.hxx>
#include <TransferBRep_ShapeMapper.hxx>
#include <TransferBRep_ShapeBinder.hxx>
#include <TransferBRep_ShapeListBinder.hxx>
#include <Transfer_SimpleBinderOfTransient.hxx>
#include <XSControl_ConnectedShapes.hxx>
#include <XSControl_TransferWriter.hxx>
#include <XSControl_TransferReader.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <Transfer_ResultFromModel.hxx>
#include <TopTools_HSequenceOfShape.hxx>
#include <TopoDS_Compound.hxx>
#include <BRep_Builder.hxx>
#include <TransferBRep.hxx>
#include <BRepTools.hxx>
#include <TopoDS.hxx>
#include <TColStd_SequenceOfInteger.hxx>
#include <TopExp_Explorer.hxx>
#include <Geom_Geometry.hxx>
#include <Geom2d_Curve.hxx>
#include <IFSelect_CheckCounter.hxx>
#include <ShapeExtend_Explorer.hxx>
#include <Interface_Macros.hxx>
#include <stdio.h>
#include <TopoDS_Iterator.hxx>
#include <Transfer_TransientListBinder.hxx>
#include <Message_Messenger.hxx>
#include <Message.hxx>
// ######################################################################
// #### ####
// #### COMMANDS ####
// #### ####
// ######################################################################
//=======================================================================
//function : XSControl_tpdraw
//purpose :
//=======================================================================
static IFSelect_ReturnStatus XSControl_tpdraw
(const Handle(IFSelect_SessionPilot)& pilot)
{
Standard_Integer argc = pilot->NbWords();
const Standard_CString arg1 = pilot->Arg(1);
const Standard_CString arg2 = pilot->Arg(2);
const Standard_CString arg3 = pilot->Arg(3);
Handle(Transfer_TransientProcess) TP = XSControl::Session(pilot)->TransferReader()->TransientProcess();
Handle(Message_Messenger) sout = Message::DefaultMessenger();
if (TP.IsNull()) { sout<<"No Transfer Read"<<endl; return IFSelect_RetError;}
// **** tpdraw ****
if (argc < 2) {
sout<<"Donner [mode facultatif : item ou root] , NUMERO , nom DRAW facultatif"<<endl;
sout<<" mode si present : item ou root, sinon n0 d entite modele"<<endl;
sout<<" NUMERO entier : d entite, d item transfert ou de root transfert\n"
<< " ou * pour dire tous"<<endl;
return IFSelect_RetError;
}
Standard_Integer mode = 0, num=0;
if (arg1[0] == 'i') mode = 1;
else if (arg1[0] == 'r') mode = 2;
Standard_Boolean tout = Standard_False;
if (mode == 0) {
if (argc < 2) { sout<<"Donner au moins un NUMERO ou *"<<endl; return IFSelect_RetError; }
if (arg1[0] == '*') tout = Standard_True;
else num = IFSelect_Functions::GiveEntityNumber(XSControl::Session(pilot),arg1);
} else {
if (arg2[0] == '*') tout = Standard_True;
else num = IFSelect_Functions::GiveEntityNumber(XSControl::Session(pilot),arg2);
}
Standard_Integer nbvar = 0;
Handle(Transfer_Binder) binder;
Handle(Standard_Transient) ent;
TopoDS_Shape sh; char nomvar[40];
// Standard_Boolean moderoot = (pilot->Word(0).Value(3) == 'r');
Standard_Integer n1, n2, i, max=0, index=0;
Handle(Interface_InterfaceModel) model = TP->Model();
if (model.IsNull()) {
if (mode == 0) {
sout<<"Pas de modele, preciser n0 d item de transfert"<<endl;
return IFSelect_RetError;
}
}
if (mode == 0) { sout<<"Entite de modele"; max = model->NbEntities(); }
if (mode == 1) { sout<<"Item de transfert"; max = TP->NbMapped(); }
if (mode == 2) { sout<<"Racine de transfert"; max = TP->NbRoots(); }
if (tout) {
n1 = 1; n2 = max;
sout<<", listage de 1 a "<<max<<endl;
}
else if (num <= 0 || num > max) {
sout<<" - Num="<<num<<" hors limite (de 1 a "<<max<<")"<<endl;
return IFSelect_RetError;
} else {
n1 = n2 = num; nbvar = -1; // nbvar : 1ere shape simple = pas de n0
sout<<", n0 "<<num<<endl;
}
for (i = n1; i <= n2; i ++) {
if (mode == 0) {
ent = model->Value(i);
num = i;
index = TP->MapIndex(ent);
} else if (mode == 1) {
ent = TP->Mapped(i);
if (model.IsNull()) num = 0;
else num = model->Number(ent);
index = i;
} else if (mode == 2) {
ent = TP->Root(i);
if (model.IsNull()) num = 0;
else num = model->Number(ent);
index = TP->MapIndex(ent);
}
if (index > 0) binder = TP->MapItem (index);
if (binder.IsNull()) index = 0;
if (index == 0) {
if (!tout) sout<<"Entite n0 "<<num<<" : non repertoriee"<<endl;
continue;
}
if (!binder->HasResult()) {
if (!tout) sout<<"Entite n0 "<<num<<" : pas de resultat"<<endl;
continue;
}
sh = TransferBRep::ShapeResult (binder);
//DeclareAndCast(TransferBRep_ShapeBinder,shb,binder);
if (!sh.IsNull()) {
//sh = shb->Result();
nbvar ++;
if (sh.IsNull()) { sout<<" (no Shape recorded)"<<endl; continue; }
if (tout) sout<<"[ "<<i<<" ]:";
if (num == 0) sout<<" pas dans le modele";
else sout<<" ent.n0 "<<num;
sout<<", item transfert n0 "<<index;
if (nbvar == 0) {
if (argc > 3 && mode > 0) sprintf (nomvar,"%s",arg3);
else if (argc > 2 && mode == 0) sprintf (nomvar,"%s",arg2);
else sprintf (nomvar,"tp_%d",i);
} else {
if (argc > 3 && mode > 0) sprintf (nomvar,"%s_%d",arg3,nbvar);
else if (argc > 2 && mode == 0) sprintf (nomvar,"%s_%d",arg2,nbvar);
else sprintf (nomvar,"tp_%d",i);
}
sout<<" -> 1 DRAW Shape: "<<nomvar<<endl;
XSControl::Vars(pilot)->SetShape(nomvar,sh);
continue;
}
DeclareAndCast(TransferBRep_ShapeListBinder,slb,binder);
if (!slb.IsNull()) {
Standard_Integer nbs = slb->NbShapes();
if (tout) sout<<"[ "<<i<<" ]:";
if (num == 0) sout<<" pas dans le modele";
else sout<<" ent.n0 "<<num;
sout<<", item transfert n0 "<<index;
sout<<" -> "<<nbs<<" DRAW Shapes :";
for (Standard_Integer j = 1; j <= nbs; j ++) {
sh = slb->Shape(j); if (nbvar < 0) nbvar = 0; nbvar ++;
if (sh.IsNull()) { sout<<" (no Shape recorded)"<<endl; continue; }
if (argc > 3 && mode > 0) sprintf (nomvar,"%s_%d",arg3,nbvar);
else if (argc > 2 && mode == 0) sprintf (nomvar,"%s_%d",arg2,nbvar);
else sprintf (nomvar,"tp_%d_%d",i,nbvar);
sout<<" "<<nomvar;
XSControl::Vars(pilot)->SetShape(nomvar,sh);
}
sout<<endl;
continue;
}
DeclareAndCast(Transfer_SimpleBinderOfTransient,trb,binder);
if (!trb.IsNull()) {
Handle(Standard_Transient) resu = trb->Result();
if (resu.IsNull()) {
sout<<"Entite n0 "<<num<<" : pas de resultat"<<endl;
continue;
}
DeclareAndCast(Geom_Geometry,geom,resu);
sout<<"Entite n0 "<<num<<" : resultat "<<resu->DynamicType()->Name();
if (geom.IsNull()) { sout<<endl; continue; }
nbvar ++;
if (nbvar == 0) {
if (argc > 3 && mode > 0) sprintf (nomvar,"%s",arg3);
else if (argc > 2 && mode == 0) sprintf (nomvar,"%s",arg2);
else sprintf (nomvar,"tp_%d",i);
} else {
if (argc > 3 && mode > 0) sprintf (nomvar,"%s_%d",arg3,nbvar);
else if (argc > 2 && mode == 0) sprintf (nomvar,"%s_%d",arg2,nbvar);
else sprintf (nomvar,"tp_%d",i);
}
char* nomv = nomvar;
XSControl::Vars(pilot)->Set (nomv,geom);
sout<<" -> DRAW Geom : "<<nomvar<<endl;
continue;
}
if (sh.IsNull() && trb.IsNull())
if (!tout) sout<<"Entite n0 "<<num<<" : resultat pas une Shape mais "<<binder->ResultTypeName()<<endl;
}
if (sh.IsNull()) sout<<" (No Shape)"<<endl;
return IFSelect_RetDone;
}
//=======================================================================
//function : XSControl_tpcompound
//purpose :
//=======================================================================
static IFSelect_ReturnStatus XSControl_tpcompound
(const Handle(IFSelect_SessionPilot)& pilot)
{
Standard_Integer argc = pilot->NbWords();
const Standard_CString arg1 = pilot->Arg(1);
Handle(Transfer_TransientProcess) TP = XSControl::Session(pilot)->TransferReader()->TransientProcess();
Handle(Message_Messenger) sout = Message::DefaultMessenger();
if (TP.IsNull()) { sout<<"No Transfer Read"<<endl; return IFSelect_RetError;}
// **** tpcompound ****
if (argc < 2) { sout<<"Give a NAME for the Compound + optional givelist, else roots are taken"<<endl; return IFSelect_RetError; }
Handle(TopTools_HSequenceOfShape) list;
if (argc == 2) list = TransferBRep::Shapes(TP);
else {
Handle(TColStd_HSequenceOfTransient) lise = IFSelect_Functions::GiveList(pilot->Session(),pilot->CommandPart(2));
if (lise.IsNull()) { sout<<"Not a valid entity list : "<<pilot->CommandPart(2)<<endl; return IFSelect_RetError; }
list = TransferBRep::Shapes (TP,lise);
sout<<lise->Length()<<" Entities, ";
}
if (list.IsNull()) { sout<<"No Shape listed"<<endl; return IFSelect_RetError; }
Standard_Integer nb = list->Length();
sout<<nb<<" Shape(s) listed"<<endl;
TopoDS_Compound C;
BRep_Builder B;
B.MakeCompound(C);
for (Standard_Integer i = 1; i <= nb; i ++) B.Add (C,list->Value(i));
XSControl::Vars(pilot)->SetShape (arg1,C);
return IFSelect_RetDone;
}
//=======================================================================
//function : XSControl_traccess
//purpose :
//=======================================================================
static IFSelect_ReturnStatus XSControl_traccess
(const Handle(IFSelect_SessionPilot)& pilot)
{
Standard_Integer argc = pilot->NbWords();
const Standard_CString arg1 = pilot->Arg(1);
const Standard_CString arg2 = pilot->Arg(2);
// **** trdraw : TransferReader **** 26
// **** trsave : TransferReader **** 27
// **** trcomp (comp -> DRAW) **** 28
// **** trscomp (comp -> save) **** 29
Standard_Boolean cascomp = (pilot->Word(0).Location(1,'o',1,5) > 0);
Standard_Boolean cassave = (pilot->Word(0).Location(1,'s',1,5) > 0);
char nomsh[100], noms[100];
Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
Handle(Message_Messenger) sout = Message::DefaultMessenger();
if (TR.IsNull()) { sout<<" manque init"<<endl; return IFSelect_RetError; }
Handle(Interface_InterfaceModel) mdl = TR->Model();
if (mdl.IsNull()) { sout<<" modele absent"<<endl; return IFSelect_RetError; }
Standard_Integer num = (argc > 1 ? IFSelect_Functions::GiveEntityNumber(XSControl::Session(pilot),arg1) : 0);
if (argc > 1) strcpy (nomsh,arg1);
else strcpy (nomsh,(cascomp ? "TREAD_COMP" : "TREAD_LIST"));
if (cassave) sout<<" save shapes -> current directory"<<endl;
if (num == 0 || cascomp) {
TopoDS_Compound C; // pour cas compound
BRep_Builder B;
B.MakeCompound(C);
Handle(TopTools_HSequenceOfShape) list = TR->ShapeResultList(Standard_True);
Standard_Integer i, nb = list->Length();
sout<<" TOUS RESULTATS par ShapeResultList, soit "<<nb<<endl;
for (i = 1; i <= nb; i ++) {
sprintf (noms,"%s_%d",nomsh,i);
if ( (i%1000) == 0) sout<<"("<<i<<")"<<endl;
else if ( (i%100) == 0) sout<<"*";
else if ( (i%10) == 0) sout<<"0";
else sout<<".";
if (list->Value(i).IsNull()) continue;
if (!cascomp && !cassave) XSControl::Vars(pilot)->SetShape(noms,list->Value(i));
else if (!cascomp && cassave) BRepTools::Write (list->Value(i),noms);
else if (cascomp) B.Add (C,list->Value(i));
}
sout<<endl;
if (cascomp && !cassave) XSControl::Vars(pilot)->SetShape(nomsh,C);
else if (cascomp && cassave) BRepTools::Write (C,nomsh);
} else {
if (num < 1 || num > mdl->NbEntities()) { sout<<" incorrect:"<<arg1<<endl; return IFSelect_RetError; }
TopoDS_Shape sh = TR->ShapeResult(mdl->Value(num));
if (sh.IsNull()) { sout<<" Pas de resultat pour "<<arg1<<endl; return IFSelect_RetError; }
if (argc > 2) sprintf (nomsh,"%s",arg2);
else sprintf (nomsh,"TREAD_%d",num);
if (!cascomp && !cassave) XSControl::Vars(pilot)->SetShape(nomsh,sh);
else if (!cascomp && cassave) BRepTools::Write (sh,nomsh);
else sout<<"Option non comprise"<<endl;
}
return IFSelect_RetDone;
}
//=======================================================================
//function : XSControl_IsEqualSubShape
//purpose :
//=======================================================================
// PTV 23.08.2000 Added for checking where are an entity from.
static Standard_Boolean XSControl_IsEqualSubShape (const TopoDS_Shape& Shape,
TopoDS_Shape& sh, Standard_Integer aLevel)
{
if ( sh.IsSame(Shape) ) return Standard_True;
if (aLevel > 0) {
TopoDS_Shape varShape;
aLevel--;
TopoDS_Iterator it(sh);
for (; it.More(); it.Next() ) {
varShape = it.Value();
if ( XSControl_IsEqualSubShape(Shape, varShape, aLevel) ) return Standard_True;
}
}
return Standard_False;
}
//=======================================================================
//function : XSControl_fromshape
//purpose :
//=======================================================================
static IFSelect_ReturnStatus XSControl_fromshape
(const Handle(IFSelect_SessionPilot)& pilot)
{
Standard_Integer argc = pilot->NbWords();
const Standard_CString arg1 = pilot->Arg(1);
// **** fromshape (tread) ****
Handle(Message_Messenger) sout = Message::DefaultMessenger();
if (argc < 2) {
sout<<"Give name of a DRAW Shape"<<endl;
return IFSelect_RetError;
}
const char* a1 = (char *)arg1;
TopoDS_Shape Shape = XSControl::Vars(pilot)->GetShape(a1);
if (Shape.IsNull()) {
sout<<"Not a DRAW Shape:"<<arg1<<endl;
return IFSelect_RetError;
}
Standard_Boolean yena = Standard_False;
Standard_Integer aLevel = 1;
if (argc >=3 )
aLevel = atoi(pilot->Arg(2));
Standard_Boolean silent = Standard_False;
if (aLevel <0 ) {
silent = Standard_True;
aLevel = -aLevel;
}
// IMPORT
Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
if (TR.IsNull()) { } // sout<<"No read transfer (import) recorded"<<endl;
else {
yena = Standard_True;
if ( ! silent ) sout<<"Shape "<<arg1<<" : ";
Standard_Integer modrec = 1;
Handle(Standard_Transient) ent = TR->EntityFromShapeResult (Shape,modrec);
if (ent.IsNull()) {
modrec = -1;
ent = TR->EntityFromShapeResult (Shape,modrec);
}
if (ent.IsNull()) {
modrec = 2;
Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
if (TP.IsNull()) {
if ( silent )
sout << "Shape "<<arg1<<" : ";
sout<<"no map"<<endl;
}
else {
TopoDS_Shape S0 = Shape;
TopLoc_Location L;
S0.Location ( L );
Standard_Integer i, nb = TP->NbMapped();
if ( ! silent ) sout<<"searching in map among "<<nb<<" ...";
for (i = 1; i <= nb; i ++) {
ent = TP->Mapped(i);
TopoDS_Shape sh = TransferBRep::ShapeResult(TP,ent);
if (sh.IsNull()) {
ent.Nullify();
continue;
}
if (XSControl_IsEqualSubShape(Shape, sh, aLevel)) break;
modrec = -2;
sh.Location ( L );
if (XSControl_IsEqualSubShape(S0, sh, aLevel)) break;
ent.Nullify();
modrec = 2;
}
}
}
if ( ! ent.IsNull() ) {
if ( silent ) sout << "Shape " << arg1 << ": ";
if (modrec <0) sout<<"(moved from origin) ";
//else sout<<"(origin) ";
}
// on affiche
if (ent.IsNull()) {
if ( ! silent ) sout<<" unknown as imported";
// skl 11.05.2004
// if Shape is a compound try to make "fromshape" for its subshapes
if(Shape.ShapeType()==TopAbs_COMPOUND) {
sout<<endl<<"Subshapes imported from entities:";
TopoDS_Iterator Iter(Shape);
for (; Iter.More(); Iter.Next()) {
TopoDS_Shape subsh = Iter.Value();
Standard_Integer submodrec = 1;
Handle(Standard_Transient) subent = TR->EntityFromShapeResult(subsh,submodrec);
if (subent.IsNull()) {
submodrec = -1;
subent = TR->EntityFromShapeResult(subsh,submodrec);
}
if (!subent.IsNull()) {
sout<<" "<<XSControl::Session(pilot)->Model()->Number(subent);
}
}
}
}
else {
sout<<"imported from entity ";
XSControl::Session(pilot)->Model()->Print(ent,sout);
if ( silent ) sout << " in file " << XSControl::Session(pilot)->LoadedFile() << endl;
}
if ( ! silent ) sout<<endl;
}
// ET EN EXPORT ?
Handle(Transfer_FinderProcess) FP = XSControl::Session(pilot)->MapWriter();
if (FP.IsNull()) { } //sout<<"No write transfer (export) recorded"<<endl;
else {
yena = Standard_True;
Handle(Transfer_Finder) fnd = TransferBRep::ShapeMapper (FP,Shape);
Handle(Standard_Transient) ent;
if (!fnd.IsNull()) ent = FP->FindTransient (fnd);
if (!ent.IsNull()) {
sout<<"Shape "<<arg1<<": exported to entity ";
XSControl::Session(pilot)->Model()->Print(ent,sout);
if ( silent ) sout << " in file " << XSControl::Session(pilot)->LoadedFile();
sout<<endl;
}
// abv 31.08.00: treat case of splitted shape (several results)
// it is supposed that results are of the same type and lie in one-level comp
else {
Handle(Transfer_Binder) bnd = FP->Find ( fnd );
if ( ! bnd.IsNull() ) {
Handle(Transfer_TransientListBinder) TransientListBinder =
//Handle(Transfer_TransientListBinder)::DownCast( bnd->Next(Standard_True) ); //skl
Handle(Transfer_TransientListBinder)::DownCast( bnd ); //skl
if (! TransientListBinder.IsNull() ) {
Standard_Integer i = 1, nb = TransientListBinder->NbTransients();
if (nb > 0) sout<<"Shape "<<arg1<<": exported to entities ";
for (; i<=nb; i++) {
XSControl::Session(pilot)->Model()->Print( TransientListBinder->Transient(i), sout );
if (i < nb) sout<<", ";
}
if (nb > 0) {
if ( silent ) sout << " in file " << XSControl::Session(pilot)->LoadedFile();
sout<<endl;
}
}
/* else {
TopoDS_Shape comp = TransferBRep::ShapeResult(bnd);
if ( ! comp.IsNull() && comp.ShapeType() < Shape.ShapeType() ) {
Standard_Boolean start = Standard_True;
for ( TopoDS_Iterator it(comp); it.More(); it.Next() ) {
Handle(Transfer_Finder) cfnd = TransferBRep::ShapeMapper (FP,it.Value());
if ( cfnd.IsNull() ) continue;
Handle(Standard_Transient) cent = FP->FindTransient (cfnd);
if ( cent.IsNull() ) continue;
if ( start )
sout<<"Shape "<<arg1<<" : exported to entities ";
else sout << ", ";
start = Standard_False;
XSControl::Session(pilot)->Model()->Print(cent,sout);
}
if ( ! start ) sout<<endl;
}
} */
}
}
}
if (!yena) sout<<"No transfer (either import or export) recorded"<<endl;
return IFSelect_RetVoid;
}
//=======================================================================
//function : XSControl_trconnexentities
//purpose :
//=======================================================================
static IFSelect_ReturnStatus XSControl_trconnexentities
(const Handle(IFSelect_SessionPilot)& pilot)
{
Standard_Integer argc = pilot->NbWords();
const Standard_CString arg1 = pilot->Arg(1);
// **** connected entities (last transfer) ****
Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
Handle(Transfer_TransientProcess) TP;
if (!TR.IsNull()) TP = TR->TransientProcess();
Handle(Message_Messenger) sout = Message::DefaultMessenger();
if (TP.IsNull()) { sout<<"no transfer map"<<endl; return IFSelect_RetVoid; }
if (argc < 2) {
sout<<"Give name of a DRAW Shape + optional shape type v-e-w-f(D)-s"<<endl;
return IFSelect_RetError;
}
const char* a1 = (const char *)arg1;
TopoDS_Shape Shape = XSControl::Vars(pilot)->GetShape(a1);
if (Shape.IsNull()) { sout<<"Not a DRAW Shape:"<<arg1<<endl; return IFSelect_RetError; }
sout<<"Shape "<<arg1<<" : ";
Handle(TColStd_HSequenceOfTransient) list =
XSControl_ConnectedShapes::AdjacentEntities (Shape,TP,TopAbs_FACE);
Standard_Integer i, nb = list->Length();
sout<<nb<<" Entities produced Connected Shapes :"<<endl;
Handle(Interface_InterfaceModel) model = XSControl::Session(pilot)->Model();
sout<<"(";
for (i = 1; i <= nb; i ++) {
if (i > 1) sout<<",";
sout<<model->Number(list->Value(i));
}
sout<<")"<<endl;
return IFSelect_RetDone;
}
//=======================================================================
//function : XSControl_trimport
//purpose :
//=======================================================================
static IFSelect_ReturnStatus XSControl_trimport
(const Handle(IFSelect_SessionPilot)& pilot)
{
// FileName ou . (pour courant) VarName GiveList (obligatoire)
// GiveList : * pour xst-transferrable-roots
Handle(XSControl_WorkSession) WS = XSControl::Session(pilot);
Standard_Integer argc = pilot->NbWords();
Handle(Message_Messenger) sout = Message::DefaultMessenger();
if (argc < 4) {
sout<<"Give : filename or . for current model; varname or . to take fileroot\n GiveList, * for all transferrable roots"<<endl;
return IFSelect_RetError;
}
const Standard_CString arg1 = pilot->Arg(1);
const Standard_CString arg2 = pilot->Arg(2);
const Standard_CString arg3 = pilot->Arg(3);
// File Name and Variable (root) Name
TCollection_AsciiString fnom,rnom;
Standard_Boolean modfic = XSControl_FuncShape::FileAndVar
(WS,arg1,arg2,"IMPORT",fnom,rnom);
if (modfic) sout<<" File to read : "<<fnom<<endl;
else sout<<" Model taken from the session : "<<fnom<<endl;
sout<<" -- Names of variables BREP-DRAW prefixed by : "<<rnom<<endl;
// keep the current command, because sub-commands will be called
TCollection_AsciiString compart = pilot->CommandPart (3);
// Reading file if required
if (modfic) {
TCollection_AsciiString comload ("xload ");
comload.AssignCat(arg1);
IFSelect_ReturnStatus status = pilot->Execute(comload);
if (status != IFSelect_RetDone)
{ sout<<"Abandon import"<<endl; return status; }
} else {
sout<<"Currently Loaded Model"<<endl;
}
// Selecting Entities
Handle(TColStd_HSequenceOfTransient) list;
if (arg3[0] == '*' && arg3[1] == '\0') {
list = WS->GiveList ("xst-transferrable-roots");
sout<<"All Transferrable Roots : ";
} else {
sout<<"List given by "<<compart.ToCString()<<" : ";
list = WS->GiveList (compart.ToCString());
}
if (list.IsNull()) { sout<<"No list defined. Abandon"<<endl; return IFSelect_RetError; }
Standard_Integer nbl = list->Length();
sout<<"Nb entities selected : "<<nbl<<endl;
// Starting Transfer
WS->InitTransferReader (0);
Handle(XSControl_TransferReader) TR = WS->TransferReader();
if (TR.IsNull()) { sout<<" init not done or failed"<<endl; return IFSelect_RetError; }
TR->BeginTransfer();
// Transferring
Standard_Integer nbt = TR->TransferList(list);
sout<<"Nb Entities Selected : "<<nbl<<" have given "<<nbt<<" results"<<endl;
// Filling VARS. one compound (trimpcomp) or one shape per ent (trimport)
Standard_Boolean iscomp = (pilot->Arg(0)[5] == 'c');
Standard_Integer nbs = 0;
TopoDS_Shape sh;
TopoDS_Compound C;
BRep_Builder B;
B.MakeCompound (C);
Handle(Interface_InterfaceModel) mdl = TR->Model();
if (mdl.IsNull()) { sout<<" modele absent"<<endl; return IFSelect_RetError; }
for (Standard_Integer il= 1; il <= nbl; il ++) {
Handle(Standard_Transient) ent = list->Value(il);
sh = TR->ShapeResult(ent);
if (sh.IsNull()) continue;
nbs ++;
if (iscomp) B.Add (C,sh);
else {
char nomsh[50];
sprintf (nomsh,"%s_%d",rnom.ToCString(),nbs);
XSControl::Vars(pilot)->SetShape(nomsh,sh);
}
}
if (nbs == 0) sout<<"No Shape produced"<<endl;
else if (nbs == 1) {
sout<<"One Shape produced, named "<<rnom.ToCString()<<endl;
XSControl::Vars(pilot)->SetShape(rnom.ToCString(),sh);
} else if (iscomp) {
sout<<"One compound made of "<<nbs<<" Shapes, named "<<rnom.ToCString()<<endl;
XSControl::Vars(pilot)->SetShape(rnom.ToCString(),C);
} else { // several individual shapes
sout<<nbs<<" Shapes, named "<<rnom.ToCString()<<"_1 to "<<rnom.ToCString()<<"_"<<nbs<<endl;
}
return IFSelect_RetDone;
}
//=======================================================================
//function : XSControl_twrite
//purpose :
//=======================================================================
static IFSelect_ReturnStatus XSControl_twrite
(const Handle(IFSelect_SessionPilot)& pilot)
{
Standard_Integer argc = pilot->NbWords();
const Standard_CString arg1 = pilot->Arg(1);
// **** twrite ****
Handle(Message_Messenger) sout = Message::DefaultMessenger();
Handle(XSControl_TransferWriter) TW = XSControl::Session(pilot)->TransferWriter();
if (argc < 2) { sout<<" donner nom de shape draw"<<endl; return IFSelect_RetError; }
sout<<"Attention, on alimente le modele courant ..."<<endl;
// Shape
for (Standard_Integer i = 1; i < argc; i ++) {
const char* ai = (const char *)pilot->Arg(i);
TopoDS_Shape Shape = XSControl::Vars(pilot)->GetShape(ai);
if (Shape.IsNull()) { sout<<"pas un nom de shape draw:"<<arg1<<endl; continue; }
sout<<"Pour Shape : "<<ai;
Standard_Integer stat = TW->TransferWriteShape (XSControl::Session(pilot)->Model(),Shape);
sout<<" Transfer Write Status = "<<stat<<endl;
}
pilot->Session()->ComputeGraph();
// Transient ? (Geom) : ignore
return IFSelect_RetDone;
}
// ######################################################################
// #### TIMERS ####
// ######################################################################
// ######################################################################
// #### ####
// #### Initialising Commands ####
// #### ####
// ######################################################################
static int initactor = 0;
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void XSControl_FuncShape::Init ()
{
if (initactor) return; initactor = 1;
IFSelect_Act::SetGroup("DE: General");
IFSelect_Act::AddFunc ("tpdraw","[mode:item or root] num|* [nomvar] Passes an ITEM to Shape Draw (Start or Result)",XSControl_tpdraw);
IFSelect_Act::AddFunc ("tpcompound","name:cstring [givelist] : -> compound with Shapes Root or from givelist",XSControl_tpcompound);
IFSelect_Act::AddFunc ("trdraw","results ->DRAW : all; or num [name] : from ent.num -> DRAW [name/tread_num]",XSControl_traccess);
IFSelect_Act::AddFunc ("trsave","results ->files : all; or num [name] : from ent.num -> DRAW [name/tread_num]",XSControl_traccess);
IFSelect_Act::AddFunc ("trcomp","results -> 1 compound -> DRAW + name optional",XSControl_traccess);
IFSelect_Act::AddFunc ("trscomp","results -> 1 compound -> file + name optional",XSControl_traccess);
IFSelect_Act::AddFunc ("fromshape","shape [level=1]: imported/exported entity (when known)",XSControl_fromshape);
IFSelect_Act::AddFunc ("trconnexent","name of draw shape : entities -> connected shapes (when known)",XSControl_trconnexentities);
IFSelect_Act::AddFunc ("trimport","filename or . varname givelist -> 1 shape per entity",XSControl_trimport);
IFSelect_Act::AddFunc ("trimpcomp","filename or . varname givelist -> one xcompound",XSControl_trimport);
IFSelect_Act::AddFunc ("twrite","shape : transfer write for this shape, AFTER newmodel !",XSControl_twrite);
//skl IFSelect_Act::AddFunc ("checkbrep","shapename or * [+ rootname for expurged and faulties [+ mode f-s]]",XSHAPE_checkbrep);
//skl IFSelect_Act::AddFunc ("dblist","option : clear nb index set n1 data n1 n2",XSHAPE_dblist);
}
// ######################################################################
// #### ####
// #### Additional Methods ####
// #### ####
// ######################################################################
//=======================================================================
//function : MoreShapes
//purpose :
//=======================================================================
Standard_Integer XSControl_FuncShape::MoreShapes
(const Handle(XSControl_WorkSession)& session,
Handle(TopTools_HSequenceOfShape)& list, const Standard_CString name)
{
// name = un nom -> Draw
// name = "*" -> tous les transferts RACINES du TP
// name = "**" -> tous les transferts du TP : VRAIMENT TOUS
// name = "." -> reperage graphique (not yet impl)
// name = nom(n1-n2) avec n1,n2 entiers : les variables de nom nomn1 a nomn2
Handle(Message_Messenger) sout = Message::DefaultMessenger();
if (list.IsNull()) list = new TopTools_HSequenceOfShape();
if (name[0] == '*' && (name[1] == '\0' || (name[1] == '*' && name[2] == '\0'))) {
Handle(Transfer_TransientProcess) TP = session->TransferReader()->TransientProcess();
if (TP.IsNull()) { sout<<"last transfer : unknown"<<endl;return 0; }
Handle(TopTools_HSequenceOfShape) li = TransferBRep::Shapes(TP,(name[1] == '\0'));
if (li.IsNull()) return 0;
list->Append (li);
return li->Length();
}
Standard_Integer i, paro = 0, parf = 0, moins = 0, n1 = 0, n2 = 0;
for (i = 0; name[i] != '\0'; i ++) {
if (name[i] == '(') paro = i;
if (name[i] == '-') moins = i;
if (name[i] == ')') parf = i;
}
if (paro && moins && parf) {
n2 = atoi (&name[moins+1]);
n1 = atoi (&name[paro +1]); if (n1 < 0) n1 += n2; // sinon on a n1-n2
}
// liste
if (n1 <= n2 && n1 > 0) {
char nom[50], nomsh[60]; Standard_Integer nbsh = 0;
for (i = 0; i < paro; i ++) nom[i]=name[i]; nom[paro] = '\0';
sout<<"Shapes DRAW named : "<<nom<<n1<<" to "<<nom<<n2;
for (i = n1; i <= n2 ; i ++) {
const char* nomshh = &nomsh[0];
sprintf (nomsh,"%s%d",nom,i);
TopoDS_Shape Shape = session->Vars()->GetShape(nomshh);
if (Shape.IsNull()) continue;
list->Append(Shape);
nbsh ++;
}
sout<<" -> taken "<<nbsh<<" Shapes"<<endl;
return nbsh;
}
const char* a1 = (const char *)name;
TopoDS_Shape Shape = session->Vars()->GetShape(a1);
if (Shape.IsNull()) { sout<<"not a shape draw:"<<a1<<endl; return 0; }
list->Append(Shape);
return 1;
}
//=======================================================================
//function : FileAndVar
//purpose :
//=======================================================================
Standard_Boolean XSControl_FuncShape::FileAndVar
(const Handle(XSControl_WorkSession)& session,
const Standard_CString file, const Standard_CString var,
const Standard_CString def,
TCollection_AsciiString& resfile, TCollection_AsciiString& resvar)
{
Standard_Boolean iafic = Standard_True;
resfile.Clear(); resvar.Clear();
if (file)
if ( file[0] == '\0' ||
(file[0] == '.' && file[1] == '\0')) iafic = Standard_False;
if (!iafic) resfile.AssignCat (session->LoadedFile());
else resfile.AssignCat (file);
if (var && var[0] != '\0' && (var[0] != '.' || var[1] != '\0') )
resvar.AssignCat (var);
else if (resfile.Length() == 0) resvar.AssignCat (def);
else {
Standard_Integer nomdeb, nomfin;
nomdeb = resfile.SearchFromEnd ("/");
if (nomdeb <= 0) nomdeb = resfile.SearchFromEnd("\\"); // pour NT
if (nomdeb < 0) nomdeb = 0;
nomfin = resfile.SearchFromEnd (".");
if (nomfin < nomdeb) nomfin = resfile.Length() + 1;
resvar = resfile.SubString(nomdeb+1,nomfin-1);
}
return iafic;
}

View File

@@ -0,0 +1,23 @@
-- File: XSControl_Functions.cdl
-- Created: Tue Mar 26 18:08:36 1996
-- Author: Christian CAILLET
-- <cky@fidox>
---Copyright: Matra Datavision 1996
class Functions from XSControl
---Purpose : Functions from XSControl gives access to actions which can be
-- commanded with the resources provided by XSControl: especially
-- Controller and Transfer
--
-- It works by adding functions by method Init
uses CString
is
Init (myclass);
---Purpose : Defines and loads all functions for XSControl (as ActFunc)
end Functions;

View File

@@ -0,0 +1,835 @@
#include <XSControl_Functions.ixx>
#include <XSControl.hxx>
#include <XSControl_Controller.hxx>
#include <IFSelect_Profile.hxx>
#include <IFSelect_Option.hxx>
#include <MoniTool_TypedValue.hxx>
#include <Interface_Static.hxx>
#include <TColStd_HSequenceOfAsciiString.hxx>
#include <XSControl_WorkSession.hxx>
#include <IFSelect_Act.hxx>
#include <IFSelect_SessionPilot.hxx>
#include <IFSelect_Functions.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TColStd_HSequenceOfHAsciiString.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Transfer_TransientProcess.hxx>
#include <Transfer_FinderProcess.hxx>
#include <Transfer_Binder.hxx>
#include <Interface_CheckIterator.hxx>
#include <IFSelect_CheckCounter.hxx>
#include <Transfer_TransferIterator.hxx>
#include <Transfer_IteratorOfProcessForTransient.hxx>
#include <Dico_IteratorOfDictionaryOfInteger.hxx>
//#include <TransferBRep_ShapeBinder.hxx>
//#include <TransferBRep_ShapeListBinder.hxx>
//#include <TransferBRep_ShapeMapper.hxx>
//#include <TransferBRep_OrientedShapeMapper.hxx>
#include <XSControl_TransferWriter.hxx>
#include <XSControl_TransferReader.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <Transfer_ResultFromModel.hxx>
#include <XSControl_SelectForTransfer.hxx>
#include <Interface_Macros.hxx>
#include <Message_Messenger.hxx>
#include <Message.hxx>
// #######################################################################
// ## ##
// ## ##
// ## FUNCTIONS ##
// ## ##
// ## ##
// #######################################################################
//=======================================================================
//function : xinit
//=======================================================================
static IFSelect_ReturnStatus XSControl_xinit(const Handle(IFSelect_SessionPilot)& pilot)
{
Standard_Integer argc = pilot->NbWords();
const Standard_CString arg1 = pilot->Arg(1);
// **** xinit ****
if (argc > 1) return (XSControl::Session(pilot)->SelectNorm(arg1) ?
IFSelect_RetDone : IFSelect_RetFail);
Handle(Message_Messenger) sout = Message::DefaultMessenger();
sout<<"Selected Norm:"<<XSControl::Session(pilot)->SelectedNorm()<<endl;
return IFSelect_RetVoid;
}
//=======================================================================
//function : xnorm
//=======================================================================
static IFSelect_ReturnStatus XSControl_xnorm(const Handle(IFSelect_SessionPilot)& pilot)
{
Standard_Integer argc = pilot->NbWords();
const Standard_CString arg1 = pilot->Arg(1);
// **** xnorm ****
Handle(XSControl_WorkSession) WS = XSControl::Session(pilot);
Handle(XSControl_Controller) control = WS->NormAdaptor();
Handle(Message_Messenger) sout = Message::DefaultMessenger();
if (argc == 1)
sout<<"Current Norm. xnorm newnorm [profile] to change , xnorm ? for the list"<<endl;
else sout<<"Current Norm :"<<endl;
if (control.IsNull()) sout<<"no norm currently defined"<<endl;
else
sout<<" Long Name (complete) : "<<control->Name(Standard_False)<<endl
<< " Short name (resource) : "<<control->Name(Standard_True)<<endl;
if (argc == 1) return IFSelect_RetVoid;
if (arg1[0] == '?') {
sout<<"List of available norms"<<endl;
Standard_Integer i,nb;
Handle(TColStd_HSequenceOfHAsciiString) norms = XSControl_Controller::ListRecorded(-1);
nb = norms->Length();
sout<<"Short Proper Names (complete names) : "<<nb<<" :";
for (i = 1; i <= nb; i ++) sout<<" "<<norms->Value(i)->ToCString();
sout<<endl;
norms = XSControl_Controller::ListRecorded(1);
nb = norms->Length();
sout<<"Long Proper Names (resource names) : "<<nb<<" :";
for (i = 1; i <= nb; i ++) sout<<" "<<norms->Value(i)->ToCString();
sout<<endl;
norms = XSControl_Controller::ListRecorded(0);
nb = norms->Length();
sout<<"All Norm Names (short, long and aliases) "<<nb<<" :";
for (i = 1; i <= nb; i ++) sout<<" "<<norms->Value(i)->ToCString();
sout<<endl;
sout<<"To change, xnorm newnorm"<<endl;
return IFSelect_RetVoid;
}
control = XSControl_Controller::Recorded(arg1);
if (control.IsNull()) { sout<<" No norm named : "<<arg1<<endl; return IFSelect_RetError; }
else {
WS->SetController(control);
sout<<"new norm : "<<control->Name()<<endl;
if (argc > 2) {
const Standard_CString arg2 = pilot->Arg(2);
if (!control->Profile()->SetCurrent (arg2))
sout<<"profile could not be set to "<<arg2<<endl;
}
sout<<"current profile : "<<control->Profile()->Current()<<endl;
IFSelect_Activator::SetCurrentAlias (WS->SelectedNorm(Standard_True));
return IFSelect_RetDone;
}
return IFSelect_RetVoid;
}
//=======================================================================
//function : xprofile
//=======================================================================
static IFSelect_ReturnStatus XSControl_xprofile(const Handle(IFSelect_SessionPilot)& pilot)
{
Standard_Integer argc = pilot->NbWords();
const Standard_CString arg1 = pilot->Arg(1);
// **** xprofile ****
Handle(XSControl_WorkSession) WS = XSControl::Session(pilot);
Handle(XSControl_Controller) control = WS->NormAdaptor();
if (control.IsNull()) return IFSelect_RetFail;
Handle(IFSelect_Profile) prof = control->Profile();
Handle(Message_Messenger) sout = Message::DefaultMessenger();
sout<<"Current Profile : "<<prof->Current().ToCString()<<endl;
if (argc < 2) {
sout<<"xprofile ? for list of profile confs"<<endl
<< "xprofile . to apply the current profile (after editing)"<<endl
<< "xprofile profname to select one and apply it"<<endl
<< "xprofile profname . to record current profile as profname"<<endl
<<" (in followings, profname may be replaced by . for current profile)"<<endl
<< "xprofile profname ? to list its definition"<<endl
<< "xprofile profname - to clear it completely"<<endl
<< "xprofile profname optname casename to edit an option of it"<<endl
<< "xprofile profname - optname to clear an option from it"<<endl;
return IFSelect_RetVoid;
}
if (argc == 2) {
if (arg1[0] == '?') {
Handle(TColStd_HSequenceOfAsciiString) confs = prof->ConfList();
Standard_Integer i, nb = confs->Length();
sout<<"List of Available Profile Configurations : "<<nb<<" Items"<<endl;
for (i = 1; i <= nb; i ++) sout<<confs->Value(i).ToCString()<<endl;
return IFSelect_RetVoid;
} else if (arg1[0] == '.' && arg1[1] == '\0') {
if (!control->ApplyProfile(WS,".")) {
sout<<"Applying current profile has failed"<<endl;
return IFSelect_RetFail;
}
return IFSelect_RetDone;
} else {
// Select a Profile
if (!control->ApplyProfile(WS,arg1)) {
sout<<"Setting "<<arg1<<" as current has failed"<<endl;
return IFSelect_RetFail;
}
sout<<"Setting "<<arg1<<" as current"<<endl;
return IFSelect_RetDone;
}
}
if (argc == 3) {
const Standard_CString arg2 = pilot->Arg(2);
// List the definition of a profile
if (arg2[0] == '?') {
Handle(TColStd_HSequenceOfAsciiString) opts, cases;
prof->SwitchList (arg1,opts,cases);
Standard_Integer i,nb = opts->Length();
sout<<"Option -- Case -- ("<<nb<<" switches on configuration "<<arg1<<")"<<endl;
for (i = 1; i <= nb; i ++) {
sout<<opts->Value(i).ToCString()<<" "<<cases->Value(i).ToCString()<<endl;
}
return IFSelect_RetVoid;
// Clear a profile
} else if (arg2[0] == '-' && arg2[1] == '\0') {
if (!prof->ClearConf(arg1)) {
sout<<"Clearing profile "<<arg2<<" has failed"<<endl;
return IFSelect_RetFail;
}
return IFSelect_RetDone;
// Merge Profile arg2 to arg1
} else {
if (!prof->HasConf (arg1)) prof->AddConf (arg1);
if (!prof->AddFromOtherConf (arg1,arg2)) {
sout<<"Merging profile "<<arg2<<" to "<<arg1<<" has failed"<<endl;
return IFSelect_RetFail;
}
return IFSelect_RetDone;
}
}
// Editing / Adding a switch in a profile
if (argc == 4) {
const Standard_CString arg2 = pilot->Arg(2);
const Standard_CString arg3 = pilot->Arg(3);
// Removing a switch
if (arg2[0] == '-' && arg2[1] == '\0') {
if (!prof->RemoveSwitch (arg1,arg3)) {
sout<<"Removing switch on option "<<arg3<<" in profile "<<arg1<<" has failed"<<endl;
return IFSelect_RetFail;
}
sout<<"Edition of profile "<<arg1<<" done. To apply it : xprofile "<<arg1<<endl;
return IFSelect_RetDone;
// Setting a switch
} else {
if (!prof->AddSwitch (arg1,arg2,arg3)) {
sout<<"Setting profile "<<arg1<<" for option "<<arg2<<" to case "<<arg3<<" has failed"<<endl;
return IFSelect_RetFail;
}
sout<<"Edition of profile "<<arg1<<" done. To apply it : xprofile "<<arg1<<endl;
return IFSelect_RetDone;
}
}
return IFSelect_RetVoid;
}
//=======================================================================
//function : xoption
//=======================================================================
static IFSelect_ReturnStatus XSControl_xoption(const Handle(IFSelect_SessionPilot)& pilot)
{
Standard_Integer argc = pilot->NbWords();
const Standard_CString arg1 = pilot->Arg(1);
const Standard_CString arg2 = pilot->Arg(2);
const Standard_CString arg3 = pilot->Arg(3);
// **** xoption ****
Handle(XSControl_WorkSession) WS = XSControl::Session(pilot);
Handle(XSControl_Controller) control = WS->NormAdaptor();
if (control.IsNull()) return IFSelect_RetFail;
Handle(IFSelect_Profile) prof = control->Profile();
Handle(Message_Messenger) sout = Message::DefaultMessenger();
sout<<"Current Profile : "<<prof->Current().ToCString()<<endl;
if (argc < 2) {
sout<<"xoption anopt : query an option"<<endl
<< "xoption anopt newcase : switch (basic definition)"
<<" (but is superseded by current configuration)"<<endl
<<"xoption + optname [param] : create an option on a parameter"<<endl
<<" (param absent is taken param=optname)"
<<"xoption anopt + casename [value] : add a case for a parameter"<<endl
<<" (value absent is taken value=casename)"<<endl;
Handle(TColStd_HSequenceOfAsciiString) optlist = prof->OptionList();
Standard_Integer iopt, nbopt = optlist->Length();
sout<<"Total : "<<nbopt<<" Options"<<endl;
for (iopt = 1; iopt <= nbopt; iopt ++) {
TCollection_AsciiString optname = optlist->Value(iopt);
Handle(IFSelect_Option) opt = prof->Option (optname.ToCString());
sout<<optname.ToCString()<<" : "<<opt->CaseName()<<endl;
}
return IFSelect_RetVoid;
}
// xoption optname : description
if (argc == 2) {
Handle(IFSelect_Option) opt = prof->Option (arg1);
if (opt.IsNull()) { sout<<"Not a recorded Option : "<<arg1<<endl; return IFSelect_RetError; }
// On va lister les valeurs admises
Handle(TColStd_HSequenceOfAsciiString) caselist = opt->ItemList();
Standard_Integer icase, nbcase = caselist->Length();
Handle(MoniTool_TypedValue) tv = opt->TypedValue();
if (tv.IsNull()) sout<<"Option : "<<arg1<<" Type : "<<opt->Type()->Name();
else sout<<"Option : "<<arg1<<" TypedValue. Name : "<<tv->Name()<<endl<<" Definition : "<<tv->Definition();
sout<<endl<<" Current Case (basic) : "<<opt->CaseName()<<" Total : "<<nbcase<<" Cases :"<<endl;
for (icase = 1; icase <= nbcase; icase ++) {
const TCollection_AsciiString& acase = caselist->Value(icase);
sout<<acase.ToCString();
// Aliases ?
Handle(TColStd_HSequenceOfAsciiString) aliases = opt->Aliases(acase.ToCString());
Standard_Integer ial, nbal = (aliases.IsNull() ? 0 : aliases->Length());
if (nbal > 0) sout<<" - Alias:";
for (ial = 1; ial <= nbal; ial ++) sout<<" "<<aliases->Value(ial);
if (!tv.IsNull()) {
// TypedValue : on peut afficher la valeur
Handle(TCollection_HAsciiString) str;
opt->Item (acase.ToCString(),str);
if (!str.IsNull()) sout<<" - Value:"<<str->ToCString();
}
sout<<endl;
}
return IFSelect_RetVoid;
}
// xoption + optname [paramname]
if (argc >= 3 && arg1[0] == '+' && arg1[1] == '\0') {
Standard_CString parname = pilot->Arg(argc-1);
Handle(Interface_Static) param = Interface_Static::Static(parname);
if (param.IsNull()) { sout<<"No static parameter is named "<<parname<<endl;
return IFSelect_RetError; }
Handle(IFSelect_Option) opt = new IFSelect_Option(param,arg2);
prof->AddOption (opt);
return IFSelect_RetDone;
}
// xoption optname + case [val]
if (argc >= 4 && arg2[0] == '+' && arg2[1] == '\0') {
Handle(IFSelect_Option) opt = prof->Option (arg1);
if (opt.IsNull()) { sout<<"Not a recorded Option : "<<arg1<<endl; return IFSelect_RetError; }
Handle(MoniTool_TypedValue) tv = opt->TypedValue();
if (tv.IsNull()) { sout<<"Option not for a Parameter : "<<arg1<<endl; return IFSelect_RetError; }
Standard_CString valname = pilot->Arg(argc-1);
if (!opt->AddBasic (arg3,valname)) {
sout<<"Option "<<arg1<<" : not an allowed value : "<<valname<<endl;
return IFSelect_RetError;
}
return IFSelect_RetDone;
}
// xoption optname newcase : edition
if (argc == 3) {
Handle(IFSelect_Option) opt = prof->Option (arg1);
if (opt.IsNull()) { sout<<"Not a recorded Option : "<<arg1<<endl; return IFSelect_RetError; }
if (!opt->Switch (arg2)) {
sout<<"Option : "<<arg1<<" , Not a suitable case : "<<arg2<<endl;
return IFSelect_RetFail;
}
sout<<"Option : "<<arg1<<" switched to case : "<<arg2<<endl;
return IFSelect_RetDone;
}
return IFSelect_RetVoid;
}
//=======================================================================
//function : newmodel
//=======================================================================
static IFSelect_ReturnStatus XSControl_newmodel(const Handle(IFSelect_SessionPilot)& pilot)
{
// **** newmodel ****
if (!XSControl::Session(pilot)->NewModel().IsNull()) return IFSelect_RetDone;
Handle(Message_Messenger) sout = Message::DefaultMessenger();
sout<<"No new Model produced"<<endl;
return IFSelect_RetFail;
}
//=======================================================================
//function : tpclear
//=======================================================================
static IFSelect_ReturnStatus XSControl_tpclear(const Handle(IFSelect_SessionPilot)& pilot)
{
// **** tpclear/twclear ****
Standard_Boolean modew = Standard_False;
if (pilot->Word(0).Value(2) == 'w') modew = Standard_True;
Handle(Transfer_FinderProcess) FP = XSControl::Session(pilot)->MapWriter();
Handle(Transfer_TransientProcess) TP = XSControl::Session(pilot)->MapReader();
Handle(Message_Messenger) sout = Message::DefaultMessenger();
if ( modew) { if(!FP.IsNull()) FP->Clear(); else sout<<"No Transfer Write"<<endl; }
else { if(!TP.IsNull()) TP->Clear(); else sout<<"No Transfer Read"<<endl; }
return IFSelect_RetDone;
}
//=======================================================================
//function : tpstat
//=======================================================================
static IFSelect_ReturnStatus XSControl_tpstat(const Handle(IFSelect_SessionPilot)& pilot)
{
Standard_Integer argc = pilot->NbWords();
const Standard_CString arg1 = pilot->Arg(1);
//const Standard_CString arg2 = pilot->Arg(2);
Handle(Transfer_TransientProcess) TP= XSControl::Session(pilot)->MapReader();
Handle(Message_Messenger) sout = Message::DefaultMessenger();
if (TP.IsNull()) { sout<<"No Transfer Read"<<endl; return IFSelect_RetError;}
// **** tpstat ****
Standard_Integer mod1 = -1;
Standard_Integer mod2 = 0;
// g : general c : check (compte) C (liste) f : fails(compte) F (liste)
// resultats racines : n : n0s entites s : status b : binders
// t : compte par type r : compte par resultat l : liste(type-resultat)
// *n *s *b *t *r *l : idem sur tout
// ?n etc.. : idem sur resultats anormaux
// ? tout court pour help
if (argc > 1) {
char a2 = arg1[1]; if (a2 == '\0') a2 = '!';
switch (arg1[0]) {
case 'g' : mod1 = 0; break;
case 'c' : mod1 = 4; mod2 = 4; break;
case 'C' : mod1 = 4; mod2 = 2; break;
case 'f' : mod1 = 5; mod2 = 4; break;
case 'F' : mod1 = 5; mod2 = 2; break;
case '*' : mod1 = 2; break;
case '?' : mod1 = 3; break;
default : mod1 = 1; if (argc > 2) mod1 = 2; a2 = arg1[0]; break;
}
if (mod1 < 1 || mod1 > 3) a2 = '!';
switch (a2) {
case 'n' : mod2 = 0; break;
case 's' : mod2 = 1; break;
case 'b' : mod2 = 2; break;
case 't' : mod2 = 3; break;
case 'r' : mod2 = 4; break;
case 'l' : mod2 = 5; break;
case 'L' : mod2 = 6; break;
case '!' : break;
case '?' : mod1 = -1; break;
default : mod1 = -2; break;
}
}
// A present help eventuel
if (mod1 < -1) sout<<"Unknown Mode"<<endl;
if (mod1 < 0) {
sout<<"Modes available :\n"
<<"g : general c : checks (count) C (list)"<<"\n"
<<" f : fails (count) F (list)"<<"\n"
<<" n : numbers of transferred entities (on TRANSFER ROOTS)"<<"\n"
<<" s : their status (type entity-result , presence checks)"<<"\n"
<<" b : detail of binders"<<"\n"
<<" t : count per entity type r : per type/status result"<<"\n"
<<" l : count per couple type entity/result"<<"\n"
<<" L : list per couple type entity/result"<<"\n"
<<" *n *s *b *t *r *l *L : idem on ALL recorded items"<<"\n"
<<" ?n ?s ?b ?t ... : idem on abnormal items"<<"\n"
<<" n select : n applied on a selection idem for s b t r l"<<endl;
if (mod1 < -1) return IFSelect_RetError;
return IFSelect_RetVoid;
}
if (!TP.IsNull()) {
sout<<"TransferRead :";
if (TP->Model() != pilot->Session()->Model()) sout<<"Model differs from the session";
Handle(TColStd_HSequenceOfTransient) list =
IFSelect_Functions::GiveList(pilot->Session(),pilot->CommandPart(2));
XSControl_TransferReader::PrintStatsOnList (TP,list,mod1,mod2);
// TP->PrintStats (1,sout);
}
else sout<<"TransferRead : not defined"<<endl;
return IFSelect_RetVoid;
}
//=======================================================================
//function : tpent
//=======================================================================
static IFSelect_ReturnStatus XSControl_tpent(const Handle(IFSelect_SessionPilot)& pilot)
{
Standard_Integer argc = pilot->NbWords();
const Standard_CString arg1 = pilot->Arg(1);
Handle(Transfer_TransientProcess) TP= XSControl::Session(pilot)->MapReader();
// **** tpent ****
Handle(Message_Messenger) sout = Message::DefaultMessenger();
if (TP.IsNull()) { sout<<"No Transfer Read"<<endl; return IFSelect_RetError;}
Handle(Interface_InterfaceModel) model = TP->Model();
if (model.IsNull()) return IFSelect_RetFail;
if (argc < 2) { sout<<"Give ENTITY NUMBER (IN MODEL TransferProcess)"<<endl; return IFSelect_RetError; }
Standard_Integer num = atoi(arg1);
if (num <= 0 || num > model->NbEntities()) { sout<<"Number not in [1 - "<<model->NbEntities()<<"]"<<endl; return IFSelect_RetError; }
Handle(Standard_Transient) ent = model->Value(num);
Standard_Integer index = TP->MapIndex (ent);
if (index == 0) sout<<"Entity "<<num<<" not recorded in transfer"<<endl;
else XSControl::Session(pilot)->PrintTransferStatus (index,Standard_False,sout);
return IFSelect_RetVoid;
}
//=======================================================================
//function : tpitem
//=======================================================================
static IFSelect_ReturnStatus XSControl_tpitem(const Handle(IFSelect_SessionPilot)& pilot)
{
Standard_Integer argc = pilot->NbWords();
const Standard_CString arg1 = pilot->Arg(1);
// **** tpitem/tproot/twitem/twroot ****
Handle(Message_Messenger) sout = Message::DefaultMessenger();
if (argc < 2) { sout<<"Give ITEM NUMBER (in TransferProcess)"<<endl; return IFSelect_RetError; }
Standard_Integer num = atoi(arg1);
if (pilot->Word(0).Value(3) == 'r') num = -num;
Standard_Boolean modew = Standard_False;
if (pilot->Word(0).Value(2) == 'w') modew = Standard_True;
Handle(Transfer_Binder) binder;
Handle(Transfer_Finder) finder;
Handle(Standard_Transient) ent;
if (!XSControl::Session(pilot)->PrintTransferStatus(num,modew,sout))
sout<<" - Num="<<num<<" incorrect"<<endl;
return IFSelect_RetVoid;
}
//=======================================================================
//function : tpatr
//=======================================================================
static IFSelect_ReturnStatus XSControl_tpatr(const Handle(IFSelect_SessionPilot)& /*pilot*/)
{
/*skl
Standard_Integer argc = pilot->NbWords();
const Standard_CString arg1 = pilot->Arg(1);
Handle(XSControl_WorkSession) WS = XSControl::Session(pilot);
Handle(Transfer_TransientProcess) TP = WS->MapReader();
Handle(Message_Messenger) sout = Message::DefaultMessenger();
// tpatr tout court : liste tous les attributs
// tpatr nomatr : sur cet attribut, liste les valeurs par entite
if (argc < 2) {
Handle(Dico_DictionaryOfInteger) list = TP->Attributes();
for (Dico_IteratorOfDictionaryOfInteger iter(list); iter.More(); iter.Next()) {
TCollection_AsciiString name = iter.Name();
Standard_Integer nbatr = iter.Value();
Interface_ParamType aty = TP->AttributeType (name.ToCString());
sout<<"Name : "<<name<<" Count="<<nbatr<<" Type : ";
switch (aty) {
case Interface_ParamInteger : sout<<"Integer"; break;
case Interface_ParamReal : sout<<"Real"; break;
case Interface_ParamIdent : sout<<"Object"; break;
case Interface_ParamText : sout<<"String"; break;
default : sout<<"(Mixed)";
}
sout<<endl;
}
}
else {
Standard_Integer num , nb = 0;
sout<<"Attribute Name : "<<arg1<<endl;
for (num = TP->NextItemWithAttribute(arg1,0); num > 0;
num = TP->NextItemWithAttribute(arg1,num)) {
nb ++;
sout<<"Item "<<num<<" , Entity ";
WS->Model()->Print(TP->Mapped(num),sout);
Handle(Transfer_Binder) bnd = TP->MapItem (num);
Interface_ParamType aty = bnd->AttributeType(arg1);
switch (aty) {
case Interface_ParamInteger : sout<<" Integer="<<bnd->IntegerAttribute(arg1); break;
case Interface_ParamReal : sout<<" Real="<<bnd->RealAttribute(arg1); break;
case Interface_ParamIdent : sout<<" Object,Type:"<<bnd->Attribute(arg1)->DynamicType()->Name(); break;
case Interface_ParamText : sout<<" String="<<bnd->StringAttribute(arg1);
default : sout<<"(none)"; break;
}
sout<<endl;
}
sout<<"Attribute Name : "<<arg1<<" on "<<nb<<" Items"<<endl;
}
skl*/
return IFSelect_RetVoid;
}
//=======================================================================
//function : trecord
//=======================================================================
static IFSelect_ReturnStatus XSControl_trecord(const Handle(IFSelect_SessionPilot)& pilot)
{
Standard_Integer argc = pilot->NbWords();
const Standard_CString arg1 = pilot->Arg(1);
Handle(Transfer_TransientProcess) TP = XSControl::Session(pilot)->MapReader();
// **** trecord : TransferReader ****
Standard_Boolean tous = (argc == 1);
Standard_Integer num = -1;
Handle(Interface_InterfaceModel) mdl = XSControl::Session(pilot)->Model();
Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
Handle(Standard_Transient) ent;
Handle(Message_Messenger) sout = Message::DefaultMessenger();
if (mdl.IsNull() || TR.IsNull() || TP.IsNull())
{ sout<<" init not done"<<endl; return IFSelect_RetError; }
if (!tous) num = atoi(arg1);
// Enregistrer les racines
if (tous) {
Standard_Integer nb = TP->NbRoots();
sout<<" Recording "<<nb<<" Roots"<<endl;
for (Standard_Integer i = 1; i <= nb; i ++) {
ent = TP->Root(i);
if (TR->RecordResult (ent)) sout<<" Root n0."<<i<<endl;
else sout<<" Root n0."<<i<<" not recorded"<<endl;
}
} else {
if (num < 1 || num > mdl->NbEntities()) sout<<"incorrect number:"<<num<<endl;
else if (TR->RecordResult(mdl->Value(num))) sout<<" Entity n0."<<num<<endl;
else sout<<" Entity n0."<<num<<" not recorded"<<endl;
}
return IFSelect_RetDone;
}
//=======================================================================
//function : trstat
//=======================================================================
static IFSelect_ReturnStatus XSControl_trstat(const Handle(IFSelect_SessionPilot)& pilot)
{
Standard_Integer argc = pilot->NbWords();
const Standard_CString arg1 = pilot->Arg(1);
Handle(Message_Messenger) sout = Message::DefaultMessenger();
// **** trstat : TransferReader ****
Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
if (TR.IsNull()) { sout<<" init not done"<<endl; return IFSelect_RetError; }
Handle(Interface_InterfaceModel) mdl = TR->Model();
if (mdl.IsNull()) { sout<<" No model"<<endl; return IFSelect_RetError; }
sout<<" Statistics : FileName : "<<TR->FileName()<<endl;
if (argc == 1) {
// stats generales
TR->PrintStats(10,0);
} else {
// stats unitaires
Standard_Integer num = atoi(arg1);
if (num < 1 || num > mdl->NbEntities()) { sout<<" incorrect number:"<<arg1<<endl; return IFSelect_RetError; }
Handle(Standard_Transient) ent = mdl->Value(num);
if (!TR->IsRecorded(ent)) { sout<<" Entity "<<num<<" not recorded"<<endl; return IFSelect_RetError; }
Handle(Transfer_ResultFromModel) RM = TR->FinalResult(ent);
Handle(TColStd_HSequenceOfTransient) list = TR->CheckedList(ent);
Standard_Integer i, nb = list->Length();
if (nb > 0) sout<<" Entities implied by Check/Result :"<<nb<<" i.e.:";
for (i = 1; i <= nb; i ++) { sout<<" "; mdl->Print(list->Value(i),sout); }
sout<<endl;
if (RM.IsNull()) { sout<<" no other info"<<endl; return IFSelect_RetVoid; }
Interface_CheckIterator chl = RM->CheckList(Standard_False);
pilot->Session()->PrintCheckList(chl,Standard_False,IFSelect_EntitiesByItem);
}
return IFSelect_RetVoid;
}
//=======================================================================
//function : trbegin
//=======================================================================
static IFSelect_ReturnStatus XSControl_trbegin(const Handle(IFSelect_SessionPilot)& pilot)
{
// **** trbegin : TransferReader ****
Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
Standard_Boolean init = TR.IsNull();
if (pilot->NbWords() > 1) { if (pilot->Arg(1)[0] == 'i') init = Standard_True; }
if (init) {
XSControl::Session(pilot)->InitTransferReader (0);
TR = XSControl::Session(pilot)->TransferReader();
if (TR.IsNull()) {
Handle(Message_Messenger) sout = Message::DefaultMessenger();
sout<<" init not done or failed"<<endl;
return IFSelect_RetError;
}
}
TR->BeginTransfer();
return IFSelect_RetDone;
}
//=======================================================================
//function : tread
//=======================================================================
static IFSelect_ReturnStatus XSControl_tread(const Handle(IFSelect_SessionPilot)& pilot)
{
Standard_Integer argc = pilot->NbWords();
//const Standard_CString arg1 = pilot->Arg(1);
// **** tread : TransferReader ****
Handle(Message_Messenger) sout = Message::DefaultMessenger();
Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
if (TR.IsNull()) { sout<<" init not done"<<endl; return IFSelect_RetError; }
Handle(Interface_InterfaceModel) mdl = TR->Model();
if (mdl.IsNull()) { sout<<" No model"<<endl; return IFSelect_RetError; }
if (argc < 2) {
// DeclareAndCast(IFSelect_Selection,sel,pilot->Session()->NamedItem("xst-model-roots"));
Handle(Standard_Transient) sel = pilot->Session()->NamedItem("xst-model-roots");
if (sel.IsNull()) { sout<<"Select Roots absent"<<endl; return IFSelect_RetError; }
Handle(TColStd_HSequenceOfTransient) list = pilot->Session()->GiveList(sel);
sout<<" Transferring all roots i.e. : "<<TR->TransferList(list)<<endl;
} else {
Handle(TColStd_HSequenceOfTransient) list =
IFSelect_Functions::GiveList(pilot->Session(),pilot->CommandPart(1));
sout<<" Transfer of "<<list->Length()<<" entities"<<endl;
Standard_Integer nb = TR->TransferList(list);
sout<<" Gives "<<nb<<" results"<<endl;
}
return IFSelect_RetDone;
}
//=======================================================================
//function : trtp
//=======================================================================
static IFSelect_ReturnStatus XSControl_trtp(const Handle(IFSelect_SessionPilot)& pilot)
{
// **** TReader -> TProcess ****
Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
Handle(Message_Messenger) sout = Message::DefaultMessenger();
if (TR.IsNull()) sout<<" No TransferReader"<<endl;
else if (TR->TransientProcess().IsNull()) sout<<" Transfer Reader without Process"<<endl;
////else { XSDRAW::SetTransferProcess(TR->TransientProcess()); return IFSelect_RetDone; }
return IFSelect_RetVoid;
}
//=======================================================================
//function : tptr
//=======================================================================
static IFSelect_ReturnStatus XSControl_tptr(const Handle(IFSelect_SessionPilot)& pilot)
{
// **** TProcess -> TReader ****
XSControl::Session(pilot)->InitTransferReader (3);
return IFSelect_RetDone;
}
//=======================================================================
//function : twmode
//=======================================================================
static IFSelect_ReturnStatus XSControl_twmode(const Handle(IFSelect_SessionPilot)& pilot)
{
Standard_Integer argc = pilot->NbWords();
const Standard_CString arg1 = pilot->Arg(1);
// **** twmode ****
Handle(XSControl_TransferWriter) TW = XSControl::Session(pilot)->TransferWriter();
Handle(XSControl_Controller) control = XSControl::Session(pilot)->NormAdaptor();
Standard_Integer modemin,modemax;
Handle(Message_Messenger) sout = Message::DefaultMessenger();
if (control->ModeWriteBounds (modemin,modemax)) {
sout<<"Write Mode : allowed values "<<modemin<<" to "<<modemax<<endl;
for (Standard_Integer modd = modemin; modd <= modemax; modd ++) {
sout<<modd<<" : "<<control->ModeWriteHelp (modd)<<endl;;
}
}
sout<<"Write Mode : actual = "<<TW->TransferMode()<<endl;
if (argc <= 1) return IFSelect_RetVoid;
Standard_Integer mod = atoi(arg1);
sout<<"New value -> "<<arg1<<endl;
TW->SetTransferMode(mod);
if (!control->IsModeWrite (mod)) sout<<"Warning : this new value is not supported"<<endl;
return IFSelect_RetDone;
}
//=======================================================================
//function : twstat
//=======================================================================
static IFSelect_ReturnStatus XSControl_twstat(const Handle(IFSelect_SessionPilot)& pilot)
{
//Standard_Integer argc = pilot->NbWords();
//const Standard_CString arg1 = pilot->Arg(1);
//const Standard_CString arg2 = pilot->Arg(2);
Handle(Transfer_FinderProcess) FP = XSControl::Session(pilot)->MapWriter();
// **** twstat ****
// Pour Write
Handle(Message_Messenger) sout = Message::DefaultMessenger();
if (!FP.IsNull()) {
sout<<"TransferWrite:";
// XSControl_TransferWriter::PrintStatsProcess (FP,mod1,mod2);
FP->PrintStats (1,sout);
}
else sout<<"TransferWrite: not defined"<<endl;
return IFSelect_RetVoid;
}
//=======================================================================
//function : settransfert
//=======================================================================
static IFSelect_ReturnStatus XSControl_settransfert(const Handle(IFSelect_SessionPilot)& pilot)
{
// **** SelectForTransfer ****
return pilot->RecordItem(new XSControl_SelectForTransfer(XSControl::Session(pilot)->TransferReader()));
}
static int initactor = 0;
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void XSControl_Functions::Init ()
{
if (initactor) return; initactor = 1;
IFSelect_Act::SetGroup("DE: General");
IFSelect_Act::AddFunc ("xinit","[norm:string to change norme] reinitialises according to the norm",XSControl_xinit);
IFSelect_Act::AddFunc ("xnorm","displays current norm +norm : changes it",XSControl_xnorm);
IFSelect_Act::AddFunc ("xprofile","displays current profile +prof : changes it",XSControl_xprofile);
IFSelect_Act::AddFunc ("xoption","lists options +opt : lists cases +case : changes current case",XSControl_xoption);
IFSelect_Act::AddFunc ("newmodel","produces a new empty model, for the session",XSControl_newmodel);
IFSelect_Act::AddFunc ("tpclear","Clears TransferProcess (READ)",XSControl_tpclear);
IFSelect_Act::AddFunc ("twclear","Clears TransferProcess (WRITE)",XSControl_tpclear);
IFSelect_Act::AddFunc ("tpstat","Statistics on TransferProcess (READ)",XSControl_tpstat);
IFSelect_Act::AddFunc ("tpent","[num:integer] Statistics on an entity of the model (READ)",XSControl_tpent);
IFSelect_Act::AddFunc ("tpitem","[num:integer] Statistics on ITEM of transfer (READ)" ,XSControl_tpitem);
IFSelect_Act::AddFunc ("tproot","[num:integer] Statistics on a ROOT of transfert (READ)" ,XSControl_tpitem);
IFSelect_Act::AddFunc ("twitem","[num:integer] Statistics on an ITEM of transfer (WRITE)" ,XSControl_tpitem);
IFSelect_Act::AddFunc ("twroot","[num:integer] Statistics on a ROOT of transfer (WRITE)",XSControl_tpitem);
IFSelect_Act::AddFunc ("tpatr","[name] List all Attributes, or values for a Name",XSControl_tpatr);
IFSelect_Act::AddFunc ("trecord","record : all root results; or num : for entity n0.num",XSControl_trecord);
IFSelect_Act::AddFunc ("trstat","general statistics; or num : stats on entity n0 num",XSControl_trstat);
IFSelect_Act::AddFunc ("trbegin","begin-transfer-reader [init]",XSControl_trbegin);
IFSelect_Act::AddFunc ("tread","transfers all roots, or num|sel|sel num : entity list, by transfer-reader",XSControl_tread);
IFSelect_Act::AddFunc ("trtp","feeds commands tp... with results from tr...",XSControl_trtp);
IFSelect_Act::AddFunc ("tptr","feeds tr... from tp... (may be incomplete)",XSControl_tptr);
IFSelect_Act::AddFunc ("twmode","displays mode transfer write, + num changes it",XSControl_twmode);
IFSelect_Act::AddFunc ("twstat","Statistics on TransferProcess (WRITE)",XSControl_twstat);
IFSelect_Act::AddFSet ("selecttransfer","selection (recognize from transfer actor)",XSControl_settransfert);
}

View File

@@ -0,0 +1,242 @@
-- File: XSControl_Reader.cdl
-- Created: Wed May 14 14:32:43 1997
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class Reader from XSControl
---Purpose :
-- A groundwork to convert a shape to data which complies
-- with a particular norm. This data can be that of a whole
-- model or that of a specific list of entities in the model.
-- You specify the list using a single selection or a
-- combination of selections. A selection is an operator which
-- computes a list of entities from a list given in input. To
-- specify the input, you can use:
-- - A predefined selection such as "xst-transferrable-roots"
-- - A filter based on a signature.
-- A signature is an operator which returns a string from an
-- entity according to its type.
-- For example:
-- - "xst-type" (CDL)
-- - "iges-level"
-- - "step-type".
-- A filter can be based on a signature by giving a value to
-- be matched by the string returned. For example,
-- "xst-type(Curve)".
-- If no list is specified, the selection computes its list of
-- entities from the whole model. To use this class, you have to
-- initialize the transfer norm first, as shown in the example below.
-- Example:
-- Control_Reader reader;
-- IFSelect_ReturnStatus status = reader.ReadFile (filename.);
-- When using IGESControl_Reader or STEPControl_Reader - as the
-- above example shows - the reader initializes the norm directly.
-- Note that loading the file only stores the data. It does
-- not translate this data. Shapes are accumulated by
-- successive transfers. The last shape is cleared by:
-- - ClearShapes which allows you to handle a new batch
-- - TransferRoots which restarts the list of shapes from scratch.
uses CString, OStream, Transient,
SequenceOfTransient from TColStd, HSequenceOfTransient from TColStd,
InterfaceModel from Interface, WorkSession from XSControl,
ReturnStatus from IFSelect, PrintCount from IFSelect,
Shape from TopoDS, SequenceOfShape from TopTools
is
Create returns Reader;
---Purpose : Creates a Reader from scratch (creates an empty WorkSession)
-- A WorkSession or a Controller must be provided before running
Create (norm : CString) returns Reader;
---Purpose : Creates a Reader from scratch, with a norm name which
-- identifies a Controller
Create (WS : mutable WorkSession from XSControl;
scratch : Boolean = Standard_True) returns Reader;
---Purpose : Creates a Reader from an already existing Session, with a
-- Controller already set
---Purpose: Virtual destructor
---C++ : alias "Standard_EXPORT virtual ~XSControl_Reader() {}"
SetNorm (me : in out; norm : CString) returns Boolean;
---Purpose : Sets a specific norm to <me>
-- Returns True if done, False if <norm> is not available
SetWS (me : in out; WS : mutable WorkSession from XSControl;
scratch : Boolean = Standard_True);
---Purpose : Sets a specific session to <me>
WS (me) returns WorkSession from XSControl;
---Purpose : Returns the session used in <me>
ReadFile (me : in out; filename : CString) returns ReturnStatus;
---Purpose : Loads a file and returns the read status
-- Zero for a Model which compies with the Controller
Model (me) returns InterfaceModel;
---Purpose : Returns the model. It can then be consulted (header, product)
GiveList (me : in out; first, second : CString = "")
returns HSequenceOfTransient from TColStd;
---Purpose : Returns a list of entities from the IGES or STEP file
-- according to the following rules:
-- - if first and second are empty strings, the whole file is selected.
-- - if first is an entity number or label, the entity referred to is selected.
-- - if first is a list of entity numbers/labels separated by commas, the entities referred to are selected,
-- - if first is the name of a selection in the worksession and second is not defined,
-- the list contains the standard output for that selection.
-- - if first is the name of a selection and second is defined, the criterion defined
-- by second is applied to the result of the first selection.
-- A selection is an operator which computes a list of entities from a list given in
-- input according to its type. If no list is specified, the selection computes its
-- list of entities from the whole model.
-- A selection can be:
-- - A predefined selection (xst-transferrable-mode)
-- - A filter based on a signature
-- A Signature is an operator which returns a string from an entity according to its type. For example:
-- - "xst-type" (CDL)
-- - "iges-level"
-- - "step-type".
-- For example, if you wanted to select only the advanced_faces in a STEP file you
-- would use the following code:
-- Example
-- Reader.GiveList("xst-transferrable-roots","step-type(ADVANCED_FACE)");
-- Warning
-- If the value given to second is incorrect, it will simply be ignored.
GiveList (me : in out; first : CString; ent : Transient)
returns HSequenceOfTransient from TColStd;
---Purpose : Computes a List of entities from the model as follows
-- <first> beeing a Selection, <ent> beeing an entity or a list
-- of entities (as a HSequenceOfTransient) :
-- the standard result of this selection applied to this list
-- if <first> is erroneous, a null handle is returned
NbRootsForTransfer (me : in out) returns Integer is virtual ;
---Purpose : Determines the list of root entities which are candidate for
-- a transfer to a Shape, and returns the number
-- of entities in the list
RootForTransfer (me : in out; num : Integer = 1) returns Transient;
---Purpose : Returns an IGES or STEP root
-- entity for translation. The entity is identified by its
-- rank in a list.
TransferOneRoot (me : in out; num : Integer = 1) returns Boolean ;
---Purpose : Translates a root identified by the rank num in the model.
-- false is returned if no shape is produced.
TransferOne (me : in out; num : Integer) returns Boolean;
---Purpose : Translates an IGES or STEP
-- entity identified by the rank num in the model.
-- false is returned if no shape is produced.
TransferEntity (me : in out; start : Transient) returns Boolean;
---Purpose : Translates an IGES or STEP
-- entity in the model. true is returned if a shape is
-- produced; otherwise, false is returned.
TransferList (me : in out; list : HSequenceOfTransient from TColStd)
returns Integer;
---Purpose : Translates a list of entities.
-- Returns the number of IGES or STEP entities that were
-- successfully translated. The list can be produced with GiveList.
-- Warning - This function does not clear the existing output shapes.
TransferRoots (me : in out) returns Integer;
---Purpose : Translates all translatable
-- roots and returns the number of successful translations.
-- Warning - This function clears existing output shapes first.
ClearShapes (me : in out);
---Purpose : Clears the list of shapes that
-- may have accumulated in calls to TransferOne or TransferRoot.C
NbShapes (me) returns Integer;
---Purpose : Returns the number of shapes produced by translation.
Shapes (me: in out) returns SequenceOfShape from TopTools is protected;
---Purpose : Returns a sequence of produced shapes
---C++: return &
Shape (me; num : Integer = 1) returns Shape from TopoDS;
---Purpose : Returns the shape resulting
-- from a translation and identified by the rank num.
-- num equals 1 by default. In other words, the first shape
-- resulting from the translation is returned.
OneShape (me) returns Shape from TopoDS;
---Purpose : Returns all of the results in
-- a single shape which is:
-- - a null shape if there are no results,
-- - a shape if there is one result,
-- - a compound containing the resulting shapes if there are more than one.
PrintCheckLoad (me; failsonly : Boolean; mode : PrintCount);
---Purpose : Prints the check list attached to loaded data, on the Standard
-- Trace File (starts at cout)
-- All messages or fails only, according to <failsonly>
-- mode = 0 : per entity, prints messages
-- mode = 1 : per message, just gives count of entities per check
-- mode = 2 : also gives entity numbers
PrintCheckTransfer (me; failsonly : Boolean; mode : PrintCount);
---Purpose : Displays check results for the
-- last translation of IGES or STEP entities to Open CASCADE
-- entities. Only fail messages are displayed if failsonly is
-- true. All messages are displayed if failsonly is
-- false. mode determines the contents and the order of the
-- messages according to the terms of the IFSelect_PrintCount enumeration.
PrintStatsTransfer (me; what : Integer; mode : Integer = 0);
---Purpose : Displays the statistics for
-- the last translation. what defines the kind of
-- statistics that are displayed as follows:
-- - 0 gives general statistics (number of translated roots,
-- number of warnings, number of fail messages),
-- - 1 gives root results,
-- - 2 gives statistics for all checked entities,
-- - 3 gives the list of translated entities,
-- - 4 gives warning and fail messages,
-- - 5 gives fail messages only.
-- The use of mode depends on the value of what. If what is 0,
-- mode is ignored. If what is 1, 2 or 3, mode defines the following:
-- - 0 lists the numbers of IGES or STEP entities in the respective model
-- - 1 gives the number, identifier, type and result
-- type for each IGES or STEP entity and/or its status
-- (fail, warning, etc.)
-- - 2 gives maximum information for each IGES or STEP entity (i.e. checks)
-- - 3 gives the number of entities per type of IGES or STEP entity
-- - 4 gives the number of IGES or STEP entities per result type and/or status
-- - 5 gives the number of pairs (IGES or STEP or result type and status)
-- - 6 gives the number of pairs (IGES or STEP or result type
-- and status) AND the list of entity numbers in the IGES or STEP model.
-- If what is 4 or 5, mode defines the warning and fail
-- messages as follows:
-- - if mode is 0 all warnings and checks per entity are returned
-- - if mode is 2 the list of entities per warning is returned.
-- If mode is not set, only the list of all entities per warning is given.
GetStatsTransfer (me; list: HSequenceOfTransient from TColStd;
nbMapped : out Integer;
nbWithResult: out Integer;
nbWithFail : out Integer);
---Purpose: Gives statistics about Transfer
fields
thesession : WorkSession from XSControl;
therootsta : Boolean is protected; -- are roots determined
theroots : SequenceOfTransient is protected; -- only roots available for Transfer
theshapes : SequenceOfShape;
end Reader;

View File

@@ -0,0 +1,428 @@
// pdn 26.02.99 added initializing of compound in function OneShape
//: gka 14.04.99: S4136: apply scaling
#include <XSControl_Reader.ixx>
#include <XSControl_Controller.hxx>
#include <XSControl_TransferReader.hxx>
#include <Interface_ShareFlags.hxx>
#include <IFSelect_Functions.hxx>
#include <ShapeExtend_Explorer.hxx>
#include <TopoDS_Compound.hxx>
#include <BRep_Builder.hxx>
#include <Transfer_IteratorOfProcessForTransient.hxx>
#include <Transfer_TransientProcess.hxx>
#include <Transfer_Binder.hxx>
//#include <ShapeCustom.hxx>
#include <Interface_Static.hxx>
#include <Interface_Check.hxx>
#include <Message_ProgressSentry.hxx>
//#include <ShapeAlgo.hxx>
//#include <ShapeAlgo_AlgoContainer.hxx>
//=======================================================================
//function : XSControl_Reader
//purpose :
//=======================================================================
XSControl_Reader::XSControl_Reader ()
{
SetWS (new XSControl_WorkSession);
}
//=======================================================================
//function : XSControl_Reader
//purpose :
//=======================================================================
XSControl_Reader::XSControl_Reader (const Standard_CString norm)
{
SetNorm (norm);
}
//=======================================================================
//function : XSControl_Reader
//purpose :
//=======================================================================
XSControl_Reader::XSControl_Reader(const Handle(XSControl_WorkSession)& WS,
const Standard_Boolean scratch)
{
SetWS (WS,scratch);
}
//=======================================================================
//function : SetNorm
//purpose :
//=======================================================================
Standard_Boolean XSControl_Reader::SetNorm (const Standard_CString norm)
{
if (thesession.IsNull()) SetWS (new XSControl_WorkSession);
Standard_Boolean stat = thesession->SelectNorm (norm);
if (stat) {
thesession->InitTransferReader(0);
thesession->InitTransferReader(4);
}
return stat;
}
//=======================================================================
//function : SetWS
//purpose :
//=======================================================================
void XSControl_Reader::SetWS(const Handle(XSControl_WorkSession)& WS,
const Standard_Boolean scratch)
{
therootsta = Standard_False;
theroots.Clear();
thesession = WS;
// Il doit y avoir un Controller ... Sinon onverra plus tard (apres SetNorm)
if (thesession->NormAdaptor().IsNull()) return;
Handle(Interface_InterfaceModel) model = thesession->Model ();
if (scratch || model.IsNull()) model = thesession->NewModel ();
thesession->InitTransferReader(0);
thesession->InitTransferReader(4);
}
//=======================================================================
//function : WS
//purpose :
//=======================================================================
Handle(XSControl_WorkSession) XSControl_Reader::WS () const
{
return thesession;
}
//=======================================================================
//function : ReadFile
//purpose :
//=======================================================================
IFSelect_ReturnStatus XSControl_Reader::ReadFile
(const Standard_CString filename)
{
IFSelect_ReturnStatus stat = thesession->ReadFile(filename);
thesession->InitTransferReader(4);
return stat;
}
Handle(Interface_InterfaceModel) XSControl_Reader::Model () const
{
return thesession->Model();
}
//=======================================================================
//function : GiveList
//purpose :
//=======================================================================
Handle(TColStd_HSequenceOfTransient) XSControl_Reader::GiveList
(const Standard_CString first, const Standard_CString second)
{
if (first && first[0] != '\0') {
return thesession->GiveList (first,second);
}
Handle(TColStd_HSequenceOfTransient) list = new TColStd_HSequenceOfTransient();
Standard_Integer i,nbr = NbRootsForTransfer();
for (i = 1; i <= nbr; i ++) list->Append (RootForTransfer(i));
return list;
}
//=======================================================================
//function : GiveList
//purpose :
//=======================================================================
Handle(TColStd_HSequenceOfTransient) XSControl_Reader::GiveList
(const Standard_CString first, const Handle(Standard_Transient)& list)
{
return thesession->GiveListFromList (first,list);
}
//=======================================================================
//function : NbRootsForTransfer
//purpose :
//=======================================================================
Standard_Integer XSControl_Reader::NbRootsForTransfer ()
{
if (therootsta) return theroots.Length();
therootsta = Standard_True;
Interface_ShareFlags sf (thesession->Graph());
Standard_Integer i, nbr = sf.NbRoots();
for (i = 1; i <= nbr; i ++) {
// on filtre les racines qu on sait transferer
Handle(Standard_Transient) start = sf.Root(i);
if (thesession->TransferReader()->Recognize(start)) theroots.Append(start);
}
return theroots.Length();
}
//=======================================================================
//function : RootForTransfer
//purpose :
//=======================================================================
Handle(Standard_Transient) XSControl_Reader::RootForTransfer
(const Standard_Integer num)
{
Handle(Standard_Transient) voidroot;
Standard_Integer nbr = NbRootsForTransfer();
if (num < 1 || num > nbr) return voidroot;
return theroots.Value(num);
}
// #### TRANSFERT ####
//=======================================================================
//function : TransferOneRoot
//purpose :
//=======================================================================
Standard_Boolean XSControl_Reader::TransferOneRoot(const Standard_Integer num)
{
return TransferEntity (RootForTransfer (num));
}
//=======================================================================
//function : TransferOne
//purpose :
//=======================================================================
Standard_Boolean XSControl_Reader::TransferOne(const Standard_Integer num)
{
return TransferEntity (thesession->StartingEntity (num));
}
//=======================================================================
//function : TransferEntity
//purpose :
//=======================================================================
Standard_Boolean XSControl_Reader::TransferEntity
(const Handle(Standard_Transient)& start)
{
if (start.IsNull()) return Standard_False;
Handle(XSControl_TransferReader) TR = thesession->TransferReader();
TR->BeginTransfer();
if (TR->TransferOne (start) == 0) return Standard_False;
TopoDS_Shape sh = TR->ShapeResult(start);
//ShapeExtend_Explorer STU;
//SMH May 00: allow empty shapes (STEP CAX-IF, external references)
//if (STU.ShapeType(sh,Standard_True) == TopAbs_SHAPE) return Standard_False; // nulle-vide
theshapes.Append(sh);
return Standard_True;
}
//=======================================================================
//function : TransferList
//purpose :
//=======================================================================
Standard_Integer XSControl_Reader::TransferList
(const Handle(TColStd_HSequenceOfTransient)& list)
{
if (list.IsNull()) return 0;
Standard_Integer nbt = 0;
Standard_Integer i, nb = list->Length();
Handle(XSControl_TransferReader) TR = thesession->TransferReader();
TR->BeginTransfer();
ClearShapes();
ShapeExtend_Explorer STU;
for (i = 1; i <= nb; i ++) {
Handle(Standard_Transient) start = list->Value(i);
if (TR->TransferOne (start) == 0) continue;
TopoDS_Shape sh = TR->ShapeResult(start);
if (STU.ShapeType(sh,Standard_True) == TopAbs_SHAPE) continue; // nulle-vide
theshapes.Append(sh);
nbt ++;
}
return nbt;
}
//=======================================================================
//function : TransferRoots
//purpose :
//=======================================================================
Standard_Integer XSControl_Reader::TransferRoots ()
{
NbRootsForTransfer();
Standard_Integer nbt = 0;
Standard_Integer i, nb = theroots.Length();
Handle(XSControl_TransferReader) TR = thesession->TransferReader();
TR->BeginTransfer();
ClearShapes();
ShapeExtend_Explorer STU;
Handle(Transfer_TransientProcess) proc = thesession->MapReader();
Message_ProgressSentry PS ( proc->GetProgress(), "Root", 0, nb, 1 );
for (i = 1; i <= nb && PS.More(); i ++,PS.Next()) {
Handle(Standard_Transient) start = theroots.Value(i);
if (TR->TransferOne (start) == 0) continue;
TopoDS_Shape sh = TR->ShapeResult(start);
if (STU.ShapeType(sh,Standard_True) == TopAbs_SHAPE) continue; // nulle-vide
theshapes.Append(sh);
nbt ++;
}
return nbt;
}
//=======================================================================
//function : ClearShapes
//purpose :
//=======================================================================
void XSControl_Reader::ClearShapes ()
{
theshapes.Clear();
}
//=======================================================================
//function : NbShapes
//purpose :
//=======================================================================
Standard_Integer XSControl_Reader::NbShapes () const
{
return theshapes.Length();
}
//=======================================================================
//function : Shapes
//purpose :
//=======================================================================
TopTools_SequenceOfShape& XSControl_Reader::Shapes()
{
return theshapes;
}
//=======================================================================
//function : Shape
//purpose :
//=======================================================================
TopoDS_Shape XSControl_Reader::Shape (const Standard_Integer num) const
{
return theshapes.Value(num);
}
//=======================================================================
//function : OneShape
//purpose :
//=======================================================================
TopoDS_Shape XSControl_Reader::OneShape () const
{
TopoDS_Shape sh;
Standard_Integer i,nb = theshapes.Length();
if (nb == 0) return sh;
if (nb == 1) return theshapes.Value(1);
TopoDS_Compound C;
BRep_Builder B;
//pdn 26.02.99 testing S4133
B.MakeCompound(C);
for (i = 1; i <= nb; i ++) B.Add (C,theshapes.Value(i));
return C;
}
//=======================================================================
//function : PrintCheckLoad
//purpose :
//=======================================================================
void XSControl_Reader::PrintCheckLoad (const Standard_Boolean failsonly,
const IFSelect_PrintCount mode) const
{
thesession->PrintCheckList (thesession->ModelCheckList(),failsonly, mode);
}
//=======================================================================
//function : PrintCheckTransfer
//purpose :
//=======================================================================
void XSControl_Reader::PrintCheckTransfer(const Standard_Boolean failsonly,
const IFSelect_PrintCount mode) const
{
thesession->PrintCheckList (thesession->TransferReader()->LastCheckList(),failsonly, mode);
}
//=======================================================================
//function : PrintStatsTransfer
//purpose :
//=======================================================================
void XSControl_Reader::PrintStatsTransfer (const Standard_Integer what,
const Standard_Integer mode) const
{
thesession->TransferReader()->PrintStats (what,mode);
}
//=======================================================================
//function : GetStatsTransfer
//purpose :
//=======================================================================
void XSControl_Reader::GetStatsTransfer (const Handle(TColStd_HSequenceOfTransient)& list,
Standard_Integer& nbMapped,
Standard_Integer& nbWithResult,
Standard_Integer& nbWithFail) const
{
Handle(Transfer_TransientProcess) TP = thesession->MapReader();
Transfer_IteratorOfProcessForTransient itrp(Standard_True);
itrp = TP->CompleteResult(Standard_True);
if(!list.IsNull()) itrp.Filter (list);
nbMapped = nbWithFail = nbWithResult = 0;
for (itrp.Start(); itrp.More(); itrp.Next()) {
Handle(Transfer_Binder) binder = itrp.Value();
Handle(Standard_Transient) ent = itrp.Starting();
nbMapped++;
if (binder.IsNull()) nbWithFail++;
else
if(!binder->HasResult()) nbWithFail++;
else
{
Interface_CheckStatus cst = binder->Check()->Status();
if ((cst == Interface_CheckOK)||(cst == Interface_CheckWarning))
nbWithResult++;
else
nbWithFail++;
}
}
}

View File

@@ -0,0 +1,70 @@
-- File: XSControl_SelectForTransfer.cdl
-- Created: Tue Mar 26 14:03:27 1996
-- Author: Christian CAILLET
-- <cky@fidox>
---Copyright: Matra Datavision 1996
class SelectForTransfer from XSControl inherits SelectExtract from IFSelect
---Purpose : This selection selects the entities which are recognised for
-- transfer by an Actor for Read : current one or another one.
--
-- An Actor is an operator which runs transfers from interface
-- entities to objects for Imagine. It has a method to recognize
-- the entities it can process (by default, it recognises all,
-- this method can be redefined).
--
-- A TransferReader brings an Actor, according to the currently
-- selected norm and transfer conditions.
--
-- This selection considers, either the current Actor (brought by
-- the TransferReader, updated as required), or a precise one.
uses AsciiString from TCollection, InterfaceModel,
ActorOfTransientProcess, TransferReader
is
Create returns mutable SelectForTransfer;
---Purpose : Creates a SelectForTransfer, non initialised
-- it sorts nothing, unless an Actor has been defined
Create (TR : TransferReader) returns mutable SelectForTransfer;
---Purpose : Creates a SelectForTransfer, which will work with the
-- currently defined Actor brought by the TransferReader
SetReader (me : mutable; TR : TransferReader);
---Purpose : Sets a TransferReader to sort entities : it brings the Actor,
-- which may change, while the TransferReader does not
SetActor (me : mutable; act : mutable ActorOfTransientProcess);
---Purpose : Sets a precise actor to sort entities
-- This definition oversedes the creation with a TransferReader
Actor (me) returns ActorOfTransientProcess;
---Purpose : Returns the Actor used as precised one.
-- Returns a Null Handle for a creation from a TransferReader
-- without any further setting
Reader (me) returns TransferReader;
---Purpose : Returns the Reader (if created with a Reader)
-- Returns a Null Handle if not created with a Reader
Sort (me; rank : Integer; ent : Transient; model : InterfaceModel)
returns Boolean;
---Purpose : Returns True for an Entity which is recognized by the Actor,
-- either the precised one, or the one defined by TransferReader
--Sort (me; ent : in out Transient) returns Boolean;
ExtractLabel (me) returns AsciiString from TCollection;
---Purpose : Returns a text defining the criterium : "Recognized for Transfer [(current actor)]"
fields
theTR : TransferReader;
theAC : ActorOfTransientProcess;
end SelectForTransfer;

View File

@@ -0,0 +1,40 @@
#include <XSControl_SelectForTransfer.ixx>
XSControl_SelectForTransfer::XSControl_SelectForTransfer () { }
XSControl_SelectForTransfer::XSControl_SelectForTransfer
(const Handle(XSControl_TransferReader)& TR)
{ theTR = TR; }
void XSControl_SelectForTransfer::SetReader
(const Handle(XSControl_TransferReader)& TR)
{ theTR = TR; }
void XSControl_SelectForTransfer::SetActor
(const Handle(Transfer_ActorOfTransientProcess)& act)
{ theAC = act; }
Handle(Transfer_ActorOfTransientProcess) XSControl_SelectForTransfer::Actor () const
{ return theAC; }
Handle(XSControl_TransferReader) XSControl_SelectForTransfer::Reader () const
{ return theTR; }
Standard_Boolean XSControl_SelectForTransfer::Sort
(const Standard_Integer /*rank*/, const Handle(Standard_Transient)& ent,
const Handle(Interface_InterfaceModel)& /*model*/) const
{
Handle(Transfer_ActorOfTransientProcess) act = theAC;
if (act.IsNull() && !theTR.IsNull()) act = theTR->Actor();
if (!act.IsNull()) return act->Recognize(ent);//,theTR->TransientProcess());//act->Recognize(ent);
return Standard_False;
}
TCollection_AsciiString XSControl_SelectForTransfer::ExtractLabel () const
{
if (!theTR.IsNull()) return TCollection_AsciiString
("Recognized for Transfer (current actor)");
return TCollection_AsciiString("Recognized for Transfer");
}

View File

@@ -0,0 +1,63 @@
-- File: XSControl_SignTransferStatus.cdl
-- Created: Fri Jul 31 09:08:22 1998
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class SignTransferStatus from XSControl inherits Signature from IFSelect
---Purpose : This Signatures gives the Transfer Status of an entity, as
-- recorded in a TransferProcess. It can be :
-- - Void : not recorded, or recorded as void with no message
-- (attributes are not taken into account)
-- - Warning : no result, warning message(s), no fail
-- - Fail : no result, fail messages (with or without warning)
-- - Result.. : result, no message (neither warning nor fail)
-- Result.. i.e. Result:TypeName of the result
-- - Result../Warning : result, with warning but no fail
-- - Result../Fail : result, with fail (.e. bad result)
-- - Fail on run : no result yet recorded, no message, but
-- an exception occurred while recording the result
-- (this should not appear and indicates a programming error)
uses CString, Transient, InterfaceModel,
TransientProcess, TransferReader
is
Create returns mutable SignTransferStatus;
---Purpose : Creates a SignTransferStatus, not initialised
-- it gives nothing (empty string)
Create (TR : TransferReader) returns mutable SignTransferStatus;
---Purpose : Creates a SignTransferStatus, which will work on the current
-- TransientProcess brought by the TransferReader (its MapReader)
SetReader (me : mutable; TR : TransferReader);
---Purpose : Sets a TransferReader to work
SetMap (me : mutable; TP : TransientProcess);
---Purpose : Sets a precise map to sign entities
-- This definition oversedes the creation with a TransferReader
Map (me) returns TransientProcess;
---Purpose : Returns the TransientProcess used as precised one
-- Returns a Null Handle for a creation from a TransferReader
-- without any further setting
Reader (me) returns TransferReader;
---Purpose : Returns the Reader (if created with a Reader)
-- Returns a Null Handle if not created with a Reader
Value (me; ent : any Transient; model : InterfaceModel) returns CString;
---Purpose : Returns the Signature for a Transient object, as its transfer
-- status
fields
theTR : TransferReader;
theTP : TransientProcess;
end SignTransferStatus;

View File

@@ -0,0 +1,96 @@
#include <XSControl_SignTransferStatus.ixx>
#include <Transfer_Binder.hxx>
#include <TCollection_AsciiString.hxx>
#include <Interface_Check.hxx>
//#include <stdio.h>
static TCollection_AsciiString& themes()
{
static TCollection_AsciiString tm;
return tm;
}
// si resultat avec type: a exploiter tout de suite !
XSControl_SignTransferStatus::XSControl_SignTransferStatus ()
: IFSelect_Signature("Transfer Status") { }
XSControl_SignTransferStatus::XSControl_SignTransferStatus
(const Handle(XSControl_TransferReader)& TR)
: IFSelect_Signature("Transfer Status") ,
theTR (TR) { }
void XSControl_SignTransferStatus::SetReader
(const Handle(XSControl_TransferReader)& TR)
{ theTR = TR; }
void XSControl_SignTransferStatus::SetMap
(const Handle(Transfer_TransientProcess)& TP)
{ theTP = TP; }
Handle(Transfer_TransientProcess) XSControl_SignTransferStatus::Map () const
{ return theTP; }
Handle(XSControl_TransferReader) XSControl_SignTransferStatus::Reader () const
{ return theTR; }
// BinderStatus retourne une valeur :
// 0 Binder Null. 1 void 2 Warning seul 3 Fail seul
// 11 Resultat OK. 12 Resultat+Warning. 13 Resultat+Fail
// 20 Abnormal (Interrupted)
static Standard_Integer BinderStatus (const Handle(Transfer_Binder)& binder)
{
Standard_Integer stat = 0;
if (binder.IsNull()) return 0;
Interface_CheckStatus cst = binder->Check()->Status();
Transfer_StatusExec est = binder->StatusExec ();
Standard_Boolean res = binder->HasResult();
if (est == Transfer_StatusRun || est == Transfer_StatusLoop) return 20;
if (cst == Interface_CheckOK) stat = (res ? 11 : 1);
else if (cst == Interface_CheckWarning) stat = (res ? 12 : 2);
else if (cst == Interface_CheckFail) stat = (res ? 13 : 3);
return stat;
}
Standard_CString XSControl_SignTransferStatus::Value
(const Handle(Standard_Transient)& ent,
const Handle(Interface_InterfaceModel)& /*model*/) const
{
if (ent.IsNull()) return "";
Handle(Transfer_TransientProcess) TP = theTP;
if (TP.IsNull() && !theTR.IsNull()) TP = theTR->TransientProcess();
if (TP.IsNull()) return "";
Handle(Transfer_Binder) binder = TP->Find(ent);
Standard_Integer stat = BinderStatus (binder);
if (stat <= 1) return "";
if (stat == 2) return "Warning";
if (stat == 3) return "Fail";
if (stat == 20) return "Fail on run";
themes().Clear();
if (stat > 10) {
// Y a un resultat : donner son type
Handle(Transfer_Binder) bnd = binder;
Standard_Integer hasres = Standard_False;
while (!bnd.IsNull()) {
if (bnd->Status() != Transfer_StatusVoid) {
if (!hasres) themes().AssignCat("Result:");
else themes().AssignCat(",");
themes().AssignCat(bnd->ResultTypeName());
hasres = Standard_True;
}
bnd = bnd->NextResult();
}
// if (stat == 11) sprintf(themes,"Result:%s",binder->ResultTypeName());
if (stat == 12) themes().AssignCat("/Warning");
if (stat == 13) themes().AssignCat("/Fail");
}
return themes().ToCString();
}

View File

@@ -0,0 +1,349 @@
-- File: XSControl_TransferReader.cdl
-- Created: Tue Dec 5 10:50:44 1995
-- Author: Christian CAILLET
-- <cky@fidox>
---Copyright: Matra Datavision 1995
class TransferReader from XSControl inherits TShared
---Purpose : A TransferReader performs, manages, handles results of,
-- transfers done when reading a file (i.e. from entities of an
-- InterfaceModel, to objects for Imagine)
--
-- Running is organised around basic tools : TransientProcess and
-- its Actor, results are Binders and CheckIterators. It implies
-- control by a Controller (which prepares the Actor as required)
--
-- Getting results can be done directly on TransientProcess, but
-- these are immediate "last produced" results. Each transfer of
-- an entity gives a final result, but also possible intermediate
-- data, and checks, which can be attached to sub-entities.
--
-- Hence, final results (which intermediates and checks) are
-- recorded as ResultFromModel and can be queried individually.
--
-- Some more direct access are given for results which are
-- Transient or Shapes
uses CString, AsciiString, Transient,
DataMapOfIntegerTransient, HSequenceOfTransient, DictionaryOfTransient,
InterfaceModel, CheckIterator, Graph, HGraph,
TransientProcess, ActorOfTransientProcess, Binder, ResultFromModel,
CheckStatus from Interface, Controller from XSControl,
Shape from TopoDS, HSequenceOfShape from TopTools
is
Create returns mutable TransferReader;
---Purpose : Creates a TransferReader, empty
-- General Management --
SetController (me : mutable; control : mutable Controller from XSControl);
---Purpose : Sets a Controller. It is required to generate the Actor.
-- Elsewhere, the Actor must be provided directly
SetActor (me : mutable; actor : mutable ActorOfTransientProcess);
---Purpose : Sets the Actor directly : this value will be used if the
-- Controller is not set
Actor (me : mutable) returns mutable ActorOfTransientProcess;
---Purpose : Returns the Actor, determined by the Controller, or if this
-- one is unknown, directly set.
-- Once it has been defined, it can then be edited.
SetModel (me : mutable; model : InterfaceModel);
---Purpose : Sets an InterfaceModel. This causes former results, computed
-- from another one, to be lost (see also Clear)
SetGraph (me : mutable; graph : HGraph);
---Purpose : Sets a Graph and its InterfaceModel (calls SetModel)
Model (me) returns InterfaceModel;
---Purpose : Returns the currently set InterfaceModel
SetContext (me : mutable; name : CString; ctx : Transient);
---Purpose : Sets a Context : according to receiving appli, to be
-- interpreted by the Actor
GetContext (me; name : CString; type : Type; ctx : out Transient)
returns Boolean;
---Purpose : Returns the Context attached to a name, if set and if it is
-- Kind of the type, else a Null Handle
-- Returns True if OK, False if no Context
Context (me : mutable) returns DictionaryOfTransient;
---Purpose : Returns (modifiable) the whole definition of Context
-- Rather for internal use (ex.: preparing and setting in once)
---C++ : return &
SetFileName (me : mutable; name : CString);
---Purpose : Sets a new value for (loaded) file name
FileName (me) returns CString;
---Purpose : Returns actual value of file name
Clear (me : mutable; mode : Integer);
---Purpose : Clears data, according mode :
-- -1 all
-- 0 nothing done
-- +1 final results
-- +2 working data (model, context, transfer process)
TransientProcess (me) returns mutable TransientProcess;
---Purpose : Returns the currently used TransientProcess
-- It is computed from the model by TransferReadRoots, or by
-- BeginTransferRead
SetTransientProcess (me : mutable; TP : mutable TransientProcess);
---Purpose : Forces the TransientProcess
-- Remark : it also changes the Model and the Actor, from those
-- recorded in the new TransientProcess
-- Recording and Querying Results --
-- these methods work mainly on recorded data
-- i.e. they don't need Controller and Actor
RecordResult (me : mutable; ent : Transient) returns Boolean;
---Purpose : Records a final result of transferring an entity
-- This result is recorded as a ResultFromModel, taken from
-- the TransientProcess
-- Returns True if a result is available, False else
IsRecorded (me; ent : Transient) returns Boolean;
---Purpose : Returns True if a final result is recorded for an entity
-- Remark that it can bring no effective result if transfer has
-- completely failed (FinalResult brings only fail messages ...)
HasResult (me; ent : Transient) returns Boolean;
---Purpose : Returns True if a final result is recorded AND BRINGS AN
-- EFFECTIVE RESULT (else, it brings only fail messages)
RecordedList (me) returns HSequenceOfTransient;
---Purpose : Returns the list of entities to which a final result is
-- attached (i.e. processed by RecordResult)
Skip (me : mutable; ent : Transient) returns Boolean;
---Purpose : Note that an entity has been required for transfer but no
-- result at all is available (typically : case not implemented)
-- It is not an error, but it gives a specific status : Skipped
-- Returns True if done, False if <ent> is not in starting model
IsSkipped (me; ent : Transient) returns Boolean;
---Purpose : Returns True if an entity is noted as skipped
IsMarked (me; ent : Transient) returns Boolean;
---Purpose : Returns True if an entity has been asked for transfert, hence
-- it is marked, as : Recorded (a computation has ran, with or
-- without an effective result), or Skipped (case ignored)
FinalResult (me; ent : Transient) returns ResultFromModel;
---Purpose : Returns the final result recorded for an entity, as such
FinalEntityLabel (me; ent : Transient) returns CString;
---Purpose : Returns the label attached to an entity recorded for final,
-- or an empty string if not recorded
FinalEntityNumber (me; ent : Transient) returns Integer;
---Purpose : Returns the number attached to the entity recorded for final,
-- or zero if not recorded (looks in the ResultFromModel)
ResultFromNumber (me; num : Integer) returns ResultFromModel;
---Purpose : Returns the final result recorded for a NUMBER of entity
-- (internal use). Null if out of range
TransientResult (me; ent : Transient) returns mutable Transient;
---Purpose : Returns the resulting object as a Transient
-- Null Handle if no result or result not transient
ShapeResult (me; ent : Transient) returns Shape from TopoDS;
---Purpose : Returns the resulting object as a Shape
-- Null Shape if no result or result not a shape
ClearResult (me : mutable; ent : Transient; mode : Integer) returns Boolean;
---Purpose : Clears recorded result for an entity, according mode
-- <mode> = -1 : true, complete, clearing (erasing result)
-- <mode> >= 0 : simple "stripping", see ResultFromModel,
-- in particular, 0 for simple internal strip,
-- 10 for all but final result,
-- 11 for all : just label, status and filename are kept
-- Returns True when done, False if nothing was to clear
EntityFromResult (me; res : Transient; mode : Integer=0) returns Transient;
---Purpose : Returns an entity from which a given result was produced.
-- If <mode> = 0 (D), searches in last root transfers
-- If <mode> = 1, searches in last (root & sub) transfers
-- If <mode> = 2, searches in root recorded results
-- If <mode> = 3, searches in all (root & sub) recordeds
-- <res> can be, either a transient object (result itself) or
-- a binder. For a binder of shape, calls EntityFromShapeResult
-- Returns a Null Handle if <res> not recorded
EntityFromShapeResult (me; res : Shape from TopoDS; mode : Integer=0)
returns Transient;
---Purpose : Returns an entity from which a given shape result was produced
-- Returns a Null Handle if <res> not recorded or not a Shape
EntitiesFromShapeList (me; res : HSequenceOfShape from TopTools; mode : Integer = 0)
returns HSequenceOfTransient from TColStd;
---Purpose : Returns the list of entities from which some shapes were
-- produced : it corresponds to a loop on EntityFromShapeResult,
-- but is optimised
CheckList (me; ent : Transient; level : Integer = 0) returns CheckIterator;
---Purpose : Returns the CheckList resulting from transferring <ent>, i.e.
-- stored in its recorded form ResultFromModel
-- (empty if transfer successful or not recorded ...)
--
-- If <ent> is the Model, returns the complete cumulated
-- check-list, <level> is ignored
--
-- If <ent> is an entity of the Model, <level> applies as follows
-- <level> : -1 for <ent> only, LAST transfer (TransientProcess)
-- <level> : 0 for <ent> only (D)
-- 1 for <ent> and its immediate subtransfers, if any
-- 2 for <ent> and subtransferts at all levels
HasChecks (me; ent : Transient; failsonly : Boolean) returns Boolean;
---Purpose : Returns True if an entity (with a final result) has checks :
-- - failsonly = False : any kind of check message
-- - failsonly = True : fails only
-- Returns False if <ent> is not recorded
CheckedList (me; ent : Transient;
withcheck : CheckStatus = Interface_CheckAny; result : Boolean = Standard_True)
returns HSequenceOfTransient;
---Purpose : Returns the list of starting entities to which a given check
-- status is attached, IN FINAL RESULTS
-- <ent> can be an entity, or the model to query all entities
-- Below, "entities" are, either <ent> plus its sub-transferred,
-- or all the entities of the model
--
-- <check> = -2 , all entities whatever the check (see result)
-- <check> = -1 , entities with no fail (warning allowed)
-- <check> = 0 , entities with no check at all
-- <check> = 1 , entities with warning but no fail
-- <check> = 2 , entities with fail
-- <result> : if True, only entities with an attached result
-- Remark : result True and check=0 will give an empty list
-- Actions for Transfer (Read) --
BeginTransfer (me : mutable) returns Boolean;
---Purpose : Defines a new TransferProcess for reading transfer
-- Returns True if done, False if data are not properly defined
-- (the Model, the Actor for Read)
Recognize (me : mutable; ent : Transient) returns Boolean;
---Purpose : Tells if an entity is recognized as a valid candidate for
-- Transfer. Calls method Recognize from the Actor (if known)
TransferOne (me : mutable; ent : Transient;
rec : Boolean = Standard_True) returns Integer;
---Purpose : Commands the transfer on reading for an entity to data for
-- Imagine, using the selected Actor for Read
-- Returns count of transferred entities, ok or with fails (0/1)
-- If <rec> is True (D), the result is recorded by RecordResult
TransferList (me : mutable; list : HSequenceOfTransient;
rec : Boolean = Standard_True) returns Integer;
---Purpose : Commands the transfer on reading for a list of entities to
-- data for Imagine, using the selected Actor for Read
-- Returns count of transferred entities, ok or with fails (0/1)
-- If <rec> is True (D), the results are recorded by RecordResult
TransferRoots (me : mutable; G : Graph) returns Integer;
---Purpose : Transfers the content of the current Interface Model to
-- data handled by Imagine, starting from its Roots (determined
-- by the Graph <G>), using the selected Actor for Read
-- Returns the count of performed root transfers (i.e. 0 if none)
-- or -1 if no actor is defined
TransferClear (me : mutable; ent : Transient; level : Integer = 0);
---Purpose : Clears the results attached to an entity
-- if <ents> equates the starting model, clears all results
PrintStats (me; what : Integer; mode : Integer = 0);
---Purpose : Prints statistics on current Trace File, according <what> and
-- <mode>. See PrintStatsProcess for details
-- Querying last transfer (i.e. TransientProcess) --
LastCheckList (me) returns CheckIterator;
---Purpose : Returns the CheckList resulting from last TransferRead
-- i.e. from TransientProcess itself, recorded from last Clear
LastTransferList (me; roots : Boolean) returns HSequenceOfTransient;
---Purpose : Returns the list of entities recorded as lastly transferred
-- i.e. from TransientProcess itself, recorded from last Clear
-- If <roots> is True , considers only roots of transfer
-- If <roots> is False, considers all entities bound with result
ShapeResultList (me : mutable; rec : Boolean)
returns HSequenceOfShape from TopTools;
---Purpose : Returns a list of result Shapes
-- If <rec> is True , sees RecordedList
-- If <rec> is False, sees LastTransferList (last ROOT transfers)
-- For each one, if it is a Shape, it is cumulated to the list
-- If no Shape is found, returns an empty Sequence
PrintStatsProcess (myclass; TP : TransientProcess;
what : Integer; mode : Integer = 0);
---Purpose : This routines prints statistics about a TransientProcess
-- It can be called, by a TransferReader, or isolately
-- Prints are done on the default trace file
-- <what> defines what kind of statistics are to be printed :
-- 0 : basic figures
-- 1 : root results
-- 2 : all recorded (roots, intermediate, checked entities)
-- 3 : abnormal records
-- 4 : check messages (warnings and fails)
-- 5 : fail messages
--
-- <mode> is used according <what> :
-- <what> = 0 : <mode> is ignored
-- <what> = 1,2,3 : <mode> as follows :
-- 0 (D) : just lists numbers of concerned entities in the model
-- 1 : for each entity, gives number,label, type and result
-- type and/or status (fail/warning...)
-- 2 : for each entity, gives maximal information (i.e. checks)
-- 3 : counts per type of starting entity (class type)
-- 4 : counts per result type and/or status
-- 5 : counts per couple (starting type / result type/status)
-- 6 : idem plus gives for each item, the list of numbers of
-- entities in the starting model
--
-- <what> = 4,5 : modes relays on an enum PrintCount :
-- 0 (D) : ItemsByEntity (sequential list by entity)
-- 1 : CountByItem
-- 2 : ShortByItem (count + 5 first numbers)
-- 3 : ListByItem (count + entity numbers)
-- 4 : EntitiesByItem (count + entity numbers and labels)
PrintStatsOnList (myclass; TP : TransientProcess;
list : HSequenceOfTransient;
what : Integer; mode : Integer = 0);
---Purpose : Works as PrintStatsProcess, but displays data only on the
-- entities which are in <list> (filter)
fields
theController : Controller;
theFilename : AsciiString;
theModel : InterfaceModel;
theGraph : HGraph;
theContext : DictionaryOfTransient;
theActor : ActorOfTransientProcess;
theTransfer : TransientProcess;
theResults : DataMapOfIntegerTransient;
theShapeResult : HSequenceOfShape from TopTools;
end TransferReader;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,108 @@
-- File: XSControl_TransferWriter.cdl
-- Created: Wed Mar 13 09:49:23 1996
-- Author: Christian CAILLET
-- <cky@fidox>
---Copyright: Matra Datavision 1996
class TransferWriter from XSControl inherits TShared
---Purpose : TransferWriter gives help to control transfer to write a file
-- after having converted data from Cascade/Imagine
--
-- It works with a Controller (which itself can work with an
-- Actor to Write) and a FinderProcess. It records results and
-- checks
uses Transient,
Shape from TopoDS,
CheckIterator from Interface,
InterfaceModel from Interface,
FinderProcess, Controller, ReturnStatus
is
Create returns mutable TransferWriter;
---Purpose : Creates a TransferWriter, empty, ready to run
-- with an empty FinderProcess (but no controller, etc)
FinderProcess (me) returns mutable FinderProcess;
---Purpose : Returns the FinderProcess itself
SetFinderProcess (me : mutable; FP : mutable FinderProcess);
---Purpose : Sets a new FinderProcess and forgets the former one
Controller (me) returns Controller;
---Purpose : Returns the currently used Controller
SetController (me : mutable; ctl : Controller);
---Purpose : Sets a new Controller, also sets a new FinderProcess
Clear (me : mutable; mode : Integer);
---Purpose : Clears recorded data according a mode
-- 0 clears FinderProcess (results, checks)
-- -1 create a new FinderProcess
TransferMode (me) returns Integer;
---Purpose : Returns the current Transfer Mode (an Integer)
-- It will be interpreted by the Controller to run Transfers
-- This call form could be later replaced by more specific ones
-- (parameters suited for each norm / transfer case)
SetTransferMode (me : mutable; mode : Integer);
---Purpose : Changes the Transfer Mode
PrintStats (me; what : Integer; mode : Integer = 0);
---Purpose : Prints statistics on current Trace File, according what,mode
-- See PrintStatsProcess for details
-- Operations themselves
RecognizeTransient (me : mutable; obj : Transient) returns Boolean;
---Purpose : Tells if a transient object (from an application) is a valid
-- candidate for a transfer to a model
-- Asks the Controller (RecognizeWriteTransient)
-- If <obj> is a HShape, calls RecognizeShape
TransferWriteTransient (me : mutable; model : mutable InterfaceModel;
obj : Transient)
returns ReturnStatus;
---Purpose : Transfers a Transient object (from an application) to a model
-- of current norm, according to the last call to SetTransferMode
-- Works by calling the Controller
-- Returns status : =0 if OK, >0 if error during transfer, <0 if
-- transfer badly initialised
RecognizeShape (me : mutable; shape : Shape from TopoDS) returns Boolean;
---Purpose : Tells if a Shape is valid for a transfer to a model
-- Asks the Controller (RecognizeWriteShape)
TransferWriteShape (me : mutable; model : mutable InterfaceModel;
shape : Shape from TopoDS)
returns ReturnStatus;
---Purpose : Transfers a Shape from CasCade to a model of current norm,
-- according to the last call to SetTransferMode
-- Works by calling the Controller
-- Returns status : =0 if OK, >0 if error during transfer, <0 if
-- transfer badly initialised
CheckList (me) returns CheckIterator;
---Purpose : Returns the check-list of last transfer (write), i.e. the
-- check-list currently recorded in the FinderProcess
ResultCheckList (me; model : InterfaceModel) returns CheckIterator;
---Purpose : Returns the check-list of last transfer (write), but tries
-- to bind to each check, the resulting entity in the model
-- instead of keeping the original Mapper, whenever known
PrintStatsProcess (myclass; TP : FinderProcess;
what : Integer; mode : Integer = 0);
---Purpose : Forecast to print statitics about a FinderProcess
fields
theController : Controller;
theTransferWrite : FinderProcess;
theTransferMode : Integer;
end TransferWriter;

View File

@@ -0,0 +1,184 @@
#include <XSControl_TransferWriter.ixx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <Transfer_SimpleBinderOfTransient.hxx>
#include <Transfer_TransientMapper.hxx>
#include <XSControl_Utils.hxx>
#include <Message_Messenger.hxx>
#include <Interface_Macros.hxx>
#include <Interface_Check.hxx>
XSControl_TransferWriter::XSControl_TransferWriter ()
{ theTransferWrite = new Transfer_FinderProcess; theTransferMode = 0; }
Handle(Transfer_FinderProcess) XSControl_TransferWriter::FinderProcess () const
{ return theTransferWrite; }
void XSControl_TransferWriter::SetFinderProcess (const Handle(Transfer_FinderProcess)& FP)
{ theTransferWrite = FP; }
Handle(XSControl_Controller) XSControl_TransferWriter::Controller () const
{ return theController; }
void XSControl_TransferWriter::SetController (const Handle(XSControl_Controller)& ctl)
{
theController = ctl;
Clear(-1);
}
void XSControl_TransferWriter::Clear (const Standard_Integer mode)
{
if (mode < 0 || theTransferWrite.IsNull())
theTransferWrite = new Transfer_FinderProcess;
else theTransferWrite->Clear();
}
Standard_Integer XSControl_TransferWriter::TransferMode () const
{ return theTransferMode; }
void XSControl_TransferWriter::SetTransferMode (const Standard_Integer mod)
{ theTransferMode = mod; }
void XSControl_TransferWriter::PrintStats
(const Standard_Integer , const Standard_Integer ) const
{
Handle(Message_Messenger) sout = theTransferWrite->Messenger();
// A ameliorer ... !
sout<<"\n*******************************************************************\n";
sout << "****** Statistics on Transfer (Write) ******"<<endl;
sout<<"\n*******************************************************************\n";
sout << "****** Transfer Mode = "<<theTransferMode;
Standard_CString modehelp = theController->ModeWriteHelp (theTransferMode);
if (modehelp && modehelp[0] != 0) sout<<" I.E. "<<modehelp;
sout<<" ******"<<endl;
}
// ########## LES ACTIONS ##########
Standard_Boolean XSControl_TransferWriter::RecognizeTransient
(const Handle(Standard_Transient)& obj)
{
if (theController.IsNull()) return Standard_False;
XSControl_Utils xu;
TopoDS_Shape sh = xu.BinderShape (obj);
if (!sh.IsNull()) return RecognizeShape (sh);
return theController->RecognizeWriteTransient (obj,theTransferMode);
}
IFSelect_ReturnStatus XSControl_TransferWriter::TransferWriteTransient
(const Handle(Interface_InterfaceModel)& model,
const Handle(Standard_Transient)& obj)
{
IFSelect_ReturnStatus status = IFSelect_RetVoid;
if (theController.IsNull()) return IFSelect_RetError;
if (model.IsNull()) return IFSelect_RetVoid;
if (theTransferWrite.IsNull()) theTransferWrite = new Transfer_FinderProcess;
Handle(Transfer_ActorOfFinderProcess) nulact;
theTransferWrite->SetActor (nulact);
Handle(Standard_Transient) resultat;
Handle(Message_Messenger) sout = theTransferWrite->Messenger();
try {
OCC_CATCH_SIGNALS
PrintStats(theTransferMode);
sout << "****** Transferring Transient, CDL Type = ";
sout<<obj->DynamicType()->Name()<<" ******"<<endl;
status = theController->TransferWriteTransient
(obj,theTransferWrite,model,theTransferMode);
}
catch(Standard_Failure) {
sout<<"**** **** TransferWriteShape, EXCEPTION : ";
sout<<Standard_Failure::Caught()->GetMessageString();
sout<<endl;
status = IFSelect_RetFail;
}
return status;
}
Standard_Boolean XSControl_TransferWriter::RecognizeShape
(const TopoDS_Shape& shape)
{
if (theController.IsNull()) return Standard_False;
if (shape.IsNull()) return Standard_False;
return theController->RecognizeWriteShape (shape,theTransferMode);
}
IFSelect_ReturnStatus XSControl_TransferWriter::TransferWriteShape
(const Handle(Interface_InterfaceModel)& model,
const TopoDS_Shape& shape)
{
IFSelect_ReturnStatus status = IFSelect_RetVoid;
if (theController.IsNull()) return IFSelect_RetError;
if (model.IsNull()) return IFSelect_RetVoid;
if (theTransferWrite.IsNull()) theTransferWrite = new Transfer_FinderProcess;
// effacer l actor : Controller s en charge
Handle(Transfer_ActorOfFinderProcess) nulact;
theTransferWrite->SetActor (nulact);
Handle(Standard_Transient) resultat;
Handle(Message_Messenger) sout = theTransferWrite->Messenger();
try {
OCC_CATCH_SIGNALS
PrintStats(theTransferMode);
sout << "****** Transferring Shape, ShapeType = " << shape.ShapeType();
sout<<" ******"<<endl;
status = theController->TransferWriteShape
(shape,theTransferWrite,model,theTransferMode);
}
catch(Standard_Failure) {
sout<<"**** **** TransferWriteShape, EXCEPTION : ";
sout<<Standard_Failure::Caught()->GetMessageString();
sout<<endl;
status = IFSelect_RetFail;
}
return status;
}
Interface_CheckIterator XSControl_TransferWriter::CheckList () const
{
Interface_CheckIterator chl;
if (theTransferWrite.IsNull()) return chl;
Standard_Integer i, nb = theTransferWrite->NbMapped();
for (i = 1; i <= nb; i ++) {
DeclareAndCast(Transfer_SimpleBinderOfTransient,tb,theTransferWrite->MapItem
(i));
if (tb.IsNull()) continue;
Handle(Interface_Check) ach = tb->Check();
if (ach->NbFails() == 0 || ach->NbWarnings() == 0) continue;
DeclareAndCast(Transfer_TransientMapper,tm,theTransferWrite->Mapped(i));
if (tm.IsNull()) ach->GetEntity (theTransferWrite->Mapped(i));
else ach->GetEntity (tm->Value());
chl.Add(ach);
}
return chl;
}
Interface_CheckIterator XSControl_TransferWriter::ResultCheckList
(const Handle(Interface_InterfaceModel)& model) const
{
Interface_CheckIterator chl;
if (theTransferWrite.IsNull()) return chl;
Standard_Integer i, nb = theTransferWrite->NbMapped();
for (i = 1; i <= nb; i ++) {
DeclareAndCast(Transfer_SimpleBinderOfTransient,tb,theTransferWrite->MapItem
(i));
if (tb.IsNull()) continue;
const Handle(Interface_Check) ach = tb->Check();
if (ach->NbFails() == 0 || ach->NbWarnings() == 0) continue;
Handle(Standard_Transient) ent = tb->Result();
if (!ent.IsNull() && !model.IsNull()) chl.Add(ach,model->Number(ent));
else chl.Add(ach,0);
}
return chl;
}
void XSControl_TransferWriter::PrintStatsProcess
(const Handle(Transfer_FinderProcess)& ,
const Standard_Integer , const Standard_Integer )
{ }

207
src/XSControl/XSControl_Utils.cdl Executable file
View File

@@ -0,0 +1,207 @@
-- File: XSControl_Utils.cdl
-- Created: Mon Dec 4 14:15:56 1995
-- Author: Christian CAILLET
-- <cky@fidox>
---Copyright: Matra Datavision 1995
class Utils from XSControl
---Purpose : This class provides various useful utility routines, to
-- facilitate handling of most common data structures :
-- transients (type, type name ...),
-- strings (ascii or extended, pointed or handled or ...),
-- shapes (reading, writing, testing ...),
-- sequences & arrays (of strings, of transients, of shapes ...),
-- ...
--
-- Also it gives some helps on some data structures from XSTEP,
-- such as printing on standard trace file, recignizing most
-- currently used auxiliary types (Binder,Mapper ...)
uses CString, ExtString, Transient,
AsciiString, HAsciiString, ExtendedString, HExtendedString,
HSequenceOfInteger from TColStd,
HSequenceOfTransient, HSequenceOfHAsciiString, HSequenceOfHExtendedString,
Shape from TopoDS, HSequenceOfShape from TopTools, ShapeEnum from TopAbs,
Binder from Transfer
raises TypeMismatch
is
Create returns Utils;
---Purpose : the only use of this, is to allow a frontal to get one
-- distinct "Utils" set per separate engine
-- Trace File
-- the class TraceFile gives enough functions to work from ccl
-- except to print a line to the default trace file (ccl can't call it)
TraceLine (me; line : CString);
---Purpose : Just prints a line into the current Trace File. This allows to
-- better characterise the various trace outputs, as desired.
TraceLines (me; lines : Transient);
---Purpose : Just prints a line or a set of lines into the current Trace
-- File. <lines> can be a HAscii/ExtendedString (produces a print
-- without ending line) or a HSequence or HArray1 Of ..
-- (one new line per item)
-- General Functions on Sequences : below
-- Simple Transient Objects (complements) --
IsKind (me; item : Transient; what : Type) returns Boolean;
-- simply IsKind from Transient
TypeName (me; item : Transient; nopk : Boolean = Standard_False)
returns CString;
---Purpose : Returns the name of the dynamic type of an object, i.e. :
-- If it is a Type, its Name
-- If it is a object not a type, the Name of its DynamicType
-- If it is Null, an empty string
-- If <nopk> is False (D), gives complete name
-- If <nopk> is True, returns class name without package
-- List of Transients (HSequence or HArray1) --
TraValue (me; list : Transient; num : Integer)
returns mutable Transient;
-- allowed : HSequenceOfTransient -> Transient,
-- HSequenceOfHAsciiString -> HAsciiString
-- out of range gives Null Handle
NewSeqTra (me) returns mutable HSequenceOfTransient; -- empty new
AppendTra (me; seqval : mutable HSequenceOfTransient;
traval : Transient);
-- Dates
DateString (me; yy,mm,dd,hh,mn,ss : Integer) returns CString;
DateValues (me; text : CString; yy,mm,dd,hh,mn,ss : out Integer);
-- -- Strings -- --
-- Ascii --
ToCString (me; strval : HAsciiString) returns CString;
ToCString (me; strval : AsciiString) returns CString;
ToHString (me; strcon : CString) returns mutable HAsciiString;
ToAString (me; strcon : CString) returns AsciiString;
-- Extended --
ToEString (me; strval : HExtendedString) returns ExtString;
ToEString (me; strval : ExtendedString) returns ExtString;
ToHString (me; strcon : ExtString) returns mutable HExtendedString;
ToXString (me; strcon : ExtString) returns ExtendedString;
-- Ascii <-> Extended --
AsciiToExtended (me; str : CString) returns ExtString;
IsAscii (me; str : ExtString) returns Boolean;
ExtendedToAscii (me; str : ExtString) returns CString;
-- List of Strings --
CStrValue (me; list : Transient; num : Integer) returns CString;
EStrValue (me; list : Transient; num : Integer) returns ExtString;
-- list : HSequence or HArray1 of (H)AsciiString or (H)ExtendedString
-- conversions Ascii<->Extended are done if required
-- out of range gives empty string
NewSeqCStr (me) returns mutable HSequenceOfHAsciiString; -- empty
AppendCStr (me; seqval : mutable HSequenceOfHAsciiString;
strval : CString);
NewSeqEStr (me) returns mutable HSequenceOfHExtendedString; -- empty
AppendEStr (me; seqval : mutable HSequenceOfHExtendedString;
strval : ExtString);
-- -- Shapes -- --
-- Direct Handling, Read-Write --
WriteShape (me; shape : Shape from TopoDS; filename : CString)
returns Boolean;
---Purpose : Writes a Shape under the internal BRepTools form
-- (an internal help utility)
-- Returns True if writing has succeeded, False else
NewShape (me) returns Shape from TopoDS;
---Purpose : Returns a new empty, undefined Shape, which can then be filled
-- by ReadShape
ReadShape (me; shape : in out Shape from TopoDS; filename : CString)
returns Boolean;
---Purpose : Reads a Shape from the internal BRepTools form and returns it
-- (an internal help utility)
-- Returns True if reading has succeeded, False else
IsNullShape (me; shape : Shape from TopoDS) returns Boolean;
---Purpose : Returns True if a Shape is Null
CompoundFromSeq (me; seqval : HSequenceOfShape)
returns Shape from TopoDS;
---Purpose : Converts a list of Shapes to a Compound (a kind of Shape)
ShapeType (me; shape : Shape from TopoDS; compound : Boolean)
returns ShapeEnum;
---Purpose : Returns the type of a Shape : true type if <compound> is False
-- If <compound> is True and <shape> is a Compound, iterates on
-- its items. If all are of the same type, returns this type.
-- Else, returns COMPOUND. If it is empty, returns SHAPE
-- For a Null Shape, returns SHAPE
SortedCompound (me; shape : Shape from TopoDS; type : ShapeEnum;
explore : Boolean; compound : Boolean)
returns Shape from TopoDS;
---Purpose : From a Shape, builds a Compound as follows :
-- explores it level by level
-- If <explore> is False, only COMPOUND items. Else, all items
-- Adds to the result, shapes which comply to <type>
-- + if <type> is WIRE, considers free edges (and makes wires)
-- + if <type> is SHELL, considers free faces (and makes shells)
-- If <compound> is True, gathers items in compounds which
-- correspond to starting COMPOUND,SOLID or SHELL containers, or
-- items directly contained in a Compound
-- -- List of Shapes -- --
ShapeValue (me; seqv : HSequenceOfShape from TopTools; num : Integer)
returns Shape from TopoDS;
-- out of range gives Null Handle
NewSeqShape (me) returns mutable HSequenceOfShape; -- empty new
AppendShape (me; seqv : mutable HSequenceOfShape;
shape : Shape from TopoDS);
-- Shape <-> Transient --
ShapeBinder (me; shape : Shape from TopoDS; hs : Boolean = Standard_True)
returns mutable Transient;
---Purpose : Creates a Transient Object from a Shape : it is either a Binder
-- (used by functions which require a Transient but can process
-- a Shape, such as viewing functions) or a HShape (according to hs)
-- Default is a HShape
BinderShape (me; tr : Transient) returns Shape from TopoDS;
---Purpose : From a Transient, returns a Shape.
-- In fact, recognizes ShapeBinder ShapeMapper and HShape
-- -- Lists : others functions -- --
SeqLength (me; list : Transient) returns Integer;
-- list : HSequence of Transient,(H)Ascii/ExtendedString,Shape,Integer
SeqToArr (me; seq : Transient; first : Integer = 1)
returns mutable Transient raises TypeMismatch;
-- <first> gives the lower index of produced array
-- empty sequence gives a null handle
ArrToSeq (me; arr : Transient)
returns mutable Transient raises TypeMismatch;
-- allowed combinations :
-- HSequenceOfTransient <-> HArray1OfTransient
-- HSequenceOfHAsciiString <-> HArray1OfHAsciiString (from Interface)
-- Arrays are build from index <first>, by default 1
SeqIntValue (me; list : HSequenceOfInteger from TColStd; num : Integer)
returns Integer;
end Utils;

586
src/XSControl/XSControl_Utils.cxx Executable file
View File

@@ -0,0 +1,586 @@
#include <XSControl_Utils.ixx>
#include <Message_Messenger.hxx>
#include <Message.hxx>
#include <Interface_Macros.hxx>
#include <Interface_MSG.hxx>
#include <TColStd_HSequenceOfAsciiString.hxx>
#include <TColStd_HSequenceOfExtendedString.hxx>
#include <TColStd_HArray1OfTransient.hxx>
#include <Interface_HArray1OfHAsciiString.hxx>
#include <TransferBRep.hxx>
#include <TransferBRep_ShapeBinder.hxx>
#include <TransferBRep_ShapeMapper.hxx>
#include <TopoDS_HShape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopExp_Explorer.hxx>
#include <Transfer_SimpleBinderOfTransient.hxx>
#include <BRep_Builder.hxx>
#include <BRepTools.hxx>
static TCollection_AsciiString bufasc;
static TCollection_ExtendedString bufext;
static const Standard_ExtString voidext = { 0 };
XSControl_Utils::XSControl_Utils () { }
// #########################################################
// ####### Fonctions de TRACE #######
void XSControl_Utils::TraceLine (const Standard_CString line) const
{
Handle(Message_Messenger) sout = Message::DefaultMessenger();
sout<<line<<endl;
}
void XSControl_Utils::TraceLines (const Handle(Standard_Transient)& lines) const
{
Handle(Message_Messenger) sout = Message::DefaultMessenger();
Standard_Integer i,nb;
DeclareAndCast(TColStd_HSequenceOfHAsciiString,linha,lines);
if (!linha.IsNull()) {
nb = linha->Length();
for (i = 1; i <= nb; i ++)
if (!linha->Value(i).IsNull()) sout<<linha->Value(i)->ToCString()<<endl;
return;
}
DeclareAndCast(TColStd_HSequenceOfAsciiString,lina,lines);
if (!lina.IsNull()) {
nb = lina->Length();
for (i = 1; i <= nb; i ++)
sout<<lina->Value(i).ToCString()<<endl;
return;
}
DeclareAndCast(TColStd_HSequenceOfHExtendedString,linhe,lines);
if (!linhe.IsNull()) {
nb = linhe->Length();
for (i = 1; i <= nb; i ++)
if (!linhe->Value(i).IsNull())
sout << linhe->Value(i) << endl;
return;
}
DeclareAndCast(TColStd_HSequenceOfExtendedString,linee,lines);
if (!linee.IsNull()) {
nb = linee->Length();
for (i = 1; i <= nb; i ++)
sout << linee->Value(i) << endl;
return;
}
DeclareAndCast(TCollection_HAsciiString,lin1a,lines);
if (!lin1a.IsNull()) sout<<lin1a;
DeclareAndCast(TCollection_HExtendedString,lin1e,lines);
if (!lin1e.IsNull()) sout<<lin1e;
}
// #########################################################
// ####### TRANSIENT : Quelques acces de base #######
Standard_Boolean XSControl_Utils::IsKind
(const Handle(Standard_Transient)& item, const Handle(Standard_Type)& what) const
{
if (item.IsNull()) return Standard_False;
if (what.IsNull()) return Standard_False;
return item->IsKind(what);
}
Standard_CString XSControl_Utils::TypeName
(const Handle(Standard_Transient)& item, const Standard_Boolean nopk) const
{
if (item.IsNull()) return "";
DeclareAndCast(Standard_Type,atype,item);
if (atype.IsNull()) atype = item->DynamicType();
Standard_CString tn = atype->Name();
if (!nopk) return tn;
for (int i = 0; tn[i] != '\0'; i ++) {
if (tn[i] == '_') return &tn[i+1];
}
return tn;
}
// ####### TRANSIENT : Fonctions de liste #######
Handle(Standard_Transient) XSControl_Utils::TraValue
(const Handle(Standard_Transient)& seqval, const Standard_Integer num) const
{
Handle(Standard_Transient) val;
if (num < 1) return val;
if (seqval.IsNull()) return val;
DeclareAndCast(TColStd_HSequenceOfHAsciiString,seqs,seqval);
if (!seqs.IsNull())
{ if (num <= seqs->Length()) val = seqs->Value(num); return val; }
DeclareAndCast(TColStd_HSequenceOfTransient,seqt,seqval);
if (!seqt.IsNull())
{ if (num <= seqt->Length()) val = seqt->Value(num); return val; }
// Standard_TypeMismatch::Raise("XSControl_Utils::SeqTraValue");
return val;
}
Handle(TColStd_HSequenceOfTransient) XSControl_Utils::NewSeqTra () const
{ return new TColStd_HSequenceOfTransient(); }
void XSControl_Utils::AppendTra
(const Handle(TColStd_HSequenceOfTransient)& seqval,
const Handle(Standard_Transient)& traval) const
{ seqval->Append (traval); }
// ####### DATES #######
Standard_CString XSControl_Utils::DateString
(const Standard_Integer yy, const Standard_Integer mm,
const Standard_Integer dd, const Standard_Integer hh,
const Standard_Integer mn, const Standard_Integer ss) const
{
char ladate[50];
Interface_MSG::TDate (ladate, yy,mm,dd,hh,mn,ss);
bufasc.Clear(); bufasc.AssignCat(ladate);
return bufasc.ToCString();
}
void XSControl_Utils::DateValues
(const Standard_CString text,
Standard_Integer& yy, Standard_Integer& mm, Standard_Integer& dd,
Standard_Integer& hh, Standard_Integer& mn, Standard_Integer& ss) const
{ Interface_MSG::NDate (text, yy,mm,dd,hh,mn,ss); }
// ##########################################################
// ####### STRING : Ascii de base #######
Standard_CString XSControl_Utils::ToCString
(const Handle(TCollection_HAsciiString)& strval) const
{
//JR/Hp
Standard_CString astr = (Standard_CString ) (strval.IsNull() ? "" : strval->ToCString());
return astr ;
// return (strval.IsNull() ? "" : strval->ToCString());
}
Standard_CString XSControl_Utils::ToCString
(const TCollection_AsciiString& strval) const
{ return strval.ToCString(); }
Handle(TCollection_HAsciiString) XSControl_Utils::ToHString
(const Standard_CString strcon) const
{ return new TCollection_HAsciiString(strcon); }
TCollection_AsciiString XSControl_Utils::ToAString
(const Standard_CString strcon) const
{ return TCollection_AsciiString(strcon); }
// ####### STRING : Extended de base #######
Standard_ExtString XSControl_Utils::ToEString
(const Handle(TCollection_HExtendedString)& strval) const
{ return (strval.IsNull() ? voidext : strval->ToExtString()); }
Standard_ExtString XSControl_Utils::ToEString
(const TCollection_ExtendedString& strval) const
{ return strval.ToExtString(); }
Handle(TCollection_HExtendedString) XSControl_Utils::ToHString
(const Standard_ExtString strcon) const
{ return new TCollection_HExtendedString(strcon); }
TCollection_ExtendedString XSControl_Utils::ToXString
(const Standard_ExtString strcon) const
{ return TCollection_ExtendedString(strcon); }
// ####### STRING : Ascii <-> Extended #######
Standard_ExtString XSControl_Utils::AsciiToExtended (const Standard_CString str) const
{
bufext.Clear(); bufext = TCollection_ExtendedString (str);
return bufext.ToExtString();
}
Standard_Boolean XSControl_Utils::IsAscii (const Standard_ExtString str) const
{
bufext.Clear(); bufext.AssignCat (str);
return bufext.IsAscii();
}
Standard_CString XSControl_Utils::ExtendedToAscii (const Standard_ExtString str) const
{
bufext.Clear(); bufext.AssignCat (str); bufasc.Clear();
Standard_Integer i, nb = bufext.Length();
for (i = 1; i <= nb; i ++) {
int unext = bufext.Value(i);
unext = unext & 127;
char uncar = char(unext);
bufasc.AssignCat (uncar);
}
return bufasc.ToCString();
}
// ####### STRING : LISTES #######
Standard_CString XSControl_Utils::CStrValue
(const Handle(Standard_Transient)& list, const Standard_Integer num) const
{
DeclareAndCast(TColStd_HSequenceOfHAsciiString,linha,list);
if (!linha.IsNull()) {
//JR/Hp
Standard_CString astr = (Standard_CString )
(num > linha->Length() ? "" : linha->Value(num)->ToCString());
return astr ;
// return (num > linha->Length() ? "" : linha->Value(num)->ToCString());
}
DeclareAndCast(TColStd_HSequenceOfAsciiString,lina,list);
if (!lina.IsNull()) {
//JR/Hp
Standard_CString astr = (Standard_CString )
(num > lina->Length() ? "" : lina->Value(num).ToCString());
return astr ;
// return (num > lina->Length() ? "" : lina->Value(num).ToCString());
}
DeclareAndCast(TColStd_HSequenceOfHExtendedString,linhe,list);
if (!linhe.IsNull()) {
//JR/Hp
Standard_CString astr = (Standard_CString )
(num > linhe->Length() ? "" : ExtendedToAscii(linhe->Value(num)->ToExtString()));
return astr ;
// return (num > linhe->Length() ? "" : ExtendedToAscii(linhe->Value(num)->ToExtString()));
}
DeclareAndCast(TColStd_HSequenceOfExtendedString,linee,list);
if (!linee.IsNull()) {
//JR/Hp
Standard_CString astr = (Standard_CString )
(num > linee->Length() ? "" : ExtendedToAscii(linee->Value(num).ToExtString()));
return astr ;
// return (num > linee->Length() ? "" : ExtendedToAscii(linee->Value(num).T
}
DeclareAndCast(TCollection_HAsciiString,lin1a,list);
if (!lin1a.IsNull()) return lin1a->ToCString();
DeclareAndCast(TCollection_HExtendedString,lin1e,list);
if (!lin1e.IsNull()) return ExtendedToAscii(lin1e->ToExtString());
return "";
}
Standard_ExtString XSControl_Utils::EStrValue
(const Handle(Standard_Transient)& list, const Standard_Integer num) const
{
DeclareAndCast(TColStd_HSequenceOfHAsciiString,linha,list);
if (!linha.IsNull()) return
(num > linha->Length() ? voidext : AsciiToExtended(linha->Value(num)->ToCString()));
DeclareAndCast(TColStd_HSequenceOfAsciiString,lina,list);
if (!lina.IsNull())
(num > lina->Length() ? voidext : AsciiToExtended(lina->Value(num).ToCString()));
DeclareAndCast(TColStd_HSequenceOfHExtendedString,linhe,list);
if (!linhe.IsNull()) return
(num > linhe->Length() ? voidext : linhe->Value(num)->ToExtString());
DeclareAndCast(TColStd_HSequenceOfExtendedString,linee,list);
if (!linee.IsNull()) return
(num > linee->Length() ? voidext : linee->Value(num).ToExtString());
DeclareAndCast(TCollection_HAsciiString,lin1a,list);
if (!lin1a.IsNull()) return AsciiToExtended(lin1a->ToCString());
DeclareAndCast(TCollection_HExtendedString,lin1e,list);
if (!lin1e.IsNull()) return lin1e->ToExtString();
return voidext;
}
Handle(TColStd_HSequenceOfHAsciiString) XSControl_Utils::NewSeqCStr () const
{ return new TColStd_HSequenceOfHAsciiString(); }
void XSControl_Utils::AppendCStr
(const Handle(TColStd_HSequenceOfHAsciiString)& seqval,
const Standard_CString strval) const
{ seqval->Append (new TCollection_HAsciiString(strval)); }
Handle(TColStd_HSequenceOfHExtendedString) XSControl_Utils::NewSeqEStr () const
{ return new TColStd_HSequenceOfHExtendedString(); }
void XSControl_Utils::AppendEStr
(const Handle(TColStd_HSequenceOfHExtendedString)& seqval,
const Standard_ExtString strval) const
{ seqval->Append (new TCollection_HExtendedString(strval)); }
// ##########################################################
// ####### SHAPES : Acces de base #######
Standard_Boolean XSControl_Utils::WriteShape
(const TopoDS_Shape& shape,
const Standard_CString filename) const
{ return BRepTools::Write (shape,filename); }
TopoDS_Shape XSControl_Utils::NewShape () const
{ TopoDS_Shape shape; return shape; }
Standard_Boolean XSControl_Utils::ReadShape
(TopoDS_Shape& shape,
const Standard_CString filename) const
{
BRep_Builder B;
return BRepTools::Read (shape,filename,B);
}
Standard_Boolean XSControl_Utils::IsNullShape (const TopoDS_Shape& shape) const
{ return shape.IsNull(); }
TopoDS_Shape XSControl_Utils::CompoundFromSeq
(const Handle(TopTools_HSequenceOfShape)& seqval) const
{
BRep_Builder B;
TopoDS_Compound C;
B.MakeCompound(C);
Standard_Integer i,n = seqval->Length();
for (i = 1; i <= n ; i ++) B.Add(C,seqval->Value(i));
return C;
}
TopAbs_ShapeEnum XSControl_Utils::ShapeType
(const TopoDS_Shape& shape, const Standard_Boolean compound) const
{
if (shape.IsNull()) return TopAbs_SHAPE;
TopAbs_ShapeEnum res = shape.ShapeType();
if (!compound || res != TopAbs_COMPOUND) return res;
res = TopAbs_SHAPE;
for (TopoDS_Iterator iter(shape); iter.More(); iter.Next()) {
TopoDS_Shape sh = iter.Value();
if (sh.IsNull()) continue;
TopAbs_ShapeEnum typ = sh.ShapeType();
if (typ == TopAbs_COMPOUND) typ = ShapeType (sh,compound);
if (res == TopAbs_SHAPE) res = typ;
// Egalite : OK; Pseudo-Egalite : EDGE/WIRE ou FACE/SHELL
else if (res == TopAbs_EDGE && typ == TopAbs_WIRE) res = typ;
else if (res == TopAbs_WIRE && typ == TopAbs_EDGE) continue;
else if (res == TopAbs_FACE && typ == TopAbs_SHELL) res = typ;
else if (res == TopAbs_SHELL && typ == TopAbs_FACE) continue;
else if (res != typ) return TopAbs_COMPOUND;
}
return res;
}
TopoDS_Shape XSControl_Utils::SortedCompound
(const TopoDS_Shape& shape, const TopAbs_ShapeEnum type,
const Standard_Boolean explore, const Standard_Boolean compound) const
{
if (shape.IsNull()) return shape;
TopAbs_ShapeEnum typ = shape.ShapeType();
TopoDS_Shape sh, sh0;
Standard_Integer nb = 0;
// Compound : on le prend, soit tel quel, soit son contenu
if (typ == TopAbs_COMPOUND || typ == TopAbs_COMPSOLID) {
TopoDS_Compound C;
BRep_Builder B;
B.MakeCompound (C);
for (TopoDS_Iterator it(shape); it.More(); it.Next()) {
sh0 = SortedCompound (it.Value(),type,explore,compound);
if (sh0.IsNull()) continue;
sh = sh0;
typ = sh.ShapeType();
if (typ == TopAbs_COMPOUND && !compound) {
for (TopoDS_Iterator it2 (sh); it2.More(); it2.Next())
{ nb ++; sh = it2.Value(); B.Add (C, sh); }
}
else { nb ++; B.Add (C,sh); }
}
if (nb == 0) C.Nullify();
else if (nb == 1) return sh;
return C;
}
// Egalite : OK; Pseudo-Egalite : EDGE/WIRE ou FACE/SHELL
if (typ == type) return shape;
if (typ == TopAbs_EDGE && type == TopAbs_WIRE) {
BRep_Builder B;
TopoDS_Wire W;
B.MakeWire (W);
B.Add (W,shape); // ne passe pas ! : TopoDS::Edge(shape)
return W;
}
if (typ == TopAbs_FACE && type == TopAbs_SHELL) {
BRep_Builder B;
TopoDS_Shell S;
B.MakeShell (S);
B.Add (S,shape); // ne passe pas ! : TopoDS::Face(shape));
return S;
}
// Le reste : selon exploration
if (!explore) {
TopoDS_Shape nulsh;
return nulsh;
}
// Ici, on doit explorer
// SOLID + mode COMPOUND : reconduire les SHELLs
if (typ == TopAbs_SOLID && compound) {
TopoDS_Compound C;
BRep_Builder B;
B.MakeCompound (C);
for (TopoDS_Iterator it(shape); it.More(); it.Next()) {
sh0 = SortedCompound (it.Value(),type,explore,compound);
if (sh0.IsNull()) continue;
sh = sh0;
nb ++; B.Add (C,sh);
}
if (nb == 0) C.Nullify();
else if (nb == 1) return sh;
return C;
}
// Exploration classique
TopoDS_Compound CC;
BRep_Builder BB;
BB.MakeCompound(CC);
for (TopExp_Explorer expl (shape,type); expl.More(); expl.Next()) {
nb ++; sh = expl.Current();
BB.Add (CC,sh);
}
if (nb == 0) CC.Nullify();
else if (nb == 1) return sh;
return CC;
}
// ####### SHAPES : Liste #######
TopoDS_Shape XSControl_Utils::ShapeValue
(const Handle(TopTools_HSequenceOfShape)& seqval, const Standard_Integer num) const
{
TopoDS_Shape shape;
if (seqval.IsNull()) return shape;
if (num > 0 && num <= seqval->Length()) shape = seqval->Value(num);
return shape;
}
Handle(TopTools_HSequenceOfShape) XSControl_Utils::NewSeqShape () const
{ return new TopTools_HSequenceOfShape(); }
void XSControl_Utils::AppendShape
(const Handle(TopTools_HSequenceOfShape)& seqval, const TopoDS_Shape& shape) const
{ seqval->Append (shape); }
// ####### SHAPES <-> Transient #######
Handle(Standard_Transient) XSControl_Utils::ShapeBinder
(const TopoDS_Shape& shape, const Standard_Boolean hs) const
{ if (hs) return new TopoDS_HShape (shape);
else return new TransferBRep_ShapeBinder (shape); }
TopoDS_Shape XSControl_Utils::BinderShape
(const Handle(Standard_Transient)& tr) const
{
TopoDS_Shape sh;
DeclareAndCast(Transfer_Binder,sb,tr);
if (!sb.IsNull()) return TransferBRep::ShapeResult(sb);
DeclareAndCast(TransferBRep_ShapeMapper,sm,tr);
if (!sm.IsNull()) return sm->Value();
DeclareAndCast(TopoDS_HShape,hs,tr);
if (!hs.IsNull()) return hs->Shape();
return sh;
}
// ##########################################################
// ####### LISTES : Fonctions Generales #######
Standard_Integer XSControl_Utils::SeqLength
(const Handle(Standard_Transient)& seqval) const
{
if (seqval.IsNull()) return 0;
DeclareAndCast(TColStd_HSequenceOfHAsciiString,seqs,seqval);
if (!seqs.IsNull()) return seqs->Length();
DeclareAndCast(TColStd_HSequenceOfAsciiString,seqa,seqval);
if (!seqa.IsNull()) return seqa->Length();
DeclareAndCast(TColStd_HSequenceOfHExtendedString,seqe,seqval);
if (!seqe.IsNull()) return seqe->Length();
DeclareAndCast(TColStd_HSequenceOfHExtendedString,seqx,seqval);
if (!seqx.IsNull()) return seqx->Length();
DeclareAndCast(TColStd_HSequenceOfTransient,seqt,seqval);
if (!seqt.IsNull()) return seqt->Length();
DeclareAndCast(TopTools_HSequenceOfShape,seqh,seqval);
if (!seqh.IsNull()) return seqh->Length();
DeclareAndCast(TColStd_HSequenceOfInteger,seqi,seqval);
if (!seqi.IsNull()) return seqi->Length();
// Standard_TypeMismatch::Raise("XSControl_Utils::SeqLength");
return 0;
}
Handle(Standard_Transient) XSControl_Utils::SeqToArr
(const Handle(Standard_Transient)& seqval, const Standard_Integer first) const
{
Standard_Integer i,lng;
Handle(Standard_Transient) val;
if (seqval.IsNull()) return val;
DeclareAndCast(TColStd_HSequenceOfHAsciiString,seqs,seqval);
if (!seqs.IsNull()) {
lng = seqs->Length();
Handle(Interface_HArray1OfHAsciiString) arrs =
new Interface_HArray1OfHAsciiString(first,lng-first+1);
for (i = 1; i <= lng; i ++) arrs->SetValue (i-first+1,seqs->Value(i));
return arrs;
}
DeclareAndCast(TColStd_HSequenceOfTransient,seqt,seqval);
if (!seqt.IsNull()) {
lng = seqt->Length();
Handle(TColStd_HArray1OfTransient) arrt =
new TColStd_HArray1OfTransient(first,lng-first+1);
for (i = 1; i <= lng; i ++) arrt->SetValue (i-first+1,seqt->Value(i));
return arrt;
}
Standard_TypeMismatch::Raise("XSControl_Utils::SeqToArr");
return val;
}
Handle(Standard_Transient) XSControl_Utils::ArrToSeq
(const Handle(Standard_Transient)& arrval) const
{
Standard_Integer i,first,last;
Handle(Standard_Transient) val;
if (arrval.IsNull()) return val;
DeclareAndCast(Interface_HArray1OfHAsciiString,arrs,arrval);
if (!arrs.IsNull()) {
first = arrs->Lower();
last = arrs->Upper();
Handle(TColStd_HSequenceOfHAsciiString) seqs =
new TColStd_HSequenceOfHAsciiString();
for (i = first; i <= last; i ++) seqs->Append (arrs->Value(i));
return seqs;
}
DeclareAndCast(TColStd_HArray1OfTransient,arrt,arrval);
if (!arrt.IsNull()) {
first = arrt->Lower();
last = arrt->Upper();
Handle(TColStd_HSequenceOfTransient) seqt =
new TColStd_HSequenceOfTransient();
for (i = first; i <= last; i ++) seqt->Append (arrt->Value(i));
return seqt;
}
Standard_TypeMismatch::Raise("XSControl_Utils::ArrToSeq");
return val;
}
Standard_Integer XSControl_Utils::SeqIntValue
(const Handle(TColStd_HSequenceOfInteger)& seqval,
const Standard_Integer num) const
{
if (seqval.IsNull()) return 0;
return seqval->Value(num);
}

View File

@@ -0,0 +1,60 @@
-- File: XSControl_Vars.cdl
-- Created: Wed Jul 22 16:05:57 1998
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class Vars from XSControl inherits TShared from MMgt
---Purpose : Defines a receptacle for externally defined variables, each
-- one has a name
--
-- I.E. a WorkSession for XSTEP is generally used inside a
-- context, which brings variables, especially shapes and
-- geometries. For instance DRAW or an application engine
--
-- This class provides a common form for this. It also provides
-- a default implementation (locally recorded variables in a
-- dictionary), but which is aimed to be redefined
uses CString, Transient, DictionaryOfTransient,
Pnt from gp, Pnt2d from gp,
Geometry from Geom, Curve from Geom, Curve from Geom2d, Surface from Geom,
Shape from TopoDS
is
Create returns mutable Vars;
Set (me : mutable; name : CString; val : Transient) is virtual;
Get (me; name : in out CString) returns Transient is virtual;
GetGeom (me; name : in out CString) returns Geometry is virtual;
GetCurve2d (me; name : in out CString) returns Curve from Geom2d is virtual;
GetCurve (me; name : in out CString) returns Curve from Geom is virtual;
GetSurface (me; name : in out CString) returns Surface from Geom is virtual;
SetPoint (me : mutable; name : CString; val : Pnt from gp) is virtual;
SetPoint2d (me : mutable; name : CString; val : Pnt2d from gp) is virtual;
GetPoint (me; name : in out CString; pnt : out Pnt from gp) returns Boolean is virtual;
GetPoint2d (me; name : in out CString; pnt : out Pnt2d from gp) returns Boolean is virtual;
SetShape (me : mutable; name : CString; val : Shape from TopoDS) is virtual;
GetShape (me; name : in out CString) returns Shape from TopoDS is virtual;
fields
thevars : DictionaryOfTransient;
end Vars;

View File

@@ -0,0 +1,72 @@
#include <XSControl_Vars.ixx>
#include <Geom_CartesianPoint.hxx>
#include <Geom2d_CartesianPoint.hxx>
#include <TopoDS_HShape.hxx>
#include <Interface_Macros.hxx>
XSControl_Vars::XSControl_Vars ()
{ thevars = new Dico_DictionaryOfTransient; }
void XSControl_Vars::Set
(const Standard_CString name,
const Handle(Standard_Transient)& val)
{
thevars->SetItem (name,val);
}
Handle(Standard_Transient) XSControl_Vars::Get ( Standard_CString& name) const
{
Handle(Standard_Transient) val;
if (!thevars->GetItem (name,val)) val.Nullify();
return val;
}
Handle(Geom_Geometry) XSControl_Vars::GetGeom ( Standard_CString& name) const
{ return GetCasted(Geom_Geometry,Get(name)); }
Handle(Geom2d_Curve) XSControl_Vars::GetCurve2d ( Standard_CString& name) const
{ return GetCasted(Geom2d_Curve,Get(name)); }
Handle(Geom_Curve) XSControl_Vars::GetCurve ( Standard_CString& name) const
{ return GetCasted(Geom_Curve,Get(name)); }
Handle(Geom_Surface) XSControl_Vars::GetSurface ( Standard_CString& name) const
{ return GetCasted(Geom_Surface,Get(name)); }
void XSControl_Vars::SetPoint (const Standard_CString name, const gp_Pnt& val)
{ Set (name, new Geom_CartesianPoint(val)); }
Standard_Boolean XSControl_Vars::GetPoint (Standard_CString& name, gp_Pnt& pnt) const
{
DeclareAndCast(Geom_CartesianPoint,val,Get(name));
if (val.IsNull()) return Standard_False;
pnt = val->Pnt();
return Standard_True;
}
void XSControl_Vars::SetPoint2d (const Standard_CString name, const gp_Pnt2d& val)
{ Set (name, new Geom2d_CartesianPoint(val)); }
Standard_Boolean XSControl_Vars::GetPoint2d (Standard_CString& name, gp_Pnt2d& pnt) const
{
DeclareAndCast(Geom2d_CartesianPoint,val,Get(name));
if (val.IsNull()) return Standard_False;
pnt = val->Pnt2d();
return Standard_True;
}
void XSControl_Vars::SetShape (const Standard_CString name, const TopoDS_Shape& val)
{ Set (name, new TopoDS_HShape(val)); }
TopoDS_Shape XSControl_Vars::GetShape (Standard_CString& name) const
{
TopoDS_Shape sh;
DeclareAndCast(TopoDS_HShape,val,Get(name));
if (!val.IsNull()) sh = val->Shape();
return sh;
}

View File

@@ -0,0 +1,226 @@
-- File: XSControl_WorkSession.cdl
-- Created: Thu Jun 1 15:46:28 1995
-- Author: Christian CAILLET
-- <cky@anion>
---Copyright: Matra Datavision 1995
class WorkSession from XSControl inherits WorkSession from IFSelect
---Purpose : This WorkSession completes the basic one, by adding :
-- - use of Controller, with norm selection...
-- - management of transfers (both ways) with auxiliary classes
-- TransferReader and TransferWriter
-- -> these transfers may work with a Context List : its items
-- are given by the user, according to the transfer to be
-- i.e. it is interpreted by the Actors
-- Each item is accessed by a Name
uses CString, Transient, DictionaryOfTransient,
InterfaceModel, CheckIterator,
TransientProcess, FinderProcess,
TransferReader, TransferWriter, Controller, Vars, ReturnStatus,
Messenger from Message,
Shape from TopoDS
is
Create returns mutable WorkSession from XSControl;
ClearData (me : mutable; mode : Integer) is redefined;
---Purpose : In addition to basic ClearData, clears Transfer and Management
-- for interactive use, for mode = 0,1,2 and over 4
-- Plus : mode = 5 to clear Transfers (both ways) only
-- mode = 6 to clear enforced results
-- mode = 7 to clear transfers, results
-- Norm Management --
SelectNorm (me : mutable; normname : CString; profile : CString = "")
returns Boolean;
---Purpose : Selects a Norm defined by its name.
-- A Norm is described and handled by a Controller
-- Returns True if done, False if <normname> is unknown
--
-- A Profile may be set too. If no Profile is provided, the
-- current Profile for this Norm is taken
-- If the asked Profile is not defined for this Norm, it remains
-- in current Profile, returned value is True
SelectProfile (me : mutable; profile : CString) returns Boolean;
---Purpose : Sets a Profile as current for the current Norm
-- Returns True if done, False if <profile> is unknown for this norm
--
-- For more infos on Profile, query the Profile of the Controller
SetController (me : mutable; ctl : mutable Controller);
---Purpose : Selects a Norm defined by its Controller itself
AdaptNorm (me : mutable) is virtual;
---Purpose : This method is called once a new norm has been successfully
-- selected. It can be redefined, default does nothing
SelectedNorm (me; rsc : Boolean = Standard_False) returns CString;
---Purpose : Returns the name of the last Selected Norm. If none is
-- defined, returns an empty string
-- By default, returns the complete name of the norm
-- If <rsc> is True, returns the short name used for resource
NormAdaptor (me) returns mutable Controller;
---Purpose : Returns the norm controller itself
-- Context used for Transfer : it is a DictionaryOfTransient (no control here)
Context (me) returns DictionaryOfTransient;
---Purpose : Returns the current Context List, Null if not defined
-- The Context is given to the TransientProcess for TransferRead
SetAllContext (me : mutable; context : DictionaryOfTransient);
---Purpose : Sets the current Context List, as a whole
-- Sets it to the TransferReader
ClearContext (me : mutable);
---Purpose : Clears the whole current Context (nullifies it)
-- Management and Actions of Transfer (Read) --
-- performed by TransferReader
-- WorkSession adds some useful accesses
-- It is actually oriented to shapes and transient objects
PrintTransferStatus (me; num : Integer; wri : Boolean; S : Messenger from Message)
returns Boolean;
---Purpose : Prints the transfer status of a transferred item, as beeing
-- the Mapped n0 <num>, from MapWriter if <wri> is True, or
-- from MapReader if <wri> is False
-- Returns True when done, False else (i.e. num out of range)
InitTransferReader (me : mutable; mode : Integer);
---Purpose : Sets a Transfer Reader, by internal ways, according mode :
-- 0 recreates it clear, 1 clears it (does not recreate)
-- 2 aligns Roots of TransientProcess from final Results
-- 3 aligns final Results from Roots of TransientProcess
-- 4 begins a new transfer (by BeginTransfer)
-- 5 recreates TransferReader then begins a new transfer
SetTransferReader (me : mutable; TR : mutable TransferReader);
---Purpose : Sets a Transfer Reader, which manages transfers on reading
TransferReader (me) returns mutable TransferReader;
---Purpose : Returns the Transfer Reader, Null if not set
MapReader (me) returns mutable TransientProcess;
---Purpose : Returns the TransientProcess(internal data for TransferReader)
SetMapReader (me : mutable; TP : mutable TransientProcess) returns Boolean;
---Purpose : Changes the Map Reader, i.e. considers that the new one
-- defines the relevant read results (forgets the former ones)
-- Returns True when done, False in case of bad definition, i.e.
-- if Model from TP differs from that of Session
Result (me; ent : Transient; mode : Integer)
returns mutable Transient;
---Purpose : Returns the result attached to a starting entity
-- If <mode> = 0, returns Final Result
-- If <mode> = 1, considers Last Result
-- If <mode> = 2, considers Final, else if absent, Last
-- returns it as Transient, if result is not transient returns
-- the Binder
-- <mode> = 10,11,12 idem but returns the Binder itself
-- (if it is not, e.g. Shape, returns the Binder)
-- <mode> = 20, returns the ResultFromModel
TransferReadOne (me : mutable; ents : Transient) returns Integer;
---Purpose : Commands the transfer of, either one entity, or a list
-- I.E. calls the TransferReader after having analysed <ents>
-- It is cumulated from the last BeginTransfer
-- <ents> is processed by GiveList, hence :
-- - <ents> a Selection : its SelectionResult
-- - <ents> a HSequenceOfTransient : this list
-- - <ents> the Model : in this specific case, all the roots,
-- with no cumulation of former transfers (TransferReadRoots)
TransferReadRoots (me : mutable) returns Integer;
---Purpose : Commands the transfer of all the root entities of the model
-- i.e. calls TransferRoot from the TransferReader with the Graph
-- No cumulation with former calls to TransferReadOne
-- Other actions : see the class TransferReader
-- BeginTransferRead (me : mutable) returns Boolean; and
-- RecognizeRead (me : mutable; ent : Transient) see TransferReader
-- TransferReadOne (me : mutable; ents : Transient) -> TransferOne/List
-- TransferReadRoots (me : mutable) returns Integer;
-- TransferReadCheckList (me) returns CheckIterator; -> LastCheckList
-- TransferReadCheckOne (me; ent : Transient; level : Integer = 0)
-- -> CheckList avec en plus level = -1 (last)
-- TransferredReadList (me; ents : Transient; -> CheckedList
-- withcheck : Integer = 0; level : Integer = 0) withcheck a change
-- TransferReadClear (me : mutable; ents : Transient; level : Integer = 0);
-- ShapeResultList (me : mutable) returns HSequenceOfShape from TopTools;
-- + rec : Boolean (recorded/last)
-- Management of Transfer (Write) --
-- It is actually oriented to shapes
NewModel (me : mutable) returns mutable InterfaceModel from Interface;
---Purpose : produces and returns a new Model well conditionned
-- It is produced by the Norm Controller
-- It can be Null (if this function is not implemented)
TransferWriter (me) returns mutable TransferWriter;
---Purpose : Returns the Transfer Reader, Null if not set
MapWriter (me) returns mutable FinderProcess;
---Purpose : Returns the FinderProcess (internal data for TransferWriter)
SetMapWriter (me : mutable; FP : mutable FinderProcess) returns Boolean;
---Purpose : Changes the Map Reader, i.e. considers that the new one
-- defines the relevant read results (forgets the former ones)
-- Returns True when done, False if <FP> is Null
SetModeWriteShape (me : mutable; mode : Integer);
---Purpose : Sets a mode to transfer Shapes from CasCade to entities of the
-- current norm, which interprets it (see various Controllers)
-- This call form could be later replaced by a more general one
ModeWriteShape (me) returns Integer;
---Purpose : Records the current Mode to Write Shapes
TransferWriteShape (me : mutable; shape : Shape from TopoDS;
compgraph : Boolean = Standard_True)
returns ReturnStatus;
---Purpose : Transfers a Shape from CasCade to a model of current norm,
-- according to the last call to SetModeWriteShape
-- Returns status :Done if OK, Fail if error during transfer,
-- Error if transfer badly initialised
TransferWriteCheckList (me) returns CheckIterator;
---Purpose : Returns the check-list of last transfer (write)
-- It is recorded in the FinderProcess, but it must be bound with
-- resulting entities (in the resulting file model) rather than
-- with original objects (in fact, their mappers)
Vars (me) returns Vars;
SetVars (me : mutable; newvars : Vars);
ClearBinders (me : mutable);
---Purpose : Clears binders
Destroy(me: mutable)
---C++: alias ~
is static;
fields
theController : Controller;
theTransferRead : TransferReader from XSControl;
theTransferWrite : TransferWriter from XSControl;
theContext : DictionaryOfTransient;
theModeWriteShape : Integer;
theVars : Vars;
end WorkSession;

View File

@@ -0,0 +1,683 @@
//:i1 pdn 03.04.99 BUC60301
#include <XSControl_WorkSession.ixx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <Interface_HGraph.hxx>
#include <Interface_Graph.hxx>
#include <IFSelect_Profile.hxx>
#include <Transfer_TransientProcess.hxx>
#include <Transfer_ResultFromModel.hxx>
#include <Transfer_ResultFromTransient.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <TransferBRep.hxx>
#include <Transfer_Binder.hxx>
#include <Transfer_Finder.hxx>
#include <Transfer_SimpleBinderOfTransient.hxx>
// tpent
#include <Interface_IntVal.hxx>
#include <Geom2d_Point.hxx>
#include <Dico_DictionaryOfTransient.hxx>
#include <Dico_IteratorOfDictionaryOfTransient.hxx>
#include <Interface_Macros.hxx>
#include <Interface_Check.hxx>
#include <Message_Messenger.hxx>
//=======================================================================
//function : XSControl_WorkSession
//purpose :
//=======================================================================
XSControl_WorkSession::XSControl_WorkSession ()
{
theModeWriteShape = 0;
theTransferRead = new XSControl_TransferReader;
theTransferWrite = new XSControl_TransferWriter;
theVars = new XSControl_Vars;
}
//=======================================================================
//function : ClearData
//purpose :
//=======================================================================
void XSControl_WorkSession::ClearData (const Standard_Integer mode)
{
// 1-2-3-4 : standard IFSelect
if (mode >= 1 && mode <= 4) IFSelect_WorkSession::ClearData (mode);
// 5 : Transferts seuls
// 6 : Resultats forces seuls
// 7 : Management, y compris tous transferts (forces/calcules), views
if (mode == 5 || mode == 7) {
theTransferRead->Clear(-1);
theTransferWrite->Clear(-1);
}
if (mode == 6 && !theTransferRead.IsNull()) theTransferRead->Clear(1);
theTransferRead->SetGraph (HGraph());
}
//=======================================================================
//function : SelectNorm
//purpose :
//=======================================================================
Standard_Boolean XSControl_WorkSession::SelectNorm(const Standard_CString normname,
const Standard_CString profile)
{
// RAZ ancienne norme et resultats
theTransferRead->Clear(-1);
// ???? En toute rigueur, menage a faire dans XWS : virer les items
// ( a la limite, pourquoi pas, refaire XWS en entier)
Handle(XSControl_Controller) newadapt =
XSControl_Controller::Recorded (normname);
if (newadapt.IsNull()) return Standard_False;
if (newadapt == theController) return Standard_True;
SetController (newadapt);
if (profile && profile[0] != '\0') newadapt->Profile()->SetCurrent(profile);
// cout<<"##########################\n"
// <<"## Select Norm : "<<normname<<"\n"
// <<"##########################"<<endl;
return Standard_True;
}
//=======================================================================
//function : SelectProfile
//purpose :
//=======================================================================
Standard_Boolean XSControl_WorkSession::SelectProfile(const Standard_CString profile)
{
return theController->Profile()->SetCurrent(profile);
}
//=======================================================================
//function : SetController
//purpose :
//=======================================================================
void XSControl_WorkSession::SetController(const Handle(XSControl_Controller)& ctl)
{
theController = ctl;
SetLibrary ( theController->WorkLibrary() );
SetProtocol ( theController->Protocol() );
ClearItems(); ClearFinalModifiers();
ClearShareOut(Standard_False); ClearFile();
Handle(XSControl_WorkSession) aWorkSession = this;
theController->Customise (aWorkSession);
SetSignType ( theController->SignType() );
theTransferRead->SetController (theController);
theTransferWrite->SetController (theController);
AdaptNorm ();
}
//=======================================================================
//function : AdaptNorm
//purpose :
//=======================================================================
void XSControl_WorkSession::AdaptNorm ()
{
}
//=======================================================================
//function : SelectedNorm
//purpose :
//=======================================================================
Standard_CString XSControl_WorkSession::SelectedNorm(const Standard_Boolean rsc) const
{
//JR/Hp :
Standard_CString astr = (Standard_CString ) (theController.IsNull() ? "" : theController->Name(rsc));
return astr ;
}
// { return (theController.IsNull() ? "" : theController->Name(rsc)); }
//=======================================================================
//function : NormAdaptor
//purpose :
//=======================================================================
Handle(XSControl_Controller) XSControl_WorkSession::NormAdaptor () const
{
return theController;
}
// ##########################################
// ############ Contexte de Transfert ######
// ##########################################
//=======================================================================
//function : Context
//purpose :
//=======================================================================
Handle(Dico_DictionaryOfTransient) XSControl_WorkSession::Context () const
{
return theContext;
}
//=======================================================================
//function : SetAllContext
//purpose :
//=======================================================================
void XSControl_WorkSession::SetAllContext(const Handle(Dico_DictionaryOfTransient)& context)
{
theContext = context;
theTransferRead->Context() = context;
}
//=======================================================================
//function : ClearContext
//purpose :
//=======================================================================
void XSControl_WorkSession::ClearContext ()
{
Handle(Dico_DictionaryOfTransient) nulctx;
SetAllContext(nulctx);
}
// ##########################################
// ############ RESULTATS FORCES ######
// ##########################################
//=======================================================================
//function : PrintTransferStatus
//purpose :
//=======================================================================
Standard_Boolean XSControl_WorkSession::PrintTransferStatus(const Standard_Integer num,
const Standard_Boolean wri,
const Handle(Message_Messenger)& S) const
{
Handle(Transfer_FinderProcess) FP = MapWriter();
Handle(Transfer_TransientProcess) TP = MapReader();
Handle(Transfer_Binder) binder;
Handle(Transfer_Finder) finder;
Handle(Standard_Transient) ent;
// *** WRITE ***
if (wri) {
if (FP.IsNull()) return Standard_False;
if (num == 0 ) return Standard_False;
Standard_Integer ne=0, nr=0, max = FP->NbMapped() ,maxr = FP->NbRoots();
if (num > 0) {
if (num > max) return Standard_False;
ne = num;
finder = FP->Mapped(ne);
nr = FP->RootIndex(finder);
} else if (num < 0) {
nr = -num;
if (nr > maxr) return Standard_False;
finder = FP->Root(nr);
ne = FP->MapIndex(finder);
}
S<<"Transfer Write item n0."<<ne<<" of "<<max;
if (nr > 0) S<<" ** Transfer Root n0."<<ne; S<<endl;
ent = FP->FindTransient(finder);
S<<" -> Type "<<finder->DynamicType()->Name()<<endl;
FP->StartTrace (binder,finder,0,0); // pb sout/S
if (!ent.IsNull()) {
S<<" ** Resultat Transient, type "<<ent->DynamicType()->Name();
Handle(Interface_InterfaceModel) model = Model();
if (!model.IsNull())
{ S<<" In output Model, Entity "; model->Print(ent,S); }
S<<endl;
}
}
// *** READ ***
else {
if (TP.IsNull()) return Standard_False;
Handle(Interface_InterfaceModel) model = TP->Model();
if (model.IsNull()) cout<<"No Model"<<endl;
else if (model != Model()) cout<<"Model different from the session"<<endl;
if (num == 0) return Standard_False;
Standard_Integer ne=0, nr=0, max = TP->NbMapped() ,maxr = TP->NbRoots();
if (num > 0) {
if (num > max) return Standard_False;
ne = num;
ent = TP->Mapped(ne);
nr = TP->RootIndex(finder);
} else if (num < 0) {
nr = -num;
if (nr > maxr) return Standard_False;
ent = TP->Root(nr);
ne = TP->MapIndex(ent);
}
S<<"Transfer Read item n0."<<ne<<" of "<<max;
if (nr > 0) S<<" ** Transfer Root n0."<<ne; S<<endl;
if (!model.IsNull()) { S<<" In Model, Entity "; model->Print(ent,S); }
binder = TP->MapItem (ne);
S<<endl;
TP->StartTrace (binder,ent,0,0);
/*skl
if (!binder.IsNull()) {
// infos complementaires : cas et attributs
Standard_Integer icas, nbcas = binder->NbCases();
if (nbcas > 0) S<<"Recorded Cases : "<<nbcas<<" :";
for (icas = 1; icas <= nbcas; icas ++) S<<" "<<binder->CaseName(icas);
if (nbcas > 0) S<<endl;
Standard_Integer nbatr = 0;
Handle(Dico_DictionaryOfTransient) atrs = binder->AttrList();
Dico_IteratorOfDictionaryOfTransient iatr (atrs);
for (; iatr.More(); iatr.Next()) {
Handle(Standard_Transient) atr = iatr.Value();
if (atr.IsNull()) continue;
if (nbatr == 0) S<<"-- List of Attributes"<<endl;
nbatr ++;
S<<iatr.Name()<<" : ";
DeclareAndCast(Interface_IntVal,intatr,atr);
if (!intatr.IsNull()) S<<"Integer="<<intatr->Value();
DeclareAndCast(Geom2d_Point,realtr,atr);
if (!realtr.IsNull()) S<<"Real="<<realtr->X();
if (intatr.IsNull() && realtr.IsNull()) S<<"Type:"<<atr->DynamicType()->Name();
S<<endl;
}
if (nbatr > 0) S<<"-- Total of Attributes : "<<nbatr<<endl;
}
skl*/
}
// *** CHECK (commun READ+WRITE) ***
if (!binder.IsNull()) {
const Handle(Interface_Check) ch = binder->Check();
Standard_Integer i,nbw = ch->NbWarnings(), nbf = ch->NbFails();
if (nbw > 0) {
S<<" - Warnings : "<<nbw<<" :\n";
for (i = 1; i <= nbw; i ++) S<<ch->CWarning(i)<<endl;
}
if (nbf > 0) {
S<<" - Fails : "<<nbf<<" :\n";
for (i = 1; i <= nbf; i ++) S<<ch->CFail(i)<<endl;
}
}
return Standard_True;
}
//=======================================================================
//function : InitTransferReader
//purpose :
//=======================================================================
void XSControl_WorkSession::InitTransferReader(const Standard_Integer mode)
{
if (mode == 0 || mode == 5) theTransferRead->Clear(-1); // full clear
if (theTransferRead.IsNull()) SetTransferReader (new XSControl_TransferReader);
else SetTransferReader (theTransferRead);
// mode = 0 fait par SetTransferReader suite a Nullify
if (mode == 1) {
if (!theTransferRead.IsNull()) theTransferRead->Clear(-1);
else SetTransferReader (new XSControl_TransferReader);
}
if (mode == 2) {
Handle(Transfer_TransientProcess) TP = theTransferRead->TransientProcess();
if (TP.IsNull()) {
TP = new Transfer_TransientProcess;
theTransferRead->SetTransientProcess(TP);
TP->SetGraph (HGraph());
}
Handle(TColStd_HSequenceOfTransient) lis = theTransferRead->RecordedList();
Standard_Integer i, nb = lis->Length();
for (i = 1; i <= nb; i ++) TP->SetRoot(lis->Value(i));
}
if (mode == 3) {
Handle(Transfer_TransientProcess) TP = theTransferRead->TransientProcess();
if (TP.IsNull()) return;
Standard_Integer i, nb = TP->NbRoots();
for (i = 1; i <= nb; i ++) theTransferRead->RecordResult(TP->Root(i));
}
if (mode == 4 || mode == 5) theTransferRead->BeginTransfer();
}
//=======================================================================
//function : SetTransferReader
//purpose :
//=======================================================================
void XSControl_WorkSession::SetTransferReader(const Handle(XSControl_TransferReader)& TR)
{
if (theTransferRead != TR) //i1 pdn 03.04.99 BUC60301
theTransferRead = TR;
if (TR.IsNull()) return;
TR->SetController (theController);
TR->SetGraph (HGraph());
if (!TR->TransientProcess().IsNull()) return;
Handle(Transfer_TransientProcess) TP = new Transfer_TransientProcess
(Model().IsNull() ? 100 : Model()->NbEntities() + 100);
TP->SetGraph (HGraph());
TP->SetErrorHandle(Standard_True);
TR->SetTransientProcess(TP);
}
//=======================================================================
//function : TransferReader
//purpose :
//=======================================================================
Handle(XSControl_TransferReader) XSControl_WorkSession::TransferReader () const
{
return theTransferRead;
}
//=======================================================================
//function : MapReader
//purpose :
//=======================================================================
Handle(Transfer_TransientProcess) XSControl_WorkSession::MapReader () const
{
return theTransferRead->TransientProcess();
}
//=======================================================================
//function : SetMapReader
//purpose :
//=======================================================================
Standard_Boolean XSControl_WorkSession::SetMapReader
(const Handle(Transfer_TransientProcess)& TP)
{
if ( TP.IsNull()) return Standard_False;
if (TP->Model().IsNull()) TP->SetModel (Model());
TP->SetGraph (HGraph());
if (TP->Model() != Model()) return Standard_False;
// TR ne doit pas bouger, c est un "crochet" pour signatures, selections ...
// En revanche, mieux vaut le RAZ
// Handle(XSControl_TransferReader) TR = new XSControl_TransferReader;
Handle(XSControl_TransferReader) TR = theTransferRead;
TR->Clear(-1);
SetTransferReader (TR); // avec le meme mais le reinitialise
TR->SetTransientProcess (TP); // et prend le nouveau TP
return Standard_True;
}
//=======================================================================
//function : Result
//purpose :
//=======================================================================
Handle(Standard_Transient) XSControl_WorkSession::Result
(const Handle(Standard_Transient)& ent, const Standard_Integer mode) const
{
Standard_Integer ouca = (mode % 10);
Standard_Integer kica = (mode / 10);
Handle(Transfer_Binder) binder;
Handle(Transfer_ResultFromModel) resu;
if (ouca != 1) resu = theTransferRead->FinalResult(ent);
if (mode == 20) return resu;
if (!resu.IsNull()) binder = resu->MainResult()->Binder();
if (binder.IsNull() && ouca > 0)
binder = theTransferRead->TransientProcess()->Find(ent);
if (kica == 1) return binder;
DeclareAndCast(Transfer_SimpleBinderOfTransient,trb,binder);
if (!trb.IsNull()) return trb->Result();
return binder;
}
// ##########################################
// ############ TRANSFERT #############
// ##########################################
//=======================================================================
//function : TransferReadOne
//purpose :
//=======================================================================
Standard_Integer XSControl_WorkSession::TransferReadOne
(const Handle(Standard_Transient)& ent)
{
//Standard_OStream& sout = Interface_TraceFile::Def();
//Standard_Integer level = Interface_TraceFile::DefLevel();
Handle(Interface_InterfaceModel) model = Model();
if (ent == model) return TransferReadRoots();
Handle(TColStd_HSequenceOfTransient) list = GiveList(ent);
if (list->Length() == 1) return theTransferRead->TransferOne(list->Value(1));
else return theTransferRead->TransferList (list);
}
//=======================================================================
//function : TransferReadRoots
//purpose :
//=======================================================================
Standard_Integer XSControl_WorkSession::TransferReadRoots ()
{
return theTransferRead->TransferRoots(Graph());
}
// ##########################################
// ############ TRANSFERT WRITE
// ##########################################
//=======================================================================
//function : NewModel
//purpose :
//=======================================================================
Handle(Interface_InterfaceModel) XSControl_WorkSession::NewModel ()
{
Handle(Interface_InterfaceModel) newmod;
if (theController.IsNull()) return newmod;
newmod = theController->NewModel();
SetModel(newmod);
theTransferWrite->Clear(-1);
return newmod;
}
//=======================================================================
//function : TransferWriter
//purpose :
//=======================================================================
Handle(XSControl_TransferWriter) XSControl_WorkSession::TransferWriter () const
{
return theTransferWrite;
}
//=======================================================================
//function : MapWriter
//purpose :
//=======================================================================
Handle(Transfer_FinderProcess) XSControl_WorkSession::MapWriter () const
{
return theTransferWrite->FinderProcess();
}
//=======================================================================
//function : SetMapWriter
//purpose :
//=======================================================================
Standard_Boolean XSControl_WorkSession::SetMapWriter
(const Handle(Transfer_FinderProcess)& FP)
{
if ( FP.IsNull()) return Standard_False;
theTransferWrite->SetFinderProcess (FP);
return Standard_True;
}
//=======================================================================
//function : SetModeWriteShape
//purpose :
//=======================================================================
void XSControl_WorkSession::SetModeWriteShape(const Standard_Integer mode)
{
theTransferWrite->SetTransferMode(mode);
}
//=======================================================================
//function : ModeWriteShape
//purpose :
//=======================================================================
Standard_Integer XSControl_WorkSession::ModeWriteShape () const
{
return theTransferWrite->TransferMode();
}
//=======================================================================
//function : TransferWriteShape
//purpose :
//=======================================================================
IFSelect_ReturnStatus XSControl_WorkSession::TransferWriteShape
(const TopoDS_Shape& shape, const Standard_Boolean compgraph)
{
IFSelect_ReturnStatus status;
if (theController.IsNull()) return IFSelect_RetError;
Handle(Interface_InterfaceModel) model = Model();
if (model.IsNull()) return IFSelect_RetVoid;
status = theTransferWrite->TransferWriteShape (model,shape);
// qui s occupe de tout, try/catch inclus
//skl insert param compgraph for XDE writing 10.12.2003
if(compgraph) ComputeGraph(Standard_True);
return status;
}
//=======================================================================
//function : TransferWriteCheckList
//purpose :
//=======================================================================
Interface_CheckIterator XSControl_WorkSession::TransferWriteCheckList () const
{
return theTransferWrite->ResultCheckList (Model());
}
//=======================================================================
//function : Vars
//purpose :
//=======================================================================
Handle(XSControl_Vars) XSControl_WorkSession::Vars () const
{
return theVars;
}
//=======================================================================
//function : SetVars
//purpose :
//=======================================================================
void XSControl_WorkSession::SetVars (const Handle(XSControl_Vars)& newvars)
{
theVars = newvars;
}
//=======================================================================
//function : ClearBinders
//purpose :
//=======================================================================
void XSControl_WorkSession::ClearBinders()
{
Handle(Transfer_FinderProcess) FP = theTransferWrite->FinderProcess();
//Due to big number of chains of binders it is necessary to
//collect head binders of each chain in the sequence
TColStd_SequenceOfTransient aSeqBnd;
TColStd_SequenceOfTransient aSeqShapes;
Standard_Integer i =1;
for( ; i <= FP->NbMapped();i++) {
Handle(Transfer_Binder) bnd = FP->MapItem ( i );
if(!bnd.IsNull())
aSeqBnd.Append(bnd);
Handle(Standard_Transient) ash = FP->Mapped(i);
aSeqShapes.Append(ash);
}
//removing finder process containing result of translation.
FP->Clear();
ClearData(1);
ClearData(5);
//removing each chain of binders
while(aSeqBnd.Length() >0) {
Handle(Transfer_Binder) aBnd = Handle(Transfer_Binder)::DownCast(aSeqBnd.Value(1));
Handle(Standard_Transient) ash =aSeqShapes.Value(1);
aSeqBnd.Remove(1);
aSeqShapes.Remove(1);
ash.Nullify();
while(!aBnd.IsNull()) {
Handle(Transfer_Binder) aBndNext = aBnd->NextResult();
aBnd.Nullify();
aBnd = aBndNext;
}
}
}
//=======================================================================
//function : Destroy
//purpose :
//=======================================================================
void XSControl_WorkSession::Destroy()
{
ClearBinders();
}

View File

@@ -0,0 +1,64 @@
-- File: XSControl_Writer.cdl
-- Created: Wed May 14 15:21:58 1997
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class Writer from XSControl
---Purpose : This class gives a simple way to create then write a
-- Model compliant to a given norm, from a Shape
-- The model can then be edited by tools by other appropriate tools
uses CString,
InterfaceModel from Interface, WorkSession from XSControl,
ReturnStatus from IFSelect,
Shape from TopoDS
is
Create returns Writer;
---Purpose : Creates a Writer from scratch
Create (norm : CString) returns Writer;
---Purpose : Creates a Writer from scratch, with a norm name which
-- identifie a Controller
Create (WS : mutable WorkSession from XSControl;
scratch : Boolean = Standard_True) returns Writer;
---Purpose : Creates a Writer from an already existing Session
-- If <scratch> is True (D), clears already recorded data
SetNorm (me : in out; norm : CString) returns Boolean;
---Purpose : Sets a specific norm to <me>
-- Returns True if done, False if <norm> is not available
SetWS (me : in out; WS : mutable WorkSession from XSControl;
scratch : Boolean = Standard_True);
---Purpose : Sets a specific session to <me>
WS (me) returns WorkSession from XSControl;
---Purpose : Returns the session used in <me>
Model (me : in out; newone : Boolean = Standard_False) returns InterfaceModel;
---Purpose : Returns the produced model. Produces a new one if not yet done
-- or if <newone> is True
-- This method allows for instance to edit product or header
-- data before writing
TransferShape (me : in out; sh : Shape from TopoDS; mode : Integer = 0)
returns ReturnStatus;
---Purpose : Transfers a Shape according to the mode
WriteFile (me : in out; filename : CString) returns ReturnStatus;
---Purpose : Writes the produced model
PrintStatsTransfer (me; what : Integer; mode : Integer = 0);
---Purpose : Prints Statistics about Transfer
fields
thesession : WorkSession from XSControl;
end Writer;

View File

@@ -0,0 +1,67 @@
//:i1 gka 03.04.99 BUC60301
#include <XSControl_Writer.ixx>
#include <XSControl_Controller.hxx>
#include <XSControl_TransferWriter.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Interface_Macros.hxx>
XSControl_Writer::XSControl_Writer ()
{
SetWS (new XSControl_WorkSession);
}
XSControl_Writer::XSControl_Writer (const Standard_CString norm)
{
SetNorm (norm);
}
XSControl_Writer::XSControl_Writer
(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch)
{
SetWS (WS,scratch);
}
Standard_Boolean XSControl_Writer::SetNorm (const Standard_CString norm)
{
if (thesession.IsNull()) SetWS (new XSControl_WorkSession);
Standard_Boolean sess = thesession->SelectNorm (norm);
Handle(Interface_InterfaceModel) model = Model (); //:i1 gka 03.04.99 BUC60301
return sess;
}
void XSControl_Writer::SetWS
(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch)
{
thesession = WS;
// Un controller doit etre defini ...
thesession->InitTransferReader(0);
Handle(Interface_InterfaceModel) model = Model (scratch);
}
Handle(XSControl_WorkSession) XSControl_Writer::WS () const
{ return thesession; }
Handle(Interface_InterfaceModel) XSControl_Writer::Model
(const Standard_Boolean newone)
{
Handle(Interface_InterfaceModel) model = thesession->Model();
if (newone || model.IsNull()) model = thesession->NewModel();
return model;
}
IFSelect_ReturnStatus XSControl_Writer::TransferShape
(const TopoDS_Shape& sh, const Standard_Integer mode)
{
thesession->SetModeWriteShape (mode);
return thesession->TransferWriteShape (sh);
}
IFSelect_ReturnStatus XSControl_Writer::WriteFile
(const Standard_CString filename)
{ return thesession->SendAll(filename); }
void XSControl_Writer::PrintStatsTransfer
(const Standard_Integer what, const Standard_Integer mode) const
{ thesession->TransferWriter()->PrintStats (what,mode); }