#include <IGESCAFControl_ConfigurationNode.hxx>
#include <IGESCAFControl_Reader.hxx>
#include <IGESCAFControl_Writer.hxx>
+#include <IGESControl_Controller.hxx>
#include <IGESData.hxx>
#include <IGESData_IGESModel.hxx>
#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)
: DE_Provider(theNode)
{}
+//=======================================================================
+// function : personizeWS
+// 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())
+ {
+ IGESControl_Controller::Init();
+ theWS->SelectNorm("IGES");
+ }
+}
+
//=======================================================================
// function : initStatic
// purpose :
return false;
}
Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
+ personizeWS(theWS);
initStatic(aNode);
-
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);
return false;
}
Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
+ personizeWS(theWS);
initStatic(aNode);
-
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);
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);
}
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);
}
}
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());
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
- Handle(XSControl_WorkSession) aWS;
+ Handle(XSControl_WorkSession) aWS = new XSControl_WorkSession();
return Read(thePath, theShape, aWS, theProgress);
}
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);
}
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);
return false;
}
Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
+ 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);
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);
Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(aWriter.Writer().WS()->Model());
STEPControl_StepModelType aMode =
static_cast<STEPControl_StepModelType>(aNode->InternalParameters.WriteModelType);
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);
}
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);
}
return false;
}
Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
+ personizeWS(theWS);
STEPControl_Reader aReader;
- if(!theWS.IsNull())
- {
- aReader.SetWS(theWS);
- }
+ aReader.SetWS(theWS);
IFSelect_ReturnStatus aReadstat = IFSelect_RetVoid;
StepData_ConfParameters aParams;
aReadstat = aReader.ReadFile(thePath.ToCString(), aParams);
}
Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
+ 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));
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
- Handle(XSControl_WorkSession) aWS;
+ Handle(XSControl_WorkSession) aWS = new XSControl_WorkSession();
return Read(thePath, theShape, aWS, theProgress);
}
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);
}
{
return TCollection_AsciiString("OCC");
}
+
+//=======================================================================
+// function : personizeWS
+// 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(STEPCAFControl_Controller) aCntrl = Handle(STEPCAFControl_Controller)::DownCast(theWS->NormAdaptor());
+ if (aCntrl.IsNull())
+ {
+ STEPCAFControl_Controller::Init();
+ theWS->SelectNorm("STEP");
+ }
+}
//! @return provider's vendor name
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+ 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);
};
}
Handle(DE_Wrapper) aConf = DE_Wrapper::GlobalWrapper()->Copy();
+ Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
Standard_Boolean aStat = Standard_True;
if (!aConfString.IsEmpty())
{
if (aStat)
{
TopoDS_Shape aShape;
- aStat = isNoDoc ? aConf->Read(aFilePath, aShape) : aConf->Read(aFilePath, aDoc);
+ aStat = isNoDoc ? aConf->Read(aFilePath, aShape, aWS) : aConf->Read(aFilePath, aDoc, aWS);
if (isNoDoc && aStat)
{
DBRep::Set(aDocShapeName.ToCString(), aShape);
{
return 1;
}
+ XSDRAW::CollectActiveWorkSessions(aFilePath);
return 0;
}
return 1;
}
Handle(DE_Wrapper) aConf = DE_Wrapper::GlobalWrapper()->Copy();
+ Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
Standard_Boolean aStat = Standard_True;
if (!aConfString.IsEmpty())
{
theDI << "Error: incorrect shape " << aDocShapeName << "\n";
return 1;
}
- aStat = aConf->Write(aFilePath, aShape);
+ aStat = aConf->Write(aFilePath, aShape, aWS);
}
else
{
- aStat = aConf->Write(aFilePath, aDoc);
+ aStat = aConf->Write(aFilePath, aDoc, aWS);
}
}
if (!aStat)
{
return 1;
}
+ XSDRAW::CollectActiveWorkSessions(aFilePath);
return 0;
}