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->SetName(new TCollection_HAsciiString(file));
myReader.WS()->AppendReferenceWS(file, newWS);
// read file
EF->SetLoadStatus(sr.ReadFile(fullname));

View 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;

View File

@@ -11,11 +11,9 @@
// 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>
@@ -27,8 +25,7 @@
#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)
@@ -36,20 +33,24 @@ IMPLEMENT_STANDARD_RTTIEXT(XSControl_WorkSession,IFSelect_WorkSession)
//function : XSControl_WorkSession
//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 :
//=======================================================================
void XSControl_WorkSession::ClearData(const Standard_Integer mode)
{
// 1-2-3-4 : standard IFSelect
@@ -59,7 +60,8 @@ void XSControl_WorkSession::ClearData (const Standard_Integer mode)
// 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);
}
@@ -67,12 +69,10 @@ void XSControl_WorkSession::ClearData (const Standard_Integer mode)
myTransferReader->SetGraph(HGraph());
}
//=======================================================================
//function : SelectNorm
//purpose :
//=======================================================================
Standard_Boolean XSControl_WorkSession::SelectNorm(const Standard_CString normname)
{
// Old norm and results
@@ -87,12 +87,10 @@ Standard_Boolean XSControl_WorkSession::SelectNorm(const Standard_CString normn
return Standard_True;
}
//=======================================================================
//function : SetController
//purpose :
//=======================================================================
void XSControl_WorkSession::SetController(const Handle(XSControl_Controller)& ctl)
{
myController = ctl;
@@ -113,12 +111,10 @@ void XSControl_WorkSession::SetController(const Handle(XSControl_Controller)& ct
myTransferWriter->SetController(myController);
}
//=======================================================================
//function : SelectedNorm
//purpose :
//=======================================================================
Standard_CString XSControl_WorkSession::SelectedNorm(const Standard_Boolean rsc) const
{
//JR/Hp :
@@ -126,46 +122,20 @@ Standard_CString XSControl_WorkSession::SelectedNorm(const Standard_Boolean rsc)
return astr;
}
// ##########################################
// ############ Contexte de Transfert ######
// ##########################################
//=======================================================================
//function : SetAllContext
//function : SelectedNorm
//purpose :
//=======================================================================
void XSControl_WorkSession::SetAllContext(const NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>& context)
void XSControl_WorkSession::AppendReferenceWS(const TCollection_AsciiString& theName,
const Handle(XSControl_WorkSession)& theWS)
{
myContext = context;
myTransferReader->Context() = context;
myReferenceWS.Bind(theName, theWS);
}
//=======================================================================
//function : ClearContext
//purpose :
//=======================================================================
void XSControl_WorkSession::ClearContext ()
{
myContext.Clear();
myTransferReader->Context().Clear();
}
// ##########################################
// ############ RESULTATS FORCES ######
// ##########################################
//=======================================================================
//function : PrintTransferStatus
//purpose :
//=======================================================================
Standard_Boolean XSControl_WorkSession::PrintTransferStatus(const Standard_Integer num,
const Standard_Boolean wri,
Standard_OStream& S) const
@@ -178,17 +148,21 @@ 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;
Standard_Integer ne = 0, nr = 0, max = FP->NbMapped(), maxr = FP->NbRoots();
if (num > 0) {
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);
@@ -204,17 +178,21 @@ Standard_Boolean XSControl_WorkSession::PrintTransferStatus(const Standard_Inte
ent = FP->FindTransient(finder);
S << " -> Type " << finder->DynamicType()->Name() << std::endl;
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();
if (!model.IsNull())
{ S<<" In output Model, Entity "; model->Print(ent, S); }
{
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;
@@ -222,12 +200,15 @@ Standard_Boolean XSControl_WorkSession::PrintTransferStatus(const Standard_Inte
if (num == 0) return Standard_False;
Standard_Integer ne = 0, nr = 0, max = TP->NbMapped(), maxr = TP->NbRoots();
if (num > 0) {
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);
@@ -248,14 +229,17 @@ Standard_Boolean XSControl_WorkSession::PrintTransferStatus(const Standard_Inte
}
// *** CHECK (commun READ+WRITE) ***
if (!binder.IsNull()) {
if (!binder.IsNull())
{
const Handle(Interface_Check) ch = binder->Check();
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;
}
if (nbf > 0) {
if (nbf > 0)
{
S << " - Fails : " << nbf << " :\n";
for (i = 1; i <= nbf; i++) S << ch->CFail(i) << std::endl;
}
@@ -263,12 +247,10 @@ Standard_Boolean XSControl_WorkSession::PrintTransferStatus(const Standard_Inte
return Standard_True;
}
//=======================================================================
//function : InitTransferReader
//purpose :
//=======================================================================
void XSControl_WorkSession::InitTransferReader(const Standard_Integer mode)
{
if (mode == 0 || mode == 5) myTransferReader->Clear(-1); // full clear
@@ -276,13 +258,16 @@ void XSControl_WorkSession::InitTransferReader(const Standard_Integer mode)
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);
}
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());
@@ -291,7 +276,8 @@ void XSControl_WorkSession::InitTransferReader(const Standard_Integer mode)
Standard_Integer i, nb = lis->Length();
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();
@@ -300,12 +286,10 @@ void XSControl_WorkSession::InitTransferReader(const Standard_Integer mode)
if (mode == 4 || mode == 5) myTransferReader->BeginTransfer();
}
//=======================================================================
//function : SetTransferReader
//purpose :
//=======================================================================
void XSControl_WorkSession::SetTransferReader(const Handle(XSControl_TransferReader)& TR)
{
if (myTransferReader != TR) //i1 pdn 03.04.99 BUC60301
@@ -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();
@@ -335,7 +318,6 @@ Handle(Transfer_TransientProcess) XSControl_WorkSession::MapReader() const
//function : SetMapReader
//purpose :
//=======================================================================
Standard_Boolean XSControl_WorkSession::SetMapReader(const Handle(Transfer_TransientProcess)& TP)
{
if (TP.IsNull()) return Standard_False;
@@ -353,14 +335,12 @@ Standard_Boolean XSControl_WorkSession::SetMapReader (const Handle(Transfer_Tran
return Standard_True;
}
//=======================================================================
//function : Result
//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);
@@ -381,16 +361,10 @@ Handle(Standard_Transient) XSControl_WorkSession::Result
return binder;
}
// ##########################################
// ############ TRANSFERT #############
// ##########################################
//=======================================================================
//function : TransferReadOne
//purpose :
//=======================================================================
Standard_Integer XSControl_WorkSession::TransferReadOne(const Handle(Standard_Transient)& ent,
const Message_ProgressRange& theProgress)
{
@@ -404,27 +378,19 @@ Standard_Integer XSControl_WorkSession::TransferReadOne (const Handle(Standard_T
return myTransferReader->TransferList(list, Standard_True, theProgress);
}
//=======================================================================
//function : TransferReadRoots
//purpose :
//=======================================================================
Standard_Integer XSControl_WorkSession::TransferReadRoots(const Message_ProgressRange& theProgress)
{
return myTransferReader->TransferRoots(Graph(), theProgress);
}
// ##########################################
// ############ TRANSFERT WRITE
// ##########################################
//=======================================================================
//function : NewModel
//purpose :
//=======================================================================
Handle(Interface_InterfaceModel) XSControl_WorkSession::NewModel()
{
Handle(Interface_InterfaceModel) newmod;
@@ -441,12 +407,30 @@ Handle(Interface_InterfaceModel) XSControl_WorkSession::NewModel ()
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
//purpose :
//=======================================================================
IFSelect_ReturnStatus XSControl_WorkSession::TransferWriteShape(const TopoDS_Shape& shape,
const Standard_Boolean compgraph,
const Message_ProgressRange& theProgress)
@@ -470,24 +454,20 @@ IFSelect_ReturnStatus XSControl_WorkSession::TransferWriteShape (const TopoDS_Sh
return status;
}
//=======================================================================
//function : TransferWriteCheckList
//purpose :
//=======================================================================
Interface_CheckIterator XSControl_WorkSession::TransferWriteCheckList() const
{
return myTransferWriter->ResultCheckList(Model());
}
//=======================================================================
//function : ClearBinders
//function : clearBinders
//purpose :
//=======================================================================
void XSControl_WorkSession::ClearBinders()
void XSControl_WorkSession::clearBinders()
{
const Handle(Transfer_FinderProcess)& FP = myTransferWriter->FinderProcess();
//Due to big number of chains of binders it is necessary to
@@ -495,7 +475,8 @@ void XSControl_WorkSession::ClearBinders()
TColStd_SequenceOfTransient aSeqBnd;
TColStd_SequenceOfTransient aSeqShapes;
Standard_Integer i = 1;
for( ; i <= FP->NbMapped();i++) {
for (; i <= FP->NbMapped(); i++)
{
Handle(Transfer_Binder) bnd = FP->MapItem(i);
if (!bnd.IsNull())
aSeqBnd.Append(bnd);
@@ -508,18 +489,18 @@ void XSControl_WorkSession::ClearBinders()
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);
aSeqBnd.Remove(1);
aSeqShapes.Remove(1);
ash.Nullify();
while(!aBnd.IsNull()) {
while (!aBnd.IsNull())
{
Handle(Transfer_Binder) aBndNext = aBnd->NextResult();
aBnd.Nullify();
aBnd = aBndNext;
}
}
}

View 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
@@ -50,8 +51,7 @@ class XSControl_WorkSession : public IFSelect_WorkSession
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
@@ -77,26 +77,22 @@ class XSControl_WorkSession : public IFSelect_WorkSession
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; }
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; }
//! Returns the current reference WS List, empty if not defined
const XSControl_WorkSessionMap& ReferenceWS() const { return myReferenceWS; }
//! 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();
//! 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)
@@ -110,8 +106,7 @@ class XSControl_WorkSession : public IFSelect_WorkSession
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;
@@ -131,7 +126,8 @@ 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>
@@ -155,25 +151,18 @@ class XSControl_WorkSession : public IFSelect_WorkSession
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,
Standard_EXPORT IFSelect_ReturnStatus TransferWriteShape(const TopoDS_Shape& theShape,
const Standard_Boolean theCompGraph = Standard_True,
const Message_ProgressRange& theProgress = Message_ProgressRange());
@@ -183,24 +172,19 @@ class XSControl_WorkSession : public IFSelect_WorkSession
//! 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:
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