Reorganize DE Wrapper classes to have single style and logic.
Each TKDE* will have own DE*_Provider and DE*_ConfigurationNode
DE* package will have all necessary classes and enums inside instead of another places.
It is nesessary to register only one ConfigurationNode for all needed formats.
~~~~{.cpp}
Handle(DE_Wrapper) aSession = DE_Wrapper::GlobalWrapper();
-Handle(DE_ConfigurationNode) aNode = new STEPCAFControl_ConfigurationNode();
+Handle(DE_ConfigurationNode) aNode = new DESTEP_ConfigurationNode();
aSession->Bind(aNode);
~~~~
@subsubsection occt_de_wrapper_3_3_2 Registering providers. DRAW Sample
~~~~{.cpp}
// global variable
-static Handle(STEPCAFControl_ConfigurationNode) THE_STEP_NODE;
+static Handle(DESTEP_ConfigurationNode) THE_STEP_NODE;
static Handle(DE_ConfigurationNode) RegisterStepNode()
{
return THE_STEP_NODE;
}
- THE_STEP_NODE = new STEPCAFControl_ConfigurationNode();
+ THE_STEP_NODE = new DESTEP_ConfigurationNode();
aSession->Bind(THE_STEP_NODE);
return THE_STEP_NODE;
}
~~~~{.cpp}
// Creating or getting node
-Handle(STEPCAFControl_ConfigurationNode) aNode = new STEPCAFControl_ConfigurationNode();
+Handle(DESTEP_ConfigurationNode) aNode = new DESTEP_ConfigurationNode();
// Creating an one-time provider
Handle(DE_Provider) aProvider = aNode->BuildProvider();
// Setting configuration with all parameters
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <DEBREP_ConfigurationNode.hxx>
+
+#include <DEBREP_Provider.hxx>
+#include <DE_ConfigurationContext.hxx>
+#include <DE_PluginHolder.hxx>
+#include <NCollection_Buffer.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(DEBREP_ConfigurationNode, DE_ConfigurationNode)
+
+namespace
+{
+static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
+{
+ static const TCollection_AsciiString aScope = "provider";
+ return aScope;
+}
+
+// Wrapper to auto-load DE component
+DE_PluginHolder<DEBREP_ConfigurationNode> THE_OCCT_BREP_COMPONENT_PLUGIN;
+} // namespace
+
+//=================================================================================================
+
+DEBREP_ConfigurationNode::DEBREP_ConfigurationNode()
+ : DE_ConfigurationNode()
+{
+}
+
+//=================================================================================================
+
+DEBREP_ConfigurationNode::DEBREP_ConfigurationNode(const Handle(DEBREP_ConfigurationNode)& theNode)
+ : DE_ConfigurationNode(theNode)
+{
+ InternalParameters = theNode->InternalParameters;
+}
+
+//=================================================================================================
+
+bool DEBREP_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
+{
+ TCollection_AsciiString aScope =
+ THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
+
+ InternalParameters.WriteBinary =
+ theResource->BooleanVal("write.binary", InternalParameters.WriteBinary, aScope);
+ InternalParameters.WriteVersionBin =
+ (BinTools_FormatVersion)theResource->IntegerVal("write.version.binary",
+ InternalParameters.WriteVersionBin,
+ aScope);
+ InternalParameters.WriteVersionAscii =
+ (TopTools_FormatVersion)theResource->IntegerVal("write.version.ascii",
+ InternalParameters.WriteVersionAscii,
+ aScope);
+ InternalParameters.WriteTriangles =
+ theResource->BooleanVal("write.triangles", InternalParameters.WriteTriangles, aScope);
+ InternalParameters.WriteNormals =
+ theResource->BooleanVal("write.normals", InternalParameters.WriteNormals, aScope);
+ return true;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEBREP_ConfigurationNode::Save() const
+{
+ TCollection_AsciiString aResult;
+ aResult += "!*****************************************************************************\n";
+ aResult =
+ aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
+ TCollection_AsciiString aScope =
+ THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
+
+ aResult += "!\n";
+ aResult += "!Write parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines the binary file format\n";
+ aResult += "!Default value: 1. Available values: 0(\"off\"), 1(\"on\")\n";
+ aResult += aScope + "write.binary :\t " + InternalParameters.WriteBinary + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines the format version for the binary format writing\n";
+ aResult += "!Default value: 4. Available values: 1, 2, 3, 4\n";
+ aResult += aScope + "write.version.binary :\t " + InternalParameters.WriteVersionBin + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines the format version for the ASCII format writing\n";
+ aResult += "!Default value: 3. Available values: 1, 2, 3\n";
+ aResult += aScope + "write.version.ascii :\t " + InternalParameters.WriteVersionAscii + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines the flag for storing shape with(without) triangles\n";
+ aResult += "!Default value: 1. Available values: 0(\"off\"), 1(\"on\")\n";
+ aResult += aScope + "write.triangles :\t " + InternalParameters.WriteTriangles + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines the flag for storing shape with(without) normals\n";
+ aResult += "!Default value: 1. Available values: 0(\"off\"), 1(\"on\")\n";
+ aResult += aScope + "write.normals :\t " + InternalParameters.WriteNormals + "\n";
+ aResult += "!\n";
+
+ aResult += "!*****************************************************************************\n";
+ return aResult;
+}
+
+//=================================================================================================
+
+Handle(DE_ConfigurationNode) DEBREP_ConfigurationNode::Copy() const
+{
+ return new DEBREP_ConfigurationNode(*this);
+}
+
+//=================================================================================================
+
+Handle(DE_Provider) DEBREP_ConfigurationNode::BuildProvider()
+{
+ return new DEBREP_Provider(this);
+}
+
+//=================================================================================================
+
+bool DEBREP_ConfigurationNode::IsImportSupported() const
+{
+ return true;
+}
+
+//=================================================================================================
+
+bool DEBREP_ConfigurationNode::IsExportSupported() const
+{
+ return true;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEBREP_ConfigurationNode::GetFormat() const
+{
+ return TCollection_AsciiString("BREP");
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEBREP_ConfigurationNode::GetVendor() const
+{
+ return TCollection_AsciiString("OCC");
+}
+
+//=================================================================================================
+
+TColStd_ListOfAsciiString DEBREP_ConfigurationNode::GetExtensions() const
+{
+ TColStd_ListOfAsciiString anExt;
+ anExt.Append("brep");
+ return anExt;
+}
+
+//=================================================================================================
+
+bool DEBREP_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
+{
+ if (theBuffer.IsNull() || theBuffer->Size() < 20)
+ {
+ return false;
+ }
+ const char* aBytes = (const char*)theBuffer->Data();
+ if (::strstr(aBytes, "DBRep_DrawableShape") || ::strstr(aBytes, "CASCADE Topology V1")
+ || ::strstr(aBytes, "CASCADE Topology V3"))
+ {
+ return true;
+ }
+ return false;
+}
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _DEBREP_ConfigurationNode_HeaderFile
+#define _DEBREP_ConfigurationNode_HeaderFile
+
+#include <DE_ConfigurationNode.hxx>
+
+#include <BinTools_FormatVersion.hxx>
+#include <TopTools_FormatVersion.hxx>
+
+//! The purpose of this class is to configure the transfer process for BRep format
+//! Stores the necessary settings for DEBREP_Provider.
+//! Configures and creates special provider to transfer BRep files.
+//!
+//! Nodes grouped by Vendor name and Format type.
+//! The Vendor name is "OCC"
+//! The Format type is "BREP"
+//! The supported CAD extension is ".brep"
+//! The import process is supported.
+//! The export process is supported.
+class DEBREP_ConfigurationNode : public DE_ConfigurationNode
+{
+ DEFINE_STANDARD_RTTIEXT(DEBREP_ConfigurationNode, DE_ConfigurationNode)
+public:
+ //! Initializes all field by default
+ Standard_EXPORT DEBREP_ConfigurationNode();
+
+ //! Copies values of all fields
+ //! @param[in] theNode object to copy
+ Standard_EXPORT DEBREP_ConfigurationNode(const Handle(DEBREP_ConfigurationNode)& theNode);
+
+ //! Updates values according the resource
+ //! @param[in] theResource input resource to use
+ //! @return true if theResource loading has ended correctly
+ Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource)
+ Standard_OVERRIDE;
+
+ //! Writes configuration to the string
+ //! @return result resource string
+ Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
+
+ //! Copies values of all fields
+ //! @return new object with the same field values
+ Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
+
+ //! Creates new provider for the own format
+ //! @return new created provider
+ Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
+
+public:
+ //! Checks the import supporting
+ //! @return true if import is supported
+ Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
+
+ //! Checks the export supporting
+ //! @return true if export is supported
+ Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
+
+ //! Gets CAD format name of associated provider
+ //! @return provider CAD format
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
+
+ //! Gets provider's vendor name of associated provider
+ //! @return provider's vendor name
+ Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+
+ //! Gets list of supported file extensions
+ //! @return list of extensions
+ Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
+
+ //! Checks the file content to verify a format
+ //! @param[in] theBuffer read stream buffer to check content
+ //! @return Standard_True if file is supported by a current provider
+ Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
+ Standard_OVERRIDE;
+
+public:
+ struct DEBRep_InternalSection
+ {
+ // Write
+ bool WriteBinary = true; //!< Defines the binary file format
+ // clang-format off
+ BinTools_FormatVersion WriteVersionBin = BinTools_FormatVersion_CURRENT; //!< Defines the writer version for the binary format
+ TopTools_FormatVersion WriteVersionAscii = TopTools_FormatVersion_CURRENT; //!< Defines the writer version for the ASCII format
+ // clang-format on
+ bool WriteTriangles = true; //!< Defines the flag for storing shape with(without) triangles
+ bool WriteNormals = true; //!< Defines the flag for storing shape with(without) normals
+
+ } InternalParameters;
+};
+
+#endif // _DEBREP_ConfigurationNode_HeaderFile
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <DEBREP_Provider.hxx>
+
+#include <BRepTools.hxx>
+#include <BRep_Builder.hxx>
+#include <BinTools.hxx>
+#include <DEBREP_ConfigurationNode.hxx>
+#include <Message.hxx>
+#include <OSD_FileSystem.hxx>
+#include <TDocStd_Document.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <XCAFDoc_ShapeTool.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(DEBREP_Provider, DE_Provider)
+
+//=================================================================================================
+
+DEBREP_Provider::DEBREP_Provider() {}
+
+//=================================================================================================
+
+DEBREP_Provider::DEBREP_Provider(const Handle(DE_ConfigurationNode)& theNode)
+ : DE_Provider(theNode)
+{
+}
+
+//=================================================================================================
+
+bool DEBREP_Provider::Read(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ (void)theWS;
+ return Read(thePath, theDocument, theProgress);
+}
+
+//=================================================================================================
+
+bool DEBREP_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);
+}
+
+//=================================================================================================
+
+bool DEBREP_Provider::Read(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ const Message_ProgressRange& theProgress)
+{
+ if (theDocument.IsNull())
+ {
+ Message::SendFail() << "Error in the DEBREP_Provider during reading the file " << thePath
+ << "\t: theDocument shouldn't be null";
+ return false;
+ }
+ TopoDS_Shape aShape;
+ if (!Read(thePath, aShape, theProgress))
+ {
+ return false;
+ }
+ Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
+ aShTool->AddShape(aShape);
+ return true;
+}
+
+//=================================================================================================
+
+bool DEBREP_Provider::Write(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ const Message_ProgressRange& theProgress)
+{
+ TopoDS_Shape aShape;
+ TDF_LabelSequence aLabels;
+ Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
+ aSTool->GetFreeShapes(aLabels);
+ if (aLabels.Length() <= 0)
+ {
+ Message::SendFail() << "Error in the DEBREP_Provider during writing the file " << thePath
+ << "\t: Document contain no shapes";
+ return false;
+ }
+
+ Handle(DEBREP_ConfigurationNode) aNode = Handle(DEBREP_ConfigurationNode)::DownCast(GetNode());
+ if (aNode->GlobalParameters.LengthUnit != 1.0)
+ {
+ Message::SendWarning()
+ << "Warning in the DEBREP_Provider during writing the file " << thePath
+ << "\t: Target Units for writing were changed, but current format doesn't support scaling";
+ }
+
+ if (aLabels.Length() == 1)
+ {
+ aShape = aSTool->GetShape(aLabels.Value(1));
+ }
+ else
+ {
+ TopoDS_Compound aComp;
+ BRep_Builder aBuilder;
+ aBuilder.MakeCompound(aComp);
+ for (Standard_Integer anIndex = 1; anIndex <= aLabels.Length(); anIndex++)
+ {
+ TopoDS_Shape aS = aSTool->GetShape(aLabels.Value(anIndex));
+ aBuilder.Add(aComp, aS);
+ }
+ aShape = aComp;
+ }
+ return Write(thePath, aShape, theProgress);
+}
+
+//=================================================================================================
+
+bool DEBREP_Provider::Read(const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ (void)theWS;
+ return Read(thePath, theShape, theProgress);
+}
+
+//=================================================================================================
+
+bool DEBREP_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);
+}
+
+//=================================================================================================
+
+bool DEBREP_Provider::Read(const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ const Message_ProgressRange& theProgress)
+{
+ bool isBinaryFormat = true;
+ {
+ // probe file header to recognize format
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ std::shared_ptr<std::istream> aFile =
+ aFileSystem->OpenIStream(thePath, std::ios::in | std::ios::binary);
+ if (aFile.get() == NULL)
+ {
+ Message::SendFail() << "Error in the DEBREP_Provider during reading the file " << thePath
+ << "\t: Cannot read the file";
+ return false;
+ }
+
+ char aStringBuf[255] = {};
+ aFile->read(aStringBuf, 255);
+ if (aFile->fail())
+ {
+ Message::SendFail() << "Error in the DEBREP_Provider during reading the file " << thePath
+ << "\t: Cannot read the file";
+ return false;
+ }
+ isBinaryFormat = !(::strncmp(aStringBuf, "DBRep_DrawableShape", 19) == 0);
+ }
+
+ if (isBinaryFormat)
+ {
+ if (!BinTools::Read(theShape, thePath.ToCString(), theProgress))
+ {
+ Message::SendFail() << "Error in the DEBREP_Provider during reading the file " << thePath
+ << "\t: Cannot read from the file";
+ return false;
+ }
+ }
+ else
+ {
+ if (!BRepTools::Read(theShape, thePath.ToCString(), BRep_Builder(), theProgress))
+ {
+ Message::SendFail() << "Error in the DEBREP_Provider during reading the file " << thePath
+ << "\t: Cannot read from the file";
+ return false;
+ }
+ }
+
+ return true;
+}
+
+//=================================================================================================
+
+bool DEBREP_Provider::Write(const TCollection_AsciiString& thePath,
+ const TopoDS_Shape& theShape,
+ const Message_ProgressRange& theProgress)
+{
+ if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEBREP_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DEBREP_Provider during writing the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DEBREP_ConfigurationNode) aNode = Handle(DEBREP_ConfigurationNode)::DownCast(GetNode());
+ if (aNode->GlobalParameters.LengthUnit != 1.0)
+ {
+ Message::SendWarning()
+ << "Warning in the DEBREP_Provider during writing the file " << thePath
+ << "\t: Target Units for writing were changed, but current format doesn't support scaling";
+ }
+ if (aNode->InternalParameters.WriteBinary)
+ {
+ if (aNode->InternalParameters.WriteVersionBin
+ > static_cast<BinTools_FormatVersion>(BinTools_FormatVersion_UPPER)
+ || aNode->InternalParameters.WriteVersionBin
+ < static_cast<BinTools_FormatVersion>(BinTools_FormatVersion_LOWER))
+ {
+ Message::SendFail() << "Error in the DEBREP_Provider during writing the file " << thePath
+ << "\t: Unknown format version";
+ return false;
+ }
+ if (aNode->InternalParameters.WriteNormals
+ && aNode->InternalParameters.WriteVersionBin < BinTools_FormatVersion_VERSION_4)
+ {
+ Message::SendFail() << "Error in the DEBREP_Provider during writing the file " << thePath
+ << "\t: Vertex normals require binary format version 4 or later";
+ return false;
+ }
+
+ if (!BinTools::Write(theShape,
+ thePath.ToCString(),
+ aNode->InternalParameters.WriteTriangles,
+ aNode->InternalParameters.WriteNormals,
+ aNode->InternalParameters.WriteVersionBin,
+ theProgress))
+ {
+ Message::SendFail() << "Error in the DEBREP_Provider during writing the file " << thePath
+ << "\t: Cannot write the file";
+ return false;
+ }
+ }
+ else
+ {
+ if (aNode->InternalParameters.WriteVersionAscii
+ > static_cast<TopTools_FormatVersion>(TopTools_FormatVersion_UPPER)
+ || aNode->InternalParameters.WriteVersionAscii
+ < static_cast<TopTools_FormatVersion>(TopTools_FormatVersion_LOWER))
+ {
+ Message::SendFail() << "Error in the DEBREP_Provider during writing the file " << thePath
+ << "\t: Unknown format version";
+ return false;
+ }
+ if (aNode->InternalParameters.WriteNormals
+ && aNode->InternalParameters.WriteVersionAscii < TopTools_FormatVersion_VERSION_3)
+ {
+ Message::SendFail() << "Error in the DEBREP_Provider during writing the file " << thePath
+ << "\t: Error: vertex normals require ascii format version 3 or later";
+ return false;
+ }
+ if (!BRepTools::Write(theShape,
+ thePath.ToCString(),
+ aNode->InternalParameters.WriteTriangles,
+ aNode->InternalParameters.WriteNormals,
+ aNode->InternalParameters.WriteVersionAscii,
+ theProgress))
+ {
+ Message::SendFail() << "Error in the DEBREP_Provider during writing the file " << thePath
+ << "\t: Cannot write the file";
+ return false;
+ }
+ }
+
+ return true;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEBREP_Provider::GetFormat() const
+{
+ return TCollection_AsciiString("BREP");
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEBREP_Provider::GetVendor() const
+{
+ return TCollection_AsciiString("OCC");
+}
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _DEBREP_Provider_HeaderFile
+#define _DEBREP_Provider_HeaderFile
+
+#include <DE_Provider.hxx>
+
+//! The class to transfer BRep files.
+//! Reads and Writes any BRep files into/from OCCT.
+//! Each operation needs configuration node.
+//!
+//! Providers grouped by Vendor name and Format type.
+//! The Vendor name is "OCC"
+//! The Format type is "BREP"
+//! The import process is supported.
+//! The export process is supported.
+class DEBREP_Provider : public DE_Provider
+{
+public:
+ DEFINE_STANDARD_RTTIEXT(DEBREP_Provider, DE_Provider)
+
+public:
+ //! Default constructor
+ //! Configure translation process with global configuration
+ Standard_EXPORT DEBREP_Provider();
+
+ //! Configure translation process
+ //! @param[in] theNode object to init the DE_Provider
+ Standard_EXPORT DEBREP_Provider(const Handle(DE_ConfigurationNode)& theNode);
+
+public:
+ //! Reads a CAD file, according internal configuration
+ //! @param[in] thePath path to the import CAD file
+ //! @param[out] theDocument document to save result
+ //! @param[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Read operation has ended correctly
+ Standard_EXPORT virtual bool Read(
+ const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ 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[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Write operation has ended correctly
+ Standard_EXPORT virtual bool Write(
+ const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ 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[in] theProgress 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[in] theProgress 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
+ //! @param[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Read operation has ended correctly
+ Standard_EXPORT virtual bool Read(
+ const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ 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[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Write operation has ended correctly
+ Standard_EXPORT virtual bool Write(
+ const TCollection_AsciiString& thePath,
+ const TopoDS_Shape& theShape,
+ 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[in] theProgress 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[in] theProgress 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 CAD format
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
+
+ //! Gets provider's vendor name of associated provider
+ //! @return provider's vendor name
+ Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+};
+
+#endif // _DEBREP_Provider_HeaderFile
--- /dev/null
+DEBREP_ConfigurationNode.cxx
+DEBREP_ConfigurationNode.hxx
+DEBREP_Provider.cxx
+DEBREP_Provider.hxx
+++ /dev/null
-// Copyright (c) 2022 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <DEBRepCascade_ConfigurationNode.hxx>
-
-#include <DE_ConfigurationContext.hxx>
-#include <DE_PluginHolder.hxx>
-#include <DEBRepCascade_Provider.hxx>
-#include <NCollection_Buffer.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(DEBRepCascade_ConfigurationNode, DE_ConfigurationNode)
-
-namespace
-{
- static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
- {
- static const TCollection_AsciiString aScope = "provider";
- return aScope;
- }
-
- // Wrapper to auto-load DE component
- DE_PluginHolder<DEBRepCascade_ConfigurationNode> THE_OCCT_BREP_COMPONENT_PLUGIN;
-}
-
-//=======================================================================
-// function : DEBRepCascade_ConfigurationNode
-// purpose :
-//=======================================================================
-DEBRepCascade_ConfigurationNode::DEBRepCascade_ConfigurationNode() :
- DE_ConfigurationNode()
-{}
-
-//=======================================================================
-// function : DEBRepCascade_ConfigurationNode
-// purpose :
-//=======================================================================
-DEBRepCascade_ConfigurationNode::DEBRepCascade_ConfigurationNode(const Handle(DEBRepCascade_ConfigurationNode)& theNode)
- :DE_ConfigurationNode(theNode)
-{
- InternalParameters = theNode->InternalParameters;
-}
-
-//=======================================================================
-// function : Load
-// purpose :
-//=======================================================================
-bool DEBRepCascade_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
-{
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
-
- InternalParameters.WriteBinary =
- theResource->BooleanVal("write.binary", InternalParameters.WriteBinary, aScope);
- InternalParameters.WriteVersionBin =
- (BinTools_FormatVersion)theResource->IntegerVal("write.version.binary", InternalParameters.WriteVersionBin, aScope);
- InternalParameters.WriteVersionAscii =
- (TopTools_FormatVersion)theResource->IntegerVal("write.version.ascii", InternalParameters.WriteVersionAscii, aScope);
- InternalParameters.WriteTriangles =
- theResource->BooleanVal("write.triangles", InternalParameters.WriteTriangles, aScope);
- InternalParameters.WriteNormals =
- theResource->BooleanVal("write.normals", InternalParameters.WriteNormals, aScope);
- return true;
-}
-
-//=======================================================================
-// function : Save
-// purpose :
-//=======================================================================
-TCollection_AsciiString DEBRepCascade_ConfigurationNode::Save() const
-{
- TCollection_AsciiString aResult;
- aResult += "!*****************************************************************************\n";
- aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
-
- aResult += "!\n";
- aResult += "!Write parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the binary file format\n";
- aResult += "!Default value: 1. Available values: 0(\"off\"), 1(\"on\")\n";
- aResult += aScope + "write.binary :\t " + InternalParameters.WriteBinary + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the format version for the binary format writing\n";
- aResult += "!Default value: 4. Available values: 1, 2, 3, 4\n";
- aResult += aScope + "write.version.binary :\t " + InternalParameters.WriteVersionBin + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the format version for the ASCII format writing\n";
- aResult += "!Default value: 3. Available values: 1, 2, 3\n";
- aResult += aScope + "write.version.ascii :\t " + InternalParameters.WriteVersionAscii + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the flag for storing shape with(without) triangles\n";
- aResult += "!Default value: 1. Available values: 0(\"off\"), 1(\"on\")\n";
- aResult += aScope + "write.triangles :\t " + InternalParameters.WriteTriangles + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the flag for storing shape with(without) normals\n";
- aResult += "!Default value: 1. Available values: 0(\"off\"), 1(\"on\")\n";
- aResult += aScope + "write.normals :\t " + InternalParameters.WriteNormals + "\n";
- aResult += "!\n";
-
- aResult += "!*****************************************************************************\n";
- return aResult;
-}
-
-//=======================================================================
-// function : Copy
-// purpose :
-//=======================================================================
-Handle(DE_ConfigurationNode) DEBRepCascade_ConfigurationNode::Copy() const
-{
- return new DEBRepCascade_ConfigurationNode(*this);
-}
-
-//=======================================================================
-// function : BuildProvider
-// purpose :
-//=======================================================================
-Handle(DE_Provider) DEBRepCascade_ConfigurationNode::BuildProvider()
-{
- return new DEBRepCascade_Provider(this);
-}
-
-//=======================================================================
-// function : IsImportSupported
-// purpose :
-//=======================================================================
-bool DEBRepCascade_ConfigurationNode::IsImportSupported() const
-{
- return true;
-}
-
-//=======================================================================
-// function : IsExportSupported
-// purpose :
-//=======================================================================
-bool DEBRepCascade_ConfigurationNode::IsExportSupported() const
-{
- return true;
-}
-
-//=======================================================================
-// function : GetFormat
-// purpose :
-//=======================================================================
-TCollection_AsciiString DEBRepCascade_ConfigurationNode::GetFormat() const
-{
- return TCollection_AsciiString("BREP");
-}
-
-//=======================================================================
-// function : GetVendor
-// purpose :
-//=======================================================================
-TCollection_AsciiString DEBRepCascade_ConfigurationNode::GetVendor() const
-{
- return TCollection_AsciiString("OCC");
-}
-
-//=======================================================================
-// function : GetExtensions
-// purpose :
-//=======================================================================
-TColStd_ListOfAsciiString DEBRepCascade_ConfigurationNode::GetExtensions() const
-{
- TColStd_ListOfAsciiString anExt;
- anExt.Append("brep");
- return anExt;
-}
-
-//=======================================================================
-// function : CheckContent
-// purpose :
-//=======================================================================
-bool DEBRepCascade_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
-{
- if (theBuffer.IsNull() || theBuffer->Size() < 20)
- {
- return false;
- }
- const char* aBytes = (const char*)theBuffer->Data();
- if (::strstr(aBytes, "DBRep_DrawableShape") ||
- ::strstr(aBytes, "CASCADE Topology V1") ||
- ::strstr(aBytes, "CASCADE Topology V3"))
- {
- return true;
- }
- return false;
-}
-
#ifndef _DEBRepCascade_ConfigurationNode_HeaderFile
#define _DEBRepCascade_ConfigurationNode_HeaderFile
-#include <DE_ConfigurationNode.hxx>
+#include <DEBREP_ConfigurationNode.hxx>
-#include <BinTools_FormatVersion.hxx>
-#include <TopTools_FormatVersion.hxx>
-
-//! The purpose of this class is to configure the transfer process for BRep format
-//! Stores the necessary settings for DEBRepCascade_Provider.
-//! Configures and creates special provider to transfer BRep files.
-//!
-//! Nodes grouped by Vendor name and Format type.
-//! The Vendor name is "OCC"
-//! The Format type is "BREP"
-//! The supported CAD extension is ".brep"
-//! The import process is supported.
-//! The export process is supported.
-class DEBRepCascade_ConfigurationNode : public DE_ConfigurationNode
-{
- DEFINE_STANDARD_RTTIEXT(DEBRepCascade_ConfigurationNode, DE_ConfigurationNode)
-public:
-
- //! Initializes all field by default
- Standard_EXPORT DEBRepCascade_ConfigurationNode();
-
- //! Copies values of all fields
- //! @param[in] theNode object to copy
- Standard_EXPORT DEBRepCascade_ConfigurationNode(const Handle(DEBRepCascade_ConfigurationNode)& theNode);
-
- //! Updates values according the resource
- //! @param[in] theResource input resource to use
- //! @return true if theResource loading has ended correctly
- Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource) Standard_OVERRIDE;
-
- //! Writes configuration to the string
- //! @return result resource string
- Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
-
- //! Copies values of all fields
- //! @return new object with the same field values
- Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
-
-
- //! Creates new provider for the own format
- //! @return new created provider
- Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
-
-public:
-
- //! Checks the import supporting
- //! @return true if import is supported
- Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
-
- //! Checks the export supporting
- //! @return true if export is supported
- Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
-
- //! Gets CAD format name of associated provider
- //! @return provider CAD format
- Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
-
- //! Gets provider's vendor name of associated provider
- //! @return provider's vendor name
- Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
-
- //! Gets list of supported file extensions
- //! @return list of extensions
- Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
-
- //! Checks the file content to verify a format
- //! @param[in] theBuffer read stream buffer to check content
- //! @return Standard_True if file is supported by a current provider
- Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const Standard_OVERRIDE;
-
-public:
- struct DEBRep_InternalSection
- {
- // Write
- bool WriteBinary = true; //!< Defines the binary file format
-// clang-format off
- BinTools_FormatVersion WriteVersionBin = BinTools_FormatVersion_CURRENT; //!< Defines the writer version for the binary format
- TopTools_FormatVersion WriteVersionAscii = TopTools_FormatVersion_CURRENT; //!< Defines the writer version for the ASCII format
-// clang-format on
- bool WriteTriangles = true; //!< Defines the flag for storing shape with(without) triangles
- bool WriteNormals = true; //!< Defines the flag for storing shape with(without) normals
-
- } InternalParameters;
-};
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef DEBREP_ConfigurationNode DEBRepCascade_ConfigurationNode;
#endif // _DEBRepCascade_ConfigurationNode_HeaderFile
+++ /dev/null
-// Copyright (c) 2022 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <DEBRepCascade_Provider.hxx>
-
-#include <BinTools.hxx>
-#include <BRep_Builder.hxx>
-#include <BRepTools.hxx>
-#include <DEBRepCascade_ConfigurationNode.hxx>
-#include <Message.hxx>
-#include <OSD_FileSystem.hxx>
-#include <TDocStd_Document.hxx>
-#include <XCAFDoc_ShapeTool.hxx>
-#include <XCAFDoc_DocumentTool.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(DEBRepCascade_Provider, DE_Provider)
-
-//=======================================================================
-// function : DEBRepCascade_Provider
-// purpose :
-//=======================================================================
-DEBRepCascade_Provider::DEBRepCascade_Provider()
-{}
-
-//=======================================================================
-// function : DEBRepCascade_Provider
-// purpose :
-//=======================================================================
-DEBRepCascade_Provider::DEBRepCascade_Provider(const Handle(DE_ConfigurationNode)& theNode)
- :DE_Provider(theNode)
-{}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool DEBRepCascade_Provider::Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- Handle(XSControl_WorkSession)& theWS,
- 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())
- {
- 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))
- {
- return false;
- }
- Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
- aShTool->AddShape(aShape);
- return true;
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
- TopoDS_Shape aShape;
- TDF_LabelSequence aLabels;
- Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
- aSTool->GetFreeShapes(aLabels);
- if (aLabels.Length() <= 0)
- {
- Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
- thePath << "\t: Document contain no shapes";
- return false;
- }
-
- Handle(DEBRepCascade_ConfigurationNode) aNode = Handle(DEBRepCascade_ConfigurationNode)::DownCast(GetNode());
- if (aNode->GlobalParameters.LengthUnit != 1.0)
- {
- Message::SendWarning() << "Warning in the DEBRepCascade_Provider during writing the file " <<
- thePath << "\t: Target Units for writing were changed, but current format doesn't support scaling";
- }
-
- if (aLabels.Length() == 1)
- {
- aShape = aSTool->GetShape(aLabels.Value(1));
- }
- else
- {
- TopoDS_Compound aComp;
- BRep_Builder aBuilder;
- aBuilder.MakeCompound(aComp);
- for (Standard_Integer anIndex = 1; anIndex <= aLabels.Length(); anIndex++)
- {
- TopoDS_Shape aS = aSTool->GetShape(aLabels.Value(anIndex));
- aBuilder.Add(aComp, aS);
- }
- aShape = aComp;
- }
- return Write(thePath, aShape, theProgress);
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool DEBRepCascade_Provider::Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- Handle(XSControl_WorkSession)& theWS,
- 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
- const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
- std::shared_ptr<std::istream> aFile = aFileSystem->OpenIStream(thePath, std::ios::in | std::ios::binary);
- if (aFile.get() == NULL)
- {
- Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
- thePath << "\t: Cannot read the file";
- return false;
- }
-
- char aStringBuf[255] = {};
- aFile->read(aStringBuf, 255);
- if (aFile->fail())
- {
- Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
- thePath << "\t: Cannot read the file";
- return false;
- }
- isBinaryFormat = !(::strncmp(aStringBuf, "DBRep_DrawableShape", 19) == 0);
- }
-
- if (isBinaryFormat)
- {
- if (!BinTools::Read(theShape, thePath.ToCString(), theProgress))
- {
- Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
- thePath << "\t: Cannot read from the file";
- return false;
- }
- }
- else
- {
- if (!BRepTools::Read(theShape, thePath.ToCString(), BRep_Builder(), theProgress))
- {
- Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
- thePath << "\t: Cannot read from the file";
- return false;
- }
- }
-
- return true;
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress)
-{
- if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEBRepCascade_ConfigurationNode)))
- {
- Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
- thePath << "\t: Incorrect or empty Configuration Node";
- return false;
- }
- Handle(DEBRepCascade_ConfigurationNode) aNode = Handle(DEBRepCascade_ConfigurationNode)::DownCast(GetNode());
- if (aNode->GlobalParameters.LengthUnit != 1.0)
- {
- Message::SendWarning() << "Warning in the DEBRepCascade_Provider during writing the file " <<
- thePath << "\t: Target Units for writing were changed, but current format doesn't support scaling";
- }
- if (aNode->InternalParameters.WriteBinary)
- {
- if (aNode->InternalParameters.WriteVersionBin > static_cast<BinTools_FormatVersion>(BinTools_FormatVersion_UPPER) ||
- aNode->InternalParameters.WriteVersionBin < static_cast<BinTools_FormatVersion>(BinTools_FormatVersion_LOWER))
- {
- Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
- thePath << "\t: Unknown format version";
- return false;
- }
- if (aNode->InternalParameters.WriteNormals &&
- aNode->InternalParameters.WriteVersionBin < BinTools_FormatVersion_VERSION_4)
- {
- Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
- thePath << "\t: Vertex normals require binary format version 4 or later";
- return false;
- }
-
- if (!BinTools::Write(theShape, thePath.ToCString(), aNode->InternalParameters.WriteTriangles,
- aNode->InternalParameters.WriteNormals, aNode->InternalParameters.WriteVersionBin, theProgress))
- {
- Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
- thePath << "\t: Cannot write the file";
- return false;
- }
- }
- else
- {
- if (aNode->InternalParameters.WriteVersionAscii > static_cast<TopTools_FormatVersion>(TopTools_FormatVersion_UPPER) ||
- aNode->InternalParameters.WriteVersionAscii < static_cast<TopTools_FormatVersion>(TopTools_FormatVersion_LOWER))
- {
- Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
- thePath << "\t: Unknown format version";
- return false;
- }
- if (aNode->InternalParameters.WriteNormals &&
- aNode->InternalParameters.WriteVersionAscii < TopTools_FormatVersion_VERSION_3)
- {
- Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
- thePath << "\t: Error: vertex normals require ascii format version 3 or later";
- return false;
- }
- if (!BRepTools::Write(theShape, thePath.ToCString(), aNode->InternalParameters.WriteTriangles,
- aNode->InternalParameters.WriteNormals, aNode->InternalParameters.WriteVersionAscii, theProgress))
- {
- Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
- thePath << "\t: Cannot write the file";
- return false;
- }
- }
-
- return true;
-}
-
-//=======================================================================
-// function : GetFormat
-// purpose :
-//=======================================================================
-TCollection_AsciiString DEBRepCascade_Provider::GetFormat() const
-{
- return TCollection_AsciiString("BREP");
-}
-
-//=======================================================================
-// function : GetVendor
-// purpose :
-//=======================================================================
-TCollection_AsciiString DEBRepCascade_Provider::GetVendor() const
-{
- return TCollection_AsciiString("OCC");
-}
#ifndef _DEBRepCascade_Provider_HeaderFile
#define _DEBRepCascade_Provider_HeaderFile
-#include <DE_Provider.hxx>
+#include <DEBREP_Provider.hxx>
-//! The class to transfer BRep files.
-//! Reads and Writes any BRep files into/from OCCT.
-//! Each operation needs configuration node.
-//!
-//! Providers grouped by Vendor name and Format type.
-//! The Vendor name is "OCC"
-//! The Format type is "BREP"
-//! The import process is supported.
-//! The export process is supported.
-class DEBRepCascade_Provider : public DE_Provider
-{
-public:
- DEFINE_STANDARD_RTTIEXT(DEBRepCascade_Provider, DE_Provider)
-
-public:
-
- //! Default constructor
- //! Configure translation process with global configuration
- Standard_EXPORT DEBRepCascade_Provider();
-
- //! Configure translation process
- //! @param[in] theNode object to init the DE_Provider
- Standard_EXPORT DEBRepCascade_Provider(const Handle(DE_ConfigurationNode)& theNode);
-
-public:
-
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theDocument document to save result
- //! @param[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- 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[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- 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[in] theProgress 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[in] theProgress 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
- //! @param[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- 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[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- 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[in] theProgress 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[in] theProgress 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 CAD format
- Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
-
- //! Gets provider's vendor name of associated provider
- //! @return provider's vendor name
- Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
-};
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef DEBREP_Provider DEBRepCascade_Provider;
#endif // _DEBRepCascade_Provider_HeaderFile
-DEBRepCascade_ConfigurationNode.cxx
DEBRepCascade_ConfigurationNode.hxx
-DEBRepCascade_Provider.cxx
DEBRepCascade_Provider.hxx
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <DEGLTF_ConfigurationNode.hxx>
+
+#include <DEGLTF_Provider.hxx>
+#include <DE_ConfigurationContext.hxx>
+#include <DE_PluginHolder.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(DEGLTF_ConfigurationNode, DE_ConfigurationNode)
+
+namespace
+{
+static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
+{
+ static const TCollection_AsciiString aScope = "provider";
+ return aScope;
+}
+
+// Wrapper to auto-load DE component
+DE_PluginHolder<DEGLTF_ConfigurationNode> THE_OCCT_GLTF_COMPONENT_PLUGIN;
+} // namespace
+
+//=================================================================================================
+
+DEGLTF_ConfigurationNode::DEGLTF_ConfigurationNode()
+ : DE_ConfigurationNode()
+{
+}
+
+//=================================================================================================
+
+DEGLTF_ConfigurationNode::DEGLTF_ConfigurationNode(const Handle(DEGLTF_ConfigurationNode)& theNode)
+ : DE_ConfigurationNode(theNode)
+{
+ InternalParameters = theNode->InternalParameters;
+}
+
+//=================================================================================================
+
+bool DEGLTF_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
+{
+ TCollection_AsciiString aScope =
+ THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
+
+ InternalParameters.FileLengthUnit =
+ theResource->RealVal("file.length.unit", InternalParameters.FileLengthUnit, aScope);
+ InternalParameters.SystemCS =
+ (RWMesh_CoordinateSystem)(theResource->IntegerVal("system.cs",
+ (int)InternalParameters.SystemCS,
+ aScope)
+ % 2);
+ InternalParameters.FileCS =
+ (RWMesh_CoordinateSystem)(theResource->IntegerVal("file.cs",
+ (int)InternalParameters.SystemCS,
+ aScope)
+ % 2);
+
+ InternalParameters.ReadSinglePrecision =
+ theResource->BooleanVal("read.single.precision",
+ InternalParameters.ReadSinglePrecision,
+ aScope);
+ InternalParameters.ReadCreateShapes =
+ theResource->BooleanVal("read.create.shapes", InternalParameters.ReadCreateShapes, aScope);
+ InternalParameters.ReadRootPrefix =
+ theResource->StringVal("read.root.prefix", InternalParameters.ReadRootPrefix, aScope);
+ InternalParameters.ReadFillDoc =
+ theResource->BooleanVal("read.fill.doc", InternalParameters.ReadFillDoc, aScope);
+ InternalParameters.ReadFillIncomplete =
+ theResource->BooleanVal("read.fill.incomplete", InternalParameters.ReadFillIncomplete, aScope);
+ InternalParameters.ReadMemoryLimitMiB =
+ theResource->IntegerVal("read.memory.limit.mib", InternalParameters.ReadMemoryLimitMiB, aScope);
+ InternalParameters.ReadParallel =
+ theResource->BooleanVal("read.parallel", InternalParameters.ReadParallel, aScope);
+ InternalParameters.ReadSkipEmptyNodes =
+ theResource->BooleanVal("read.skip.empty.nodes", InternalParameters.ReadSkipEmptyNodes, aScope);
+ InternalParameters.ReadLoadAllScenes =
+ theResource->BooleanVal("read.load.all.scenes", InternalParameters.ReadLoadAllScenes, aScope);
+ InternalParameters.ReadUseMeshNameAsFallback =
+ theResource->BooleanVal("read.use.mesh.name.as.fallback",
+ InternalParameters.ReadUseMeshNameAsFallback,
+ aScope);
+ InternalParameters.ReadSkipLateDataLoading =
+ theResource->BooleanVal("read.skip.late.data.loading",
+ InternalParameters.ReadSkipLateDataLoading,
+ aScope);
+ InternalParameters.ReadKeepLateData =
+ theResource->BooleanVal("read.keep.late.data", InternalParameters.ReadKeepLateData, aScope);
+ InternalParameters.ReadPrintDebugMessages =
+ theResource->BooleanVal("read.print.debug.message",
+ InternalParameters.ReadPrintDebugMessages,
+ aScope);
+
+ InternalParameters.WriteComment =
+ theResource->StringVal("write.comment", InternalParameters.WriteComment, aScope);
+ InternalParameters.WriteAuthor =
+ theResource->StringVal("write.author", InternalParameters.WriteAuthor, aScope);
+
+ InternalParameters.WriteTrsfFormat =
+ (RWGltf_WriterTrsfFormat)(theResource->IntegerVal("write.trsf.format",
+ InternalParameters.WriteTrsfFormat,
+ aScope)
+ % (RWGltf_WriterTrsfFormat_UPPER + 1));
+ InternalParameters.WriteNodeNameFormat =
+ (RWMesh_NameFormat)(theResource->IntegerVal("write.node.name.format",
+ InternalParameters.WriteNodeNameFormat,
+ aScope)
+ % (RWMesh_NameFormat_ProductAndInstanceAndOcaf + 1));
+ InternalParameters.WriteMeshNameFormat =
+ (RWMesh_NameFormat)(theResource->IntegerVal("write.mesh.name.format",
+ InternalParameters.WriteMeshNameFormat,
+ aScope)
+ % (RWMesh_NameFormat_ProductAndInstanceAndOcaf + 1));
+ InternalParameters.WriteForcedUVExport =
+ theResource->BooleanVal("write.forced.uv.export",
+ InternalParameters.WriteForcedUVExport,
+ aScope);
+ InternalParameters.WriteEmbedTexturesInGlb =
+ theResource->BooleanVal("write.embed.textures.in.glb",
+ InternalParameters.WriteEmbedTexturesInGlb,
+ aScope);
+ InternalParameters.WriteMergeFaces =
+ theResource->BooleanVal("write.merge.faces", InternalParameters.WriteMergeFaces, aScope);
+ InternalParameters.WriteSplitIndices16 =
+ theResource->BooleanVal("write.split.indices16",
+ InternalParameters.WriteSplitIndices16,
+ aScope);
+ return true;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEGLTF_ConfigurationNode::Save() const
+{
+ TCollection_AsciiString aResult;
+ aResult += "!*****************************************************************************\n";
+ aResult =
+ aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
+ TCollection_AsciiString aScope =
+ THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
+
+ aResult += "!\n";
+ aResult += "!Common parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!File length units to convert from while reading the file, defined as scale factor "
+ "for m (meters)\n";
+ aResult += "!Default value: 1.0(M)\n";
+ aResult += aScope + "file.length.unit :\t " + InternalParameters.FileLengthUnit + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!System origin coordinate system to perform conversion into during read\n";
+ aResult += "!Default value: 0(Zup). Available values: 0(Zup), 1(Yup)\n";
+ aResult += aScope + "system.cs :\t " + InternalParameters.SystemCS + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!File origin coordinate system to perform conversion during read\n";
+ aResult += "!Default value: 1(Yup). Available values: 0(Zup), 1(Yup)\n";
+ aResult += aScope + "file.cs :\t " + InternalParameters.FileCS + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Read parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag for reading vertex data with single or double floating point precision\n";
+ aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "read.single.precision :\t " + InternalParameters.ReadSinglePrecision + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag for create a single triangulation\n";
+ aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "read.create.shapes :\t " + InternalParameters.ReadCreateShapes + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Root folder for generating root labels names\n";
+ aResult += "!Default value: "
+ "(empty). Available values: <path>\n";
+ aResult += aScope + "read.root.prefix :\t " + InternalParameters.ReadRootPrefix + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag for fill document from shape sequence\n";
+ aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "read.fill.doc :\t " + InternalParameters.ReadFillDoc + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag for fill the document with partially retrieved data even if reader has fa-iled "
+ "with er-ror\n";
+ aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "read.fill.incomplete :\t " + InternalParameters.ReadFillIncomplete + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Memory usage limit(MiB)\n";
+ aResult += "!Default value: -1(no limit). Available values: -1(no limit), any positive value\n";
+ aResult += aScope + "read.memory.limit.mib :\t " + InternalParameters.ReadMemoryLimitMiB + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag to use multithreading\n";
+ aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "read.parallel :\t " + InternalParameters.ReadParallel + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag to ignore nodes without Geometry\n";
+ aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "read.skip.empty.nodes :\t " + InternalParameters.ReadSkipEmptyNodes + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag to load all scenes in the document\n";
+ aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "read.load.all.scenes :\t " + InternalParameters.ReadLoadAllScenes + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag to use Mesh name in case if Node name is empty\n";
+ aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "read.use.mesh.name.as.fallback :\t "
+ + InternalParameters.ReadUseMeshNameAsFallback + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag to skip triangulation loading\n";
+ aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
+ aResult +=
+ aScope + "read.skip.late.data.loading :\t " + InternalParameters.ReadSkipLateDataLoading + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult +=
+ "!Flag to keep information about deferred storage to load/unload triangulation later\n";
+ aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "read.keep.late.data :\t " + InternalParameters.ReadKeepLateData + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag to print additional debug information\n";
+ aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
+ aResult +=
+ aScope + "read.print.debug.message :\t " + InternalParameters.ReadPrintDebugMessages + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Write parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Export special comment\n";
+ aResult += "!Default value: "
+ "(empty). Available values: <string>\n";
+ aResult += aScope + "write.comment :\t " + InternalParameters.WriteComment + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Author of exported file name\n";
+ aResult += "!Default value: "
+ "(empty). Available values: <string>\n";
+ aResult += aScope + "write.author :\t " + InternalParameters.WriteAuthor + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Transformation format to write into glTF file\n";
+ aResult += "!Default value: 0(Compact). Available values: 0(Compact), 1(Mat4), 2(TRS)\n";
+ aResult += aScope + "write.trsf.format :\t " + InternalParameters.WriteTrsfFormat + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "! Name format for exporting Nodes\n";
+ aResult += "!Default value: 3(InstanceOrProduct). Available values: 0(Compact), 1(Mat4), 2(TRS), "
+ "3(InstanceOrProduct), 4(ProductOrInstance), 5(ProductAndInstance), "
+ "6(ProductAndInstanceAndOcaf)\n";
+ aResult += aScope + "write.node.name.format :\t " + InternalParameters.WriteNodeNameFormat + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Name format for exporting Meshes\n";
+ aResult += "!Default value: 1(Product). Available values: 0(Compact), 1(Mat4), 2(TRS), "
+ "3(InstanceOrProduct), 4(ProductOrInstance), 5(ProductAndInstance), "
+ "6(ProductAndInstanceAndOcaf)\n";
+ aResult += aScope + "write.mesh.name.format :\t " + InternalParameters.WriteMeshNameFormat + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Export UV coordinates even if there are no mapped texture\n";
+ aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "write.forced.uv.export :\t " + InternalParameters.WriteForcedUVExport + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag to write image textures into GLB file\n";
+ aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
+ aResult +=
+ aScope + "write.embed.textures.in.glb :\t " + InternalParameters.WriteEmbedTexturesInGlb + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag to merge faces within a single part\n";
+ aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "write.merge.faces :\t " + InternalParameters.WriteMergeFaces + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag to prefer keeping 16-bit indexes while merging face\n";
+ aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "write.split.indices16 :\t " + InternalParameters.WriteSplitIndices16 + "\n";
+ aResult += "!\n";
+
+ aResult += "!*****************************************************************************\n";
+ return aResult;
+}
+
+//=================================================================================================
+
+Handle(DE_ConfigurationNode) DEGLTF_ConfigurationNode::Copy() const
+{
+ return new DEGLTF_ConfigurationNode(*this);
+}
+
+//=================================================================================================
+
+Handle(DE_Provider) DEGLTF_ConfigurationNode::BuildProvider()
+{
+ return new DEGLTF_Provider(this);
+}
+
+//=================================================================================================
+
+bool DEGLTF_ConfigurationNode::IsImportSupported() const
+{
+ return true;
+}
+
+//=================================================================================================
+
+bool DEGLTF_ConfigurationNode::IsExportSupported() const
+{
+ return true;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEGLTF_ConfigurationNode::GetFormat() const
+{
+ return TCollection_AsciiString("GLTF");
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEGLTF_ConfigurationNode::GetVendor() const
+{
+ return TCollection_AsciiString("OCC");
+}
+
+//=================================================================================================
+
+TColStd_ListOfAsciiString DEGLTF_ConfigurationNode::GetExtensions() const
+{
+ TColStd_ListOfAsciiString anExt;
+ anExt.Append("gltf");
+ anExt.Append("glb");
+ return anExt;
+}
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _DEGLTF_ConfigurationNode_HeaderFile
+#define _DEGLTF_ConfigurationNode_HeaderFile
+
+#include <DE_ConfigurationNode.hxx>
+#include <RWGltf_WriterTrsfFormat.hxx>
+#include <RWMesh_CoordinateSystem.hxx>
+#include <RWMesh_NameFormat.hxx>
+
+//! The purpose of this class is to configure the transfer process for glTF format
+//! Stores the necessary settings for DEGLTF_Provider.
+//! Configures and creates special provider to transfer glTF files.
+//!
+//! Nodes grouped by Vendor name and Format type.
+//! The Vendor name is "OCC"
+//! The Format type is "GLTF"
+//! The supported CAD extensions are ".gltf", ".glb"
+//! The import process is supported.
+//! The export process is supported.
+class DEGLTF_ConfigurationNode : public DE_ConfigurationNode
+{
+ DEFINE_STANDARD_RTTIEXT(DEGLTF_ConfigurationNode, DE_ConfigurationNode)
+public:
+ //! Initializes all field by default
+ Standard_EXPORT DEGLTF_ConfigurationNode();
+
+ //! Copies values of all fields
+ //! @param[in] theNode object to copy
+ Standard_EXPORT DEGLTF_ConfigurationNode(const Handle(DEGLTF_ConfigurationNode)& theNode);
+
+ //! Updates values according the resource
+ //! @param[in] theResource input resource to use
+ //! @return true if theResource loading has ended correctly
+ Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource)
+ Standard_OVERRIDE;
+
+ //! Writes configuration to the string
+ //! @return result resource string
+ Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
+
+ //! Copies values of all fields
+ //! @return new object with the same field values
+ Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
+
+ //! Creates new provider for the own format
+ //! @return new created provider
+ Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
+
+public:
+ //! Checks the import supporting
+ //! @return true if import is supported
+ Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
+
+ //! Checks the export supporting
+ //! @return true if export is supported
+ Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
+
+ //! Gets CAD format name of associated provider
+ //! @return provider CAD format
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
+
+ //! Gets provider's vendor name of associated provider
+ //! @return provider's vendor name
+ Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+
+ //! Gets list of supported file extensions
+ //! @return list of extensions
+ Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
+
+public:
+ struct RWGltf_InternalSection
+ {
+ // Common
+ // clang-format off
+ double FileLengthUnit = 1.; //!< File length units to convert from while reading the file, defined as scale factor for m (meters)
+ RWMesh_CoordinateSystem SystemCS = RWMesh_CoordinateSystem_Zup; //!< System origin coordinate system to perform conversion into during read
+ RWMesh_CoordinateSystem FileCS = RWMesh_CoordinateSystem_Yup; //!< File origin coordinate system to perform conversion during read
+ // Reading
+ bool ReadSinglePrecision = true; //!< Flag for reading vertex data with single or double floating point precision
+ bool ReadCreateShapes = false; //!< Flag for create a single triangulation
+ TCollection_AsciiString ReadRootPrefix; //!< Root folder for generating root labels names
+ bool ReadFillDoc = true; //!< Flag for fill document from shape sequence
+ bool ReadFillIncomplete = true; //!< Flag for fill the document with partially retrieved data even if reader has failed with error
+ int ReadMemoryLimitMiB = -1; //!< Memory usage limit
+ bool ReadParallel = false; //!< Flag to use multithreading
+ bool ReadSkipEmptyNodes = true; //!< Flag to ignore nodes without Geometry
+ bool ReadLoadAllScenes = false; //!< Flag to load all scenes in the document
+ bool ReadUseMeshNameAsFallback = true; //!< Flag to use Mesh name in case if Node name is empty
+ bool ReadSkipLateDataLoading = false; //!< Flag to skip triangulation loading
+ bool ReadKeepLateData = true;//!< Flag to keep information about deferred storage to load/unload triangulation later
+ bool ReadPrintDebugMessages = false; //!< Flag to print additional debug information
+ // Writing
+ TCollection_AsciiString WriteComment; //!< Export special comment
+ TCollection_AsciiString WriteAuthor; //!< Author of exported file name
+ RWGltf_WriterTrsfFormat WriteTrsfFormat = RWGltf_WriterTrsfFormat_Compact; //!< Transformation format to write into glTF file
+ RWMesh_NameFormat WriteNodeNameFormat = RWMesh_NameFormat_InstanceOrProduct; //!< Name format for exporting Nodes
+ RWMesh_NameFormat WriteMeshNameFormat = RWMesh_NameFormat_Product; //!< Name format for exporting Meshes
+ bool WriteForcedUVExport = false; //!< Export UV coordinates even if there are no mapped texture
+ bool WriteEmbedTexturesInGlb = true; //!< Flag to write image textures into GLB file
+ bool WriteMergeFaces = false; //!< Flag to merge faces within a single part
+ bool WriteSplitIndices16 = false; //!< Flag to prefer keeping 16-bit indexes while merging face
+ // clang-format on
+ } InternalParameters;
+};
+
+#endif // _DEGLTF_ConfigurationNode_HeaderFile
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <DEGLTF_Provider.hxx>
+
+#include <Message.hxx>
+#include <RWGltf_CafWriter.hxx>
+#include <TDocStd_Document.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <XCAFDoc_ShapeTool.hxx>
+
+namespace
+{
+//=================================================================================================
+
+static void SetReaderParameters(RWGltf_CafReader& theReader,
+ const Handle(DEGLTF_ConfigurationNode)& theNode)
+{
+ theReader.SetDoublePrecision(!theNode->InternalParameters.ReadSinglePrecision);
+ theReader.SetSystemLengthUnit(theNode->GlobalParameters.LengthUnit / 1000);
+ theReader.SetSystemCoordinateSystem(theNode->InternalParameters.SystemCS);
+ theReader.SetFileLengthUnit(theNode->InternalParameters.FileLengthUnit);
+ theReader.SetFileCoordinateSystem(theNode->InternalParameters.FileCS);
+ theReader.SetRootPrefix(theNode->InternalParameters.ReadRootPrefix);
+ theReader.SetMemoryLimitMiB(theNode->InternalParameters.ReadMemoryLimitMiB);
+
+ theReader.SetParallel(theNode->InternalParameters.ReadParallel);
+ theReader.SetSkipEmptyNodes(theNode->InternalParameters.ReadSkipEmptyNodes);
+ theReader.SetLoadAllScenes(theNode->InternalParameters.ReadLoadAllScenes);
+ theReader.SetMeshNameAsFallback(theNode->InternalParameters.ReadUseMeshNameAsFallback);
+ theReader.SetToSkipLateDataLoading(theNode->InternalParameters.ReadSkipLateDataLoading);
+ theReader.SetToKeepLateData(theNode->InternalParameters.ReadKeepLateData);
+ theReader.SetToPrintDebugMessages(theNode->InternalParameters.ReadPrintDebugMessages);
+}
+} // namespace
+
+IMPLEMENT_STANDARD_RTTIEXT(DEGLTF_Provider, DE_Provider)
+
+//=================================================================================================
+
+DEGLTF_Provider::DEGLTF_Provider() {}
+
+//=================================================================================================
+
+DEGLTF_Provider::DEGLTF_Provider(const Handle(DE_ConfigurationNode)& theNode)
+ : DE_Provider(theNode)
+{
+}
+
+//=================================================================================================
+
+bool DEGLTF_Provider::Read(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ (void)theWS;
+ return Read(thePath, theDocument, theProgress);
+}
+
+//=================================================================================================
+
+bool DEGLTF_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);
+}
+
+//=================================================================================================
+
+bool DEGLTF_Provider::Read(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ const Message_ProgressRange& theProgress)
+{
+ if (theDocument.IsNull())
+ {
+ Message::SendFail() << "Error in the DEGLTF_Provider during reading the file " << thePath
+ << "\t: theDocument shouldn't be null";
+ return false;
+ }
+ if (GetNode().IsNull()
+ || (!GetNode().IsNull() && !GetNode()->IsKind(STANDARD_TYPE(DEGLTF_ConfigurationNode))))
+ {
+ Message::SendFail() << "Error in the DEGLTF_Provider during reading the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DEGLTF_ConfigurationNode) aNode = Handle(DEGLTF_ConfigurationNode)::DownCast(GetNode());
+ RWGltf_CafReader aReader;
+ aReader.SetDocument(theDocument);
+ SetReaderParameters(aReader, aNode);
+ XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
+ aNode->GlobalParameters.LengthUnit,
+ UnitsMethods_LengthUnit_Millimeter);
+ if (!aReader.Perform(thePath, theProgress))
+ {
+ Message::SendFail() << "Error in the DEGLTF_Provider during reading the file " << thePath;
+ return false;
+ }
+
+ return true;
+}
+
+//=================================================================================================
+
+bool DEGLTF_Provider::Write(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ const Message_ProgressRange& theProgress)
+{
+ if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEGLTF_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DEGLTF_Provider during writing the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DEGLTF_ConfigurationNode) aNode = Handle(DEGLTF_ConfigurationNode)::DownCast(GetNode());
+
+ RWMesh_CoordinateSystemConverter aConverter;
+ Standard_Real aScaleFactorM = 1.;
+ if (!XCAFDoc_DocumentTool::GetLengthUnit(theDocument, aScaleFactorM))
+ {
+ aConverter.SetInputLengthUnit(aNode->GlobalParameters.SystemUnit / 1000.);
+ Message::SendWarning()
+ << "Warning in the DEGLTF_Provider during writing the file " << thePath
+ << "\t: The document has no information on Units. Using global parameter as initial Unit.";
+ }
+ aConverter.SetInputCoordinateSystem(aNode->InternalParameters.SystemCS);
+ if (aNode->GlobalParameters.LengthUnit != 1000.)
+ {
+ Message::SendWarning()
+ << "Warning in the DEGLTF_Provider during writing the file " << thePath
+ << "\t: Target format doesn't support custom units. Model will be scaled to Meters";
+ }
+ aConverter.SetOutputLengthUnit(1.); // gltf units always Meters
+ aConverter.SetOutputCoordinateSystem(aNode->InternalParameters.FileCS);
+
+ TColStd_IndexedDataMapOfStringString aFileInfo;
+ if (!aNode->InternalParameters.WriteAuthor.IsEmpty())
+ {
+ aFileInfo.Add("Author", aNode->InternalParameters.WriteAuthor);
+ }
+ if (!aNode->InternalParameters.WriteComment.IsEmpty())
+ {
+ aFileInfo.Add("Comments", aNode->InternalParameters.WriteComment);
+ }
+
+ TCollection_AsciiString anExt = thePath;
+ anExt.LowerCase();
+ RWGltf_CafWriter aWriter(thePath, anExt.EndsWith(".glb"));
+ aWriter.SetCoordinateSystemConverter(aConverter);
+ aWriter.SetTransformationFormat(aNode->InternalParameters.WriteTrsfFormat);
+ aWriter.SetNodeNameFormat(aNode->InternalParameters.WriteNodeNameFormat);
+ aWriter.SetMeshNameFormat(aNode->InternalParameters.WriteMeshNameFormat);
+ aWriter.SetForcedUVExport(aNode->InternalParameters.WriteForcedUVExport);
+ aWriter.SetToEmbedTexturesInGlb(aNode->InternalParameters.WriteEmbedTexturesInGlb);
+ aWriter.SetMergeFaces(aNode->InternalParameters.WriteMergeFaces);
+ aWriter.SetSplitIndices16(aNode->InternalParameters.WriteSplitIndices16);
+ if (!aWriter.Perform(theDocument, aFileInfo, theProgress))
+ {
+ Message::SendFail() << "Error in the DEGLTF_Provider during writing the file " << thePath;
+ return false;
+ }
+ return true;
+}
+
+//=================================================================================================
+
+bool DEGLTF_Provider::Read(const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ (void)theWS;
+ return Read(thePath, theShape, theProgress);
+}
+
+//=================================================================================================
+
+bool DEGLTF_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);
+}
+
+//=================================================================================================
+
+bool DEGLTF_Provider::Read(const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ const Message_ProgressRange& theProgress)
+{
+ if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEGLTF_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DEGLTF_Provider during reading the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DEGLTF_ConfigurationNode) aNode = Handle(DEGLTF_ConfigurationNode)::DownCast(GetNode());
+ RWGltf_CafReader aReader;
+ SetReaderParameters(aReader, aNode);
+ if (!aReader.Perform(thePath, theProgress))
+ {
+ Message::SendFail() << "Error in the DEGLTF_Provider during reading the file " << thePath;
+ return false;
+ }
+ theShape = aReader.SingleShape();
+ return true;
+}
+
+//=================================================================================================
+
+bool DEGLTF_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);
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEGLTF_Provider::GetFormat() const
+{
+ return TCollection_AsciiString("GLTF");
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEGLTF_Provider::GetVendor() const
+{
+ return TCollection_AsciiString("OCC");
+}
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _DEGLTF_Provider_HeaderFile
+#define _DEGLTF_Provider_HeaderFile
+
+#include <DEGLTF_ConfigurationNode.hxx>
+#include <DE_Provider.hxx>
+#include <RWGltf_CafReader.hxx>
+
+//! The class to transfer glTF files.
+//! Reads and Writes any glTF files into/from OCCT.
+//! Each operation needs configuration node.
+//!
+//! Providers grouped by Vendor name and Format type.
+//! The Vendor name is "OCC"
+//! The Format type is "GLTF"
+//! The import process is supported.
+//! The export process is supported.
+class DEGLTF_Provider : public DE_Provider
+{
+public:
+ DEFINE_STANDARD_RTTIEXT(DEGLTF_Provider, DE_Provider)
+
+public:
+ //! Default constructor
+ //! Configure translation process with global configuration
+ Standard_EXPORT DEGLTF_Provider();
+
+ //! Configure translation process
+ //! @param[in] theNode object to copy
+ Standard_EXPORT DEGLTF_Provider(const Handle(DE_ConfigurationNode)& theNode);
+
+public:
+ //! Reads a CAD file, according internal configuration
+ //! @param[in] thePath path to the import CAD file
+ //! @param[out] theDocument document to save result
+ //! @param[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Read operation has ended correctly
+ Standard_EXPORT virtual bool Read(
+ const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ 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[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Write operation has ended correctly
+ Standard_EXPORT virtual bool Write(
+ const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ 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[in] theProgress 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[in] theProgress 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
+ //! @param[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Read operation has ended correctly
+ Standard_EXPORT virtual bool Read(
+ const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ 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[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Write operation has ended correctly
+ Standard_EXPORT virtual bool Write(
+ const TCollection_AsciiString& thePath,
+ const TopoDS_Shape& theShape,
+ 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[in] theProgress 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[in] theProgress 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 CAD format
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
+
+ //! Gets provider's vendor name of associated provider
+ //! @return provider's vendor name
+ Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+};
+
+#endif // _DEGLTF_Provider_HeaderFile
--- /dev/null
+DEGLTF_ConfigurationNode.cxx
+DEGLTF_ConfigurationNode.hxx
+DEGLTF_Provider.cxx
+DEGLTF_Provider.hxx
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <DEIGES_ConfigurationNode.hxx>
+
+#include <DEIGES_Provider.hxx>
+#include <DE_ConfigurationContext.hxx>
+#include <DE_PluginHolder.hxx>
+#include <NCollection_Buffer.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(DEIGES_ConfigurationNode, DE_ConfigurationNode)
+
+namespace
+{
+static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
+{
+ static const TCollection_AsciiString aScope = "provider";
+ return aScope;
+}
+
+// Wrapper to auto-load DE component
+DE_PluginHolder<DEIGES_ConfigurationNode> THE_OCCT_IGES_COMPONENT_PLUGIN;
+} // namespace
+
+//=================================================================================================
+
+DEIGES_ConfigurationNode::DEIGES_ConfigurationNode()
+ : DE_ConfigurationNode()
+{
+}
+
+//=================================================================================================
+
+DEIGES_ConfigurationNode::DEIGES_ConfigurationNode(const Handle(DEIGES_ConfigurationNode)& theNode)
+ : DE_ConfigurationNode(theNode)
+{
+ InternalParameters = theNode->InternalParameters;
+}
+
+//=================================================================================================
+
+bool DEIGES_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
+{
+ TCollection_AsciiString aScope =
+ THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
+
+ InternalParameters.ReadBSplineContinuity =
+ (ReadMode_BSplineContinuity)theResource->IntegerVal("read.iges.bspline.continuity",
+ InternalParameters.ReadBSplineContinuity,
+ aScope);
+ InternalParameters.ReadPrecisionMode =
+ (ReadMode_Precision)theResource->IntegerVal("read.precision.mode",
+ InternalParameters.ReadPrecisionMode,
+ aScope);
+ InternalParameters.ReadPrecisionVal =
+ theResource->RealVal("read.precision.val", InternalParameters.ReadPrecisionVal, aScope);
+ InternalParameters.ReadMaxPrecisionMode =
+ (ReadMode_MaxPrecision)theResource->IntegerVal("read.maxprecision.mode",
+ InternalParameters.ReadMaxPrecisionMode,
+ aScope);
+ InternalParameters.ReadMaxPrecisionVal =
+ theResource->RealVal("read.maxprecision.val", InternalParameters.ReadMaxPrecisionVal, aScope);
+ InternalParameters.ReadSameParamMode =
+ theResource->BooleanVal("read.stdsameparameter.mode",
+ InternalParameters.ReadSameParamMode,
+ aScope);
+ InternalParameters.ReadSurfaceCurveMode =
+ (ReadMode_SurfaceCurve)theResource->IntegerVal("read.surfacecurve.mode",
+ InternalParameters.ReadSurfaceCurveMode,
+ aScope);
+ InternalParameters.EncodeRegAngle =
+ theResource->RealVal("read.encoderegularity.angle", InternalParameters.EncodeRegAngle, aScope);
+
+ InternalParameters.ReadApproxd1 =
+ theResource->BooleanVal("read.bspline.approxd1.mode", InternalParameters.ReadApproxd1, aScope);
+ InternalParameters.ReadResourceName =
+ theResource->StringVal("read.resource.name", InternalParameters.ReadResourceName, aScope);
+ InternalParameters.ReadSequence =
+ theResource->StringVal("read.sequence", InternalParameters.ReadSequence, aScope);
+ InternalParameters.ReadFaultyEntities =
+ theResource->BooleanVal("read.fau_lty.entities", InternalParameters.ReadFaultyEntities, aScope);
+ InternalParameters.ReadOnlyVisible =
+ theResource->BooleanVal("read.onlyvisible", InternalParameters.ReadOnlyVisible, aScope);
+ InternalParameters.ReadColor =
+ theResource->BooleanVal("read.color", InternalParameters.ReadColor, aScope);
+ InternalParameters.ReadName =
+ theResource->BooleanVal("read.name", InternalParameters.ReadName, aScope);
+ InternalParameters.ReadLayer =
+ theResource->BooleanVal("read.layer", InternalParameters.ReadLayer, aScope);
+
+ InternalParameters.WriteBRepMode =
+ (WriteMode_BRep)theResource->IntegerVal("write.brep.mode",
+ InternalParameters.WriteBRepMode,
+ aScope);
+ InternalParameters.WriteConvertSurfaceMode =
+ (WriteMode_ConvertSurface)theResource->IntegerVal("write.convertsurface.mode",
+ InternalParameters.WriteConvertSurfaceMode,
+ aScope);
+ InternalParameters.WriteHeaderAuthor =
+ theResource->StringVal("write.header.author", InternalParameters.WriteHeaderAuthor, aScope);
+ InternalParameters.WriteHeaderCompany =
+ theResource->StringVal("write.header.company", InternalParameters.WriteHeaderCompany, aScope);
+ InternalParameters.WriteHeaderProduct =
+ theResource->StringVal("write.header.product", InternalParameters.WriteHeaderProduct, aScope);
+ InternalParameters.WriteHeaderReciever =
+ theResource->StringVal("write.header.receiver", InternalParameters.WriteHeaderReciever, aScope);
+ InternalParameters.WriteResourceName =
+ theResource->StringVal("write.resource.name", InternalParameters.WriteResourceName, aScope);
+ InternalParameters.WriteSequence =
+ theResource->StringVal("write.sequence", InternalParameters.WriteSequence, aScope);
+ InternalParameters.WritePrecisionMode =
+ (WriteMode_PrecisionMode)theResource->IntegerVal("write.precision.mode",
+ InternalParameters.WritePrecisionMode,
+ aScope);
+ InternalParameters.WritePrecisionVal =
+ theResource->RealVal("write.precision.val", InternalParameters.WritePrecisionVal, aScope);
+ InternalParameters.WritePlaneMode =
+ (WriteMode_PlaneMode)theResource->IntegerVal("write.plane.mode",
+ InternalParameters.WritePlaneMode,
+ aScope);
+ InternalParameters.WriteOffsetMode =
+ theResource->BooleanVal("write.offset", InternalParameters.WriteOffsetMode, aScope);
+ InternalParameters.WriteColor =
+ theResource->BooleanVal("write.color", InternalParameters.WriteColor, aScope);
+ InternalParameters.WriteName =
+ theResource->BooleanVal("write.name", InternalParameters.WriteName, aScope);
+ InternalParameters.WriteLayer =
+ theResource->BooleanVal("write.layer", InternalParameters.WriteLayer, aScope);
+
+ return true;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEIGES_ConfigurationNode::Save() const
+{
+ TCollection_AsciiString aResult;
+ aResult += "!*****************************************************************************\n";
+ aResult =
+ aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
+ TCollection_AsciiString aScope =
+ THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
+
+ aResult += "!\n";
+ aResult += "!Common parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Manages the continuity of BSpline curves (IGES entities 106, 112 and 126) ";
+ aResult += "after translation to Open CASCADE Technology\n";
+ aResult += "!Default value: 1. Available values: 0, 1, 2\n";
+ aResult +=
+ aScope + "read.iges.bspline.continuity :\t " + InternalParameters.ReadBSplineContinuity + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Reads the precision mode value\n";
+ aResult += "!Default value: \"File\"(0). Available values: \"File\"(0), \"User\"(1)\n";
+ aResult += aScope + "read.precision.mode :\t " + InternalParameters.ReadPrecisionMode + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!This parameter gives the precision for shape construction when the ";
+ aResult += "read.precision.mode parameter value is 1\n";
+ aResult += "!Default value: 0.0001. Available values: any real positive (non null) value\n";
+ aResult += aScope + "read.precision.val :\t " + InternalParameters.ReadPrecisionVal + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines the mode of applying the maximum allowed tolerance\n";
+ aResult +=
+ "!Default value: \"Preferred\"(0). Available values: \"Preferred\"(0), \"Forced\"(1)\n";
+ aResult +=
+ aScope + "read.maxprecision.mode :\t " + InternalParameters.ReadMaxPrecisionMode + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines the maximum allowable tolerance (in internal units, which are specified in "
+ "xstep.cascade.unit)";
+ aResult += " of the shape\n";
+ aResult += "!Default value: 1. Available values: any real positive (non null) value\n";
+ aResult += aScope + "read.maxprecision.val :\t " + InternalParameters.ReadMaxPrecisionVal + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines the using of BRepLib::SameParameter\n";
+ aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(0)\n";
+ aResult +=
+ aScope + "read.stdsameparameter.mode :\t " + InternalParameters.ReadSameParamMode + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult +=
+ "!Preference for the computation of curves in case of 2D/3D inconsistency in an entity ";
+ aResult += "which has both 2D and 3D representations.\n";
+ aResult +=
+ "!Default value: \"Default\"(0). Available values: \"Default\"(0), \"2DUse_Preferred\"(2), ";
+ aResult += "\"2DUse_Forced\"(-2), \"3DUse_Preferred\"(3), \"3DUse_Forced\"(-3)\n";
+ aResult +=
+ aScope + "read.surfacecurve.mode :\t " + InternalParameters.ReadSurfaceCurveMode + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!This parameter is used within the BRepLib::EncodeRegularity() function ";
+ aResult += "which is called for a shape read ";
+ aResult += "from an IGES or a STEP file at the end of translation process.This function sets the "
+ "regularity flag of";
+ aResult +=
+ " an edge in a shell when this edge is shared by two faces.This flag shows the continuity, ";
+ aResult += "which these two faces are connected with at that edge.\n";
+ aResult += "!Default value (in degrees): 0.57295779513. Available values: <double>\n";
+ aResult += aScope + "read.encoderegularity.angle :\t " + InternalParameters.EncodeRegAngle + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Read parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult +=
+ "!If set to True, it affects the translation of bspline curves of degree 1 from IGES: ";
+ aResult += "these curves(which geometrically are polylines) are split by duplicated points, and "
+ "the translator ";
+ aResult += "attempts to convert each of the obtained parts to a bspline of a higher continuity\n";
+ aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(1)\n";
+ aResult += aScope + "read.bspline.approxd1.mode :\t " + InternalParameters.ReadApproxd1 + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines the name of the resource file\n";
+ aResult += "!Default value: \"IGES\". Available values: <string>\n";
+ aResult += aScope + "read.resource.name :\t " + InternalParameters.ReadResourceName + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines the name of the sequence of operators\n";
+ aResult += "!Default value: \"FromIGES\". Available values: <string>\n";
+ aResult += aScope + "read.sequence :\t " + InternalParameters.ReadSequence + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Parameter for reading fa-iled entities\n";
+ aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(1)\n";
+ aResult += aScope + "read.fau_lty.entities :\t " + InternalParameters.ReadFaultyEntities + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Controls transferring invisible sub entities which logically depend on the grouping "
+ "entities\n";
+ aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(1)\n";
+ aResult += aScope + "read.onlyvisible :\t " + InternalParameters.ReadOnlyVisible + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Setting up the ColorMode parameter which is used to indicate read Colors or not\n";
+ aResult += "!Default value: 1. Available values: 0, 1\n";
+ aResult += aScope + "read.color :\t " + InternalParameters.ReadColor + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Setting up the NameMode parameter which is used to indicate read Names or not\n";
+ aResult += "!Default value: 1. Available values: 0, 1\n";
+ aResult += aScope + "read.name :\t " + InternalParameters.ReadName + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Setting up the LayerMode parameter which is used to indicate read Layers or not\n";
+ aResult += "!Default value: 1. Available values: 0, 1\n";
+ aResult += aScope + "read.layer :\t " + InternalParameters.ReadLayer + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Write parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag to define entities type to write\n";
+ aResult += "!Default value: \"Faces\"(0). Available values: \"Faces\"(0), \"BRep\"(1)\n";
+ aResult += aScope + "write.brep.mode :\t " + InternalParameters.WriteBRepMode + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult +=
+ "!When writing to IGES in the BRep mode, this parameter indicates whether elementary surfaces";
+ aResult += "(cylindrical, conical, spherical, and toroidal) are converted into corresponding "
+ "IGES 5.3 entities";
+ aResult +=
+ "(if the value of a parameter value is On), or written as surfaces of revolution(by default)\n";
+ aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(1)\n";
+ aResult +=
+ aScope + "write.convertsurface.mode :\t " + InternalParameters.WriteConvertSurfaceMode + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Gives the name of the author of the file\n";
+ aResult += "!Default value: {System name of the user}. Available values: <string>\n";
+ aResult += aScope + "write.header.author :\t " + InternalParameters.WriteHeaderAuthor + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Gives the name of the sending company\n";
+ aResult += "!Default value: "
+ "(empty). Available values: <string>\n";
+ aResult += aScope + "write.header.company :\t " + InternalParameters.WriteHeaderCompany + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Gives the name of the sending product\n";
+ aResult += "!Default value: \"CAS.CADE IGES processor Vx.x\"";
+ aResult += "(where x.x means the current version of Open CASCADE Technology)";
+ aResult += "Available values : <string>\n";
+ aResult += aScope + "write.header.product :\t " + InternalParameters.WriteHeaderProduct + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Gives the name of the receiving company\n";
+ aResult += "!Default value: "
+ "(empty). Available values: <string>\n";
+ aResult += aScope + "write.header.receiver :\t " + InternalParameters.WriteHeaderReciever + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines the name of the resource file\n";
+ aResult += "!Default value: \"IGES\". Available values: <string>\n";
+ aResult += aScope + "write.resource.name :\t " + InternalParameters.WriteResourceName + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines the name of the sequence of operators\n";
+ aResult += "!Default value: \"To\". Available values: <string>\n";
+ aResult += aScope + "write.sequence :\t " + InternalParameters.WriteSequence + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Specifies the mode of writing the resolution value into the IGES file\n";
+ aResult += "!Default value: Average(0). Available values: \"Least\"(-1), \"Average\"(0), ";
+ aResult += "\"Greatest\"(1), \"Session\"(2)\n";
+ aResult += aScope + "write.precision.mode :\t " + InternalParameters.WritePrecisionMode + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!This parameter gives the resolution value for an IGES file when the "
+ "write.precision.mode parameter value is 1\n";
+ aResult += "!Default value: 0.0001. Available values: any real positive (non null) value\n";
+ aResult += aScope + "write.precision.val :\t " + InternalParameters.WritePrecisionVal + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Writing planes mode\n";
+ aResult += "!Default value: \"Plane\"(0). Available values: \"Plane\"(0), \"BSpline\"(1)\n";
+ aResult += aScope + "write.plane.mode :\t " + InternalParameters.WritePlaneMode + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Writing offset curves like BSplines\n";
+ aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(1)\n";
+ aResult += aScope + "write.offset :\t " + InternalParameters.WriteOffsetMode + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Setting up the ColorMode parameter which is used to indicate write Colors or not\n";
+ aResult += "!Default value: 1. Available values: 0, 1\n";
+ aResult += aScope + "write.color :\t " + InternalParameters.WriteColor + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Setting up the NameMode parameter which is used to indicate write Names or not\n";
+ aResult += "!Default value: 1. Available values: 0, 1\n";
+ aResult += aScope + "write.name :\t " + InternalParameters.WriteName + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Setting up the LayerMode parameter which is used to indicate write Layers or not\n";
+ aResult += "!Default value: 1. Available values: 0, 1\n";
+ aResult += aScope + "write.layer :\t " + InternalParameters.WriteLayer + "\n";
+ aResult += "!\n";
+
+ aResult += "!*****************************************************************************\n";
+ return aResult;
+}
+
+//=================================================================================================
+
+Handle(DE_ConfigurationNode) DEIGES_ConfigurationNode::Copy() const
+{
+ return new DEIGES_ConfigurationNode(*this);
+}
+
+//=================================================================================================
+
+Handle(DE_Provider) DEIGES_ConfigurationNode::BuildProvider()
+{
+ return new DEIGES_Provider(this);
+}
+
+//=================================================================================================
+
+bool DEIGES_ConfigurationNode::IsImportSupported() const
+{
+ return true;
+}
+
+//=================================================================================================
+
+bool DEIGES_ConfigurationNode::IsExportSupported() const
+{
+ return true;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEIGES_ConfigurationNode::GetFormat() const
+{
+ return TCollection_AsciiString("IGES");
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEIGES_ConfigurationNode::GetVendor() const
+{
+ return TCollection_AsciiString("OCC");
+}
+
+//=================================================================================================
+
+TColStd_ListOfAsciiString DEIGES_ConfigurationNode::GetExtensions() const
+{
+ TColStd_ListOfAsciiString anExt;
+ anExt.Append("igs");
+ anExt.Append("iges");
+ return anExt;
+}
+
+//=================================================================================================
+
+bool DEIGES_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
+{
+ if (theBuffer.IsNull() || theBuffer->Size() < 83)
+ {
+ return false;
+ }
+ const char* aBytes = (const char*)theBuffer->Data();
+ if (aBytes[72] == 'S')
+ {
+ const char* aPtr = aBytes + 73;
+ while (aPtr < aBytes + 80 && (*aPtr == ' ' || *aPtr == '0'))
+ {
+ aPtr++;
+ }
+ if (*aPtr == '1' && !::isalnum((unsigned char)*++aPtr))
+ {
+ return true;
+ }
+ }
+ return false;
+}
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _DEIGES_ConfigurationNode_HeaderFile
+#define _DEIGES_ConfigurationNode_HeaderFile
+
+#include <DE_ConfigurationNode.hxx>
+#include <UnitsMethods_LengthUnit.hxx>
+
+//! The purpose of this class is to configure the transfer process for IGES format
+//! Stores the necessary settings for DEIGES_Provider.
+//! Configures and creates special provider to transfer IGES files.
+//!
+//! Nodes grouped by Vendor name and Format type.
+//! The Vendor name is "OCC"
+//! The Format type is "IGES"
+//! The supported CAD extensions are ".igs", ".iges"
+//! The import process is supported.
+//! The export process is supported.
+class DEIGES_ConfigurationNode : public DE_ConfigurationNode
+{
+ DEFINE_STANDARD_RTTIEXT(DEIGES_ConfigurationNode, DE_ConfigurationNode)
+public:
+ //! Initializes all fields by default
+ Standard_EXPORT DEIGES_ConfigurationNode();
+
+ //! Copies values of all fields
+ //! @param[in] theNode object to copy
+ Standard_EXPORT DEIGES_ConfigurationNode(const Handle(DEIGES_ConfigurationNode)& theNode);
+
+ //! Updates values according the resource
+ //! @param[in] theResource input resource to use
+ //! @return true if theResource loading has ended correctly
+ Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource)
+ Standard_OVERRIDE;
+
+ //! Writes configuration to the string
+ //! @return result resource string
+ Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
+
+ //! Copies values of all fields
+ //! @return new object with the same field values
+ Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
+
+ //! Creates new provider for the own format
+ //! @return new created provider
+ Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
+
+public:
+ //! Checks the import supporting
+ //! @return true if import is supported
+ Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
+
+ //! Checks the export supporting
+ //! @return true if export is supported
+ Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
+
+ //! Gets CAD format name of associated provider
+ //! @return provider CAD format
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
+
+ //! Gets provider's vendor name of associated provider
+ //! @return provider's vendor name
+ Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+
+ //! Gets list of supported file extensions
+ //! @return list of extensions
+ Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
+
+ //! Checks the file content to verify a format
+ //! @param[in] theBuffer read stream buffer to check content
+ //! @return Standard_True if file is supported by a current provider
+ Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
+ Standard_OVERRIDE;
+
+public:
+ enum ReadMode_BSplineContinuity
+ {
+ ReadMode_BSplineContinuity_C0 = 0,
+ ReadMode_BSplineContinuity_C1,
+ ReadMode_BSplineContinuity_C2
+ };
+
+ enum ReadMode_Precision
+ {
+ ReadMode_Precision_File = 0,
+ ReadMode_Precision_User
+ };
+
+ enum ReadMode_MaxPrecision
+ {
+ ReadMode_MaxPrecision_Preferred = 0,
+ ReadMode_MaxPrecision_Forced
+ };
+
+ enum ReadMode_SurfaceCurve
+ {
+ ReadMode_SurfaceCurve_Default = 0,
+ ReadMode_SurfaceCurve_2DUse_Preferred = 2,
+ ReadMode_SurfaceCurve_2DUse_Forced = -2,
+ ReadMode_SurfaceCurve_3DUse_Preferred = 3,
+ ReadMode_SurfaceCurve_3DUse_Forced = -3
+ };
+
+ enum WriteMode_BRep
+ {
+ WriteMode_BRep_Faces = 0,
+ WriteMode_BRep_BRep
+ };
+
+ enum WriteMode_ConvertSurface
+ {
+ WriteMode_ConvertSurface_Off = 0,
+ WriteMode_ConvertSurface_On
+ };
+
+ enum WriteMode_PrecisionMode
+ {
+ WriteMode_PrecisionMode_Least = -1,
+ WriteMode_PrecisionMode_Average = 0,
+ WriteMode_PrecisionMode_Greatest = 1,
+ WriteMode_PrecisionMode_Session = 2
+ };
+
+ enum WriteMode_PlaneMode
+ {
+ WriteMode_PlaneMode_Plane = 0,
+ WriteMode_PlaneMode_BSpline
+ };
+
+ struct IGESCAFControl_InternalSection
+ {
+ // Common
+ // clang-format off
+ ReadMode_BSplineContinuity ReadBSplineContinuity = ReadMode_BSplineContinuity_C1; //<! Manages the continuity of BSpline curves
+ ReadMode_Precision ReadPrecisionMode = ReadMode_Precision_File; //<! Reads the precision mode value
+ double ReadPrecisionVal = 0.0001; //<! ReadMode_Precision for shape construction (if enabled user mode)
+ ReadMode_MaxPrecision ReadMaxPrecisionMode = ReadMode_MaxPrecision_Preferred; //<! Defines the mode of applying the maximum allowed tolerance
+ double ReadMaxPrecisionVal = 1; //<! Defines the maximum allowable tolerance
+ bool ReadSameParamMode = false; //<! Defines the using of BRepLib::SameParameter
+ ReadMode_SurfaceCurve ReadSurfaceCurveMode = ReadMode_SurfaceCurve_Default; //<! reference for the computation of curves in case of 2D/3D
+ double EncodeRegAngle = 0.57295779513; //<! Continuity which these two faces are connected with at that edge
+
+ //Read
+ bool ReadApproxd1 = false; //<! Flag to split bspline curves of degree 1
+ TCollection_AsciiString ReadResourceName = "IGES"; //<! Defines the name of the resource file to read
+ TCollection_AsciiString ReadSequence = "FromIGES"; //<! Defines the name of the sequence of operators to read
+ bool ReadFaultyEntities = false; //<! Parameter for reading failed entities
+ bool ReadOnlyVisible = false; //<! Parameter for reading invisible entities
+ bool ReadColor = true; //<! ColorMode is used to indicate read Colors or not
+ bool ReadName = true; //<! NameMode is used to indicate read Name or not
+ bool ReadLayer = true; //<! LayerMode is used to indicate read Layers or not
+
+ // Write
+ WriteMode_BRep WriteBRepMode = WriteMode_BRep_Faces; //<! Flag to define entities type to write
+ WriteMode_ConvertSurface WriteConvertSurfaceMode = WriteMode_ConvertSurface_Off; //<! Flag to convert surface to elementary
+ TCollection_AsciiString WriteHeaderAuthor; //<! Name of the author of the file
+ TCollection_AsciiString WriteHeaderCompany; //<! Name of the sending company
+ TCollection_AsciiString WriteHeaderProduct; //<! Name of the sending product
+ TCollection_AsciiString WriteHeaderReciever; //<! Name of the receiving company
+ TCollection_AsciiString WriteResourceName = "IGES"; //<! Defines the name of the resource file to write
+ TCollection_AsciiString WriteSequence = "ToIGES"; //<! Defines the name of the sequence of operators to write
+ WriteMode_PrecisionMode WritePrecisionMode = WriteMode_PrecisionMode_Average; //<! Specifies the mode of writing the resolution value into the IGES file
+ double WritePrecisionVal = 0.0001; //<! Resolution value for an IGES file when WriteMode_PrecisionMode is Greatest
+ WriteMode_PlaneMode WritePlaneMode = WriteMode_PlaneMode_Plane; //<! Flag to convert plane to the BSline
+ // clang-format on
+ bool WriteOffsetMode = false; //<! Writing offset curves like BSplines
+ bool WriteColor = true; //<! ColorMode is used to indicate write Colors or not
+ bool WriteName = true; //<! NameMode is used to indicate write Name or not
+ bool WriteLayer = true; //<! LayerMode is used to indicate write Layers or not
+ } InternalParameters;
+};
+
+#endif // _DEIGES_ConfigurationNode_HeaderFile
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <DEIGES_Provider.hxx>
+
+#include <DEIGES_ConfigurationNode.hxx>
+#include <IGESCAFControl_Reader.hxx>
+#include <IGESCAFControl_Writer.hxx>
+#include <IGESControl_Controller.hxx>
+#include <IGESData.hxx>
+#include <IGESData_IGESModel.hxx>
+#include <Interface_Static.hxx>
+#include <Message.hxx>
+#include <UnitsMethods.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <XSControl_WorkSession.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(DEIGES_Provider, DE_Provider)
+
+//=================================================================================================
+
+DEIGES_Provider::DEIGES_Provider() {}
+
+//=================================================================================================
+
+DEIGES_Provider::DEIGES_Provider(const Handle(DE_ConfigurationNode)& theNode)
+ : DE_Provider(theNode)
+{
+}
+
+//=================================================================================================
+
+void DEIGES_Provider::personizeWS(Handle(XSControl_WorkSession)& theWS)
+{
+ if (theWS.IsNull())
+ {
+ Message::SendWarning() << "Warning: DEIGES_Provider :"
+ << " Null work session, use internal temporary session";
+ theWS = new XSControl_WorkSession();
+ }
+ Handle(IGESControl_Controller) aCntrl =
+ Handle(IGESControl_Controller)::DownCast(theWS->NormAdaptor());
+ if (aCntrl.IsNull())
+ {
+ IGESControl_Controller::Init();
+ theWS->SelectNorm("IGES");
+ }
+}
+
+//=================================================================================================
+
+void DEIGES_Provider::initStatic(const Handle(DE_ConfigurationNode)& theNode)
+{
+ Handle(DEIGES_ConfigurationNode) aNode = Handle(DEIGES_ConfigurationNode)::DownCast(theNode);
+ IGESData::Init();
+
+ // Get previous values
+ myOldValues.ReadBSplineContinuity =
+ (DEIGES_ConfigurationNode::ReadMode_BSplineContinuity)Interface_Static::IVal(
+ "read.iges.bspline.continuity");
+ myOldValues.ReadPrecisionMode =
+ (DEIGES_ConfigurationNode::ReadMode_Precision)Interface_Static::IVal("read.precision.mode");
+ myOldValues.ReadPrecisionVal = Interface_Static::RVal("read.precision.val");
+ myOldValues.ReadMaxPrecisionMode =
+ (DEIGES_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 =
+ (DEIGES_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 =
+ (DEIGES_ConfigurationNode::WriteMode_BRep)Interface_Static::IVal("write.iges.brep.mode");
+ myOldValues.WriteConvertSurfaceMode =
+ (DEIGES_ConfigurationNode::WriteMode_ConvertSurface)Interface_Static::IVal(
+ "write.convertsurface.mode");
+ 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 =
+ (DEIGES_ConfigurationNode::WriteMode_PrecisionMode)Interface_Static::IVal(
+ "write.precision.mode");
+ myOldValues.WritePrecisionVal = Interface_Static::RVal("write.precision.val");
+ myOldValues.WritePlaneMode =
+ (DEIGES_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");
+
+ // Set new values
+ 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 DEIGES_Provider::setStatic(
+ const DEIGES_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::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 DEIGES_Provider::resetStatic()
+{
+ Interface_Static::SetIVal("xstep.cascade.unit", myOldLengthUnit);
+ UnitsMethods::SetCasCadeLengthUnit(myOldLengthUnit);
+ setStatic(myOldValues);
+}
+
+//=================================================================================================
+
+bool DEIGES_Provider::Read(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ if (theDocument.IsNull())
+ {
+ Message::SendFail() << "Error in the DEIGES_Provider during reading the file " << thePath
+ << "\t: theDocument shouldn't be null";
+ return false;
+ }
+ if (!GetNode()->IsKind(STANDARD_TYPE(DEIGES_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DEIGES_Provider during reading the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DEIGES_ConfigurationNode) aNode = Handle(DEIGES_ConfigurationNode)::DownCast(GetNode());
+ personizeWS(theWS);
+ initStatic(aNode);
+ XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
+ aNode->GlobalParameters.LengthUnit,
+ UnitsMethods_LengthUnit_Millimeter);
+ IGESCAFControl_Reader aReader;
+ aReader.SetWS(theWS);
+
+ 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 (aReadStat != IFSelect_RetDone)
+ {
+ Message::SendFail() << "Error in the DEIGES_Provider during reading the file " << thePath
+ << "\t: abandon, no model loaded";
+ resetStatic();
+ return false;
+ }
+
+ if (!aReader.Transfer(theDocument, theProgress))
+ {
+ Message::SendFail() << "Error in the DEIGES_Provider during reading the file " << thePath
+ << "\t: Cannot read any relevant data from the IGES file";
+ resetStatic();
+ return false;
+ }
+ resetStatic();
+ return true;
+}
+
+//=================================================================================================
+
+bool DEIGES_Provider::Write(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ if (!GetNode()->IsKind(STANDARD_TYPE(DEIGES_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DEIGES_Provider during reading the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DEIGES_ConfigurationNode) aNode = Handle(DEIGES_ConfigurationNode)::DownCast(GetNode());
+ personizeWS(theWS);
+ initStatic(aNode);
+ Standard_Integer aFlag = IGESData_BasicEditor::GetFlagByValue(aNode->GlobalParameters.LengthUnit);
+ IGESCAFControl_Writer aWriter(theWS,
+ (aFlag > 0) ? IGESData_BasicEditor::UnitFlagName(aFlag) : "MM");
+ IGESData_GlobalSection aGS = aWriter.Model()->GlobalSection();
+ Standard_Real aScaleFactorMM = 1.;
+ Standard_Boolean aHasUnits =
+ XCAFDoc_DocumentTool::GetLengthUnit(theDocument,
+ aScaleFactorMM,
+ UnitsMethods_LengthUnit_Millimeter);
+ if (aHasUnits)
+ {
+ aGS.SetCascadeUnit(aScaleFactorMM);
+ }
+ else
+ {
+ aGS.SetCascadeUnit(aNode->GlobalParameters.SystemUnit);
+ Message::SendWarning()
+ << "Warning in the DEIGES_Provider during writing the file " << thePath
+ << "\t: The document has no information on Units. Using global parameter as initial Unit.";
+ }
+ if (aFlag == 0)
+ {
+ aGS.SetScale(aNode->GlobalParameters.LengthUnit);
+ }
+ aWriter.Model()->SetGlobalSection(aGS);
+ 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 DEIGES_Provider during reading the file " << thePath
+ << "\t: The document cannot be translated or gives no result";
+ resetStatic();
+ return false;
+ }
+ if (!aWriter.Write(thePath.ToCString()))
+ {
+ Message::SendFail() << "Error in the DEIGES_Provider during reading the file " << thePath
+ << "\t: Write failed";
+ resetStatic();
+ return false;
+ }
+ resetStatic();
+ return true;
+}
+
+//=================================================================================================
+
+bool DEIGES_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);
+}
+
+//=================================================================================================
+
+bool DEIGES_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);
+}
+
+//=================================================================================================
+
+bool DEIGES_Provider::Read(const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ (void)theProgress;
+ if (!GetNode()->IsKind(STANDARD_TYPE(DEIGES_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DEIGES_Provider during reading the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DEIGES_ConfigurationNode) aNode = Handle(DEIGES_ConfigurationNode)::DownCast(GetNode());
+ initStatic(aNode);
+ personizeWS(theWS);
+ IGESControl_Reader aReader;
+ aReader.SetWS(theWS);
+ aReader.SetReadVisible(aNode->InternalParameters.ReadOnlyVisible);
+ IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
+ aReadStat = aReader.ReadFile(thePath.ToCString());
+ if (aReadStat != IFSelect_RetDone)
+ {
+ Message::SendFail() << "Error in the DEIGES_Provider during reading the file " << thePath
+ << "\t: Could not read file, no model loaded";
+ resetStatic();
+ return false;
+ }
+ if (aReader.TransferRoots() <= 0)
+ {
+ Message::SendFail() << "Error in the DEIGES_Provider during reading the file " << thePath
+ << "\t: Cannot read any relevant data from the IGES file";
+ resetStatic();
+ return false;
+ }
+ theShape = aReader.OneShape();
+ resetStatic();
+ return true;
+}
+
+//=================================================================================================
+
+bool DEIGES_Provider::Write(const TCollection_AsciiString& thePath,
+ const TopoDS_Shape& theShape,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ (void)theWS;
+ (void)theProgress;
+ if (!GetNode()->IsKind(STANDARD_TYPE(DEIGES_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DEIGES_Provider during reading the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DEIGES_ConfigurationNode) aNode = Handle(DEIGES_ConfigurationNode)::DownCast(GetNode());
+ initStatic(aNode);
+ Standard_Integer aFlag = IGESData_BasicEditor::GetFlagByValue(aNode->GlobalParameters.LengthUnit);
+ IGESControl_Writer aWriter((aFlag > 0) ? IGESData_BasicEditor::UnitFlagName(aFlag) : "MM",
+ aNode->InternalParameters.WriteBRepMode);
+ IGESData_GlobalSection aGS = aWriter.Model()->GlobalSection();
+ aGS.SetCascadeUnit(aNode->GlobalParameters.SystemUnit);
+ if (!aFlag)
+ {
+ aGS.SetScale(aNode->GlobalParameters.LengthUnit);
+ }
+ aWriter.Model()->SetGlobalSection(aGS);
+ Standard_Boolean aIsOk = aWriter.AddShape(theShape);
+ if (!aIsOk)
+ {
+ Message::SendFail() << "DEIGES_Provider: Shape not written";
+ resetStatic();
+ return false;
+ }
+
+ if (!(aWriter.Write(thePath.ToCString())))
+ {
+ Message::SendFail() << "DEIGES_Provider: Error on writing file " << thePath;
+ resetStatic();
+ return false;
+ }
+ resetStatic();
+ return true;
+}
+
+//=================================================================================================
+
+bool DEIGES_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);
+}
+
+//=================================================================================================
+
+bool DEIGES_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);
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEIGES_Provider::GetFormat() const
+{
+ return TCollection_AsciiString("IGES");
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEIGES_Provider::GetVendor() const
+{
+ return TCollection_AsciiString("OCC");
+}
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _DEIGES_Provider_HeaderFile
+#define _DEIGES_Provider_HeaderFile
+
+#include <DEIGES_ConfigurationNode.hxx>
+#include <DE_Provider.hxx>
+
+//! The class to transfer IGES files.
+//! Reads and Writes any IGES files into/from OCCT.
+//! Each operation needs configuration node.
+//!
+//! Providers grouped by Vendor name and Format type.
+//! The Vendor name is "OCC"
+//! The Format type is "IGES"
+//! The import process is supported.
+//! The export process is supported.
+class DEIGES_Provider : public DE_Provider
+{
+public:
+ DEFINE_STANDARD_RTTIEXT(DEIGES_Provider, DE_Provider)
+
+public:
+ //! Default constructor
+ //! Configure translation process with global configuration
+ Standard_EXPORT DEIGES_Provider();
+
+ //! Configure translation process
+ //! @param[in] theNode object to copy
+ Standard_EXPORT DEIGES_Provider(const Handle(DE_ConfigurationNode)& theNode);
+
+public:
+ //! Reads a CAD file, according internal configuration
+ //! @param[in] thePath path to the import CAD file
+ //! @param[out] theDocument document to save result
+ //! @param[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Read operation has ended correctly
+ Standard_EXPORT virtual bool Read(
+ const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ 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[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Write operation has ended correctly
+ Standard_EXPORT virtual bool Write(
+ const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ 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[in] theProgress 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[in] theProgress 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
+ //! @param[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Read operation has ended correctly
+ Standard_EXPORT virtual bool Read(
+ const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ 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[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Write operation has ended correctly
+ Standard_EXPORT virtual bool Write(
+ const TCollection_AsciiString& thePath,
+ const TopoDS_Shape& theShape,
+ 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[in] theProgress 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[in] theProgress 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 CAD format
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
+
+ //! Gets provider's vendor name of associated provider
+ //! @return provider's vendor name
+ Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+
+private:
+ //! Personizes work session with current format.
+ //! Creates new temporary session if current session is null
+ //! @param[in] theWS current work session
+ void personizeWS(Handle(XSControl_WorkSession)& theWS);
+
+ //! Initialize static variables
+ void initStatic(const Handle(DE_ConfigurationNode)& theNode);
+
+ //! Initialize static variables
+ void setStatic(const DEIGES_ConfigurationNode::IGESCAFControl_InternalSection& theParameter);
+
+ //! Reset used interface static variables
+ void resetStatic();
+
+ DEIGES_ConfigurationNode::IGESCAFControl_InternalSection myOldValues;
+ int myOldLengthUnit = 1;
+};
+
+#endif // _DEIGES_Provider_HeaderFile
--- /dev/null
+DEIGES_ConfigurationNode.cxx
+DEIGES_ConfigurationNode.hxx
+DEIGES_Provider.cxx
+DEIGES_Provider.hxx
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <DEOBJ_ConfigurationNode.hxx>
+
+#include <DEOBJ_Provider.hxx>
+#include <DE_ConfigurationContext.hxx>
+#include <DE_PluginHolder.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(DEOBJ_ConfigurationNode, DE_ConfigurationNode)
+
+namespace
+{
+static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
+{
+ static const TCollection_AsciiString aScope = "provider";
+ return aScope;
+}
+
+// Wrapper to auto-load DE component
+DE_PluginHolder<DEOBJ_ConfigurationNode> THE_OCCT_OBJ_COMPONENT_PLUGIN;
+} // namespace
+
+//=================================================================================================
+
+DEOBJ_ConfigurationNode::DEOBJ_ConfigurationNode()
+ : DE_ConfigurationNode()
+{
+}
+
+//=================================================================================================
+
+DEOBJ_ConfigurationNode::DEOBJ_ConfigurationNode(const Handle(DEOBJ_ConfigurationNode)& theNode)
+ : DE_ConfigurationNode(theNode)
+{
+ InternalParameters = theNode->InternalParameters;
+}
+
+//=================================================================================================
+
+bool DEOBJ_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
+{
+ TCollection_AsciiString aScope =
+ THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
+ InternalParameters.FileLengthUnit =
+ theResource->RealVal("file.length.unit", InternalParameters.FileLengthUnit, aScope);
+ InternalParameters.SystemCS =
+ (RWMesh_CoordinateSystem)(theResource->IntegerVal("system.cs",
+ (int)InternalParameters.SystemCS,
+ aScope)
+ % 2);
+ InternalParameters.FileCS =
+ (RWMesh_CoordinateSystem)(theResource->IntegerVal("file.cs",
+ (int)InternalParameters.SystemCS,
+ aScope)
+ % 2);
+
+ InternalParameters.ReadSinglePrecision =
+ theResource->BooleanVal("read.single.precision",
+ InternalParameters.ReadSinglePrecision,
+ aScope);
+ InternalParameters.ReadCreateShapes =
+ theResource->BooleanVal("read.create.shapes", InternalParameters.ReadCreateShapes, aScope);
+ InternalParameters.ReadRootPrefix =
+ theResource->StringVal("read.root.prefix", InternalParameters.ReadRootPrefix, aScope);
+ InternalParameters.ReadFillDoc =
+ theResource->BooleanVal("read.fill.doc", InternalParameters.ReadFillDoc, aScope);
+ InternalParameters.ReadFillIncomplete =
+ theResource->BooleanVal("read.fill.incomplete", InternalParameters.ReadFillIncomplete, aScope);
+ InternalParameters.ReadMemoryLimitMiB =
+ theResource->IntegerVal("read.memory.limit.mib", InternalParameters.ReadMemoryLimitMiB, aScope);
+
+ InternalParameters.WriteComment =
+ theResource->StringVal("write.comment", InternalParameters.WriteComment, aScope);
+ InternalParameters.WriteAuthor =
+ theResource->StringVal("write.author", InternalParameters.WriteAuthor, aScope);
+ return true;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEOBJ_ConfigurationNode::Save() const
+{
+ TCollection_AsciiString aResult;
+ aResult += "!*****************************************************************************\n";
+ aResult =
+ aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
+ TCollection_AsciiString aScope =
+ THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
+
+ aResult += "!\n";
+ aResult += "!Common parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!File length units to convert from while reading the file, defined as scale factor "
+ "for m (meters)\n";
+ aResult += "!Default value: 1.0(M)\n";
+ aResult += aScope + "file.length.unit :\t " + InternalParameters.FileLengthUnit + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!System origin coordinate system to perform conversion into during read\n";
+ aResult += "!Default value: 0(Zup). Available values: 0(Zup), 1(Yup)\n";
+ aResult += aScope + "system.cs :\t " + InternalParameters.SystemCS + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!File origin coordinate system to perform conversion during read\n";
+ aResult += "!Default value: 1(Yup). Available values: 0(Zup), 1(Yup)\n";
+ aResult += aScope + "file.cs :\t " + InternalParameters.FileCS + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Read parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag for reading vertex data with single or double floating point precision\n";
+ aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "read.single.precision :\t " + InternalParameters.ReadSinglePrecision + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag for create a single triangulation\n";
+ aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "read.create.shapes :\t " + InternalParameters.ReadCreateShapes + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Root folder for generating root labels names\n";
+ aResult += "!Default value: "
+ "(empty). Available values: <path>\n";
+ aResult += aScope + "read.root.prefix :\t " + InternalParameters.ReadRootPrefix + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag for fill document from shape sequence\n";
+ aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "read.fill.doc :\t " + InternalParameters.ReadFillDoc + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag for fill the document with partially retrieved data even if reader has fa-iled "
+ "with er-ror\n";
+ aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "read.fill.incomplete :\t " + InternalParameters.ReadFillIncomplete + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Memory usage limit(MiB)\n";
+ aResult += "!Default value: -1(no limit). Available values: -1(no limit), any positive value\n";
+ aResult += aScope + "read.memory.limit.mib :\t " + InternalParameters.ReadMemoryLimitMiB + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Write parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Export special comment\n";
+ aResult += "!Default value: "
+ "(empty). Available values: <string>\n";
+ aResult += aScope + "write.comment :\t " + InternalParameters.WriteComment + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Author of exported file name\n";
+ aResult += "!Default value: "
+ "(empty). Available values: <string>\n";
+ aResult += aScope + "write.author :\t " + InternalParameters.WriteAuthor + "\n";
+ aResult += "!\n";
+
+ aResult += "!*****************************************************************************\n";
+ return aResult;
+}
+
+//=================================================================================================
+
+Handle(DE_ConfigurationNode) DEOBJ_ConfigurationNode::Copy() const
+{
+ return new DEOBJ_ConfigurationNode(*this);
+}
+
+//=================================================================================================
+
+Handle(DE_Provider) DEOBJ_ConfigurationNode::BuildProvider()
+{
+ return new DEOBJ_Provider(this);
+}
+
+//=================================================================================================
+
+bool DEOBJ_ConfigurationNode::IsImportSupported() const
+{
+ return true;
+}
+
+//=================================================================================================
+
+bool DEOBJ_ConfigurationNode::IsExportSupported() const
+{
+ return true;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEOBJ_ConfigurationNode::GetFormat() const
+{
+ return TCollection_AsciiString("OBJ");
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEOBJ_ConfigurationNode::GetVendor() const
+{
+ return TCollection_AsciiString("OCC");
+}
+
+//=================================================================================================
+
+TColStd_ListOfAsciiString DEOBJ_ConfigurationNode::GetExtensions() const
+{
+ TColStd_ListOfAsciiString anExt;
+ anExt.Append("obj");
+ return anExt;
+}
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _DEOBJ_ConfigurationNode_HeaderFile
+#define _DEOBJ_ConfigurationNode_HeaderFile
+
+#include <DE_ConfigurationNode.hxx>
+#include <RWMesh_CoordinateSystem.hxx>
+
+//! The purpose of this class is to configure the transfer process for OBJ format
+//! Stores the necessary settings for DEOBJ_Provider.
+//! Configures and creates special provider to transfer OBJ files.
+//!
+//! Nodes grouped by Vendor name and Format type.
+//! The Vendor name is "OCC"
+//! The Format type is "OBJ"
+//! The supported CAD extension is ".obj"
+//! The import process is supported.
+//! The export process is supported.
+class DEOBJ_ConfigurationNode : public DE_ConfigurationNode
+{
+ DEFINE_STANDARD_RTTIEXT(DEOBJ_ConfigurationNode, DE_ConfigurationNode)
+public:
+ //! Initializes all field by default
+ Standard_EXPORT DEOBJ_ConfigurationNode();
+
+ //! Copies values of all fields
+ //! @param[in] theNode object to copy
+ Standard_EXPORT DEOBJ_ConfigurationNode(const Handle(DEOBJ_ConfigurationNode)& theNode);
+
+ //! Updates values according the resource
+ //! @param[in] theResource input resource to use
+ //! @return true if theResource loading has ended correctly
+ Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource)
+ Standard_OVERRIDE;
+
+ //! Writes configuration to the string
+ //! @return result resource string
+ Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
+
+ //! Copies values of all fields
+ //! @return new object with the same field values
+ Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
+
+ //! Creates new provider for the own format
+ //! @return new created provider
+ Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
+
+public:
+ //! Checks the import supporting
+ //! @return true if import is supported
+ Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
+
+ //! Checks the export supporting
+ //! @return true if export is supported
+ Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
+
+ //! Gets CAD format name of associated provider
+ //! @return provider CAD format
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
+
+ //! Gets provider's vendor name of associated provider
+ //! @return provider's vendor name
+ Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+
+ //! Gets list of supported file extensions
+ //! @return list of extensions
+ Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
+
+public:
+ struct RWObj_InternalSection
+ {
+ // Common
+ // clang-format off
+ double FileLengthUnit = 1.; //!< File length units to convert from while reading the file, defined as scale factor for m (meters)
+ RWMesh_CoordinateSystem SystemCS = RWMesh_CoordinateSystem_Zup; //!< System origin coordinate system to perform conversion into during read
+ RWMesh_CoordinateSystem FileCS = RWMesh_CoordinateSystem_Yup; //!< File origin coordinate system to perform conversion during read
+ // Reading
+ bool ReadSinglePrecision = false; //!< Flag for reading vertex data with single or double floating point precision
+ bool ReadCreateShapes = false; //!< Flag for create a single triangulation
+ TCollection_AsciiString ReadRootPrefix; //!< Root folder for generating root labels names
+ bool ReadFillDoc = true; //!< Flag for fill document from shape sequence
+ bool ReadFillIncomplete = true; //!< Flag for fill the document with partially retrieved data even if reader has failed with error
+ // clang-format on
+ int ReadMemoryLimitMiB = -1; //!< Memory usage limit
+ // Writing
+ TCollection_AsciiString WriteComment; //!< Export special comment
+ TCollection_AsciiString WriteAuthor; //!< Author of exported file name
+ } InternalParameters;
+};
+
+#endif // _DEOBJ_ConfigurationNode_HeaderFile
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <DEOBJ_Provider.hxx>
+
+#include <BRep_Builder.hxx>
+#include <DEOBJ_ConfigurationNode.hxx>
+#include <RWObj_CafReader.hxx>
+#include <RWObj_CafWriter.hxx>
+#include <TDocStd_Document.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <XCAFDoc_ShapeTool.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(DEOBJ_Provider, DE_Provider)
+
+//=================================================================================================
+
+DEOBJ_Provider::DEOBJ_Provider() {}
+
+//=================================================================================================
+
+DEOBJ_Provider::DEOBJ_Provider(const Handle(DE_ConfigurationNode)& theNode)
+ : DE_Provider(theNode)
+{
+}
+
+//=================================================================================================
+
+bool DEOBJ_Provider::Read(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ (void)theWS;
+ return Read(thePath, theDocument, theProgress);
+}
+
+//=================================================================================================
+
+bool DEOBJ_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);
+}
+
+//=================================================================================================
+
+bool DEOBJ_Provider::Read(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ const Message_ProgressRange& theProgress)
+{
+ if (theDocument.IsNull())
+ {
+ Message::SendFail() << "Error in the DEOBJ_Provider during reading the file " << thePath
+ << "\t: theDocument shouldn't be null";
+ return false;
+ }
+ if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEOBJ_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DEOBJ_ConfigurationNode during reading the file "
+ << thePath << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DEOBJ_ConfigurationNode) aNode = Handle(DEOBJ_ConfigurationNode)::DownCast(GetNode());
+ RWObj_CafReader aReader;
+ aReader.SetSinglePrecision(aNode->InternalParameters.ReadSinglePrecision);
+ aReader.SetSystemLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
+ aReader.SetSystemCoordinateSystem(aNode->InternalParameters.SystemCS);
+ aReader.SetFileLengthUnit(aNode->InternalParameters.FileLengthUnit);
+ aReader.SetFileCoordinateSystem(aNode->InternalParameters.FileCS);
+ aReader.SetDocument(theDocument);
+ aReader.SetRootPrefix(aNode->InternalParameters.ReadRootPrefix);
+ aReader.SetMemoryLimitMiB(aNode->InternalParameters.ReadMemoryLimitMiB);
+ if (!aReader.Perform(thePath, theProgress))
+ {
+ Message::SendFail() << "Error in the DEOBJ_ConfigurationNode during reading the file "
+ << thePath;
+ return false;
+ }
+ XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
+ aNode->GlobalParameters.LengthUnit,
+ UnitsMethods_LengthUnit_Millimeter);
+ return true;
+}
+
+//=================================================================================================
+
+bool DEOBJ_Provider::Write(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ const Message_ProgressRange& theProgress)
+{
+ if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEOBJ_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DEOBJ_ConfigurationNode during writing the file "
+ << thePath << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DEOBJ_ConfigurationNode) aNode = Handle(DEOBJ_ConfigurationNode)::DownCast(GetNode());
+
+ TColStd_IndexedDataMapOfStringString aFileInfo;
+ if (!aNode->InternalParameters.WriteAuthor.IsEmpty())
+ {
+ aFileInfo.Add("Author", aNode->InternalParameters.WriteAuthor);
+ }
+ if (!aNode->InternalParameters.WriteComment.IsEmpty())
+ {
+ aFileInfo.Add("Comments", aNode->InternalParameters.WriteComment);
+ }
+
+ RWMesh_CoordinateSystemConverter aConverter;
+ Standard_Real aScaleFactorMM = 1.;
+ if (XCAFDoc_DocumentTool::GetLengthUnit(theDocument,
+ aScaleFactorMM,
+ UnitsMethods_LengthUnit_Millimeter))
+ {
+ aConverter.SetInputLengthUnit(aScaleFactorMM / 1000.);
+ }
+ else
+ {
+ aConverter.SetInputLengthUnit(aNode->GlobalParameters.SystemUnit / 1000.);
+ Message::SendWarning()
+ << "Warning in the DEOBJ_Provider during writing the file " << thePath
+ << "\t: The document has no information on Units. Using global parameter as initial Unit.";
+ }
+ aConverter.SetInputCoordinateSystem(aNode->InternalParameters.SystemCS);
+ aConverter.SetOutputLengthUnit(aNode->GlobalParameters.LengthUnit / 1000.);
+ aConverter.SetOutputCoordinateSystem(aNode->InternalParameters.FileCS);
+
+ RWObj_CafWriter aWriter(thePath);
+ aWriter.SetCoordinateSystemConverter(aConverter);
+ if (!aWriter.Perform(theDocument, aFileInfo, theProgress))
+ {
+ Message::SendFail() << "Error in the DEOBJ_ConfigurationNode during writing the file "
+ << thePath;
+ return false;
+ }
+ return true;
+}
+
+//=================================================================================================
+
+bool DEOBJ_Provider::Read(const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ (void)theWS;
+ return Read(thePath, theShape, theProgress);
+}
+
+//=================================================================================================
+
+bool DEOBJ_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);
+}
+
+//=================================================================================================
+
+bool DEOBJ_Provider::Read(const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ const Message_ProgressRange& theProgress)
+{
+ if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEOBJ_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DEOBJ_ConfigurationNode during writing the file "
+ << thePath << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DEOBJ_ConfigurationNode) aNode = Handle(DEOBJ_ConfigurationNode)::DownCast(GetNode());
+ RWMesh_CoordinateSystemConverter aConverter;
+ aConverter.SetOutputLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
+ aConverter.SetOutputCoordinateSystem(aNode->InternalParameters.SystemCS);
+ aConverter.SetInputLengthUnit(aNode->InternalParameters.FileLengthUnit);
+ aConverter.SetInputCoordinateSystem(aNode->InternalParameters.FileCS);
+
+ RWObj_TriangulationReader aSimpleReader;
+ aSimpleReader.SetTransformation(aConverter);
+ aSimpleReader.SetSinglePrecision(aNode->InternalParameters.ReadSinglePrecision);
+ aSimpleReader.SetCreateShapes(aNode->InternalParameters.ReadCreateShapes);
+ aSimpleReader.SetSinglePrecision(aNode->InternalParameters.ReadSinglePrecision);
+ aSimpleReader.SetMemoryLimit(aNode->InternalParameters.ReadMemoryLimitMiB);
+ if (!aSimpleReader.Read(thePath, theProgress))
+ {
+ Message::SendFail() << "Error in the DEOBJ_ConfigurationNode during reading the file "
+ << thePath;
+ return false;
+ }
+ Handle(Poly_Triangulation) aTriangulation = aSimpleReader.GetTriangulation();
+ TopoDS_Face aFace;
+ BRep_Builder aBuiler;
+ aBuiler.MakeFace(aFace);
+ aBuiler.UpdateFace(aFace, aTriangulation);
+ theShape = aFace;
+ return true;
+}
+
+//=================================================================================================
+
+bool DEOBJ_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);
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEOBJ_Provider::GetFormat() const
+{
+ return TCollection_AsciiString("OBJ");
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEOBJ_Provider::GetVendor() const
+{
+ return TCollection_AsciiString("OCC");
+}
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _DEOBJ_Provider_HeaderFile
+#define _DEOBJ_Provider_HeaderFile
+
+#include <DE_Provider.hxx>
+
+//! The class to transfer OBJ files.
+//! Reads and Writes any OBJ files into/from OCCT.
+//! Each operation needs configuration node.
+//!
+//! Providers grouped by Vendor name and Format type.
+//! The Vendor name is "OCC"
+//! The Format type is "OBJ"
+//! The import process is supported.
+//! The export process is supported.
+class DEOBJ_Provider : public DE_Provider
+{
+public:
+ DEFINE_STANDARD_RTTIEXT(DEOBJ_Provider, DE_Provider)
+
+public:
+ //! Default constructor
+ //! Configure translation process with global configuration
+ Standard_EXPORT DEOBJ_Provider();
+
+ //! Configure translation process
+ //! @param[in] theNode object to copy
+ Standard_EXPORT DEOBJ_Provider(const Handle(DE_ConfigurationNode)& theNode);
+
+public:
+ //! Reads a CAD file, according internal configuration
+ //! @param[in] thePath path to the import CAD file
+ //! @param[out] theDocument document to save result
+ //! @param[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Read operation has ended correctly
+ Standard_EXPORT virtual bool Read(
+ const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ 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[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Write operation has ended correctly
+ Standard_EXPORT virtual bool Write(
+ const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ 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[in] theProgress 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[in] theProgress 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
+ //! @param[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Read operation has ended correctly
+ Standard_EXPORT virtual bool Read(
+ const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ 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[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Write operation has ended correctly
+ Standard_EXPORT virtual bool Write(
+ const TCollection_AsciiString& thePath,
+ const TopoDS_Shape& theShape,
+ 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[in] theProgress 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[in] theProgress 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 CAD format
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
+
+ //! Gets provider's vendor name of associated provider
+ //! @return provider's vendor name
+ Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+};
+
+#endif // _DEOBJ_Provider_HeaderFile
--- /dev/null
+DEOBJ_ConfigurationNode.cxx
+DEOBJ_ConfigurationNode.hxx
+DEOBJ_Provider.cxx
+DEOBJ_Provider.hxx
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <DEPLY_ConfigurationNode.hxx>
+
+#include <DEPLY_Provider.hxx>
+#include <DE_ConfigurationContext.hxx>
+#include <DE_PluginHolder.hxx>
+#include <NCollection_Buffer.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(DEPLY_ConfigurationNode, DE_ConfigurationNode)
+
+namespace
+{
+static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
+{
+ static const TCollection_AsciiString aScope = "provider";
+ return aScope;
+}
+
+// Wrapper to auto-load DE component
+DE_PluginHolder<DEPLY_ConfigurationNode> THE_OCCT_PLY_COMPONENT_PLUGIN;
+} // namespace
+
+//=================================================================================================
+
+DEPLY_ConfigurationNode::DEPLY_ConfigurationNode()
+ : DE_ConfigurationNode()
+{
+}
+
+//=================================================================================================
+
+DEPLY_ConfigurationNode::DEPLY_ConfigurationNode(const Handle(DEPLY_ConfigurationNode)& theNode)
+ : DE_ConfigurationNode(theNode)
+{
+ InternalParameters = theNode->InternalParameters;
+}
+
+//=================================================================================================
+
+bool DEPLY_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
+{
+ TCollection_AsciiString aScope =
+ THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
+ InternalParameters.FileLengthUnit =
+ theResource->RealVal("file.length.unit", InternalParameters.FileLengthUnit, aScope);
+ InternalParameters.SystemCS =
+ (RWMesh_CoordinateSystem)(theResource->IntegerVal("system.cs",
+ (int)InternalParameters.SystemCS,
+ aScope)
+ % 2);
+ InternalParameters.FileCS =
+ (RWMesh_CoordinateSystem)(theResource->IntegerVal("file.cs",
+ (int)InternalParameters.SystemCS,
+ aScope)
+ % 2);
+
+ InternalParameters.WriteNormals =
+ theResource->BooleanVal("write.normals", InternalParameters.WriteNormals, aScope);
+ InternalParameters.WriteColors =
+ theResource->BooleanVal("write.colors", InternalParameters.WriteColors, aScope);
+ InternalParameters.WriteTexCoords =
+ theResource->BooleanVal("write.tex.coords", InternalParameters.WriteTexCoords, aScope);
+ InternalParameters.WritePartId =
+ theResource->BooleanVal("write.part.id", InternalParameters.WritePartId, aScope);
+ InternalParameters.WriteFaceId =
+ theResource->BooleanVal("write.face.id", InternalParameters.WriteFaceId, aScope);
+ InternalParameters.WriteComment =
+ theResource->StringVal("write.comment", InternalParameters.WriteComment, aScope);
+ InternalParameters.WriteAuthor =
+ theResource->StringVal("write.author", InternalParameters.WriteAuthor, aScope);
+ return Standard_True;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEPLY_ConfigurationNode::Save() const
+{
+ TCollection_AsciiString aResult;
+ aResult += "!*****************************************************************************\n";
+ aResult =
+ aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
+ TCollection_AsciiString aScope =
+ THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
+
+ aResult += "!\n";
+ aResult += "!Common parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!File length units to convert from while reading the file, defined as scale factor "
+ "for m (meters)\n";
+ aResult += "!Default value: 1.0(MM)\n";
+ aResult += aScope + "file.length.unit :\t " + InternalParameters.FileLengthUnit + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!System origin coordinate system to perform conversion into during read\n";
+ aResult += "!Default value: 0(Zup). Available values: 0(Zup), 1(Yup)\n";
+ aResult += aScope + "system.cs :\t " + InternalParameters.SystemCS + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!File origin coordinate system to perform conversion during read\n";
+ aResult += "!Default value: 1(Yup). Available values: 0(Zup), 1(Yup)\n";
+ aResult += aScope + "file.cs :\t " + InternalParameters.FileCS + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Write parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag for write normals\n";
+ aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "write.normals :\t " + InternalParameters.WriteNormals + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag for write colors\n";
+ aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "write.colors :\t " + InternalParameters.WriteColors + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag for write UV / texture coordinates\n";
+ aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "write.tex.coords :\t " + InternalParameters.WriteTexCoords + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag for write part Id as element attribute\n";
+ aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "write.part.id :\t " + InternalParameters.WritePartId + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Flag for write face Id as element attribute. Cannot be combined with HasPartId\n";
+ aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
+ aResult += aScope + "write.face.id :\t " + InternalParameters.WriteFaceId + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Export special comment\n";
+ aResult += "!Default value: "
+ "(empty). Available values: <string>\n";
+ aResult += aScope + "write.comment :\t " + InternalParameters.WriteComment + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Author of exported file name\n";
+ aResult += "!Default value: "
+ "(empty). Available values: <string>\n";
+ aResult += aScope + "write.author :\t " + InternalParameters.WriteAuthor + "\n";
+ aResult += "!\n";
+
+ aResult += "!*****************************************************************************\n";
+ return aResult;
+}
+
+//=================================================================================================
+
+Handle(DE_ConfigurationNode) DEPLY_ConfigurationNode::Copy() const
+{
+ return new DEPLY_ConfigurationNode(*this);
+}
+
+//=================================================================================================
+
+Handle(DE_Provider) DEPLY_ConfigurationNode::BuildProvider()
+{
+ return new DEPLY_Provider(this);
+}
+
+//=================================================================================================
+
+bool DEPLY_ConfigurationNode::IsImportSupported() const
+{
+ return Standard_False;
+}
+
+//=================================================================================================
+
+bool DEPLY_ConfigurationNode::IsExportSupported() const
+{
+ return Standard_True;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEPLY_ConfigurationNode::GetFormat() const
+{
+ return TCollection_AsciiString("PLY");
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEPLY_ConfigurationNode::GetVendor() const
+{
+ return TCollection_AsciiString("OCC");
+}
+
+//=================================================================================================
+
+TColStd_ListOfAsciiString DEPLY_ConfigurationNode::GetExtensions() const
+{
+ TColStd_ListOfAsciiString anExt;
+ anExt.Append("ply");
+ return anExt;
+}
+
+//=================================================================================================
+
+bool DEPLY_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
+{
+ if (theBuffer.IsNull() || theBuffer->Size() < 4)
+ {
+ return false;
+ }
+ const char* aBytes = (const char*)theBuffer->Data();
+ if (!::strncmp(aBytes, "ply", 3) && ::isspace(aBytes[3]))
+ {
+ return true;
+ }
+ return false;
+}
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _DEPLY_ConfigurationNode_HeaderFile
+#define _DEPLY_ConfigurationNode_HeaderFile
+
+#include <DE_ConfigurationNode.hxx>
+#include <Precision.hxx>
+#include <RWMesh_CoordinateSystem.hxx>
+
+class DE_ConfigurationContext;
+
+//! The purpose of this class is to configure the transfer process for PLY format
+//! Stores the necessary settings for DEPLY_Provider.
+//! Configures and creates special provider to transfer PLY files.
+//!
+//! Nodes grouped by Vendor name and Format type.
+//! The Vendor name is "OCC"
+//! The Format type is "PLY"
+//! The supported CAD extension is ".ply"
+//! The import process isn't supported.
+//! The export process is supported.
+class DEPLY_ConfigurationNode : public DE_ConfigurationNode
+{
+ DEFINE_STANDARD_RTTIEXT(DEPLY_ConfigurationNode, DE_ConfigurationNode)
+public:
+ //! Initializes all field by default
+ Standard_EXPORT DEPLY_ConfigurationNode();
+
+ //! Copies values of all fields
+ //! @param[in] theNode object to copy
+ Standard_EXPORT DEPLY_ConfigurationNode(const Handle(DEPLY_ConfigurationNode)& theNode);
+
+ //! Updates values according the resource
+ //! @param[in] theResource input resource to use
+ //! @return true if theResource loading has ended correctly
+ Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource)
+ Standard_OVERRIDE;
+
+ //! Writes configuration to the string
+ //! @return result resource string
+ Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
+
+ //! Copies values of all fields
+ //! @return new object with the same field values
+ Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
+
+ //! Creates new provider for the own format
+ //! @return new created provider
+ Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
+
+public:
+ //! Checks the import supporting
+ //! @return true if import is supported
+ Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
+
+ //! Checks the export supporting
+ //! @return true if export is supported
+ Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
+
+ //! Gets CAD format name of associated provider
+ //! @return provider CAD format
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
+
+ //! Gets provider's vendor name of associated provider
+ //! @return provider's vendor name
+ Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+
+ //! Gets list of supported file extensions
+ //! @return list of extensions
+ Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
+
+ //! Checks the file content to verify a format
+ //! @param[in] theBuffer read stream buffer to check content
+ //! @return Standard_True if file is supported by a current provider
+ Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
+ Standard_OVERRIDE;
+
+public:
+ struct RWPly_InternalSection
+ {
+ // Common
+ // clang-format off
+ double FileLengthUnit = 1.; //!< File length units to convert from while reading the file, defined as scale factor for m (meters)
+ RWMesh_CoordinateSystem SystemCS = RWMesh_CoordinateSystem_Zup; //!< System origin coordinate system to perform conversion into during read
+ RWMesh_CoordinateSystem FileCS = RWMesh_CoordinateSystem_Yup; //!< File origin coordinate system to perform conversion during read
+ // Writing
+ bool WriteNormals = true; //!< Flag for write normals
+ bool WriteColors = true; //!< Flag for write colors
+ bool WriteTexCoords = false; //!< Flag for write UV / texture coordinates
+ bool WritePartId = true; //!< Flag for write part Id as element attribute
+ bool WriteFaceId = false; //!< Flag for write face Id as element attribute. Cannot be combined with HasPartId
+ // clang-format on
+ TCollection_AsciiString WriteComment; //!< Export special comment
+ TCollection_AsciiString WriteAuthor; //!< Author of exported file name
+ } InternalParameters;
+};
+
+#endif // _DEPLY_ConfigurationNode_HeaderFile
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <DEPLY_Provider.hxx>
+
+#include <BRep_Builder.hxx>
+#include <DEPLY_ConfigurationNode.hxx>
+#include <DE_Wrapper.hxx>
+#include <Message.hxx>
+#include <RWMesh_FaceIterator.hxx>
+#include <RWPly_CafWriter.hxx>
+#include <RWPly_PlyWriterContext.hxx>
+#include <TDocStd_Document.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <XCAFDoc_ShapeTool.hxx>
+#include <XCAFPrs_DocumentExplorer.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(DEPLY_Provider, DE_Provider)
+
+//=================================================================================================
+
+DEPLY_Provider::DEPLY_Provider() {}
+
+//=================================================================================================
+
+DEPLY_Provider::DEPLY_Provider(const Handle(DE_ConfigurationNode)& theNode)
+ : DE_Provider(theNode)
+{
+}
+
+//=================================================================================================
+
+bool DEPLY_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);
+}
+
+//=================================================================================================
+
+bool DEPLY_Provider::Write(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ const Message_ProgressRange& theProgress)
+{
+ if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEPLY_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DEPLY_Provider during writing the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DEPLY_ConfigurationNode) aNode = Handle(DEPLY_ConfigurationNode)::DownCast(GetNode());
+
+ TDF_LabelSequence aRootLabels;
+ Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
+ aShapeTool->GetFreeShapes(aRootLabels);
+ if (aRootLabels.IsEmpty())
+ {
+ return Standard_True;
+ }
+
+ TColStd_IndexedDataMapOfStringString aFileInfo;
+ if (!aNode->InternalParameters.WriteAuthor.IsEmpty())
+ {
+ aFileInfo.Add("Author", aNode->InternalParameters.WriteAuthor);
+ }
+ if (!aNode->InternalParameters.WriteComment.IsEmpty())
+ {
+ aFileInfo.Add("Comments", aNode->InternalParameters.WriteComment);
+ }
+ RWMesh_CoordinateSystemConverter aConverter;
+ Standard_Real aScaleFactorM = 1.;
+ if (XCAFDoc_DocumentTool::GetLengthUnit(theDocument, aScaleFactorM))
+ {
+ aConverter.SetInputLengthUnit(aScaleFactorM);
+ }
+ else
+ {
+ aConverter.SetInputLengthUnit(aNode->GlobalParameters.SystemUnit / 1000.);
+ Message::SendWarning()
+ << "Warning in the DEPLY_Provider during writing the file " << thePath
+ << "\t: The document has no information on Units. Using global parameter as initial Unit.";
+ }
+ aConverter.SetInputCoordinateSystem(aNode->InternalParameters.SystemCS);
+ aConverter.SetOutputLengthUnit(aNode->GlobalParameters.LengthUnit / 1000.);
+ aConverter.SetOutputCoordinateSystem(aNode->InternalParameters.FileCS);
+
+ RWPly_CafWriter aPlyCtx(thePath);
+ aPlyCtx.SetNormals(aNode->InternalParameters.WriteNormals);
+ aPlyCtx.SetColors(aNode->InternalParameters.WriteColors);
+ aPlyCtx.SetTexCoords(aNode->InternalParameters.WriteTexCoords);
+ aPlyCtx.SetPartId(aNode->InternalParameters.WritePartId);
+ aPlyCtx.SetFaceId(aNode->InternalParameters.WriteFaceId);
+ if (!aPlyCtx.Perform(theDocument, aFileInfo, theProgress))
+ {
+ Message::SendFail() << "Error in the DEPLY_Provider during writing the file " << thePath
+ << "\t: Cannot perform the document";
+ return false;
+ }
+
+ return true;
+}
+
+//=================================================================================================
+
+bool DEPLY_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);
+}
+
+//=================================================================================================
+
+bool DEPLY_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);
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEPLY_Provider::GetFormat() const
+{
+ return TCollection_AsciiString("PLY");
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEPLY_Provider::GetVendor() const
+{
+ return TCollection_AsciiString("OCC");
+}
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _DEPLY_Provider_HeaderFile
+#define _DEPLY_Provider_HeaderFile
+
+#include <DE_Provider.hxx>
+
+//! The class to transfer PLY files.
+//! Writes any PLY files from OCCT.
+//! Each operation needs configuration node.
+//!
+//! Providers grouped by Vendor name and Format type.
+//! The Vendor name is "OCC"
+//! The Format type is "PLY"
+//! The import process isn't supported.
+//! The export process is supported.
+class DEPLY_Provider : public DE_Provider
+{
+public:
+ DEFINE_STANDARD_RTTIEXT(DEPLY_Provider, DE_Provider)
+
+public:
+ //! Default constructor
+ //! Configure translation process with global configuration
+ Standard_EXPORT DEPLY_Provider();
+
+ //! Configure translation process
+ //! @param[in] theNode object to copy
+ Standard_EXPORT DEPLY_Provider(const Handle(DE_ConfigurationNode)& theNode);
+
+public:
+ //! Writes a CAD file, according internal configuration
+ //! @param[in] thePath path to the export CAD file
+ //! @param[out] theDocument document to export
+ //! @param[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Write operation has ended correctly
+ Standard_EXPORT virtual bool Write(
+ const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ 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[in] theProgress 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
+ //! @param[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Write operation has ended correctly
+ Standard_EXPORT virtual bool Write(
+ const TCollection_AsciiString& thePath,
+ const TopoDS_Shape& theShape,
+ 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[in] theProgress 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 CAD format
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
+
+ //! Gets provider's vendor name of associated provider
+ //! @return provider's vendor name
+ Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+};
+
+#endif // _DEPLY_Provider_HeaderFile
--- /dev/null
+DEPLY_ConfigurationNode.cxx
+DEPLY_ConfigurationNode.hxx
+DEPLY_Provider.cxx
+DEPLY_Provider.hxx
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <DESTEP_ConfigurationNode.hxx>
+
+#include <DESTEP_Provider.hxx>
+#include <DE_ConfigurationContext.hxx>
+#include <DE_PluginHolder.hxx>
+#include <NCollection_Buffer.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(DESTEP_ConfigurationNode, DE_ConfigurationNode)
+
+namespace
+{
+static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
+{
+ static const TCollection_AsciiString aScope = "provider";
+ return aScope;
+}
+
+// Wrapper to auto-load DE component
+DE_PluginHolder<DESTEP_ConfigurationNode> THE_OCCT_STEP_COMPONENT_PLUGIN;
+} // namespace
+
+//=================================================================================================
+
+DESTEP_ConfigurationNode::DESTEP_ConfigurationNode()
+ : DE_ConfigurationNode()
+{
+}
+
+//=================================================================================================
+
+DESTEP_ConfigurationNode::DESTEP_ConfigurationNode(const Handle(DESTEP_ConfigurationNode)& theNode)
+ : DE_ConfigurationNode(theNode),
+ InternalParameters(theNode->InternalParameters)
+{
+}
+
+//=================================================================================================
+
+bool DESTEP_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
+{
+ TCollection_AsciiString aScope =
+ THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
+
+ InternalParameters.ReadBSplineContinuity =
+ (StepData_ConfParameters::ReadMode_BSplineContinuity)theResource->IntegerVal(
+ "read.iges.bspline.continuity",
+ InternalParameters.ReadBSplineContinuity,
+ aScope);
+ InternalParameters.ReadPrecisionMode =
+ (StepData_ConfParameters::ReadMode_Precision)
+ theResource->IntegerVal("read.precision.mode", InternalParameters.ReadPrecisionMode, aScope);
+ InternalParameters.ReadPrecisionVal =
+ theResource->RealVal("read.precision.val", InternalParameters.ReadPrecisionVal, aScope);
+ InternalParameters.ReadMaxPrecisionMode =
+ (StepData_ConfParameters::ReadMode_MaxPrecision)theResource->IntegerVal(
+ "read.maxprecision.mode",
+ InternalParameters.ReadMaxPrecisionMode,
+ aScope);
+ InternalParameters.ReadMaxPrecisionVal =
+ theResource->RealVal("read.maxprecision.val", InternalParameters.ReadMaxPrecisionVal, aScope);
+ InternalParameters.ReadSameParamMode =
+ theResource->BooleanVal("read.stdsameparameter.mode",
+ InternalParameters.ReadSameParamMode,
+ aScope);
+ InternalParameters.ReadSurfaceCurveMode =
+ (StepData_ConfParameters::ReadMode_SurfaceCurve)theResource->IntegerVal(
+ "read.surfacecurve.mode",
+ InternalParameters.ReadSurfaceCurveMode,
+ aScope);
+ InternalParameters.EncodeRegAngle =
+ theResource->RealVal("read.encoderegularity.angle", InternalParameters.EncodeRegAngle, aScope);
+ InternalParameters.AngleUnit =
+ (StepData_ConfParameters::AngleUnitMode)theResource->IntegerVal("angleunit.mode",
+ InternalParameters.AngleUnit,
+ aScope);
+
+ InternalParameters.ReadResourceName =
+ theResource->StringVal("read.resource.name", InternalParameters.ReadResourceName, aScope);
+ InternalParameters.ReadSequence =
+ theResource->StringVal("read.sequence", InternalParameters.ReadSequence, aScope);
+ InternalParameters.ReadProductMode =
+ theResource->BooleanVal("read.product.mode", InternalParameters.ReadProductMode, aScope);
+ InternalParameters.ReadProductContext =
+ (StepData_ConfParameters::ReadMode_ProductContext)theResource->IntegerVal(
+ "read.product.context",
+ InternalParameters.ReadProductContext,
+ aScope);
+ InternalParameters.ReadShapeRepr =
+ (StepData_ConfParameters::ReadMode_ShapeRepr)
+ theResource->IntegerVal("read.shape.repr", InternalParameters.ReadShapeRepr, aScope);
+ InternalParameters.ReadTessellated =
+ (StepData_ConfParameters::RWMode_Tessellated)
+ theResource->IntegerVal("read.tessellated", InternalParameters.ReadTessellated, aScope);
+ InternalParameters.ReadAssemblyLevel =
+ (StepData_ConfParameters::ReadMode_AssemblyLevel)
+ theResource->IntegerVal("read.assembly.level", InternalParameters.ReadAssemblyLevel, aScope);
+ InternalParameters.ReadRelationship =
+ theResource->BooleanVal("read.shape.relationship", InternalParameters.ReadRelationship, aScope);
+ InternalParameters.ReadShapeAspect =
+ theResource->BooleanVal("read.shape.aspect", InternalParameters.ReadShapeAspect, aScope);
+ InternalParameters.ReadConstrRelation =
+ theResource->BooleanVal("read.constructivegeom.relationship",
+ InternalParameters.ReadConstrRelation,
+ aScope);
+ InternalParameters.ReadSubshapeNames =
+ theResource->BooleanVal("read.stepcaf.subshapes.name",
+ InternalParameters.ReadSubshapeNames,
+ aScope);
+ InternalParameters.ReadCodePage =
+ (Resource_FormatType)theResource->IntegerVal("read.codepage",
+ InternalParameters.ReadCodePage,
+ aScope);
+ InternalParameters.ReadNonmanifold =
+ theResource->BooleanVal("read.nonmanifold", InternalParameters.ReadNonmanifold, aScope);
+ InternalParameters.ReadIdeas =
+ theResource->BooleanVal("read.ideas", InternalParameters.ReadIdeas, aScope);
+ InternalParameters.ReadAllShapes =
+ theResource->BooleanVal("read.all.shapes", InternalParameters.ReadAllShapes, aScope);
+ InternalParameters.ReadRootTransformation =
+ theResource->BooleanVal("read.root.transformation",
+ InternalParameters.ReadRootTransformation,
+ aScope);
+ InternalParameters.ReadColor =
+ theResource->BooleanVal("read.color", InternalParameters.ReadColor, aScope);
+ InternalParameters.ReadName =
+ theResource->BooleanVal("read.name", InternalParameters.ReadName, aScope);
+ InternalParameters.ReadLayer =
+ theResource->BooleanVal("read.layer", InternalParameters.ReadLayer, aScope);
+ InternalParameters.ReadProps =
+ theResource->BooleanVal("read.props", InternalParameters.ReadProps, aScope);
+ InternalParameters.ReadMetadata =
+ theResource->BooleanVal("read.metadata", InternalParameters.ReadMetadata, aScope);
+
+ InternalParameters.WritePrecisionMode =
+ (StepData_ConfParameters::WriteMode_PrecisionMode)theResource->IntegerVal(
+ "write.precision.mode",
+ InternalParameters.WritePrecisionMode,
+ aScope);
+ InternalParameters.WritePrecisionVal =
+ theResource->RealVal("write.precision.val", InternalParameters.WritePrecisionVal, aScope);
+ InternalParameters.WriteAssembly =
+ (StepData_ConfParameters::WriteMode_Assembly)
+ theResource->IntegerVal("write.assembly", InternalParameters.WriteAssembly, aScope);
+ InternalParameters.WriteSchema =
+ (StepData_ConfParameters::WriteMode_StepSchema)
+ theResource->IntegerVal("write.schema", InternalParameters.WriteSchema, aScope);
+ InternalParameters.WriteTessellated =
+ (StepData_ConfParameters::RWMode_Tessellated)
+ theResource->IntegerVal("write.tessellated", InternalParameters.WriteTessellated, aScope);
+ InternalParameters.WriteProductName =
+ theResource->StringVal("write.product.name", InternalParameters.WriteProductName, aScope);
+ InternalParameters.WriteSurfaceCurMode =
+ theResource->BooleanVal("write.surfacecurve.mode",
+ InternalParameters.WriteSurfaceCurMode,
+ aScope);
+ InternalParameters.WriteUnit =
+ (UnitsMethods_LengthUnit)theResource->IntegerVal("write.unit",
+ InternalParameters.WriteUnit,
+ aScope);
+ InternalParameters.WriteResourceName =
+ theResource->StringVal("write.resource.name", InternalParameters.WriteResourceName, aScope);
+ InternalParameters.WriteSequence =
+ theResource->StringVal("write.sequence", InternalParameters.WriteSequence, aScope);
+ InternalParameters.WriteVertexMode =
+ (StepData_ConfParameters::WriteMode_VertexMode)
+ theResource->IntegerVal("write.vertex.mode", InternalParameters.WriteVertexMode, aScope);
+ InternalParameters.WriteSubshapeNames =
+ theResource->BooleanVal("write.stepcaf.subshapes.name",
+ InternalParameters.WriteSubshapeNames,
+ aScope);
+ InternalParameters.WriteColor =
+ theResource->BooleanVal("write.color", InternalParameters.WriteColor, aScope);
+ InternalParameters.WriteName =
+ theResource->BooleanVal("write.name", InternalParameters.WriteName, aScope);
+ InternalParameters.WriteLayer =
+ theResource->BooleanVal("write.layer", InternalParameters.WriteLayer, aScope);
+ InternalParameters.WriteProps =
+ theResource->BooleanVal("write.props", InternalParameters.WriteProps, aScope);
+ InternalParameters.WriteModelType =
+ (STEPControl_StepModelType)theResource->IntegerVal("write.model.type",
+ InternalParameters.WriteModelType,
+ aScope);
+
+ return true;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DESTEP_ConfigurationNode::Save() const
+{
+ TCollection_AsciiString aResult;
+ aResult += "!*****************************************************************************\n";
+ aResult =
+ aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
+ TCollection_AsciiString aScope =
+ THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
+
+ aResult += "!\n";
+ aResult += "!Common parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Manages the continuity of BSpline curves (IGES entities 106, 112 and 126) ";
+ aResult += "after translation to Open CASCADE Technology\n";
+ aResult += "!Default value: 1. Available values: 0, 1, 2\n";
+ aResult +=
+ aScope + "read.iges.bspline.continuity :\t " + InternalParameters.ReadBSplineContinuity + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Reads the precision mode value\n";
+ aResult += "!Default value: \"File\"(0). Available values: \"File\"(0), \"User\"(1)\n";
+ aResult += aScope + "read.precision.mode :\t " + InternalParameters.ReadPrecisionMode + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!This parameter gives the precision for shape construction when the ";
+ aResult += "read.precision.mode parameter value is 1\n";
+ aResult += "!Default value: 0.0001. Available values: any real positive (non null) value\n";
+ aResult += aScope + "read.precision.val :\t " + InternalParameters.ReadPrecisionVal + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines the mode of applying the maximum allowed tolerance\n";
+ aResult +=
+ "!Default value: \"Preferred\"(0). Available values: \"Preferred\"(0), \"Forced\"(1)\n";
+ aResult +=
+ aScope + "read.maxprecision.mode :\t " + InternalParameters.ReadMaxPrecisionMode + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines the maximum allowable tolerance (in internal units, which are specified in "
+ "xstep.cascade.unit)";
+ aResult += " of the shape\n";
+ aResult += "!Default value: 1. Available values: any real positive (non null) value\n";
+ aResult += aScope + "read.maxprecision.val :\t " + InternalParameters.ReadMaxPrecisionVal + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines the using of BRepLib::SameParameter\n";
+ aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(1)\n";
+ aResult +=
+ aScope + "read.stdsameparameter.mode :\t " + InternalParameters.ReadSameParamMode + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult +=
+ "!Preference for the computation of curves in case of 2D/3D inconsistency in an entity ";
+ aResult += "which has both 2D and 3D representations.\n";
+ aResult +=
+ "!Default value: \"Default\"(0). Available values: \"Default\"(0), \"2DUse_Preferred\"(2), ";
+ aResult += "\"2DUse_Forced\"(-2), \"3DUse_Preferred\"(3), \"3DUse_Forced\"(-3)\n";
+ aResult +=
+ aScope + "read.surfacecurve.mode :\t " + InternalParameters.ReadSurfaceCurveMode + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!This parameter is used within the BRepLib::EncodeRegularity() function ";
+ aResult += "which is called for a shape read ";
+ aResult += "from an IGES or a STEP file at the end of translation process.This function sets the "
+ "regularity flag of";
+ aResult +=
+ " an edge in a shell when this edge is shared by two faces.This flag shows the continuity, ";
+ aResult += "which these two faces are connected with at that edge.\n";
+ aResult += "!Default value (in degrees): 0.57295779513. Available values: <double>\n";
+ aResult += aScope + "read.encoderegularity.angle :\t " + InternalParameters.EncodeRegAngle + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Indicates what angle units should be used when a STEP file is read\n";
+ aResult += "!Default value: \"File\"(0). Available values: \"File\"(0), \"Rad\"(1), \"Deg\"(2)\n";
+ aResult += aScope + "angleunit.mode :\t " + InternalParameters.AngleUnit + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Read Parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines the name of the resource file\n";
+ aResult += "!Default value: \"STEP\". Available values: <string>\n";
+ aResult += aScope + "read.resource.name :\t " + InternalParameters.ReadResourceName + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines name of the sequence of operators\n";
+ aResult += "!Default value: \"FromSTEP\". Available values: <string>\n";
+ aResult += aScope + "read.sequence :\t " + InternalParameters.ReadSequence + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult +=
+ "!Defines the approach used for selection of top-level STEP entities for translation, ";
+ aResult += "and for recognition of assembly structures\n";
+ aResult += "!Default value: 1(\"ON\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
+ aResult += aScope + "read.product.mode :\t " + InternalParameters.ReadProductMode + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult +=
+ "!When reading AP 209 STEP files, allows selecting either only 'design' or 'analysis', ";
+ aResult += "or both types of products for translation\n";
+ aResult +=
+ "!Default value: 1(\"all\"). Available values: 1(\"all\"), 2(\"design\"), 3(\"analysis\")\n";
+ aResult += aScope + "read.product.context :\t " + InternalParameters.ReadProductContext + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Specifies preferred type of representation of the shape of the product, in case if "
+ "a STEP file contains";
+ aResult += " more than one representation(i.e.multiple PRODUCT_DEFINITION_SHAPE entities) for a "
+ "single product\n";
+ aResult += "!Default value: 1(\"All\"). Available values: 1(\"All\"), 2(\"ABSR\"), 3(\"MSSR\"), "
+ "4(\"GBSSR\"), ";
+ aResult += "5(\"FBSR\"), 6(\"EBWSR\"), 7(\"GBWSR\")\n";
+ aResult += aScope + "read.shape.repr :\t " + InternalParameters.ReadShapeRepr + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines whether tessellated shapes should be translated";
+ aResult += "!Default value: 1(\"On\"). Available values: 0(\"OFF\"), 2(\"OnNoBRep\")\n";
+ aResult += aScope + "read.tessellated :\t " + InternalParameters.ReadTessellated + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Specifies which data should be read for the products found in the STEP file\n";
+ aResult += "!Default value: 1(\"All\"). Available values: 1(\"All\"), 2(\"assembly\"),";
+ aResult += "3(\"structure\"), 4(\"shape\")\n";
+ aResult += aScope + "read.assembly.level :\t " + InternalParameters.ReadAssemblyLevel + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult +=
+ "!Defines whether shapes associated with the main SHAPE_DEFINITION_REPRESENTATION entity";
+ aResult += "of the product via SHAPE_REPRESENTATIONSHIP_RELATION should be translated\n";
+ aResult += "!Default value: 1(\"ON\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
+ aResult += aScope + "read.shape.relationship :\t " + InternalParameters.ReadRelationship + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult +=
+ "!Defines whether shapes associated with the PRODUCT_DEFINITION_SHAPE entity of the product ";
+ aResult += "via SHAPE_ASPECT should be translated.\n";
+ aResult += "!Default value: 1(\"ON\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
+ aResult += aScope + "read.shape.aspect :\t " + InternalParameters.ReadShapeAspect + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Boolean flag regulating translation of "
+ "\"CONSTRUCTIVE_GEOMETRY_REPRESENTATION_RELATIONSHIP\" ";
+ aResult += "entities that define position of constructive geometry entities contained in ";
+ aResult += "\"CONSTRUCTIVE_GEOMETRY_REPRESENTATION\" with respect to the main representation of "
+ "the shape (product).\n";
+ aResult += "!Default value: 0(\"OFF\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
+ aResult += aScope + "read.constructivegeom.relationship :\t "
+ + InternalParameters.ReadConstrRelation + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Indicates whether to read sub-shape names from 'Name' attributes of STEP "
+ "Representation Items\n";
+ aResult += "!Default value: 0(\"OFF\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
+ aResult +=
+ aScope + "read.stepcaf.subshapes.name :\t " + InternalParameters.ReadSubshapeNames + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!STEP file encoding for names translation\n";
+ aResult +=
+ "!Default value: 4(\"UTF8\"). Available values: 0(\"SJIS\"), 1(\"EUC\"), 2(\"NoConversion\"), ";
+ aResult +=
+ "3(\"GB\"), 4(\"UTF8\"), 5(\"SystemLocale\"), 6(\"CP1250\"), 7(\"CP1251\"), 8(\"CP1252\"), ";
+ aResult += "9(\"CP1253\"), 10(\"CP1254\"), 11(\"CP1255\"), 12(\"CP1256\"), 13(\"CP1257\"), "
+ "14(\"CP1258\"), ";
+ aResult += "15(\"iso8859-1\"), 16(\"iso8859-2\"), 17(\"iso8859-3\"), 18(\"iso8859-4\"), "
+ "19(\"iso8859-5\"), ";
+ aResult +=
+ "20(\"iso8859-6\"), 21(\"iso8859-7\"), 22(\"iso8859-8\"), 23(\"iso8859-9\"), 24(\"CP850\")\n";
+ aResult += aScope + "read.codepage :\t " + InternalParameters.ReadCodePage + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Non-manifold topology reading\n";
+ aResult += "!Default value: 0(\"OFF\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
+ aResult += aScope + "read.nonmanifold :\t " + InternalParameters.ReadNonmanifold + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!I-Deas-like STEP processing\n";
+ aResult += "!Default value: 0(\"OFF\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
+ aResult += aScope + "read.ideas :\t " + InternalParameters.ReadIdeas + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Parameter to read all top level solids and shells\n";
+ aResult += "!Default value: 0(\"OFF\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
+ aResult += aScope + "read.all.shapes :\t " + InternalParameters.ReadAllShapes + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult +=
+ "!Mode to variate apply or not transformation placed in the root shape representation.\n";
+ aResult += "!Default value: 1(\"ON\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
+ aResult +=
+ aScope + "read.root.transformation :\t " + InternalParameters.ReadRootTransformation + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Setting up the read.colo parameter which is used to indicate read Colors or not\n";
+ aResult += "!Default value: +. Available values: \"-\", \"+\"\n";
+ aResult += aScope + "read.color :\t " + InternalParameters.ReadColor + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Setting up the read.name parameter which is used to indicate read Names or not\n";
+ aResult += "!Default value: +. Available values: \"-\", \"+\"\n";
+ aResult += aScope + "read.name :\t " + InternalParameters.ReadName + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Setting up the read.layer parameter which is used to indicate read Layers or not\n";
+ aResult += "!Default value: +. Available values: \"-\", \"+\"\n";
+ aResult += aScope + "read.layer :\t " + InternalParameters.ReadLayer + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Setting up the read.props parameter which is used to indicate read Validation "
+ "properties or not\n";
+ aResult += "!Default value: +. Available values: \"-\", \"+\"\n";
+ aResult += aScope + "read.props :\t " + InternalParameters.ReadProps + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult +=
+ "!Setting up the read.metadata parameter which is used to indicate read Metadata or not\n";
+ aResult += "!Default value: 1(\"ON\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
+ aResult += aScope + "read.metadata :\t " + InternalParameters.ReadMetadata + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Write Parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Writes the precision value\n";
+ aResult += "!Default value: \"Average\"(0). Available values: \"Least\"(-1), \"Average\"(0), ";
+ aResult += "\"Greatest\"(1), \"Session\"(2)\n";
+ aResult += aScope + "write.precision.mode :\t " + InternalParameters.WritePrecisionMode + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!A user-defined precision value\n";
+ aResult += "!Default value: 0.0001. Available values: any real positive (non null) value\n";
+ aResult += aScope + "write.precision.val :\t " + InternalParameters.WritePrecisionVal + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Writing assembly mode\n";
+ aResult += "!Default value: 2(\"Auto\"). Available values: 0(\"Off\"), 1(\"On\"), 2(\"Auto\")\n";
+ aResult += aScope + "write.assembly :\t " + InternalParameters.WriteAssembly + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines the version of schema used for the output STEP file\n";
+ aResult +=
+ "!Default value: 1 or AP214CD. Available values: 1 or AP214CD, 2 or AP214DIS, 3 or AP203, ";
+ aResult += "4 or AP214IS, 5 or AP242DIS\n";
+ aResult += aScope + "write.schema :\t " + InternalParameters.WriteSchema + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines whether tessellated shapes should be translated";
+ aResult += "!Default value: 2(\"OnNoBRep\"). Available values: 0(\"OFF\"), 1(\"On\")\n";
+ aResult += aScope + "write.tessellated :\t " + InternalParameters.WriteTessellated + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines the text string that will be used for field 'name' of PRODUCT entities "
+ "written to the STEP file\n";
+ aResult += "!Default value: OCCT STEP translator (current OCCT version number). Available "
+ "values: <string>\n";
+ aResult += aScope + "write.product.name :\t " + InternalParameters.WriteProductName + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult +=
+ "!This parameter indicates whether parametric curves should be written into the STEP file\n";
+ aResult += "!Default value: 1(\"ON\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
+ aResult +=
+ aScope + "write.surfacecurve.mode :\t " + InternalParameters.WriteSurfaceCurMode + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines a unit in which the STEP file should be written.\n";
+ aResult += "!Default value: MM(2). Available values: \"INCH\"(1), \"MM\"(2), \"??\"(3), "
+ "\"FT\"(4), \"MI\"(5), ";
+ aResult += "\"M\"(6), \"KM\"(7), \"MIL\"(8), \"UM\"(9), \"CM\"(10), \"UIN\"(11)\n";
+ aResult += aScope + "write.unit :\t " + InternalParameters.WriteUnit + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines the name of the resource file\n";
+ aResult += "!Default value: \"STEP\". Available values: <string>\n";
+ aResult += aScope + "write.resource.name :\t " + InternalParameters.WriteResourceName + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Defines name of the sequence of operators\n";
+ aResult += "!Default value: \"ToSTEP\". Available values: <string>\n";
+ aResult += aScope + "write.sequence :\t " + InternalParameters.WriteSequence + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!This parameter indicates which of free vertices writing mode is switch on\n";
+ aResult += "!Default value: 0(\"One Compound\"). Available values: 0(\"One Compound\"), "
+ "1(\"Signle Vertex\")\n";
+ aResult += aScope + "write.vertex.mode :\t " + InternalParameters.WriteVertexMode + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Indicates whether to write sub-shape names to 'Name' attributes of STEP "
+ "Representation Items\n";
+ aResult += "!Default value: 0(\"OFF\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
+ aResult +=
+ aScope + "write.stepcaf.subshapes.name :\t " + InternalParameters.WriteSubshapeNames + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Setting up the write.colo parameter which is used to indicate write Colors or not\n";
+ aResult += "!Default value: +. Available values: \"-\", \"+\"\n";
+ aResult += aScope + "write.color :\t " + InternalParameters.WriteColor + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Setting up the write.name parameter which is used to indicate write Names or not\n";
+ aResult += "!Default value: +. Available values: \"-\", \"+\"\n";
+ aResult += aScope + "write.name :\t " + InternalParameters.WriteName + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult +=
+ "!Setting up the write.layer parameter which is used to indicate write Layers or not\n";
+ aResult += "!Default value: +. Available values: \"-\", \"+\"\n";
+ aResult += aScope + "write.layer :\t " + InternalParameters.WriteLayer + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Setting up the write.props parameter which is used to indicate write Validation "
+ "properties or not\n";
+ aResult += "!Default value: +. Available values: \"-\", \"+\"\n";
+ aResult += aScope + "write.props :\t " + InternalParameters.WriteProps + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Setting up the Model Type which gives you the choice of translation mode for an "
+ "Open CASCADE shape that ";
+ aResult += "is being translated to STEP\n";
+ aResult += "!Default value: 0. Available values: 0, 1, 2, 3, 4\n";
+ aResult += aScope + "write.model.type :\t " + InternalParameters.WriteModelType + "\n";
+ aResult += "!\n";
+
+ aResult += "!*****************************************************************************\n";
+
+ return aResult;
+}
+
+//=================================================================================================
+
+Handle(DE_ConfigurationNode) DESTEP_ConfigurationNode::Copy() const
+{
+ return new DESTEP_ConfigurationNode(*this);
+}
+
+//=================================================================================================
+
+Handle(DE_Provider) DESTEP_ConfigurationNode::BuildProvider()
+{
+ return new DESTEP_Provider(this);
+}
+
+//=================================================================================================
+
+bool DESTEP_ConfigurationNode::IsImportSupported() const
+{
+ return true;
+}
+
+//=================================================================================================
+
+bool DESTEP_ConfigurationNode::IsExportSupported() const
+{
+ return true;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DESTEP_ConfigurationNode::GetFormat() const
+{
+ return TCollection_AsciiString("STEP");
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DESTEP_ConfigurationNode::GetVendor() const
+{
+ return TCollection_AsciiString("OCC");
+}
+
+//=================================================================================================
+
+TColStd_ListOfAsciiString DESTEP_ConfigurationNode::GetExtensions() const
+{
+ TColStd_ListOfAsciiString anExt;
+ anExt.Append("stp");
+ anExt.Append("step");
+ anExt.Append("stpz");
+ return anExt;
+}
+
+//=================================================================================================
+
+bool DESTEP_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
+{
+ if (theBuffer.IsNull() || theBuffer->Size() < 100)
+ {
+ return false;
+ }
+ const char* aBytes = (const char*)theBuffer->Data();
+ if (::strstr(aBytes, "IFC"))
+ {
+ return false;
+ }
+ if (::strstr(aBytes, "ISO-10303-21"))
+ {
+ // Double-check by presence of "FILE_SHEMA" statement
+ const char* aPtr = ::strstr(aBytes, "FILE_SCHEMA");
+ if (aPtr)
+ {
+ return true;
+ }
+ }
+ return false;
+}
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _DESTEP_ConfigurationNode_HeaderFile
+#define _DESTEP_ConfigurationNode_HeaderFile
+
+#include <DE_ConfigurationNode.hxx>
+#include <Resource_FormatType.hxx>
+#include <STEPControl_StepModelType.hxx>
+#include <StepData_ConfParameters.hxx>
+#include <UnitsMethods_LengthUnit.hxx>
+
+//! The purpose of this class is to configure the transfer process for STEP format
+//! Stores the necessary settings for DESTEP_Provider.
+//! Configures and creates special provider to transfer STEP files.
+//!
+//! Nodes grouped by Vendor name and Format type.
+//! The Vendor name is "OCC"
+//! The Format type is "STEP"
+//! The supported CAD extensions are ".stp", ".step", ".stpz"
+//! The import process is supported.
+//! The export process is supported.
+class DESTEP_ConfigurationNode : public DE_ConfigurationNode
+{
+ DEFINE_STANDARD_RTTIEXT(DESTEP_ConfigurationNode, DE_ConfigurationNode)
+public:
+ //! Initializes all field by default
+ Standard_EXPORT DESTEP_ConfigurationNode();
+
+ //! Copies values of all fields
+ //! @param[in] theNode object to copy
+ Standard_EXPORT DESTEP_ConfigurationNode(const Handle(DESTEP_ConfigurationNode)& theNode);
+
+ //! Updates values according the resource
+ //! @param[in] theResource input resource to use
+ //! @return true if theResource loading has ended correctly
+ Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource)
+ Standard_OVERRIDE;
+
+ //! Writes configuration to the string
+ //! @return result resource string
+ Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
+
+ //! Copies values of all fields
+ //! @return new object with the same field values
+ Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
+
+ //! Creates new provider for the own format
+ //! @return new created provider
+ Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
+
+public:
+ //! Checks the import supporting
+ //! @return true if import is supported
+ Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
+
+ //! Checks the export supporting
+ //! @return true if export is supported
+ Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
+
+ //! Gets CAD format name of associated provider
+ //! @return provider CAD format
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
+
+ //! Gets provider's vendor name of associated provider
+ //! @return provider's vendor name
+ Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+
+ //! Gets list of supported file extensions
+ //! @return list of extensions
+ Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
+
+ //! Checks the file content to verify a format
+ //! @param[in] theBuffer read stream buffer to check content
+ //! @return Standard_True if file is supported by a current provider
+ Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
+ Standard_OVERRIDE;
+
+public:
+ StepData_ConfParameters InternalParameters;
+};
+
+#endif // _DESTEP_ConfigurationNode_HeaderFile
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <DESTEP_Provider.hxx>
+
+#include <DESTEP_ConfigurationNode.hxx>
+#include <Interface_Static.hxx>
+#include <Message.hxx>
+#include <STEPCAFControl_Controller.hxx>
+#include <STEPCAFControl_Reader.hxx>
+#include <STEPCAFControl_Writer.hxx>
+#include <StepData_ConfParameters.hxx>
+#include <StepData_StepModel.hxx>
+#include <UnitsMethods.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <XSControl_WorkSession.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(DESTEP_Provider, DE_Provider)
+
+//=================================================================================================
+
+DESTEP_Provider::DESTEP_Provider() {}
+
+//=================================================================================================
+
+DESTEP_Provider::DESTEP_Provider(const Handle(DE_ConfigurationNode)& theNode)
+ : DE_Provider(theNode)
+{
+}
+
+//=================================================================================================
+
+bool DESTEP_Provider::Read(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ if (theDocument.IsNull())
+ {
+ Message::SendFail() << "Error in the DESTEP_Provider during reading the file " << thePath
+ << "\t: theDocument shouldn't be null";
+ return false;
+ }
+ if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DESTEP_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DESTEP_Provider during reading the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DESTEP_ConfigurationNode) aNode = Handle(DESTEP_ConfigurationNode)::DownCast(GetNode());
+ personizeWS(theWS);
+ XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
+ aNode->GlobalParameters.LengthUnit,
+ UnitsMethods_LengthUnit_Millimeter);
+ STEPCAFControl_Reader aReader;
+ aReader.Init(theWS);
+ aReader.SetColorMode(aNode->InternalParameters.ReadColor);
+ aReader.SetNameMode(aNode->InternalParameters.ReadName);
+ aReader.SetLayerMode(aNode->InternalParameters.ReadLayer);
+ aReader.SetPropsMode(aNode->InternalParameters.ReadProps);
+ aReader.SetMetaMode(aNode->InternalParameters.ReadMetadata);
+
+ IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
+ StepData_ConfParameters aParams = aNode->InternalParameters;
+ aReadStat = aReader.ReadFile(thePath.ToCString(), aParams);
+ if (aReadStat != IFSelect_RetDone)
+ {
+ Message::SendFail() << "Error in the DESTEP_Provider during reading the file " << thePath
+ << "\t: abandon";
+ return false;
+ }
+
+ if (!aReader.Transfer(theDocument, theProgress))
+ {
+ Message::SendFail() << "Error in the DESTEP_Provider during reading the file " << thePath
+ << "\t: Cannot read any relevant data from the STEP file";
+ return false;
+ }
+ return true;
+}
+
+//=================================================================================================
+
+bool DESTEP_Provider::Write(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DESTEP_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DESTEP_Provider during writing the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DESTEP_ConfigurationNode) aNode = Handle(DESTEP_ConfigurationNode)::DownCast(GetNode());
+ personizeWS(theWS);
+ STEPCAFControl_Writer aWriter;
+ aWriter.Init(theWS);
+ Handle(StepData_StepModel) aModel =
+ Handle(StepData_StepModel)::DownCast(aWriter.Writer().WS()->Model());
+ STEPControl_StepModelType aMode =
+ static_cast<STEPControl_StepModelType>(aNode->InternalParameters.WriteModelType);
+ aWriter.SetColorMode(aNode->InternalParameters.WriteColor);
+ aWriter.SetNameMode(aNode->InternalParameters.WriteName);
+ aWriter.SetLayerMode(aNode->InternalParameters.WriteLayer);
+ aWriter.SetPropsMode(aNode->InternalParameters.WriteProps);
+ StepData_ConfParameters aParams = aNode->InternalParameters;
+ Standard_Real aScaleFactorMM = 1.;
+ if (XCAFDoc_DocumentTool::GetLengthUnit(theDocument,
+ aScaleFactorMM,
+ UnitsMethods_LengthUnit_Millimeter))
+ {
+ aModel->SetLocalLengthUnit(aScaleFactorMM);
+ }
+ else
+ {
+ aModel->SetLocalLengthUnit(aNode->GlobalParameters.SystemUnit);
+ Message::SendWarning()
+ << "Warning in the DESTEP_Provider during writing the file " << thePath
+ << "\t: The document has no information on Units. Using global parameter as initial Unit.";
+ }
+ UnitsMethods_LengthUnit aTargetUnit =
+ UnitsMethods::GetLengthUnitByFactorValue(aNode->GlobalParameters.LengthUnit,
+ UnitsMethods_LengthUnit_Millimeter);
+ aParams.WriteUnit = aTargetUnit;
+ aModel->SetWriteLengthUnit(aNode->GlobalParameters.LengthUnit);
+ TDF_Label aLabel;
+ if (!aWriter.Transfer(theDocument, aParams, aMode, 0, theProgress))
+ {
+ Message::SendFail() << "Error in the DESTEP_Provider during writing the file " << thePath
+ << "\t: The document cannot be translated or gives no result";
+ return false;
+ }
+ IFSelect_ReturnStatus aStatus = aWriter.Write(thePath.ToCString());
+ switch (aStatus)
+ {
+ case IFSelect_RetVoid: {
+ Message::SendFail() << "Error in the DESTEP_Provider during writing the file " << thePath
+ << "\t: No file written";
+ return false;
+ ;
+ }
+ case IFSelect_RetDone: {
+ break;
+ }
+ default: {
+ Message::SendFail() << "Error in the DESTEP_Provider during writing the file " << thePath
+ << "\t: Error on writing file";
+ return false;
+ }
+ }
+ return true;
+}
+
+//=================================================================================================
+
+bool DESTEP_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);
+}
+
+//=================================================================================================
+
+bool DESTEP_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);
+}
+
+//=================================================================================================
+
+bool DESTEP_Provider::Read(const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ (void)theProgress;
+ if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DESTEP_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DESTEP_Provider during reading the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DESTEP_ConfigurationNode) aNode = Handle(DESTEP_ConfigurationNode)::DownCast(GetNode());
+ personizeWS(theWS);
+ STEPControl_Reader aReader;
+ aReader.SetWS(theWS);
+ IFSelect_ReturnStatus aReadstat = IFSelect_RetVoid;
+ StepData_ConfParameters aParams = aNode->InternalParameters;
+ aReadstat = aReader.ReadFile(thePath.ToCString(), aParams);
+ Handle(StepData_StepModel) aModel = aReader.StepModel();
+ if (aReadstat != IFSelect_RetDone)
+ {
+ Message::SendFail() << "Error in the DESTEP_Provider during reading the file " << thePath
+ << "\t: abandon, no model loaded";
+ return false;
+ }
+ aModel->SetLocalLengthUnit(aNode->GlobalParameters.LengthUnit);
+ if (aReader.TransferRoots() <= 0)
+ {
+ Message::SendFail() << "Error in the DESTEP_Provider during reading the file " << thePath
+ << "\t:Cannot read any relevant data from the STEP file";
+ return false;
+ }
+ theShape = aReader.OneShape();
+ return true;
+}
+
+//=================================================================================================
+
+bool DESTEP_Provider::Write(const TCollection_AsciiString& thePath,
+ const TopoDS_Shape& theShape,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DESTEP_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DESTEP_Provider during reading the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DESTEP_ConfigurationNode) aNode = Handle(DESTEP_ConfigurationNode)::DownCast(GetNode());
+
+ personizeWS(theWS);
+ STEPControl_Writer aWriter;
+ aWriter.SetWS(theWS);
+ IFSelect_ReturnStatus aWritestat = IFSelect_RetVoid;
+ Handle(StepData_StepModel) aModel = aWriter.Model();
+ ;
+ StepData_ConfParameters aParams = aNode->InternalParameters;
+ aModel->SetLocalLengthUnit(aNode->GlobalParameters.SystemUnit);
+ UnitsMethods_LengthUnit aTargetUnit =
+ UnitsMethods::GetLengthUnitByFactorValue(aNode->GlobalParameters.LengthUnit,
+ UnitsMethods_LengthUnit_Millimeter);
+ aParams.WriteUnit = aTargetUnit;
+ if (aTargetUnit == UnitsMethods_LengthUnit_Undefined)
+ {
+ aModel->SetWriteLengthUnit(1.0);
+ Message::SendWarning()
+ << "Custom units are not supported by STEP format, but LengthUnit global parameter doesn't "
+ "fit any predefined unit. Units will be scaled to Millimeters";
+ }
+ else
+ {
+ aModel->SetWriteLengthUnit(aNode->GlobalParameters.LengthUnit);
+ }
+ aWritestat = aWriter.Transfer(theShape,
+ aNode->InternalParameters.WriteModelType,
+ aParams,
+ true,
+ theProgress);
+ if (aWritestat != IFSelect_RetDone)
+ {
+ Message::SendFail() << "Error in the DESTEP_Provider during reading the file " << thePath
+ << "\t: abandon, no model loaded";
+ return false;
+ }
+ if (aWriter.Write(thePath.ToCString()) != IFSelect_RetDone)
+ {
+ Message::SendFail() << "DESTEP_Provider: Error on writing file";
+ return false;
+ }
+ return true;
+}
+
+//=================================================================================================
+
+bool DESTEP_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);
+}
+
+//=================================================================================================
+
+bool DESTEP_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);
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DESTEP_Provider::GetFormat() const
+{
+ return TCollection_AsciiString("STEP");
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DESTEP_Provider::GetVendor() const
+{
+ return TCollection_AsciiString("OCC");
+}
+
+//=================================================================================================
+
+void DESTEP_Provider::personizeWS(Handle(XSControl_WorkSession)& theWS)
+{
+ if (theWS.IsNull())
+ {
+ Message::SendWarning() << "Warning: DESTEP_Provider :"
+ << " Null work session, use internal temporary session";
+ theWS = new XSControl_WorkSession();
+ }
+ Handle(STEPCAFControl_Controller) aCntrl =
+ Handle(STEPCAFControl_Controller)::DownCast(theWS->NormAdaptor());
+ if (aCntrl.IsNull())
+ {
+ STEPCAFControl_Controller::Init();
+ theWS->SelectNorm("STEP");
+ }
+}
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _DESTEP_Provider_HeaderFile
+#define _DESTEP_Provider_HeaderFile
+
+#include <DESTEP_ConfigurationNode.hxx>
+#include <DE_Provider.hxx>
+
+//! The class to transfer STEP files.
+//! Reads and Writes any STEP files into/from OCCT.
+//! Each operation needs configuration node.
+//!
+//! Providers grouped by Vendor name and Format type.
+//! The Vendor name is "OCC"
+//! The Format type is "STEP"
+//! The import process is supported.
+//! The export process is supported.
+class DESTEP_Provider : public DE_Provider
+{
+public:
+ DEFINE_STANDARD_RTTIEXT(DESTEP_Provider, DE_Provider)
+
+public:
+ //! Default constructor
+ //! Configure translation process with global configuration
+ Standard_EXPORT DESTEP_Provider();
+
+ //! Configure translation process
+ //! @param[in] theNode object to copy
+ Standard_EXPORT DESTEP_Provider(const Handle(DE_ConfigurationNode)& theNode);
+
+public:
+ //! Reads a CAD file, according internal configuration
+ //! @param[in] thePath path to the import CAD file
+ //! @param[out] theDocument document to save result
+ //! @param[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Read operation has ended correctly
+ Standard_EXPORT virtual bool Read(
+ const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ 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[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Write operation has ended correctly
+ Standard_EXPORT virtual bool Write(
+ const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ 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[in] theProgress 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[in] theProgress 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
+ //! @param[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Read operation has ended correctly
+ Standard_EXPORT virtual bool Read(
+ const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ 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[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Write operation has ended correctly
+ Standard_EXPORT virtual bool Write(
+ const TCollection_AsciiString& thePath,
+ const TopoDS_Shape& theShape,
+ 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[in] theProgress 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[in] theProgress 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 CAD format
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
+
+ //! Gets provider's vendor name of associated provider
+ //! @return provider's vendor name
+ Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+
+private:
+ //! Personizes work session with current format.
+ //! Creates new temporary session if current session is null
+ //! @param[in] theWS current work session
+ void personizeWS(Handle(XSControl_WorkSession)& theWS);
+};
+
+#endif // _DESTEP_Provider_HeaderFile
--- /dev/null
+DESTEP_ConfigurationNode.cxx
+DESTEP_ConfigurationNode.hxx
+DESTEP_Provider.cxx
+DESTEP_Provider.hxx
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <DESTL_ConfigurationNode.hxx>
+
+#include <DESTL_Provider.hxx>
+#include <DE_ConfigurationContext.hxx>
+#include <DE_PluginHolder.hxx>
+#include <NCollection_Buffer.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(DESTL_ConfigurationNode, DE_ConfigurationNode)
+
+namespace
+{
+static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
+{
+ static const TCollection_AsciiString aScope = "provider";
+ return aScope;
+}
+
+// Wrapper to auto-load DE component
+DE_PluginHolder<DESTL_ConfigurationNode> THE_OCCT_STL_COMPONENT_PLUGIN;
+} // namespace
+
+//=================================================================================================
+
+DESTL_ConfigurationNode::DESTL_ConfigurationNode()
+ : DE_ConfigurationNode()
+{
+}
+
+//=================================================================================================
+
+DESTL_ConfigurationNode::DESTL_ConfigurationNode(const Handle(DESTL_ConfigurationNode)& theNode)
+ : DE_ConfigurationNode(theNode)
+{
+ InternalParameters = theNode->InternalParameters;
+}
+
+//=================================================================================================
+
+bool DESTL_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
+{
+ TCollection_AsciiString aScope =
+ THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
+
+ InternalParameters.ReadMergeAngle =
+ theResource->RealVal("read.merge.angle", InternalParameters.ReadMergeAngle, aScope);
+ InternalParameters.ReadBRep =
+ theResource->BooleanVal("read.brep", InternalParameters.ReadBRep, aScope);
+ InternalParameters.WriteAscii =
+ theResource->BooleanVal("write.ascii", InternalParameters.WriteAscii, aScope);
+ return true;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DESTL_ConfigurationNode::Save() const
+{
+ TCollection_AsciiString aResult;
+ aResult += "!*****************************************************************************\n";
+ aResult =
+ aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
+ TCollection_AsciiString aScope =
+ THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
+
+ aResult += "!\n";
+ aResult += "!Read parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Input merge angle value\n";
+ aResult += "!Default value (in degrees): 90.0. Angle should be within [0.0, 90.0] range\n";
+ aResult += aScope + "read.merge.angle :\t " + InternalParameters.ReadMergeAngle + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Setting up Boundary Representation flag\n";
+ aResult += "!Default value: false. Available values: \"on\", \"off\"\n";
+ aResult += aScope + "read.brep :\t " + InternalParameters.ReadBRep + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Write parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Setting up writing mode (Ascii or Binary)\n";
+ aResult += "!Default value: 1(Binary). Available values: 0(Ascii), 1(Binary)\n";
+ aResult += aScope + "write.ascii :\t " + InternalParameters.WriteAscii + "\n";
+ aResult += "!\n";
+
+ aResult += "!*****************************************************************************\n";
+ return aResult;
+}
+
+//=================================================================================================
+
+Handle(DE_ConfigurationNode) DESTL_ConfigurationNode::Copy() const
+{
+ return new DESTL_ConfigurationNode(*this);
+}
+
+//=================================================================================================
+
+Handle(DE_Provider) DESTL_ConfigurationNode::BuildProvider()
+{
+ return new DESTL_Provider(this);
+}
+
+//=================================================================================================
+
+bool DESTL_ConfigurationNode::IsImportSupported() const
+{
+ return true;
+}
+
+//=================================================================================================
+
+bool DESTL_ConfigurationNode::IsExportSupported() const
+{
+ return true;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DESTL_ConfigurationNode::GetFormat() const
+{
+ return TCollection_AsciiString("STL");
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DESTL_ConfigurationNode::GetVendor() const
+{
+ return TCollection_AsciiString("OCC");
+}
+
+//=================================================================================================
+
+TColStd_ListOfAsciiString DESTL_ConfigurationNode::GetExtensions() const
+{
+ TColStd_ListOfAsciiString anExt;
+ anExt.Append("stl");
+ return anExt;
+}
+
+//=================================================================================================
+
+bool DESTL_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
+{
+ if (theBuffer.IsNull() || theBuffer->Size() < 7)
+ {
+ return false;
+ }
+ const char* aBytes = (const char*)theBuffer->Data();
+ if (!(::strncmp(aBytes, "solid", 5) || ::strncmp(aBytes, "SOLID", 5)) && isspace(aBytes[5]))
+ {
+ return true;
+ }
+ // binary STL has no header for identification - format can be detected only by file extension
+ return false;
+}
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _DESTL_ConfigurationNode_HeaderFile
+#define _DESTL_ConfigurationNode_HeaderFile
+
+#include <DE_ConfigurationNode.hxx>
+
+//! The purpose of this class is to configure the transfer process for STL format
+//! Stores the necessary settings for DESTL_Provider.
+//! Configures and creates special provider to transfer STL files.
+//!
+//! Nodes grouped by Vendor name and Format type.
+//! The Vendor name is "OCC"
+//! The Format type is "STL"
+//! The supported CAD extension is ".stl"
+//! The import process is supported.
+//! The export process is supported.
+class DESTL_ConfigurationNode : public DE_ConfigurationNode
+{
+ DEFINE_STANDARD_RTTIEXT(DESTL_ConfigurationNode, DE_ConfigurationNode)
+public:
+ //! Initializes all field by default
+ Standard_EXPORT DESTL_ConfigurationNode();
+
+ //! Copies values of all fields
+ //! @param[in] theNode object to copy
+ Standard_EXPORT DESTL_ConfigurationNode(const Handle(DESTL_ConfigurationNode)& theNode);
+
+ //! Updates values according the resource
+ //! @param[in] theResource input resource to use
+ //! @return true if theResource loading has ended correctly
+ Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource)
+ Standard_OVERRIDE;
+
+ //! Writes configuration to the string
+ //! @return result resource string
+ Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
+
+ //! Copies values of all fields
+ //! @return new object with the same field values
+ Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
+
+ //! Creates new provider for the own format
+ //! @return new created provider
+ Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
+
+public:
+ //! Checks the import supporting
+ //! @return true if import is supported
+ Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
+
+ //! Checks the export supporting
+ //! @return true if export is supported
+ Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
+
+ //! Gets CAD format name of associated provider
+ //! @return provider CAD format
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
+
+ //! Gets provider's vendor name of associated provider
+ //! @return provider's vendor name
+ Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+
+ //! Gets list of supported file extensions
+ //! @return list of extensions
+ Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
+
+ //! Checks the file content to verify a format
+ //! @param[in] theBuffer read stream buffer to check content
+ //! @return Standard_True if file is supported by a current provider
+ Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
+ Standard_OVERRIDE;
+
+public:
+ struct RWStl_InternalSection
+ {
+ // Read
+ double ReadMergeAngle = 90.; //!< Input merge angle value
+ bool ReadBRep = false; //!< Setting up Boundary Representation flag
+
+ // Write
+ bool WriteAscii = true; //!< Setting up writing mode (Ascii or Binary)
+
+ } InternalParameters;
+};
+
+#endif // _DESTL_ConfigurationNode_HeaderFile
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <DESTL_Provider.hxx>
+
+#include <BRep_Builder.hxx>
+#include <DESTL_ConfigurationNode.hxx>
+#include <Message.hxx>
+#include <RWStl.hxx>
+#include <StlAPI.hxx>
+#include <StlAPI_Writer.hxx>
+#include <TDocStd_Document.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <XCAFDoc_ShapeTool.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(DESTL_Provider, DE_Provider)
+
+//=================================================================================================
+
+DESTL_Provider::DESTL_Provider() {}
+
+//=================================================================================================
+
+DESTL_Provider::DESTL_Provider(const Handle(DE_ConfigurationNode)& theNode)
+ : DE_Provider(theNode)
+{
+}
+
+//=================================================================================================
+
+bool DESTL_Provider::Read(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ (void)theWS;
+ return Read(thePath, theDocument, theProgress);
+}
+
+//=================================================================================================
+
+bool DESTL_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);
+}
+
+//=================================================================================================
+
+bool DESTL_Provider::Read(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ const Message_ProgressRange& theProgress)
+{
+ if (theDocument.IsNull())
+ {
+ Message::SendFail() << "Error in the DESTL_Provider during reading the file " << thePath
+ << "\t: theDocument shouldn't be null";
+ return false;
+ }
+ TopoDS_Shape aShape;
+ if (!Read(thePath, aShape, theProgress))
+ {
+ return false;
+ }
+ Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
+ aShapeTool->AddShape(aShape);
+ return true;
+}
+
+//=================================================================================================
+
+bool DESTL_Provider::Write(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ const Message_ProgressRange& theProgress)
+{
+ TopoDS_Shape aShape;
+ TDF_LabelSequence aLabels;
+ Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
+ aSTool->GetFreeShapes(aLabels);
+ if (aLabels.Length() <= 0)
+ {
+ Message::SendFail() << "Error in the DESTL_Provider during writing the file " << thePath
+ << "\t: Document contain no shapes";
+ return false;
+ }
+
+ Handle(DESTL_ConfigurationNode) aNode = Handle(DESTL_ConfigurationNode)::DownCast(GetNode());
+ if (aNode->GlobalParameters.LengthUnit != 1.0)
+ {
+ Message::SendWarning()
+ << "Warning in the DESTL_Provider during writing the file " << thePath
+ << "\t: Target Units for writing were changed, but current format doesn't support scaling";
+ }
+
+ if (aLabels.Length() == 1)
+ {
+ aShape = aSTool->GetShape(aLabels.Value(1));
+ }
+ else
+ {
+ TopoDS_Compound aComp;
+ BRep_Builder aBuilder;
+ aBuilder.MakeCompound(aComp);
+ for (Standard_Integer anIndex = 1; anIndex <= aLabels.Length(); anIndex++)
+ {
+ TopoDS_Shape aS = aSTool->GetShape(aLabels.Value(anIndex));
+ aBuilder.Add(aComp, aS);
+ }
+ aShape = aComp;
+ }
+ return Write(thePath, aShape, theProgress);
+}
+
+//=================================================================================================
+
+bool DESTL_Provider::Read(const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ (void)theWS;
+ return Read(thePath, theShape, theProgress);
+}
+
+//=================================================================================================
+
+bool DESTL_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);
+}
+
+//=================================================================================================
+
+bool DESTL_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(DESTL_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DESTL_Provider during reading the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return true;
+ }
+ Handle(DESTL_ConfigurationNode) aNode = Handle(DESTL_ConfigurationNode)::DownCast(GetNode());
+ double aMergeAngle = aNode->InternalParameters.ReadMergeAngle * M_PI / 180.0;
+ if (aMergeAngle != M_PI_2)
+ {
+ if (aMergeAngle < 0.0 || aMergeAngle > M_PI_2)
+ {
+ Message::SendFail() << "Error in the DESTL_Provider during reading the file " << thePath
+ << "\t: The merge angle is out of the valid range";
+ return false;
+ }
+ }
+ if (!aNode->InternalParameters.ReadBRep)
+ {
+ Handle(Poly_Triangulation) aTriangulation =
+ RWStl::ReadFile(thePath.ToCString(), aMergeAngle, theProgress);
+
+ TopoDS_Face aFace;
+ BRep_Builder aB;
+ aB.MakeFace(aFace);
+ aB.UpdateFace(aFace, aTriangulation);
+ theShape = aFace;
+ }
+ else
+ {
+ Standard_DISABLE_DEPRECATION_WARNINGS if (!StlAPI::Read(theShape, thePath.ToCString()))
+ {
+ Message::SendFail() << "Error in the DESTL_Provider during reading the file " << thePath;
+ return false;
+ }
+ Standard_ENABLE_DEPRECATION_WARNINGS
+ }
+ return true;
+}
+
+//=================================================================================================
+
+bool DESTL_Provider::Write(const TCollection_AsciiString& thePath,
+ const TopoDS_Shape& theShape,
+ const Message_ProgressRange& theProgress)
+{
+ Message::SendWarning()
+ << "OCCT Stl writer does not support model scaling according to custom length unit";
+ if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DESTL_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DESTL_Provider during reading the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DESTL_ConfigurationNode) aNode = Handle(DESTL_ConfigurationNode)::DownCast(GetNode());
+ if (aNode->GlobalParameters.LengthUnit != 1.0)
+ {
+ Message::SendWarning()
+ << "Warning in the DESTL_Provider during writing the file " << thePath
+ << "\t: Target Units for writing were changed, but current format doesn't support scaling";
+ }
+
+ StlAPI_Writer aWriter;
+ aWriter.ASCIIMode() = aNode->InternalParameters.WriteAscii;
+ if (!aWriter.Write(theShape, thePath.ToCString(), theProgress))
+ {
+ Message::SendFail() << "Error in the DESTL_Provider during reading the file " << thePath
+ << "\t: Mesh writing has been failed";
+ return false;
+ }
+ return true;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DESTL_Provider::GetFormat() const
+{
+ return TCollection_AsciiString("STL");
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DESTL_Provider::GetVendor() const
+{
+ return TCollection_AsciiString("OCC");
+}
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _DESTL_Provider_HeaderFile
+#define _DESTL_Provider_HeaderFile
+
+#include <DE_Provider.hxx>
+
+//! The class to transfer STL files.
+//! Reads and Writes any STL files into/from OCCT.
+//! Each operation needs configuration node.
+//!
+//! Providers grouped by Vendor name and Format type.
+//! The Vendor name is "OCC"
+//! The Format type is "STL"
+//! The import process is supported.
+//! The export process is supported.
+class DESTL_Provider : public DE_Provider
+{
+public:
+ DEFINE_STANDARD_RTTIEXT(DESTL_Provider, DE_Provider)
+
+public:
+
+ //! Default constructor
+ //! Configure translation process with global configuration
+ Standard_EXPORT DESTL_Provider();
+
+ //! Configure translation process
+ //! @param[in] theNode object to copy
+ Standard_EXPORT DESTL_Provider(const Handle(DE_ConfigurationNode)& theNode);
+
+public:
+
+ //! Reads a CAD file, according internal configuration
+ //! @param[in] thePath path to the import CAD file
+ //! @param[out] theDocument document to save result
+ //! @param[in] theWS current work session
+ //! @param[in] theProgress 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,
+ 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[in] theWS current work session
+ //! @param[in] theProgress 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,
+ 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[in] theProgress 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[in] theProgress 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
+ //! @param[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Read operation has ended correctly
+ Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ 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[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Write operation has ended correctly
+ Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
+ const TopoDS_Shape& theShape,
+ 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[in] theProgress 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[in] theProgress 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
+ //! @return provider CAD format
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
+
+ //! Gets provider's vendor name of associated provider
+ //! @return provider's vendor name
+ Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+};
+
+#endif // _DESTL_Provider_HeaderFile
--- /dev/null
+DESTL_ConfigurationNode.cxx
+DESTL_ConfigurationNode.hxx
+DESTL_Provider.cxx
+DESTL_Provider.hxx
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <DEVRML_ConfigurationNode.hxx>
+
+#include <DEVRML_Provider.hxx>
+#include <DE_ConfigurationContext.hxx>
+#include <DE_PluginHolder.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(DEVRML_ConfigurationNode, DE_ConfigurationNode)
+
+namespace
+{
+static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
+{
+ static const TCollection_AsciiString aScope = "provider";
+ return aScope;
+}
+
+// Wrapper to auto-load DE component
+DE_PluginHolder<DEVRML_ConfigurationNode> THE_OCCT_VRML_COMPONENT_PLUGIN;
+} // namespace
+
+//=================================================================================================
+
+DEVRML_ConfigurationNode::DEVRML_ConfigurationNode()
+ : DE_ConfigurationNode()
+{
+}
+
+//=================================================================================================
+
+DEVRML_ConfigurationNode::DEVRML_ConfigurationNode(const Handle(DEVRML_ConfigurationNode)& theNode)
+ : DE_ConfigurationNode(theNode)
+{
+ InternalParameters = theNode->InternalParameters;
+}
+
+//=================================================================================================
+
+bool DEVRML_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
+{
+ TCollection_AsciiString aScope =
+ THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
+
+ InternalParameters.ReadFileUnit =
+ theResource->RealVal("read.file.unit", InternalParameters.ReadFileUnit, aScope);
+ InternalParameters.ReadFileCoordinateSys =
+ (RWMesh_CoordinateSystem)theResource->IntegerVal("read.file.coordinate.system",
+ InternalParameters.ReadFileCoordinateSys,
+ aScope);
+ InternalParameters.ReadSystemCoordinateSys =
+ (RWMesh_CoordinateSystem)theResource->IntegerVal("read.system.coordinate.system",
+ InternalParameters.ReadSystemCoordinateSys,
+ aScope);
+ InternalParameters.ReadFillIncomplete =
+ theResource->BooleanVal("read.fill.incomplete", InternalParameters.ReadFillIncomplete, aScope);
+
+ InternalParameters.WriterVersion =
+ (WriteMode_WriterVersion)theResource->IntegerVal("writer.version",
+ InternalParameters.WriterVersion,
+ aScope);
+ InternalParameters.WriteRepresentationType =
+ (WriteMode_RepresentationType)theResource->IntegerVal(
+ "write.representation.type",
+ InternalParameters.WriteRepresentationType,
+ aScope);
+
+ return true;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEVRML_ConfigurationNode::Save() const
+{
+ TCollection_AsciiString aResult;
+ aResult += "!*****************************************************************************\n";
+ aResult =
+ aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
+ TCollection_AsciiString aScope =
+ THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
+
+ aResult += "!\n";
+ aResult += "!Read parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Set (override) file length units to convert from while reading the file, defined as "
+ "scale factor for m (meters).\n";
+ aResult += "!Default value: 1. Available values: positive double\n";
+ aResult += aScope + "read.file.unit :\t " + InternalParameters.ReadFileUnit + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Set (override) file origin coordinate system to perform conversion during read.\n";
+ aResult += "!Default value: Yup (1). { Zup (0) | Yup (1) }\n";
+ aResult +=
+ aScope + "read.file.coordinate.system :\t " + InternalParameters.ReadFileCoordinateSys + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Set system origin coordinate system to perform conversion into during read.\n";
+ aResult += "!Default value: Zup (0). Available values: { Zup (0) | Yup (1) }\n";
+ aResult += aScope + "read.system.coordinate.system :\t "
+ + InternalParameters.ReadSystemCoordinateSys + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Set flag allowing partially read file content to be put into the XDE document.\n";
+ aResult += "!Default value: 1(\"ON\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
+ aResult += aScope + "read.fill.incomplete :\t " + InternalParameters.ReadFillIncomplete + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Write parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Setting up writer version.\n";
+ aResult += "!Default value: 2. Available values: 1, 2\n";
+ aResult += aScope + "writer.version :\t " + InternalParameters.WriterVersion + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Setting up representation\n";
+ aResult += "!Default value: 1. Available values: 0(shaded), 1(wireframe), 2(both).\n";
+ aResult +=
+ aScope + "write.representation.type :\t " + InternalParameters.WriteRepresentationType + "\n";
+ aResult += "!\n";
+
+ aResult += "!*****************************************************************************\n";
+ return aResult;
+}
+
+//=================================================================================================
+
+Handle(DE_ConfigurationNode) DEVRML_ConfigurationNode::Copy() const
+{
+ return new DEVRML_ConfigurationNode(*this);
+}
+
+//=================================================================================================
+
+Handle(DE_Provider) DEVRML_ConfigurationNode::BuildProvider()
+{
+ return new DEVRML_Provider(this);
+}
+
+//=================================================================================================
+
+bool DEVRML_ConfigurationNode::IsImportSupported() const
+{
+ return true;
+}
+
+//=================================================================================================
+
+bool DEVRML_ConfigurationNode::IsExportSupported() const
+{
+ return true;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEVRML_ConfigurationNode::GetFormat() const
+{
+ return TCollection_AsciiString("VRML");
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEVRML_ConfigurationNode::GetVendor() const
+{
+ return TCollection_AsciiString("OCC");
+}
+
+//=================================================================================================
+
+TColStd_ListOfAsciiString DEVRML_ConfigurationNode::GetExtensions() const
+{
+ TColStd_ListOfAsciiString anExt;
+ anExt.Append("vrml");
+ anExt.Append("wrl");
+ return anExt;
+}
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _DEVRML_ConfigurationNode_HeaderFile
+#define _DEVRML_ConfigurationNode_HeaderFile
+
+#include <DE_ConfigurationNode.hxx>
+#include <RWMesh_CoordinateSystem.hxx>
+
+//! The purpose of this class is to configure the transfer process for VRML format
+//! Stores the necessary settings for DEVRML_Provider.
+//! Configures and creates special provider to transfer VRML files.
+//!
+//! Nodes grouped by Vendor name and Format type.
+//! The Vendor name is "OCC"
+//! The Format type is "VRML"
+//! The supported CAD extensions are ".vrml", ".wrl"
+//! The import process is supported.
+//! The export process is supported.
+class DEVRML_ConfigurationNode : public DE_ConfigurationNode
+{
+ DEFINE_STANDARD_RTTIEXT(DEVRML_ConfigurationNode, DE_ConfigurationNode)
+public:
+ //! Initializes all field by default
+ Standard_EXPORT DEVRML_ConfigurationNode();
+
+ //! Copies values of all fields
+ //! @param[in] theNode object to copy
+ Standard_EXPORT DEVRML_ConfigurationNode(const Handle(DEVRML_ConfigurationNode)& theNode);
+
+ //! Updates values according the resource
+ //! @param[in] theResource input resource to use
+ //! @return true if theResource loading has ended correctly
+ Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource)
+ Standard_OVERRIDE;
+
+ //! Writes configuration to the string
+ //! @return result resource string
+ Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
+
+ //! Copies values of all fields
+ //! @return new object with the same field values
+ Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
+
+ //! Creates new provider for the own format
+ //! @return new created provider
+ Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
+
+public:
+ //! Checks the import supporting
+ //! @return true if import is supported
+ Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
+
+ //! Checks the export supporting
+ //! @return true if export is supported
+ Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
+
+ //! Gets CAD format name of associated provider
+ //! @return provider CAD format
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
+
+ //! Gets provider's vendor name of associated provider
+ //! @return provider's vendor name
+ Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+
+ //! Gets list of supported file extensions
+ //! @return list of extensions
+ Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
+
+public:
+ enum WriteMode_WriterVersion
+ {
+ WriteMode_WriterVersion_1 = 1,
+ WriteMode_WriterVersion_2
+ };
+
+ enum WriteMode_RepresentationType
+ {
+ WriteMode_RepresentationType_Shaded = 0,
+ WriteMode_RepresentationType_Wireframe,
+ WriteMode_RepresentationType_Both
+ };
+
+ struct Vrml_InternalSection
+ {
+ // Read
+ // clang-format off
+ double ReadFileUnit = 1.; //<! file length units to convert from while reading the file, defined as scale factor for meters
+ RWMesh_CoordinateSystem ReadFileCoordinateSys = RWMesh_CoordinateSystem_Yup; //<! coordinate system defined by Vrml file
+ RWMesh_CoordinateSystem ReadSystemCoordinateSys = RWMesh_CoordinateSystem_Zup; //<! result coordinate system
+ bool ReadFillIncomplete = true; //<! fill the document with partially retrieved data even if reader has failed with error
+
+ // Write
+ WriteMode_WriterVersion WriterVersion = WriteMode_WriterVersion_2; //!< Setting up writer version (1/2)
+ WriteMode_RepresentationType WriteRepresentationType = WriteMode_RepresentationType_Wireframe; //!< Setting up representation (shaded/wireframe/both)
+ // clang-format on
+
+ } InternalParameters;
+};
+
+#endif // _DEVRML_ConfigurationNode_HeaderFile
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <DEVRML_Provider.hxx>
+
+#include <DEVRML_ConfigurationNode.hxx>
+#include <Message.hxx>
+#include <OSD_Path.hxx>
+#include <TDocStd_Document.hxx>
+#include <VrmlAPI_CafReader.hxx>
+#include <VrmlAPI_Writer.hxx>
+#include <VrmlData_Scene.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <XCAFDoc_ShapeTool.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(DEVRML_Provider, DE_Provider)
+
+//=================================================================================================
+
+DEVRML_Provider::DEVRML_Provider() {}
+
+//=================================================================================================
+
+DEVRML_Provider::DEVRML_Provider(const Handle(DE_ConfigurationNode)& theNode)
+ : DE_Provider(theNode)
+{
+}
+
+//=================================================================================================
+
+bool DEVRML_Provider::Read(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ (void)theWS;
+ return Read(thePath, theDocument, theProgress);
+}
+
+//=================================================================================================
+
+bool DEVRML_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);
+}
+
+//=================================================================================================
+
+bool DEVRML_Provider::Read(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ const Message_ProgressRange& theProgress)
+{
+ if (theDocument.IsNull())
+ {
+ Message::SendFail() << "Error in the DEVRML_Provider during reading the file " << thePath
+ << "\t: theDocument shouldn't be null";
+ return false;
+ }
+ if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEVRML_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DEVRML_Provider during reading the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DEVRML_ConfigurationNode) aNode = Handle(DEVRML_ConfigurationNode)::DownCast(GetNode());
+
+ VrmlAPI_CafReader aVrmlReader;
+ aVrmlReader.SetDocument(theDocument);
+ aVrmlReader.SetFileLengthUnit(aNode->InternalParameters.ReadFileUnit);
+ aVrmlReader.SetSystemLengthUnit(aNode->GlobalParameters.LengthUnit);
+ aVrmlReader.SetFileCoordinateSystem(aNode->InternalParameters.ReadFileCoordinateSys);
+ aVrmlReader.SetSystemCoordinateSystem(aNode->InternalParameters.ReadSystemCoordinateSys);
+ aVrmlReader.SetFillIncompleteDocument(aNode->InternalParameters.ReadFillIncomplete);
+
+ XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->InternalParameters.ReadFileUnit);
+
+ if (!aVrmlReader.Perform(thePath, theProgress))
+ {
+ if (aVrmlReader.ExtraStatus() != RWMesh_CafReaderStatusEx_Partial)
+ {
+ Message::SendFail() << "Error in the DEVRML_Provider during reading the file '" << thePath
+ << "'";
+ return false;
+ }
+ Message::SendWarning()
+ << "Warning in the DEVRML_Provider during reading the file: file has been read paratially "
+ << "(due to unexpected EOF, syntax error, memory limit) '" << thePath << "'";
+ }
+ return true;
+}
+
+//=================================================================================================
+
+bool DEVRML_Provider::Write(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ const Message_ProgressRange& theProgress)
+{
+ (void)theProgress;
+ if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEVRML_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DEVRML_Provider during writing the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DEVRML_ConfigurationNode) aNode = Handle(DEVRML_ConfigurationNode)::DownCast(GetNode());
+
+ VrmlAPI_Writer aWriter;
+ aWriter.SetRepresentation(
+ static_cast<VrmlAPI_RepresentationOfShape>(aNode->InternalParameters.WriteRepresentationType));
+ Standard_Real aScaling = 1.;
+ Standard_Real aScaleFactorMM = 1.;
+ if (XCAFDoc_DocumentTool::GetLengthUnit(theDocument,
+ aScaleFactorMM,
+ UnitsMethods_LengthUnit_Millimeter))
+ {
+ aScaling = aScaleFactorMM / aNode->GlobalParameters.LengthUnit;
+ }
+ else
+ {
+ aScaling = aNode->GlobalParameters.SystemUnit / aNode->GlobalParameters.LengthUnit;
+ Message::SendWarning()
+ << "Warning in the DEVRML_Provider during writing the file " << thePath
+ << "\t: The document has no information on Units. Using global parameter as initial Unit.";
+ }
+ if (!aWriter.WriteDoc(theDocument, thePath.ToCString(), aScaling))
+ {
+ Message::SendFail() << "Error in the DEVRML_Provider during wtiting the file " << thePath
+ << "\t: File was not written";
+ return false;
+ }
+
+ return true;
+}
+
+//=================================================================================================
+
+bool DEVRML_Provider::Read(const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ (void)theWS;
+ return Read(thePath, theShape, theProgress);
+}
+
+//=================================================================================================
+
+bool DEVRML_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);
+}
+
+//=================================================================================================
+
+bool DEVRML_Provider::Read(const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ const Message_ProgressRange& theProgress)
+{
+ (void)theProgress;
+ if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEVRML_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DEVRML_Provider during reading the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DEVRML_ConfigurationNode) aNode = Handle(DEVRML_ConfigurationNode)::DownCast(GetNode());
+
+ TopoDS_Shape aShape;
+ VrmlData_DataMapOfShapeAppearance aShapeAppMap;
+
+ std::filebuf aFic;
+ std::istream aStream(&aFic);
+
+ if (aFic.open(thePath.ToCString(), std::ios::in))
+ {
+ // Get path of the VRML file.
+ OSD_Path aPath(thePath.ToCString());
+ TCollection_AsciiString aVrmlDir(".");
+ TCollection_AsciiString aDisk = aPath.Disk();
+ TCollection_AsciiString aTrek = aPath.Trek();
+ if (!aTrek.IsEmpty())
+ {
+ if (!aDisk.IsEmpty())
+ {
+ aVrmlDir = aDisk;
+ }
+ else
+ {
+ aVrmlDir.Clear();
+ }
+ aTrek.ChangeAll('|', '/');
+ aVrmlDir += aTrek;
+ }
+
+ VrmlData_Scene aScene;
+ aScene.SetLinearScale(aNode->GlobalParameters.LengthUnit);
+
+ aScene.SetVrmlDir(aVrmlDir);
+ aScene << aStream;
+ const char* aStr = 0L;
+ switch (aScene.Status())
+ {
+ case VrmlData_StatusOK: {
+ aShape = aScene.GetShape(aShapeAppMap);
+ break;
+ }
+ case VrmlData_EmptyData:
+ aStr = "EmptyData";
+ break;
+ case VrmlData_UnrecoverableError:
+ aStr = "UnrecoverableError";
+ break;
+ case VrmlData_GeneralError:
+ aStr = "GeneralError";
+ break;
+ case VrmlData_EndOfFile:
+ aStr = "EndOfFile";
+ break;
+ case VrmlData_NotVrmlFile:
+ aStr = "NotVrmlFile";
+ break;
+ case VrmlData_CannotOpenFile:
+ aStr = "CannotOpenFile";
+ break;
+ case VrmlData_VrmlFormatError:
+ aStr = "VrmlFormatError";
+ break;
+ case VrmlData_NumericInputError:
+ aStr = "NumericInputError";
+ break;
+ case VrmlData_IrrelevantNumber:
+ aStr = "IrrelevantNumber";
+ break;
+ case VrmlData_BooleanInputError:
+ aStr = "BooleanInputError";
+ break;
+ case VrmlData_StringInputError:
+ aStr = "StringInputError";
+ break;
+ case VrmlData_NodeNameUnknown:
+ aStr = "NodeNameUnknown";
+ break;
+ case VrmlData_NonPositiveSize:
+ aStr = "NonPositiveSize";
+ break;
+ case VrmlData_ReadUnknownNode:
+ aStr = "ReadUnknownNode";
+ break;
+ case VrmlData_NonSupportedFeature:
+ aStr = "NonSupportedFeature";
+ break;
+ case VrmlData_OutputStreamUndefined:
+ aStr = "OutputStreamUndefined";
+ break;
+ case VrmlData_NotImplemented:
+ aStr = "NotImplemented";
+ break;
+ default:
+ break;
+ }
+ if (aStr)
+ {
+ Message::SendFail() << "Error in the DEVRML_Provider during reading the file " << thePath
+ << "\t: ++ VRML Error: " << aStr << " in line " << aScene.GetLineError();
+ return false;
+ }
+ else
+ {
+ theShape = aShape;
+ }
+ }
+ else
+ {
+ Message::SendFail() << "Error in the DEVRML_Provider during reading the file " << thePath
+ << "\t: cannot open file";
+ return false;
+ }
+ return true;
+}
+
+//=================================================================================================
+
+bool DEVRML_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);
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEVRML_Provider::GetFormat() const
+{
+ return TCollection_AsciiString("VRML");
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEVRML_Provider::GetVendor() const
+{
+ return TCollection_AsciiString("OCC");
+}
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _DEVRML_Provider_HeaderFile
+#define _DEVRML_Provider_HeaderFile
+
+#include <DE_Provider.hxx>
+
+//! The class to transfer VRML files.
+//! Reads and Writes any VRML files into/from OCCT.
+//! Each operation needs configuration node.
+//!
+//! Providers grouped by Vendor name and Format type.
+//! The Vendor name is "OCC"
+//! The Format type is "VRML"
+//! The import process is supported.
+//! The export process is supported.
+class DEVRML_Provider : public DE_Provider
+{
+public:
+ DEFINE_STANDARD_RTTIEXT(DEVRML_Provider, DE_Provider)
+
+public:
+ //! Default constructor
+ //! Configure translation process with global configuration
+ Standard_EXPORT DEVRML_Provider();
+
+ //! Configure translation process
+ //! @param[in] theNode object to copy
+ Standard_EXPORT DEVRML_Provider(const Handle(DE_ConfigurationNode)& theNode);
+
+public:
+ //! Reads a CAD file, according internal configuration
+ //! @param[in] thePath path to the import CAD file
+ //! @param[out] theDocument document to save result
+ //! @param[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Read operation has ended correctly
+ Standard_EXPORT virtual bool Read(
+ const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ 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[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Write operation has ended correctly
+ Standard_EXPORT virtual bool Write(
+ const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ 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[in] theProgress 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[in] theProgress 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
+ //! @param[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Read operation has ended correctly
+ Standard_EXPORT virtual bool Read(
+ const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ 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[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Write operation has ended correctly
+ Standard_EXPORT virtual bool Write(
+ const TCollection_AsciiString& thePath,
+ const TopoDS_Shape& theShape,
+ 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[in] theProgress 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[in] theProgress 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 CAD format
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
+
+ //! Gets provider's vendor name of associated provider
+ //! @return provider's vendor name
+ Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+};
+
+#endif // _DEVRML_Provider_HeaderFile
--- /dev/null
+DEVRML_ConfigurationNode.cxx
+DEVRML_ConfigurationNode.hxx
+DEVRML_Provider.cxx
+DEVRML_Provider.hxx
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <DEXCAF_ConfigurationNode.hxx>
+
+#include <DEXCAF_Provider.hxx>
+#include <DE_ConfigurationContext.hxx>
+#include <DE_PluginHolder.hxx>
+#include <NCollection_Buffer.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(DEXCAF_ConfigurationNode, DE_ConfigurationNode)
+
+namespace
+{
+static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
+{
+ static const TCollection_AsciiString aScope = "provider";
+ return aScope;
+}
+
+// Wrapper to auto-load DE component
+DE_PluginHolder<DEXCAF_ConfigurationNode> THE_OCCT_XCAF_COMPONENT_PLUGIN;
+} // namespace
+
+//=================================================================================================
+
+DEXCAF_ConfigurationNode::DEXCAF_ConfigurationNode()
+ : DE_ConfigurationNode()
+{
+}
+
+//=================================================================================================
+
+DEXCAF_ConfigurationNode::DEXCAF_ConfigurationNode(const Handle(DEXCAF_ConfigurationNode)& theNode)
+ : DE_ConfigurationNode(theNode)
+{
+ InternalParameters = theNode->InternalParameters;
+}
+
+//=================================================================================================
+
+bool DEXCAF_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
+{
+ TCollection_AsciiString aScope =
+ THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
+
+ InternalParameters.ReadAppendMode =
+ (PCDM_ReaderFilter::AppendMode)theResource->IntegerVal("read.append.mode",
+ InternalParameters.ReadAppendMode,
+ aScope);
+ theResource->GetStringSeq("read.skip.values", InternalParameters.ReadSkipValues, aScope);
+ theResource->GetStringSeq("read.values", InternalParameters.ReadValues, aScope);
+
+ return true;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEXCAF_ConfigurationNode::Save() const
+{
+ TCollection_AsciiString aResult;
+ aResult += "!*****************************************************************************\n";
+ aResult =
+ aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
+ TCollection_AsciiString aScope =
+ THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
+
+ aResult += "!\n";
+ aResult += "!Read parameters:\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Don't allow append (when the value = 0, it is the default value), ";
+ aResult += "keeps existing attributes, reads only new ones(when the value = 1), ";
+ aResult += "overwrites the existing attributes by the loaded ones(when the value = 2)\n";
+ aResult += "!Default value: 0. Available values: 0, 1, 2\n";
+ aResult += aScope + "read.append.mode :\t " + InternalParameters.ReadAppendMode + "\n";
+ aResult += "!\n";
+
+ aResult += "!\n";
+ aResult += "!Overwrites the existing attributes by the loaded ones";
+ aResult += "!Default value: empty. Available values: {sequence<string>}\n";
+ aResult += aScope + "read.skip.values :\t ";
+ for (TColStd_ListOfAsciiString::Iterator anIt(InternalParameters.ReadSkipValues); anIt.More();
+ anIt.Next())
+ {
+ aResult += anIt.Value() + " ";
+ }
+ aResult += "\n!\n";
+
+ aResult += "!\n";
+ aResult += "!1) Adds sub-tree path like \"0:2\"";
+ aResult += "2) Adds attribute to read by typename. Disables the skipped attributes added. (there "
+ "shouldn't be '0' after -read)\n";
+ aResult += "!Default value: empty. Available values: {sequence<string>}\n";
+ aResult += aScope + "read.values :\t ";
+ for (TColStd_ListOfAsciiString::Iterator anIt(InternalParameters.ReadValues); anIt.More();
+ anIt.Next())
+ {
+ aResult += anIt.Value() + " ";
+ }
+ aResult += "\n!\n";
+
+ aResult += "!*****************************************************************************\n";
+ return aResult;
+}
+
+//=================================================================================================
+
+Handle(DE_ConfigurationNode) DEXCAF_ConfigurationNode::Copy() const
+{
+ return new DEXCAF_ConfigurationNode(*this);
+}
+
+//=================================================================================================
+
+Handle(DE_Provider) DEXCAF_ConfigurationNode::BuildProvider()
+{
+ return new DEXCAF_Provider(this);
+}
+
+//=================================================================================================
+
+bool DEXCAF_ConfigurationNode::IsImportSupported() const
+{
+ return true;
+}
+
+//=================================================================================================
+
+bool DEXCAF_ConfigurationNode::IsExportSupported() const
+{
+ return true;
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEXCAF_ConfigurationNode::GetFormat() const
+{
+ return TCollection_AsciiString("XCAF");
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEXCAF_ConfigurationNode::GetVendor() const
+{
+ return TCollection_AsciiString("OCC");
+}
+
+//=================================================================================================
+
+TColStd_ListOfAsciiString DEXCAF_ConfigurationNode::GetExtensions() const
+{
+ TColStd_ListOfAsciiString anExt;
+ anExt.Append("xbf");
+ return anExt;
+}
+
+//=================================================================================================
+
+bool DEXCAF_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
+{
+ if (theBuffer.IsNull() || theBuffer->Size() < 8)
+ {
+ return false;
+ }
+ const char* aBytes = (const char*)theBuffer->Data();
+ if (!::strncmp(aBytes, "BINFILE", 7))
+ {
+ return true;
+ }
+ return false;
+}
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _DEXCAF_ConfigurationNode_HeaderFile
+#define _DEXCAF_ConfigurationNode_HeaderFile
+
+#include <DE_ConfigurationNode.hxx>
+#include <PCDM_ReaderFilter.hxx>
+#include <TColStd_ListOfAsciiString.hxx>
+
+//! The purpose of this class is to configure the transfer process for XDE Documents
+//! Stores the necessary settings for DEXCAF_Provider.
+//! Configures and creates special provider to transfer XDE Documents.
+//!
+//! Nodes grouped by Vendor name and Format type.
+//! The Vendor name is "OCC"
+//! The Format type is "XCAF"
+//! The supported CAD extension is ".xbf"
+//! The import process is supported.
+//! The export process is supported.
+class DEXCAF_ConfigurationNode : public DE_ConfigurationNode
+{
+ DEFINE_STANDARD_RTTIEXT(DEXCAF_ConfigurationNode, DE_ConfigurationNode)
+public:
+ //! Initializes all field by default
+ Standard_EXPORT DEXCAF_ConfigurationNode();
+
+ //! Copies values of all fields
+ //! @param[in] theNode object to copy
+ Standard_EXPORT DEXCAF_ConfigurationNode(const Handle(DEXCAF_ConfigurationNode)& theNode);
+
+ //! Updates values according the resource
+ //! @param[in] theResource input resource to use
+ //! @return true if theResource loading has ended correctly
+ Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource)
+ Standard_OVERRIDE;
+
+ //! Writes configuration to the string
+ //! @return result resource string
+ Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
+
+ //! Copies values of all fields
+ //! @return new object with the same field values
+ Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
+
+ //! Creates new provider for the own format
+ //! @return new created provider
+ Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
+
+public:
+ //! Checks the import supporting
+ //! @return true if import is supported
+ Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
+
+ //! Checks the export supporting
+ //! @return true if export is supported
+ Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
+
+ //! Gets CAD format name of associated provider
+ //! @return provider CAD format
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
+
+ //! Gets provider's vendor name of associated provider
+ //! @return provider's vendor name
+ Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+
+ //! Gets list of supported file extensions
+ //! @return list of extensions
+ Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
+
+ //! Checks the file content to verify a format
+ //! @param[in] theBuffer read stream buffer to check content
+ //! @return Standard_True if file is supported by a current provider
+ Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
+ Standard_OVERRIDE;
+
+public:
+ struct XCAFDoc_InternalSection
+ {
+ // Read
+ // clang-format off
+ PCDM_ReaderFilter::AppendMode ReadAppendMode = PCDM_ReaderFilter::AppendMode::AppendMode_Forbid; //!< Setting up the append mode
+ TColStd_ListOfAsciiString ReadSkipValues; //!< Overwrites the existing attributes by the loaded ones
+ TColStd_ListOfAsciiString ReadValues; //!< Adds sub-tree path or adds attribute to read by typename
+ // clang-format on
+
+ } InternalParameters;
+};
+
+#endif // _DEXCAF_ConfigurationNode_HeaderFile
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <DEXCAF_Provider.hxx>
+
+#include <BinDrivers.hxx>
+#include <BinLDrivers.hxx>
+#include <BinTObjDrivers.hxx>
+#include <BinXCAFDrivers.hxx>
+#include <StdDrivers.hxx>
+#include <StdLDrivers.hxx>
+#include <XmlDrivers.hxx>
+#include <XmlLDrivers.hxx>
+#include <XmlTObjDrivers.hxx>
+#include <XmlXCAFDrivers.hxx>
+
+#include <BRep_Builder.hxx>
+#include <DEXCAF_ConfigurationNode.hxx>
+#include <Message.hxx>
+#include <TDocStd_Application.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <XCAFDoc_ShapeTool.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(DEXCAF_Provider, DE_Provider)
+
+//=================================================================================================
+
+DEXCAF_Provider::DEXCAF_Provider() {}
+
+//=================================================================================================
+
+DEXCAF_Provider::DEXCAF_Provider(const Handle(DE_ConfigurationNode)& theNode)
+ : DE_Provider(theNode)
+{
+}
+
+//=================================================================================================
+
+bool DEXCAF_Provider::Read(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ (void)theWS;
+ return Read(thePath, theDocument, theProgress);
+}
+
+//=================================================================================================
+
+bool DEXCAF_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);
+}
+
+//=================================================================================================
+
+bool DEXCAF_Provider::Read(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ const Message_ProgressRange& theProgress)
+{
+ if (theDocument.IsNull())
+ {
+ Message::SendFail() << "Error in the DEXCAF_Provider during reading the file " << thePath
+ << "\t: theDocument shouldn't be null";
+ return false;
+ }
+ if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEXCAF_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DEXCAF_Provider during reading the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(DEXCAF_ConfigurationNode) aNode = Handle(DEXCAF_ConfigurationNode)::DownCast(GetNode());
+ Handle(TDocStd_Document) aDocument;
+ Handle(TDocStd_Application) anApp = new TDocStd_Application();
+ BinDrivers::DefineFormat(anApp);
+ BinLDrivers::DefineFormat(anApp);
+ BinTObjDrivers::DefineFormat(anApp);
+ BinXCAFDrivers::DefineFormat(anApp);
+ StdDrivers::DefineFormat(anApp);
+ StdLDrivers::DefineFormat(anApp);
+ XmlDrivers::DefineFormat(anApp);
+ XmlLDrivers::DefineFormat(anApp);
+ XmlTObjDrivers::DefineFormat(anApp);
+ XmlXCAFDrivers::DefineFormat(anApp);
+ Handle(PCDM_ReaderFilter) aFilter =
+ new PCDM_ReaderFilter(aNode->InternalParameters.ReadAppendMode);
+ for (TColStd_ListOfAsciiString::Iterator anIt(aNode->InternalParameters.ReadSkipValues);
+ anIt.More();
+ anIt.Next())
+ {
+ aFilter->AddSkipped(anIt.Value());
+ }
+ for (TColStd_ListOfAsciiString::Iterator anIt(aNode->InternalParameters.ReadValues); anIt.More();
+ anIt.Next())
+ {
+ if (anIt.Value().StartsWith("0"))
+ {
+ aFilter->AddPath(anIt.Value());
+ }
+ else
+ {
+ aFilter->AddRead(anIt.Value());
+ }
+ }
+
+ if (anApp->Open(thePath, aDocument, aFilter, theProgress) != PCDM_RS_OK)
+ {
+ Message::SendFail() << "Error in the DEXCAF_Provider during reading the file : " << thePath
+ << "\t: Cannot open XDE document";
+ return false;
+ }
+ theDocument->SetData(aDocument->GetData());
+ return true;
+}
+
+//=================================================================================================
+
+bool DEXCAF_Provider::Write(const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ const Message_ProgressRange& theProgress)
+{
+ Handle(TDocStd_Application) anApp = new TDocStd_Application();
+ BinXCAFDrivers::DefineFormat(anApp);
+
+ Handle(DEXCAF_ConfigurationNode) aNode = Handle(DEXCAF_ConfigurationNode)::DownCast(GetNode());
+ if (aNode->GlobalParameters.LengthUnit != 1.0)
+ {
+ Message::SendWarning()
+ << "Warning in the DEXCAF_Provider during writing the file " << thePath
+ << "\t: Target Units for writing were changed, but current format doesn't support scaling";
+ }
+
+ PCDM_StoreStatus aStatus = PCDM_SS_Doc_IsNull;
+ if (!thePath.IsEmpty())
+ {
+ aStatus = anApp->SaveAs(theDocument, thePath, theProgress);
+ }
+ else if (!theDocument->IsSaved())
+ {
+ Message::SendFail() << "Storage error in the DEXCAF_Provider during writing the file "
+ << thePath << "\t: Storage error : this document has never been saved";
+ return false;
+ }
+ else
+ {
+ aStatus = anApp->Save(theDocument, theProgress);
+ }
+
+ switch (aStatus)
+ {
+ case PCDM_SS_OK:
+ return true;
+ case PCDM_SS_DriverFailure:
+ Message::SendFail() << "Error in the DEXCAF_Provider during writing the file : " << thePath
+ << "\t: Storage error : driver failure";
+ break;
+ case PCDM_SS_WriteFailure:
+ Message::SendFail() << "Error in the DEXCAF_Provider during the writing the file : "
+ << thePath << "\t: Storage error : write failure";
+ break;
+ case PCDM_SS_Failure:
+ Message::SendFail() << "Error in the DEXCAF_Provider during writing the file : " << thePath
+ << "\t: Storage error : general failure";
+ break;
+ case PCDM_SS_Doc_IsNull:
+ Message::SendFail() << "Error in the DEXCAF_Provider during writing the file : " << thePath
+ << "\t: Storage error :: document is NULL";
+ break;
+ case PCDM_SS_No_Obj:
+ Message::SendFail() << "Error in the DEXCAF_Provider during writing the file : " << thePath
+ << "\t: Storage error : no object";
+ break;
+ case PCDM_SS_Info_Section_Error:
+ Message::SendFail() << "Error in the DEXCAF_Provider during writing the file : " << thePath
+ << "\t: Storage error : section error";
+ break;
+ case PCDM_SS_UserBreak:
+ Message::SendFail() << "Error in the DEXCAF_Provider during writing the file : " << thePath
+ << "\t: Storage error : user break";
+ break;
+ case PCDM_SS_UnrecognizedFormat:
+ Message::SendFail() << "Error in the DEXCAF_Provider during writing the file : " << thePath
+ << "\t: Storage error : unrecognized document storage format : "
+ << theDocument->StorageFormat();
+ break;
+ }
+ return false;
+}
+
+//=================================================================================================
+
+bool DEXCAF_Provider::Read(const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ Handle(XSControl_WorkSession)& theWS,
+ const Message_ProgressRange& theProgress)
+{
+ (void)theWS;
+ return Read(thePath, theShape, theProgress);
+}
+
+//=================================================================================================
+
+bool DEXCAF_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);
+}
+
+//=================================================================================================
+
+bool DEXCAF_Provider::Read(const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ const Message_ProgressRange& theProgress)
+{
+ if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEXCAF_ConfigurationNode)))
+ {
+ Message::SendFail() << "Error in the DEXCAF_Provider during reading the file " << thePath
+ << "\t: Incorrect or empty Configuration Node";
+ return false;
+ }
+ Handle(TDocStd_Document) aDocument;
+ Handle(TDocStd_Application) anApp = new TDocStd_Application();
+ BinXCAFDrivers::DefineFormat(anApp);
+ anApp->NewDocument("BinXCAF", aDocument);
+ Read(thePath, aDocument, theProgress);
+ TDF_LabelSequence aLabels;
+ Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main());
+ aSTool->GetFreeShapes(aLabels);
+ if (aLabels.Length() <= 0)
+ {
+ Message::SendFail() << "Error in the DEXCAF_Provider during reading the file : " << thePath
+ << "\t: Document contain no shapes";
+ return false;
+ }
+
+ if (aLabels.Length() == 1)
+ {
+ theShape = aSTool->GetShape(aLabels.Value(1));
+ }
+ else
+ {
+ TopoDS_Compound aComp;
+ BRep_Builder aBuilder;
+ aBuilder.MakeCompound(aComp);
+ for (Standard_Integer anIndex = 1; anIndex <= aLabels.Length(); anIndex++)
+ {
+ TopoDS_Shape aS = aSTool->GetShape(aLabels.Value(anIndex));
+ aBuilder.Add(aComp, aS);
+ }
+ theShape = aComp;
+ }
+ return true;
+}
+
+//=================================================================================================
+
+bool DEXCAF_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);
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEXCAF_Provider::GetFormat() const
+{
+ return TCollection_AsciiString("XCAF");
+}
+
+//=================================================================================================
+
+TCollection_AsciiString DEXCAF_Provider::GetVendor() const
+{
+ return TCollection_AsciiString("OCC");
+}
--- /dev/null
+// Copyright (c) 2022 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _DEXCAF_Provider_HeaderFile
+#define _DEXCAF_Provider_HeaderFile
+
+#include <DE_Provider.hxx>
+
+//! The class to transfer XCAF Documents.
+//! Reads and Writes any XDE Document files into/from OCCT.
+//! Each operation needs configuration node.
+//!
+//! Providers grouped by Vendor name and Format type.
+//! The Vendor name is "OCC"
+//! The Format type is "XCAF"
+//! The import process is supported.
+//! The export process is supported.
+class DEXCAF_Provider : public DE_Provider
+{
+public:
+ DEFINE_STANDARD_RTTIEXT(DEXCAF_Provider, DE_Provider)
+
+public:
+ //! Default constructor
+ //! Configure translation process with global configuration
+ Standard_EXPORT DEXCAF_Provider();
+
+ //! Configure translation process
+ //! @param[in] theNode object to copy
+ Standard_EXPORT DEXCAF_Provider(const Handle(DE_ConfigurationNode)& theNode);
+
+public:
+ //! Reads a CAD file, according internal configuration
+ //! @param[in] thePath path to the import CAD file
+ //! @param[out] theDocument document to save result
+ //! @param[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Read operation has ended correctly
+ Standard_EXPORT virtual bool Read(
+ const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ 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[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Write operation has ended correctly
+ Standard_EXPORT virtual bool Write(
+ const TCollection_AsciiString& thePath,
+ const Handle(TDocStd_Document)& theDocument,
+ 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[in] theProgress 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[in] theProgress 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
+ //! @param[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Read operation has ended correctly
+ Standard_EXPORT virtual bool Read(
+ const TCollection_AsciiString& thePath,
+ TopoDS_Shape& theShape,
+ 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[in] theWS current work session
+ //! @param[in] theProgress progress indicator
+ //! @return true if Write operation has ended correctly
+ Standard_EXPORT virtual bool Write(
+ const TCollection_AsciiString& thePath,
+ const TopoDS_Shape& theShape,
+ 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[in] theProgress 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[in] theProgress 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 CAD format
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
+
+ //! Gets provider's vendor name of associated provider
+ //! @return provider's vendor name
+ Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
+};
+
+#endif // _DEXCAF_Provider_HeaderFile
--- /dev/null
+DEXCAF_ConfigurationNode.cxx
+DEXCAF_ConfigurationNode.hxx
+DEXCAF_Provider.cxx
+DEXCAF_Provider.hxx
+++ /dev/null
-// Copyright (c) 2022 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <DEXCAFCascade_ConfigurationNode.hxx>
-
-#include <DE_ConfigurationContext.hxx>
-#include <DE_PluginHolder.hxx>
-#include <DEXCAFCascade_Provider.hxx>
-#include <NCollection_Buffer.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(DEXCAFCascade_ConfigurationNode, DE_ConfigurationNode)
-
-namespace
-{
- static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
- {
- static const TCollection_AsciiString aScope = "provider";
- return aScope;
- }
-
- // Wrapper to auto-load DE component
- DE_PluginHolder<DEXCAFCascade_ConfigurationNode> THE_OCCT_XCAF_COMPONENT_PLUGIN;
-}
-
-//=======================================================================
-// function : DEXCAFCascade_ConfigurationNode
-// purpose :
-//=======================================================================
-DEXCAFCascade_ConfigurationNode::DEXCAFCascade_ConfigurationNode() :
- DE_ConfigurationNode()
-{}
-
-//=======================================================================
-// function : DEXCAFCascade_ConfigurationNode
-// purpose :
-//=======================================================================
-DEXCAFCascade_ConfigurationNode::DEXCAFCascade_ConfigurationNode(const Handle(DEXCAFCascade_ConfigurationNode)& theNode)
- :DE_ConfigurationNode(theNode)
-{
- InternalParameters = theNode->InternalParameters;
-}
-
-//=======================================================================
-// function : Load
-// purpose :
-//=======================================================================
-bool DEXCAFCascade_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
-{
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
-
- InternalParameters.ReadAppendMode = (PCDM_ReaderFilter::AppendMode)
- theResource->IntegerVal("read.append.mode", InternalParameters.ReadAppendMode, aScope);
- theResource->GetStringSeq("read.skip.values", InternalParameters.ReadSkipValues, aScope);
- theResource->GetStringSeq("read.values", InternalParameters.ReadValues, aScope);
-
- return true;
-}
-
-//=======================================================================
-// function : Save
-// purpose :
-//=======================================================================
-TCollection_AsciiString DEXCAFCascade_ConfigurationNode::Save() const
-{
- TCollection_AsciiString aResult;
- aResult += "!*****************************************************************************\n";
- aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
-
- aResult += "!\n";
- aResult += "!Read parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Don't allow append (when the value = 0, it is the default value), ";
- aResult += "keeps existing attributes, reads only new ones(when the value = 1), ";
- aResult += "overwrites the existing attributes by the loaded ones(when the value = 2)\n";
- aResult += "!Default value: 0. Available values: 0, 1, 2\n";
- aResult += aScope + "read.append.mode :\t " + InternalParameters.ReadAppendMode + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Overwrites the existing attributes by the loaded ones";
- aResult += "!Default value: empty. Available values: {sequence<string>}\n";
- aResult += aScope + "read.skip.values :\t ";
- for (TColStd_ListOfAsciiString::Iterator anIt(InternalParameters.ReadSkipValues); anIt.More(); anIt.Next())
- {
- aResult += anIt.Value() + " ";
- }
- aResult += "\n!\n";
-
- aResult += "!\n";
- aResult += "!1) Adds sub-tree path like \"0:2\"";
- aResult += "2) Adds attribute to read by typename. Disables the skipped attributes added. (there shouldn't be '0' after -read)\n";
- aResult += "!Default value: empty. Available values: {sequence<string>}\n";
- aResult += aScope + "read.values :\t ";
- for (TColStd_ListOfAsciiString::Iterator anIt(InternalParameters.ReadValues); anIt.More(); anIt.Next())
- {
- aResult += anIt.Value() + " ";
- }
- aResult += "\n!\n";
-
- aResult += "!*****************************************************************************\n";
- return aResult;
-}
-
-//=======================================================================
-// function : Copy
-// purpose :
-//=======================================================================
-Handle(DE_ConfigurationNode) DEXCAFCascade_ConfigurationNode::Copy() const
-{
- return new DEXCAFCascade_ConfigurationNode(*this);
-}
-
-//=======================================================================
-// function : BuildProvider
-// purpose :
-//=======================================================================
-Handle(DE_Provider) DEXCAFCascade_ConfigurationNode::BuildProvider()
-{
- return new DEXCAFCascade_Provider (this);
-}
-
-//=======================================================================
-// function : IsImportSupported
-// purpose :
-//=======================================================================
-bool DEXCAFCascade_ConfigurationNode::IsImportSupported() const
-{
- return true;
-}
-
-//=======================================================================
-// function : IsExportSupported
-// purpose :
-//=======================================================================
-bool DEXCAFCascade_ConfigurationNode::IsExportSupported() const
-{
- return true;
-}
-
-//=======================================================================
-// function : GetFormat
-// purpose :
-//=======================================================================
-TCollection_AsciiString DEXCAFCascade_ConfigurationNode::GetFormat() const
-{
- return TCollection_AsciiString("XCAF");
-}
-
-//=======================================================================
-// function : GetVendor
-// purpose :
-//=======================================================================
-TCollection_AsciiString DEXCAFCascade_ConfigurationNode::GetVendor() const
-{
- return TCollection_AsciiString("OCC");
-}
-
-//=======================================================================
-// function : GetExtensions
-// purpose :
-//=======================================================================
-TColStd_ListOfAsciiString DEXCAFCascade_ConfigurationNode::GetExtensions() const
-{
- TColStd_ListOfAsciiString anExt;
- anExt.Append("xbf");
- return anExt;
-}
-
-//=======================================================================
-// function : CheckContent
-// purpose :
-//=======================================================================
-bool DEXCAFCascade_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
-{
- if (theBuffer.IsNull() || theBuffer->Size() < 8)
- {
- return false;
- }
- const char* aBytes = (const char*)theBuffer->Data();
- if (!::strncmp(aBytes, "BINFILE", 7))
- {
- return true;
- }
- return false;
-}
#ifndef _DEXCAFCascade_ConfigurationNode_HeaderFile
#define _DEXCAFCascade_ConfigurationNode_HeaderFile
-#include <DE_ConfigurationNode.hxx>
-#include <PCDM_ReaderFilter.hxx>
-#include <TColStd_ListOfAsciiString.hxx>
+#include <DEXCAF_ConfigurationNode.hxx>
-//! The purpose of this class is to configure the transfer process for XDE Documents
-//! Stores the necessary settings for DEXCAFCascade_Provider.
-//! Configures and creates special provider to transfer XDE Documents.
-//!
-//! Nodes grouped by Vendor name and Format type.
-//! The Vendor name is "OCC"
-//! The Format type is "XCAF"
-//! The supported CAD extension is ".xbf"
-//! The import process is supported.
-//! The export process is supported.
-class DEXCAFCascade_ConfigurationNode : public DE_ConfigurationNode
-{
- DEFINE_STANDARD_RTTIEXT(DEXCAFCascade_ConfigurationNode, DE_ConfigurationNode)
-public:
-
- //! Initializes all field by default
- Standard_EXPORT DEXCAFCascade_ConfigurationNode();
-
- //! Copies values of all fields
- //! @param[in] theNode object to copy
- Standard_EXPORT DEXCAFCascade_ConfigurationNode(const Handle(DEXCAFCascade_ConfigurationNode)& theNode);
-
- //! Updates values according the resource
- //! @param[in] theResource input resource to use
- //! @return true if theResource loading has ended correctly
- Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource) Standard_OVERRIDE;
-
- //! Writes configuration to the string
- //! @return result resource string
- Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
-
- //! Copies values of all fields
- //! @return new object with the same field values
- Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
-
-
- //! Creates new provider for the own format
- //! @return new created provider
- Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
-
-public:
-
- //! Checks the import supporting
- //! @return true if import is supported
- Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
-
- //! Checks the export supporting
- //! @return true if export is supported
- Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
-
- //! Gets CAD format name of associated provider
- //! @return provider CAD format
- Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
-
- //! Gets provider's vendor name of associated provider
- //! @return provider's vendor name
- Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
-
- //! Gets list of supported file extensions
- //! @return list of extensions
- Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
-
- //! Checks the file content to verify a format
- //! @param[in] theBuffer read stream buffer to check content
- //! @return Standard_True if file is supported by a current provider
- Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const Standard_OVERRIDE;
-
-public:
- struct XCAFDoc_InternalSection
- {
- // Read
-// clang-format off
- PCDM_ReaderFilter::AppendMode ReadAppendMode = PCDM_ReaderFilter::AppendMode::AppendMode_Forbid; //!< Setting up the append mode
- TColStd_ListOfAsciiString ReadSkipValues; //!< Overwrites the existing attributes by the loaded ones
- TColStd_ListOfAsciiString ReadValues; //!< Adds sub-tree path or adds attribute to read by typename
-// clang-format on
-
- } InternalParameters;
-};
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef DEXCAF_ConfigurationNode DEXCAFCascade_ConfigurationNode;
#endif // _DEXCAFCascade_ConfigurationNode_HeaderFile
+++ /dev/null
-// Copyright (c) 2022 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <DEXCAFCascade_Provider.hxx>
-
-#include <BinDrivers.hxx>
-#include <BinLDrivers.hxx>
-#include <BinTObjDrivers.hxx>
-#include <BinXCAFDrivers.hxx>
-#include <StdDrivers.hxx>
-#include <StdLDrivers.hxx>
-#include <XmlDrivers.hxx>
-#include <XmlLDrivers.hxx>
-#include <XmlTObjDrivers.hxx>
-#include <XmlXCAFDrivers.hxx>
-
-#include <BRep_Builder.hxx>
-#include <DEXCAFCascade_ConfigurationNode.hxx>
-#include <Message.hxx>
-#include <TDocStd_Application.hxx>
-#include <XCAFDoc_DocumentTool.hxx>
-#include <XCAFDoc_ShapeTool.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(DEXCAFCascade_Provider, DE_Provider)
-
-
-//=======================================================================
-// function : DEXCAFCascade_Provider
-// purpose :
-//=======================================================================
-DEXCAFCascade_Provider::DEXCAFCascade_Provider()
-{}
-
-//=======================================================================
-// function : DEXCAFCascade_Provider
-// purpose :
-//=======================================================================
-DEXCAFCascade_Provider::DEXCAFCascade_Provider(const Handle(DE_ConfigurationNode)& theNode)
- :DE_Provider(theNode)
-{}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- Handle(XSControl_WorkSession)& theWS,
- 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 " <<
- thePath << "\t: theDocument shouldn't be null";
- return false;
- }
- if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEXCAFCascade_ConfigurationNode)))
- {
- Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file " << thePath
- << "\t: Incorrect or empty Configuration Node";
- return false;
- }
- Handle(DEXCAFCascade_ConfigurationNode) aNode = Handle(DEXCAFCascade_ConfigurationNode)::DownCast(GetNode());
- Handle(TDocStd_Document) aDocument;
- Handle(TDocStd_Application) anApp = new TDocStd_Application();
- BinDrivers::DefineFormat(anApp);
- BinLDrivers::DefineFormat(anApp);
- BinTObjDrivers::DefineFormat(anApp);
- BinXCAFDrivers::DefineFormat(anApp);
- StdDrivers::DefineFormat(anApp);
- StdLDrivers::DefineFormat(anApp);
- XmlDrivers::DefineFormat(anApp);
- XmlLDrivers::DefineFormat(anApp);
- XmlTObjDrivers::DefineFormat(anApp);
- XmlXCAFDrivers::DefineFormat(anApp);
- Handle(PCDM_ReaderFilter) aFilter = new PCDM_ReaderFilter(aNode->InternalParameters.ReadAppendMode);
- for (TColStd_ListOfAsciiString::Iterator anIt(aNode->InternalParameters.ReadSkipValues); anIt.More(); anIt.Next())
- {
- aFilter->AddSkipped(anIt.Value());
- }
- for (TColStd_ListOfAsciiString::Iterator anIt(aNode->InternalParameters.ReadValues); anIt.More(); anIt.Next())
- {
- if (anIt.Value().StartsWith("0"))
- {
- aFilter->AddPath(anIt.Value());
- }
- else
- {
- aFilter->AddRead(anIt.Value());
- }
- }
-
- if (anApp->Open(thePath, aDocument, aFilter, theProgress) != PCDM_RS_OK)
- {
- Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file : " << thePath
- << "\t: Cannot open XDE document";
- return false;
- }
- theDocument->SetData(aDocument->GetData());
- return true;
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool DEXCAFCascade_Provider::Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
- Handle(TDocStd_Application) anApp = new TDocStd_Application();
- BinXCAFDrivers::DefineFormat(anApp);
-
- Handle(DEXCAFCascade_ConfigurationNode) aNode = Handle(DEXCAFCascade_ConfigurationNode)::DownCast(GetNode());
- if (aNode->GlobalParameters.LengthUnit != 1.0)
- {
- Message::SendWarning() << "Warning in the DEXCAFCascade_Provider during writing the file " <<
- thePath << "\t: Target Units for writing were changed, but current format doesn't support scaling";
- }
-
- PCDM_StoreStatus aStatus = PCDM_SS_Doc_IsNull;
- if (!thePath.IsEmpty())
- {
- aStatus = anApp->SaveAs(theDocument, thePath, theProgress);
- }
- else if (!theDocument->IsSaved())
- {
- Message::SendFail() << "Storage error in the DEXCAFCascade_Provider during writing the file " <<
- thePath << "\t: Storage error : this document has never been saved";
- return false;
- }
- else
- {
- aStatus = anApp->Save(theDocument, theProgress);
- }
-
- switch (aStatus)
- {
- case PCDM_SS_OK:
- return true;
- case PCDM_SS_DriverFailure:
- Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
- << "\t: Storage error : driver failure";
- break;
- case PCDM_SS_WriteFailure:
- Message::SendFail() << "Error in the DEXCAFCascade_Provider during the writing the file : " << thePath
- << "\t: Storage error : write failure";
- break;
- case PCDM_SS_Failure:
- Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
- << "\t: Storage error : general failure";
- break;
- case PCDM_SS_Doc_IsNull:
- Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
- << "\t: Storage error :: document is NULL";
- break;
- case PCDM_SS_No_Obj:
- Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
- << "\t: Storage error : no object";
- break;
- case PCDM_SS_Info_Section_Error:
- Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
- << "\t: Storage error : section error";
- break;
- case PCDM_SS_UserBreak:
- Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
- << "\t: Storage error : user break";
- break;
- case PCDM_SS_UnrecognizedFormat:
- Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
- << "\t: Storage error : unrecognized document storage format : " << theDocument->StorageFormat();
- break;
- }
- return false;
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- Handle(XSControl_WorkSession)& theWS,
- 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
- << "\t: Incorrect or empty Configuration Node";
- return false;
- }
- Handle(TDocStd_Document) aDocument;
- Handle(TDocStd_Application) anApp = new TDocStd_Application();
- BinXCAFDrivers::DefineFormat(anApp);
- anApp->NewDocument("BinXCAF", aDocument);
- Read(thePath, aDocument, theProgress);
- TDF_LabelSequence aLabels;
- Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main());
- aSTool->GetFreeShapes(aLabels);
- if (aLabels.Length() <= 0)
- {
- Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file : " << thePath
- << "\t: Document contain no shapes";
- return false;
- }
-
- if (aLabels.Length() == 1)
- {
- theShape = aSTool->GetShape(aLabels.Value(1));
- }
- else
- {
- TopoDS_Compound aComp;
- BRep_Builder aBuilder;
- aBuilder.MakeCompound(aComp);
- for (Standard_Integer anIndex = 1; anIndex <= aLabels.Length(); anIndex++)
- {
- TopoDS_Shape aS = aSTool->GetShape(aLabels.Value(anIndex));
- aBuilder.Add(aComp, aS);
- }
- theShape = aComp;
- }
- return true;
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool DEXCAFCascade_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);
-}
-
-//=======================================================================
-// function : GetFormat
-// purpose :
-//=======================================================================
-TCollection_AsciiString DEXCAFCascade_Provider::GetFormat() const
-{
- return TCollection_AsciiString("XCAF");
-}
-
-//=======================================================================
-// function : GetVendor
-// purpose :
-//=======================================================================
-TCollection_AsciiString DEXCAFCascade_Provider::GetVendor() const
-{
- return TCollection_AsciiString("OCC");
-}
#ifndef _DEXCAFCascade_Provider_HeaderFile
#define _DEXCAFCascade_Provider_HeaderFile
-#include <DE_Provider.hxx>
+#include <DEXCAF_Provider.hxx>
-//! The class to transfer XCAF Documents.
-//! Reads and Writes any XDE Document files into/from OCCT.
-//! Each operation needs configuration node.
-//!
-//! Providers grouped by Vendor name and Format type.
-//! The Vendor name is "OCC"
-//! The Format type is "XCAF"
-//! The import process is supported.
-//! The export process is supported.
-class DEXCAFCascade_Provider : public DE_Provider
-{
-public:
- DEFINE_STANDARD_RTTIEXT(DEXCAFCascade_Provider, DE_Provider)
-
-public:
-
- //! Default constructor
- //! Configure translation process with global configuration
- Standard_EXPORT DEXCAFCascade_Provider();
-
- //! Configure translation process
- //! @param[in] theNode object to copy
- Standard_EXPORT DEXCAFCascade_Provider(const Handle(DE_ConfigurationNode)& theNode);
-
-public:
-
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theDocument document to save result
- //! @param[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- 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[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- 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[in] theProgress 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[in] theProgress 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
- //! @param[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- 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[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- 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[in] theProgress 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[in] theProgress 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 CAD format
- Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
-
- //! Gets provider's vendor name of associated provider
- //! @return provider's vendor name
- Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
-};
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef DEXCAF_Provider DEXCAFCascade_Provider;
#endif // _DEXCAFCascade_Provider_HeaderFile
-DEXCAFCascade_ConfigurationNode.cxx
DEXCAFCascade_ConfigurationNode.hxx
-DEXCAFCascade_Provider.cxx
DEXCAFCascade_Provider.hxx
IGESCAFControl.cxx
IGESCAFControl.hxx
-IGESCAFControl_ConfigurationNode.cxx
IGESCAFControl_ConfigurationNode.hxx
-IGESCAFControl_Provider.cxx
IGESCAFControl_Provider.hxx
IGESCAFControl_Reader.cxx
IGESCAFControl_Reader.hxx
+++ /dev/null
-// Copyright (c) 2022 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <IGESCAFControl_ConfigurationNode.hxx>
-
-#include <DE_ConfigurationContext.hxx>
-#include <DE_PluginHolder.hxx>
-#include <IGESCAFControl_Provider.hxx>
-#include <NCollection_Buffer.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(IGESCAFControl_ConfigurationNode, DE_ConfigurationNode)
-
-namespace
-{
- static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
- {
- static const TCollection_AsciiString aScope = "provider";
- return aScope;
- }
-
- // Wrapper to auto-load DE component
- DE_PluginHolder<IGESCAFControl_ConfigurationNode> THE_OCCT_IGES_COMPONENT_PLUGIN;
-}
-
-//=======================================================================
-// function : IGESCAFControl_ConfigurationNode
-// purpose :
-//=======================================================================
-IGESCAFControl_ConfigurationNode::IGESCAFControl_ConfigurationNode() :
- DE_ConfigurationNode()
-{}
-
-//=======================================================================
-// function : IGESCAFControl_ConfigurationNode
-// purpose :
-//=======================================================================
-IGESCAFControl_ConfigurationNode::IGESCAFControl_ConfigurationNode(const Handle(IGESCAFControl_ConfigurationNode)& theNode)
- :DE_ConfigurationNode(theNode)
-{
- InternalParameters = theNode->InternalParameters;
-}
-
-//=======================================================================
-// function : Load
-// purpose :
-//=======================================================================
-bool IGESCAFControl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
-{
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
-
- InternalParameters.ReadBSplineContinuity = (ReadMode_BSplineContinuity)
- theResource->IntegerVal("read.iges.bspline.continuity", InternalParameters.ReadBSplineContinuity, aScope);
- InternalParameters.ReadPrecisionMode = (ReadMode_Precision)
- theResource->IntegerVal("read.precision.mode", InternalParameters.ReadPrecisionMode, aScope);
- InternalParameters.ReadPrecisionVal =
- theResource->RealVal("read.precision.val", InternalParameters.ReadPrecisionVal, aScope);
- InternalParameters.ReadMaxPrecisionMode = (ReadMode_MaxPrecision)
- theResource->IntegerVal("read.maxprecision.mode", InternalParameters.ReadMaxPrecisionMode, aScope);
- InternalParameters.ReadMaxPrecisionVal =
- theResource->RealVal("read.maxprecision.val", InternalParameters.ReadMaxPrecisionVal, aScope);
- InternalParameters.ReadSameParamMode =
- theResource->BooleanVal("read.stdsameparameter.mode", InternalParameters.ReadSameParamMode, aScope);
- InternalParameters.ReadSurfaceCurveMode = (ReadMode_SurfaceCurve)
- theResource->IntegerVal("read.surfacecurve.mode", InternalParameters.ReadSurfaceCurveMode, aScope);
- InternalParameters.EncodeRegAngle =
- theResource->RealVal("read.encoderegularity.angle", InternalParameters.EncodeRegAngle, aScope);
-
- InternalParameters.ReadApproxd1 =
- theResource->BooleanVal("read.bspline.approxd1.mode", InternalParameters.ReadApproxd1, aScope);
- InternalParameters.ReadResourceName =
- theResource->StringVal("read.resource.name", InternalParameters.ReadResourceName, aScope);
- InternalParameters.ReadSequence =
- theResource->StringVal("read.sequence", InternalParameters.ReadSequence, aScope);
- InternalParameters.ReadFaultyEntities =
- theResource->BooleanVal("read.fau_lty.entities", InternalParameters.ReadFaultyEntities, aScope);
- InternalParameters.ReadOnlyVisible =
- theResource->BooleanVal("read.onlyvisible", InternalParameters.ReadOnlyVisible, aScope);
- InternalParameters.ReadColor =
- theResource->BooleanVal("read.color", InternalParameters.ReadColor, aScope);
- InternalParameters.ReadName =
- theResource->BooleanVal("read.name", InternalParameters.ReadName, aScope);
- InternalParameters.ReadLayer =
- theResource->BooleanVal("read.layer", InternalParameters.ReadLayer, aScope);
-
- InternalParameters.WriteBRepMode = (WriteMode_BRep)
- theResource->IntegerVal("write.brep.mode", InternalParameters.WriteBRepMode, aScope);
- InternalParameters.WriteConvertSurfaceMode = (WriteMode_ConvertSurface)
- theResource->IntegerVal("write.convertsurface.mode", InternalParameters.WriteConvertSurfaceMode, aScope);
- InternalParameters.WriteHeaderAuthor =
- theResource->StringVal("write.header.author", InternalParameters.WriteHeaderAuthor, aScope);
- InternalParameters.WriteHeaderCompany =
- theResource->StringVal("write.header.company", InternalParameters.WriteHeaderCompany, aScope);
- InternalParameters.WriteHeaderProduct =
- theResource->StringVal("write.header.product", InternalParameters.WriteHeaderProduct, aScope);
- InternalParameters.WriteHeaderReciever =
- theResource->StringVal("write.header.receiver", InternalParameters.WriteHeaderReciever, aScope);
- InternalParameters.WriteResourceName =
- theResource->StringVal("write.resource.name", InternalParameters.WriteResourceName, aScope);
- InternalParameters.WriteSequence =
- theResource->StringVal("write.sequence", InternalParameters.WriteSequence, aScope);
- InternalParameters.WritePrecisionMode = (WriteMode_PrecisionMode)
- theResource->IntegerVal("write.precision.mode", InternalParameters.WritePrecisionMode, aScope);
- InternalParameters.WritePrecisionVal =
- theResource->RealVal("write.precision.val", InternalParameters.WritePrecisionVal, aScope);
- InternalParameters.WritePlaneMode = (WriteMode_PlaneMode)
- theResource->IntegerVal("write.plane.mode", InternalParameters.WritePlaneMode, aScope);
- InternalParameters.WriteOffsetMode =
- theResource->BooleanVal("write.offset", InternalParameters.WriteOffsetMode, aScope);
- InternalParameters.WriteColor =
- theResource->BooleanVal("write.color", InternalParameters.WriteColor, aScope);
- InternalParameters.WriteName =
- theResource->BooleanVal("write.name", InternalParameters.WriteName, aScope);
- InternalParameters.WriteLayer =
- theResource->BooleanVal("write.layer", InternalParameters.WriteLayer, aScope);
-
- return true;
-}
-
-//=======================================================================
-// function : Save
-// purpose :
-//=======================================================================
-TCollection_AsciiString IGESCAFControl_ConfigurationNode::Save() const
-{
- TCollection_AsciiString aResult;
- aResult += "!*****************************************************************************\n";
- aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
-
- aResult += "!\n";
- aResult += "!Common parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Manages the continuity of BSpline curves (IGES entities 106, 112 and 126) ";
- aResult += "after translation to Open CASCADE Technology\n";
- aResult += "!Default value: 1. Available values: 0, 1, 2\n";
- aResult += aScope + "read.iges.bspline.continuity :\t " + InternalParameters.ReadBSplineContinuity + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Reads the precision mode value\n";
- aResult += "!Default value: \"File\"(0). Available values: \"File\"(0), \"User\"(1)\n";
- aResult += aScope + "read.precision.mode :\t " + InternalParameters.ReadPrecisionMode + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!This parameter gives the precision for shape construction when the ";
- aResult += "read.precision.mode parameter value is 1\n";
- aResult += "!Default value: 0.0001. Available values: any real positive (non null) value\n";
- aResult += aScope + "read.precision.val :\t " + InternalParameters.ReadPrecisionVal + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the mode of applying the maximum allowed tolerance\n";
- aResult += "!Default value: \"Preferred\"(0). Available values: \"Preferred\"(0), \"Forced\"(1)\n";
- aResult += aScope + "read.maxprecision.mode :\t " + InternalParameters.ReadMaxPrecisionMode + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the maximum allowable tolerance (in internal units, which are specified in xstep.cascade.unit)";
- aResult += " of the shape\n";
- aResult += "!Default value: 1. Available values: any real positive (non null) value\n";
- aResult += aScope + "read.maxprecision.val :\t " + InternalParameters.ReadMaxPrecisionVal + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the using of BRepLib::SameParameter\n";
- aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(0)\n";
- aResult += aScope + "read.stdsameparameter.mode :\t " + InternalParameters.ReadSameParamMode + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Preference for the computation of curves in case of 2D/3D inconsistency in an entity ";
- aResult += "which has both 2D and 3D representations.\n";
- aResult += "!Default value: \"Default\"(0). Available values: \"Default\"(0), \"2DUse_Preferred\"(2), ";
- aResult += "\"2DUse_Forced\"(-2), \"3DUse_Preferred\"(3), \"3DUse_Forced\"(-3)\n";
- aResult += aScope + "read.surfacecurve.mode :\t " + InternalParameters.ReadSurfaceCurveMode + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!This parameter is used within the BRepLib::EncodeRegularity() function ";
- aResult += "which is called for a shape read ";
- aResult += "from an IGES or a STEP file at the end of translation process.This function sets the regularity flag of";
- aResult += " an edge in a shell when this edge is shared by two faces.This flag shows the continuity, ";
- aResult += "which these two faces are connected with at that edge.\n";
- aResult += "!Default value (in degrees): 0.57295779513. Available values: <double>\n";
- aResult += aScope + "read.encoderegularity.angle :\t " + InternalParameters.EncodeRegAngle + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Read parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!If set to True, it affects the translation of bspline curves of degree 1 from IGES: ";
- aResult += "these curves(which geometrically are polylines) are split by duplicated points, and the translator ";
- aResult += "attempts to convert each of the obtained parts to a bspline of a higher continuity\n";
- aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(1)\n";
- aResult += aScope + "read.bspline.approxd1.mode :\t " + InternalParameters.ReadApproxd1 + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the name of the resource file\n";
- aResult += "!Default value: \"IGES\". Available values: <string>\n";
- aResult += aScope + "read.resource.name :\t " + InternalParameters.ReadResourceName + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the name of the sequence of operators\n";
- aResult += "!Default value: \"FromIGES\". Available values: <string>\n";
- aResult += aScope + "read.sequence :\t " + InternalParameters.ReadSequence + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Parameter for reading fa-iled entities\n";
- aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(1)\n";
- aResult += aScope + "read.fau_lty.entities :\t " + InternalParameters.ReadFaultyEntities + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Controls transferring invisible sub entities which logically depend on the grouping entities\n";
- aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(1)\n";
- aResult += aScope + "read.onlyvisible :\t " + InternalParameters.ReadOnlyVisible + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up the ColorMode parameter which is used to indicate read Colors or not\n";
- aResult += "!Default value: 1. Available values: 0, 1\n";
- aResult += aScope + "read.color :\t " + InternalParameters.ReadColor + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up the NameMode parameter which is used to indicate read Names or not\n";
- aResult += "!Default value: 1. Available values: 0, 1\n";
- aResult += aScope + "read.name :\t " + InternalParameters.ReadName + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up the LayerMode parameter which is used to indicate read Layers or not\n";
- aResult += "!Default value: 1. Available values: 0, 1\n";
- aResult += aScope + "read.layer :\t " + InternalParameters.ReadLayer + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Write parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag to define entities type to write\n";
- aResult += "!Default value: \"Faces\"(0). Available values: \"Faces\"(0), \"BRep\"(1)\n";
- aResult += aScope + "write.brep.mode :\t " + InternalParameters.WriteBRepMode + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!When writing to IGES in the BRep mode, this parameter indicates whether elementary surfaces";
- aResult += "(cylindrical, conical, spherical, and toroidal) are converted into corresponding IGES 5.3 entities";
- aResult += "(if the value of a parameter value is On), or written as surfaces of revolution(by default)\n";
- aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(1)\n";
- aResult += aScope + "write.convertsurface.mode :\t " + InternalParameters.WriteConvertSurfaceMode + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Gives the name of the author of the file\n";
- aResult += "!Default value: {System name of the user}. Available values: <string>\n";
- aResult += aScope + "write.header.author :\t " + InternalParameters.WriteHeaderAuthor + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Gives the name of the sending company\n";
- aResult += "!Default value: ""(empty). Available values: <string>\n";
- aResult += aScope + "write.header.company :\t " + InternalParameters.WriteHeaderCompany + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Gives the name of the sending product\n";
- aResult += "!Default value: \"CAS.CADE IGES processor Vx.x\"";
- aResult += "(where x.x means the current version of Open CASCADE Technology)";
- aResult += "Available values : <string>\n";
- aResult += aScope + "write.header.product :\t " + InternalParameters.WriteHeaderProduct + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Gives the name of the receiving company\n";
- aResult += "!Default value: ""(empty). Available values: <string>\n";
- aResult += aScope + "write.header.receiver :\t " + InternalParameters.WriteHeaderReciever + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the name of the resource file\n";
- aResult += "!Default value: \"IGES\". Available values: <string>\n";
- aResult += aScope + "write.resource.name :\t " + InternalParameters.WriteResourceName + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the name of the sequence of operators\n";
- aResult += "!Default value: \"To\". Available values: <string>\n";
- aResult += aScope + "write.sequence :\t " + InternalParameters.WriteSequence + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Specifies the mode of writing the resolution value into the IGES file\n";
- aResult += "!Default value: Average(0). Available values: \"Least\"(-1), \"Average\"(0), ";
- aResult += "\"Greatest\"(1), \"Session\"(2)\n";
- aResult += aScope + "write.precision.mode :\t " + InternalParameters.WritePrecisionMode + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!This parameter gives the resolution value for an IGES file when the write.precision.mode parameter value is 1\n";
- aResult += "!Default value: 0.0001. Available values: any real positive (non null) value\n";
- aResult += aScope + "write.precision.val :\t " + InternalParameters.WritePrecisionVal + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Writing planes mode\n";
- aResult += "!Default value: \"Plane\"(0). Available values: \"Plane\"(0), \"BSpline\"(1)\n";
- aResult += aScope + "write.plane.mode :\t " + InternalParameters.WritePlaneMode + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Writing offset curves like BSplines\n";
- aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(1)\n";
- aResult += aScope + "write.offset :\t " + InternalParameters.WriteOffsetMode + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up the ColorMode parameter which is used to indicate write Colors or not\n";
- aResult += "!Default value: 1. Available values: 0, 1\n";
- aResult += aScope + "write.color :\t " + InternalParameters.WriteColor + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up the NameMode parameter which is used to indicate write Names or not\n";
- aResult += "!Default value: 1. Available values: 0, 1\n";
- aResult += aScope + "write.name :\t " + InternalParameters.WriteName + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up the LayerMode parameter which is used to indicate write Layers or not\n";
- aResult += "!Default value: 1. Available values: 0, 1\n";
- aResult += aScope + "write.layer :\t " + InternalParameters.WriteLayer + "\n";
- aResult += "!\n";
-
- aResult += "!*****************************************************************************\n";
- return aResult;
-}
-
-//=======================================================================
-// function : Copy
-// purpose :
-//=======================================================================
-Handle(DE_ConfigurationNode) IGESCAFControl_ConfigurationNode::Copy() const
-{
- return new IGESCAFControl_ConfigurationNode(*this);
-}
-
-//=======================================================================
-// function : BuildProvider
-// purpose :
-//=======================================================================
-Handle(DE_Provider) IGESCAFControl_ConfigurationNode::BuildProvider()
-{
- return new IGESCAFControl_Provider(this);
-}
-
-//=======================================================================
-// function : IsImportSupported
-// purpose :
-//=======================================================================
-bool IGESCAFControl_ConfigurationNode::IsImportSupported() const
-{
- return true;
-}
-
-//=======================================================================
-// function : IsExportSupported
-// purpose :
-//=======================================================================
-bool IGESCAFControl_ConfigurationNode::IsExportSupported() const
-{
- return true;
-}
-
-//=======================================================================
-// function : GetFormat
-// purpose :
-//=======================================================================
-TCollection_AsciiString IGESCAFControl_ConfigurationNode::GetFormat() const
-{
- return TCollection_AsciiString("IGES");
-}
-
-//=======================================================================
-// function : GetVendor
-// purpose :
-//=======================================================================
-TCollection_AsciiString IGESCAFControl_ConfigurationNode::GetVendor() const
-{
- return TCollection_AsciiString("OCC");
-}
-
-//=======================================================================
-// function : GetExtensions
-// purpose :
-//=======================================================================
-TColStd_ListOfAsciiString IGESCAFControl_ConfigurationNode::GetExtensions() const
-{
- TColStd_ListOfAsciiString anExt;
- anExt.Append("igs");
- anExt.Append("iges");
- return anExt;
-}
-
-//=======================================================================
-// function : CheckContent
-// purpose :
-//=======================================================================
-bool IGESCAFControl_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
-{
- if (theBuffer.IsNull() || theBuffer->Size() < 83)
- {
- return false;
- }
- const char* aBytes = (const char*)theBuffer->Data();
- if (aBytes[72] == 'S')
- {
- const char* aPtr = aBytes + 73;
- while (aPtr < aBytes + 80 && (*aPtr == ' ' || *aPtr == '0'))
- {
- aPtr++;
- }
- if (*aPtr == '1' && !::isalnum((unsigned char)*++aPtr))
- {
- return true;
- }
- }
- return false;
-}
#ifndef _IGESCAFControl_ConfigurationNode_HeaderFile
#define _IGESCAFControl_ConfigurationNode_HeaderFile
-#include <DE_ConfigurationNode.hxx>
-#include <UnitsMethods_LengthUnit.hxx>
+#include <DEIGES_ConfigurationNode.hxx>
-//! The purpose of this class is to configure the transfer process for IGES format
-//! Stores the necessary settings for IGESCAFControl_Provider.
-//! Configures and creates special provider to transfer IGES files.
-//!
-//! Nodes grouped by Vendor name and Format type.
-//! The Vendor name is "OCC"
-//! The Format type is "IGES"
-//! The supported CAD extensions are ".igs", ".iges"
-//! The import process is supported.
-//! The export process is supported.
-class IGESCAFControl_ConfigurationNode : public DE_ConfigurationNode
-{
- DEFINE_STANDARD_RTTIEXT(IGESCAFControl_ConfigurationNode, DE_ConfigurationNode)
-public:
-
- //! Initializes all fields by default
- Standard_EXPORT IGESCAFControl_ConfigurationNode();
-
- //! Copies values of all fields
- //! @param[in] theNode object to copy
- Standard_EXPORT IGESCAFControl_ConfigurationNode(const Handle(IGESCAFControl_ConfigurationNode)& theNode);
-
- //! Updates values according the resource
- //! @param[in] theResource input resource to use
- //! @return true if theResource loading has ended correctly
- Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource) Standard_OVERRIDE;
-
- //! Writes configuration to the string
- //! @return result resource string
- Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
-
- //! Copies values of all fields
- //! @return new object with the same field values
- Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
-
-
- //! Creates new provider for the own format
- //! @return new created provider
- Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
-
-public:
-
- //! Checks the import supporting
- //! @return true if import is supported
- Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
-
- //! Checks the export supporting
- //! @return true if export is supported
- Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
-
- //! Gets CAD format name of associated provider
- //! @return provider CAD format
- Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
-
- //! Gets provider's vendor name of associated provider
- //! @return provider's vendor name
- Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
-
- //! Gets list of supported file extensions
- //! @return list of extensions
- Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
-
- //! Checks the file content to verify a format
- //! @param[in] theBuffer read stream buffer to check content
- //! @return Standard_True if file is supported by a current provider
- Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const Standard_OVERRIDE;
-
-public:
-
- enum ReadMode_BSplineContinuity
- {
- ReadMode_BSplineContinuity_C0 = 0,
- ReadMode_BSplineContinuity_C1,
- ReadMode_BSplineContinuity_C2
- };
- enum ReadMode_Precision
- {
- ReadMode_Precision_File = 0,
- ReadMode_Precision_User
- };
- enum ReadMode_MaxPrecision
- {
- ReadMode_MaxPrecision_Preferred = 0,
- ReadMode_MaxPrecision_Forced
- };
- enum ReadMode_SurfaceCurve
- {
- ReadMode_SurfaceCurve_Default = 0,
- ReadMode_SurfaceCurve_2DUse_Preferred = 2,
- ReadMode_SurfaceCurve_2DUse_Forced = -2,
- ReadMode_SurfaceCurve_3DUse_Preferred = 3,
- ReadMode_SurfaceCurve_3DUse_Forced = -3
- };
- enum WriteMode_BRep
- {
- WriteMode_BRep_Faces = 0,
- WriteMode_BRep_BRep
- };
- enum WriteMode_ConvertSurface
- {
- WriteMode_ConvertSurface_Off = 0,
- WriteMode_ConvertSurface_On
- };
- enum WriteMode_PrecisionMode
- {
- WriteMode_PrecisionMode_Least = -1,
- WriteMode_PrecisionMode_Average = 0,
- WriteMode_PrecisionMode_Greatest = 1,
- WriteMode_PrecisionMode_Session = 2
- };
- enum WriteMode_PlaneMode
- {
- WriteMode_PlaneMode_Plane = 0,
- WriteMode_PlaneMode_BSpline
- };
- struct IGESCAFControl_InternalSection
- {
- // Common
-// clang-format off
- ReadMode_BSplineContinuity ReadBSplineContinuity = ReadMode_BSplineContinuity_C1; //<! Manages the continuity of BSpline curves
- ReadMode_Precision ReadPrecisionMode = ReadMode_Precision_File; //<! Reads the precision mode value
- double ReadPrecisionVal = 0.0001; //<! ReadMode_Precision for shape construction (if enabled user mode)
- ReadMode_MaxPrecision ReadMaxPrecisionMode = ReadMode_MaxPrecision_Preferred; //<! Defines the mode of applying the maximum allowed tolerance
- double ReadMaxPrecisionVal = 1; //<! Defines the maximum allowable tolerance
- bool ReadSameParamMode = false; //<! Defines the using of BRepLib::SameParameter
- ReadMode_SurfaceCurve ReadSurfaceCurveMode = ReadMode_SurfaceCurve_Default; //<! reference for the computation of curves in case of 2D/3D
- double EncodeRegAngle = 0.57295779513; //<! Continuity which these two faces are connected with at that edge
-
- //Read
- bool ReadApproxd1 = false; //<! Flag to split bspline curves of degree 1
- TCollection_AsciiString ReadResourceName = "IGES"; //<! Defines the name of the resource file to read
- TCollection_AsciiString ReadSequence = "FromIGES"; //<! Defines the name of the sequence of operators to read
- bool ReadFaultyEntities = false; //<! Parameter for reading failed entities
- bool ReadOnlyVisible = false; //<! Parameter for reading invisible entities
- bool ReadColor = true; //<! ColorMode is used to indicate read Colors or not
- bool ReadName = true; //<! NameMode is used to indicate read Name or not
- bool ReadLayer = true; //<! LayerMode is used to indicate read Layers or not
-
- // Write
- WriteMode_BRep WriteBRepMode = WriteMode_BRep_Faces; //<! Flag to define entities type to write
- WriteMode_ConvertSurface WriteConvertSurfaceMode = WriteMode_ConvertSurface_Off; //<! Flag to convert surface to elementary
- TCollection_AsciiString WriteHeaderAuthor; //<! Name of the author of the file
- TCollection_AsciiString WriteHeaderCompany; //<! Name of the sending company
- TCollection_AsciiString WriteHeaderProduct; //<! Name of the sending product
- TCollection_AsciiString WriteHeaderReciever; //<! Name of the receiving company
- TCollection_AsciiString WriteResourceName = "IGES"; //<! Defines the name of the resource file to write
- TCollection_AsciiString WriteSequence = "ToIGES"; //<! Defines the name of the sequence of operators to write
- WriteMode_PrecisionMode WritePrecisionMode = WriteMode_PrecisionMode_Average; //<! Specifies the mode of writing the resolution value into the IGES file
- double WritePrecisionVal = 0.0001; //<! Resolution value for an IGES file when WriteMode_PrecisionMode is Greatest
- WriteMode_PlaneMode WritePlaneMode = WriteMode_PlaneMode_Plane; //<! Flag to convert plane to the BSline
-// clang-format on
- bool WriteOffsetMode = false; //<! Writing offset curves like BSplines
- bool WriteColor = true; //<! ColorMode is used to indicate write Colors or not
- bool WriteName = true; //<! NameMode is used to indicate write Name or not
- bool WriteLayer = true; //<! LayerMode is used to indicate write Layers or not
- } InternalParameters;
-
-};
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef DEIGES_ConfigurationNode IGESCAFControl_ConfigurationNode;
#endif // _IGESCAFControl_ConfigurationNode_HeaderFile
+++ /dev/null
-// Copyright (c) 2022 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <IGESCAFControl_Provider.hxx>
-
-#include <IGESCAFControl_ConfigurationNode.hxx>
-#include <IGESCAFControl_Reader.hxx>
-#include <IGESCAFControl_Writer.hxx>
-#include <IGESControl_Controller.hxx>
-#include <IGESData.hxx>
-#include <IGESData_IGESModel.hxx>
-#include <Interface_Static.hxx>
-#include <Message.hxx>
-#include <XCAFDoc_DocumentTool.hxx>
-#include <XSControl_WorkSession.hxx>
-#include <UnitsMethods.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(IGESCAFControl_Provider, DE_Provider)
-
-//=======================================================================
-// function : IGESCAFControl_Provider
-// purpose :
-//=======================================================================
-IGESCAFControl_Provider::IGESCAFControl_Provider()
-{}
-
-//=======================================================================
-// function : IGESCAFControl_Provider
-// purpose :
-//=======================================================================
-IGESCAFControl_Provider::IGESCAFControl_Provider(const Handle(DE_ConfigurationNode)& theNode)
- : DE_Provider(theNode)
-{}
-
-//=======================================================================
-// function : personizeWS
-// purpose :
-//=======================================================================
-void IGESCAFControl_Provider::personizeWS(Handle(XSControl_WorkSession)& theWS)
-{
- if (theWS.IsNull())
- {
- Message::SendWarning() << "Warning: IGESCAFControl_Provider :"
- << " Null work session, use internal temporary session";
- theWS = new XSControl_WorkSession();
- }
- Handle(IGESControl_Controller) aCntrl = Handle(IGESControl_Controller)::DownCast(theWS->NormAdaptor());
- if (aCntrl.IsNull())
- {
- IGESControl_Controller::Init();
- theWS->SelectNorm("IGES");
- }
-}
-
-//=======================================================================
-// function : initStatic
-// purpose :
-//=======================================================================
-void IGESCAFControl_Provider::initStatic(const Handle(DE_ConfigurationNode)& theNode)
-{
- Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(theNode);
- IGESData::Init();
-
- // 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.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");
-
- // Set new values
- 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);
-}
-
-//=======================================================================
-// function : setStatic
-// purpose :
-//=======================================================================
-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::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);
-}
-
-//=======================================================================
-// function : resetStatic
-// purpose :
-//=======================================================================
-void IGESCAFControl_Provider::resetStatic()
-{
- Interface_Static::SetIVal("xstep.cascade.unit", myOldLengthUnit);
- UnitsMethods::SetCasCadeLengthUnit(myOldLengthUnit);
- setStatic(myOldValues);
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool IGESCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- Handle(XSControl_WorkSession)& theWS,
- const Message_ProgressRange& theProgress)
-{
- if (theDocument.IsNull())
- {
- Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
- thePath << "\t: theDocument shouldn't be null";
- 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";
- return false;
- }
- Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
- personizeWS(theWS);
- initStatic(aNode);
- XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
- IGESCAFControl_Reader aReader;
- aReader.SetWS(theWS);
-
- 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 (aReadStat != IFSelect_RetDone)
- {
- Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
- thePath << "\t: 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";
- resetStatic();
- return false;
- }
- resetStatic();
- return true;
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool IGESCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- Handle(XSControl_WorkSession)& theWS,
- const Message_ProgressRange& 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";
- return false;
- }
- Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
- personizeWS(theWS);
- initStatic(aNode);
- Standard_Integer aFlag = IGESData_BasicEditor::GetFlagByValue(aNode->GlobalParameters.LengthUnit);
- IGESCAFControl_Writer aWriter(theWS, (aFlag > 0) ? IGESData_BasicEditor::UnitFlagName(aFlag) : "MM");
- IGESData_GlobalSection aGS = aWriter.Model()->GlobalSection();
- Standard_Real aScaleFactorMM = 1.;
- Standard_Boolean aHasUnits = XCAFDoc_DocumentTool::GetLengthUnit(theDocument, aScaleFactorMM, UnitsMethods_LengthUnit_Millimeter);
- if (aHasUnits)
- {
- aGS.SetCascadeUnit(aScaleFactorMM);
- }
- else
- {
- aGS.SetCascadeUnit(aNode->GlobalParameters.SystemUnit);
- Message::SendWarning() << "Warning in the IGESCAFControl_Provider during writing the file " <<
- thePath << "\t: The document has no information on Units. Using global parameter as initial Unit.";
- }
- if (aFlag == 0)
- {
- aGS.SetScale(aNode->GlobalParameters.LengthUnit);
- }
- aWriter.Model()->SetGlobalSection(aGS);
- 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";
- resetStatic();
- return false;
- }
- if (!aWriter.Write(thePath.ToCString()))
- {
- Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
- thePath << "\t: Write failed";
- resetStatic();
- return false;
- }
- 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 :
-//=======================================================================
-bool IGESCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- Handle(XSControl_WorkSession)& theWS,
- const Message_ProgressRange& theProgress)
-{
- (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";
- return false;
- }
- Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
- initStatic(aNode);
- personizeWS(theWS);
- IGESControl_Reader aReader;
- aReader.SetWS(theWS);
- aReader.SetReadVisible(aNode->InternalParameters.ReadOnlyVisible);
- IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
- 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";
- 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";
- resetStatic();
- return false;
- }
- theShape = aReader.OneShape();
- resetStatic();
- return true;
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool IGESCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- Handle(XSControl_WorkSession)& theWS,
- const Message_ProgressRange& theProgress)
-{
- (void)theWS;
- (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";
- return false;
- }
- Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
- initStatic(aNode);
- Standard_Integer aFlag = IGESData_BasicEditor::GetFlagByValue(aNode->GlobalParameters.LengthUnit);
- IGESControl_Writer aWriter((aFlag > 0) ? IGESData_BasicEditor::UnitFlagName(aFlag) : "MM",
- aNode->InternalParameters.WriteBRepMode);
- IGESData_GlobalSection aGS = aWriter.Model()->GlobalSection();
- aGS.SetCascadeUnit(aNode->GlobalParameters.SystemUnit);
- if (!aFlag)
- {
- aGS.SetScale(aNode->GlobalParameters.LengthUnit);
- }
- aWriter.Model()->SetGlobalSection(aGS);
- Standard_Boolean aIsOk = aWriter.AddShape(theShape);
- if (!aIsOk)
- {
- Message::SendFail() << "IGESCAFControl_Provider: Shape not written";
- resetStatic();
- return false;
- }
-
- if (!(aWriter.Write(thePath.ToCString())))
- {
- Message::SendFail() << "IGESCAFControl_Provider: Error on writing file " << thePath;
- resetStatic();
- return false;
- }
- resetStatic();
- 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 :
-//=======================================================================
-TCollection_AsciiString IGESCAFControl_Provider::GetFormat() const
-{
- return TCollection_AsciiString("IGES");
-}
-
-//=======================================================================
-// function : GetVendor
-// purpose :
-//=======================================================================
-TCollection_AsciiString IGESCAFControl_Provider::GetVendor() const
-{
- return TCollection_AsciiString("OCC");
-}
#ifndef _IGESCAFControl_Provider_HeaderFile
#define _IGESCAFControl_Provider_HeaderFile
-#include <DE_Provider.hxx>
-#include <IGESCAFControl_ConfigurationNode.hxx>
+#include <DEIGES_Provider.hxx>
-//! The class to transfer IGES files.
-//! Reads and Writes any IGES files into/from OCCT.
-//! Each operation needs configuration node.
-//!
-//! Providers grouped by Vendor name and Format type.
-//! The Vendor name is "OCC"
-//! The Format type is "IGES"
-//! The import process is supported.
-//! The export process is supported.
-class IGESCAFControl_Provider : public DE_Provider
-{
-public:
- DEFINE_STANDARD_RTTIEXT(IGESCAFControl_Provider, DE_Provider)
-
-public:
-
- //! Default constructor
- //! Configure translation process with global configuration
- Standard_EXPORT IGESCAFControl_Provider();
-
- //! Configure translation process
- //! @param[in] theNode object to copy
- Standard_EXPORT IGESCAFControl_Provider(const Handle(DE_ConfigurationNode)& theNode);
-
-public:
-
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theDocument document to save result
- //! @param[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- 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[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- 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[in] theProgress 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[in] theProgress 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
- //! @param[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- 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[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- 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[in] theProgress 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[in] theProgress 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 CAD format
- Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
-
- //! Gets provider's vendor name of associated provider
- //! @return provider's vendor name
- Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
-
-private:
-
- //! Personizes work session with current format.
- //! Creates new temporary session if current session is null
- //! @param[in] theWS current work session
- void personizeWS(Handle(XSControl_WorkSession)& theWS);
-
- //! Initialize static variables
- void initStatic(const Handle(DE_ConfigurationNode)& theNode);
-
- //! Initialize static variables
- void setStatic(const IGESCAFControl_ConfigurationNode::IGESCAFControl_InternalSection& theParameter);
-
- //! Reset used interface static variables
- void resetStatic();
-
- IGESCAFControl_ConfigurationNode::IGESCAFControl_InternalSection myOldValues;
- int myOldLengthUnit = 1;
-
-};
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef DEIGES_Provider IGESCAFControl_Provider;
#endif // _IGESCAFControl_Provider_HeaderFile
RWGltf_CafReader.hxx
RWGltf_CafWriter.cxx
RWGltf_CafWriter.hxx
-RWGltf_ConfigurationNode.cxx
RWGltf_ConfigurationNode.hxx
RWGltf_DracoParameters.hxx
RWGltf_GltfAccessor.hxx
RWGltf_GltfSceneNodeMap.hxx
RWGltf_MaterialCommon.hxx
RWGltf_MaterialMetallicRoughness.hxx
-RWGltf_Provider.cxx
RWGltf_Provider.hxx
RWGltf_TriangulationReader.cxx
RWGltf_TriangulationReader.hxx
+++ /dev/null
-// Copyright (c) 2022 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <RWGltf_ConfigurationNode.hxx>
-
-#include <DE_ConfigurationContext.hxx>
-#include <DE_PluginHolder.hxx>
-#include <RWGltf_Provider.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(RWGltf_ConfigurationNode, DE_ConfigurationNode)
-
-namespace
-{
- static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
- {
- static const TCollection_AsciiString aScope = "provider";
- return aScope;
- }
-
- // Wrapper to auto-load DE component
- DE_PluginHolder<RWGltf_ConfigurationNode> THE_OCCT_GLTF_COMPONENT_PLUGIN;
-}
-
-//=======================================================================
-// function : RWGltf_ConfigurationNode
-// purpose :
-//=======================================================================
-RWGltf_ConfigurationNode::RWGltf_ConfigurationNode() :
- DE_ConfigurationNode()
-{}
-
-//=======================================================================
-// function : RWGltf_ConfigurationNode
-// purpose :
-//=======================================================================
-RWGltf_ConfigurationNode::RWGltf_ConfigurationNode(const Handle(RWGltf_ConfigurationNode)& theNode)
- :DE_ConfigurationNode(theNode)
-{
- InternalParameters = theNode->InternalParameters;
-}
-
-//=======================================================================
-// function : Load
-// purpose :
-//=======================================================================
-bool RWGltf_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
-{
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
-
- InternalParameters.FileLengthUnit =
- theResource->RealVal("file.length.unit", InternalParameters.FileLengthUnit, aScope);
- InternalParameters.SystemCS = (RWMesh_CoordinateSystem)
- (theResource->IntegerVal("system.cs", (int)InternalParameters.SystemCS, aScope) % 2);
- InternalParameters.FileCS = (RWMesh_CoordinateSystem)
- (theResource->IntegerVal("file.cs", (int)InternalParameters.SystemCS, aScope) % 2);
-
- InternalParameters.ReadSinglePrecision =
- theResource->BooleanVal("read.single.precision", InternalParameters.ReadSinglePrecision, aScope);
- InternalParameters.ReadCreateShapes =
- theResource->BooleanVal("read.create.shapes", InternalParameters.ReadCreateShapes, aScope);
- InternalParameters.ReadRootPrefix =
- theResource->StringVal("read.root.prefix", InternalParameters.ReadRootPrefix, aScope);
- InternalParameters.ReadFillDoc =
- theResource->BooleanVal("read.fill.doc", InternalParameters.ReadFillDoc, aScope);
- InternalParameters.ReadFillIncomplete =
- theResource->BooleanVal("read.fill.incomplete", InternalParameters.ReadFillIncomplete, aScope);
- InternalParameters.ReadMemoryLimitMiB =
- theResource->IntegerVal("read.memory.limit.mib", InternalParameters.ReadMemoryLimitMiB, aScope);
- InternalParameters.ReadParallel =
- theResource->BooleanVal("read.parallel", InternalParameters.ReadParallel, aScope);
- InternalParameters.ReadSkipEmptyNodes =
- theResource->BooleanVal("read.skip.empty.nodes", InternalParameters.ReadSkipEmptyNodes, aScope);
- InternalParameters.ReadLoadAllScenes =
- theResource->BooleanVal("read.load.all.scenes", InternalParameters.ReadLoadAllScenes, aScope);
- InternalParameters.ReadUseMeshNameAsFallback =
- theResource->BooleanVal("read.use.mesh.name.as.fallback", InternalParameters.ReadUseMeshNameAsFallback, aScope);
- InternalParameters.ReadSkipLateDataLoading =
- theResource->BooleanVal("read.skip.late.data.loading", InternalParameters.ReadSkipLateDataLoading, aScope);
- InternalParameters.ReadKeepLateData =
- theResource->BooleanVal("read.keep.late.data", InternalParameters.ReadKeepLateData, aScope);
- InternalParameters.ReadPrintDebugMessages =
- theResource->BooleanVal("read.print.debug.message", InternalParameters.ReadPrintDebugMessages, aScope);
-
- InternalParameters.WriteComment =
- theResource->StringVal("write.comment", InternalParameters.WriteComment, aScope);
- InternalParameters.WriteAuthor =
- theResource->StringVal("write.author", InternalParameters.WriteAuthor, aScope);
-
- InternalParameters.WriteTrsfFormat = (RWGltf_WriterTrsfFormat)
- (theResource->IntegerVal("write.trsf.format", InternalParameters.WriteTrsfFormat, aScope) % (RWGltf_WriterTrsfFormat_UPPER + 1));
- InternalParameters.WriteNodeNameFormat = (RWMesh_NameFormat)
- (theResource->IntegerVal("write.node.name.format", InternalParameters.WriteNodeNameFormat, aScope) % (RWMesh_NameFormat_ProductAndInstanceAndOcaf + 1));
- InternalParameters.WriteMeshNameFormat = (RWMesh_NameFormat)
- (theResource->IntegerVal("write.mesh.name.format", InternalParameters.WriteMeshNameFormat, aScope) % (RWMesh_NameFormat_ProductAndInstanceAndOcaf + 1));
- InternalParameters.WriteForcedUVExport =
- theResource->BooleanVal("write.forced.uv.export", InternalParameters.WriteForcedUVExport, aScope);
- InternalParameters.WriteEmbedTexturesInGlb =
- theResource->BooleanVal("write.embed.textures.in.glb", InternalParameters.WriteEmbedTexturesInGlb, aScope);
- InternalParameters.WriteMergeFaces =
- theResource->BooleanVal("write.merge.faces", InternalParameters.WriteMergeFaces, aScope);
- InternalParameters.WriteSplitIndices16 =
- theResource->BooleanVal("write.split.indices16", InternalParameters.WriteSplitIndices16, aScope);
- return true;
-}
-
-//=======================================================================
-// function : Save
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWGltf_ConfigurationNode::Save() const
-{
- TCollection_AsciiString aResult;
- aResult += "!*****************************************************************************\n";
- aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
-
- aResult += "!\n";
- aResult += "!Common parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!File length units to convert from while reading the file, defined as scale factor for m (meters)\n";
- aResult += "!Default value: 1.0(M)\n";
- aResult += aScope + "file.length.unit :\t " + InternalParameters.FileLengthUnit + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!System origin coordinate system to perform conversion into during read\n";
- aResult += "!Default value: 0(Zup). Available values: 0(Zup), 1(Yup)\n";
- aResult += aScope + "system.cs :\t " + InternalParameters.SystemCS + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!File origin coordinate system to perform conversion during read\n";
- aResult += "!Default value: 1(Yup). Available values: 0(Zup), 1(Yup)\n";
- aResult += aScope + "file.cs :\t " + InternalParameters.FileCS + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Read parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag for reading vertex data with single or double floating point precision\n";
- aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
- aResult += aScope + "read.single.precision :\t " + InternalParameters.ReadSinglePrecision + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag for create a single triangulation\n";
- aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
- aResult += aScope + "read.create.shapes :\t " + InternalParameters.ReadCreateShapes + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Root folder for generating root labels names\n";
- aResult += "!Default value: ""(empty). Available values: <path>\n";
- aResult += aScope + "read.root.prefix :\t " + InternalParameters.ReadRootPrefix + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag for fill document from shape sequence\n";
- aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
- aResult += aScope + "read.fill.doc :\t " + InternalParameters.ReadFillDoc + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag for fill the document with partially retrieved data even if reader has fa-iled with er-ror\n";
- aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
- aResult += aScope + "read.fill.incomplete :\t " + InternalParameters.ReadFillIncomplete + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Memory usage limit(MiB)\n";
- aResult += "!Default value: -1(no limit). Available values: -1(no limit), any positive value\n";
- aResult += aScope + "read.memory.limit.mib :\t " + InternalParameters.ReadMemoryLimitMiB + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag to use multithreading\n";
- aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
- aResult += aScope + "read.parallel :\t " + InternalParameters.ReadParallel + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag to ignore nodes without Geometry\n";
- aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
- aResult += aScope + "read.skip.empty.nodes :\t " + InternalParameters.ReadSkipEmptyNodes + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag to load all scenes in the document\n";
- aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
- aResult += aScope + "read.load.all.scenes :\t " + InternalParameters.ReadLoadAllScenes + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag to use Mesh name in case if Node name is empty\n";
- aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
- aResult += aScope + "read.use.mesh.name.as.fallback :\t " + InternalParameters.ReadUseMeshNameAsFallback + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag to skip triangulation loading\n";
- aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
- aResult += aScope + "read.skip.late.data.loading :\t " + InternalParameters.ReadSkipLateDataLoading + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag to keep information about deferred storage to load/unload triangulation later\n";
- aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
- aResult += aScope + "read.keep.late.data :\t " + InternalParameters.ReadKeepLateData + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag to print additional debug information\n";
- aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
- aResult += aScope + "read.print.debug.message :\t " + InternalParameters.ReadPrintDebugMessages + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Write parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Export special comment\n";
- aResult += "!Default value: ""(empty). Available values: <string>\n";
- aResult += aScope + "write.comment :\t " + InternalParameters.WriteComment + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Author of exported file name\n";
- aResult += "!Default value: ""(empty). Available values: <string>\n";
- aResult += aScope + "write.author :\t " + InternalParameters.WriteAuthor + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Transformation format to write into glTF file\n";
- aResult += "!Default value: 0(Compact). Available values: 0(Compact), 1(Mat4), 2(TRS)\n";
- aResult += aScope + "write.trsf.format :\t " + InternalParameters.WriteTrsfFormat + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "! Name format for exporting Nodes\n";
- aResult += "!Default value: 3(InstanceOrProduct). Available values: 0(Compact), 1(Mat4), 2(TRS), 3(InstanceOrProduct), 4(ProductOrInstance), 5(ProductAndInstance), 6(ProductAndInstanceAndOcaf)\n";
- aResult += aScope + "write.node.name.format :\t " + InternalParameters.WriteNodeNameFormat + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Name format for exporting Meshes\n";
- aResult += "!Default value: 1(Product). Available values: 0(Compact), 1(Mat4), 2(TRS), 3(InstanceOrProduct), 4(ProductOrInstance), 5(ProductAndInstance), 6(ProductAndInstanceAndOcaf)\n";
- aResult += aScope + "write.mesh.name.format :\t " + InternalParameters.WriteMeshNameFormat + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Export UV coordinates even if there are no mapped texture\n";
- aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
- aResult += aScope + "write.forced.uv.export :\t " + InternalParameters.WriteForcedUVExport + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag to write image textures into GLB file\n";
- aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
- aResult += aScope + "write.embed.textures.in.glb :\t " + InternalParameters.WriteEmbedTexturesInGlb + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag to merge faces within a single part\n";
- aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
- aResult += aScope + "write.merge.faces :\t " + InternalParameters.WriteMergeFaces + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag to prefer keeping 16-bit indexes while merging face\n";
- aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
- aResult += aScope + "write.split.indices16 :\t " + InternalParameters.WriteSplitIndices16 + "\n";
- aResult += "!\n";
-
- aResult += "!*****************************************************************************\n";
- return aResult;
-}
-
-//=======================================================================
-// function : Copy
-// purpose :
-//=======================================================================
-Handle(DE_ConfigurationNode) RWGltf_ConfigurationNode::Copy() const
-{
- return new RWGltf_ConfigurationNode(*this);
-}
-
-//=======================================================================
-// function : BuildProvider
-// purpose :
-//=======================================================================
-Handle(DE_Provider) RWGltf_ConfigurationNode::BuildProvider()
-{
- return new RWGltf_Provider(this);
-}
-
-//=======================================================================
-// function : IsImportSupported
-// purpose :
-//=======================================================================
-bool RWGltf_ConfigurationNode::IsImportSupported() const
-{
- return true;
-}
-
-//=======================================================================
-// function : IsExportSupported
-// purpose :
-//=======================================================================
-bool RWGltf_ConfigurationNode::IsExportSupported() const
-{
- return true;
-}
-
-//=======================================================================
-// function : GetFormat
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWGltf_ConfigurationNode::GetFormat() const
-{
- return TCollection_AsciiString("GLTF");
-}
-
-//=======================================================================
-// function : GetVendor
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWGltf_ConfigurationNode::GetVendor() const
-{
- return TCollection_AsciiString("OCC");
-}
-
-//=======================================================================
-// function : GetExtensions
-// purpose :
-//=======================================================================
-TColStd_ListOfAsciiString RWGltf_ConfigurationNode::GetExtensions() const
-{
- TColStd_ListOfAsciiString anExt;
- anExt.Append("gltf");
- anExt.Append("glb");
- return anExt;
-}
#ifndef _RWGltf_ConfigurationNode_HeaderFile
#define _RWGltf_ConfigurationNode_HeaderFile
-#include <DE_ConfigurationNode.hxx>
-#include <RWMesh_CoordinateSystem.hxx>
-#include <RWGltf_WriterTrsfFormat.hxx>
-#include <RWMesh_NameFormat.hxx>
+#include <DEGLTF_ConfigurationNode.hxx>
-//! The purpose of this class is to configure the transfer process for glTF format
-//! Stores the necessary settings for RWGltf_Provider.
-//! Configures and creates special provider to transfer glTF files.
-//!
-//! Nodes grouped by Vendor name and Format type.
-//! The Vendor name is "OCC"
-//! The Format type is "GLTF"
-//! The supported CAD extensions are ".gltf", ".glb"
-//! The import process is supported.
-//! The export process is supported.
-class RWGltf_ConfigurationNode : public DE_ConfigurationNode
-{
- DEFINE_STANDARD_RTTIEXT(RWGltf_ConfigurationNode, DE_ConfigurationNode)
-public:
-
- //! Initializes all field by default
- Standard_EXPORT RWGltf_ConfigurationNode();
-
- //! Copies values of all fields
- //! @param[in] theNode object to copy
- Standard_EXPORT RWGltf_ConfigurationNode(const Handle(RWGltf_ConfigurationNode)& theNode);
-
- //! Updates values according the resource
- //! @param[in] theResource input resource to use
- //! @return true if theResource loading has ended correctly
- Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource) Standard_OVERRIDE;
-
- //! Writes configuration to the string
- //! @return result resource string
- Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
-
- //! Copies values of all fields
- //! @return new object with the same field values
- Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
-
- //! Creates new provider for the own format
- //! @return new created provider
- Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
-
-public:
-
- //! Checks the import supporting
- //! @return true if import is supported
- Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
-
- //! Checks the export supporting
- //! @return true if export is supported
- Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
-
- //! Gets CAD format name of associated provider
- //! @return provider CAD format
- Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
-
- //! Gets provider's vendor name of associated provider
- //! @return provider's vendor name
- Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
-
- //! Gets list of supported file extensions
- //! @return list of extensions
- Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
-
-public:
- struct RWGltf_InternalSection
- {
- // Common
-// clang-format off
- double FileLengthUnit = 1.; //!< File length units to convert from while reading the file, defined as scale factor for m (meters)
- RWMesh_CoordinateSystem SystemCS = RWMesh_CoordinateSystem_Zup; //!< System origin coordinate system to perform conversion into during read
- RWMesh_CoordinateSystem FileCS = RWMesh_CoordinateSystem_Yup; //!< File origin coordinate system to perform conversion during read
- // Reading
- bool ReadSinglePrecision = true; //!< Flag for reading vertex data with single or double floating point precision
- bool ReadCreateShapes = false; //!< Flag for create a single triangulation
- TCollection_AsciiString ReadRootPrefix; //!< Root folder for generating root labels names
- bool ReadFillDoc = true; //!< Flag for fill document from shape sequence
- bool ReadFillIncomplete = true; //!< Flag for fill the document with partially retrieved data even if reader has failed with error
- int ReadMemoryLimitMiB = -1; //!< Memory usage limit
- bool ReadParallel = false; //!< Flag to use multithreading
- bool ReadSkipEmptyNodes = true; //!< Flag to ignore nodes without Geometry
- bool ReadLoadAllScenes = false; //!< Flag to load all scenes in the document
- bool ReadUseMeshNameAsFallback = true; //!< Flag to use Mesh name in case if Node name is empty
- bool ReadSkipLateDataLoading = false; //!< Flag to skip triangulation loading
- bool ReadKeepLateData = true;//!< Flag to keep information about deferred storage to load/unload triangulation later
- bool ReadPrintDebugMessages = false; //!< Flag to print additional debug information
- // Writing
- TCollection_AsciiString WriteComment; //!< Export special comment
- TCollection_AsciiString WriteAuthor; //!< Author of exported file name
- RWGltf_WriterTrsfFormat WriteTrsfFormat = RWGltf_WriterTrsfFormat_Compact; //!< Transformation format to write into glTF file
- RWMesh_NameFormat WriteNodeNameFormat = RWMesh_NameFormat_InstanceOrProduct; //!< Name format for exporting Nodes
- RWMesh_NameFormat WriteMeshNameFormat = RWMesh_NameFormat_Product; //!< Name format for exporting Meshes
- bool WriteForcedUVExport = false; //!< Export UV coordinates even if there are no mapped texture
- bool WriteEmbedTexturesInGlb = true; //!< Flag to write image textures into GLB file
- bool WriteMergeFaces = false; //!< Flag to merge faces within a single part
- bool WriteSplitIndices16 = false; //!< Flag to prefer keeping 16-bit indexes while merging face
-// clang-format on
- } InternalParameters;
-};
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef DEGLTF_ConfigurationNode RWGltf_ConfigurationNode;
#endif // _RWGltf_ConfigurationNode_HeaderFile
+++ /dev/null
-// Copyright (c) 2022 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <RWGltf_Provider.hxx>
-
-#include <Message.hxx>
-#include <RWGltf_CafWriter.hxx>
-#include <TDocStd_Document.hxx>
-#include <XCAFDoc_ShapeTool.hxx>
-#include <XCAFDoc_DocumentTool.hxx>
-
-namespace
-{
- //=======================================================================
- // function : SetReaderParameters
- // purpose :
- //=======================================================================
- static void SetReaderParameters(RWGltf_CafReader& theReader, const Handle(RWGltf_ConfigurationNode)& theNode)
- {
- theReader.SetDoublePrecision(!theNode->InternalParameters.ReadSinglePrecision);
- theReader.SetSystemLengthUnit(theNode->GlobalParameters.LengthUnit / 1000);
- theReader.SetSystemCoordinateSystem(theNode->InternalParameters.SystemCS);
- theReader.SetFileLengthUnit(theNode->InternalParameters.FileLengthUnit);
- theReader.SetFileCoordinateSystem(theNode->InternalParameters.FileCS);
- theReader.SetRootPrefix(theNode->InternalParameters.ReadRootPrefix);
- theReader.SetMemoryLimitMiB(theNode->InternalParameters.ReadMemoryLimitMiB);
-
- theReader.SetParallel(theNode->InternalParameters.ReadParallel);
- theReader.SetSkipEmptyNodes(theNode->InternalParameters.ReadSkipEmptyNodes);
- theReader.SetLoadAllScenes(theNode->InternalParameters.ReadLoadAllScenes);
- theReader.SetMeshNameAsFallback(theNode->InternalParameters.ReadUseMeshNameAsFallback);
- theReader.SetToSkipLateDataLoading(theNode->InternalParameters.ReadSkipLateDataLoading);
- theReader.SetToKeepLateData(theNode->InternalParameters.ReadKeepLateData);
- theReader.SetToPrintDebugMessages(theNode->InternalParameters.ReadPrintDebugMessages);
- }
-}
-
-IMPLEMENT_STANDARD_RTTIEXT(RWGltf_Provider, DE_Provider)
-
-//=======================================================================
-// function : RWGltf_Provider
-// purpose :
-//=======================================================================
-RWGltf_Provider::RWGltf_Provider()
-{}
-
-//=======================================================================
-// function : RWGltf_Provider
-// purpose :
-//=======================================================================
-RWGltf_Provider::RWGltf_Provider(const Handle(DE_ConfigurationNode)& theNode)
- :DE_Provider(theNode)
-{}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool RWGltf_Provider::Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- Handle(XSControl_WorkSession)& theWS,
- 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 " <<
- thePath << "\t: theDocument shouldn't be null";
- return false;
- }
- if (GetNode().IsNull() || (!GetNode().IsNull() && !GetNode()->IsKind(STANDARD_TYPE(RWGltf_ConfigurationNode))))
- {
- Message::SendFail() << "Error in the RWGltf_Provider during reading the file " <<
- thePath << "\t: Incorrect or empty Configuration Node";
- return false;
- }
- Handle(RWGltf_ConfigurationNode) aNode = Handle(RWGltf_ConfigurationNode)::DownCast(GetNode());
- RWGltf_CafReader aReader;
- aReader.SetDocument(theDocument);
- SetReaderParameters(aReader, aNode);
- XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
- if (!aReader.Perform(thePath, theProgress))
- {
- Message::SendFail() << "Error in the RWGltf_Provider during reading the file " << thePath;
- return false;
- }
-
- return true;
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool RWGltf_Provider::Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
- if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWGltf_ConfigurationNode)))
- {
- Message::SendFail() << "Error in the RWGltf_Provider during writing the file " <<
- thePath << "\t: Incorrect or empty Configuration Node";
- return false;
- }
- Handle(RWGltf_ConfigurationNode) aNode = Handle(RWGltf_ConfigurationNode)::DownCast(GetNode());
-
- RWMesh_CoordinateSystemConverter aConverter;
- Standard_Real aScaleFactorM = 1.;
- if (!XCAFDoc_DocumentTool::GetLengthUnit(theDocument, aScaleFactorM))
- {
- aConverter.SetInputLengthUnit(aNode->GlobalParameters.SystemUnit / 1000.);
- Message::SendWarning() << "Warning in the RWGltf_Provider during writing the file " <<
- thePath << "\t: The document has no information on Units. Using global parameter as initial Unit.";
- }
- aConverter.SetInputCoordinateSystem(aNode->InternalParameters.SystemCS);
- if (aNode->GlobalParameters.LengthUnit != 1000.)
- {
- Message::SendWarning() << "Warning in the RWGltf_Provider during writing the file " <<
- thePath << "\t: Target format doesn't support custom units. Model will be scaled to Meters";
- }
- aConverter.SetOutputLengthUnit(1.); // gltf units always Meters
- aConverter.SetOutputCoordinateSystem(aNode->InternalParameters.FileCS);
-
- TColStd_IndexedDataMapOfStringString aFileInfo;
- if (!aNode->InternalParameters.WriteAuthor.IsEmpty())
- {
- aFileInfo.Add("Author", aNode->InternalParameters.WriteAuthor);
- }
- if (!aNode->InternalParameters.WriteComment.IsEmpty())
- {
- aFileInfo.Add("Comments", aNode->InternalParameters.WriteComment);
- }
-
- TCollection_AsciiString anExt = thePath;
- anExt.LowerCase();
- RWGltf_CafWriter aWriter(thePath, anExt.EndsWith(".glb"));
- aWriter.SetCoordinateSystemConverter(aConverter);
- aWriter.SetTransformationFormat(aNode->InternalParameters.WriteTrsfFormat);
- aWriter.SetNodeNameFormat(aNode->InternalParameters.WriteNodeNameFormat);
- aWriter.SetMeshNameFormat(aNode->InternalParameters.WriteMeshNameFormat);
- aWriter.SetForcedUVExport(aNode->InternalParameters.WriteForcedUVExport);
- aWriter.SetToEmbedTexturesInGlb(aNode->InternalParameters.WriteEmbedTexturesInGlb);
- aWriter.SetMergeFaces(aNode->InternalParameters.WriteMergeFaces);
- aWriter.SetSplitIndices16(aNode->InternalParameters.WriteSplitIndices16);
- if (!aWriter.Perform(theDocument, aFileInfo, theProgress))
- {
- Message::SendFail() << "Error in the RWGltf_Provider during writing the file " << thePath;
- return false;
- }
- return true;
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool RWGltf_Provider::Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- Handle(XSControl_WorkSession)& theWS,
- 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 " <<
- thePath << "\t: Incorrect or empty Configuration Node";
- return false;
- }
- Handle(RWGltf_ConfigurationNode) aNode = Handle(RWGltf_ConfigurationNode)::DownCast(GetNode());
- RWGltf_CafReader aReader;
- SetReaderParameters(aReader, aNode);
- if (!aReader.Perform(thePath, theProgress))
- {
- Message::SendFail() << "Error in the RWGltf_Provider during reading the file " << thePath;
- return false;
- }
- theShape = aReader.SingleShape();
- return true;
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool RWGltf_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);
-}
-
-//=======================================================================
-// function : GetFormat
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWGltf_Provider::GetFormat() const
-{
- return TCollection_AsciiString("GLTF");
-}
-
-//=======================================================================
-// function : GetVendor
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWGltf_Provider::GetVendor() const
-{
- return TCollection_AsciiString("OCC");
-}
#ifndef _RWGltf_Provider_HeaderFile
#define _RWGltf_Provider_HeaderFile
-#include <DE_Provider.hxx>
-#include <RWGltf_CafReader.hxx>
-#include <RWGltf_ConfigurationNode.hxx>
+#include <DEGLTF_Provider.hxx>
-//! The class to transfer glTF files.
-//! Reads and Writes any glTF files into/from OCCT.
-//! Each operation needs configuration node.
-//!
-//! Providers grouped by Vendor name and Format type.
-//! The Vendor name is "OCC"
-//! The Format type is "GLTF"
-//! The import process is supported.
-//! The export process is supported.
-class RWGltf_Provider : public DE_Provider
-{
-public:
- DEFINE_STANDARD_RTTIEXT(RWGltf_Provider, DE_Provider)
-
-public:
-
- //! Default constructor
- //! Configure translation process with global configuration
- Standard_EXPORT RWGltf_Provider();
-
- //! Configure translation process
- //! @param[in] theNode object to copy
- Standard_EXPORT RWGltf_Provider(const Handle(DE_ConfigurationNode)& theNode);
-
-public:
-
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theDocument document to save result
- //! @param[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- 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[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- 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[in] theProgress 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[in] theProgress 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
- //! @param[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- 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[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- 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[in] theProgress 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[in] theProgress 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 CAD format
- Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
-
- //! Gets provider's vendor name of associated provider
- //! @return provider's vendor name
- Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
-
-};
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef DEGLTF_Provider RWGltf_Provider;
#endif // _RWGltf_Provider_HeaderFile
RWObj_CafReader.hxx
RWObj_CafWriter.cxx
RWObj_CafWriter.hxx
-RWObj_ConfigurationNode.cxx
RWObj_ConfigurationNode.hxx
RWObj_Material.hxx
RWObj_MtlReader.cxx
RWObj_ObjMaterialMap.hxx
RWObj_ObjWriterContext.cxx
RWObj_ObjWriterContext.hxx
-RWObj_Provider.cxx
RWObj_Provider.hxx
RWObj_Reader.cxx
RWObj_Reader.hxx
+++ /dev/null
-// Copyright (c) 2022 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <RWObj_ConfigurationNode.hxx>
-
-#include <DE_ConfigurationContext.hxx>
-#include <DE_PluginHolder.hxx>
-#include <RWObj_Provider.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(RWObj_ConfigurationNode, DE_ConfigurationNode)
-
-namespace
-{
- static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
- {
- static const TCollection_AsciiString aScope = "provider";
- return aScope;
- }
-
- // Wrapper to auto-load DE component
- DE_PluginHolder<RWObj_ConfigurationNode> THE_OCCT_OBJ_COMPONENT_PLUGIN;
-}
-
-//=======================================================================
-// function : RWObj_ConfigurationNode
-// purpose :
-//=======================================================================
-RWObj_ConfigurationNode::RWObj_ConfigurationNode() :
- DE_ConfigurationNode()
-{}
-
-//=======================================================================
-// function : RWObj_ConfigurationNode
-// purpose :
-//=======================================================================
-RWObj_ConfigurationNode::RWObj_ConfigurationNode(const Handle(RWObj_ConfigurationNode)& theNode)
- :DE_ConfigurationNode(theNode)
-{
- InternalParameters = theNode->InternalParameters;
-}
-
-//=======================================================================
-// function : Load
-// purpose :
-//=======================================================================
-bool RWObj_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
-{
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
- InternalParameters.FileLengthUnit =
- theResource->RealVal("file.length.unit", InternalParameters.FileLengthUnit, aScope);
- InternalParameters.SystemCS = (RWMesh_CoordinateSystem)
- (theResource->IntegerVal("system.cs", (int)InternalParameters.SystemCS, aScope) % 2);
- InternalParameters.FileCS = (RWMesh_CoordinateSystem)
- (theResource->IntegerVal("file.cs", (int)InternalParameters.SystemCS, aScope) % 2);
-
- InternalParameters.ReadSinglePrecision =
- theResource->BooleanVal("read.single.precision", InternalParameters.ReadSinglePrecision, aScope);
- InternalParameters.ReadCreateShapes =
- theResource->BooleanVal("read.create.shapes", InternalParameters.ReadCreateShapes, aScope);
- InternalParameters.ReadRootPrefix =
- theResource->StringVal("read.root.prefix", InternalParameters.ReadRootPrefix, aScope);
- InternalParameters.ReadFillDoc =
- theResource->BooleanVal("read.fill.doc", InternalParameters.ReadFillDoc, aScope);
- InternalParameters.ReadFillIncomplete =
- theResource->BooleanVal("read.fill.incomplete", InternalParameters.ReadFillIncomplete, aScope);
- InternalParameters.ReadMemoryLimitMiB =
- theResource->IntegerVal("read.memory.limit.mib", InternalParameters.ReadMemoryLimitMiB, aScope);
-
- InternalParameters.WriteComment =
- theResource->StringVal("write.comment", InternalParameters.WriteComment, aScope);
- InternalParameters.WriteAuthor =
- theResource->StringVal("write.author", InternalParameters.WriteAuthor, aScope);
- return true;
-}
-
-//=======================================================================
-// function : Save
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWObj_ConfigurationNode::Save() const
-{
- TCollection_AsciiString aResult;
- aResult += "!*****************************************************************************\n";
- aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
-
- aResult += "!\n";
- aResult += "!Common parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!File length units to convert from while reading the file, defined as scale factor for m (meters)\n";
- aResult += "!Default value: 1.0(M)\n";
- aResult += aScope + "file.length.unit :\t " + InternalParameters.FileLengthUnit + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!System origin coordinate system to perform conversion into during read\n";
- aResult += "!Default value: 0(Zup). Available values: 0(Zup), 1(Yup)\n";
- aResult += aScope + "system.cs :\t " + InternalParameters.SystemCS + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!File origin coordinate system to perform conversion during read\n";
- aResult += "!Default value: 1(Yup). Available values: 0(Zup), 1(Yup)\n";
- aResult += aScope + "file.cs :\t " + InternalParameters.FileCS + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Read parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag for reading vertex data with single or double floating point precision\n";
- aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
- aResult += aScope + "read.single.precision :\t " + InternalParameters.ReadSinglePrecision + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag for create a single triangulation\n";
- aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
- aResult += aScope + "read.create.shapes :\t " + InternalParameters.ReadCreateShapes + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Root folder for generating root labels names\n";
- aResult += "!Default value: ""(empty). Available values: <path>\n";
- aResult += aScope + "read.root.prefix :\t " + InternalParameters.ReadRootPrefix + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag for fill document from shape sequence\n";
- aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
- aResult += aScope + "read.fill.doc :\t " + InternalParameters.ReadFillDoc + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag for fill the document with partially retrieved data even if reader has fa-iled with er-ror\n";
- aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
- aResult += aScope + "read.fill.incomplete :\t " + InternalParameters.ReadFillIncomplete + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Memory usage limit(MiB)\n";
- aResult += "!Default value: -1(no limit). Available values: -1(no limit), any positive value\n";
- aResult += aScope + "read.memory.limit.mib :\t " + InternalParameters.ReadMemoryLimitMiB + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Write parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Export special comment\n";
- aResult += "!Default value: ""(empty). Available values: <string>\n";
- aResult += aScope + "write.comment :\t " + InternalParameters.WriteComment + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Author of exported file name\n";
- aResult += "!Default value: ""(empty). Available values: <string>\n";
- aResult += aScope + "write.author :\t " + InternalParameters.WriteAuthor + "\n";
- aResult += "!\n";
-
- aResult += "!*****************************************************************************\n";
- return aResult;
-}
-
-//=======================================================================
-// function : Copy
-// purpose :
-//=======================================================================
-Handle(DE_ConfigurationNode) RWObj_ConfigurationNode::Copy() const
-{
- return new RWObj_ConfigurationNode(*this);
-}
-
-//=======================================================================
-// function : BuildProvider
-// purpose :
-//=======================================================================
-Handle(DE_Provider) RWObj_ConfigurationNode::BuildProvider()
-{
- return new RWObj_Provider(this);
-}
-
-//=======================================================================
-// function : IsImportSupported
-// purpose :
-//=======================================================================
-bool RWObj_ConfigurationNode::IsImportSupported() const
-{
- return true;
-}
-
-//=======================================================================
-// function : IsExportSupported
-// purpose :
-//=======================================================================
-bool RWObj_ConfigurationNode::IsExportSupported() const
-{
- return true;
-}
-
-//=======================================================================
-// function : GetFormat
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWObj_ConfigurationNode::GetFormat() const
-{
- return TCollection_AsciiString("OBJ");
-}
-
-//=======================================================================
-// function : GetVendor
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWObj_ConfigurationNode::GetVendor() const
-{
- return TCollection_AsciiString("OCC");
-}
-
-//=======================================================================
-// function : GetExtensions
-// purpose :
-//=======================================================================
-TColStd_ListOfAsciiString RWObj_ConfigurationNode::GetExtensions() const
-{
- TColStd_ListOfAsciiString anExt;
- anExt.Append("obj");
- return anExt;
-}
#ifndef _RWObj_ConfigurationNode_HeaderFile
#define _RWObj_ConfigurationNode_HeaderFile
-#include <DE_ConfigurationNode.hxx>
-#include <RWMesh_CoordinateSystem.hxx>
+#include <DEOBJ_ConfigurationNode.hxx>
-//! The purpose of this class is to configure the transfer process for OBJ format
-//! Stores the necessary settings for RWObj_Provider.
-//! Configures and creates special provider to transfer OBJ files.
-//!
-//! Nodes grouped by Vendor name and Format type.
-//! The Vendor name is "OCC"
-//! The Format type is "OBJ"
-//! The supported CAD extension is ".obj"
-//! The import process is supported.
-//! The export process is supported.
-class RWObj_ConfigurationNode : public DE_ConfigurationNode
-{
- DEFINE_STANDARD_RTTIEXT(RWObj_ConfigurationNode, DE_ConfigurationNode)
-public:
-
- //! Initializes all field by default
- Standard_EXPORT RWObj_ConfigurationNode();
-
- //! Copies values of all fields
- //! @param[in] theNode object to copy
- Standard_EXPORT RWObj_ConfigurationNode(const Handle(RWObj_ConfigurationNode)& theNode);
-
- //! Updates values according the resource
- //! @param[in] theResource input resource to use
- //! @return true if theResource loading has ended correctly
- Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource) Standard_OVERRIDE;
-
- //! Writes configuration to the string
- //! @return result resource string
- Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
-
- //! Copies values of all fields
- //! @return new object with the same field values
- Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
-
- //! Creates new provider for the own format
- //! @return new created provider
- Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
-
-public:
-
- //! Checks the import supporting
- //! @return true if import is supported
- Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
-
- //! Checks the export supporting
- //! @return true if export is supported
- Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
-
- //! Gets CAD format name of associated provider
- //! @return provider CAD format
- Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
-
- //! Gets provider's vendor name of associated provider
- //! @return provider's vendor name
- Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
-
- //! Gets list of supported file extensions
- //! @return list of extensions
- Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
-
-public:
- struct RWObj_InternalSection
- {
- // Common
-// clang-format off
- double FileLengthUnit = 1.; //!< File length units to convert from while reading the file, defined as scale factor for m (meters)
- RWMesh_CoordinateSystem SystemCS = RWMesh_CoordinateSystem_Zup; //!< System origin coordinate system to perform conversion into during read
- RWMesh_CoordinateSystem FileCS = RWMesh_CoordinateSystem_Yup; //!< File origin coordinate system to perform conversion during read
- // Reading
- bool ReadSinglePrecision = false; //!< Flag for reading vertex data with single or double floating point precision
- bool ReadCreateShapes = false; //!< Flag for create a single triangulation
- TCollection_AsciiString ReadRootPrefix; //!< Root folder for generating root labels names
- bool ReadFillDoc = true; //!< Flag for fill document from shape sequence
- bool ReadFillIncomplete = true; //!< Flag for fill the document with partially retrieved data even if reader has failed with error
-// clang-format on
- int ReadMemoryLimitMiB = -1; //!< Memory usage limit
- // Writing
- TCollection_AsciiString WriteComment; //!< Export special comment
- TCollection_AsciiString WriteAuthor; //!< Author of exported file name
- } InternalParameters;
-};
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef DEOBJ_ConfigurationNode RWObj_ConfigurationNode;
#endif // _RWObj_ConfigurationNode_HeaderFile
+++ /dev/null
-// Copyright (c) 2022 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <RWObj_Provider.hxx>
-
-#include <BRep_Builder.hxx>
-#include <RWObj_ConfigurationNode.hxx>
-#include <RWObj_CafReader.hxx>
-#include <RWObj_CafWriter.hxx>
-#include <TDocStd_Document.hxx>
-#include <XCAFDoc_ShapeTool.hxx>
-#include <XCAFDoc_DocumentTool.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(RWObj_Provider, DE_Provider)
-
-//=======================================================================
-// function : RWObj_Provider
-// purpose :
-//=======================================================================
-RWObj_Provider::RWObj_Provider()
-{}
-
-//=======================================================================
-// function : RWObj_Provider
-// purpose :
-//=======================================================================
-RWObj_Provider::RWObj_Provider(const Handle(DE_ConfigurationNode)& theNode)
- :DE_Provider(theNode)
-{}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- Handle(XSControl_WorkSession)& theWS,
- 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 " <<
- thePath << "\t: theDocument shouldn't be null";
- return false;
- }
- if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWObj_ConfigurationNode)))
- {
- Message::SendFail() << "Error in the RWObj_ConfigurationNode during reading the file " <<
- thePath << "\t: Incorrect or empty Configuration Node";
- return false;
- }
- Handle(RWObj_ConfigurationNode) aNode = Handle(RWObj_ConfigurationNode)::DownCast(GetNode());
- RWObj_CafReader aReader;
- aReader.SetSinglePrecision(aNode->InternalParameters.ReadSinglePrecision);
- aReader.SetSystemLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
- aReader.SetSystemCoordinateSystem(aNode->InternalParameters.SystemCS);
- aReader.SetFileLengthUnit(aNode->InternalParameters.FileLengthUnit);
- aReader.SetFileCoordinateSystem(aNode->InternalParameters.FileCS);
- aReader.SetDocument(theDocument);
- aReader.SetRootPrefix(aNode->InternalParameters.ReadRootPrefix);
- aReader.SetMemoryLimitMiB(aNode->InternalParameters.ReadMemoryLimitMiB);
- if (!aReader.Perform(thePath, theProgress))
- {
- Message::SendFail() << "Error in the RWObj_ConfigurationNode during reading the file " << thePath;
- return false;
- }
- XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
- return true;
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
- if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWObj_ConfigurationNode)))
- {
- Message::SendFail() << "Error in the RWObj_ConfigurationNode during writing the file " <<
- thePath << "\t: Incorrect or empty Configuration Node";
- return false;
- }
- Handle(RWObj_ConfigurationNode) aNode = Handle(RWObj_ConfigurationNode)::DownCast(GetNode());
-
- TColStd_IndexedDataMapOfStringString aFileInfo;
- if (!aNode->InternalParameters.WriteAuthor.IsEmpty())
- {
- aFileInfo.Add("Author", aNode->InternalParameters.WriteAuthor);
- }
- if (!aNode->InternalParameters.WriteComment.IsEmpty())
- {
- aFileInfo.Add("Comments", aNode->InternalParameters.WriteComment);
- }
-
- RWMesh_CoordinateSystemConverter aConverter;
- Standard_Real aScaleFactorMM = 1.;
- if (XCAFDoc_DocumentTool::GetLengthUnit(theDocument, aScaleFactorMM, UnitsMethods_LengthUnit_Millimeter))
- {
- aConverter.SetInputLengthUnit(aScaleFactorMM / 1000.);
- }
- else
- {
- aConverter.SetInputLengthUnit(aNode->GlobalParameters.SystemUnit / 1000.);
- Message::SendWarning() << "Warning in the RWObj_Provider during writing the file " <<
- thePath << "\t: The document has no information on Units. Using global parameter as initial Unit.";
- }
- aConverter.SetInputCoordinateSystem(aNode->InternalParameters.SystemCS);
- aConverter.SetOutputLengthUnit(aNode->GlobalParameters.LengthUnit / 1000.);
- aConverter.SetOutputCoordinateSystem(aNode->InternalParameters.FileCS);
-
- RWObj_CafWriter aWriter(thePath);
- aWriter.SetCoordinateSystemConverter(aConverter);
- if (!aWriter.Perform(theDocument, aFileInfo, theProgress))
- {
- Message::SendFail() << "Error in the RWObj_ConfigurationNode during writing the file " << thePath;
- return false;
- }
- return true;
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- Handle(XSControl_WorkSession)& theWS,
- 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 " <<
- thePath << "\t: Incorrect or empty Configuration Node";
- return false;
- }
- Handle(RWObj_ConfigurationNode) aNode = Handle(RWObj_ConfigurationNode)::DownCast(GetNode());
- RWMesh_CoordinateSystemConverter aConverter;
- aConverter.SetOutputLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
- aConverter.SetOutputCoordinateSystem(aNode->InternalParameters.SystemCS);
- aConverter.SetInputLengthUnit(aNode->InternalParameters.FileLengthUnit);
- aConverter.SetInputCoordinateSystem(aNode->InternalParameters.FileCS);
-
- RWObj_TriangulationReader aSimpleReader;
- aSimpleReader.SetTransformation(aConverter);
- aSimpleReader.SetSinglePrecision(aNode->InternalParameters.ReadSinglePrecision);
- aSimpleReader.SetCreateShapes(aNode->InternalParameters.ReadCreateShapes);
- aSimpleReader.SetSinglePrecision(aNode->InternalParameters.ReadSinglePrecision);
- aSimpleReader.SetMemoryLimit(aNode->InternalParameters.ReadMemoryLimitMiB);
- if (!aSimpleReader.Read(thePath, theProgress))
- {
- Message::SendFail() << "Error in the RWObj_ConfigurationNode during reading the file " << thePath;
- return false;
- }
- Handle(Poly_Triangulation) aTriangulation = aSimpleReader.GetTriangulation();
- TopoDS_Face aFace;
- BRep_Builder aBuiler;
- aBuiler.MakeFace(aFace);
- aBuiler.UpdateFace(aFace, aTriangulation);
- theShape = aFace;
- return true;
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool RWObj_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);
-}
-
-//=======================================================================
-// function : GetFormat
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWObj_Provider::GetFormat() const
-{
- return TCollection_AsciiString("OBJ");
-}
-
-//=======================================================================
-// function : GetVendor
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWObj_Provider::GetVendor() const
-{
- return TCollection_AsciiString("OCC");
-}
#ifndef _RWObj_Provider_HeaderFile
#define _RWObj_Provider_HeaderFile
-#include <DE_Provider.hxx>
+#include <DEOBJ_Provider.hxx>
-//! The class to transfer OBJ files.
-//! Reads and Writes any OBJ files into/from OCCT.
-//! Each operation needs configuration node.
-//!
-//! Providers grouped by Vendor name and Format type.
-//! The Vendor name is "OCC"
-//! The Format type is "OBJ"
-//! The import process is supported.
-//! The export process is supported.
-class RWObj_Provider : public DE_Provider
-{
-public:
- DEFINE_STANDARD_RTTIEXT(RWObj_Provider, DE_Provider)
-
-public:
-
- //! Default constructor
- //! Configure translation process with global configuration
- Standard_EXPORT RWObj_Provider();
-
- //! Configure translation process
- //! @param[in] theNode object to copy
- Standard_EXPORT RWObj_Provider(const Handle(DE_ConfigurationNode)& theNode);
-
-public:
-
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theDocument document to save result
- //! @param[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- 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[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- 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[in] theProgress 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[in] theProgress 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
- //! @param[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- 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[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- 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[in] theProgress 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[in] theProgress 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 CAD format
- Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
-
- //! Gets provider's vendor name of associated provider
- //! @return provider's vendor name
- Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
-};
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef DEOBJ_Provider RWObj_Provider;
#endif // _RWObj_Provider_HeaderFile
RWPly_CafWriter.cxx
RWPly_CafWriter.hxx
-RWPly_ConfigurationNode.cxx
RWPly_ConfigurationNode.hxx
RWPly_PlyWriterContext.cxx
RWPly_PlyWriterContext.hxx
-RWPly_Provider.cxx
RWPly_Provider.hxx
+++ /dev/null
-// Copyright (c) 2022 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <RWPly_ConfigurationNode.hxx>
-
-#include <DE_ConfigurationContext.hxx>
-#include <DE_PluginHolder.hxx>
-#include <NCollection_Buffer.hxx>
-#include <RWPly_Provider.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(RWPly_ConfigurationNode, DE_ConfigurationNode)
-
-namespace
-{
- static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
- {
- static const TCollection_AsciiString aScope = "provider";
- return aScope;
- }
-
- // Wrapper to auto-load DE component
- DE_PluginHolder<RWPly_ConfigurationNode> THE_OCCT_PLY_COMPONENT_PLUGIN;
-}
-
-//=======================================================================
-// function : RWPly_ConfigurationNode
-// purpose :
-//=======================================================================
-RWPly_ConfigurationNode::RWPly_ConfigurationNode() :
- DE_ConfigurationNode()
-{}
-
-//=======================================================================
-// function : RWPly_ConfigurationNode
-// purpose :
-//=======================================================================
-RWPly_ConfigurationNode::RWPly_ConfigurationNode(const Handle(RWPly_ConfigurationNode)& theNode)
- :DE_ConfigurationNode(theNode)
-{
- InternalParameters = theNode->InternalParameters;
-}
-
-//=======================================================================
-// function : Load
-// purpose :
-//=======================================================================
-bool RWPly_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
-{
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
- InternalParameters.FileLengthUnit =
- theResource->RealVal("file.length.unit", InternalParameters.FileLengthUnit, aScope);
- InternalParameters.SystemCS =
- (RWMesh_CoordinateSystem)(theResource->IntegerVal("system.cs", (int)InternalParameters.SystemCS, aScope) % 2);
- InternalParameters.FileCS =
- (RWMesh_CoordinateSystem)(theResource->IntegerVal("file.cs", (int)InternalParameters.SystemCS, aScope) % 2);
-
- InternalParameters.WriteNormals =
- theResource->BooleanVal("write.normals", InternalParameters.WriteNormals, aScope);
- InternalParameters.WriteColors =
- theResource->BooleanVal("write.colors", InternalParameters.WriteColors, aScope);
- InternalParameters.WriteTexCoords =
- theResource->BooleanVal("write.tex.coords", InternalParameters.WriteTexCoords, aScope);
- InternalParameters.WritePartId =
- theResource->BooleanVal("write.part.id", InternalParameters.WritePartId, aScope);
- InternalParameters.WriteFaceId =
- theResource->BooleanVal("write.face.id", InternalParameters.WriteFaceId, aScope);
- InternalParameters.WriteComment =
- theResource->StringVal("write.comment", InternalParameters.WriteComment, aScope);
- InternalParameters.WriteAuthor =
- theResource->StringVal("write.author", InternalParameters.WriteAuthor, aScope);
- return Standard_True;
-}
-
-//=======================================================================
-// function : Save
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWPly_ConfigurationNode::Save() const
-{
- TCollection_AsciiString aResult;
- aResult += "!*****************************************************************************\n";
- aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
-
- aResult += "!\n";
- aResult += "!Common parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!File length units to convert from while reading the file, defined as scale factor for m (meters)\n";
- aResult += "!Default value: 1.0(MM)\n";
- aResult += aScope + "file.length.unit :\t " + InternalParameters.FileLengthUnit + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!System origin coordinate system to perform conversion into during read\n";
- aResult += "!Default value: 0(Zup). Available values: 0(Zup), 1(Yup)\n";
- aResult += aScope + "system.cs :\t " + InternalParameters.SystemCS + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!File origin coordinate system to perform conversion during read\n";
- aResult += "!Default value: 1(Yup). Available values: 0(Zup), 1(Yup)\n";
- aResult += aScope + "file.cs :\t " + InternalParameters.FileCS + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Write parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag for write normals\n";
- aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
- aResult += aScope + "write.normals :\t " + InternalParameters.WriteNormals + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag for write colors\n";
- aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
- aResult += aScope + "write.colors :\t " + InternalParameters.WriteColors + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag for write UV / texture coordinates\n";
- aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
- aResult += aScope + "write.tex.coords :\t " + InternalParameters.WriteTexCoords + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag for write part Id as element attribute\n";
- aResult += "!Default value: 1(true). Available values: 0(false), 1(true)\n";
- aResult += aScope + "write.part.id :\t " + InternalParameters.WritePartId + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Flag for write face Id as element attribute. Cannot be combined with HasPartId\n";
- aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
- aResult += aScope + "write.face.id :\t " + InternalParameters.WriteFaceId + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Export special comment\n";
- aResult += "!Default value: ""(empty). Available values: <string>\n";
- aResult += aScope + "write.comment :\t " + InternalParameters.WriteComment + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Author of exported file name\n";
- aResult += "!Default value: ""(empty). Available values: <string>\n";
- aResult += aScope + "write.author :\t " + InternalParameters.WriteAuthor + "\n";
- aResult += "!\n";
-
- aResult += "!*****************************************************************************\n";
- return aResult;
-}
-
-//=======================================================================
-// function : Copy
-// purpose :
-//=======================================================================
-Handle(DE_ConfigurationNode) RWPly_ConfigurationNode::Copy() const
-{
- return new RWPly_ConfigurationNode(*this);
-}
-
-//=======================================================================
-// function : BuildProvider
-// purpose :
-//=======================================================================
-Handle(DE_Provider) RWPly_ConfigurationNode::BuildProvider()
-{
- return new RWPly_Provider(this);
-}
-
-//=======================================================================
-// function : IsImportSupported
-// purpose :
-//=======================================================================
-bool RWPly_ConfigurationNode::IsImportSupported() const
-{
- return Standard_False;
-}
-
-//=======================================================================
-// function : IsExportSupported
-// purpose :
-//=======================================================================
-bool RWPly_ConfigurationNode::IsExportSupported() const
-{
- return Standard_True;
-}
-
-//=======================================================================
-// function : GetFormat
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWPly_ConfigurationNode::GetFormat() const
-{
- return TCollection_AsciiString("PLY");
-}
-
-//=======================================================================
-// function : GetVendor
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWPly_ConfigurationNode::GetVendor() const
-{
- return TCollection_AsciiString("OCC");
-}
-
-//=======================================================================
-// function : GetExtensions
-// purpose :
-//=======================================================================
-TColStd_ListOfAsciiString RWPly_ConfigurationNode::GetExtensions() const
-{
- TColStd_ListOfAsciiString anExt;
- anExt.Append("ply");
- return anExt;
-}
-
-//=======================================================================
-// function : CheckContent
-// purpose :
-//=======================================================================
-bool RWPly_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
-{
- if (theBuffer.IsNull() || theBuffer->Size() < 4)
- {
- return false;
- }
- const char* aBytes = (const char*)theBuffer->Data();
- if (!::strncmp(aBytes, "ply", 3) && ::isspace(aBytes[3]))
- {
- return true;
- }
- return false;
-}
#ifndef _RWPly_ConfigurationNode_HeaderFile
#define _RWPly_ConfigurationNode_HeaderFile
-#include <DE_ConfigurationNode.hxx>
-#include <Precision.hxx>
-#include <RWMesh_CoordinateSystem.hxx>
+#include <DEPLY_ConfigurationNode.hxx>
-class DE_ConfigurationContext;
-
-//! The purpose of this class is to configure the transfer process for PLY format
-//! Stores the necessary settings for RWPly_Provider.
-//! Configures and creates special provider to transfer PLY files.
-//!
-//! Nodes grouped by Vendor name and Format type.
-//! The Vendor name is "OCC"
-//! The Format type is "PLY"
-//! The supported CAD extension is ".ply"
-//! The import process isn't supported.
-//! The export process is supported.
-class RWPly_ConfigurationNode : public DE_ConfigurationNode
-{
- DEFINE_STANDARD_RTTIEXT(RWPly_ConfigurationNode, DE_ConfigurationNode)
-public:
-
- //! Initializes all field by default
- Standard_EXPORT RWPly_ConfigurationNode();
-
- //! Copies values of all fields
- //! @param[in] theNode object to copy
- Standard_EXPORT RWPly_ConfigurationNode(const Handle(RWPly_ConfigurationNode)& theNode);
-
- //! Updates values according the resource
- //! @param[in] theResource input resource to use
- //! @return true if theResource loading has ended correctly
- Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource) Standard_OVERRIDE;
-
- //! Writes configuration to the string
- //! @return result resource string
- Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
-
- //! Copies values of all fields
- //! @return new object with the same field values
- Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
-
- //! Creates new provider for the own format
- //! @return new created provider
- Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
-
-public:
-
- //! Checks the import supporting
- //! @return true if import is supported
- Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
-
- //! Checks the export supporting
- //! @return true if export is supported
- Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
-
- //! Gets CAD format name of associated provider
- //! @return provider CAD format
- Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
-
- //! Gets provider's vendor name of associated provider
- //! @return provider's vendor name
- Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
-
- //! Gets list of supported file extensions
- //! @return list of extensions
- Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
-
- //! Checks the file content to verify a format
- //! @param[in] theBuffer read stream buffer to check content
- //! @return Standard_True if file is supported by a current provider
- Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const Standard_OVERRIDE;
-
-public:
- struct RWPly_InternalSection
- {
- // Common
-// clang-format off
- double FileLengthUnit = 1.; //!< File length units to convert from while reading the file, defined as scale factor for m (meters)
- RWMesh_CoordinateSystem SystemCS = RWMesh_CoordinateSystem_Zup; //!< System origin coordinate system to perform conversion into during read
- RWMesh_CoordinateSystem FileCS = RWMesh_CoordinateSystem_Yup; //!< File origin coordinate system to perform conversion during read
- // Writing
- bool WriteNormals = true; //!< Flag for write normals
- bool WriteColors = true; //!< Flag for write colors
- bool WriteTexCoords = false; //!< Flag for write UV / texture coordinates
- bool WritePartId = true; //!< Flag for write part Id as element attribute
- bool WriteFaceId = false; //!< Flag for write face Id as element attribute. Cannot be combined with HasPartId
-// clang-format on
- TCollection_AsciiString WriteComment; //!< Export special comment
- TCollection_AsciiString WriteAuthor; //!< Author of exported file name
- } InternalParameters;
-};
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef DEPLY_ConfigurationNode RWPly_ConfigurationNode;
#endif // _RWPly_ConfigurationNode_HeaderFile
+++ /dev/null
-// Copyright (c) 2022 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <RWPly_Provider.hxx>
-
-#include <BRep_Builder.hxx>
-#include <DE_Wrapper.hxx>
-#include <Message.hxx>
-#include <RWPly_ConfigurationNode.hxx>
-#include <RWPly_CafWriter.hxx>
-#include <RWMesh_FaceIterator.hxx>
-#include <RWPly_PlyWriterContext.hxx>
-#include <TDocStd_Document.hxx>
-#include <XCAFDoc_ShapeTool.hxx>
-#include <XCAFDoc_DocumentTool.hxx>
-#include <XCAFPrs_DocumentExplorer.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(RWPly_Provider, DE_Provider)
-
-//=======================================================================
-// function : RWPly_Provider
-// purpose :
-//=======================================================================
-RWPly_Provider::RWPly_Provider()
-{}
-
-//=======================================================================
-// function : RWPly_Provider
-// purpose :
-//=======================================================================
-RWPly_Provider::RWPly_Provider(const Handle(DE_ConfigurationNode)& theNode)
- :DE_Provider(theNode)
-{}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool RWPly_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 : 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 " <<
- thePath << "\t: Incorrect or empty Configuration Node";
- return false;
- }
- Handle(RWPly_ConfigurationNode) aNode = Handle(RWPly_ConfigurationNode)::DownCast(GetNode());
-
- TDF_LabelSequence aRootLabels;
- Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
- aShapeTool->GetFreeShapes(aRootLabels);
- if (aRootLabels.IsEmpty())
- {
- return Standard_True;
- }
-
- TColStd_IndexedDataMapOfStringString aFileInfo;
- if (!aNode->InternalParameters.WriteAuthor.IsEmpty())
- {
- aFileInfo.Add("Author", aNode->InternalParameters.WriteAuthor);
- }
- if (!aNode->InternalParameters.WriteComment.IsEmpty())
- {
- aFileInfo.Add("Comments", aNode->InternalParameters.WriteComment);
- }
- RWMesh_CoordinateSystemConverter aConverter;
- Standard_Real aScaleFactorM = 1.;
- if (XCAFDoc_DocumentTool::GetLengthUnit(theDocument, aScaleFactorM))
- {
- aConverter.SetInputLengthUnit(aScaleFactorM);
- }
- else
- {
- aConverter.SetInputLengthUnit(aNode->GlobalParameters.SystemUnit / 1000.);
- Message::SendWarning() << "Warning in the RWPly_Provider during writing the file " <<
- thePath << "\t: The document has no information on Units. Using global parameter as initial Unit.";
- }
- aConverter.SetInputCoordinateSystem(aNode->InternalParameters.SystemCS);
- aConverter.SetOutputLengthUnit(aNode->GlobalParameters.LengthUnit / 1000.);
- aConverter.SetOutputCoordinateSystem(aNode->InternalParameters.FileCS);
-
- RWPly_CafWriter aPlyCtx(thePath);
- aPlyCtx.SetNormals(aNode->InternalParameters.WriteNormals);
- aPlyCtx.SetColors(aNode->InternalParameters.WriteColors);
- aPlyCtx.SetTexCoords(aNode->InternalParameters.WriteTexCoords);
- aPlyCtx.SetPartId(aNode->InternalParameters.WritePartId);
- aPlyCtx.SetFaceId(aNode->InternalParameters.WriteFaceId);
- if (!aPlyCtx.Perform(theDocument, aFileInfo, theProgress))
- {
- Message::SendFail() << "Error in the RWPly_Provider during writing the file "
- << thePath << "\t: Cannot perform the document";
- return false;
- }
-
- return true;
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool RWPly_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 : 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);
-}
-
-//=======================================================================
-// function : GetFormat
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWPly_Provider::GetFormat() const
-{
- return TCollection_AsciiString("PLY");
-}
-
-//=======================================================================
-// function : GetVendor
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWPly_Provider::GetVendor() const
-{
- return TCollection_AsciiString("OCC");
-}
#ifndef _RWPly_Provider_HeaderFile
#define _RWPly_Provider_HeaderFile
-#include <DE_Provider.hxx>
+#include <DEPLY_Provider.hxx>
-//! The class to transfer PLY files.
-//! Writes any PLY files from OCCT.
-//! Each operation needs configuration node.
-//!
-//! Providers grouped by Vendor name and Format type.
-//! The Vendor name is "OCC"
-//! The Format type is "PLY"
-//! The import process isn't supported.
-//! The export process is supported.
-class RWPly_Provider : public DE_Provider
-{
-public:
- DEFINE_STANDARD_RTTIEXT(RWPly_Provider, DE_Provider)
-
-public:
-
- //! Default constructor
- //! Configure translation process with global configuration
- Standard_EXPORT RWPly_Provider();
-
- //! Configure translation process
- //! @param[in] theNode object to copy
- Standard_EXPORT RWPly_Provider(const Handle(DE_ConfigurationNode)& theNode);
-
-public:
-
- //! Writes a CAD file, according internal configuration
- //! @param[in] thePath path to the export CAD file
- //! @param[out] theDocument document to export
- //! @param[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- 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[in] theProgress 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
- //! @param[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- 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[in] theProgress 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 CAD format
- Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
-
- //! Gets provider's vendor name of associated provider
- //! @return provider's vendor name
- Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
-};
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef DEPLY_Provider RWPly_Provider;
#endif // _RWPly_Provider_HeaderFile
RWStl.hxx
RWStl_Reader.cxx
RWStl_Reader.hxx
-RWStl_ConfigurationNode.cxx
RWStl_ConfigurationNode.hxx
-RWStl_Provider.cxx
RWStl_Provider.hxx
+++ /dev/null
-// Copyright (c) 2022 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <RWStl_ConfigurationNode.hxx>
-
-#include <DE_ConfigurationContext.hxx>
-#include <DE_PluginHolder.hxx>
-#include <NCollection_Buffer.hxx>
-#include <RWStl_Provider.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(RWStl_ConfigurationNode, DE_ConfigurationNode)
-
-namespace
-{
- static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
- {
- static const TCollection_AsciiString aScope = "provider";
- return aScope;
- }
-
- // Wrapper to auto-load DE component
- DE_PluginHolder<RWStl_ConfigurationNode> THE_OCCT_STL_COMPONENT_PLUGIN;
-}
-
-//=======================================================================
-// function : STEPCAFControl_ConfigurationNode
-// purpose :
-//=======================================================================
-RWStl_ConfigurationNode::RWStl_ConfigurationNode() :
- DE_ConfigurationNode()
-{}
-
-//=======================================================================
-// function : STEPCAFControl_ConfigurationNode
-// purpose :
-//=======================================================================
-RWStl_ConfigurationNode::RWStl_ConfigurationNode(const Handle(RWStl_ConfigurationNode)& theNode)
- :DE_ConfigurationNode(theNode)
-{
- InternalParameters = theNode->InternalParameters;
-}
-
-//=======================================================================
-// function : Load
-// purpose :
-//=======================================================================
-bool RWStl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
-{
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
-
- InternalParameters.ReadMergeAngle =
- theResource->RealVal("read.merge.angle", InternalParameters.ReadMergeAngle, aScope);
- InternalParameters.ReadBRep =
- theResource->BooleanVal("read.brep", InternalParameters.ReadBRep, aScope);
- InternalParameters.WriteAscii =
- theResource->BooleanVal("write.ascii", InternalParameters.WriteAscii, aScope);
- return true;
-}
-
-//=======================================================================
-// function : Save
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWStl_ConfigurationNode::Save() const
-{
- TCollection_AsciiString aResult;
- aResult += "!*****************************************************************************\n";
- aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
-
- aResult += "!\n";
- aResult += "!Read parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Input merge angle value\n";
- aResult += "!Default value (in degrees): 90.0. Angle should be within [0.0, 90.0] range\n";
- aResult += aScope + "read.merge.angle :\t " + InternalParameters.ReadMergeAngle + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up Boundary Representation flag\n";
- aResult += "!Default value: false. Available values: \"on\", \"off\"\n";
- aResult += aScope + "read.brep :\t " + InternalParameters.ReadBRep + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Write parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up writing mode (Ascii or Binary)\n";
- aResult += "!Default value: 1(Binary). Available values: 0(Ascii), 1(Binary)\n";
- aResult += aScope + "write.ascii :\t " + InternalParameters.WriteAscii + "\n";
- aResult += "!\n";
-
- aResult += "!*****************************************************************************\n";
- return aResult;
-}
-
-//=======================================================================
-// function : Copy
-// purpose :
-//=======================================================================
-Handle(DE_ConfigurationNode) RWStl_ConfigurationNode::Copy() const
-{
- return new RWStl_ConfigurationNode(*this);
-}
-
-//=======================================================================
-// function : BuildProvider
-// purpose :
-//=======================================================================
-Handle(DE_Provider) RWStl_ConfigurationNode::BuildProvider()
-{
- return new RWStl_Provider(this);
-}
-
-//=======================================================================
-// function : IsImportSupported
-// purpose :
-//=======================================================================
-bool RWStl_ConfigurationNode::IsImportSupported() const
-{
- return true;
-}
-
-//=======================================================================
-// function : IsExportSupported
-// purpose :
-//=======================================================================
-bool RWStl_ConfigurationNode::IsExportSupported() const
-{
- return true;
-}
-
-//=======================================================================
-// function : GetFormat
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWStl_ConfigurationNode::GetFormat() const
-{
- return TCollection_AsciiString("STL");
-}
-
-//=======================================================================
-// function : GetVendor
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWStl_ConfigurationNode::GetVendor() const
-{
- return TCollection_AsciiString("OCC");
-}
-
-//=======================================================================
-// function : GetExtensions
-// purpose :
-//=======================================================================
-TColStd_ListOfAsciiString RWStl_ConfigurationNode::GetExtensions() const
-{
- TColStd_ListOfAsciiString anExt;
- anExt.Append("stl");
- return anExt;
-}
-
-//=======================================================================
-// function : CheckContent
-// purpose :
-//=======================================================================
-bool RWStl_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
-{
- if (theBuffer.IsNull() || theBuffer->Size() < 7)
- {
- return false;
- }
- const char* aBytes = (const char*)theBuffer->Data();
- if (!(::strncmp(aBytes, "solid", 5) || ::strncmp(aBytes, "SOLID", 5)) && isspace(aBytes[5]))
- {
- return true;
- }
- // binary STL has no header for identification - format can be detected only by file extension
- return false;
-}
#ifndef _RWStl_ConfigurationNode_HeaderFile
#define _RWStl_ConfigurationNode_HeaderFile
-#include <DE_ConfigurationNode.hxx>
+#include <DESTL_ConfigurationNode.hxx>
-//! The purpose of this class is to configure the transfer process for STL format
-//! Stores the necessary settings for RWStl_Provider.
-//! Configures and creates special provider to transfer STL files.
-//!
-//! Nodes grouped by Vendor name and Format type.
-//! The Vendor name is "OCC"
-//! The Format type is "STL"
-//! The supported CAD extension is ".stl"
-//! The import process is supported.
-//! The export process is supported.
-class RWStl_ConfigurationNode : public DE_ConfigurationNode
-{
- DEFINE_STANDARD_RTTIEXT(RWStl_ConfigurationNode, DE_ConfigurationNode)
-public:
-
- //! Initializes all field by default
- Standard_EXPORT RWStl_ConfigurationNode();
-
- //! Copies values of all fields
- //! @param[in] theNode object to copy
- Standard_EXPORT RWStl_ConfigurationNode(const Handle(RWStl_ConfigurationNode)& theNode);
-
- //! Updates values according the resource
- //! @param[in] theResource input resource to use
- //! @return true if theResource loading has ended correctly
- Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource) Standard_OVERRIDE;
-
- //! Writes configuration to the string
- //! @return result resource string
- Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
-
- //! Copies values of all fields
- //! @return new object with the same field values
- Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
-
-
- //! Creates new provider for the own format
- //! @return new created provider
- Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
-
-public:
-
- //! Checks the import supporting
- //! @return true if import is supported
- Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
-
- //! Checks the export supporting
- //! @return true if export is supported
- Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
-
- //! Gets CAD format name of associated provider
- //! @return provider CAD format
- Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
-
- //! Gets provider's vendor name of associated provider
- //! @return provider's vendor name
- Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
-
- //! Gets list of supported file extensions
- //! @return list of extensions
- Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
-
- //! Checks the file content to verify a format
- //! @param[in] theBuffer read stream buffer to check content
- //! @return Standard_True if file is supported by a current provider
- Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const Standard_OVERRIDE;
-
-public:
- struct RWStl_InternalSection
- {
- // Read
- double ReadMergeAngle = 90.; //!< Input merge angle value
- bool ReadBRep = false; //!< Setting up Boundary Representation flag
-
- // Write
- bool WriteAscii = true; //!< Setting up writing mode (Ascii or Binary)
-
- } InternalParameters;
-};
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef DESTL_ConfigurationNode RWStl_ConfigurationNode;
#endif // _RWStl_ConfigurationNode_HeaderFile
+++ /dev/null
-// Copyright (c) 2022 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <RWStl_Provider.hxx>
-
-#include <BRep_Builder.hxx>
-#include <Message.hxx>
-#include <RWStl.hxx>
-#include <RWStl_ConfigurationNode.hxx>
-#include <StlAPI.hxx>
-#include <StlAPI_Writer.hxx>
-#include <TDocStd_Document.hxx>
-#include <XCAFDoc_ShapeTool.hxx>
-#include <XCAFDoc_DocumentTool.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(RWStl_Provider, DE_Provider)
-
-//=======================================================================
-// function : RWStl_Provider
-// purpose :
-//=======================================================================
-RWStl_Provider::RWStl_Provider()
-{}
-
-//=======================================================================
-// function : RWStl_Provider
-// purpose :
-//=======================================================================
-RWStl_Provider::RWStl_Provider(const Handle(DE_ConfigurationNode)& theNode)
- :DE_Provider(theNode)
-{}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool RWStl_Provider::Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- Handle(XSControl_WorkSession)& theWS,
- 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 " <<
- thePath << "\t: theDocument shouldn't be null";
- return false;
- }
- TopoDS_Shape aShape;
- if (!Read(thePath, aShape, theProgress))
- {
- return false;
- }
- Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
- aShapeTool->AddShape(aShape);
- return true;
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool RWStl_Provider::Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
- TopoDS_Shape aShape;
- TDF_LabelSequence aLabels;
- Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
- aSTool->GetFreeShapes(aLabels);
- if (aLabels.Length() <= 0)
- {
- Message::SendFail() << "Error in the RWStl_Provider during writing the file " <<
- thePath << "\t: Document contain no shapes";
- return false;
- }
-
- Handle(RWStl_ConfigurationNode) aNode = Handle(RWStl_ConfigurationNode)::DownCast(GetNode());
- if (aNode->GlobalParameters.LengthUnit != 1.0)
- {
- Message::SendWarning() << "Warning in the RWStl_Provider during writing the file " <<
- thePath << "\t: Target Units for writing were changed, but current format doesn't support scaling";
- }
-
- if (aLabels.Length() == 1)
- {
- aShape = aSTool->GetShape(aLabels.Value(1));
- }
- else
- {
- TopoDS_Compound aComp;
- BRep_Builder aBuilder;
- aBuilder.MakeCompound(aComp);
- for (Standard_Integer anIndex = 1; anIndex <= aLabels.Length(); anIndex++)
- {
- TopoDS_Shape aS = aSTool->GetShape(aLabels.Value(anIndex));
- aBuilder.Add(aComp, aS);
- }
- aShape = aComp;
- }
- return Write(thePath, aShape, theProgress);
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool RWStl_Provider::Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- Handle(XSControl_WorkSession)& theWS,
- 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)))
- {
- Message::SendFail() << "Error in the RWStl_Provider during reading the file " <<
- thePath << "\t: Incorrect or empty Configuration Node";
- return true;
- }
- 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 < 0.0 || aMergeAngle > M_PI_2)
- {
- Message::SendFail() << "Error in the RWStl_Provider during reading the file " <<
- thePath << "\t: The merge angle is out of the valid range";
- return false;
- }
- }
- if (!aNode->InternalParameters.ReadBRep)
- {
- Handle(Poly_Triangulation) aTriangulation = RWStl::ReadFile(thePath.ToCString(), aMergeAngle, theProgress);
-
- TopoDS_Face aFace;
- BRep_Builder aB;
- aB.MakeFace(aFace);
- aB.UpdateFace(aFace, aTriangulation);
- theShape = aFace;
- }
- else
- {
- Standard_DISABLE_DEPRECATION_WARNINGS
- if (!StlAPI::Read(theShape, thePath.ToCString()))
- {
- Message::SendFail() << "Error in the RWStl_Provider during reading the file " << thePath;
- return false;
- }
- Standard_ENABLE_DEPRECATION_WARNINGS
- }
- return true;
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool RWStl_Provider::Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress)
-{
- Message::SendWarning() << "OCCT Stl writer does not support model scaling according to custom length unit";
- if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWStl_ConfigurationNode)))
- {
- Message::SendFail() << "Error in the RWStl_Provider during reading the file " <<
- thePath << "\t: Incorrect or empty Configuration Node";
- return false;
- }
- Handle(RWStl_ConfigurationNode) aNode = Handle(RWStl_ConfigurationNode)::DownCast(GetNode());
- if (aNode->GlobalParameters.LengthUnit != 1.0)
- {
- Message::SendWarning() << "Warning in the RWStl_Provider during writing the file " <<
- thePath << "\t: Target Units for writing were changed, but current format doesn't support scaling";
- }
-
- StlAPI_Writer aWriter;
- aWriter.ASCIIMode() = aNode->InternalParameters.WriteAscii;
- if (!aWriter.Write(theShape, thePath.ToCString(), theProgress))
- {
- Message::SendFail() << "Error in the RWStl_Provider during reading the file " <<
- thePath << "\t: Mesh writing has been failed";
- return false;
- }
- return true;
-}
-
-//=======================================================================
-// function : GetFormat
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWStl_Provider::GetFormat() const
-{
- return TCollection_AsciiString("STL");
-}
-
-//=======================================================================
-// function : GetVendor
-// purpose :
-//=======================================================================
-TCollection_AsciiString RWStl_Provider::GetVendor() const
-{
- return TCollection_AsciiString("OCC");
-}
#ifndef _RWStl_Provider_HeaderFile
#define _RWStl_Provider_HeaderFile
-#include <DE_Provider.hxx>
+#include <DESTL_Provider.hxx>
-//! The class to transfer STL files.
-//! Reads and Writes any STL files into/from OCCT.
-//! Each operation needs configuration node.
-//!
-//! Providers grouped by Vendor name and Format type.
-//! The Vendor name is "OCC"
-//! The Format type is "STL"
-//! The import process is supported.
-//! The export process is supported.
-class RWStl_Provider : public DE_Provider
-{
-public:
- DEFINE_STANDARD_RTTIEXT(RWStl_Provider, DE_Provider)
-
-public:
-
- //! Default constructor
- //! Configure translation process with global configuration
- Standard_EXPORT RWStl_Provider();
-
- //! Configure translation process
- //! @param[in] theNode object to copy
- Standard_EXPORT RWStl_Provider(const Handle(DE_ConfigurationNode)& theNode);
-
-public:
-
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theDocument document to save result
- //! @param[in] theWS current work session
- //! @param[in] theProgress 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,
- 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[in] theWS current work session
- //! @param[in] theProgress 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,
- 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[in] theProgress 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[in] theProgress 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
- //! @param[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- 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[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- 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[in] theProgress 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[in] theProgress 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
- //! @return provider CAD format
- Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
-
- //! Gets provider's vendor name of associated provider
- //! @return provider's vendor name
- Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
-};
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef DESTL_Provider RWStl_Provider;
#endif // _RWStl_Provider_HeaderFile
STEPCAFControl_ActorWrite.cxx
STEPCAFControl_ActorWrite.hxx
-STEPCAFControl_ConfigurationNode.cxx
STEPCAFControl_ConfigurationNode.hxx
STEPCAFControl_Controller.cxx
STEPCAFControl_Controller.hxx
STEPCAFControl_ExternFile.lxx
STEPCAFControl_GDTProperty.hxx
STEPCAFControl_GDTProperty.cxx
-STEPCAFControl_Provider.cxx
STEPCAFControl_Provider.hxx
STEPCAFControl_Reader.cxx
STEPCAFControl_Reader.hxx
+++ /dev/null
-// Copyright (c) 2022 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <STEPCAFControl_ConfigurationNode.hxx>
-
-#include <DE_ConfigurationContext.hxx>
-#include <DE_PluginHolder.hxx>
-#include <NCollection_Buffer.hxx>
-#include <STEPCAFControl_Provider.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(STEPCAFControl_ConfigurationNode, DE_ConfigurationNode)
-
-namespace
-{
- static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
- {
- static const TCollection_AsciiString aScope = "provider";
- return aScope;
- }
-
- // Wrapper to auto-load DE component
- DE_PluginHolder<STEPCAFControl_ConfigurationNode> THE_OCCT_STEP_COMPONENT_PLUGIN;
-}
-
-//=======================================================================
-// function : STEPCAFControl_ConfigurationNode
-// purpose :
-//=======================================================================
-STEPCAFControl_ConfigurationNode::STEPCAFControl_ConfigurationNode() :
- DE_ConfigurationNode()
-{}
-
-//=======================================================================
-// function : STEPCAFControl_ConfigurationNode
-// purpose :
-//=======================================================================
-STEPCAFControl_ConfigurationNode::STEPCAFControl_ConfigurationNode(const Handle(STEPCAFControl_ConfigurationNode)& theNode)
- :DE_ConfigurationNode(theNode),
- InternalParameters(theNode->InternalParameters)
-{}
-
-//=======================================================================
-// function : Load
-// purpose :
-//=======================================================================
-bool STEPCAFControl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
-{
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
-
- InternalParameters.ReadBSplineContinuity = (StepData_ConfParameters::ReadMode_BSplineContinuity)
- theResource->IntegerVal("read.iges.bspline.continuity", InternalParameters.ReadBSplineContinuity, aScope);
- InternalParameters.ReadPrecisionMode = (StepData_ConfParameters::ReadMode_Precision)
- theResource->IntegerVal("read.precision.mode", InternalParameters.ReadPrecisionMode, aScope);
- InternalParameters.ReadPrecisionVal =
- theResource->RealVal("read.precision.val", InternalParameters.ReadPrecisionVal, aScope);
- InternalParameters.ReadMaxPrecisionMode = (StepData_ConfParameters::ReadMode_MaxPrecision)
- theResource->IntegerVal("read.maxprecision.mode", InternalParameters.ReadMaxPrecisionMode, aScope);
- InternalParameters.ReadMaxPrecisionVal =
- theResource->RealVal("read.maxprecision.val", InternalParameters.ReadMaxPrecisionVal, aScope);
- InternalParameters.ReadSameParamMode =
- theResource->BooleanVal("read.stdsameparameter.mode", InternalParameters.ReadSameParamMode, aScope);
- InternalParameters.ReadSurfaceCurveMode = (StepData_ConfParameters::ReadMode_SurfaceCurve)
- theResource->IntegerVal("read.surfacecurve.mode", InternalParameters.ReadSurfaceCurveMode, aScope);
- InternalParameters.EncodeRegAngle =
- theResource->RealVal("read.encoderegularity.angle", InternalParameters.EncodeRegAngle, aScope);
- InternalParameters.AngleUnit = (StepData_ConfParameters::AngleUnitMode)
- theResource->IntegerVal("angleunit.mode", InternalParameters.AngleUnit, aScope);
-
- InternalParameters.ReadResourceName =
- theResource->StringVal("read.resource.name", InternalParameters.ReadResourceName, aScope);
- InternalParameters.ReadSequence =
- theResource->StringVal("read.sequence", InternalParameters.ReadSequence, aScope);
- InternalParameters.ReadProductMode =
- theResource->BooleanVal("read.product.mode", InternalParameters.ReadProductMode, aScope);
- InternalParameters.ReadProductContext = (StepData_ConfParameters::ReadMode_ProductContext)
- theResource->IntegerVal("read.product.context", InternalParameters.ReadProductContext, aScope);
- InternalParameters.ReadShapeRepr = (StepData_ConfParameters::ReadMode_ShapeRepr)
- theResource->IntegerVal("read.shape.repr", InternalParameters.ReadShapeRepr, aScope);
- InternalParameters.ReadTessellated = (StepData_ConfParameters::RWMode_Tessellated)
- theResource->IntegerVal("read.tessellated", InternalParameters.ReadTessellated, aScope);
- InternalParameters.ReadAssemblyLevel = (StepData_ConfParameters::ReadMode_AssemblyLevel)
- theResource->IntegerVal("read.assembly.level", InternalParameters.ReadAssemblyLevel, aScope);
- InternalParameters.ReadRelationship =
- theResource->BooleanVal("read.shape.relationship", InternalParameters.ReadRelationship, aScope);
- InternalParameters.ReadShapeAspect =
- theResource->BooleanVal("read.shape.aspect", InternalParameters.ReadShapeAspect, aScope);
- InternalParameters.ReadConstrRelation =
- theResource->BooleanVal("read.constructivegeom.relationship", InternalParameters.ReadConstrRelation, aScope);
- InternalParameters.ReadSubshapeNames =
- theResource->BooleanVal("read.stepcaf.subshapes.name", InternalParameters.ReadSubshapeNames, aScope);
- InternalParameters.ReadCodePage = (Resource_FormatType)
- theResource->IntegerVal("read.codepage", InternalParameters.ReadCodePage, aScope);
- InternalParameters.ReadNonmanifold =
- theResource->BooleanVal("read.nonmanifold", InternalParameters.ReadNonmanifold, aScope);
- InternalParameters.ReadIdeas =
- theResource->BooleanVal("read.ideas", InternalParameters.ReadIdeas, aScope);
- InternalParameters.ReadAllShapes =
- theResource->BooleanVal("read.all.shapes", InternalParameters.ReadAllShapes, aScope);
- InternalParameters.ReadRootTransformation =
- theResource->BooleanVal("read.root.transformation", InternalParameters.ReadRootTransformation, aScope);
- InternalParameters.ReadColor =
- theResource->BooleanVal("read.color", InternalParameters.ReadColor, aScope);
- InternalParameters.ReadName =
- theResource->BooleanVal("read.name", InternalParameters.ReadName, aScope);
- InternalParameters.ReadLayer =
- theResource->BooleanVal("read.layer", InternalParameters.ReadLayer, aScope);
- InternalParameters.ReadProps =
- theResource->BooleanVal("read.props", InternalParameters.ReadProps, aScope);
- InternalParameters.ReadMetadata =
- theResource->BooleanVal("read.metadata", InternalParameters.ReadMetadata, aScope);
-
- InternalParameters.WritePrecisionMode = (StepData_ConfParameters::WriteMode_PrecisionMode)
- theResource->IntegerVal("write.precision.mode", InternalParameters.WritePrecisionMode, aScope);
- InternalParameters.WritePrecisionVal =
- theResource->RealVal("write.precision.val", InternalParameters.WritePrecisionVal, aScope);
- InternalParameters.WriteAssembly = (StepData_ConfParameters::WriteMode_Assembly)
- theResource->IntegerVal("write.assembly", InternalParameters.WriteAssembly, aScope);
- InternalParameters.WriteSchema = (StepData_ConfParameters::WriteMode_StepSchema)
- theResource->IntegerVal("write.schema", InternalParameters.WriteSchema, aScope);
- InternalParameters.WriteTessellated = (StepData_ConfParameters::RWMode_Tessellated)
- theResource->IntegerVal("write.tessellated", InternalParameters.WriteTessellated, aScope);
- InternalParameters.WriteProductName =
- theResource->StringVal("write.product.name", InternalParameters.WriteProductName, aScope);
- InternalParameters.WriteSurfaceCurMode =
- theResource->BooleanVal("write.surfacecurve.mode", InternalParameters.WriteSurfaceCurMode, aScope);
- InternalParameters.WriteUnit = (UnitsMethods_LengthUnit)
- theResource->IntegerVal("write.unit", InternalParameters.WriteUnit, aScope);
- InternalParameters.WriteResourceName =
- theResource->StringVal("write.resource.name", InternalParameters.WriteResourceName, aScope);
- InternalParameters.WriteSequence =
- theResource->StringVal("write.sequence", InternalParameters.WriteSequence, aScope);
- InternalParameters.WriteVertexMode = (StepData_ConfParameters::WriteMode_VertexMode)
- theResource->IntegerVal("write.vertex.mode", InternalParameters.WriteVertexMode, aScope);
- InternalParameters.WriteSubshapeNames =
- theResource->BooleanVal("write.stepcaf.subshapes.name", InternalParameters.WriteSubshapeNames, aScope);
- InternalParameters.WriteColor =
- theResource->BooleanVal("write.color", InternalParameters.WriteColor, aScope);
- InternalParameters.WriteName =
- theResource->BooleanVal("write.name", InternalParameters.WriteName, aScope);
- InternalParameters.WriteLayer =
- theResource->BooleanVal("write.layer", InternalParameters.WriteLayer, aScope);
- InternalParameters.WriteProps =
- theResource->BooleanVal("write.props", InternalParameters.WriteProps, aScope);
- InternalParameters.WriteModelType = (STEPControl_StepModelType)
- theResource->IntegerVal("write.model.type", InternalParameters.WriteModelType, aScope);
-
- return true;
-}
-
-//=======================================================================
-// function : Save
-// purpose :
-//=======================================================================
-TCollection_AsciiString STEPCAFControl_ConfigurationNode::Save() const
-{
- TCollection_AsciiString aResult;
- aResult += "!*****************************************************************************\n";
- aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
-
- aResult += "!\n";
- aResult += "!Common parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Manages the continuity of BSpline curves (IGES entities 106, 112 and 126) ";
- aResult += "after translation to Open CASCADE Technology\n";
- aResult += "!Default value: 1. Available values: 0, 1, 2\n";
- aResult += aScope + "read.iges.bspline.continuity :\t " + InternalParameters.ReadBSplineContinuity + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Reads the precision mode value\n";
- aResult += "!Default value: \"File\"(0). Available values: \"File\"(0), \"User\"(1)\n";
- aResult += aScope + "read.precision.mode :\t " + InternalParameters.ReadPrecisionMode + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!This parameter gives the precision for shape construction when the ";
- aResult += "read.precision.mode parameter value is 1\n";
- aResult += "!Default value: 0.0001. Available values: any real positive (non null) value\n";
- aResult += aScope + "read.precision.val :\t " + InternalParameters.ReadPrecisionVal + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the mode of applying the maximum allowed tolerance\n";
- aResult += "!Default value: \"Preferred\"(0). Available values: \"Preferred\"(0), \"Forced\"(1)\n";
- aResult += aScope + "read.maxprecision.mode :\t " + InternalParameters.ReadMaxPrecisionMode + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the maximum allowable tolerance (in internal units, which are specified in xstep.cascade.unit)";
- aResult += " of the shape\n";
- aResult += "!Default value: 1. Available values: any real positive (non null) value\n";
- aResult += aScope + "read.maxprecision.val :\t " + InternalParameters.ReadMaxPrecisionVal + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the using of BRepLib::SameParameter\n";
- aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(1)\n";
- aResult += aScope + "read.stdsameparameter.mode :\t " + InternalParameters.ReadSameParamMode + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Preference for the computation of curves in case of 2D/3D inconsistency in an entity ";
- aResult += "which has both 2D and 3D representations.\n";
- aResult += "!Default value: \"Default\"(0). Available values: \"Default\"(0), \"2DUse_Preferred\"(2), ";
- aResult += "\"2DUse_Forced\"(-2), \"3DUse_Preferred\"(3), \"3DUse_Forced\"(-3)\n";
- aResult += aScope + "read.surfacecurve.mode :\t " + InternalParameters.ReadSurfaceCurveMode + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!This parameter is used within the BRepLib::EncodeRegularity() function ";
- aResult += "which is called for a shape read ";
- aResult += "from an IGES or a STEP file at the end of translation process.This function sets the regularity flag of";
- aResult += " an edge in a shell when this edge is shared by two faces.This flag shows the continuity, ";
- aResult += "which these two faces are connected with at that edge.\n";
- aResult += "!Default value (in degrees): 0.57295779513. Available values: <double>\n";
- aResult += aScope + "read.encoderegularity.angle :\t " + InternalParameters.EncodeRegAngle + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Indicates what angle units should be used when a STEP file is read\n";
- aResult += "!Default value: \"File\"(0). Available values: \"File\"(0), \"Rad\"(1), \"Deg\"(2)\n";
- aResult += aScope + "angleunit.mode :\t " + InternalParameters.AngleUnit + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Read Parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the name of the resource file\n";
- aResult += "!Default value: \"STEP\". Available values: <string>\n";
- aResult += aScope + "read.resource.name :\t " + InternalParameters.ReadResourceName + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines name of the sequence of operators\n";
- aResult += "!Default value: \"FromSTEP\". Available values: <string>\n";
- aResult += aScope + "read.sequence :\t " + InternalParameters.ReadSequence + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the approach used for selection of top-level STEP entities for translation, ";
- aResult += "and for recognition of assembly structures\n";
- aResult += "!Default value: 1(\"ON\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
- aResult += aScope + "read.product.mode :\t " + InternalParameters.ReadProductMode + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!When reading AP 209 STEP files, allows selecting either only 'design' or 'analysis', ";
- aResult += "or both types of products for translation\n";
- aResult += "!Default value: 1(\"all\"). Available values: 1(\"all\"), 2(\"design\"), 3(\"analysis\")\n";
- aResult += aScope + "read.product.context :\t " + InternalParameters.ReadProductContext + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Specifies preferred type of representation of the shape of the product, in case if a STEP file contains";
- aResult += " more than one representation(i.e.multiple PRODUCT_DEFINITION_SHAPE entities) for a single product\n";
- aResult += "!Default value: 1(\"All\"). Available values: 1(\"All\"), 2(\"ABSR\"), 3(\"MSSR\"), 4(\"GBSSR\"), ";
- aResult += "5(\"FBSR\"), 6(\"EBWSR\"), 7(\"GBWSR\")\n";
- aResult += aScope + "read.shape.repr :\t " + InternalParameters.ReadShapeRepr + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines whether tessellated shapes should be translated";
- aResult += "!Default value: 1(\"On\"). Available values: 0(\"OFF\"), 2(\"OnNoBRep\")\n";
- aResult += aScope + "read.tessellated :\t " + InternalParameters.ReadTessellated + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Specifies which data should be read for the products found in the STEP file\n";
- aResult += "!Default value: 1(\"All\"). Available values: 1(\"All\"), 2(\"assembly\"),";
- aResult += "3(\"structure\"), 4(\"shape\")\n";
- aResult += aScope + "read.assembly.level :\t " + InternalParameters.ReadAssemblyLevel + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines whether shapes associated with the main SHAPE_DEFINITION_REPRESENTATION entity";
- aResult += "of the product via SHAPE_REPRESENTATIONSHIP_RELATION should be translated\n";
- aResult += "!Default value: 1(\"ON\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
- aResult += aScope + "read.shape.relationship :\t " + InternalParameters.ReadRelationship + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines whether shapes associated with the PRODUCT_DEFINITION_SHAPE entity of the product ";
- aResult += "via SHAPE_ASPECT should be translated.\n";
- aResult += "!Default value: 1(\"ON\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
- aResult += aScope + "read.shape.aspect :\t " + InternalParameters.ReadShapeAspect + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Boolean flag regulating translation of \"CONSTRUCTIVE_GEOMETRY_REPRESENTATION_RELATIONSHIP\" ";
- aResult += "entities that define position of constructive geometry entities contained in ";
- aResult += "\"CONSTRUCTIVE_GEOMETRY_REPRESENTATION\" with respect to the main representation of the shape (product).\n";
- aResult += "!Default value: 0(\"OFF\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
- aResult += aScope + "read.constructivegeom.relationship :\t " + InternalParameters.ReadConstrRelation + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Indicates whether to read sub-shape names from 'Name' attributes of STEP Representation Items\n";
- aResult += "!Default value: 0(\"OFF\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
- aResult += aScope + "read.stepcaf.subshapes.name :\t " + InternalParameters.ReadSubshapeNames + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!STEP file encoding for names translation\n";
- aResult += "!Default value: 4(\"UTF8\"). Available values: 0(\"SJIS\"), 1(\"EUC\"), 2(\"NoConversion\"), ";
- aResult += "3(\"GB\"), 4(\"UTF8\"), 5(\"SystemLocale\"), 6(\"CP1250\"), 7(\"CP1251\"), 8(\"CP1252\"), ";
- aResult += "9(\"CP1253\"), 10(\"CP1254\"), 11(\"CP1255\"), 12(\"CP1256\"), 13(\"CP1257\"), 14(\"CP1258\"), ";
- aResult += "15(\"iso8859-1\"), 16(\"iso8859-2\"), 17(\"iso8859-3\"), 18(\"iso8859-4\"), 19(\"iso8859-5\"), ";
- aResult += "20(\"iso8859-6\"), 21(\"iso8859-7\"), 22(\"iso8859-8\"), 23(\"iso8859-9\"), 24(\"CP850\")\n";
- aResult += aScope + "read.codepage :\t " + InternalParameters.ReadCodePage + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Non-manifold topology reading\n";
- aResult += "!Default value: 0(\"OFF\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
- aResult += aScope + "read.nonmanifold :\t " + InternalParameters.ReadNonmanifold + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!I-Deas-like STEP processing\n";
- aResult += "!Default value: 0(\"OFF\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
- aResult += aScope + "read.ideas :\t " + InternalParameters.ReadIdeas + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Parameter to read all top level solids and shells\n";
- aResult += "!Default value: 0(\"OFF\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
- aResult += aScope + "read.all.shapes :\t " + InternalParameters.ReadAllShapes + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Mode to variate apply or not transformation placed in the root shape representation.\n";
- aResult += "!Default value: 1(\"ON\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
- aResult += aScope + "read.root.transformation :\t " + InternalParameters.ReadRootTransformation + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up the read.colo parameter which is used to indicate read Colors or not\n";
- aResult += "!Default value: +. Available values: \"-\", \"+\"\n";
- aResult += aScope + "read.color :\t " + InternalParameters.ReadColor + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up the read.name parameter which is used to indicate read Names or not\n";
- aResult += "!Default value: +. Available values: \"-\", \"+\"\n";
- aResult += aScope + "read.name :\t " + InternalParameters.ReadName + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up the read.layer parameter which is used to indicate read Layers or not\n";
- aResult += "!Default value: +. Available values: \"-\", \"+\"\n";
- aResult += aScope + "read.layer :\t " + InternalParameters.ReadLayer + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up the read.props parameter which is used to indicate read Validation properties or not\n";
- aResult += "!Default value: +. Available values: \"-\", \"+\"\n";
- aResult += aScope + "read.props :\t " + InternalParameters.ReadProps + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up the read.metadata parameter which is used to indicate read Metadata or not\n";
- aResult += "!Default value: 1(\"ON\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
- aResult += aScope + "read.metadata :\t " + InternalParameters.ReadMetadata + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Write Parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Writes the precision value\n";
- aResult += "!Default value: \"Average\"(0). Available values: \"Least\"(-1), \"Average\"(0), ";
- aResult += "\"Greatest\"(1), \"Session\"(2)\n";
- aResult += aScope + "write.precision.mode :\t " + InternalParameters.WritePrecisionMode + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!A user-defined precision value\n";
- aResult += "!Default value: 0.0001. Available values: any real positive (non null) value\n";
- aResult += aScope + "write.precision.val :\t " + InternalParameters.WritePrecisionVal + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Writing assembly mode\n";
- aResult += "!Default value: 2(\"Auto\"). Available values: 0(\"Off\"), 1(\"On\"), 2(\"Auto\")\n";
- aResult += aScope + "write.assembly :\t " + InternalParameters.WriteAssembly + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the version of schema used for the output STEP file\n";
- aResult += "!Default value: 1 or AP214CD. Available values: 1 or AP214CD, 2 or AP214DIS, 3 or AP203, ";
- aResult += "4 or AP214IS, 5 or AP242DIS\n";
- aResult += aScope + "write.schema :\t " + InternalParameters.WriteSchema + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines whether tessellated shapes should be translated";
- aResult += "!Default value: 2(\"OnNoBRep\"). Available values: 0(\"OFF\"), 1(\"On\")\n";
- aResult += aScope + "write.tessellated :\t " + InternalParameters.WriteTessellated + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the text string that will be used for field 'name' of PRODUCT entities written to the STEP file\n";
- aResult += "!Default value: OCCT STEP translator (current OCCT version number). Available values: <string>\n";
- aResult += aScope + "write.product.name :\t " + InternalParameters.WriteProductName + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!This parameter indicates whether parametric curves should be written into the STEP file\n";
- aResult += "!Default value: 1(\"ON\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
- aResult += aScope + "write.surfacecurve.mode :\t " + InternalParameters.WriteSurfaceCurMode + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines a unit in which the STEP file should be written.\n";
- aResult += "!Default value: MM(2). Available values: \"INCH\"(1), \"MM\"(2), \"??\"(3), \"FT\"(4), \"MI\"(5), ";
- aResult += "\"M\"(6), \"KM\"(7), \"MIL\"(8), \"UM\"(9), \"CM\"(10), \"UIN\"(11)\n";
- aResult += aScope + "write.unit :\t " + InternalParameters.WriteUnit + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines the name of the resource file\n";
- aResult += "!Default value: \"STEP\". Available values: <string>\n";
- aResult += aScope + "write.resource.name :\t " + InternalParameters.WriteResourceName + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Defines name of the sequence of operators\n";
- aResult += "!Default value: \"ToSTEP\". Available values: <string>\n";
- aResult += aScope + "write.sequence :\t " + InternalParameters.WriteSequence + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!This parameter indicates which of free vertices writing mode is switch on\n";
- aResult += "!Default value: 0(\"One Compound\"). Available values: 0(\"One Compound\"), 1(\"Signle Vertex\")\n";
- aResult += aScope + "write.vertex.mode :\t " + InternalParameters.WriteVertexMode + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Indicates whether to write sub-shape names to 'Name' attributes of STEP Representation Items\n";
- aResult += "!Default value: 0(\"OFF\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
- aResult += aScope + "write.stepcaf.subshapes.name :\t " + InternalParameters.WriteSubshapeNames + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up the write.colo parameter which is used to indicate write Colors or not\n";
- aResult += "!Default value: +. Available values: \"-\", \"+\"\n";
- aResult += aScope + "write.color :\t " + InternalParameters.WriteColor + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up the write.name parameter which is used to indicate write Names or not\n";
- aResult += "!Default value: +. Available values: \"-\", \"+\"\n";
- aResult += aScope + "write.name :\t " + InternalParameters.WriteName + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up the write.layer parameter which is used to indicate write Layers or not\n";
- aResult += "!Default value: +. Available values: \"-\", \"+\"\n";
- aResult += aScope + "write.layer :\t " + InternalParameters.WriteLayer + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up the write.props parameter which is used to indicate write Validation properties or not\n";
- aResult += "!Default value: +. Available values: \"-\", \"+\"\n";
- aResult += aScope + "write.props :\t " + InternalParameters.WriteProps + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up the Model Type which gives you the choice of translation mode for an Open CASCADE shape that ";
- aResult += "is being translated to STEP\n";
- aResult += "!Default value: 0. Available values: 0, 1, 2, 3, 4\n";
- aResult += aScope + "write.model.type :\t " + InternalParameters.WriteModelType + "\n";
- aResult += "!\n";
-
- aResult += "!*****************************************************************************\n";
-
- return aResult;
-}
-
-//=======================================================================
-// function : Copy
-// purpose :
-//=======================================================================
-Handle(DE_ConfigurationNode) STEPCAFControl_ConfigurationNode::Copy() const
-{
- return new STEPCAFControl_ConfigurationNode(*this);
-}
-
-//=======================================================================
-// function : BuildProvider
-// purpose :
-//=======================================================================
-Handle(DE_Provider) STEPCAFControl_ConfigurationNode::BuildProvider()
-{
- return new STEPCAFControl_Provider(this);
-}
-
-//=======================================================================
-// function : IsImportSupported
-// purpose :
-//=======================================================================
-bool STEPCAFControl_ConfigurationNode::IsImportSupported() const
-{
- return true;
-}
-
-//=======================================================================
-// function : IsExportSupported
-// purpose :
-//=======================================================================
-bool STEPCAFControl_ConfigurationNode::IsExportSupported() const
-{
- return true;
-}
-
-//=======================================================================
-// function : GetFormat
-// purpose :
-//=======================================================================
-TCollection_AsciiString STEPCAFControl_ConfigurationNode::GetFormat() const
-{
- return TCollection_AsciiString("STEP");
-}
-
-//=======================================================================
-// function : GetVendor
-// purpose :
-//=======================================================================
-TCollection_AsciiString STEPCAFControl_ConfigurationNode::GetVendor() const
-{
- return TCollection_AsciiString("OCC");
-}
-
-//=======================================================================
-// function : GetExtensions
-// purpose :
-//=======================================================================
-TColStd_ListOfAsciiString STEPCAFControl_ConfigurationNode::GetExtensions() const
-{
- TColStd_ListOfAsciiString anExt;
- anExt.Append("stp");
- anExt.Append("step");
- anExt.Append("stpz");
- return anExt;
-}
-
-//=======================================================================
-// function : CheckContent
-// purpose :
-//=======================================================================
-bool STEPCAFControl_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
-{
- if (theBuffer.IsNull() || theBuffer->Size() < 100)
- {
- return false;
- }
- const char* aBytes = (const char*)theBuffer->Data();
- if (::strstr(aBytes, "IFC"))
- {
- return false;
- }
- if (::strstr(aBytes, "ISO-10303-21"))
- {
- // Double-check by presence of "FILE_SHEMA" statement
- const char* aPtr = ::strstr(aBytes, "FILE_SCHEMA");
- if (aPtr)
- {
- return true;
- }
- }
- return false;
-}
#ifndef _STEPCAFControl_ConfigurationNode_HeaderFile
#define _STEPCAFControl_ConfigurationNode_HeaderFile
-#include <DE_ConfigurationNode.hxx>
-#include <STEPControl_StepModelType.hxx>
-#include <StepData_ConfParameters.hxx>
-#include <Resource_FormatType.hxx>
-#include <UnitsMethods_LengthUnit.hxx>
+#include <DESTEP_ConfigurationNode.hxx>
-//! The purpose of this class is to configure the transfer process for STEP format
-//! Stores the necessary settings for STEPCAFControl_Provider.
-//! Configures and creates special provider to transfer STEP files.
-//!
-//! Nodes grouped by Vendor name and Format type.
-//! The Vendor name is "OCC"
-//! The Format type is "STEP"
-//! The supported CAD extensions are ".stp", ".step", ".stpz"
-//! The import process is supported.
-//! The export process is supported.
-class STEPCAFControl_ConfigurationNode : public DE_ConfigurationNode
-{
- DEFINE_STANDARD_RTTIEXT(STEPCAFControl_ConfigurationNode, DE_ConfigurationNode)
-public:
-
- //! Initializes all field by default
- Standard_EXPORT STEPCAFControl_ConfigurationNode();
-
- //! Copies values of all fields
- //! @param[in] theNode object to copy
- Standard_EXPORT STEPCAFControl_ConfigurationNode(const Handle(STEPCAFControl_ConfigurationNode)& theNode);
-
- //! Updates values according the resource
- //! @param[in] theResource input resource to use
- //! @return true if theResource loading has ended correctly
- Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource) Standard_OVERRIDE;
-
- //! Writes configuration to the string
- //! @return result resource string
- Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
-
- //! Copies values of all fields
- //! @return new object with the same field values
- Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
-
-
- //! Creates new provider for the own format
- //! @return new created provider
- Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
-
-public:
-
- //! Checks the import supporting
- //! @return true if import is supported
- Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
-
- //! Checks the export supporting
- //! @return true if export is supported
- Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
-
- //! Gets CAD format name of associated provider
- //! @return provider CAD format
- Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
-
- //! Gets provider's vendor name of associated provider
- //! @return provider's vendor name
- Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
-
- //! Gets list of supported file extensions
- //! @return list of extensions
- Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
-
- //! Checks the file content to verify a format
- //! @param[in] theBuffer read stream buffer to check content
- //! @return Standard_True if file is supported by a current provider
- Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const Standard_OVERRIDE;
-
-public:
-
- StepData_ConfParameters InternalParameters;
-};
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef DESTEP_ConfigurationNode STEPCAFControl_ConfigurationNode;
#endif // _STEPCAFControl_ConfigurationNode_HeaderFile
+++ /dev/null
-// Copyright (c) 2022 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <STEPCAFControl_Provider.hxx>
-
-#include <Interface_Static.hxx>
-#include <Message.hxx>
-#include <StepData_StepModel.hxx>
-#include <StepData_ConfParameters.hxx>
-#include <STEPCAFControl_ConfigurationNode.hxx>
-#include <STEPCAFControl_Controller.hxx>
-#include <STEPCAFControl_Reader.hxx>
-#include <STEPCAFControl_Writer.hxx>
-#include <XCAFDoc_DocumentTool.hxx>
-#include <XSControl_WorkSession.hxx>
-#include <UnitsMethods.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(STEPCAFControl_Provider, DE_Provider)
-
-//=======================================================================
-// function : STEPCAFControl_Provider
-// purpose :
-//=======================================================================
-STEPCAFControl_Provider::STEPCAFControl_Provider()
-{}
-
-//=======================================================================
-// function : STEPCAFControl_Provider
-// purpose :
-//=======================================================================
-STEPCAFControl_Provider::STEPCAFControl_Provider(const Handle(DE_ConfigurationNode)& theNode)
- :DE_Provider(theNode)
-{}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- Handle(XSControl_WorkSession)& theWS,
- const Message_ProgressRange& theProgress)
-{
- if (theDocument.IsNull())
- {
- Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
- thePath << "\t: theDocument shouldn't be null";
- return false;
- }
- 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";
- return false;
- }
- Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
- personizeWS(theWS);
- XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
- STEPCAFControl_Reader aReader;
- aReader.Init(theWS);
- aReader.SetColorMode(aNode->InternalParameters.ReadColor);
- aReader.SetNameMode(aNode->InternalParameters.ReadName);
- aReader.SetLayerMode(aNode->InternalParameters.ReadLayer);
- aReader.SetPropsMode(aNode->InternalParameters.ReadProps);
- aReader.SetMetaMode(aNode->InternalParameters.ReadMetadata);
-
- IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
- StepData_ConfParameters aParams = aNode->InternalParameters;
- aReadStat = aReader.ReadFile(thePath.ToCString(), aParams);
- if (aReadStat != IFSelect_RetDone)
- {
- Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
- thePath << "\t: abandon";
- 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";
- return false;
- }
- return true;
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool STEPCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
- 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 in the STEPCAFControl_Provider during writing the file " <<
- thePath << "\t: Incorrect or empty Configuration Node";
- return false;
- }
- Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
- personizeWS(theWS);
- STEPCAFControl_Writer aWriter;
- aWriter.Init(theWS);
- Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(aWriter.Writer().WS()->Model());
- STEPControl_StepModelType aMode =
- static_cast<STEPControl_StepModelType>(aNode->InternalParameters.WriteModelType);
- aWriter.SetColorMode(aNode->InternalParameters.WriteColor);
- aWriter.SetNameMode(aNode->InternalParameters.WriteName);
- aWriter.SetLayerMode(aNode->InternalParameters.WriteLayer);
- aWriter.SetPropsMode(aNode->InternalParameters.WriteProps);
- StepData_ConfParameters aParams = aNode->InternalParameters;
- Standard_Real aScaleFactorMM = 1.;
- if (XCAFDoc_DocumentTool::GetLengthUnit(theDocument, aScaleFactorMM, UnitsMethods_LengthUnit_Millimeter))
- {
- aModel->SetLocalLengthUnit(aScaleFactorMM);
- }
- else
- {
- aModel->SetLocalLengthUnit(aNode->GlobalParameters.SystemUnit);
- Message::SendWarning() << "Warning in the STEPCAFControl_Provider during writing the file " <<
- thePath << "\t: The document has no information on Units. Using global parameter as initial Unit.";
- }
- UnitsMethods_LengthUnit aTargetUnit = UnitsMethods::GetLengthUnitByFactorValue(aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
- aParams.WriteUnit = aTargetUnit;
- aModel->SetWriteLengthUnit(aNode->GlobalParameters.LengthUnit);
- TDF_Label aLabel;
- if (!aWriter.Transfer(theDocument, aParams, aMode, 0, theProgress))
- {
- Message::SendFail() << "Error in the STEPCAFControl_Provider during writing the file " <<
- thePath << "\t: The document cannot be translated or gives no result";
- return false;
- }
- IFSelect_ReturnStatus aStatus = aWriter.Write(thePath.ToCString());
- switch (aStatus)
- {
- case IFSelect_RetVoid:
- {
- Message::SendFail() << "Error in the STEPCAFControl_Provider during writing the file " <<
- thePath << "\t: No file written";
- return false;;
- }
- case IFSelect_RetDone:
- {
- break;
- }
- default:
- {
- Message::SendFail() << "Error in the STEPCAFControl_Provider during writing the file " <<
- thePath << "\t: Error on writing file";
- return false;
- }
- }
- return true;
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool STEPCAFControl_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 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);
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- Handle(XSControl_WorkSession)& theWS,
- const Message_ProgressRange& theProgress)
-{
- (void)theProgress;
- 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";
- return false;
- }
- Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
- personizeWS(theWS);
- STEPControl_Reader aReader;
- aReader.SetWS(theWS);
- IFSelect_ReturnStatus aReadstat = IFSelect_RetVoid;
- StepData_ConfParameters aParams = aNode->InternalParameters;
- aReadstat = aReader.ReadFile(thePath.ToCString(), aParams);
- Handle(StepData_StepModel) aModel = aReader.StepModel();
- if (aReadstat != IFSelect_RetDone)
- {
- Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
- thePath << "\t: abandon, no model loaded";
- 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";
- return false;
- }
- theShape = aReader.OneShape();
- return true;
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool STEPCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- Handle(XSControl_WorkSession)& theWS,
- const Message_ProgressRange& theProgress)
-{
- 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";
- return false;
- }
- Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
-
- personizeWS(theWS);
- STEPControl_Writer aWriter;
- aWriter.SetWS(theWS);
- IFSelect_ReturnStatus aWritestat = IFSelect_RetVoid;
- Handle(StepData_StepModel) aModel = aWriter.Model();;
- StepData_ConfParameters aParams = aNode->InternalParameters;
- aModel->SetLocalLengthUnit(aNode->GlobalParameters.SystemUnit);
- UnitsMethods_LengthUnit aTargetUnit = UnitsMethods::GetLengthUnitByFactorValue(aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
- aParams.WriteUnit = aTargetUnit;
- if (aTargetUnit == UnitsMethods_LengthUnit_Undefined)
- {
- aModel->SetWriteLengthUnit(1.0);
- Message::SendWarning() << "Custom units are not supported by STEP format, but LengthUnit global parameter doesn't fit any predefined unit. Units will be scaled to Millimeters";
- }
- else
- {
- aModel->SetWriteLengthUnit(aNode->GlobalParameters.LengthUnit);
- }
- aWritestat = aWriter.Transfer(theShape, aNode->InternalParameters.WriteModelType, aParams, true, theProgress);
- if (aWritestat != IFSelect_RetDone)
- {
- Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
- thePath << "\t: abandon, no model loaded";
- return false;
- }
- if (aWriter.Write(thePath.ToCString()) != IFSelect_RetDone)
- {
- Message::SendFail() << "STEPCAFControl_Provider: Error on writing file";
- 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,
- const TopoDS_Shape& theShape,
- const Message_ProgressRange& theProgress)
-{
- Handle(XSControl_WorkSession) aWS = new XSControl_WorkSession();
- return Write(thePath, theShape, aWS, theProgress);
-}
-
-//=======================================================================
-// function : GetFormat
-// purpose :
-//=======================================================================
-TCollection_AsciiString STEPCAFControl_Provider::GetFormat() const
-{
- return TCollection_AsciiString("STEP");
-}
-
-//=======================================================================
-// function : GetVendor
-// purpose :
-//=======================================================================
-TCollection_AsciiString STEPCAFControl_Provider::GetVendor() const
-{
- return TCollection_AsciiString("OCC");
-}
-
-//=======================================================================
-// function : personizeWS
-// purpose :
-//=======================================================================
-void STEPCAFControl_Provider::personizeWS(Handle(XSControl_WorkSession)& theWS)
-{
- if (theWS.IsNull())
- {
- Message::SendWarning() << "Warning: STEPCAFControl_Provider :"
- << " Null work session, use internal temporary session";
- theWS = new XSControl_WorkSession();
- }
- Handle(STEPCAFControl_Controller) aCntrl = Handle(STEPCAFControl_Controller)::DownCast(theWS->NormAdaptor());
- if (aCntrl.IsNull())
- {
- STEPCAFControl_Controller::Init();
- theWS->SelectNorm("STEP");
- }
-}
#ifndef _STEPCAFControl_Provider_HeaderFile
#define _STEPCAFControl_Provider_HeaderFile
-#include <DE_Provider.hxx>
-#include <STEPCAFControl_ConfigurationNode.hxx>
+#include <DESTEP_Provider.hxx>
-//! The class to transfer STEP files.
-//! Reads and Writes any STEP files into/from OCCT.
-//! Each operation needs configuration node.
-//!
-//! Providers grouped by Vendor name and Format type.
-//! The Vendor name is "OCC"
-//! The Format type is "STEP"
-//! The import process is supported.
-//! The export process is supported.
-class STEPCAFControl_Provider : public DE_Provider
-{
-public:
- DEFINE_STANDARD_RTTIEXT(STEPCAFControl_Provider, DE_Provider)
-
-public:
-
- //! Default constructor
- //! Configure translation process with global configuration
- Standard_EXPORT STEPCAFControl_Provider();
-
- //! Configure translation process
- //! @param[in] theNode object to copy
- Standard_EXPORT STEPCAFControl_Provider(const Handle(DE_ConfigurationNode)& theNode);
-
-public:
-
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theDocument document to save result
- //! @param[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- 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[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- 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[in] theProgress 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[in] theProgress 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
- //! @param[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- 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[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- 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[in] theProgress 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[in] theProgress 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 CAD format
- Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
-
- //! Gets provider's vendor name of associated provider
- //! @return provider's vendor name
- Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
-
- private:
-
- //! Personizes work session with current format.
- //! Creates new temporary session if current session is null
- //! @param[in] theWS current work session
- void personizeWS(Handle(XSControl_WorkSession)& theWS);
-
-};
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef DESTEP_Provider STEPCAFControl_Provider;
#endif // _STEPCAFControl_Provider_HeaderFile
DEBRepCascade
DEXCAFCascade
+DEBREP
+DEXCAF
RWGltf
+DEGLTF
\ No newline at end of file
BRepToIGES
BRepToIGESBRep
IGESControl
+DEIGES
StepFile
RWHeaderSection
APIHeaderSection
-HeaderSection
\ No newline at end of file
+HeaderSection
+DESTEP
VrmlAPI
Vrml
VrmlData
+DEVRML
Vrml_Cone.cxx
Vrml_Cone.hxx
Vrml_ConeParts.hxx
-Vrml_ConfigurationNode.cxx
Vrml_ConfigurationNode.hxx
Vrml_Coordinate3.cxx
Vrml_Coordinate3.hxx
Vrml_PointLight.hxx
Vrml_PointSet.cxx
Vrml_PointSet.hxx
-Vrml_Provider.cxx
Vrml_Provider.hxx
Vrml_Rotation.cxx
Vrml_Rotation.hxx
+++ /dev/null
-// Copyright (c) 2022 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Vrml_ConfigurationNode.hxx>
-
-#include <DE_ConfigurationContext.hxx>
-#include <DE_PluginHolder.hxx>
-#include <Vrml_Provider.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(Vrml_ConfigurationNode, DE_ConfigurationNode)
-
-namespace
-{
- static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
- {
- static const TCollection_AsciiString aScope = "provider";
- return aScope;
- }
-
- // Wrapper to auto-load DE component
- DE_PluginHolder<Vrml_ConfigurationNode> THE_OCCT_VRML_COMPONENT_PLUGIN;
-}
-
-//=======================================================================
-// function : STEPCAFControl_ConfigurationNode
-// purpose :
-//=======================================================================
-Vrml_ConfigurationNode::Vrml_ConfigurationNode() :
- DE_ConfigurationNode()
-{}
-
-//=======================================================================
-// function : STEPCAFControl_ConfigurationNode
-// purpose :
-//=======================================================================
-Vrml_ConfigurationNode::Vrml_ConfigurationNode(const Handle(Vrml_ConfigurationNode)& theNode)
- :DE_ConfigurationNode(theNode)
-{
- InternalParameters = theNode->InternalParameters;
-}
-
-//=======================================================================
-// function : Load
-// purpose :
-//=======================================================================
-bool Vrml_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
-{
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
-
- InternalParameters.ReadFileUnit =
- theResource->RealVal("read.file.unit", InternalParameters.ReadFileUnit, aScope);
- InternalParameters.ReadFileCoordinateSys = (RWMesh_CoordinateSystem)
- theResource->IntegerVal("read.file.coordinate.system", InternalParameters.ReadFileCoordinateSys, aScope);
- InternalParameters.ReadSystemCoordinateSys = (RWMesh_CoordinateSystem)
- theResource->IntegerVal("read.system.coordinate.system", InternalParameters.ReadSystemCoordinateSys, aScope);
- InternalParameters.ReadFillIncomplete =
- theResource->BooleanVal("read.fill.incomplete", InternalParameters.ReadFillIncomplete, aScope);
-
- InternalParameters.WriterVersion = (WriteMode_WriterVersion)
- theResource->IntegerVal("writer.version", InternalParameters.WriterVersion, aScope);
- InternalParameters.WriteRepresentationType = (WriteMode_RepresentationType)
- theResource->IntegerVal("write.representation.type", InternalParameters.WriteRepresentationType, aScope);
-
- return true;
-}
-
-//=======================================================================
-// function : Save
-// purpose :
-//=======================================================================
-TCollection_AsciiString Vrml_ConfigurationNode::Save() const
-{
- TCollection_AsciiString aResult;
- aResult += "!*****************************************************************************\n";
- aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
-
- aResult += "!\n";
- aResult += "!Read parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Set (override) file length units to convert from while reading the file, defined as scale factor for m (meters).\n";
- aResult += "!Default value: 1. Available values: positive double\n";
- aResult += aScope + "read.file.unit :\t " + InternalParameters.ReadFileUnit + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Set (override) file origin coordinate system to perform conversion during read.\n";
- aResult += "!Default value: Yup (1). { Zup (0) | Yup (1) }\n";
- aResult += aScope + "read.file.coordinate.system :\t " + InternalParameters.ReadFileCoordinateSys + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Set system origin coordinate system to perform conversion into during read.\n";
- aResult += "!Default value: Zup (0). Available values: { Zup (0) | Yup (1) }\n";
- aResult += aScope + "read.system.coordinate.system :\t " + InternalParameters.ReadSystemCoordinateSys + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Set flag allowing partially read file content to be put into the XDE document.\n";
- aResult += "!Default value: 1(\"ON\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
- aResult += aScope + "read.fill.incomplete :\t " + InternalParameters.ReadFillIncomplete + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Write parameters:\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up writer version.\n";
- aResult += "!Default value: 2. Available values: 1, 2\n";
- aResult += aScope + "writer.version :\t " + InternalParameters.WriterVersion + "\n";
- aResult += "!\n";
-
- aResult += "!\n";
- aResult += "!Setting up representation\n";
- aResult += "!Default value: 1. Available values: 0(shaded), 1(wireframe), 2(both).\n";
- aResult += aScope + "write.representation.type :\t " + InternalParameters.WriteRepresentationType + "\n";
- aResult += "!\n";
-
- aResult += "!*****************************************************************************\n";
- return aResult;
-}
-
-//=======================================================================
-// function : Copy
-// purpose :
-//=======================================================================
-Handle(DE_ConfigurationNode) Vrml_ConfigurationNode::Copy() const
-{
- return new Vrml_ConfigurationNode(*this);
-}
-
-//=======================================================================
-// function : BuildProvider
-// purpose :
-//=======================================================================
-Handle(DE_Provider) Vrml_ConfigurationNode::BuildProvider()
-{
- return new Vrml_Provider(this);
-}
-
-//=======================================================================
-// function : IsImportSupported
-// purpose :
-//=======================================================================
-bool Vrml_ConfigurationNode::IsImportSupported() const
-{
- return true;
-}
-
-//=======================================================================
-// function : IsExportSupported
-// purpose :
-//=======================================================================
-bool Vrml_ConfigurationNode::IsExportSupported() const
-{
- return true;
-}
-
-//=======================================================================
-// function : GetFormat
-// purpose :
-//=======================================================================
-TCollection_AsciiString Vrml_ConfigurationNode::GetFormat() const
-{
- return TCollection_AsciiString("VRML");
-}
-
-//=======================================================================
-// function : GetVendor
-// purpose :
-//=======================================================================
-TCollection_AsciiString Vrml_ConfigurationNode::GetVendor() const
-{
- return TCollection_AsciiString("OCC");
-}
-
-//=======================================================================
-// function : GetExtensions
-// purpose :
-//=======================================================================
-TColStd_ListOfAsciiString Vrml_ConfigurationNode::GetExtensions() const
-{
- TColStd_ListOfAsciiString anExt;
- anExt.Append("vrml");
- anExt.Append("wrl");
- return anExt;
-}
#ifndef _Vrml_ConfigurationNode_HeaderFile
#define _Vrml_ConfigurationNode_HeaderFile
-#include <DE_ConfigurationNode.hxx>
-#include <RWMesh_CoordinateSystem.hxx>
+#include <DEVRML_ConfigurationNode.hxx>
-//! The purpose of this class is to configure the transfer process for VRML format
-//! Stores the necessary settings for Vrml_Provider.
-//! Configures and creates special provider to transfer VRML files.
-//!
-//! Nodes grouped by Vendor name and Format type.
-//! The Vendor name is "OCC"
-//! The Format type is "VRML"
-//! The supported CAD extensions are ".vrml", ".wrl"
-//! The import process is supported.
-//! The export process is supported.
-class Vrml_ConfigurationNode : public DE_ConfigurationNode
-{
- DEFINE_STANDARD_RTTIEXT(Vrml_ConfigurationNode, DE_ConfigurationNode)
-public:
-
- //! Initializes all field by default
- Standard_EXPORT Vrml_ConfigurationNode();
-
- //! Copies values of all fields
- //! @param[in] theNode object to copy
- Standard_EXPORT Vrml_ConfigurationNode(const Handle(Vrml_ConfigurationNode)& theNode);
-
- //! Updates values according the resource
- //! @param[in] theResource input resource to use
- //! @return true if theResource loading has ended correctly
- Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource) Standard_OVERRIDE;
-
- //! Writes configuration to the string
- //! @return result resource string
- Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
-
- //! Copies values of all fields
- //! @return new object with the same field values
- Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
-
-
- //! Creates new provider for the own format
- //! @return new created provider
- Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
-
-public:
-
- //! Checks the import supporting
- //! @return true if import is supported
- Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
-
- //! Checks the export supporting
- //! @return true if export is supported
- Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
-
- //! Gets CAD format name of associated provider
- //! @return provider CAD format
- Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
-
- //! Gets provider's vendor name of associated provider
- //! @return provider's vendor name
- Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
-
- //! Gets list of supported file extensions
- //! @return list of extensions
- Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
-
-public:
- enum WriteMode_WriterVersion
- {
- WriteMode_WriterVersion_1 = 1,
- WriteMode_WriterVersion_2
- };
- enum WriteMode_RepresentationType
- {
- WriteMode_RepresentationType_Shaded = 0,
- WriteMode_RepresentationType_Wireframe,
- WriteMode_RepresentationType_Both
- };
-
- struct Vrml_InternalSection
- {
- // Read
-// clang-format off
- double ReadFileUnit = 1.; //<! file length units to convert from while reading the file, defined as scale factor for meters
- RWMesh_CoordinateSystem ReadFileCoordinateSys = RWMesh_CoordinateSystem_Yup; //<! coordinate system defined by Vrml file
- RWMesh_CoordinateSystem ReadSystemCoordinateSys = RWMesh_CoordinateSystem_Zup; //<! result coordinate system
- bool ReadFillIncomplete = true; //<! fill the document with partially retrieved data even if reader has failed with error
-
- // Write
- WriteMode_WriterVersion WriterVersion = WriteMode_WriterVersion_2; //!< Setting up writer version (1/2)
- WriteMode_RepresentationType WriteRepresentationType = WriteMode_RepresentationType_Wireframe; //!< Setting up representation (shaded/wireframe/both)
-// clang-format on
-
- } InternalParameters;
-};
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef DEVRML_ConfigurationNode Vrml_ConfigurationNode;
#endif // _Vrml_ConfigurationNode_HeaderFile
+++ /dev/null
-// Copyright (c) 2022 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Vrml_Provider.hxx>
-
-#include <Message.hxx>
-#include <OSD_Path.hxx>
-#include <TDocStd_Document.hxx>
-#include <VrmlAPI_CafReader.hxx>
-#include <VrmlAPI_Writer.hxx>
-#include <VrmlData_Scene.hxx>
-#include <Vrml_ConfigurationNode.hxx>
-#include <XCAFDoc_ShapeTool.hxx>
-#include <XCAFDoc_DocumentTool.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(Vrml_Provider, DE_Provider)
-
-//=======================================================================
-// function : Vrml_Provider
-// purpose :
-//=======================================================================
-Vrml_Provider::Vrml_Provider()
-{}
-
-//=======================================================================
-// function : Vrml_Provider
-// purpose :
-//=======================================================================
-Vrml_Provider::Vrml_Provider(const Handle(DE_ConfigurationNode)& theNode)
- :DE_Provider(theNode)
-{}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool Vrml_Provider::Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- Handle(XSControl_WorkSession)& theWS,
- 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 " <<
- thePath << "\t: theDocument shouldn't be null";
- return false;
- }
- if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(Vrml_ConfigurationNode)))
- {
- Message::SendFail() << "Error in the Vrml_Provider during reading the file " <<
- thePath << "\t: Incorrect or empty Configuration Node";
- return false;
- }
- Handle(Vrml_ConfigurationNode) aNode = Handle(Vrml_ConfigurationNode)::DownCast(GetNode());
-
- VrmlAPI_CafReader aVrmlReader;
- aVrmlReader.SetDocument(theDocument);
- aVrmlReader.SetFileLengthUnit(aNode->InternalParameters.ReadFileUnit);
- aVrmlReader.SetSystemLengthUnit(aNode->GlobalParameters.LengthUnit);
- aVrmlReader.SetFileCoordinateSystem(aNode->InternalParameters.ReadFileCoordinateSys);
- aVrmlReader.SetSystemCoordinateSystem(aNode->InternalParameters.ReadSystemCoordinateSys);
- aVrmlReader.SetFillIncompleteDocument(aNode->InternalParameters.ReadFillIncomplete);
-
- XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->InternalParameters.ReadFileUnit);
-
- if (!aVrmlReader.Perform(thePath, theProgress))
- {
- if (aVrmlReader.ExtraStatus() != RWMesh_CafReaderStatusEx_Partial)
- {
- Message::SendFail() << "Error in the Vrml_Provider during reading the file '" << thePath << "'";
- return false;
- }
- Message::SendWarning() << "Warning in the Vrml_Provider during reading the file: file has been read paratially " <<
- "(due to unexpected EOF, syntax error, memory limit) '" << thePath << "'";
- }
- return true;
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool Vrml_Provider::Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- const Message_ProgressRange& theProgress)
-{
- (void)theProgress;
- if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(Vrml_ConfigurationNode)))
- {
- Message::SendFail() << "Error in the Vrml_Provider during writing the file " <<
- thePath << "\t: Incorrect or empty Configuration Node";
- return false;
- }
- Handle(Vrml_ConfigurationNode) aNode = Handle(Vrml_ConfigurationNode)::DownCast(GetNode());
-
- VrmlAPI_Writer aWriter;
- aWriter.SetRepresentation(static_cast<VrmlAPI_RepresentationOfShape>(aNode->InternalParameters.WriteRepresentationType));
- Standard_Real aScaling = 1.;
- Standard_Real aScaleFactorMM = 1.;
- if (XCAFDoc_DocumentTool::GetLengthUnit(theDocument, aScaleFactorMM, UnitsMethods_LengthUnit_Millimeter))
- {
- aScaling = aScaleFactorMM / aNode->GlobalParameters.LengthUnit;
- }
- else
- {
- aScaling = aNode->GlobalParameters.SystemUnit / aNode->GlobalParameters.LengthUnit;
- Message::SendWarning() << "Warning in the Vrml_Provider during writing the file " <<
- thePath << "\t: The document has no information on Units. Using global parameter as initial Unit.";
- }
- if (!aWriter.WriteDoc(theDocument, thePath.ToCString(), aScaling))
- {
- Message::SendFail() << "Error in the Vrml_Provider during wtiting the file " <<
- thePath << "\t: File was not written";
- return false;
- }
-
- return true;
-}
-
-//=======================================================================
-// function : Read
-// purpose :
-//=======================================================================
-bool Vrml_Provider::Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- Handle(XSControl_WorkSession)& theWS,
- 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)))
- {
- Message::SendFail() << "Error in the Vrml_Provider during reading the file " <<
- thePath << "\t: Incorrect or empty Configuration Node";
- return false;
- }
- Handle(Vrml_ConfigurationNode) aNode = Handle(Vrml_ConfigurationNode)::DownCast(GetNode());
-
- TopoDS_Shape aShape;
- VrmlData_DataMapOfShapeAppearance aShapeAppMap;
-
- std::filebuf aFic;
- std::istream aStream(&aFic);
-
- if (aFic.open(thePath.ToCString(), std::ios::in))
- {
- // Get path of the VRML file.
- OSD_Path aPath(thePath.ToCString());
- TCollection_AsciiString aVrmlDir(".");
- TCollection_AsciiString aDisk = aPath.Disk();
- TCollection_AsciiString aTrek = aPath.Trek();
- if (!aTrek.IsEmpty())
- {
- if (!aDisk.IsEmpty())
- {
- aVrmlDir = aDisk;
- }
- else
- {
- aVrmlDir.Clear();
- }
- aTrek.ChangeAll('|', '/');
- aVrmlDir += aTrek;
- }
-
- VrmlData_Scene aScene;
- aScene.SetLinearScale(aNode->GlobalParameters.LengthUnit);
-
- aScene.SetVrmlDir(aVrmlDir);
- aScene << aStream;
- const char* aStr = 0L;
- switch (aScene.Status())
- {
- case VrmlData_StatusOK:
- {
- aShape = aScene.GetShape(aShapeAppMap);
- break;
- }
- case VrmlData_EmptyData: aStr = "EmptyData"; break;
- case VrmlData_UnrecoverableError: aStr = "UnrecoverableError"; break;
- case VrmlData_GeneralError: aStr = "GeneralError"; break;
- case VrmlData_EndOfFile: aStr = "EndOfFile"; break;
- case VrmlData_NotVrmlFile: aStr = "NotVrmlFile"; break;
- case VrmlData_CannotOpenFile: aStr = "CannotOpenFile"; break;
- case VrmlData_VrmlFormatError: aStr = "VrmlFormatError"; break;
- case VrmlData_NumericInputError: aStr = "NumericInputError"; break;
- case VrmlData_IrrelevantNumber: aStr = "IrrelevantNumber"; break;
- case VrmlData_BooleanInputError: aStr = "BooleanInputError"; break;
- case VrmlData_StringInputError: aStr = "StringInputError"; break;
- case VrmlData_NodeNameUnknown: aStr = "NodeNameUnknown"; break;
- case VrmlData_NonPositiveSize: aStr = "NonPositiveSize"; break;
- case VrmlData_ReadUnknownNode: aStr = "ReadUnknownNode"; break;
- case VrmlData_NonSupportedFeature: aStr = "NonSupportedFeature"; break;
- case VrmlData_OutputStreamUndefined:aStr = "OutputStreamUndefined"; break;
- case VrmlData_NotImplemented: aStr = "NotImplemented"; break;
- default:
- break;
- }
- if (aStr)
- {
- Message::SendFail() << "Error in the Vrml_Provider during reading the file " <<
- thePath << "\t: ++ VRML Error: " << aStr << " in line " << aScene.GetLineError();
- return false;
- }
- else
- {
- theShape = aShape;
- }
- }
- else
- {
- Message::SendFail() << "Error in the Vrml_Provider during reading the file " <<
- thePath << "\t: cannot open file";
- return false;
- }
- return true;
-}
-
-//=======================================================================
-// function : Write
-// purpose :
-//=======================================================================
-bool Vrml_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);
-}
-
-//=======================================================================
-// function : GetFormat
-// purpose :
-//=======================================================================
-TCollection_AsciiString Vrml_Provider::GetFormat() const
-{
- return TCollection_AsciiString("VRML");
-}
-
-//=======================================================================
-// function : GetVendor
-// purpose :
-//=======================================================================
-TCollection_AsciiString Vrml_Provider::GetVendor() const
-{
- return TCollection_AsciiString("OCC");
-}
#ifndef _Vrml_Provider_HeaderFile
#define _Vrml_Provider_HeaderFile
-#include <DE_Provider.hxx>
+#include <DEVRML_Provider.hxx>
-//! The class to transfer VRML files.
-//! Reads and Writes any VRML files into/from OCCT.
-//! Each operation needs configuration node.
-//!
-//! Providers grouped by Vendor name and Format type.
-//! The Vendor name is "OCC"
-//! The Format type is "VRML"
-//! The import process is supported.
-//! The export process is supported.
-class Vrml_Provider : public DE_Provider
-{
-public:
- DEFINE_STANDARD_RTTIEXT(Vrml_Provider, DE_Provider)
-
-public:
-
- //! Default constructor
- //! Configure translation process with global configuration
- Standard_EXPORT Vrml_Provider();
-
- //! Configure translation process
- //! @param[in] theNode object to copy
- Standard_EXPORT Vrml_Provider(const Handle(DE_ConfigurationNode)& theNode);
-
-public:
-
- //! Reads a CAD file, according internal configuration
- //! @param[in] thePath path to the import CAD file
- //! @param[out] theDocument document to save result
- //! @param[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- 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[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const Handle(TDocStd_Document)& theDocument,
- 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[in] theProgress 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[in] theProgress 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
- //! @param[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Read operation has ended correctly
- Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
- TopoDS_Shape& theShape,
- 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[in] theWS current work session
- //! @param[in] theProgress progress indicator
- //! @return true if Write operation has ended correctly
- Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
- const TopoDS_Shape& theShape,
- 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[in] theProgress 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[in] theProgress 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 CAD format
- Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
-
- //! Gets provider's vendor name of associated provider
- //! @return provider's vendor name
- Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
-};
+Standard_DEPRECATED("Deprecated alias to moved class")
+typedef DEVRML_Provider Vrml_Provider;
#endif // _Vrml_Provider_HeaderFile
#include <DDocStd.hxx>
#include <DDocStd_DrawDocument.hxx>
#include <DE_Wrapper.hxx>
-#include <DEBRepCascade_ConfigurationNode.hxx>
-#include <DEXCAFCascade_ConfigurationNode.hxx>
+#include <DEBREP_ConfigurationNode.hxx>
+#include <DEXCAF_ConfigurationNode.hxx>
#include <Draw.hxx>
#include <Draw_PluginMacro.hxx>
#include <Draw_ProgressIndicator.hxx>
#include <Geom_Axis2Placement.hxx>
-#include <IGESCAFControl_ConfigurationNode.hxx>
+#include <DEIGES_ConfigurationNode.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Quantity_Color.hxx>
-#include <RWStl_ConfigurationNode.hxx>
-#include <RWGltf_ConfigurationNode.hxx>
-#include <RWObj_ConfigurationNode.hxx>
-#include <RWPly_ConfigurationNode.hxx>
+#include <DESTL_ConfigurationNode.hxx>
+#include <DEGLTF_ConfigurationNode.hxx>
+#include <DEOBJ_ConfigurationNode.hxx>
+#include <DEPLY_ConfigurationNode.hxx>
#include <STEPCAFControl_Controller.hxx>
-#include <STEPCAFControl_ConfigurationNode.hxx>
+#include <DESTEP_ConfigurationNode.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <TCollection_HAsciiString.hxx>
#include <V3d_Viewer.hxx>
#include <ViewerTest.hxx>
#include <ViewerTest_AutoUpdater.hxx>
-#include <Vrml_ConfigurationNode.hxx>
+#include <DEVRML_ConfigurationNode.hxx>
#include <XCAFDoc.hxx>
#include <XCAFDoc_AssemblyIterator.hxx>
#include <XCAFDoc_AssemblyGraph.hxx>
#include <DE_ConfigurationContext.hxx>
#include <DE_Provider.hxx>
#include <DE_Wrapper.hxx>
-#include <DEBRepCascade_ConfigurationNode.hxx>
+#include <DEBREP_ConfigurationNode.hxx>
#include <Draw.hxx>
#include <Draw_Interpretor.hxx>
#include <Draw_PluginMacro.hxx>
XSDRAW::LoadDraw(theDI);
// Workaround to force load TKDECascade lib
- DEBRepCascade_ConfigurationNode aTmpObj;
+ DEBREP_ConfigurationNode aTmpObj;
(void)aTmpObj;
}