mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0033300: Data Exchange, DE Wrapper - Specialise WS for each transfer process
Updated STEP and IGES to personalize own work session
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include <IGESCAFControl_Provider.hxx>
|
||||
|
||||
#include <BinXCAFDrivers.hxx>
|
||||
#include <IGESControl_Controller.hxx>
|
||||
#include <IGESCAFControl_ConfigurationNode.hxx>
|
||||
#include <IGESCAFControl_Reader.hxx>
|
||||
#include <IGESCAFControl_Writer.hxx>
|
||||
@@ -22,6 +23,7 @@
|
||||
#include <Interface_Static.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XSControl_WorkSession.hxx>
|
||||
#include <UnitsMethods.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(IGESCAFControl_Provider, DE_Provider)
|
||||
@@ -41,6 +43,25 @@ IGESCAFControl_Provider::IGESCAFControl_Provider(const Handle(DE_ConfigurationNo
|
||||
: DE_Provider(theNode)
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
// function : STEPCAFControl_Provider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void IGESCAFControl_Provider::personizeWS(Handle(XSControl_WorkSession)& theWS)
|
||||
{
|
||||
if (theWS.IsNull())
|
||||
{
|
||||
Message::SendWarning() << "Warning: IGESCAFControl_Provider :"
|
||||
<< " Null work session, use internal temporary session";
|
||||
theWS = new XSControl_WorkSession();
|
||||
}
|
||||
Handle(IGESControl_Controller) aCntrl = Handle(IGESControl_Controller)::DownCast(theWS->NormAdaptor());
|
||||
if (aCntrl.IsNull())
|
||||
{
|
||||
theWS->SelectNorm("IGES");
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : initStatic
|
||||
// purpose :
|
||||
@@ -161,12 +182,10 @@ bool IGESCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
|
||||
initStatic(aNode);
|
||||
|
||||
personizeWS(theWS);
|
||||
XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
|
||||
IGESCAFControl_Reader aReader;
|
||||
if (!theWS.IsNull())
|
||||
{
|
||||
aReader.SetWS(theWS);
|
||||
}
|
||||
aReader.SetWS(theWS);
|
||||
|
||||
aReader.SetReadVisible(aNode->InternalParameters.ReadOnlyVisible);
|
||||
|
||||
@@ -213,12 +232,9 @@ bool IGESCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
|
||||
initStatic(aNode);
|
||||
|
||||
personizeWS(theWS);
|
||||
XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->InternalParameters.WriteUnit, UnitsMethods_LengthUnit_Millimeter);
|
||||
IGESCAFControl_Writer aWriter;
|
||||
if (!theWS.IsNull())
|
||||
{
|
||||
aWriter = IGESCAFControl_Writer(theWS);
|
||||
}
|
||||
IGESCAFControl_Writer aWriter(theWS);
|
||||
aWriter.SetColorMode(aNode->InternalParameters.WriteColor);
|
||||
aWriter.SetNameMode(aNode->InternalParameters.WriteName);
|
||||
aWriter.SetLayerMode(aNode->InternalParameters.WriteLayer);
|
||||
@@ -249,7 +265,7 @@ bool IGESCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
Handle(XSControl_WorkSession) aWS;
|
||||
Handle(XSControl_WorkSession) aWS = new XSControl_WorkSession();
|
||||
return Read(thePath, theDocument, aWS, theProgress);
|
||||
}
|
||||
|
||||
@@ -261,7 +277,7 @@ bool IGESCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
Handle(XSControl_WorkSession) aWS;
|
||||
Handle(XSControl_WorkSession) aWS = new XSControl_WorkSession();
|
||||
return Write(thePath, theDocument, aWS, theProgress);
|
||||
}
|
||||
|
||||
@@ -283,11 +299,9 @@ bool IGESCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
}
|
||||
Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
|
||||
initStatic(aNode);
|
||||
personizeWS(theWS);
|
||||
IGESControl_Reader aReader;
|
||||
if (!theWS.IsNull())
|
||||
{
|
||||
aReader.SetWS(theWS);
|
||||
}
|
||||
aReader.SetWS(theWS);
|
||||
aReader.SetReadVisible(aNode->InternalParameters.ReadOnlyVisible);
|
||||
IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
|
||||
aReadStat = aReader.ReadFile(thePath.ToCString());
|
||||
@@ -359,7 +373,7 @@ bool IGESCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
Handle(XSControl_WorkSession) aWS;
|
||||
Handle(XSControl_WorkSession) aWS = new XSControl_WorkSession();
|
||||
return Read(thePath, theShape, aWS, theProgress);
|
||||
}
|
||||
|
||||
@@ -371,7 +385,7 @@ bool IGESCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
Handle(XSControl_WorkSession) aWS;
|
||||
Handle(XSControl_WorkSession) aWS = new XSControl_WorkSession();
|
||||
return Write(thePath, theShape, aWS, theProgress);
|
||||
}
|
||||
|
||||
|
@@ -135,6 +135,11 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
//! Personizes work session with current format.
|
||||
//! Creates new temporary session if current session is null
|
||||
//! @param[in] theWS current work session
|
||||
void personizeWS(Handle(XSControl_WorkSession)& theWS);
|
||||
|
||||
//! Initialize static variables
|
||||
void initStatic(const Handle(DE_ConfigurationNode)& theNode);
|
||||
|
||||
|
@@ -16,12 +16,14 @@
|
||||
#include <BinXCAFDrivers.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <STEPControl_Controller.hxx>
|
||||
#include <StepData_StepModel.hxx>
|
||||
#include <STEPCAFControl_ConfigurationNode.hxx>
|
||||
#include <STEPCAFControl_Controller.hxx>
|
||||
#include <STEPCAFControl_Reader.hxx>
|
||||
#include <STEPCAFControl_Writer.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XSControl_WorkSession.hxx>
|
||||
#include <UnitsMethods.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(STEPCAFControl_Provider, DE_Provider)
|
||||
@@ -41,6 +43,25 @@ STEPCAFControl_Provider::STEPCAFControl_Provider(const Handle(DE_ConfigurationNo
|
||||
:DE_Provider(theNode)
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
// function : STEPCAFControl_Provider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void STEPCAFControl_Provider::personizeWS(Handle(XSControl_WorkSession)& theWS)
|
||||
{
|
||||
if (theWS.IsNull())
|
||||
{
|
||||
Message::SendWarning() << "Warning: STEPCAFControl_Provider :"
|
||||
<< " Null work session, use internal temporary session";
|
||||
theWS = new XSControl_WorkSession();
|
||||
}
|
||||
Handle(STEPControl_Controller) aCntrl = Handle(STEPControl_Controller)::DownCast(theWS->NormAdaptor());
|
||||
if (aCntrl.IsNull())
|
||||
{
|
||||
theWS->SelectNorm("STEP");
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : initStatic
|
||||
// purpose :
|
||||
@@ -175,12 +196,10 @@ bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
|
||||
initStatic(aNode);
|
||||
|
||||
personizeWS(theWS);
|
||||
XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
|
||||
STEPCAFControl_Reader aReader;
|
||||
if (!theWS.IsNull())
|
||||
{
|
||||
aReader.Init(theWS);
|
||||
}
|
||||
aReader.Init(theWS);
|
||||
aReader.SetColorMode(aNode->InternalParameters.ReadColor);
|
||||
aReader.SetNameMode(aNode->InternalParameters.ReadName);
|
||||
aReader.SetLayerMode(aNode->InternalParameters.ReadLayer);
|
||||
@@ -228,11 +247,9 @@ bool STEPCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
|
||||
UnitsMethods::GetLengthUnitScale(aNode->InternalParameters.WriteUnit, UnitsMethods_LengthUnit_Millimeter),
|
||||
UnitsMethods_LengthUnit_Millimeter);
|
||||
personizeWS(theWS);
|
||||
STEPCAFControl_Writer aWriter;
|
||||
if (!theWS.IsNull())
|
||||
{
|
||||
aWriter.Init(theWS);
|
||||
}
|
||||
aWriter.Init(theWS);
|
||||
STEPControl_StepModelType aMode = static_cast<STEPControl_StepModelType>(aNode->InternalParameters.WriteModelType);
|
||||
aWriter.SetColorMode(aNode->InternalParameters.WriteColor);
|
||||
aWriter.SetNameMode(aNode->InternalParameters.WriteName);
|
||||
@@ -282,7 +299,7 @@ bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
Handle(XSControl_WorkSession) aWS;
|
||||
Handle(XSControl_WorkSession) aWS = new XSControl_WorkSession();
|
||||
return Read(thePath, theDocument, aWS, theProgress);
|
||||
}
|
||||
|
||||
@@ -294,7 +311,7 @@ bool STEPCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
Handle(XSControl_WorkSession) aWS;
|
||||
Handle(XSControl_WorkSession) aWS = new XSControl_WorkSession();
|
||||
return Write(thePath, theDocument, aWS, theProgress);
|
||||
}
|
||||
|
||||
@@ -316,11 +333,9 @@ bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
}
|
||||
Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
|
||||
initStatic(aNode);
|
||||
personizeWS(theWS);
|
||||
STEPControl_Reader aReader;
|
||||
if(!theWS.IsNull())
|
||||
{
|
||||
aReader.SetWS(theWS);
|
||||
}
|
||||
aReader.SetWS(theWS);
|
||||
IFSelect_ReturnStatus aReadstat = IFSelect_RetVoid;
|
||||
aReadstat = aReader.ReadFile(thePath.ToCString());
|
||||
if (aReadstat != IFSelect_RetDone)
|
||||
@@ -362,11 +377,9 @@ bool STEPCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
|
||||
initStatic(aNode);
|
||||
|
||||
personizeWS(theWS);
|
||||
STEPControl_Writer aWriter;
|
||||
if(!theWS.IsNull())
|
||||
{
|
||||
aWriter.SetWS(theWS);
|
||||
}
|
||||
aWriter.SetWS(theWS);
|
||||
IFSelect_ReturnStatus aWritestat = IFSelect_RetVoid;
|
||||
Handle(StepData_StepModel) aModel = aWriter.Model();
|
||||
aModel->SetWriteLengthUnit(UnitsMethods::GetLengthUnitScale(aNode->InternalParameters.WriteUnit, UnitsMethods_LengthUnit_Millimeter));
|
||||
@@ -396,7 +409,7 @@ bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
Handle(XSControl_WorkSession) aWS;
|
||||
Handle(XSControl_WorkSession) aWS = new XSControl_WorkSession();
|
||||
return Read(thePath, theShape, aWS, theProgress);
|
||||
}
|
||||
|
||||
@@ -408,7 +421,7 @@ bool STEPCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
Handle(XSControl_WorkSession) aWS;
|
||||
Handle(XSControl_WorkSession) aWS = new XSControl_WorkSession();
|
||||
return Write(thePath, theShape, aWS, theProgress);
|
||||
}
|
||||
|
||||
|
@@ -133,18 +133,23 @@ public:
|
||||
//! @return provider's vendor name
|
||||
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
//! Initialize static variables
|
||||
void initStatic(const Handle(DE_ConfigurationNode)& theNode);
|
||||
//! Personizes work session with current format.
|
||||
//! Creates new temporary session if current session is null
|
||||
//! @param[in] theWS current work session
|
||||
void personizeWS(Handle(XSControl_WorkSession)& theWS);
|
||||
|
||||
//! Initialize static variables
|
||||
void setStatic(const STEPCAFControl_ConfigurationNode::STEPCAFControl_InternalSection theParameter);
|
||||
//! Initialize static variables
|
||||
void initStatic(const Handle(DE_ConfigurationNode)& theNode);
|
||||
|
||||
//! Reset used interface static variables
|
||||
void resetStatic();
|
||||
//! Initialize static variables
|
||||
void setStatic(const STEPCAFControl_ConfigurationNode::STEPCAFControl_InternalSection theParameter);
|
||||
|
||||
STEPCAFControl_ConfigurationNode::STEPCAFControl_InternalSection myOldValues;
|
||||
//! Reset used interface static variables
|
||||
void resetStatic();
|
||||
|
||||
STEPCAFControl_ConfigurationNode::STEPCAFControl_InternalSection myOldValues;
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user