]> OCCT Git - occt.git/commitdiff
0033309: Data Exchange, XS - Update WorkSession to keep reference work sessions CR33309
authordpasukhi <dpasukhi@opencascade.com>
Fri, 6 Jan 2023 16:25:51 +0000 (16:25 +0000)
committerdpasukhi <dpasukhi@opencascade.com>
Fri, 6 Jan 2023 16:33:09 +0000 (16:33 +0000)
Updated WorkSession to keep reference WS information

src/STEPCAFControl/STEPCAFControl_Reader.cxx
src/STEPCAFControl/STEPCAFControl_Writer.cxx
src/XSControl/XSControl_WorkSession.cxx
src/XSControl/XSControl_WorkSession.hxx

index a211ebbb945360a8baf967037f36a69e38ea1874..97725bda087024cccd2164e3be1ebac6fdd87a90 100644 (file)
@@ -862,6 +862,8 @@ Handle(STEPCAFControl_ExternFile) STEPCAFControl_Reader::ReadExternFile (const S
   EF->SetWS(newWS);
   EF->SetName(new TCollection_HAsciiString(file));
 
+  myReader.WS()->AppendReferenceWS(file, newWS);
+
   // read file
   EF->SetLoadStatus(sr.ReadFile(fullname));
 
index 521d043df42b7943f6ce1ce1499c6432239c169d..699c7e343f5fabf63abb845e239d631eaca22972 100644 (file)
@@ -800,6 +800,7 @@ TopoDS_Shape STEPCAFControl_Writer::TransferExternFiles (const TDF_Label &L,
     EF->SetWS ( newWS );
     EF->SetName ( name );
     EF->SetLabel ( L );
+    Writer().WS()->AppendReferenceWS(name->String(), newWS);
     Standard_Integer assemblymode = Interface_Static::IVal ("write.step.assembly");
     Interface_Static::SetCVal ("write.step.assembly", "Off");
     const Standard_CString multi = 0;
index 07ff5ce3ebc35cbe38b929c942ba8836ae8ecf4f..f6c03e3d42e1df55e4200af8915adf722ac4a809 100644 (file)
 // Alternatively, this file may be used under the terms of Open CASCADE
 // 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_HGraph.hxx>
 #include <Interface_InterfaceModel.hxx>
 #include <Interface_Macros.hxx>
 #include <Message_Messenger.hxx>
 #include <Transfer_TransientProcess.hxx>
 #include <XSControl_Controller.hxx>
 #include <XSControl_TransferReader.hxx>
-#include <XSControl_Vars.hxx>
-#include <XSControl_WorkSession.hxx>
+#include <XSControl_TransferWriter.hxx>
 
-IMPLEMENT_STANDARD_RTTIEXT(XSControl_WorkSession,IFSelect_WorkSession)
+IMPLEMENT_STANDARD_RTTIEXT(XSControl_WorkSession, IFSelect_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),
-  myTransferWriter(new XSControl_TransferWriter),
-  myVars(new XSControl_Vars)
+//=======================================================================
+//function : XSControl_WorkSession
+//purpose  :
+//=======================================================================
+XSControl_WorkSession::~XSControl_WorkSession()
 {
+  clearBinders();
 }
 
-
 //=======================================================================
 //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
-  if (mode >= 1 && mode <= 4) IFSelect_WorkSession::ClearData (mode);
+  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) {
+  if (mode == 5 || mode == 7)
+  {
     myTransferReader->Clear(-1);
     myTransferWriter->Clear(-1);
   }
   if (mode == 6 && !myTransferReader.IsNull()) myTransferReader->Clear(1);
-  myTransferReader->SetGraph (HGraph());
+  myTransferReader->SetGraph(HGraph());
 }
 
-
 //=======================================================================
 //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
   myTransferReader->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);
+  Handle(XSControl_Controller) newadapt = XSControl_Controller::Recorded(normname);
   if (newadapt.IsNull()) return Standard_False;
   if (newadapt == myController) return Standard_True;
-  SetController (newadapt);
+  SetController(newadapt);
   return Standard_True;
 }
 
-
 //=======================================================================
 //function : SetController
-//purpose  : 
+//purpose  :
 //=======================================================================
-
 void XSControl_WorkSession::SetController(const Handle(XSControl_Controller)& ctl)
 {
   myController = ctl;
 
-  SetLibrary   ( myController->WorkLibrary() );
-  SetProtocol  ( myController->Protocol() );
+  SetLibrary(myController->WorkLibrary());
+  SetProtocol(myController->Protocol());
 
   ClearItems();
   ClearFinalModifiers();
@@ -107,70 +105,42 @@ void XSControl_WorkSession::SetController(const Handle(XSControl_Controller)& ct
 
   // Set worksession parameters from teh controller
   Handle(XSControl_WorkSession) aWorkSession(this);
-  myController->Customise (aWorkSession);
+  myController->Customise(aWorkSession);
 
-  myTransferReader->SetController (myController);
-  myTransferWriter->SetController (myController);
+  myTransferReader->SetController(myController);
+  myTransferWriter->SetController(myController);
 }
 
-
 //=======================================================================
 //function : SelectedNorm
-//purpose  : 
+//purpose  :
 //=======================================================================
-
 Standard_CString XSControl_WorkSession::SelectedNorm(const Standard_Boolean rsc) const
 {
   //JR/Hp :
-  Standard_CString astr = (Standard_CString ) (myController.IsNull() ? "" : myController->Name(rsc));
-  return astr ;
+  Standard_CString astr = (Standard_CString)(myController.IsNull() ? "" : myController->Name(rsc));
+  return astr;
 }
 
-
-//              ##########################################
-//              ############  Contexte de Transfert ######
-//              ##########################################
-
-
-//=======================================================================
-//function : SetAllContext
-//purpose  : 
 //=======================================================================
-
-void XSControl_WorkSession::SetAllContext(const NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>& context)
-{
-  myContext = context;
-  myTransferReader->Context() = context;
-}
-
-
-//=======================================================================
-//function : ClearContext
-//purpose  : 
+//function : SelectedNorm
+//purpose  :
 //=======================================================================
-
-void XSControl_WorkSession::ClearContext ()
+void XSControl_WorkSession::AppendReferenceWS(const TCollection_AsciiString& theName,
+                                              const Handle(XSControl_WorkSession)& theWS)
 {
-  myContext.Clear();
-  myTransferReader->Context().Clear();
+  myReferenceWS.Bind(theName, theWS);
 }
 
-
-//              ##########################################
-//              ############    RESULTATS FORCES    ######
-//              ##########################################
-
-
 //=======================================================================
 //function : PrintTransferStatus
-//purpose  : 
+//purpose  :
 //=======================================================================
-
-Standard_Boolean  XSControl_WorkSession::PrintTransferStatus(const Standard_Integer num,
-                                                             const Standard_Boolean wri,
-                                                             Standard_OStream& S) const
+Standard_Boolean XSControl_WorkSession::PrintTransferStatus(const Standard_Integer num,
+                                                            const Standard_Boolean wri,
+                                                            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_Binder) binder;
@@ -178,145 +148,159 @@ Standard_Boolean  XSControl_WorkSession::PrintTransferStatus(const Standard_Inte
   Handle(Standard_Transient) ent;
 
   //   ***   WRITE  ***
-  if (wri) {
+  if (wri)
+  {
     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();
-    if (num > 0) {
+    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) {
+    }
+    else if (num < 0)
+    {
       nr = -num;
       if (nr > maxr) return Standard_False;
       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)
     {
-      S<<"  ** Transfer Root n0."<<ne;
+      S << "  ** Transfer Root n0." << ne;
     }
-    S<<std::endl;
+    S << std::endl;
     ent = FP->FindTransient(finder);
-    S<<" -> Type "<<finder->DynamicType()->Name()<<std::endl;
-    FP->StartTrace (binder,finder,0,0);  // pb sout/S
-    if (!ent.IsNull()) {
-      S<<" ** Resultat Transient, type "<<ent->DynamicType()->Name();
-      const Handle(Interface_InterfaceModel) &model = Model();
+    S << " -> Type " << finder->DynamicType()->Name() << std::endl;
+    FP->StartTrace(binder, finder, 0, 0);  // pb sout/S
+    if (!ent.IsNull())
+    {
+      S << " ** Resultat Transient, type " << ent->DynamicType()->Name();
+      const Handle(Interface_InterfaceModel)& model = Model();
       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   ***
-  else {
+  else
+  {
     if (TP.IsNull()) return Standard_False;
     Handle(Interface_InterfaceModel) model = TP->Model();
-    if (model.IsNull()) std::cout<<"No Model"<<std::endl;
-    else if (model != Model()) std::cout<<"Model different from the session"<<std::endl;
+    if (model.IsNull()) std::cout << "No Model" << std::endl;
+    else if (model != Model()) std::cout << "Model different from the session" << std::endl;
     if (num == 0) return Standard_False;
 
-    Standard_Integer  ne=0, nr=0, max = TP->NbMapped() ,maxr = TP->NbRoots();
-    if (num > 0) {
+    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) {
+    }
+    else if (num < 0)
+    {
       nr = -num;
       if (nr > maxr) return Standard_False;
       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)
     {
-      S<<"  ** Transfer Root n0."<<ne;
+      S << "  ** Transfer Root n0." << ne;
     }
-    S<<std::endl;
-    if (!model.IsNull())  {  S<<" In Model, Entity ";  model->Print(ent, S); }
-    binder = TP->MapItem (ne);
-    S<<std::endl;
-    TP->StartTrace (binder,ent,0,0);
+    S << std::endl;
+    if (!model.IsNull()) { S << " In Model, Entity ";  model->Print(ent, S); }
+    binder = TP->MapItem(ne);
+    S << std::endl;
+    TP->StartTrace(binder, ent, 0, 0);
 
   }
 
-//   ***   CHECK (commun READ+WRITE)   ***
-  if (!binder.IsNull()) {
+  //   ***   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)<<std::endl;
+    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) << std::endl;
     }
-    if (nbf > 0) {
-      S<<" - Fails : "<<nbf<<" :\n";
-      for (i = 1; i <= nbf; i ++) S<<ch->CFail(i)<<std::endl;
+    if (nbf > 0)
+    {
+      S << " - Fails : " << nbf << " :\n";
+      for (i = 1; i <= nbf; i++) S << ch->CFail(i) << std::endl;
     }
   }
   return Standard_True;
 }
 
-
 //=======================================================================
 //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 (myTransferReader.IsNull()) SetTransferReader (new XSControl_TransferReader);
-  else SetTransferReader (myTransferReader);
+  if (myTransferReader.IsNull()) SetTransferReader(new XSControl_TransferReader);
+  else SetTransferReader(myTransferReader);
 
   // mode = 0 fait par SetTransferReader suite a Nullify
-  if (mode == 1) {
+  if (mode == 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();
-    if (TP.IsNull()) {
+    if (TP.IsNull())
+    {
       TP = new Transfer_TransientProcess;
       myTransferReader->SetTransientProcess(TP);
-      TP->SetGraph (HGraph());
+      TP->SetGraph(HGraph());
     }
     Handle(TColStd_HSequenceOfTransient) lis = myTransferReader->RecordedList();
     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();
     if (TP.IsNull()) return;
     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();
 }
 
-
 //=======================================================================
 //function : SetTransferReader
-//purpose  : 
+//purpose  :
 //=======================================================================
-
 void XSControl_WorkSession::SetTransferReader(const Handle(XSControl_TransferReader)& TR)
 {
   if (myTransferReader != TR) //i1 pdn 03.04.99 BUC60301
     myTransferReader = TR;
   if (TR.IsNull()) return;
-  TR->SetController (myController);
-  TR->SetGraph (HGraph());
+  TR->SetController(myController);
+  TR->SetGraph(HGraph());
   if (!TR->TransientProcess().IsNull()) return;
   Handle(Transfer_TransientProcess) TP = new Transfer_TransientProcess
-    (Model().IsNull() ? 100 : Model()->NbEntities() + 100);
-  TP->SetGraph (HGraph());
+  (Model().IsNull() ? 100 : Model()->NbEntities() + 100);
+  TP->SetGraph(HGraph());
   TP->SetErrorHandle(Standard_True);
   TR->SetTransientProcess(TP);
 }
@@ -325,7 +309,6 @@ void XSControl_WorkSession::SetTransferReader(const Handle(XSControl_TransferRea
 //function : MapReader
 //purpose  :
 //=======================================================================
-
 Handle(Transfer_TransientProcess) XSControl_WorkSession::MapReader() const
 {
   return myTransferReader->TransientProcess();
@@ -333,34 +316,31 @@ Handle(Transfer_TransientProcess) XSControl_WorkSession::MapReader() const
 
 //=======================================================================
 //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->Model().IsNull()) TP->SetModel (Model());
-  TP->SetGraph (HGraph());
+  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;
+  //  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 = myTransferReader;
   TR->Clear(-1);
 
-  SetTransferReader (TR);        // avec le meme mais le reinitialise
-  TR->SetTransientProcess (TP);  // et prend le nouveau TP
+  SetTransferReader(TR);        // avec le meme mais le reinitialise
+  TR->SetTransientProcess(TP);  // et prend le nouveau TP
   return Standard_True;
 }
 
-
 //=======================================================================
 //function : Result
-//purpose  : 
+//purpose  :
 //=======================================================================
-
-Handle(Standard_Transient)  XSControl_WorkSession::Result
-  (const Handle(Standard_Transient)& ent, const Standard_Integer mode) const
+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);
@@ -368,7 +348,7 @@ Handle(Standard_Transient)  XSControl_WorkSession::Result
   Handle(Transfer_Binder) binder;
   Handle(Transfer_ResultFromModel) resu;
 
-  if (ouca !=  1) resu = myTransferReader->FinalResult(ent);
+  if (ouca != 1) resu = myTransferReader->FinalResult(ent);
   if (mode == 20) return resu;
 
   if (!resu.IsNull()) binder = resu->MainResult()->Binder();
@@ -376,23 +356,17 @@ Handle(Standard_Transient)  XSControl_WorkSession::Result
     binder = myTransferReader->TransientProcess()->Find(ent);
 
   if (kica == 1) return binder;
-  DeclareAndCast(Transfer_SimpleBinderOfTransient,trb,binder);
+  DeclareAndCast(Transfer_SimpleBinderOfTransient, trb, binder);
   if (!trb.IsNull()) return trb->Result();
   return binder;
 }
 
-//              ##########################################
-//              ############    TRANSFERT    #############
-//              ##########################################
-
-
 //=======================================================================
 //function : TransferReadOne
-//purpose  : 
+//purpose  :
 //=======================================================================
-
-Standard_Integer XSControl_WorkSession::TransferReadOne (const Handle(Standard_Transient)& ent,
-                                                         const Message_ProgressRange& theProgress)
+Standard_Integer XSControl_WorkSession::TransferReadOne(const Handle(Standard_Transient)& ent,
+                                                        const Message_ProgressRange& theProgress)
 {
   Handle(Interface_InterfaceModel) model = Model();
   if (ent == model) return TransferReadRoots(theProgress);
@@ -401,38 +375,30 @@ Standard_Integer XSControl_WorkSession::TransferReadOne (const Handle(Standard_T
   if (list->Length() == 1)
     return myTransferReader->TransferOne(list->Value(1), Standard_True, theProgress);
   else
-    return myTransferReader->TransferList (list, Standard_True, theProgress);
+    return myTransferReader->TransferList(list, Standard_True, theProgress);
 }
 
-
 //=======================================================================
 //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);
 }
 
-
-//              ##########################################
-//              ############    TRANSFERT  WRITE
-//              ##########################################
-
 //=======================================================================
 //function : NewModel
-//purpose  : 
+//purpose  :
 //=======================================================================
-
-Handle(Interface_InterfaceModel) XSControl_WorkSession::NewModel ()
+Handle(Interface_InterfaceModel) XSControl_WorkSession::NewModel()
 {
   Handle(Interface_InterfaceModel) newmod;
   if (myController.IsNull()) return newmod;
   newmod = myController->NewModel();
-  
+
   SetModel(newmod);
-  if(!myTransferReader->TransientProcess().IsNull())
+  if (!myTransferReader->TransientProcess().IsNull())
     myTransferReader->TransientProcess()->Clear();
   //clear all contains of WS
   myTransferReader->Clear(3);
@@ -441,19 +407,37 @@ Handle(Interface_InterfaceModel) XSControl_WorkSession::NewModel ()
   return newmod;
 }
 
+//=======================================================================
+//function : TransferWriter
+//purpose  :
+//=======================================================================
+const Handle(XSControl_TransferWriter)& XSControl_WorkSession::TransferWriter() const
+{
+  return myTransferWriter;
+}
 
 //=======================================================================
-//function : TransferWriteShape
-//purpose  : 
+//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;
+}
 
-IFSelect_ReturnStatus XSControl_WorkSession::TransferWriteShape (const TopoDS_Shape& shape,
-                                                                 const Standard_Boolean compgraph,
-                                                                 const Message_ProgressRange& theProgress)
+//=======================================================================
+//function : TransferWriteShape
+//purpose  :
+//=======================================================================
+IFSelect_ReturnStatus XSControl_WorkSession::TransferWriteShape(const TopoDS_Shape& shape,
+                                                                const Standard_Boolean compgraph,
+                                                                const Message_ProgressRange& theProgress)
 {
   IFSelect_ReturnStatus  status;
   if (myController.IsNull()) return IFSelect_RetError;
-  const Handle(Interface_InterfaceModel) &model = Model();
+  const Handle(Interface_InterfaceModel)model = Model();
   if (model.IsNull() || shape.IsNull())
   {
     return IFSelect_RetVoid;
@@ -465,61 +449,58 @@ IFSelect_ReturnStatus XSControl_WorkSession::TransferWriteShape (const TopoDS_Sh
   //  qui s occupe de tout, try/catch inclus
 
   //skl insert param compgraph for XDE writing 10.12.2003
-  if(compgraph) ComputeGraph(Standard_True);
+  if (compgraph) ComputeGraph(Standard_True);
 
   return status;
 }
 
-
 //=======================================================================
 //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
-//purpose  : 
+//function : clearBinders
+//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 
   //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())
+  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));
+    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) {
+  while (aSeqBnd.Length() > 0)
+  {
     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);
     aSeqShapes.Remove(1);
     ash.Nullify();
-    while(!aBnd.IsNull()) {
+    while (!aBnd.IsNull())
+    {
       Handle(Transfer_Binder) aBndNext = aBnd->NextResult();
       aBnd.Nullify();
       aBnd = aBndNext;
     }
-    
   }
-
 }
index c94fe0bdf8ea0da1540354ccaa4147a15032a2fb..951c6a6a34c5bf2e6d732c7ea64533f815e17047 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <IFSelect_WorkSession.hxx>
 #include <IFSelect_ReturnStatus.hxx>
-#include <XSControl_TransferWriter.hxx>
+
 class XSControl_Controller;
 class XSControl_TransferReader;
 class XSControl_Vars;
@@ -32,10 +32,11 @@ class Transfer_FinderProcess;
 class TopoDS_Shape;
 class Interface_CheckIterator;
 
-
 class XSControl_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 :
 //! - use of Controller, with norm selection...
 //! - 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
 class XSControl_WorkSession : public IFSelect_WorkSession
 {
- public:
-  
+public:
+
   Standard_EXPORT XSControl_WorkSession();
-  
-  ~XSControl_WorkSession()
-  { ClearBinders(); }
+
+  Standard_EXPORT ~XSControl_WorkSession();
 
   //! 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
-  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.
   //! A Norm is described and handled by a Controller
   //! Returns True if done, False if <normname> is unknown
   //!
   //! 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
-  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
   //! 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
-  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
-  const Handle(XSControl_Controller) & NormAdaptor() const
-  { return myController; }
-  
-  //! Returns the current Context List, Null if not defined
-  //! The Context is given to the TransientProcess for TransferRead
-  const NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> & Context() const
-  { return myContext; }
-  
-  //! 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();
-  
+  const Handle(XSControl_Controller)& NormAdaptor() const { return myController; }
+
+  //! Returns the current reference WS List, empty if not defined
+  const XSControl_WorkSessionMap& ReferenceWS() const { return myReferenceWS; }
+
+  //! Appends new refrence Work Session
+  Standard_EXPORT void AppendReferenceWS(const TCollection_AsciiString& theName,
+                                         const Handle(XSControl_WorkSession)& theWS);
+
   //! Prints the transfer status of a transferred item, as being
   //! 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)
-  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 :
   //! 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
-  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
-  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
-  const Handle(XSControl_TransferReader) & TransferReader () const
-  { return myTransferReader; }
+  const Handle(XSControl_TransferReader)& TransferReader() const { return myTransferReader; }
 
   //! Returns the TransientProcess(internal data for TransferReader)
   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)
   //! Returns True when done, False in case of bad definition, i.e.
   //! 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
   //! If <mode> = 0, returns Final 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
   //! (if it is not, e.g. Shape, returns the Binder)
   //! <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
   //! I.E. calls the TransferReader after having analysed <ents>
   //! It is cumulated from the last BeginTransfer
@@ -141,66 +137,54 @@ class XSControl_WorkSession : public IFSelect_WorkSession
   //! - <ents> a HSequenceOfTransient : this list
   //! - <ents> the Model : in this specific case, all the roots,
   //! with no cumulation of former transfers (TransferReadRoots)
-  Standard_EXPORT Standard_Integer TransferReadOne (const Handle(Standard_Transient)& theEnts,
-                                                    const Message_ProgressRange& theProgress = Message_ProgressRange());
-  
+  Standard_EXPORT Standard_Integer TransferReadOne(const Handle(Standard_Transient)& theEnts,
+                                                   const Message_ProgressRange& theProgress = Message_ProgressRange());
+
   //! 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
   Standard_EXPORT Standard_Integer TransferReadRoots(const Message_ProgressRange& theProgress = Message_ProgressRange());
-  
+
   //! produces and returns a new Model well conditioned
   //! It is produced by the Norm Controller
   //! It can be Null (if this function is not implemented)
   Standard_EXPORT Handle(Interface_InterfaceModel) NewModel();
-  
+
   //! Returns the Transfer Reader, Null if not set
-  const Handle(XSControl_TransferWriter) & TransferWriter() const
-  { return myTransferWriter; }
-  
+  Standard_EXPORT const Handle(XSControl_TransferWriter)& TransferWriter() const;
+
   //! 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
-  Standard_Boolean SetMapWriter (const Handle(Transfer_FinderProcess)& theFP)
-  {
-    if (theFP.IsNull()) return Standard_False;
-    myTransferWriter->SetFinderProcess(theFP);
-    return Standard_True;
-  }
-  
+  Standard_EXPORT Standard_Boolean SetMapWriter(const Handle(Transfer_FinderProcess)& theFP);
+
   //! 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
-  Standard_EXPORT IFSelect_ReturnStatus TransferWriteShape
-                   (const TopoDS_Shape& theShape,
-                    const Standard_Boolean theCompGraph = Standard_True,
-                    const Message_ProgressRange& theProgress = Message_ProgressRange());
-  
+  Standard_EXPORT IFSelect_ReturnStatus TransferWriteShape(const TopoDS_Shape& theShape,
+                                                           const Standard_Boolean theCompGraph = Standard_True,
+                                                           const Message_ProgressRange& theProgress = Message_ProgressRange());
+
   //! 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)
   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
-  Standard_EXPORT void ClearBinders();
+  void clearBinders();
+
+private:
 
   Handle(XSControl_Controller) myController;
   Handle(XSControl_TransferReader) myTransferReader;
   Handle(XSControl_TransferWriter) myTransferWriter;
-  NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> myContext;
-  Handle(XSControl_Vars) myVars;
+  XSControl_WorkSessionMap myReferenceWS;
 };
 
 #endif // _XSControl_WorkSession_HeaderFile