return Standard_False;
}
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
- (void)thePath;
- (void)theDocument;
- (void)theProgress;
- Message::SendFail() << "Error: provider " << GetFormat() <<
- " " << GetVendor() << " doesn't support read operation";
- return Standard_False;
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
- (void)thePath;
- (void)theDocument;
- (void)theProgress;
- Message::SendFail() << "Error: provider " << GetFormat() <<
- " " << GetVendor() << " doesn't support write operation";
- return Standard_False;
-}
-
//=======================================================================
// function : Read
// purpose :
" " << GetVendor() << " doesn't support write operation";
return Standard_False;
}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress)
-{
- (void)thePath;
- (void)theShape;
- (void)theProgress;
- Message::SendFail() << "Error: provider " << GetFormat() <<
- " " << GetVendor() << " doesn't support read operation";
- return Standard_False;
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress)
-{
- (void)thePath;
- (void)theShape;
- (void)theProgress;
- Message::SendFail() << "Error: provider " << GetFormat() <<
- " " << GetVendor() << " doesn't support write operation";
- return Standard_False;
-}
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theDocument document to save result
- //! @param theProgress[in] progress indicator
- //! @return True if Read was successful
- Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange());
-
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theDocument document to export
- //! @param theProgress[in] progress indicator
- //! @return True if Write was successful
- Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange());
-
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theShape shape to save result
- //! @param theProgress[in] progress indicator
- //! @return True if Read was successful
- Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange());
-
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theShape shape to export
- //! @param theProgress[in] progress indicator
- //! @return True if Write was successful
- Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange());
-
public:
//! Gets CAD format name of associated provider
{
static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
{
- static const TCollection_AsciiString aScope ("global");
+ static const TCollection_AsciiString aScope("global");
return aScope;
}
{
return Standard_False;
}
- if (theWS.IsNull())
- {
- return Read(thePath, theDocument, theProgress);
- }
Handle(DE_Provider) aProvider;
if (!FindProvider(thePath, Standard_True, aProvider))
{
{
return Standard_False;
}
- if (theWS.IsNull())
- {
- return Write(thePath, theDocument, theProgress);
- }
Handle(DE_Provider) aProvider;
if (!FindProvider(thePath, Standard_False, aProvider))
{
return aProvider->Write(thePath, theDocument, theWS, theProgress);
}
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
- if (theDocument.IsNull())
- {
- return Standard_False;
- }
- Handle(DE_Provider) aProvider;
- if (!FindProvider(thePath, Standard_True, aProvider))
- {
- return Standard_False;
- }
- return aProvider->Read(thePath, theDocument, theProgress);
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
- if (theDocument.IsNull())
- {
- return Standard_False;
- }
- Handle(DE_Provider) aProvider;
- if (!FindProvider(thePath, Standard_False, aProvider))
- {
- return Standard_False;
- }
- return aProvider->Write(thePath, theDocument, theProgress);
-}
-
//=======================================================================
// function : Read
// purpose :
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
- if (theWS.IsNull())
- {
- return Read(thePath, theShape, theProgress);
- }
Handle(DE_Provider) aProvider;
if (!FindProvider(thePath, Standard_True, aProvider))
{
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
- if (theWS.IsNull())
- {
- return Write(thePath, theShape, theProgress);
- }
Handle(DE_Provider) aProvider;
if (!FindProvider(thePath, Standard_False, aProvider))
{
return aProvider->Write(thePath, theShape, theWS, theProgress);
}
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress)
-{
-
- Handle(DE_Provider) aProvider;
- if (!FindProvider(thePath, Standard_True, aProvider))
- {
- return Standard_False;
- }
- return aProvider->Read(thePath, theShape, theProgress);
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress)
-{
- Handle(DE_Provider) aProvider;
- if (!FindProvider(thePath, Standard_False, aProvider))
- {
- return Standard_False;
- }
- return aProvider->Write(thePath, theShape, theProgress);
-}
-
//=======================================================================
// function : Load
// purpose :
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theDocument document to save result
- //! @param theProgress[in] progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange());
-
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theDocument document to export
- //! @param theProgress[in] progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange());
-
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theShape shape to save result
- //! @param theProgress[in] progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange());
-
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theShape shape to export
- //! @param theProgress[in] progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange());
-
public:
//! Updates values according the resource file
const Message_ProgressRange& theProgress)
{
(void)theWS;
- return Read(thePath, theDocument, theProgress);
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- Handle(XSControl_WorkSession)& theWS,
- const Message_ProgressRange& theProgress)
-{
- (void)theWS;
- return Write(thePath, theDocument, theProgress);
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool DEBRepCascade_Provider::Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
- if(theDocument.IsNull())
+ if (theDocument.IsNull())
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
thePath << "\t: theDocument shouldn't be null";
return false;
}
TopoDS_Shape aShape;
- if (!Read(thePath, aShape, theProgress))
+ if (!Read(thePath, aShape, theWS, theProgress))
{
return false;
}
//=======================================================================
bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
+ Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
+ (void)theWS;
TopoDS_Shape aShape;
TDF_LabelSequence aLabels;
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
}
aShape = aComp;
}
- return Write(thePath, aShape, theProgress);
+ return Write(thePath, aShape, theWS, theProgress);
}
//=======================================================================
const Message_ProgressRange& theProgress)
{
(void)theWS;
- return Read(thePath, theShape, theProgress);
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- Handle(XSControl_WorkSession)& theWS,
- const Message_ProgressRange& theProgress)
-{
- (void)theWS;
- return Write(thePath, theShape, theProgress);
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool DEBRepCascade_Provider::Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress)
-{
bool isBinaryFormat = true;
{
// probe file header to recognize format
//=======================================================================
bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
+ Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
+ (void)theWS;
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEBRepCascade_ConfigurationNode)))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Unknown format version";
return false;
}
- if (aNode->InternalParameters.WriteNormals &&
+ if (aNode->InternalParameters.WriteNormals &&
aNode->InternalParameters.WriteVersionBin < BinTools_FormatVersion_VERSION_4)
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
return false;
}
}
-
return true;
}
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theDocument document to save result
- //! @param theProgress[in] progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theDocument document to export
- //! @param theProgress[in] progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theShape shape to save result
- //! @param theProgress[in] progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theShape shape to export
- //! @param theProgress[in] progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
public:
//! Gets CAD format name of associated provider
const Message_ProgressRange& theProgress)
{
(void)theWS;
- return Read(thePath, theDocument, theProgress);
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool DEXCAFCascade_Provider::Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- Handle(XSControl_WorkSession)& theWS,
- const Message_ProgressRange& theProgress)
-{
- (void)theWS;
- return Write(thePath, theDocument, theProgress);
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
if (theDocument.IsNull())
{
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file " <<
//=======================================================================
bool DEXCAFCascade_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
+ Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
+ (void)theWS;
Handle(TDocStd_Application) anApp = new TDocStd_Application();
BinXCAFDrivers::DefineFormat(anApp);
PCDM_StoreStatus aStatus = PCDM_SS_Doc_IsNull;
const Message_ProgressRange& theProgress)
{
(void)theWS;
- return Read(thePath, theShape, theProgress);
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool DEXCAFCascade_Provider::Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- Handle(XSControl_WorkSession)& theWS,
- const Message_ProgressRange& theProgress)
-{
- (void)theWS;
- return Write(thePath, theShape, theProgress);
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress)
-{
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEXCAFCascade_ConfigurationNode)))
{
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file " << thePath
Handle(TDocStd_Application) anApp = new TDocStd_Application();
BinXCAFDrivers::DefineFormat(anApp);
anApp->NewDocument("BinXCAF", aDocument);
- Read(thePath, aDocument, theProgress);
+ Read(thePath, aDocument, theWS, theProgress);
TDF_LabelSequence aLabels;
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main());
aSTool->GetFreeShapes(aLabels);
//=======================================================================
bool DEXCAFCascade_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
+ Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
+ (void)theWS;
Handle(TDocStd_Document) aDoc = new TDocStd_Document("BinXCAF");
Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
aShTool->AddShape(theShape);
- return Write(thePath, aDoc, theProgress);
+ return Write(thePath, aDoc, theWS, theProgress);
}
//=======================================================================
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theDocument document to save result
- //! @param theProgress[in] progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theDocument document to export
- //! @param theProgress[in] progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theShape shape to save result
- //! @param theProgress[in] progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theShape shape to export
- //! @param theProgress[in] progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
public:
//! Gets CAD format name of associated provider
<< " Null work session, use internal temporary session";
theWS = new XSControl_WorkSession();
}
- Handle(IGESControl_Controller) aCntrl = Handle(IGESControl_Controller)::DownCast(theWS->NormAdaptor());
+ Handle(IGESControl_Controller) aCntrl =
+ Handle(IGESControl_Controller)::DownCast(theWS->NormAdaptor());
if (aCntrl.IsNull())
{
theWS->SelectNorm("IGES");
//=======================================================================
void IGESCAFControl_Provider::initStatic(const Handle(DE_ConfigurationNode)& theNode)
{
- Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(theNode);
+ Handle(IGESCAFControl_ConfigurationNode) aNode =
+ Handle(IGESCAFControl_ConfigurationNode)::DownCast(theNode);
IGESData::Init();
-
+ if (!myToUpdateStaticParameters)
+ {
+ return;
+ }
// Get previous values
- myOldValues.ReadBSplineContinuity = (IGESCAFControl_ConfigurationNode::ReadMode_BSplineContinuity)Interface_Static::IVal("read.iges.bspline.continuity");
- myOldValues.ReadPrecisionMode = (IGESCAFControl_ConfigurationNode::ReadMode_Precision)Interface_Static::IVal("read.precision.mode");
- myOldValues.ReadPrecisionVal = Interface_Static::RVal("read.precision.val");
- myOldValues.ReadMaxPrecisionMode = (IGESCAFControl_ConfigurationNode::ReadMode_MaxPrecision)Interface_Static::IVal("read.maxprecision.mode");
- myOldValues.ReadMaxPrecisionVal = Interface_Static::RVal("read.maxprecision.val");
- myOldValues.ReadSameParamMode = Interface_Static::IVal("read.stdsameparameter.mode") == 1;
- myOldValues.ReadSurfaceCurveMode = (IGESCAFControl_ConfigurationNode::ReadMode_SurfaceCurve)Interface_Static::IVal("read.surfacecurve.mode");
- myOldValues.EncodeRegAngle = Interface_Static::RVal("read.encoderegularity.angle") * 180.0 / M_PI;
-
- myOldValues.ReadApproxd1 = Interface_Static::IVal("read.iges.bspline.approxd1.mode") == 1;
- myOldValues.ReadResourceName = Interface_Static::CVal("read.iges.resource.name");
- myOldValues.ReadSequence = Interface_Static::CVal("read.iges.sequence");
- myOldValues.ReadFaultyEntities = Interface_Static::IVal("read.iges.faulty.entities") == 1;
- myOldValues.ReadOnlyVisible = Interface_Static::IVal("read.iges.onlyvisible") == 1;
-
- myOldValues.WriteBRepMode = (IGESCAFControl_ConfigurationNode::WriteMode_BRep)Interface_Static::IVal("write.iges.brep.mode");
- myOldValues.WriteConvertSurfaceMode = (IGESCAFControl_ConfigurationNode::WriteMode_ConvertSurface)Interface_Static::IVal("write.convertsurface.mode");
- myOldValues.WriteUnit = (UnitsMethods_LengthUnit)Interface_Static::IVal("write.iges.unit");
- myOldValues.WriteHeaderAuthor = Interface_Static::CVal("write.iges.header.author");
- myOldValues.WriteHeaderCompany = Interface_Static::CVal("write.iges.header.company");
- myOldValues.WriteHeaderProduct = Interface_Static::CVal("write.iges.header.product");
- myOldValues.WriteHeaderReciever = Interface_Static::CVal("write.iges.header.receiver");
- myOldValues.WriteResourceName = Interface_Static::CVal("write.iges.resource.name");
- myOldValues.WriteSequence = Interface_Static::CVal("write.iges.sequence");
- myOldValues.WritePrecisionMode = (IGESCAFControl_ConfigurationNode::WriteMode_PrecisionMode)Interface_Static::IVal("write.precision.mode");
- myOldValues.WritePrecisionVal = Interface_Static::RVal("write.precision.val");
- myOldValues.WritePlaneMode = (IGESCAFControl_ConfigurationNode::WriteMode_PlaneMode)Interface_Static::IVal("write.iges.plane.mode");
- myOldValues.WriteOffsetMode = Interface_Static::IVal("write.iges.offset.mode") == 1;
-
- myOldLengthUnit = Interface_Static::IVal("xstep.cascade.unit");
+ myOldValues.ReadBSplineContinuity =
+ (IGESCAFControl_ConfigurationNode::ReadMode_BSplineContinuity)
+ Interface_Static::IVal("read.iges.bspline.continuity");
+ myOldValues.ReadPrecisionMode =
+ (IGESCAFControl_ConfigurationNode::ReadMode_Precision)
+ Interface_Static::IVal("read.precision.mode");
+ myOldValues.ReadPrecisionVal =
+ Interface_Static::RVal("read.precision.val");
+ myOldValues.ReadMaxPrecisionMode =
+ (IGESCAFControl_ConfigurationNode::ReadMode_MaxPrecision)
+ Interface_Static::IVal("read.maxprecision.mode");
+ myOldValues.ReadMaxPrecisionVal =
+ Interface_Static::RVal("read.maxprecision.val");
+ myOldValues.ReadSameParamMode =
+ Interface_Static::IVal("read.stdsameparameter.mode") == 1;
+ myOldValues.ReadSurfaceCurveMode =
+ (IGESCAFControl_ConfigurationNode::ReadMode_SurfaceCurve)
+ Interface_Static::IVal("read.surfacecurve.mode");
+ myOldValues.EncodeRegAngle =
+ Interface_Static::RVal("read.encoderegularity.angle") * 180.0 / M_PI;
+
+ myOldValues.ReadApproxd1 =
+ Interface_Static::IVal("read.iges.bspline.approxd1.mode") == 1;
+ myOldValues.ReadResourceName =
+ Interface_Static::CVal("read.iges.resource.name");
+ myOldValues.ReadSequence =
+ Interface_Static::CVal("read.iges.sequence");
+ myOldValues.ReadFaultyEntities =
+ Interface_Static::IVal("read.iges.faulty.entities") == 1;
+ myOldValues.ReadOnlyVisible =
+ Interface_Static::IVal("read.iges.onlyvisible") == 1;
+
+ myOldValues.WriteBRepMode =
+ (IGESCAFControl_ConfigurationNode::WriteMode_BRep)
+ Interface_Static::IVal("write.iges.brep.mode");
+ myOldValues.WriteConvertSurfaceMode =
+ (IGESCAFControl_ConfigurationNode::WriteMode_ConvertSurface)
+ Interface_Static::IVal("write.convertsurface.mode");
+ myOldValues.WriteUnit =
+ (UnitsMethods_LengthUnit)
+ Interface_Static::IVal("write.iges.unit");
+ myOldValues.WriteHeaderAuthor =
+ Interface_Static::CVal("write.iges.header.author");
+ myOldValues.WriteHeaderCompany =
+ Interface_Static::CVal("write.iges.header.company");
+ myOldValues.WriteHeaderProduct =
+ Interface_Static::CVal("write.iges.header.product");
+ myOldValues.WriteHeaderReciever =
+ Interface_Static::CVal("write.iges.header.receiver");
+ myOldValues.WriteResourceName =
+ Interface_Static::CVal("write.iges.resource.name");
+ myOldValues.WriteSequence =
+ Interface_Static::CVal("write.iges.sequence");
+ myOldValues.WritePrecisionMode =
+ (IGESCAFControl_ConfigurationNode::WriteMode_PrecisionMode)
+ Interface_Static::IVal("write.precision.mode");
+ myOldValues.WritePrecisionVal =
+ Interface_Static::RVal("write.precision.val");
+ myOldValues.WritePlaneMode =
+ (IGESCAFControl_ConfigurationNode::WriteMode_PlaneMode)
+ Interface_Static::IVal("write.iges.plane.mode");
+ myOldValues.WriteOffsetMode =
+ Interface_Static::IVal("write.iges.offset.mode") == 1;
+
+ myOldGlobalValues.LengthUnit = Interface_Static::IVal("xstep.cascade.unit");
// Set new values
- UnitsMethods::SetCasCadeLengthUnit(aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
- TCollection_AsciiString aStrUnit(UnitsMethods::DumpLengthUnit(aNode->GlobalParameters.LengthUnit));
+ UnitsMethods::SetCasCadeLengthUnit(aNode->GlobalParameters.LengthUnit,
+ UnitsMethods_LengthUnit_Millimeter);
+ TCollection_AsciiString aStrUnit(
+ UnitsMethods::DumpLengthUnit(aNode->GlobalParameters.LengthUnit));
aStrUnit.UpperCase();
Interface_Static::SetCVal("xstep.cascade.unit", aStrUnit.ToCString());
setStatic(aNode->InternalParameters);
//=======================================================================
void IGESCAFControl_Provider::setStatic(const IGESCAFControl_ConfigurationNode::IGESCAFControl_InternalSection theParameter)
{
- Interface_Static::SetIVal("read.iges.bspline.continuity", theParameter.ReadBSplineContinuity);
- Interface_Static::SetIVal("read.precision.mode", theParameter.ReadPrecisionMode);
- Interface_Static::SetRVal("read.precision.val", theParameter.ReadPrecisionVal);
- Interface_Static::SetIVal("read.maxprecision.mode", theParameter.ReadMaxPrecisionMode);
- Interface_Static::SetRVal("read.maxprecision.val", theParameter.ReadMaxPrecisionVal);
- Interface_Static::SetIVal("read.stdsameparameter.mode", theParameter.ReadSameParamMode);
- Interface_Static::SetIVal("read.surfacecurve.mode", theParameter.ReadSurfaceCurveMode);
- Interface_Static::SetRVal("read.encoderegularity.angle", theParameter.EncodeRegAngle * M_PI / 180.0);
-
- Interface_Static::SetIVal("read.iges.bspline.approxd1.mode", theParameter.ReadApproxd1);
- Interface_Static::SetCVal("read.iges.resource.name", theParameter.ReadResourceName.ToCString());
- Interface_Static::SetCVal("read.iges.sequence", theParameter.ReadSequence.ToCString());
- Interface_Static::SetIVal("read.iges.faulty.entities", theParameter.ReadFaultyEntities);
- Interface_Static::SetIVal("read.iges.onlyvisible", theParameter.ReadOnlyVisible);
-
- Interface_Static::SetIVal("write.iges.brep.mode", theParameter.WriteBRepMode);
- Interface_Static::SetIVal("write.convertsurface.mode", theParameter.WriteConvertSurfaceMode);
- Interface_Static::SetIVal("write.iges.unit", theParameter.WriteUnit);
- Interface_Static::SetCVal("write.iges.header.author", theParameter.WriteHeaderAuthor.ToCString());
- Interface_Static::SetCVal("write.iges.header.company", theParameter.WriteHeaderCompany.ToCString());
- Interface_Static::SetCVal("write.iges.header.product", theParameter.WriteHeaderProduct.ToCString());
- Interface_Static::SetCVal("write.iges.header.receiver", theParameter.WriteHeaderReciever.ToCString());
- Interface_Static::SetCVal("write.iges.resource.name", theParameter.WriteResourceName.ToCString());
- Interface_Static::SetCVal("write.iges.sequence", theParameter.WriteSequence.ToCString());
- Interface_Static::SetIVal("write.precision.mode", theParameter.WritePrecisionMode);
- Interface_Static::SetRVal("write.precision.val", theParameter.WritePrecisionVal);
- Interface_Static::SetIVal("write.iges.plane.mode", theParameter.WritePlaneMode);
- Interface_Static::SetIVal("write.iges.offset.mode", theParameter.WriteOffsetMode);
+ Interface_Static::SetIVal("read.iges.bspline.continuity",
+ theParameter.ReadBSplineContinuity);
+ Interface_Static::SetIVal("read.precision.mode",
+ theParameter.ReadPrecisionMode);
+ Interface_Static::SetRVal("read.precision.val",
+ theParameter.ReadPrecisionVal);
+ Interface_Static::SetIVal("read.maxprecision.mode",
+ theParameter.ReadMaxPrecisionMode);
+ Interface_Static::SetRVal("read.maxprecision.val",
+ theParameter.ReadMaxPrecisionVal);
+ Interface_Static::SetIVal("read.stdsameparameter.mode",
+ theParameter.ReadSameParamMode);
+ Interface_Static::SetIVal("read.surfacecurve.mode",
+ theParameter.ReadSurfaceCurveMode);
+ Interface_Static::SetRVal("read.encoderegularity.angle",
+ theParameter.EncodeRegAngle * M_PI / 180.0);
+
+ Interface_Static::SetIVal("read.iges.bspline.approxd1.mode",
+ theParameter.ReadApproxd1);
+ Interface_Static::SetCVal("read.iges.resource.name",
+ theParameter.ReadResourceName.ToCString());
+ Interface_Static::SetCVal("read.iges.sequence",
+ theParameter.ReadSequence.ToCString());
+ Interface_Static::SetIVal("read.iges.faulty.entities",
+ theParameter.ReadFaultyEntities);
+ Interface_Static::SetIVal("read.iges.onlyvisible",
+ theParameter.ReadOnlyVisible);
+
+ Interface_Static::SetIVal("write.iges.brep.mode",
+ theParameter.WriteBRepMode);
+ Interface_Static::SetIVal("write.convertsurface.mode",
+ theParameter.WriteConvertSurfaceMode);
+ Interface_Static::SetIVal("write.iges.unit",
+ theParameter.WriteUnit);
+ Interface_Static::SetCVal("write.iges.header.author",
+ theParameter.WriteHeaderAuthor.ToCString());
+ Interface_Static::SetCVal("write.iges.header.company",
+ theParameter.WriteHeaderCompany.ToCString());
+ Interface_Static::SetCVal("write.iges.header.product",
+ theParameter.WriteHeaderProduct.ToCString());
+ Interface_Static::SetCVal("write.iges.header.receiver",
+ theParameter.WriteHeaderReciever.ToCString());
+ Interface_Static::SetCVal("write.iges.resource.name",
+ theParameter.WriteResourceName.ToCString());
+ Interface_Static::SetCVal("write.iges.sequence",
+ theParameter.WriteSequence.ToCString());
+ Interface_Static::SetIVal("write.precision.mode",
+ theParameter.WritePrecisionMode);
+ Interface_Static::SetRVal("write.precision.val",
+ theParameter.WritePrecisionVal);
+ Interface_Static::SetIVal("write.iges.plane.mode",
+ theParameter.WritePlaneMode);
+ Interface_Static::SetIVal("write.iges.offset.mode",
+ theParameter.WriteOffsetMode);
}
//=======================================================================
//=======================================================================
void IGESCAFControl_Provider::resetStatic()
{
- Interface_Static::SetIVal("xstep.cascade.unit", myOldLengthUnit);
- UnitsMethods::SetCasCadeLengthUnit(myOldLengthUnit);
+ if (!myToUpdateStaticParameters)
+ {
+ return;
+ }
+ Interface_Static::SetIVal("xstep.cascade.unit", myOldGlobalValues.LengthUnit);
+ UnitsMethods::SetCasCadeLengthUnit(myOldGlobalValues.LengthUnit);
setStatic(myOldValues);
}
{
if (theDocument.IsNull())
{
- Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
- thePath << "\t: theDocument shouldn't be null";
+ Message::SendFail() << "Error: IGESCAFControl_Provider : "
+ << "Null document";
return false;
}
if (!GetNode()->IsKind(STANDARD_TYPE(IGESCAFControl_ConfigurationNode)))
{
- Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
- thePath << "\t: Incorrect or empty Configuration Node";
+ Message::SendFail() << "Error: IGESCAFControl_Provider : "
+ << "Incorrect or empty Configuration Node";
return false;
}
- Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
+ 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;
- aReader.SetWS(theWS);
-
+ XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
+ aNode->GlobalParameters.LengthUnit,
+ UnitsMethods_LengthUnit_Millimeter);
+ const Standard_Boolean toUseLoaded = thePath == ".";
+ TCollection_AsciiString aFile;
+ if (toUseLoaded)
+ {
+ aFile = theWS->LoadedFile();
+ Message::SendInfo() << "Model taken from the IGES session : "
+ << aFile;
+ }
+ else
+ {
+ aFile = thePath;
+ Message::SendInfo() << "File IGES to read : "
+ << aFile;
+ }
+ IGESCAFControl_Reader aReader(theWS, !toUseLoaded);
aReader.SetReadVisible(aNode->InternalParameters.ReadOnlyVisible);
-
aReader.SetColorMode(aNode->InternalParameters.ReadColor);
aReader.SetNameMode(aNode->InternalParameters.ReadName);
aReader.SetLayerMode(aNode->InternalParameters.ReadLayer);
IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
- aReadStat = aReader.ReadFile(thePath.ToCString());
+ if (!toUseLoaded)
+ {
+ aReadStat = aReader.ReadFile(thePath.ToCString());
+ }
+ else if (theWS->NbStartingEntities() > 0)
+ {
+ aReadStat = IFSelect_RetDone;
+ }
if (aReadStat != IFSelect_RetDone)
{
- Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
- thePath << "\t: abandon, no model loaded";
+ Message::SendFail() << "Error: IGESCAFControl_Provider : ["
+ << aFile << "] : abandon, no model loaded";
resetStatic();
return false;
}
-
if (!aReader.Transfer(theDocument, theProgress))
{
- Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
- thePath << "\t: Cannot read any relevant data from the IGES file";
+ Message::SendFail() << "Error: IGESCAFControl_Provider : [" <<
+ aFile << "] : Cannot read any relevant data from the IGES file";
resetStatic();
return false;
}
{
if (!GetNode()->IsKind(STANDARD_TYPE(IGESCAFControl_ConfigurationNode)))
{
- Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
- thePath << "\t: Incorrect or empty Configuration Node";
+ Message::SendFail() << "Error: IGESCAFControl_Provider : "
+ << "Incorrect or empty Configuration Node";
return false;
}
- Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
+ 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(theWS);
+ XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
+ aNode->InternalParameters.WriteUnit,
+ UnitsMethods_LengthUnit_Millimeter);
+ IGESCAFControl_Writer aWriter(theWS, Standard_True);
aWriter.SetColorMode(aNode->InternalParameters.WriteColor);
aWriter.SetNameMode(aNode->InternalParameters.WriteName);
aWriter.SetLayerMode(aNode->InternalParameters.WriteLayer);
if (!aWriter.Transfer(theDocument, theProgress))
{
- Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
- thePath << "\t: The document cannot be translated or gives no result";
+ Message::SendFail() << "Error: IGESCAFControl_Provider : "
+ << "The document cannot be translated or gives no result";
resetStatic();
return false;
}
+ if (thePath == ".")
+ {
+ resetStatic();
+ Message::SendInfo() << "Document has been translated into the session";
+ return true;
+ }
if (!aWriter.Write(thePath.ToCString()))
{
- Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
- thePath << "\t: Write failed";
+ Message::SendFail() << "Error: IGESCAFControl_Provider : [" <<
+ thePath << "] : Write failed";
resetStatic();
return false;
}
+ Message::SendInfo() << "IGES file [" << thePath << "] Successfully written";
resetStatic();
return true;
}
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool IGESCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
- Handle(XSControl_WorkSession) aWS = new XSControl_WorkSession();
- return Read(thePath, theDocument, aWS, theProgress);
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool IGESCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
- Handle(XSControl_WorkSession) aWS = new XSControl_WorkSession();
- return Write(thePath, theDocument, aWS, theProgress);
-}
-
//=======================================================================
// function : Read
// purpose :
(void)theProgress;
if (!GetNode()->IsKind(STANDARD_TYPE(IGESCAFControl_ConfigurationNode)))
{
- Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
- thePath << "\t: Incorrect or empty Configuration Node";
+ Message::SendFail() << "Error: IGESCAFControl_Provider : "
+ << "Incorrect or empty Configuration Node";
return false;
}
- Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
+ Handle(IGESCAFControl_ConfigurationNode) aNode =
+ Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
initStatic(aNode);
personizeWS(theWS);
IGESControl_Reader aReader;
aReadStat = aReader.ReadFile(thePath.ToCString());
if (aReadStat != IFSelect_RetDone)
{
- Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
- thePath << "\t: Could not read file, no model loaded";
+ Message::SendFail() << "Error: IGESCAFControl_Provider : [" <<
+ thePath << "] : Could not read file, no model loaded";
resetStatic();
return false;
}
if (aReader.TransferRoots() <= 0)
{
- Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
- thePath << "\t: Cannot read any relevant data from the IGES file";
+ Message::SendFail() << "Error: IGESCAFControl_Provider : [" <<
+ thePath << "] : Cannot read any relevant data from the IGES file";
resetStatic();
return false;
}
(void)theProgress;
if (!GetNode()->IsKind(STANDARD_TYPE(IGESCAFControl_ConfigurationNode)))
{
- Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
- thePath << "\t: Incorrect or empty Configuration Node";
+ Message::SendFail() << "Error: IGESCAFControl_Provider : "
+ << "Incorrect or empty Configuration Node";
return false;
}
- Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
+ Handle(IGESCAFControl_ConfigurationNode) aNode =
+ Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
initStatic(aNode);
- TCollection_AsciiString aUnit(UnitsMethods::DumpLengthUnit(aNode->InternalParameters.WriteUnit));
+ TCollection_AsciiString aUnit(
+ UnitsMethods::DumpLengthUnit(aNode->InternalParameters.WriteUnit));
aUnit.UpperCase();
IGESControl_Writer aWriter(aUnit.ToCString(),
aNode->InternalParameters.WriteBRepMode);
Standard_Boolean aIsOk = aWriter.AddShape(theShape);
if (!aIsOk)
{
- Message::SendFail() << "IGESCAFControl_Provider: Shape not written";
+ Message::SendFail() << "Error: IGESCAFControl_Provider : "
+ << "Can't translate shape to IGES model";
resetStatic();
return false;
}
if (!(aWriter.Write(thePath.ToCString())))
{
- Message::SendFail() << "IGESCAFControl_Provider: Error on writing file " << thePath;
+ Message::SendFail() << "Error: IGESCAFControl_Provider : "
+ << "Can't write IGES file" << thePath;
resetStatic();
return false;
}
return true;
}
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool IGESCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress)
-{
- Handle(XSControl_WorkSession) aWS = new XSControl_WorkSession();
- return Read(thePath, theShape, aWS, theProgress);
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool IGESCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress)
-{
- Handle(XSControl_WorkSession) aWS = new XSControl_WorkSession();
- return Write(thePath, theShape, aWS, theProgress);
-}
-
//=======================================================================
// function : GetFormat
// purpose :
#define _IGESCAFControl_Provider_HeaderFile
#include <DE_Provider.hxx>
+#include <DE_ConfigurationNode.hxx>
#include <IGESCAFControl_ConfigurationNode.hxx>
//! The class to transfer IGES files.
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theDocument document to save result
- //! @param theProgress[in] progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theDocument document to export
- //! @param theProgress[in] progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theShape shape to save result
- //! @param theProgress[in] progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theShape shape to export
- //! @param theProgress[in] progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
public:
//! Gets CAD format name of associated provider
//! @return provider's vendor name
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+public:
+
+ //! Sets parameter to update static parameter, that true by default
+ void SetToUpdateStaticParameters(const bool theToUpdate) { myToUpdateStaticParameters = theToUpdate; }
+
+ //! Gets parameter to update static parameter, that true by default
+ bool ToUpdateStaticParameters() const { return myToUpdateStaticParameters; }
+
private:
//! Personizes work session with current format.
//! Reset used interface static variables
void resetStatic();
- IGESCAFControl_ConfigurationNode::IGESCAFControl_InternalSection myOldValues;
- int myOldLengthUnit = 1;
+private:
+
+ bool myToUpdateStaticParameters = true; //!< Flag to updating static parameters
+ IGESCAFControl_ConfigurationNode::IGESCAFControl_InternalSection myOldValues; //!< Container to save previous static parameters
+ IGESCAFControl_ConfigurationNode::DE_SectionGlobal myOldGlobalValues; //!< Container to save previous static parameters
};
#include <XCAFDoc_ShapeTool.hxx>
#include <XCAFDoc_DocumentTool.hxx>
-namespace
+namespace
{
//=======================================================================
// function : SetReaderParameters
const Message_ProgressRange& theProgress)
{
(void)theWS;
- return Read(thePath, theDocument, theProgress);
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool RWGltf_Provider::Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- Handle(XSControl_WorkSession)& theWS,
- const Message_ProgressRange& theProgress)
-{
- (void)theWS;
- return Write(thePath, theDocument, theProgress);
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool RWGltf_Provider::Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
if (theDocument.IsNull())
{
Message::SendFail() << "Error in the RWGltf_Provider during reading the file " <<
Message::SendFail() << "Error in the RWGltf_Provider during reading the file " << thePath;
return false;
}
-
+
return true;
}
//=======================================================================
bool RWGltf_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
+ Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
+ (void)theWS;
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWGltf_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWGltf_Provider during writing the file " <<
const Message_ProgressRange& theProgress)
{
(void)theWS;
- return Read(thePath, theShape, theProgress);
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool RWGltf_Provider::Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- Handle(XSControl_WorkSession)& theWS,
- const Message_ProgressRange& theProgress)
-{
- (void)theWS;
- return Write(thePath, theShape, theProgress);
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool RWGltf_Provider::Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress)
-{
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWGltf_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWGltf_Provider during reading the file " <<
//=======================================================================
bool RWGltf_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
+ Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
+ (void)theWS;
Handle(TDocStd_Document) aDoc = new TDocStd_Document("BinXCAF");
Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
aShTool->AddShape(theShape);
- return Write(thePath, aDoc, theProgress);
+ return Write(thePath, aDoc, theWS, theProgress);
}
//=======================================================================
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theDocument document to save result
- //! @param theProgress[in] progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theDocument document to export
- //! @param theProgress[in] progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theShape shape to save result
- //! @param theProgress[in] progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theShape shape to export
- //! @param theProgress[in] progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
public:
//! Gets CAD format name of associated provider
const Message_ProgressRange& theProgress)
{
(void)theWS;
- return Read(thePath, theDocument, theProgress);
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- Handle(XSControl_WorkSession)& theWS,
- const Message_ProgressRange& theProgress)
-{
- (void)theWS;
- return Write(thePath, theDocument, theProgress);
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
if (theDocument.IsNull())
{
Message::SendFail() << "Error in the RWObj_Provider during reading the file " <<
//=======================================================================
bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
+ Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
+ (void)theWS;
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWObj_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWObj_ConfigurationNode during writing the file " <<
const Message_ProgressRange& theProgress)
{
(void)theWS;
- return Read(thePath, theShape, theProgress);
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- Handle(XSControl_WorkSession)& theWS,
- const Message_ProgressRange& theProgress)
-{
- (void)theWS;
- return Write(thePath, theShape, theProgress);
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress)
-{
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWObj_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWObj_ConfigurationNode during writing the file " <<
//=======================================================================
bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
+ Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
+ (void)theWS;
Handle(TDocStd_Document) aDoc = new TDocStd_Document("BinXCAF");
Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
aShTool->AddShape(theShape);
- return Write(thePath, aDoc, theProgress);
+ return Write(thePath, aDoc, theWS, theProgress);
}
//=======================================================================
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theDocument document to save result
- //! @param theProgress[in] progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theDocument document to export
- //! @param theProgress[in] progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theShape shape to save result
- //! @param theProgress[in] progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theShape shape to export
- //! @param theProgress[in] progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
public:
//! Gets CAD format name of associated provider
const Message_ProgressRange& theProgress)
{
(void)theWS;
- return Write(thePath, theDocument, theProgress);
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool RWPly_Provider::Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWPly_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWPly_Provider during writing the file " <<
aPlyCtx.SetFaceId(aNode->InternalParameters.WriteFaceId);
if (!aPlyCtx.Perform(theDocument, aFileInfo, theProgress))
{
- Message::SendFail() << "Error in the RWPly_Provider during writing the file "
+ Message::SendFail() << "Error in the RWPly_Provider during writing the file "
<< thePath << "\t: Cannot perform the document";
return false;
}
const Message_ProgressRange& theProgress)
{
(void)theWS;
- return Write(thePath, theShape, theProgress);
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool RWPly_Provider::Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress)
-{
Handle(TDocStd_Document) aDoc = new TDocStd_Document("BinXCAF");
Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
aShTool->AddShape(theShape);
- return Write(thePath, aDoc, theProgress);
+ return Write(thePath, aDoc, theWS, theProgress);
}
//=======================================================================
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theDocument document to export
- //! @param theProgress[in] progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theShape shape to export
- //! @param theProgress[in] progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
public:
//! Gets CAD format name of associated provider
const Message_ProgressRange& theProgress)
{
(void)theWS;
- return Read(thePath, theDocument, theProgress);
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool RWStl_Provider::Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- Handle(XSControl_WorkSession)& theWS,
- const Message_ProgressRange& theProgress)
-{
- (void)theWS;
- return Write(thePath, theDocument, theProgress);
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool RWStl_Provider::Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
if (theDocument.IsNull())
{
Message::SendFail() << "Error in the RWStl_Provider during reading the file " <<
return false;
}
TopoDS_Shape aShape;
- if (!Read(thePath, aShape, theProgress))
+ if (!Read(thePath, aShape, theWS, theProgress))
{
return false;
}
//=======================================================================
bool RWStl_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
+ Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
+ (void)theWS;
TopoDS_Shape aShape;
TDF_LabelSequence aLabels;
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
}
aShape = aComp;
}
- return Write(thePath, aShape, theProgress);
+ return Write(thePath, aShape, theWS, theProgress);
}
//=======================================================================
const Message_ProgressRange& theProgress)
{
(void)theWS;
- return Read(thePath, theShape, theProgress);
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool RWStl_Provider::Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- Handle(XSControl_WorkSession)& theWS,
- const Message_ProgressRange& theProgress)
-{
- (void)theWS;
- return Write(thePath, theShape, theProgress);
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool RWStl_Provider::Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress)
-{
Message::SendWarning() << "OCCT Stl reader does not support model scaling according to custom length unit";
if (!GetNode()->IsKind(STANDARD_TYPE(RWStl_ConfigurationNode)))
{
}
Handle(RWStl_ConfigurationNode) aNode = Handle(RWStl_ConfigurationNode)::DownCast(GetNode());
double aMergeAngle = aNode->InternalParameters.ReadMergeAngle * M_PI / 180.0;
- if(aMergeAngle != M_PI_2)
+ if (aMergeAngle != M_PI_2)
{
if (aMergeAngle < 0.0 || aMergeAngle > M_PI_2)
{
//=======================================================================
bool RWStl_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
+ Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
+ (void)theWS;
Message::SendWarning() << "OCCT Stl writer does not support model scaling according to custom length unit";
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWStl_ConfigurationNode)))
{
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theDocument document to save result
- //! @param theProgress[in] progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theDocument document to export
- //! @param theProgress[in] progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theShape shape to save result
- //! @param theProgress[in] progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theShape shape to export
- //! @param theProgress[in] progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
public:
//! Gets CAD format name of associated provider
#include <DE_ConfigurationNode.hxx>
#include <STEPControl_StepModelType.hxx>
#include <Resource_FormatType.hxx>
+#include <TColStd_SequenceOfAsciiString.hxx>
#include <UnitsMethods_LengthUnit.hxx>
//! The purpose of this class is to configure the transfer process for STEP format
bool WriteSurfaceCurMode = true; //<! Indicates whether parametric curves (curves in parametric space of surface) should be written into the STEP file
UnitsMethods_LengthUnit WriteUnit = UnitsMethods_LengthUnit_Millimeter; //<! Defines a unit in which the STEP file should be written
TCollection_AsciiString WriteResourceName = "STEP"; //<! Defines the name of the resource file to write
+ TCollection_AsciiString WriteMultiPrefix; //<! Defines prefix for names of external files, if empty do not make multifile
TCollection_AsciiString WriteSequence = "ToSTEP"; //<! Defines the name of the sequence of operators to write
+ TColStd_SequenceOfAsciiString WriteLabels; //<! Defines list of shape labels to export, if empty import full document
WriteMode_VertexMode WriteVertexMode = WriteMode_VertexMode_OneCompound; //<! Indicates which of free vertices writing mode is switch on
bool WriteSubshapeNames = false; //<! Indicates whether to write sub-shape names to 'Name' attributes of STEP Representation Items
bool WriteColor = true; //<! ColorMode is used to indicate write Colors or not
#include <STEPCAFControl_Controller.hxx>
#include <STEPCAFControl_Reader.hxx>
#include <STEPCAFControl_Writer.hxx>
+#include <TDocStd_Document.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDF_Tool.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XSControl_WorkSession.hxx>
#include <UnitsMethods.hxx>
<< " Null work session, use internal temporary session";
theWS = new XSControl_WorkSession();
}
- Handle(STEPControl_Controller) aCntrl = Handle(STEPControl_Controller)::DownCast(theWS->NormAdaptor());
+ Handle(STEPControl_Controller) aCntrl =
+ Handle(STEPControl_Controller)::DownCast(theWS->NormAdaptor());
if (aCntrl.IsNull())
{
theWS->SelectNorm("STEP");
//=======================================================================
void STEPCAFControl_Provider::initStatic(const Handle(DE_ConfigurationNode)& theNode)
{
- Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(theNode);
+ Handle(STEPCAFControl_ConfigurationNode) aNode =
+ Handle(STEPCAFControl_ConfigurationNode)::DownCast(theNode);
STEPCAFControl_Controller::Init();
-
+ if (!myToUpdateStaticParameters)
+ {
+ return;
+ }
// Get previous values
- myOldValues.ReadBSplineContinuity = (STEPCAFControl_ConfigurationNode::ReadMode_BSplineContinuity)Interface_Static::IVal("read.iges.bspline.continuity");
- myOldValues.ReadPrecisionMode = (STEPCAFControl_ConfigurationNode::ReadMode_Precision)Interface_Static::IVal("read.precision.mode");
- myOldValues.ReadPrecisionVal = Interface_Static::RVal("read.precision.val");
- myOldValues.ReadMaxPrecisionMode = (STEPCAFControl_ConfigurationNode::ReadMode_MaxPrecision)Interface_Static::IVal("read.maxprecision.mode");
- myOldValues.ReadMaxPrecisionVal = Interface_Static::RVal("read.maxprecision.val");
- myOldValues.ReadSameParamMode = Interface_Static::IVal("read.stdsameparameter.mode") == 1;
- myOldValues.ReadSurfaceCurveMode = (STEPCAFControl_ConfigurationNode::ReadMode_SurfaceCurve)Interface_Static::IVal("read.surfacecurve.mode");
- myOldValues.EncodeRegAngle = Interface_Static::RVal("read.encoderegularity.angle") * 180.0 / M_PI;
- myOldValues.AngleUnit = (STEPCAFControl_ConfigurationNode::AngleUnitMode)Interface_Static::IVal("step.angleunit.mode");
-
- myOldValues.ReadResourceName = Interface_Static::CVal("read.step.resource.name");
- myOldValues.ReadSequence = Interface_Static::CVal("read.step.sequence");
- myOldValues.ReadProductMode = Interface_Static::IVal("read.step.product.mode") == 1;
- myOldValues.ReadProductContext = (STEPCAFControl_ConfigurationNode::ReadMode_ProductContext)Interface_Static::IVal("read.step.product.context");
- myOldValues.ReadShapeRepr = (STEPCAFControl_ConfigurationNode::ReadMode_ShapeRepr)Interface_Static::IVal("read.step.shape.repr");
- myOldValues.ReadTessellated = (STEPCAFControl_ConfigurationNode::RWMode_Tessellated)Interface_Static::IVal("read.step.tessellated");
- myOldValues.ReadAssemblyLevel = (STEPCAFControl_ConfigurationNode::ReadMode_AssemblyLevel)Interface_Static::IVal("read.step.assembly.level");
- myOldValues.ReadRelationship = Interface_Static::IVal("read.step.shape.relationship") == 1;
- myOldValues.ReadShapeAspect = Interface_Static::IVal("read.step.shape.aspect") == 1;
- myOldValues.ReadConstrRelation = Interface_Static::IVal("read.step.constructivegeom.relationship") == 1;
- myOldValues.ReadSubshapeNames = Interface_Static::IVal("read.stepcaf.subshapes.name") == 1;
- myOldValues.ReadCodePage = (Resource_FormatType)Interface_Static::IVal("read.step.codepage");
- myOldValues.ReadNonmanifold = Interface_Static::IVal("read.step.nonmanifold") == 1;
- myOldValues.ReadIdeas = Interface_Static::IVal("read.step.ideas") == 1;
- myOldValues.ReadAllShapes = Interface_Static::IVal("read.step.all.shapes") == 1;
- myOldValues.ReadRootTransformation = Interface_Static::IVal("read.step.root.transformation") == 1;
-
- myOldValues.WritePrecisionMode = (STEPCAFControl_ConfigurationNode::WriteMode_PrecisionMode)Interface_Static::IVal("write.precision.mode");
- myOldValues.WritePrecisionVal = Interface_Static::RVal("write.precision.val");
- myOldValues.WriteAssembly = (STEPCAFControl_ConfigurationNode::WriteMode_Assembly)Interface_Static::IVal("write.step.assembly");
- myOldValues.WriteSchema = (STEPCAFControl_ConfigurationNode::WriteMode_StepSchema)Interface_Static::IVal("write.step.schema");
- myOldValues.WriteTessellated = (STEPCAFControl_ConfigurationNode::RWMode_Tessellated)Interface_Static::IVal("write.step.tessellated");
- myOldValues.WriteProductName = Interface_Static::CVal("write.step.product.name");
- myOldValues.WriteSurfaceCurMode = Interface_Static::IVal("write.surfacecurve.mode") == 1;
- myOldValues.WriteUnit = (UnitsMethods_LengthUnit)Interface_Static::IVal("write.step.unit");
- myOldValues.WriteResourceName = Interface_Static::CVal("write.resource.name");
- myOldValues.WriteSequence = Interface_Static::CVal("write.step.sequence");
- myOldValues.WriteVertexMode = (STEPCAFControl_ConfigurationNode::WriteMode_VertexMode)Interface_Static::IVal("write.step.vertex.mode");
- myOldValues.WriteSubshapeNames = Interface_Static::IVal("write.stepcaf.subshapes.name") == 1;
+ myOldValues.ReadBSplineContinuity =
+ (STEPCAFControl_ConfigurationNode::ReadMode_BSplineContinuity)
+ Interface_Static::IVal("read.iges.bspline.continuity");
+ myOldValues.ReadPrecisionMode =
+ (STEPCAFControl_ConfigurationNode::ReadMode_Precision)
+ Interface_Static::IVal("read.precision.mode");
+ myOldValues.ReadPrecisionVal =
+ Interface_Static::RVal("read.precision.val");
+ myOldValues.ReadMaxPrecisionMode =
+ (STEPCAFControl_ConfigurationNode::ReadMode_MaxPrecision)
+ Interface_Static::IVal("read.maxprecision.mode");
+ myOldValues.ReadMaxPrecisionVal =
+ Interface_Static::RVal("read.maxprecision.val");
+ myOldValues.ReadSameParamMode =
+ Interface_Static::IVal("read.stdsameparameter.mode") == 1;
+ myOldValues.ReadSurfaceCurveMode =
+ (STEPCAFControl_ConfigurationNode::ReadMode_SurfaceCurve)
+ Interface_Static::IVal("read.surfacecurve.mode");
+ myOldValues.EncodeRegAngle =
+ Interface_Static::RVal("read.encoderegularity.angle") * 180.0 / M_PI;
+ myOldValues.AngleUnit =
+ (STEPCAFControl_ConfigurationNode::AngleUnitMode)
+ Interface_Static::IVal("step.angleunit.mode");
+
+ myOldValues.ReadResourceName =
+ Interface_Static::CVal("read.step.resource.name");
+ myOldValues.ReadSequence =
+ Interface_Static::CVal("read.step.sequence");
+ myOldValues.ReadProductMode =
+ Interface_Static::IVal("read.step.product.mode") == 1;
+ myOldValues.ReadProductContext =
+ (STEPCAFControl_ConfigurationNode::ReadMode_ProductContext)
+ Interface_Static::IVal("read.step.product.context");
+ myOldValues.ReadShapeRepr =
+ (STEPCAFControl_ConfigurationNode::ReadMode_ShapeRepr)
+ Interface_Static::IVal("read.step.shape.repr");
+ myOldValues.ReadTessellated =
+ (STEPCAFControl_ConfigurationNode::RWMode_Tessellated)
+ Interface_Static::IVal("read.step.tessellated");
+ myOldValues.ReadAssemblyLevel =
+ (STEPCAFControl_ConfigurationNode::ReadMode_AssemblyLevel)
+ Interface_Static::IVal("read.step.assembly.level");
+ myOldValues.ReadRelationship =
+ Interface_Static::IVal("read.step.shape.relationship") == 1;
+ myOldValues.ReadShapeAspect =
+ Interface_Static::IVal("read.step.shape.aspect") == 1;
+ myOldValues.ReadConstrRelation =
+ Interface_Static::IVal("read.step.constructivegeom.relationship") == 1;
+ myOldValues.ReadSubshapeNames =
+ Interface_Static::IVal("read.stepcaf.subshapes.name") == 1;
+ myOldValues.ReadCodePage =
+ (Resource_FormatType)Interface_Static::IVal("read.step.codepage");
+ myOldValues.ReadNonmanifold =
+ Interface_Static::IVal("read.step.nonmanifold") == 1;
+ myOldValues.ReadIdeas =
+ Interface_Static::IVal("read.step.ideas") == 1;
+ myOldValues.ReadAllShapes =
+ Interface_Static::IVal("read.step.all.shapes") == 1;
+ myOldValues.ReadRootTransformation =
+ Interface_Static::IVal("read.step.root.transformation") == 1;
+
+ myOldValues.WritePrecisionMode =
+ (STEPCAFControl_ConfigurationNode::WriteMode_PrecisionMode)
+ Interface_Static::IVal("write.precision.mode");
+ myOldValues.WritePrecisionVal =
+ Interface_Static::RVal("write.precision.val");
+ myOldValues.WriteAssembly =
+ (STEPCAFControl_ConfigurationNode::WriteMode_Assembly)
+ Interface_Static::IVal("write.step.assembly");
+ myOldValues.WriteSchema =
+ (STEPCAFControl_ConfigurationNode::WriteMode_StepSchema)
+ Interface_Static::IVal("write.step.schema");
+ myOldValues.WriteTessellated =
+ (STEPCAFControl_ConfigurationNode::RWMode_Tessellated)
+ Interface_Static::IVal("write.step.tessellated");
+ myOldValues.WriteProductName =
+ Interface_Static::CVal("write.step.product.name");
+ myOldValues.WriteSurfaceCurMode =
+ Interface_Static::IVal("write.surfacecurve.mode") == 1;
+ myOldValues.WriteUnit =
+ (UnitsMethods_LengthUnit)Interface_Static::IVal("write.step.unit");
+ myOldValues.WriteResourceName =
+ Interface_Static::CVal("write.resource.name");
+ myOldValues.WriteSequence =
+ Interface_Static::CVal("write.step.sequence");
+ myOldValues.WriteVertexMode =
+ (STEPCAFControl_ConfigurationNode::WriteMode_VertexMode)
+ Interface_Static::IVal("write.step.vertex.mode");
+ myOldValues.WriteSubshapeNames =
+ Interface_Static::IVal("write.stepcaf.subshapes.name") == 1;
// Set new values
setStatic(aNode->InternalParameters);
//=======================================================================
void STEPCAFControl_Provider::setStatic(const STEPCAFControl_ConfigurationNode::STEPCAFControl_InternalSection theParameter)
{
- Interface_Static::SetIVal("read.iges.bspline.continuity", theParameter.ReadBSplineContinuity);
- Interface_Static::SetIVal("read.precision.mode", theParameter.ReadPrecisionMode);
- Interface_Static::SetRVal("read.precision.val", theParameter.ReadPrecisionVal);
- Interface_Static::SetIVal("read.maxprecision.mode", theParameter.ReadMaxPrecisionMode);
- Interface_Static::SetRVal("read.maxprecision.val", theParameter.ReadMaxPrecisionVal);
- Interface_Static::SetIVal("read.stdsameparameter.mode", theParameter.ReadSameParamMode);
- Interface_Static::SetIVal("read.surfacecurve.mode", theParameter.ReadSurfaceCurveMode);
- Interface_Static::SetRVal("read.encoderegularity.angle", theParameter.EncodeRegAngle * M_PI / 180.0);
- Interface_Static::SetIVal("step.angleunit.mode", theParameter.AngleUnit);
-
- Interface_Static::SetCVal("read.step.resource.name", theParameter.ReadResourceName.ToCString());
- Interface_Static::SetCVal("read.step.sequence", theParameter.ReadSequence.ToCString());
- Interface_Static::SetIVal("read.step.product.mode", theParameter.ReadProductMode);
- Interface_Static::SetIVal("read.step.product.context", theParameter.ReadProductContext);
- Interface_Static::SetIVal("read.step.shape.repr", theParameter.ReadShapeRepr);
- Interface_Static::SetIVal("read.step.tessellated", theParameter.ReadTessellated);
- Interface_Static::SetIVal("read.step.assembly.level", theParameter.ReadAssemblyLevel);
- Interface_Static::SetIVal("read.step.shape.relationship", theParameter.ReadRelationship);
- Interface_Static::SetIVal("read.step.shape.aspect", theParameter.ReadShapeAspect);
- Interface_Static::SetIVal("read.step.constructivegeom.relationship", theParameter.ReadConstrRelation);
- Interface_Static::SetIVal("read.stepcaf.subshapes.name", theParameter.ReadSubshapeNames);
- Interface_Static::SetIVal("read.step.codepage", theParameter.ReadCodePage);
- Interface_Static::SetIVal("read.step.nonmanifold", theParameter.ReadNonmanifold);
- Interface_Static::SetIVal("read.step.ideas", theParameter.ReadIdeas);
- Interface_Static::SetIVal("read.step.all.shapes", theParameter.ReadAllShapes);
- Interface_Static::SetIVal("read.step.root.transformation", theParameter.ReadRootTransformation);
-
- Interface_Static::SetIVal("write.precision.mode", theParameter.WritePrecisionMode);
- Interface_Static::SetRVal("write.precision.val", theParameter.WritePrecisionVal);
- Interface_Static::SetIVal("write.step.assembly", theParameter.WriteAssembly);
- Interface_Static::SetIVal("write.step.schema", theParameter.WriteSchema);
- Interface_Static::SetIVal("write.step.tessellated", theParameter.WriteTessellated);
- Interface_Static::SetCVal("write.step.product.name", theParameter.WriteProductName.ToCString());
- Interface_Static::SetIVal("write.surfacecurve.mode", theParameter.WriteSurfaceCurMode);
- Interface_Static::SetIVal("write.step.unit", theParameter.WriteUnit);
- Interface_Static::SetCVal("write.resource.name", theParameter.WriteResourceName.ToCString());
- Interface_Static::SetCVal("write.step.sequence", theParameter.WriteSequence.ToCString());
- Interface_Static::SetIVal("write.step.vertex.mode", theParameter.WriteVertexMode);
- Interface_Static::SetIVal("write.stepcaf.subshapes.name", theParameter.WriteSubshapeNames);
+ Interface_Static::SetIVal("read.iges.bspline.continuity",
+ theParameter.ReadBSplineContinuity);
+ Interface_Static::SetIVal("read.precision.mode",
+ theParameter.ReadPrecisionMode);
+ Interface_Static::SetRVal("read.precision.val",
+ theParameter.ReadPrecisionVal);
+ Interface_Static::SetIVal("read.maxprecision.mode",
+ theParameter.ReadMaxPrecisionMode);
+ Interface_Static::SetRVal("read.maxprecision.val",
+ theParameter.ReadMaxPrecisionVal);
+ Interface_Static::SetIVal("read.stdsameparameter.mode",
+ theParameter.ReadSameParamMode);
+ Interface_Static::SetIVal("read.surfacecurve.mode",
+ theParameter.ReadSurfaceCurveMode);
+ Interface_Static::SetRVal("read.encoderegularity.angle",
+ theParameter.EncodeRegAngle * M_PI / 180.0);
+ Interface_Static::SetIVal("step.angleunit.mode",
+ theParameter.AngleUnit);
+
+ Interface_Static::SetCVal("read.step.resource.name",
+ theParameter.ReadResourceName.ToCString());
+ Interface_Static::SetCVal("read.step.sequence",
+ theParameter.ReadSequence.ToCString());
+ Interface_Static::SetIVal("read.step.product.mode",
+ theParameter.ReadProductMode);
+ Interface_Static::SetIVal("read.step.product.context",
+ theParameter.ReadProductContext);
+ Interface_Static::SetIVal("read.step.shape.repr",
+ theParameter.ReadShapeRepr);
+ Interface_Static::SetIVal("read.step.tessellated",
+ theParameter.ReadTessellated);
+ Interface_Static::SetIVal("read.step.assembly.level",
+ theParameter.ReadAssemblyLevel);
+ Interface_Static::SetIVal("read.step.shape.relationship",
+ theParameter.ReadRelationship);
+ Interface_Static::SetIVal("read.step.shape.aspect",
+ theParameter.ReadShapeAspect);
+ Interface_Static::SetIVal("read.step.constructivegeom.relationship",
+ theParameter.ReadConstrRelation);
+ Interface_Static::SetIVal("read.stepcaf.subshapes.name",
+ theParameter.ReadSubshapeNames);
+ Interface_Static::SetIVal("read.step.codepage",
+ theParameter.ReadCodePage);
+ Interface_Static::SetIVal("read.step.nonmanifold",
+ theParameter.ReadNonmanifold);
+ Interface_Static::SetIVal("read.step.ideas",
+ theParameter.ReadIdeas);
+ Interface_Static::SetIVal("read.step.all.shapes",
+ theParameter.ReadAllShapes);
+ Interface_Static::SetIVal("read.step.root.transformation",
+ theParameter.ReadRootTransformation);
+
+ Interface_Static::SetIVal("write.precision.mode",
+ theParameter.WritePrecisionMode);
+ Interface_Static::SetRVal("write.precision.val",
+ theParameter.WritePrecisionVal);
+ Interface_Static::SetIVal("write.step.assembly",
+ theParameter.WriteAssembly);
+ Interface_Static::SetIVal("write.step.schema",
+ theParameter.WriteSchema);
+ Interface_Static::SetIVal("write.step.tessellated",
+ theParameter.WriteTessellated);
+ Interface_Static::SetCVal("write.step.product.name",
+ theParameter.WriteProductName.ToCString());
+ Interface_Static::SetIVal("write.surfacecurve.mode",
+ theParameter.WriteSurfaceCurMode);
+ Interface_Static::SetIVal("write.step.unit",
+ theParameter.WriteUnit);
+ Interface_Static::SetCVal("write.resource.name",
+ theParameter.WriteResourceName.ToCString());
+ Interface_Static::SetCVal("write.step.sequence",
+ theParameter.WriteSequence.ToCString());
+ Interface_Static::SetIVal("write.step.vertex.mode",
+ theParameter.WriteVertexMode);
+ Interface_Static::SetIVal("write.stepcaf.subshapes.name",
+ theParameter.WriteSubshapeNames);
}
//=======================================================================
//=======================================================================
void STEPCAFControl_Provider::resetStatic()
{
+ if (!myToUpdateStaticParameters)
+ {
+ return;
+ }
setStatic(myOldValues);
}
{
if (theDocument.IsNull())
{
- Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
- thePath << "\t: theDocument shouldn't be null";
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "Null document";
return false;
}
- if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
+ if (GetNode().IsNull() ||
+ !GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
{
- Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
- thePath << "\t: Incorrect or empty Configuration Node";
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "Incorrect or empty Configuration Node";
return false;
}
- Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
+ 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;
- aReader.Init(theWS);
+ XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
+ aNode->GlobalParameters.LengthUnit,
+ UnitsMethods_LengthUnit_Millimeter);
+ const Standard_Boolean toUseLoaded = thePath == ".";
+ TCollection_AsciiString aFile;
+ if (toUseLoaded)
+ {
+ aFile = theWS->LoadedFile();
+ Message::SendInfo() << "Model taken from the STEP session : "
+ << aFile;
+ }
+ else
+ {
+ aFile = thePath;
+ Message::SendInfo() << "File STEP to read : "
+ << aFile;
+ }
+ STEPCAFControl_Reader aReader(theWS, !toUseLoaded);
aReader.SetColorMode(aNode->InternalParameters.ReadColor);
aReader.SetNameMode(aNode->InternalParameters.ReadName);
aReader.SetLayerMode(aNode->InternalParameters.ReadLayer);
aReader.SetPropsMode(aNode->InternalParameters.ReadProps);
-
IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
- aReadStat = aReader.ReadFile(thePath.ToCString());
+ if (!toUseLoaded)
+ {
+ aReadStat = aReader.ReadFile(thePath.ToCString());
+ }
+ else if (theWS->NbStartingEntities() > 0)
+ {
+ aReadStat = IFSelect_RetDone;
+ }
if (aReadStat != IFSelect_RetDone)
{
- Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
- thePath << "\t: abandon";
+ Message::SendFail() << "Error: STEPCAFControl_Provider : ["
+ << aFile << "] : abandon, no model loaded";
+ resetStatic();
+ return false;
+ }
+ if (!aReader.Transfer(theDocument, theProgress))
+ {
+ Message::SendFail() << "Error: STEPCAFControl_Provider : [" <<
+ aFile << "] : Cannot read any relevant data from the IGES file";
resetStatic();
return false;
}
+ resetStatic();
+ return true;
+}
+
+//=======================================================================
+// function : Read
+// purpose :
+//=======================================================================
+bool STEPCAFControl_Provider::Read(std::istream& theIStream,
+ const Handle(TDocStd_Document)& theDocument,
+ const TCollection_AsciiString theName,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ if (theDocument.IsNull())
+ {
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "Null document";
+ return false;
+ }
+ if (GetNode().IsNull() ||
+ !GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(STEPCAFControl_ConfigurationNode) aNode =
+ Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
+ initStatic(aNode);
+
+ personizeWS(theWS);
+ XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
+ aNode->GlobalParameters.LengthUnit,
+ UnitsMethods_LengthUnit_Millimeter);
+ Message::SendInfo() << "Model taken from the STEP stream";
+ STEPCAFControl_Reader aReader(theWS);
+ aReader.SetColorMode(aNode->InternalParameters.ReadColor);
+ aReader.SetNameMode(aNode->InternalParameters.ReadName);
+ aReader.SetLayerMode(aNode->InternalParameters.ReadLayer);
+ aReader.SetPropsMode(aNode->InternalParameters.ReadProps);
+ IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
+ aReadStat = aReader.ReadStream(theName.ToCString(), theIStream);
+ if (aReadStat != IFSelect_RetDone)
+ {
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "Abandon, no model loaded via stream";
+ resetStatic();
+ return false;
+ }
if (!aReader.Transfer(theDocument, theProgress))
{
- Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
- thePath << "\t: Cannot read any relevant data from the STEP file";
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "Cannot read any relevant data from the IGES file";
resetStatic();
return false;
}
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
- if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
+ if (GetNode().IsNull() ||
+ !GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
{
- Message::SendFail() << "Error in the STEPCAFControl_Provider during writing the file " <<
- thePath << "\t: Incorrect or empty Configuration Node";
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "Incorrect or empty Configuration Node";
return false;
}
- Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
+ Handle(STEPCAFControl_ConfigurationNode) aNode =
+ Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
initStatic(aNode);
-
- XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
- UnitsMethods::GetLengthUnitScale(aNode->InternalParameters.WriteUnit, UnitsMethods_LengthUnit_Millimeter),
+ XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
+ UnitsMethods::GetLengthUnitScale(
+ aNode->InternalParameters.WriteUnit,
+ UnitsMethods_LengthUnit_Millimeter),
UnitsMethods_LengthUnit_Millimeter);
personizeWS(theWS);
- STEPCAFControl_Writer aWriter;
- aWriter.Init(theWS);
- STEPControl_StepModelType aMode = static_cast<STEPControl_StepModelType>(aNode->InternalParameters.WriteModelType);
+ STEPCAFControl_Writer aWriter(theWS, Standard_True);
+ STEPControl_StepModelType aMode =
+ static_cast<STEPControl_StepModelType>(aNode->InternalParameters.WriteModelType);
aWriter.SetColorMode(aNode->InternalParameters.WriteColor);
aWriter.SetNameMode(aNode->InternalParameters.WriteName);
aWriter.SetLayerMode(aNode->InternalParameters.WriteLayer);
aWriter.SetPropsMode(aNode->InternalParameters.WriteProps);
- TDF_Label aLabel;
-
- if (!aWriter.Transfer(theDocument, aMode, 0, theProgress))
+ TDF_LabelSequence aLabels;
+ TCollection_AsciiString aLabelsString;
+ for (TColStd_SequenceOfAsciiString::Iterator anIter(aNode->InternalParameters.WriteLabels);
+ anIter.More(); anIter.Next())
+ {
+ const TCollection_AsciiString& aValue = anIter.Value();
+ TDF_Label aLabel;
+ TDF_Tool::Label(theDocument->Main().Data(), aValue, aLabel, Standard_False);
+ if (aLabel.IsNull())
+ {
+ Message::SendFail() << "Error: No label for entry '" << aValue << "'";
+ return false;
+ }
+ if (!aLabelsString.IsEmpty())
+ {
+ aLabelsString += " ";
+ }
+ aLabelsString += aValue;
+ aLabels.Append(aLabel);
+ }
+ TCollection_ExtendedString aDocName;
+ Handle(TDataStd_Name) aNameAttr;
+ if (theDocument->GetData()->Root().FindAttribute(TDataStd_Name::GetID(), aNameAttr))
+ {
+ aDocName = aNameAttr->Get();
+ }
+ Standard_Boolean aTransferStatus = Standard_True;
+ Standard_CString aMultiFilePrefix = !aNode->InternalParameters.WriteMultiPrefix.IsEmpty() ?
+ aNode->InternalParameters.WriteMultiPrefix.ToCString() : nullptr;
+ Message::SendInfo() << "Writing STEP file "
+ << thePath;
+ if (aLabels.IsEmpty())
+ {
+ Message::SendInfo() << "Translating labels "
+ << aLabelsString << " of document " << aDocName << " to STEP";
+ aTransferStatus = aWriter.Transfer(theDocument, aMode, aMultiFilePrefix, theProgress);
+ }
+ else
{
- Message::SendFail() << "Error in the STEPCAFControl_Provider during writing the file " <<
- thePath << "\t: The document cannot be translated or gives no result";
+ Message::SendInfo() << "Translating document "
+ << aDocName << " to STEP";
+ aTransferStatus = aWriter.Transfer(aLabels, aMode, aMultiFilePrefix, theProgress);
+ }
+ if (!aTransferStatus)
+ {
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "The document cannot be translated or gives no result";
resetStatic();
return false;
}
- IFSelect_ReturnStatus aStatus = aWriter.Write(thePath.ToCString());
- switch (aStatus)
+ if (thePath == ".")
{
- case IFSelect_RetVoid:
- {
- Message::SendFail() << "Error in the STEPCAFControl_Provider during writing the file " <<
- thePath << "\t: No file written";
- resetStatic();
- return false;;
- }
- case IFSelect_RetDone:
+ resetStatic();
+ Message::SendInfo() << "Document has been translated into the session";
+ return true;
+ }
+ if (aWriter.Write(thePath.ToCString()) != IFSelect_RetDone)
+ {
+ Message::SendFail() << "Error: STEPCAFControl_Provider : [" <<
+ thePath << "] : Write failed";
+ resetStatic();
+ return false;
+ }
+ Message::SendInfo() << "STEP file [" << thePath << "] Successfully written";
+ resetStatic();
+ return true;
+}
+
+//=======================================================================
+// function : Write
+// purpose :
+//=======================================================================
+bool STEPCAFControl_Provider::Write(std::ostream& theOStream,
+ const Handle(TDocStd_Document)& theDocument,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ if (GetNode().IsNull() ||
+ !GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(STEPCAFControl_ConfigurationNode) aNode =
+ Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
+ initStatic(aNode);
+ XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
+ UnitsMethods::GetLengthUnitScale(
+ aNode->InternalParameters.WriteUnit,
+ UnitsMethods_LengthUnit_Millimeter),
+ UnitsMethods_LengthUnit_Millimeter);
+ personizeWS(theWS);
+ STEPCAFControl_Writer aWriter(theWS, Standard_True);
+ STEPControl_StepModelType aMode =
+ static_cast<STEPControl_StepModelType>(aNode->InternalParameters.WriteModelType);
+ aWriter.SetColorMode(aNode->InternalParameters.WriteColor);
+ aWriter.SetNameMode(aNode->InternalParameters.WriteName);
+ aWriter.SetLayerMode(aNode->InternalParameters.WriteLayer);
+ aWriter.SetPropsMode(aNode->InternalParameters.WriteProps);
+ TDF_LabelSequence aLabels;
+ TCollection_AsciiString aLabelsString;
+ for (TColStd_SequenceOfAsciiString::Iterator anIter(aNode->InternalParameters.WriteLabels);
+ anIter.More(); anIter.Next())
+ {
+ const TCollection_AsciiString& aValue = anIter.Value();
+ TDF_Label aLabel;
+ TDF_Tool::Label(theDocument->Main().Data(), aValue, aLabel, Standard_False);
+ if (aLabel.IsNull())
{
- break;
+ Message::SendFail() << "Error: No label for entry '" << aValue << "'";
+ return false;
}
- default:
+ if (!aLabelsString.IsEmpty())
{
- Message::SendFail() << "Error in the STEPCAFControl_Provider during writing the file " <<
- thePath << "\t: Error on writing file";
- resetStatic();
- return false;
+ aLabelsString += " ";
}
+ aLabelsString += aValue;
+ aLabels.Append(aLabel);
+ }
+ TCollection_ExtendedString aDocName;
+ Handle(TDataStd_Name) aNameAttr;
+ if (theDocument->GetData()->Root().FindAttribute(TDataStd_Name::GetID(), aNameAttr))
+ {
+ aDocName = aNameAttr->Get();
+ }
+ Standard_Boolean aTransferStatus = Standard_True;
+ Standard_CString aMultiFilePrefix = !aNode->InternalParameters.WriteMultiPrefix.IsEmpty() ?
+ aNode->InternalParameters.WriteMultiPrefix.ToCString() : nullptr;
+ Message::SendInfo() << "Writing STEP file to stream";
+ if (aLabels.IsEmpty())
+ {
+ Message::SendInfo() << "Translating labels "
+ << aLabelsString << " of document " << aDocName << " to STEP";
+ aTransferStatus = aWriter.Transfer(theDocument, aMode, aMultiFilePrefix, theProgress);
+ }
+ else
+ {
+ Message::SendInfo() << "Translating document "
+ << aDocName << " to STEP";
+ aTransferStatus = aWriter.Transfer(aLabels, aMode, aMultiFilePrefix, theProgress);
+ }
+ if (!aTransferStatus)
+ {
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "The document cannot be translated or gives no result";
+ resetStatic();
+ return false;
}
+ if (aWriter.WriteStream(theOStream) != IFSelect_RetDone)
+ {
+ Message::SendFail() << "Error: STEPCAFControl_Provider : Write to stream failed";
+ resetStatic();
+ return false;
+ }
+ Message::SendInfo() << "STEP file to stream successfully written";
resetStatic();
return true;
}
// purpose :
//=======================================================================
bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
+ TopoDS_Shape& theShape,
+ Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
- Handle(XSControl_WorkSession) aWS = new XSControl_WorkSession();
- return Read(thePath, theDocument, aWS, theProgress);
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool STEPCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
- Handle(XSControl_WorkSession) aWS = new XSControl_WorkSession();
- return Write(thePath, theDocument, aWS, theProgress);
+ (void)theProgress;
+ if (GetNode().IsNull() ||
+ !GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(STEPCAFControl_ConfigurationNode) aNode =
+ Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
+ initStatic(aNode);
+ personizeWS(theWS);
+ STEPControl_Reader aReader(theWS);
+ if (aReader.ReadFile(thePath.ToCString()) != IFSelect_RetDone)
+ {
+ Message::SendFail() << "Error: STEPCAFControl_Provider : ["
+ << thePath << "] : abandon, no model loaded";
+ resetStatic();
+ return false;
+ }
+ Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(aReader.Model());
+ aModel->SetLocalLengthUnit(aNode->GlobalParameters.LengthUnit);
+ if (aReader.TransferRoots() <= 0)
+ {
+ Message::SendFail() << "Error: STEPCAFControl_Provider : [" <<
+ thePath << "] : Cannot read any relevant data from the STEP file";
+ resetStatic();
+ return false;
+ }
+ theShape = aReader.OneShape();
+ resetStatic();
+ return true;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
-bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
+bool STEPCAFControl_Provider::Read(std::istream& theIStream,
TopoDS_Shape& theShape,
+ const TCollection_AsciiString theName,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theProgress;
- if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
+ if (GetNode().IsNull() ||
+ !GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
{
- Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
- thePath << "\t: Incorrect or empty Configuration Node";
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "Incorrect or empty Configuration Node";
return false;
}
- Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
+ Handle(STEPCAFControl_ConfigurationNode) aNode =
+ Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
initStatic(aNode);
personizeWS(theWS);
- STEPControl_Reader aReader;
- aReader.SetWS(theWS);
- IFSelect_ReturnStatus aReadstat = IFSelect_RetVoid;
- aReadstat = aReader.ReadFile(thePath.ToCString());
- if (aReadstat != IFSelect_RetDone)
- {
- Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
- thePath << "\t: abandon, no model loaded";
+ STEPControl_Reader aReader(theWS);
+ if (aReader.ReadStream(theName.ToCString(), theIStream) != IFSelect_RetDone)
+ {
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "Abandon, no model loaded from STEP stream";
resetStatic();
return false;
}
aModel->SetLocalLengthUnit(aNode->GlobalParameters.LengthUnit);
if (aReader.TransferRoots() <= 0)
{
- Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
- thePath << "\t:Cannot read any relevant data from the STEP file";
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "Cannot read any relevant data from the STEP stream";
resetStatic();
return false;
}
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
- if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
+ if (GetNode().IsNull() ||
+ !GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
{
- Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
- thePath << "\t: Incorrect or empty Configuration Node";
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "Incorrect or empty Configuration Node";
return false;
}
- Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
+ Handle(STEPCAFControl_ConfigurationNode) aNode =
+ Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
initStatic(aNode);
personizeWS(theWS);
- STEPControl_Writer aWriter;
- aWriter.SetWS(theWS);
- IFSelect_ReturnStatus aWritestat = IFSelect_RetVoid;
+ STEPControl_Writer aWriter(theWS, Standard_True);
Handle(StepData_StepModel) aModel = aWriter.Model();
- aModel->SetWriteLengthUnit(UnitsMethods::GetLengthUnitScale(aNode->InternalParameters.WriteUnit, UnitsMethods_LengthUnit_Millimeter));
- aWritestat = aWriter.Transfer(theShape, aNode->InternalParameters.WriteModelType, true, theProgress);
+ aModel->SetWriteLengthUnit(UnitsMethods::GetLengthUnitScale(
+ aNode->InternalParameters.WriteUnit,
+ UnitsMethods_LengthUnit_Millimeter));
+ IFSelect_ReturnStatus aWritestat =
+ aWriter.Transfer(theShape, aNode->InternalParameters.WriteModelType, true, theProgress);
if (aWritestat != IFSelect_RetDone)
{
- Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
- thePath << "\t: abandon, no model loaded";
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "Can't translate shape to STEP model";
resetStatic();
return false;
}
if (aWriter.Write(thePath.ToCString()) != IFSelect_RetDone)
{
- Message::SendFail() << "STEPCAFControl_Provider: Error on writing file";
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "Can't write STEP file " << thePath;
resetStatic();
return false;
}
return true;
}
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress)
-{
- Handle(XSControl_WorkSession) aWS = new XSControl_WorkSession();
- return Read(thePath, theShape, aWS, theProgress);
-}
-
//=======================================================================
// function : Write
// purpose :
//=======================================================================
-bool STEPCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
+bool STEPCAFControl_Provider::Write(std::ostream& theOStream,
const TopoDS_Shape& theShape,
+ Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
- Handle(XSControl_WorkSession) aWS = new XSControl_WorkSession();
- return Write(thePath, theShape, aWS, theProgress);
+ if (GetNode().IsNull() ||
+ !GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(STEPCAFControl_ConfigurationNode) aNode =
+ Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
+ initStatic(aNode);
+
+ personizeWS(theWS);
+ STEPControl_Writer aWriter(theWS, Standard_True);
+ Handle(StepData_StepModel) aModel = aWriter.Model();
+ aModel->SetWriteLengthUnit(UnitsMethods::GetLengthUnitScale(
+ aNode->InternalParameters.WriteUnit,
+ UnitsMethods_LengthUnit_Millimeter));
+ IFSelect_ReturnStatus aWritestat =
+ aWriter.Transfer(theShape, aNode->InternalParameters.WriteModelType, true, theProgress);
+ if (aWritestat != IFSelect_RetDone)
+ {
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "Can't translate shape to STEP model";
+ resetStatic();
+ return false;
+ }
+ if (aWriter.WriteStream(theOStream) != IFSelect_RetDone)
+ {
+ Message::SendFail() << "Error: STEPCAFControl_Provider : "
+ << "Can't write STEP to stream";
+ resetStatic();
+ return false;
+ }
+ resetStatic();
+ return true;
}
//=======================================================================
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
+ //! Reads a CAD file, according internal configuration
+ //! @param[in] theIStream stream to import STEP data
+ //! @param[out] theDocument document to save result
+ //! @paramp[in] theName name of step file, can be empty
+ //! @param[in] theWS current work session
+ //! @param theProgress[in] progress indicator
+ //! @return true if Read operation has ended correctly
+ Standard_EXPORT virtual bool Read(std::istream& theIStream,
+ const Handle(TDocStd_Document)& theDocument,
+ const TCollection_AsciiString theName,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress = Message_ProgressRange());
+
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theDocument document to save result
- //! @param theProgress[in] progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
//! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
+ //! @param[in] theOStream stream to export STEP data
//! @param[out] theDocument document to export
+ //! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
+ Standard_EXPORT virtual bool Write(std::ostream& theOStream,
const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
+ //! Reads a CAD file, according internal configuration
+ //! @param[in] theIStream stream to the step file
+ //! @param[out] theShape shape to save result
+ //! @paramp[in] theName name of step file, can be empty
+ //! @param[in] theWS current work session
+ //! @param theProgress[in] progress indicator
+ //! @return true if Read operation has ended correctly
+ Standard_EXPORT virtual bool Read(std::istream& theIStream,
+ TopoDS_Shape& theShape,
+ const TCollection_AsciiString theName,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress = Message_ProgressRange());
+
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theShape shape to save result
- //! @param theProgress[in] progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
//! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
+ //! @param[in] theOStream stream to export STEP data
//! @param[out] theShape shape to export
+ //! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
+ Standard_EXPORT virtual bool Write(std::ostream& theOStream,
const TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress = Message_ProgressRange());
public:
//! @return provider's vendor name
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+public:
+
+ //! Sets parameter to update static parameter, that true by default
+ void SetToUpdateStaticParameters(const bool theToUpdate) { myToUpdateStaticParameters = theToUpdate; }
+
+ //! Gets parameter to update static parameter, that true by default
+ bool ToUpdateStaticParameters() const { return myToUpdateStaticParameters; }
+
private:
//! Personizes work session with current format.
//! Reset used interface static variables
void resetStatic();
- STEPCAFControl_ConfigurationNode::STEPCAFControl_InternalSection myOldValues;
+private:
+
+ bool myToUpdateStaticParameters = true; //!< Flag to updating static parameters
+ STEPCAFControl_ConfigurationNode::STEPCAFControl_InternalSection myOldValues; //!< Container to save previous static parameters
};
const Message_ProgressRange& theProgress)
{
(void)theWS;
- return Read(thePath, theDocument, theProgress);
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool Vrml_Provider::Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- Handle(XSControl_WorkSession)& theWS,
- const Message_ProgressRange& theProgress)
-{
- (void)theWS;
- return Write(thePath, theDocument, theProgress);
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool Vrml_Provider::Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
if (theDocument.IsNull())
{
Message::SendFail() << "Error in the Vrml_Provider during reading the file " <<
//=======================================================================
bool Vrml_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
+ Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
+ (void)theWS;
(void)theProgress;
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(Vrml_ConfigurationNode)))
{
const Message_ProgressRange& theProgress)
{
(void)theWS;
- return Read(thePath, theShape, theProgress);
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool Vrml_Provider::Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- Handle(XSControl_WorkSession)& theWS,
- const Message_ProgressRange& theProgress)
-{
- (void)theWS;
- return Write(thePath, theShape, theProgress);
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool Vrml_Provider::Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress)
-{
(void)theProgress;
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(Vrml_ConfigurationNode)))
{
//=======================================================================
bool Vrml_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
+ Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
+ (void)theWS;
Handle(TDocStd_Document) aDoc = new TDocStd_Document("BinXCAF");
Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
aShTool->AddShape(theShape);
- return Write(thePath, aDoc, theProgress);
+ return Write(thePath, aDoc, theWS, theProgress);
}
//=======================================================================
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theDocument document to save result
- //! @param theProgress[in] progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theDocument document to export
- //! @param theProgress[in] progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theShape shape to save result
- //! @param theProgress[in] progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theShape shape to export
- //! @param theProgress[in] progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
-
public:
//! Gets CAD format name of associated provider
#include <Draw_ProgressIndicator.hxx>
#include <Message.hxx>
#include <IFSelect_SessionPilot.hxx>
-#include <IGESCAFControl_Reader.hxx>
-#include <IGESCAFControl_Writer.hxx>
-#include <IGESControl_Controller.hxx>
+#include <IGESCAFControl_ConfigurationNode.hxx>
+#include <IGESCAFControl_Provider.hxx>
+//#include <IGESCAFControl_Reader.hxx>
+//#include <IGESCAFControl_Writer.hxx>
+//#include <IGESControl_Controller.hxx>
#include <Interface_Macros.hxx>
#include <OSD_OpenFile.hxx>
#include <OSD_Path.hxx>
-#include <STEPCAFControl_ExternFile.hxx>
-#include <STEPCAFControl_Reader.hxx>
-#include <STEPCAFControl_Writer.hxx>
-#include <STEPControl_Controller.hxx>
+#include <STEPCAFControl_ConfigurationNode.hxx>
+#include <STEPCAFControl_Provider.hxx>
+//#include <STEPCAFControl_ExternFile.hxx>
+//#include <STEPCAFControl_Reader.hxx>
+//#include <STEPCAFControl_Writer.hxx>
+//#include <STEPControl_Controller.hxx>
#include <TDF_Data.hxx>
#include <TDocStd_Application.hxx>
#include <TDocStd_Document.hxx>
return Standard_True;
}
-static Standard_Boolean ClearDicWS()
-{
- thedictws.Clear();
- return Standard_True;
-}
-
-static void AddWS(TCollection_AsciiString filename,
- const Handle(XSControl_WorkSession)& WS)
-{
- WS->SetVars(new XSDRAW_Vars); // support of DRAW variables
- thedictws.Bind(filename, WS);
-}
-
-
-static Standard_Boolean FillDicWS(NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)>& dicFile)
-{
- ClearDicWS();
- if (dicFile.IsEmpty())
- {
- return Standard_False;
- }
- Handle(STEPCAFControl_ExternFile) EF;
- NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)>::Iterator DicEFIt(dicFile);
- for (; DicEFIt.More(); DicEFIt.Next())
- {
- TCollection_AsciiString filename = DicEFIt.Key();
- EF = DicEFIt.Value();
- AddWS(filename, EF->GetWS());
- }
- return Standard_True;
-}
+//static Standard_Boolean ClearDicWS()
+//{
+// thedictws.Clear();
+// return Standard_True;
+//}
+//
+//static void AddWS(TCollection_AsciiString filename,
+// const Handle(XSControl_WorkSession)& WS)
+//{
+// WS->SetVars(new XSDRAW_Vars); // support of DRAW variables
+// thedictws.Bind(filename, WS);
+//}
+
+
+//static Standard_Boolean FillDicWS(NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)>& dicFile)
+//{
+ //ClearDicWS();
+ //if (dicFile.IsEmpty())
+ //{
+ // return Standard_False;
+ //}
+ //Handle(STEPCAFControl_ExternFile) EF;
+ //NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)>::Iterator DicEFIt(dicFile);
+ //for (; DicEFIt.More(); DicEFIt.Next())
+ //{
+ // TCollection_AsciiString filename = DicEFIt.Key();
+ // EF = DicEFIt.Value();
+ // AddWS(filename, EF->GetWS());
+ //}
+// return Standard_True;
+//}
static Standard_Boolean SetCurrentWS(TCollection_AsciiString filename)
{
- if (!thedictws.IsBound(filename)) return Standard_False;
- Handle(XSControl_WorkSession) CurrentWS =
- Handle(XSControl_WorkSession)::DownCast(thedictws.ChangeFind(filename));
- XSDRAW::Pilot()->SetSession(CurrentWS);
+ //if (!thedictws.IsBound(filename)) return Standard_False;
+ //Handle(XSControl_WorkSession) CurrentWS =
+ // Handle(XSControl_WorkSession)::DownCast(thedictws.ChangeFind(filename));
+ //XSDRAW::Pilot()->SetSession(CurrentWS);
return Standard_True;
}
di << "Use: " << argv[0] << " Doc filename [mode]: read IGES file to a document\n";
return 0;
}
-
- DeclareAndCast(IGESControl_Controller, ctl, XSDRAW::Controller());
- if (ctl.IsNull()) XSDRAW::SetNorm("IGES");
-
- TCollection_AsciiString fnom, rnom;
- Standard_Boolean modfic = XSDRAW::FileAndVar(argv[2], argv[1], "IGES", fnom, rnom);
- if (modfic) di << " File IGES to read : " << fnom.ToCString() << "\n";
- else di << " Model taken from the session : " << fnom.ToCString() << "\n";
- // di<<" -- Names of variables BREP-DRAW prefixed by : "<<rnom<<"\n";
-
- IGESCAFControl_Reader reader(XSDRAW::Session(), modfic);
+ Handle(IGESCAFControl_ConfigurationNode) aNode =
+ new IGESCAFControl_ConfigurationNode();
Standard_Integer onlyvisible = Interface_Static::IVal("read.iges.onlyvisible");
- reader.SetReadVisible(onlyvisible == 1);
-
+ aNode->InternalParameters.ReadOnlyVisible = onlyvisible == 1;
if (argc == 4)
{
Standard_Boolean mode = Standard_True;
{
case '-': mode = Standard_False; break;
case '+': mode = Standard_True; break;
- case 'c': reader.SetColorMode(mode); break;
- case 'n': reader.SetNameMode(mode); break;
- case 'l': reader.SetLayerMode(mode); break;
+ case 'c': aNode->InternalParameters.ReadColor = mode; break;
+ case 'n': aNode->InternalParameters.ReadName = mode; break;
+ case 'l': aNode->InternalParameters.ReadLayer = mode; break;
}
}
-
- Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di);
- Message_ProgressScope aRootScope(aProgress->Start(), "IGES import", modfic ? 2 : 1);
-
- IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
- if (modfic)
- {
- Message_ProgressScope aReadScope(aRootScope.Next(), "File reading", 1);
- aReadScope.Show();
- readstat = reader.ReadFile(fnom.ToCString());
- }
- else if (XSDRAW::Session()->NbStartingEntities() > 0)
- {
- readstat = IFSelect_RetDone;
- }
- if (readstat != IFSelect_RetDone)
- {
- if (modfic)
- {
- di << "Could not read file " << fnom.ToCString() << " , abandon\n";
- }
- else
- {
- di << "No model loaded\n";
- }
- return 1;
- }
-
Handle(TDocStd_Document) doc;
if (!DDocStd::GetDocument(argv[1], doc, Standard_False))
{
TDataStd_Name::Set(doc->GetData()->Root(), argv[1]);
Handle(DDocStd_DrawDocument) DD = new DDocStd_DrawDocument(doc);
Draw::Set(argv[1], DD);
- // di << "Document saved with name " << argv[1];
}
- if (!reader.Transfer(doc, aRootScope.Next()))
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di);
+ Handle(IGESCAFControl_Provider) aProvider =
+ new IGESCAFControl_Provider(aNode);
+ aProvider->SetToUpdateStaticParameters(false);
+ Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
+ if (!aProvider->Read(argv[2], doc, aWS, aProgress->Start()))
{
- di << "Cannot read any relevant data from the IGES file\n";
+ di << "Error: Can't read IGES file\n";
return 1;
}
-
- // Handle(DDocStd_DrawDocument) DD = new DDocStd_DrawDocument(doc);
- // Draw::Set(argv[1],DD);
- di << "Document saved with name " << argv[1];
-
+ Message::SendInfo() << "Document saved with name " << argv[1];
return 0;
}
di << "Use: " << argv[0] << " Doc filename [mode]: write document to IGES file\n";
return 0;
}
-
+ Handle(IGESCAFControl_ConfigurationNode) aNode =
+ new IGESCAFControl_ConfigurationNode();
Handle(TDocStd_Document) Doc;
DDocStd::GetDocument(argv[1], Doc);
if (Doc.IsNull())
di << argv[1] << " is not a document\n";
return 1;
}
-
- XSDRAW::SetNorm("IGES");
-
- TCollection_AsciiString fnom, rnom;
- const Standard_Boolean modfic = XSDRAW::FileAndVar(argv[2], argv[1], "IGES", fnom, rnom);
-
- // IGESControl_Writer ICW (Interface_Static::CVal("write.iges.unit"),
- // Interface_Static::IVal("write.iges.brep.mode"));
-
- Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di);
- Message_ProgressScope aRootScope(aProgress->Start(), "IGES export", modfic ? 2 : 1);
-
- IGESCAFControl_Writer writer(XSDRAW::Session(), Standard_True);
if (argc == 4)
{
Standard_Boolean mode = Standard_True;
{
case '-': mode = Standard_False; break;
case '+': mode = Standard_True; break;
- case 'c': writer.SetColorMode(mode); break;
- case 'n': writer.SetNameMode(mode); break;
- case 'l': writer.SetLayerMode(mode); break;
+ case 'c': aNode->InternalParameters.WriteColor = mode; break;
+ case 'n': aNode->InternalParameters.WriteName = mode; break;
+ case 'l': aNode->InternalParameters.WriteLayer = mode; break;
}
}
- writer.Transfer(Doc, aRootScope.Next());
-
- if (modfic)
- {
- Message_ProgressScope aWriteScope(aRootScope.Next(), "File writing", 1);
- aWriteScope.Show();
- di << "Writing IGES model to file " << argv[2] << "\n";
- if (writer.Write(argv[2]))
- {
- di << " Write OK\n";
- }
- else
- {
- di << " Write failed\n";
- }
- }
- else
- {
- di << "Document has been translated into the session";
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di);
+ Handle(IGESCAFControl_Provider) aProvider =
+ new IGESCAFControl_Provider(aNode);
+ aProvider->SetToUpdateStaticParameters(false);
+ Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
+ const TCollection_AsciiString aPath = argv[2];
+ if (!aProvider->Write(aPath, Doc, aWS, aProgress->Start()))
+ {
+ di << "Error: Can't write IGES file\n";
+ return 1;
}
return 0;
}
//=======================================================================
static Standard_Integer ReadStep(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
- DeclareAndCast(STEPControl_Controller, ctl, XSDRAW::Controller());
- if (ctl.IsNull())
- {
- XSDRAW::SetNorm ("STEP");
- }
Standard_CString aDocName = NULL;
TCollection_AsciiString aFilePath, aModeStr;
}
else
{
- Message::SendFail() << "Syntax error at '" << argv[anArgIter] << "'";
+ di << "Syntax error at '" << argv[anArgIter] << "'";
return 1;
}
}
-
- TCollection_AsciiString aFileName, anOldVarName;
- Standard_Boolean isFileMode = XSDRAW::FileAndVar (aFilePath.ToCString(), aDocName, "STEP", aFileName, anOldVarName);
- if (isFileMode) di << " File STEP to read : " << aFileName << "\n";
- else di << " Model taken from the session : " << aFileName << "\n";
- // di<<" -- Names of variables BREP-DRAW prefixed by : "<<rnom<<"\n";
-
- STEPCAFControl_Reader aReader (XSDRAW::Session(), isFileMode);
+ Handle(STEPCAFControl_ConfigurationNode) aNode =
+ new STEPCAFControl_ConfigurationNode();
if (!aModeStr.IsEmpty())
{
Standard_Boolean aMode = Standard_True;
for (Standard_Integer i = 1; aModeStr.Value (i); ++i)
{
- switch (aModeStr.Value (i))
+ switch (aModeStr.Value(i))
{
- case '-' : aMode = Standard_False; break;
- case '+' : aMode = Standard_True; break;
- case 'c' : aReader.SetColorMode (aMode); break;
- case 'n' : aReader.SetNameMode (aMode); break;
- case 'l' : aReader.SetLayerMode (aMode); break;
- case 'v' : aReader.SetPropsMode (aMode); break;
+ case '-': aMode = Standard_False; break;
+ case '+': aMode = Standard_True; break;
+ case 'c': aNode->InternalParameters.WriteColor = aMode; break;
+ case 'n': aNode->InternalParameters.WriteName = aMode; break;
+ case 'l': aNode->InternalParameters.WriteLayer = aMode; break;
+ case 'v': aNode->InternalParameters.WriteProps = aMode; break;
default:
{
- Message::SendFail() << "Syntax error at '" << aModeStr << "'\n";
+ di << "Syntax error at '" << aModeStr << "'\n";
return 1;
}
}
}
}
-
- Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (di);
- Message_ProgressScope aRootScope (aProgress->Start(), "STEP import", isFileMode ? 2 : 1);
-
- IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
- if (isFileMode)
- {
- Message_ProgressScope aReadScope (aRootScope.Next(), "File reading", 1);
- aReadScope.Show();
- if (toTestStream)
- {
- std::ifstream aStream;
- OSD_OpenStream (aStream, aFileName.ToCString(), std::ios::in | std::ios::binary);
- TCollection_AsciiString aFolder, aFileNameShort;
- OSD_Path::FolderAndFileFromPath (aFileName, aFolder, aFileNameShort);
- aReadStat = aReader.ReadStream (aFileNameShort.ToCString(), aStream);
- }
- else
- {
- aReadStat = aReader.ReadFile (aFileName.ToCString());
- }
- }
- else if (XSDRAW::Session()->NbStartingEntities() > 0)
+ Handle(TDocStd_Document) aDoc;
+ if (!DDocStd::GetDocument(aDocName, aDoc, Standard_False))
{
- aReadStat = IFSelect_RetDone;
+ Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
+ anApp->NewDocument("BinXCAF", aDoc);
+ TDataStd_Name::Set(aDoc->GetData()->Root(), aDocName);
+ Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc);
+ Draw::Set(aDocName, aDrawDoc);
}
- if (aReadStat != IFSelect_RetDone)
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (di);
+ Handle(STEPCAFControl_Provider) aProvider =
+ new STEPCAFControl_Provider(aNode);
+ aProvider->SetToUpdateStaticParameters(false);
+ Standard_Boolean aReadStat = Standard_False;
+ Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
+ if (toTestStream)
{
- if (isFileMode)
- {
- di << "Could not read file " << aFileName << " , abandon\n";
- }
- else
- {
- di << "No model loaded\n";
- }
- return 1;
+ std::ifstream aStream;
+ OSD_OpenStream (aStream, aFilePath.ToCString(), std::ios::in | std::ios::binary);
+ TCollection_AsciiString aFolder, aFileNameShort;
+ OSD_Path::FolderAndFileFromPath (aFilePath, aFolder, aFileNameShort);
+ aReadStat =
+ aProvider->Read(aStream, aDoc, aFilePath, aWS, aProgress->Start());
}
-
- Handle(TDocStd_Document) aDoc;
- if (!DDocStd::GetDocument (aDocName, aDoc, Standard_False))
+ else
{
- Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
- anApp->NewDocument("BinXCAF", aDoc);
- TDataStd_Name::Set (aDoc->GetData()->Root(), aDocName);
- Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument (aDoc);
- Draw::Set (aDocName, aDrawDoc);
- // di << "Document saved with name " << aDocName;
+ aReadStat =
+ aProvider->Read(aFilePath, aDoc, aWS, aProgress->Start());
}
- if (!aReader.Transfer (aDoc, aRootScope.Next()))
+ if (!aReadStat)
{
di << "Cannot read any relevant data from the STEP file\n";
return 1;
}
-
Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument (aDoc);
Draw::Set (aDocName, aDrawDoc);
- di << "Document saved with name " << aDocName;
-
- NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)> aDicFile = aReader.ExternFiles();
- FillDicWS (aDicFile);
- AddWS (aFileName, XSDRAW::Session());
+ Message::SendInfo() << "Document saved with name " << aDocName;
+ //NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)> aDicFile = aReader.ExternFiles();
+ //FillDicWS (aDicFile);
+ //AddWS (aFileName, XSDRAW::Session());
return 0;
}
//=======================================================================
static Standard_Integer WriteStep(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
- DeclareAndCast(STEPControl_Controller,ctl,XSDRAW::Controller());
- if (ctl.IsNull())
- {
- XSDRAW::SetNorm ("STEP");
- }
- STEPCAFControl_Writer aWriter (XSDRAW::Session(), Standard_True);
-
Handle(TDocStd_Document) aDoc;
TCollection_AsciiString aDocName, aFilePath;
- STEPControl_StepModelType aMode = STEPControl_AsIs;
+ Handle(STEPCAFControl_ConfigurationNode) aNode =
+ new STEPCAFControl_ConfigurationNode();
bool hasModeArg = false, toTestStream = false;
- TCollection_AsciiString aMultiFilePrefix, aLabelName;
TDF_Label aLabel;
for (Standard_Integer anArgIter = 1; anArgIter < argc; ++anArgIter)
{
- TCollection_AsciiString anArgCase (argv[anArgIter]);
+ TCollection_AsciiString anArgCase(argv[anArgIter]);
anArgCase.LowerCase();
if (anArgCase == "-stream")
{
else if (aDocName.IsEmpty())
{
Standard_CString aDocNameStr = argv[anArgIter];
- DDocStd::GetDocument (aDocNameStr, aDoc);
+ DDocStd::GetDocument(aDocNameStr, aDoc);
if (aDoc.IsNull())
{
di << "Syntax error: '" << argv[anArgIter] << "' is not a document";
else if (!hasModeArg)
{
hasModeArg = true;
- switch (anArgCase.Value (1))
+ switch (anArgCase.Value(1))
{
case 'a':
- case '0': aMode = STEPControl_AsIs; break;
+ case '0': aNode->InternalParameters.WriteModelType = STEPControl_AsIs; break;
case 'f':
- case '1': aMode = STEPControl_FacetedBrep; break;
+ case '1': aNode->InternalParameters.WriteModelType = STEPControl_FacetedBrep; break;
case 's':
- case '2': aMode = STEPControl_ShellBasedSurfaceModel; break;
+ case '2': aNode->InternalParameters.WriteModelType = STEPControl_ShellBasedSurfaceModel; break;
case 'm':
- case '3': aMode = STEPControl_ManifoldSolidBrep; break;
+ case '3': aNode->InternalParameters.WriteModelType = STEPControl_ManifoldSolidBrep; break;
case 'w':
- case '4': aMode = STEPControl_GeometricCurveSet; break;
+ case '4': aNode->InternalParameters.WriteModelType = STEPControl_GeometricCurveSet; break;
default:
{
- di << "Syntax error: mode '" << argv[anArgIter] << "' is incorrect [give fsmw]";
+ di << "Syntax error: mode '" << anArgCase.Value(1) << "' is incorrect [give fsmw]";
return 1;
}
}
Standard_Boolean wrmode = Standard_True;
for (Standard_Integer i = 1; i <= anArgCase.Length(); ++i)
{
- switch (anArgCase.Value (i))
+ switch (anArgCase.Value(i))
{
- case '-' : wrmode = Standard_False; break;
- case '+' : wrmode = Standard_True; break;
- case 'c' : aWriter.SetColorMode (wrmode); break;
- case 'n' : aWriter.SetNameMode (wrmode); break;
- case 'l' : aWriter.SetLayerMode (wrmode); break;
- case 'v' : aWriter.SetPropsMode (wrmode); break;
+ case '-': wrmode = Standard_False; break;
+ case '+': wrmode = Standard_True; break;
+ case 'c': aNode->InternalParameters.WriteColor = wrmode; break;
+ case 'n': aNode->InternalParameters.WriteName = wrmode; break;
+ case 'l': aNode->InternalParameters.WriteLayer = wrmode; break;
+ case 'v': aNode->InternalParameters.WriteProps = wrmode; break;
+ default:
+ {
+ di << "Syntax error at '" << anArgCase.Value(i) << "'\n";
+ return 1;
+ }
}
}
}
- else if (aMultiFilePrefix.IsEmpty()
- && anArgCase.Search (":") == -1)
+ else if (aNode->InternalParameters.WriteMultiPrefix.IsEmpty()
+ && anArgCase.Search(":") == -1)
{
- aMultiFilePrefix = argv[anArgIter];
+ aNode->InternalParameters.WriteMultiPrefix = argv[anArgIter];
}
else if (aLabel.IsNull())
{
- if (!DDF::FindLabel (aDoc->Main().Data(), argv[anArgIter], aLabel)
- || aLabel.IsNull())
+ if (!DDF::FindLabel(aDoc->Main().Data(), argv[anArgIter], aLabel)
+ || aLabel.IsNull())
{
di << "Syntax error: No label for entry '" << argv[anArgIter] << "'";
return 1;
}
- aLabelName = argv[anArgIter];
+ aNode->InternalParameters.WriteLabels.Append(argv[anArgIter]);
}
else
{
di << "Syntax error: wrong number of arguments";
return 1;
}
-
- TCollection_AsciiString aFileName, anOldVarName;
- const Standard_Boolean isFileMode = XSDRAW::FileAndVar (aFilePath.ToCString(), aDocName.ToCString(), "STEP", aFileName, anOldVarName);
-
- Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (di);
- Message_ProgressScope aRootScope (aProgress->Start(), "STEP export", isFileMode ? 2 : 1);
- if (!aLabel.IsNull())
- {
- di << "Translating label " << aLabelName << " of document " << aDocName << " to STEP\n";
- if (!aWriter.Transfer (aLabel, aMode,
- !aMultiFilePrefix.IsEmpty() ? aMultiFilePrefix.ToCString() : NULL,
- aRootScope.Next()))
- {
- di << "Error: the label of document cannot be translated or gives no result";
- return 1;
- }
- }
- else
- {
- di << "Translating document " << aDocName << " to STEP\n";
- if (!aWriter.Transfer (aDoc, aMode,
- !aMultiFilePrefix.IsEmpty() ? aMultiFilePrefix.ToCString() : NULL,
- aRootScope.Next()))
- {
- di << "Error: The document cannot be translated or gives no result\n";
- }
- }
-
- if (!isFileMode)
- {
- di << "Document has been translated into the session";
- return 0;
- }
-
- Message_ProgressScope aWriteScope (aRootScope.Next(), "File writing", 1);
- aWriteScope.Show();
- di << "Writing STEP file " << aFilePath << "\n";
-
- IFSelect_ReturnStatus aStat = IFSelect_RetVoid;
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di);
+ Handle(STEPCAFControl_Provider) aProvider =
+ new STEPCAFControl_Provider(aNode);
+ aProvider->SetToUpdateStaticParameters(false);
+ Standard_Boolean aReadStat = Standard_False;
+ Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
if (toTestStream)
{
std::ofstream aStream;
- OSD_OpenStream (aStream, aFilePath, std::ios::out | std::ios::binary);
- aStat = aWriter.WriteStream (aStream);
- aStream.close();
- if (!aStream.good()
- && aStat == IFSelect_RetDone)
- {
- aStat = IFSelect_RetFail;
- }
+ OSD_OpenStream(aStream, aFilePath, std::ios::out | std::ios::binary);
+ TCollection_AsciiString aFolder, aFileNameShort;
+ OSD_Path::FolderAndFileFromPath(aFilePath, aFolder, aFileNameShort);
+ aReadStat =
+ aProvider->Write(aStream, aDoc, aWS, aProgress->Start());
}
else
{
- aStat = aWriter.Write (aFilePath.ToCString());
+ aReadStat =
+ aProvider->Write(aFilePath, aDoc, aWS, aProgress->Start());
}
-
- switch (aStat)
+ if (!aReadStat)
{
- case IFSelect_RetVoid:
- {
- di << "Error: no file written";
- break;
- }
- case IFSelect_RetDone:
- {
- di << "File " << aFilePath << " written\n";
-
- NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)> aDicFile = aWriter.ExternFiles();
- FillDicWS (aDicFile);
- AddWS (aFilePath, XSDRAW::Session());
- break;
- }
- default:
- {
- di << "Error on writing file";
- break;
- }
+ di << "Cannot write any relevant data to the STEP file\n";
+ return 1;
}
+ //NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)> aDicFile = aWriter.ExternFiles();
+ //FillDicWS(aDicFile);
+ //AddWS(aFilePath, XSDRAW::Session());
return 0;
}
if (aStat)
{
TopoDS_Shape aShape;
- aStat = isNoDoc ? aConf->Read(aFilePath, aShape) : aConf->Read(aFilePath, aDoc);
+ Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
+ aStat = isNoDoc ? aConf->Read(aFilePath, aShape, aWS) : aConf->Read(aFilePath, aDoc, aWS);
if(isNoDoc && aStat)
{
DBRep::Set(aDocShapeName.ToCString(), aShape);
{
aStat = aConf->Load(aConfString);
}
+ Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
if (aStat)
{
if(isNoDoc)
Message::SendFail() << "Error: incorrect shape";
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)