1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +03:00

0033309: Data Exchange, XS - Update WorkSession to keep reference work sessions

Updated WorkSession to keep reference WS information
This commit is contained in:
dpasukhi
2023-01-06 16:25:51 +00:00
parent fc72568ba9
commit c688fa9262
4 changed files with 247 additions and 279 deletions

View File

@@ -862,6 +862,8 @@ Handle(STEPCAFControl_ExternFile) STEPCAFControl_Reader::ReadExternFile (const S
EF->SetWS(newWS); EF->SetWS(newWS);
EF->SetName(new TCollection_HAsciiString(file)); EF->SetName(new TCollection_HAsciiString(file));
myReader.WS()->AppendReferenceWS(file, newWS);
// read file // read file
EF->SetLoadStatus(sr.ReadFile(fullname)); EF->SetLoadStatus(sr.ReadFile(fullname));

View File

@@ -800,6 +800,7 @@ TopoDS_Shape STEPCAFControl_Writer::TransferExternFiles (const TDF_Label &L,
EF->SetWS ( newWS ); EF->SetWS ( newWS );
EF->SetName ( name ); EF->SetName ( name );
EF->SetLabel ( L ); EF->SetLabel ( L );
Writer().WS()->AppendReferenceWS(name->String(), newWS);
Standard_Integer assemblymode = Interface_Static::IVal ("write.step.assembly"); Standard_Integer assemblymode = Interface_Static::IVal ("write.step.assembly");
Interface_Static::SetCVal ("write.step.assembly", "Off"); Interface_Static::SetCVal ("write.step.assembly", "Off");
const Standard_CString multi = 0; const Standard_CString multi = 0;

View File

@@ -11,11 +11,9 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
//:i1 pdn 03.04.99 BUC60301 #include <XSControl_WorkSession.hxx>
#include <Geom2d_Point.hxx>
#include <Interface_Check.hxx> #include <Interface_Check.hxx>
#include <Interface_HGraph.hxx>
#include <Interface_InterfaceModel.hxx> #include <Interface_InterfaceModel.hxx>
#include <Interface_Macros.hxx> #include <Interface_Macros.hxx>
#include <Message_Messenger.hxx> #include <Message_Messenger.hxx>
@@ -27,78 +25,78 @@
#include <Transfer_TransientProcess.hxx> #include <Transfer_TransientProcess.hxx>
#include <XSControl_Controller.hxx> #include <XSControl_Controller.hxx>
#include <XSControl_TransferReader.hxx> #include <XSControl_TransferReader.hxx>
#include <XSControl_Vars.hxx> #include <XSControl_TransferWriter.hxx>
#include <XSControl_WorkSession.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XSControl_WorkSession,IFSelect_WorkSession) IMPLEMENT_STANDARD_RTTIEXT(XSControl_WorkSession, IFSelect_WorkSession)
//======================================================================= //=======================================================================
//function : XSControl_WorkSession //function : XSControl_WorkSession
//purpose : //purpose :
//======================================================================= //=======================================================================
XSControl_WorkSession::XSControl_WorkSession() :
myTransferReader(new XSControl_TransferReader),
myTransferWriter(new XSControl_TransferWriter)
{}
XSControl_WorkSession::XSControl_WorkSession () //=======================================================================
: myTransferReader(new XSControl_TransferReader), //function : XSControl_WorkSession
myTransferWriter(new XSControl_TransferWriter), //purpose :
myVars(new XSControl_Vars) //=======================================================================
XSControl_WorkSession::~XSControl_WorkSession()
{ {
clearBinders();
} }
//======================================================================= //=======================================================================
//function : ClearData //function : ClearData
//purpose : //purpose :
//======================================================================= //=======================================================================
void XSControl_WorkSession::ClearData(const Standard_Integer mode)
void XSControl_WorkSession::ClearData (const Standard_Integer mode)
{ {
// 1-2-3-4 : standard IFSelect // 1-2-3-4 : standard IFSelect
if (mode >= 1 && mode <= 4) IFSelect_WorkSession::ClearData (mode); if (mode >= 1 && mode <= 4) IFSelect_WorkSession::ClearData(mode);
// 5 : Transferts seuls // 5 : Transferts seuls
// 6 : Resultats forces seuls // 6 : Resultats forces seuls
// 7 : Management, y compris tous transferts (forces/calcules), views // 7 : Management, y compris tous transferts (forces/calcules), views
if (mode == 5 || mode == 7) { if (mode == 5 || mode == 7)
{
myTransferReader->Clear(-1); myTransferReader->Clear(-1);
myTransferWriter->Clear(-1); myTransferWriter->Clear(-1);
} }
if (mode == 6 && !myTransferReader.IsNull()) myTransferReader->Clear(1); if (mode == 6 && !myTransferReader.IsNull()) myTransferReader->Clear(1);
myTransferReader->SetGraph (HGraph()); myTransferReader->SetGraph(HGraph());
} }
//======================================================================= //=======================================================================
//function : SelectNorm //function : SelectNorm
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean XSControl_WorkSession::SelectNorm(const Standard_CString normname)
Standard_Boolean XSControl_WorkSession::SelectNorm(const Standard_CString normname)
{ {
// Old norm and results // Old norm and results
myTransferReader->Clear(-1); myTransferReader->Clear(-1);
// ???? En toute rigueur, menage a faire dans XWS : virer les items // ???? En toute rigueur, menage a faire dans XWS : virer les items
// ( a la limite, pourquoi pas, refaire XWS en entier) // ( a la limite, pourquoi pas, refaire XWS en entier)
Handle(XSControl_Controller) newadapt = XSControl_Controller::Recorded (normname); Handle(XSControl_Controller) newadapt = XSControl_Controller::Recorded(normname);
if (newadapt.IsNull()) return Standard_False; if (newadapt.IsNull()) return Standard_False;
if (newadapt == myController) return Standard_True; if (newadapt == myController) return Standard_True;
SetController (newadapt); SetController(newadapt);
return Standard_True; return Standard_True;
} }
//======================================================================= //=======================================================================
//function : SetController //function : SetController
//purpose : //purpose :
//======================================================================= //=======================================================================
void XSControl_WorkSession::SetController(const Handle(XSControl_Controller)& ctl) void XSControl_WorkSession::SetController(const Handle(XSControl_Controller)& ctl)
{ {
myController = ctl; myController = ctl;
SetLibrary ( myController->WorkLibrary() ); SetLibrary(myController->WorkLibrary());
SetProtocol ( myController->Protocol() ); SetProtocol(myController->Protocol());
ClearItems(); ClearItems();
ClearFinalModifiers(); ClearFinalModifiers();
@@ -107,70 +105,42 @@ void XSControl_WorkSession::SetController(const Handle(XSControl_Controller)& ct
// Set worksession parameters from teh controller // Set worksession parameters from teh controller
Handle(XSControl_WorkSession) aWorkSession(this); Handle(XSControl_WorkSession) aWorkSession(this);
myController->Customise (aWorkSession); myController->Customise(aWorkSession);
myTransferReader->SetController (myController); myTransferReader->SetController(myController);
myTransferWriter->SetController (myController); myTransferWriter->SetController(myController);
} }
//======================================================================= //=======================================================================
//function : SelectedNorm //function : SelectedNorm
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_CString XSControl_WorkSession::SelectedNorm(const Standard_Boolean rsc) const Standard_CString XSControl_WorkSession::SelectedNorm(const Standard_Boolean rsc) const
{ {
//JR/Hp : //JR/Hp :
Standard_CString astr = (Standard_CString ) (myController.IsNull() ? "" : myController->Name(rsc)); Standard_CString astr = (Standard_CString)(myController.IsNull() ? "" : myController->Name(rsc));
return astr ; return astr;
} }
// ##########################################
// ############ Contexte de Transfert ######
// ##########################################
//======================================================================= //=======================================================================
//function : SetAllContext //function : SelectedNorm
//purpose : //purpose :
//======================================================================= //=======================================================================
void XSControl_WorkSession::AppendReferenceWS(const TCollection_AsciiString& theName,
void XSControl_WorkSession::SetAllContext(const NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>& context) const Handle(XSControl_WorkSession)& theWS)
{ {
myContext = context; myReferenceWS.Bind(theName, theWS);
myTransferReader->Context() = context;
} }
//=======================================================================
//function : ClearContext
//purpose :
//=======================================================================
void XSControl_WorkSession::ClearContext ()
{
myContext.Clear();
myTransferReader->Context().Clear();
}
// ##########################################
// ############ RESULTATS FORCES ######
// ##########################################
//======================================================================= //=======================================================================
//function : PrintTransferStatus //function : PrintTransferStatus
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean XSControl_WorkSession::PrintTransferStatus(const Standard_Integer num,
Standard_Boolean XSControl_WorkSession::PrintTransferStatus(const Standard_Integer num, const Standard_Boolean wri,
const Standard_Boolean wri, Standard_OStream& S) const
Standard_OStream& S) const
{ {
const Handle(Transfer_FinderProcess) &FP = myTransferWriter->FinderProcess(); const Handle(Transfer_FinderProcess)& FP = myTransferWriter->FinderProcess();
Handle(Transfer_TransientProcess) TP = myTransferReader->TransientProcess(); Handle(Transfer_TransientProcess) TP = myTransferReader->TransientProcess();
Handle(Transfer_Binder) binder; Handle(Transfer_Binder) binder;
@@ -178,145 +148,159 @@ Standard_Boolean XSControl_WorkSession::PrintTransferStatus(const Standard_Inte
Handle(Standard_Transient) ent; Handle(Standard_Transient) ent;
// *** WRITE *** // *** WRITE ***
if (wri) { if (wri)
{
if (FP.IsNull()) return Standard_False; if (FP.IsNull()) return Standard_False;
if (num == 0 ) return Standard_False; if (num == 0) return Standard_False;
Standard_Integer ne=0, nr=0, max = FP->NbMapped() ,maxr = FP->NbRoots(); Standard_Integer ne = 0, nr = 0, max = FP->NbMapped(), maxr = FP->NbRoots();
if (num > 0) { if (num > 0)
{
if (num > max) return Standard_False; if (num > max) return Standard_False;
ne = num; ne = num;
finder = FP->Mapped(ne); finder = FP->Mapped(ne);
nr = FP->RootIndex(finder); nr = FP->RootIndex(finder);
} else if (num < 0) { }
else if (num < 0)
{
nr = -num; nr = -num;
if (nr > maxr) return Standard_False; if (nr > maxr) return Standard_False;
finder = FP->Root(nr); finder = FP->Root(nr);
ne = FP->MapIndex(finder); ne = FP->MapIndex(finder);
} }
S<<"Transfer Write item n0."<<ne<<" of "<<max; S << "Transfer Write item n0." << ne << " of " << max;
if (nr > 0) if (nr > 0)
{ {
S<<" ** Transfer Root n0."<<ne; S << " ** Transfer Root n0." << ne;
} }
S<<std::endl; S << std::endl;
ent = FP->FindTransient(finder); ent = FP->FindTransient(finder);
S<<" -> Type "<<finder->DynamicType()->Name()<<std::endl; S << " -> Type " << finder->DynamicType()->Name() << std::endl;
FP->StartTrace (binder,finder,0,0); // pb sout/S FP->StartTrace(binder, finder, 0, 0); // pb sout/S
if (!ent.IsNull()) { if (!ent.IsNull())
S<<" ** Resultat Transient, type "<<ent->DynamicType()->Name(); {
const Handle(Interface_InterfaceModel) &model = Model(); S << " ** Resultat Transient, type " << ent->DynamicType()->Name();
const Handle(Interface_InterfaceModel)& model = Model();
if (!model.IsNull()) if (!model.IsNull())
{ S<<" In output Model, Entity "; model->Print(ent, S); } {
S<<std::endl; S << " In output Model, Entity "; model->Print(ent, S);
}
S << std::endl;
} }
} }
// *** READ *** // *** READ ***
else { else
{
if (TP.IsNull()) return Standard_False; if (TP.IsNull()) return Standard_False;
Handle(Interface_InterfaceModel) model = TP->Model(); Handle(Interface_InterfaceModel) model = TP->Model();
if (model.IsNull()) std::cout<<"No Model"<<std::endl; if (model.IsNull()) std::cout << "No Model" << std::endl;
else if (model != Model()) std::cout<<"Model different from the session"<<std::endl; else if (model != Model()) std::cout << "Model different from the session" << std::endl;
if (num == 0) return Standard_False; if (num == 0) return Standard_False;
Standard_Integer ne=0, nr=0, max = TP->NbMapped() ,maxr = TP->NbRoots(); Standard_Integer ne = 0, nr = 0, max = TP->NbMapped(), maxr = TP->NbRoots();
if (num > 0) { if (num > 0)
{
if (num > max) return Standard_False; if (num > max) return Standard_False;
ne = num; ne = num;
ent = TP->Mapped(ne); ent = TP->Mapped(ne);
nr = TP->RootIndex(finder); nr = TP->RootIndex(finder);
} else if (num < 0) { }
else if (num < 0)
{
nr = -num; nr = -num;
if (nr > maxr) return Standard_False; if (nr > maxr) return Standard_False;
ent = TP->Root(nr); ent = TP->Root(nr);
ne = TP->MapIndex(ent); ne = TP->MapIndex(ent);
} }
S<<"Transfer Read item n0."<<ne<<" of "<<max; S << "Transfer Read item n0." << ne << " of " << max;
if (nr > 0) if (nr > 0)
{ {
S<<" ** Transfer Root n0."<<ne; S << " ** Transfer Root n0." << ne;
} }
S<<std::endl; S << std::endl;
if (!model.IsNull()) { S<<" In Model, Entity "; model->Print(ent, S); } if (!model.IsNull()) { S << " In Model, Entity "; model->Print(ent, S); }
binder = TP->MapItem (ne); binder = TP->MapItem(ne);
S<<std::endl; S << std::endl;
TP->StartTrace (binder,ent,0,0); TP->StartTrace(binder, ent, 0, 0);
} }
// *** CHECK (commun READ+WRITE) *** // *** CHECK (commun READ+WRITE) ***
if (!binder.IsNull()) { if (!binder.IsNull())
{
const Handle(Interface_Check) ch = binder->Check(); const Handle(Interface_Check) ch = binder->Check();
Standard_Integer i,nbw = ch->NbWarnings(), nbf = ch->NbFails(); Standard_Integer i, nbw = ch->NbWarnings(), nbf = ch->NbFails();
if (nbw > 0) { if (nbw > 0)
S<<" - Warnings : "<<nbw<<" :\n"; {
for (i = 1; i <= nbw; i ++) S<<ch->CWarning(i)<<std::endl; S << " - Warnings : " << nbw << " :\n";
for (i = 1; i <= nbw; i++) S << ch->CWarning(i) << std::endl;
} }
if (nbf > 0) { if (nbf > 0)
S<<" - Fails : "<<nbf<<" :\n"; {
for (i = 1; i <= nbf; i ++) S<<ch->CFail(i)<<std::endl; S << " - Fails : " << nbf << " :\n";
for (i = 1; i <= nbf; i++) S << ch->CFail(i) << std::endl;
} }
} }
return Standard_True; return Standard_True;
} }
//======================================================================= //=======================================================================
//function : InitTransferReader //function : InitTransferReader
//purpose : //purpose :
//======================================================================= //=======================================================================
void XSControl_WorkSession::InitTransferReader(const Standard_Integer mode)
void XSControl_WorkSession::InitTransferReader(const Standard_Integer mode)
{ {
if (mode == 0 || mode == 5) myTransferReader->Clear(-1); // full clear if (mode == 0 || mode == 5) myTransferReader->Clear(-1); // full clear
if (myTransferReader.IsNull()) SetTransferReader (new XSControl_TransferReader); if (myTransferReader.IsNull()) SetTransferReader(new XSControl_TransferReader);
else SetTransferReader (myTransferReader); else SetTransferReader(myTransferReader);
// mode = 0 fait par SetTransferReader suite a Nullify // mode = 0 fait par SetTransferReader suite a Nullify
if (mode == 1) { if (mode == 1)
{
if (!myTransferReader.IsNull()) myTransferReader->Clear(-1); if (!myTransferReader.IsNull()) myTransferReader->Clear(-1);
else SetTransferReader (new XSControl_TransferReader); else SetTransferReader(new XSControl_TransferReader);
} }
if (mode == 2) { if (mode == 2)
{
Handle(Transfer_TransientProcess) TP = myTransferReader->TransientProcess(); Handle(Transfer_TransientProcess) TP = myTransferReader->TransientProcess();
if (TP.IsNull()) { if (TP.IsNull())
{
TP = new Transfer_TransientProcess; TP = new Transfer_TransientProcess;
myTransferReader->SetTransientProcess(TP); myTransferReader->SetTransientProcess(TP);
TP->SetGraph (HGraph()); TP->SetGraph(HGraph());
} }
Handle(TColStd_HSequenceOfTransient) lis = myTransferReader->RecordedList(); Handle(TColStd_HSequenceOfTransient) lis = myTransferReader->RecordedList();
Standard_Integer i, nb = lis->Length(); Standard_Integer i, nb = lis->Length();
for (i = 1; i <= nb; i ++) TP->SetRoot(lis->Value(i)); for (i = 1; i <= nb; i++) TP->SetRoot(lis->Value(i));
} }
if (mode == 3) { if (mode == 3)
{
Handle(Transfer_TransientProcess) TP = myTransferReader->TransientProcess(); Handle(Transfer_TransientProcess) TP = myTransferReader->TransientProcess();
if (TP.IsNull()) return; if (TP.IsNull()) return;
Standard_Integer i, nb = TP->NbRoots(); Standard_Integer i, nb = TP->NbRoots();
for (i = 1; i <= nb; i ++) myTransferReader->RecordResult(TP->Root(i)); for (i = 1; i <= nb; i++) myTransferReader->RecordResult(TP->Root(i));
} }
if (mode == 4 || mode == 5) myTransferReader->BeginTransfer(); if (mode == 4 || mode == 5) myTransferReader->BeginTransfer();
} }
//======================================================================= //=======================================================================
//function : SetTransferReader //function : SetTransferReader
//purpose : //purpose :
//======================================================================= //=======================================================================
void XSControl_WorkSession::SetTransferReader(const Handle(XSControl_TransferReader)& TR) void XSControl_WorkSession::SetTransferReader(const Handle(XSControl_TransferReader)& TR)
{ {
if (myTransferReader != TR) //i1 pdn 03.04.99 BUC60301 if (myTransferReader != TR) //i1 pdn 03.04.99 BUC60301
myTransferReader = TR; myTransferReader = TR;
if (TR.IsNull()) return; if (TR.IsNull()) return;
TR->SetController (myController); TR->SetController(myController);
TR->SetGraph (HGraph()); TR->SetGraph(HGraph());
if (!TR->TransientProcess().IsNull()) return; if (!TR->TransientProcess().IsNull()) return;
Handle(Transfer_TransientProcess) TP = new Transfer_TransientProcess Handle(Transfer_TransientProcess) TP = new Transfer_TransientProcess
(Model().IsNull() ? 100 : Model()->NbEntities() + 100); (Model().IsNull() ? 100 : Model()->NbEntities() + 100);
TP->SetGraph (HGraph()); TP->SetGraph(HGraph());
TP->SetErrorHandle(Standard_True); TP->SetErrorHandle(Standard_True);
TR->SetTransientProcess(TP); TR->SetTransientProcess(TP);
} }
@@ -325,7 +309,6 @@ void XSControl_WorkSession::SetTransferReader(const Handle(XSControl_TransferRea
//function : MapReader //function : MapReader
//purpose : //purpose :
//======================================================================= //=======================================================================
Handle(Transfer_TransientProcess) XSControl_WorkSession::MapReader() const Handle(Transfer_TransientProcess) XSControl_WorkSession::MapReader() const
{ {
return myTransferReader->TransientProcess(); return myTransferReader->TransientProcess();
@@ -333,34 +316,31 @@ Handle(Transfer_TransientProcess) XSControl_WorkSession::MapReader() const
//======================================================================= //=======================================================================
//function : SetMapReader //function : SetMapReader
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean XSControl_WorkSession::SetMapReader(const Handle(Transfer_TransientProcess)& TP)
Standard_Boolean XSControl_WorkSession::SetMapReader (const Handle(Transfer_TransientProcess)& TP)
{ {
if (TP.IsNull()) return Standard_False; if (TP.IsNull()) return Standard_False;
if (TP->Model().IsNull()) TP->SetModel (Model()); if (TP->Model().IsNull()) TP->SetModel(Model());
TP->SetGraph (HGraph()); TP->SetGraph(HGraph());
if (TP->Model() != Model()) return Standard_False; if (TP->Model() != Model()) return Standard_False;
// TR ne doit pas bouger, c est un "crochet" pour signatures, selections ... // TR ne doit pas bouger, c est un "crochet" pour signatures, selections ...
// En revanche, mieux vaut le RAZ // En revanche, mieux vaut le RAZ
// Handle(XSControl_TransferReader) TR = new XSControl_TransferReader; // Handle(XSControl_TransferReader) TR = new XSControl_TransferReader;
Handle(XSControl_TransferReader) TR = myTransferReader; Handle(XSControl_TransferReader) TR = myTransferReader;
TR->Clear(-1); TR->Clear(-1);
SetTransferReader (TR); // avec le meme mais le reinitialise SetTransferReader(TR); // avec le meme mais le reinitialise
TR->SetTransientProcess (TP); // et prend le nouveau TP TR->SetTransientProcess(TP); // et prend le nouveau TP
return Standard_True; return Standard_True;
} }
//======================================================================= //=======================================================================
//function : Result //function : Result
//purpose : //purpose :
//======================================================================= //=======================================================================
Handle(Standard_Transient) XSControl_WorkSession::Result(const Handle(Standard_Transient)& ent,
Handle(Standard_Transient) XSControl_WorkSession::Result const Standard_Integer mode) const
(const Handle(Standard_Transient)& ent, const Standard_Integer mode) const
{ {
Standard_Integer ouca = (mode % 10); Standard_Integer ouca = (mode % 10);
Standard_Integer kica = (mode / 10); Standard_Integer kica = (mode / 10);
@@ -368,7 +348,7 @@ Handle(Standard_Transient) XSControl_WorkSession::Result
Handle(Transfer_Binder) binder; Handle(Transfer_Binder) binder;
Handle(Transfer_ResultFromModel) resu; Handle(Transfer_ResultFromModel) resu;
if (ouca != 1) resu = myTransferReader->FinalResult(ent); if (ouca != 1) resu = myTransferReader->FinalResult(ent);
if (mode == 20) return resu; if (mode == 20) return resu;
if (!resu.IsNull()) binder = resu->MainResult()->Binder(); if (!resu.IsNull()) binder = resu->MainResult()->Binder();
@@ -376,23 +356,17 @@ Handle(Standard_Transient) XSControl_WorkSession::Result
binder = myTransferReader->TransientProcess()->Find(ent); binder = myTransferReader->TransientProcess()->Find(ent);
if (kica == 1) return binder; if (kica == 1) return binder;
DeclareAndCast(Transfer_SimpleBinderOfTransient,trb,binder); DeclareAndCast(Transfer_SimpleBinderOfTransient, trb, binder);
if (!trb.IsNull()) return trb->Result(); if (!trb.IsNull()) return trb->Result();
return binder; return binder;
} }
// ##########################################
// ############ TRANSFERT #############
// ##########################################
//======================================================================= //=======================================================================
//function : TransferReadOne //function : TransferReadOne
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Integer XSControl_WorkSession::TransferReadOne(const Handle(Standard_Transient)& ent,
Standard_Integer XSControl_WorkSession::TransferReadOne (const Handle(Standard_Transient)& ent, const Message_ProgressRange& theProgress)
const Message_ProgressRange& theProgress)
{ {
Handle(Interface_InterfaceModel) model = Model(); Handle(Interface_InterfaceModel) model = Model();
if (ent == model) return TransferReadRoots(theProgress); if (ent == model) return TransferReadRoots(theProgress);
@@ -401,38 +375,30 @@ Standard_Integer XSControl_WorkSession::TransferReadOne (const Handle(Standard_T
if (list->Length() == 1) if (list->Length() == 1)
return myTransferReader->TransferOne(list->Value(1), Standard_True, theProgress); return myTransferReader->TransferOne(list->Value(1), Standard_True, theProgress);
else else
return myTransferReader->TransferList (list, Standard_True, theProgress); return myTransferReader->TransferList(list, Standard_True, theProgress);
} }
//======================================================================= //=======================================================================
//function : TransferReadRoots //function : TransferReadRoots
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Integer XSControl_WorkSession::TransferReadRoots(const Message_ProgressRange& theProgress)
Standard_Integer XSControl_WorkSession::TransferReadRoots (const Message_ProgressRange& theProgress)
{ {
return myTransferReader->TransferRoots(Graph(), theProgress); return myTransferReader->TransferRoots(Graph(), theProgress);
} }
// ##########################################
// ############ TRANSFERT WRITE
// ##########################################
//======================================================================= //=======================================================================
//function : NewModel //function : NewModel
//purpose : //purpose :
//======================================================================= //=======================================================================
Handle(Interface_InterfaceModel) XSControl_WorkSession::NewModel()
Handle(Interface_InterfaceModel) XSControl_WorkSession::NewModel ()
{ {
Handle(Interface_InterfaceModel) newmod; Handle(Interface_InterfaceModel) newmod;
if (myController.IsNull()) return newmod; if (myController.IsNull()) return newmod;
newmod = myController->NewModel(); newmod = myController->NewModel();
SetModel(newmod); SetModel(newmod);
if(!myTransferReader->TransientProcess().IsNull()) if (!myTransferReader->TransientProcess().IsNull())
myTransferReader->TransientProcess()->Clear(); myTransferReader->TransientProcess()->Clear();
//clear all contains of WS //clear all contains of WS
myTransferReader->Clear(3); myTransferReader->Clear(3);
@@ -441,19 +407,37 @@ Handle(Interface_InterfaceModel) XSControl_WorkSession::NewModel ()
return newmod; return newmod;
} }
//=======================================================================
//function : TransferWriter
//purpose :
//=======================================================================
const Handle(XSControl_TransferWriter)& XSControl_WorkSession::TransferWriter() const
{
return myTransferWriter;
}
//=======================================================================
//function : SetMapWriter
//purpose :
//=======================================================================
Standard_Boolean XSControl_WorkSession::SetMapWriter(const Handle(Transfer_FinderProcess)& theFP)
{
if (theFP.IsNull()) return Standard_False;
myTransferWriter->SetFinderProcess(theFP);
return Standard_True;
}
//======================================================================= //=======================================================================
//function : TransferWriteShape //function : TransferWriteShape
//purpose : //purpose :
//======================================================================= //=======================================================================
IFSelect_ReturnStatus XSControl_WorkSession::TransferWriteShape(const TopoDS_Shape& shape,
IFSelect_ReturnStatus XSControl_WorkSession::TransferWriteShape (const TopoDS_Shape& shape, const Standard_Boolean compgraph,
const Standard_Boolean compgraph, const Message_ProgressRange& theProgress)
const Message_ProgressRange& theProgress)
{ {
IFSelect_ReturnStatus status; IFSelect_ReturnStatus status;
if (myController.IsNull()) return IFSelect_RetError; if (myController.IsNull()) return IFSelect_RetError;
const Handle(Interface_InterfaceModel) &model = Model(); const Handle(Interface_InterfaceModel)& model = Model();
if (model.IsNull() || shape.IsNull()) if (model.IsNull() || shape.IsNull())
{ {
return IFSelect_RetVoid; return IFSelect_RetVoid;
@@ -465,61 +449,58 @@ IFSelect_ReturnStatus XSControl_WorkSession::TransferWriteShape (const TopoDS_Sh
// qui s occupe de tout, try/catch inclus // qui s occupe de tout, try/catch inclus
//skl insert param compgraph for XDE writing 10.12.2003 //skl insert param compgraph for XDE writing 10.12.2003
if(compgraph) ComputeGraph(Standard_True); if (compgraph) ComputeGraph(Standard_True);
return status; return status;
} }
//======================================================================= //=======================================================================
//function : TransferWriteCheckList //function : TransferWriteCheckList
//purpose : //purpose :
//======================================================================= //=======================================================================
Interface_CheckIterator XSControl_WorkSession::TransferWriteCheckList() const
Interface_CheckIterator XSControl_WorkSession::TransferWriteCheckList () const
{ {
return myTransferWriter->ResultCheckList (Model()); return myTransferWriter->ResultCheckList(Model());
} }
//======================================================================= //=======================================================================
//function : ClearBinders //function : clearBinders
//purpose : //purpose :
//======================================================================= //=======================================================================
void XSControl_WorkSession::clearBinders()
void XSControl_WorkSession::ClearBinders()
{ {
const Handle(Transfer_FinderProcess) &FP = myTransferWriter->FinderProcess(); const Handle(Transfer_FinderProcess)& FP = myTransferWriter->FinderProcess();
//Due to big number of chains of binders it is necessary to //Due to big number of chains of binders it is necessary to
//collect head binders of each chain in the sequence //collect head binders of each chain in the sequence
TColStd_SequenceOfTransient aSeqBnd; TColStd_SequenceOfTransient aSeqBnd;
TColStd_SequenceOfTransient aSeqShapes; TColStd_SequenceOfTransient aSeqShapes;
Standard_Integer i =1; Standard_Integer i = 1;
for( ; i <= FP->NbMapped();i++) { for (; i <= FP->NbMapped(); i++)
Handle(Transfer_Binder) bnd = FP->MapItem ( i ); {
if(!bnd.IsNull()) Handle(Transfer_Binder) bnd = FP->MapItem(i);
if (!bnd.IsNull())
aSeqBnd.Append(bnd); aSeqBnd.Append(bnd);
Handle(Standard_Transient) ash (FP->Mapped(i)); Handle(Standard_Transient) ash(FP->Mapped(i));
aSeqShapes.Append(ash); aSeqShapes.Append(ash);
} }
//removing finder process containing result of translation. //removing finder process containing result of translation.
FP->Clear(); FP->Clear();
ClearData(1); ClearData(1);
ClearData(5); ClearData(5);
//removing each chain of binders //removing each chain of binders
while(aSeqBnd.Length() >0) { while (aSeqBnd.Length() > 0)
{
Handle(Transfer_Binder) aBnd = Handle(Transfer_Binder)::DownCast(aSeqBnd.Value(1)); Handle(Transfer_Binder) aBnd = Handle(Transfer_Binder)::DownCast(aSeqBnd.Value(1));
Handle(Standard_Transient) ash =aSeqShapes.Value(1); Handle(Standard_Transient) ash = aSeqShapes.Value(1);
aSeqBnd.Remove(1); aSeqBnd.Remove(1);
aSeqShapes.Remove(1); aSeqShapes.Remove(1);
ash.Nullify(); ash.Nullify();
while(!aBnd.IsNull()) { while (!aBnd.IsNull())
{
Handle(Transfer_Binder) aBndNext = aBnd->NextResult(); Handle(Transfer_Binder) aBndNext = aBnd->NextResult();
aBnd.Nullify(); aBnd.Nullify();
aBnd = aBndNext; aBnd = aBndNext;
} }
} }
} }

View File

@@ -22,7 +22,7 @@
#include <IFSelect_WorkSession.hxx> #include <IFSelect_WorkSession.hxx>
#include <IFSelect_ReturnStatus.hxx> #include <IFSelect_ReturnStatus.hxx>
#include <XSControl_TransferWriter.hxx>
class XSControl_Controller; class XSControl_Controller;
class XSControl_TransferReader; class XSControl_TransferReader;
class XSControl_Vars; class XSControl_Vars;
@@ -32,10 +32,11 @@ class Transfer_FinderProcess;
class TopoDS_Shape; class TopoDS_Shape;
class Interface_CheckIterator; class Interface_CheckIterator;
class XSControl_WorkSession; class XSControl_WorkSession;
DEFINE_STANDARD_HANDLE(XSControl_WorkSession, IFSelect_WorkSession) DEFINE_STANDARD_HANDLE(XSControl_WorkSession, IFSelect_WorkSession)
typedef NCollection_DataMap<TCollection_AsciiString, Handle(XSControl_WorkSession)> XSControl_WorkSessionMap;
//! This WorkSession completes the basic one, by adding : //! This WorkSession completes the basic one, by adding :
//! - use of Controller, with norm selection... //! - use of Controller, with norm selection...
//! - management of transfers (both ways) with auxiliary classes //! - management of transfers (both ways) with auxiliary classes
@@ -46,72 +47,66 @@ DEFINE_STANDARD_HANDLE(XSControl_WorkSession, IFSelect_WorkSession)
//! Each item is accessed by a Name //! Each item is accessed by a Name
class XSControl_WorkSession : public IFSelect_WorkSession class XSControl_WorkSession : public IFSelect_WorkSession
{ {
public: public:
Standard_EXPORT XSControl_WorkSession(); Standard_EXPORT XSControl_WorkSession();
~XSControl_WorkSession() Standard_EXPORT ~XSControl_WorkSession();
{ ClearBinders(); }
//! In addition to basic ClearData, clears Transfer and Management //! In addition to basic ClearData, clears Transfer and Management
//! for interactive use, for mode = 0,1,2 and over 4 //! for interactive use, for mode = 0,1,2 and over 4
//! Plus : mode = 5 to clear Transfers (both ways) only //! Plus : mode = 5 to clear Transfers (both ways) only
//! mode = 6 to clear enforced results //! mode = 6 to clear enforced results
//! mode = 7 to clear transfers, results //! mode = 7 to clear transfers, results
Standard_EXPORT virtual void ClearData (const Standard_Integer theMode) Standard_OVERRIDE; Standard_EXPORT virtual void ClearData(const Standard_Integer theMode) Standard_OVERRIDE;
//! Selects a Norm defined by its name. //! Selects a Norm defined by its name.
//! A Norm is described and handled by a Controller //! A Norm is described and handled by a Controller
//! Returns True if done, False if <normname> is unknown //! Returns True if done, False if <normname> is unknown
//! //!
//! The current Profile for this Norm is taken. //! The current Profile for this Norm is taken.
Standard_EXPORT Standard_Boolean SelectNorm (const Standard_CString theNormName); Standard_EXPORT Standard_Boolean SelectNorm(const Standard_CString theNormName);
//! Selects a Norm defined by its Controller itself //! Selects a Norm defined by its Controller itself
Standard_EXPORT void SetController (const Handle(XSControl_Controller)& theCtl); Standard_EXPORT void SetController(const Handle(XSControl_Controller)& theCtl);
//! Returns the name of the last Selected Norm. If none is //! Returns the name of the last Selected Norm. If none is
//! defined, returns an empty string //! defined, returns an empty string
//! By default, returns the complete name of the norm //! By default, returns the complete name of the norm
//! If <rsc> is True, returns the short name used for resource //! If <rsc> is True, returns the short name used for resource
Standard_EXPORT Standard_CString SelectedNorm (const Standard_Boolean theRsc = Standard_False) const; Standard_EXPORT Standard_CString SelectedNorm(const Standard_Boolean theRsc = Standard_False) const;
//! Returns the norm controller itself //! Returns the norm controller itself
const Handle(XSControl_Controller) & NormAdaptor() const const Handle(XSControl_Controller)& NormAdaptor() const { return myController; }
{ return myController; }
//! Returns the current reference WS List, empty if not defined
//! Returns the current Context List, Null if not defined const XSControl_WorkSessionMap& ReferenceWS() const { return myReferenceWS; }
//! The Context is given to the TransientProcess for TransferRead
const NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> & Context() const //! Appends new refrence Work Session
{ return myContext; } Standard_EXPORT void AppendReferenceWS(const TCollection_AsciiString& theName,
const Handle(XSControl_WorkSession)& theWS);
//! Sets the current Context List, as a whole
//! Sets it to the TransferReader
Standard_EXPORT void SetAllContext (const NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>& theContext);
//! Clears the whole current Context (nullifies it)
Standard_EXPORT void ClearContext();
//! Prints the transfer status of a transferred item, as being //! Prints the transfer status of a transferred item, as being
//! the Mapped n0 <num>, from MapWriter if <wri> is True, or //! the Mapped n0 <num>, from MapWriter if <wri> is True, or
//! from MapReader if <wri> is False //! from MapReader if <wri> is False
//! Returns True when done, False else (i.e. num out of range) //! Returns True when done, False else (i.e. num out of range)
Standard_EXPORT Standard_Boolean PrintTransferStatus (const Standard_Integer theNum, const Standard_Boolean theWri, Standard_OStream& theS) const; Standard_EXPORT Standard_Boolean PrintTransferStatus(const Standard_Integer theNum,
const Standard_Boolean theWri,
Standard_OStream& theS) const;
//! Sets a Transfer Reader, by internal ways, according mode : //! Sets a Transfer Reader, by internal ways, according mode :
//! 0 recreates it clear, 1 clears it (does not recreate) //! 0 recreates it clear, 1 clears it (does not recreate)
//! 2 aligns Roots of TransientProcess from final Results //! 2 aligns Roots of TransientProcess from final Results
//! 3 aligns final Results from Roots of TransientProcess //! 3 aligns final Results from Roots of TransientProcess
//! 4 begins a new transfer (by BeginTransfer) //! 4 begins a new transfer (by BeginTransfer)
//! 5 recreates TransferReader then begins a new transfer //! 5 recreates TransferReader then begins a new transfer
Standard_EXPORT void InitTransferReader (const Standard_Integer theMode); Standard_EXPORT void InitTransferReader(const Standard_Integer theMode);
//! Sets a Transfer Reader, which manages transfers on reading //! Sets a Transfer Reader, which manages transfers on reading
Standard_EXPORT void SetTransferReader (const Handle(XSControl_TransferReader)& theTR); Standard_EXPORT void SetTransferReader(const Handle(XSControl_TransferReader)& theTR);
//! Returns the Transfer Reader, Null if not set //! Returns the Transfer Reader, Null if not set
const Handle(XSControl_TransferReader) & TransferReader () const const Handle(XSControl_TransferReader)& TransferReader() const { return myTransferReader; }
{ return myTransferReader; }
//! Returns the TransientProcess(internal data for TransferReader) //! Returns the TransientProcess(internal data for TransferReader)
Standard_EXPORT Handle(Transfer_TransientProcess) MapReader() const; Standard_EXPORT Handle(Transfer_TransientProcess) MapReader() const;
@@ -120,8 +115,8 @@ class XSControl_WorkSession : public IFSelect_WorkSession
//! defines the relevant read results (forgets the former ones) //! defines the relevant read results (forgets the former ones)
//! Returns True when done, False in case of bad definition, i.e. //! Returns True when done, False in case of bad definition, i.e.
//! if Model from TP differs from that of Session //! if Model from TP differs from that of Session
Standard_EXPORT Standard_Boolean SetMapReader (const Handle(Transfer_TransientProcess)& theTP); Standard_EXPORT Standard_Boolean SetMapReader(const Handle(Transfer_TransientProcess)& theTP);
//! Returns the result attached to a starting entity //! Returns the result attached to a starting entity
//! If <mode> = 0, returns Final Result //! If <mode> = 0, returns Final Result
//! If <mode> = 1, considers Last Result //! If <mode> = 1, considers Last Result
@@ -131,8 +126,9 @@ class XSControl_WorkSession : public IFSelect_WorkSession
//! <mode> = 10,11,12 idem but returns the Binder itself //! <mode> = 10,11,12 idem but returns the Binder itself
//! (if it is not, e.g. Shape, returns the Binder) //! (if it is not, e.g. Shape, returns the Binder)
//! <mode> = 20, returns the ResultFromModel //! <mode> = 20, returns the ResultFromModel
Standard_EXPORT Handle(Standard_Transient) Result (const Handle(Standard_Transient)& theEnt, const Standard_Integer theMode) const; Standard_EXPORT Handle(Standard_Transient) Result(const Handle(Standard_Transient)& theEnt,
const Standard_Integer theMode) const;
//! Commands the transfer of, either one entity, or a list //! Commands the transfer of, either one entity, or a list
//! I.E. calls the TransferReader after having analysed <ents> //! I.E. calls the TransferReader after having analysed <ents>
//! It is cumulated from the last BeginTransfer //! It is cumulated from the last BeginTransfer
@@ -141,66 +137,54 @@ class XSControl_WorkSession : public IFSelect_WorkSession
//! - <ents> a HSequenceOfTransient : this list //! - <ents> a HSequenceOfTransient : this list
//! - <ents> the Model : in this specific case, all the roots, //! - <ents> the Model : in this specific case, all the roots,
//! with no cumulation of former transfers (TransferReadRoots) //! with no cumulation of former transfers (TransferReadRoots)
Standard_EXPORT Standard_Integer TransferReadOne (const Handle(Standard_Transient)& theEnts, Standard_EXPORT Standard_Integer TransferReadOne(const Handle(Standard_Transient)& theEnts,
const Message_ProgressRange& theProgress = Message_ProgressRange()); const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Commands the transfer of all the root entities of the model //! Commands the transfer of all the root entities of the model
//! i.e. calls TransferRoot from the TransferReader with the Graph //! i.e. calls TransferRoot from the TransferReader with the Graph
//! No cumulation with former calls to TransferReadOne //! No cumulation with former calls to TransferReadOne
Standard_EXPORT Standard_Integer TransferReadRoots(const Message_ProgressRange& theProgress = Message_ProgressRange()); Standard_EXPORT Standard_Integer TransferReadRoots(const Message_ProgressRange& theProgress = Message_ProgressRange());
//! produces and returns a new Model well conditioned //! produces and returns a new Model well conditioned
//! It is produced by the Norm Controller //! It is produced by the Norm Controller
//! It can be Null (if this function is not implemented) //! It can be Null (if this function is not implemented)
Standard_EXPORT Handle(Interface_InterfaceModel) NewModel(); Standard_EXPORT Handle(Interface_InterfaceModel) NewModel();
//! Returns the Transfer Reader, Null if not set //! Returns the Transfer Reader, Null if not set
const Handle(XSControl_TransferWriter) & TransferWriter() const Standard_EXPORT const Handle(XSControl_TransferWriter)& TransferWriter() const;
{ return myTransferWriter; }
//! Changes the Map Reader, i.e. considers that the new one //! Changes the Map Reader, i.e. considers that the new one
//! defines the relevant read results (forgets the former ones) //! defines the relevant read results (forgets the former ones)
//! Returns True when done, False if <FP> is Null //! Returns True when done, False if <FP> is Null
Standard_Boolean SetMapWriter (const Handle(Transfer_FinderProcess)& theFP) Standard_EXPORT Standard_Boolean SetMapWriter(const Handle(Transfer_FinderProcess)& theFP);
{
if (theFP.IsNull()) return Standard_False;
myTransferWriter->SetFinderProcess(theFP);
return Standard_True;
}
//! Transfers a Shape from CasCade to a model of current norm, //! Transfers a Shape from CasCade to a model of current norm,
//! according to the last call to SetModeWriteShape //! according to the last call to SetModeWriteShape
//! Returns status :Done if OK, Fail if error during transfer, //! Returns status :Done if OK, Fail if error during transfer,
//! Error if transfer badly initialised //! Error if transfer badly initialised
Standard_EXPORT IFSelect_ReturnStatus TransferWriteShape Standard_EXPORT IFSelect_ReturnStatus TransferWriteShape(const TopoDS_Shape& theShape,
(const TopoDS_Shape& theShape, const Standard_Boolean theCompGraph = Standard_True,
const Standard_Boolean theCompGraph = Standard_True, const Message_ProgressRange& theProgress = Message_ProgressRange());
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Returns the check-list of last transfer (write) //! Returns the check-list of last transfer (write)
//! It is recorded in the FinderProcess, but it must be bound with //! It is recorded in the FinderProcess, but it must be bound with
//! resulting entities (in the resulting file model) rather than //! resulting entities (in the resulting file model) rather than
//! with original objects (in fact, their mappers) //! with original objects (in fact, their mappers)
Standard_EXPORT Interface_CheckIterator TransferWriteCheckList() const; Standard_EXPORT Interface_CheckIterator TransferWriteCheckList() const;
const Handle(XSControl_Vars) & Vars() const
{ return myVars; }
void SetVars (const Handle(XSControl_Vars)& theVars)
{ myVars = theVars; }
DEFINE_STANDARD_RTTIEXT(XSControl_WorkSession,IFSelect_WorkSession)
private: DEFINE_STANDARD_RTTIEXT(XSControl_WorkSession, IFSelect_WorkSession)
protected:
//! Clears binders //! Clears binders
Standard_EXPORT void ClearBinders(); void clearBinders();
private:
Handle(XSControl_Controller) myController; Handle(XSControl_Controller) myController;
Handle(XSControl_TransferReader) myTransferReader; Handle(XSControl_TransferReader) myTransferReader;
Handle(XSControl_TransferWriter) myTransferWriter; Handle(XSControl_TransferWriter) myTransferWriter;
NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> myContext; XSControl_WorkSessionMap myReferenceWS;
Handle(XSControl_Vars) myVars;
}; };
#endif // _XSControl_WorkSession_HeaderFile #endif // _XSControl_WorkSession_HeaderFile