mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-07 18:30:55 +03:00
Coding - Separate DE Wrapper's plugins to own packages #260
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.
This commit is contained in:
parent
e6b2e97f13
commit
1083052cc2
@ -200,7 +200,7 @@ All registered providers are set to the map with information about its vendor an
|
||||
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
|
||||
@ -216,7 +216,7 @@ It is possible to change a parameter from code using a smart pointer.
|
||||
|
||||
~~~~{.cpp}
|
||||
// global variable
|
||||
static Handle(STEPCAFControl_ConfigurationNode) THE_STEP_NODE;
|
||||
static Handle(DESTEP_ConfigurationNode) THE_STEP_NODE;
|
||||
|
||||
static Handle(DE_ConfigurationNode) RegisterStepNode()
|
||||
{
|
||||
@ -226,7 +226,7 @@ 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;
|
||||
}
|
||||
@ -351,7 +351,7 @@ It is possible to read and write CAD files directly from a special provider.
|
||||
|
||||
~~~~{.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
|
||||
|
@ -11,14 +11,14 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <DEBRepCascade_ConfigurationNode.hxx>
|
||||
#include <DEBREP_ConfigurationNode.hxx>
|
||||
|
||||
#include <DEBREP_Provider.hxx>
|
||||
#include <DE_ConfigurationContext.hxx>
|
||||
#include <DE_PluginHolder.hxx>
|
||||
#include <DEBRepCascade_Provider.hxx>
|
||||
#include <NCollection_Buffer.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DEBRepCascade_ConfigurationNode, DE_ConfigurationNode)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DEBREP_ConfigurationNode, DE_ConfigurationNode)
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -29,41 +29,41 @@ namespace
|
||||
}
|
||||
|
||||
// Wrapper to auto-load DE component
|
||||
DE_PluginHolder<DEBRepCascade_ConfigurationNode> THE_OCCT_BREP_COMPONENT_PLUGIN;
|
||||
DE_PluginHolder<DEBREP_ConfigurationNode> THE_OCCT_BREP_COMPONENT_PLUGIN;
|
||||
} // namespace
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
DEBREP_ConfigurationNode::DEBREP_ConfigurationNode()
|
||||
: DE_ConfigurationNode()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : DEBRepCascade_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
DEBRepCascade_ConfigurationNode::DEBRepCascade_ConfigurationNode() :
|
||||
DE_ConfigurationNode()
|
||||
{}
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
// function : DEBRepCascade_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
DEBRepCascade_ConfigurationNode::DEBRepCascade_ConfigurationNode(const Handle(DEBRepCascade_ConfigurationNode)& theNode)
|
||||
DEBREP_ConfigurationNode::DEBREP_ConfigurationNode(const Handle(DEBREP_ConfigurationNode)& theNode)
|
||||
: DE_ConfigurationNode(theNode)
|
||||
{
|
||||
InternalParameters = theNode->InternalParameters;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Load
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEBRepCascade_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
|
||||
//=================================================================================================
|
||||
|
||||
bool DEBREP_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
|
||||
{
|
||||
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
|
||||
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);
|
||||
(BinTools_FormatVersion)theResource->IntegerVal("write.version.binary",
|
||||
InternalParameters.WriteVersionBin,
|
||||
aScope);
|
||||
InternalParameters.WriteVersionAscii =
|
||||
(TopTools_FormatVersion)theResource->IntegerVal("write.version.ascii", InternalParameters.WriteVersionAscii, aScope);
|
||||
(TopTools_FormatVersion)theResource->IntegerVal("write.version.ascii",
|
||||
InternalParameters.WriteVersionAscii,
|
||||
aScope);
|
||||
InternalParameters.WriteTriangles =
|
||||
theResource->BooleanVal("write.triangles", InternalParameters.WriteTriangles, aScope);
|
||||
InternalParameters.WriteNormals =
|
||||
@ -71,16 +71,16 @@ bool DEBRepCascade_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Save
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString DEBRepCascade_ConfigurationNode::Save() const
|
||||
//=================================================================================================
|
||||
|
||||
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 =
|
||||
aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
|
||||
TCollection_AsciiString aScope =
|
||||
THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Write parameters:\n";
|
||||
@ -120,88 +120,70 @@ TCollection_AsciiString DEBRepCascade_ConfigurationNode::Save() const
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Copy
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_ConfigurationNode) DEBRepCascade_ConfigurationNode::Copy() const
|
||||
//=================================================================================================
|
||||
|
||||
Handle(DE_ConfigurationNode) DEBREP_ConfigurationNode::Copy() const
|
||||
{
|
||||
return new DEBRepCascade_ConfigurationNode(*this);
|
||||
return new DEBREP_ConfigurationNode(*this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : BuildProvider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_Provider) DEBRepCascade_ConfigurationNode::BuildProvider()
|
||||
//=================================================================================================
|
||||
|
||||
Handle(DE_Provider) DEBREP_ConfigurationNode::BuildProvider()
|
||||
{
|
||||
return new DEBRepCascade_Provider(this);
|
||||
return new DEBREP_Provider(this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsImportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEBRepCascade_ConfigurationNode::IsImportSupported() const
|
||||
//=================================================================================================
|
||||
|
||||
bool DEBREP_ConfigurationNode::IsImportSupported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsExportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEBRepCascade_ConfigurationNode::IsExportSupported() const
|
||||
//=================================================================================================
|
||||
|
||||
bool DEBREP_ConfigurationNode::IsExportSupported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetFormat
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString DEBRepCascade_ConfigurationNode::GetFormat() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DEBREP_ConfigurationNode::GetFormat() const
|
||||
{
|
||||
return TCollection_AsciiString("BREP");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetVendor
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString DEBRepCascade_ConfigurationNode::GetVendor() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DEBREP_ConfigurationNode::GetVendor() const
|
||||
{
|
||||
return TCollection_AsciiString("OCC");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetExtensions
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TColStd_ListOfAsciiString DEBRepCascade_ConfigurationNode::GetExtensions() const
|
||||
//=================================================================================================
|
||||
|
||||
TColStd_ListOfAsciiString DEBREP_ConfigurationNode::GetExtensions() const
|
||||
{
|
||||
TColStd_ListOfAsciiString anExt;
|
||||
anExt.Append("brep");
|
||||
return anExt;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : CheckContent
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEBRepCascade_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
|
||||
//=================================================================================================
|
||||
|
||||
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"))
|
||||
if (::strstr(aBytes, "DBRep_DrawableShape") || ::strstr(aBytes, "CASCADE Topology V1")
|
||||
|| ::strstr(aBytes, "CASCADE Topology V3"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
103
src/DEBREP/DEBREP_ConfigurationNode.hxx
Normal file
103
src/DEBREP/DEBREP_ConfigurationNode.hxx
Normal file
@ -0,0 +1,103 @@
|
||||
// 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
|
297
src/DEBREP/DEBREP_Provider.cxx
Normal file
297
src/DEBREP/DEBREP_Provider.cxx
Normal file
@ -0,0 +1,297 @@
|
||||
// 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");
|
||||
}
|
141
src/DEBREP/DEBREP_Provider.hxx
Normal file
141
src/DEBREP/DEBREP_Provider.hxx
Normal file
@ -0,0 +1,141 @@
|
||||
// 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
|
4
src/DEBREP/FILES
Normal file
4
src/DEBREP/FILES
Normal file
@ -0,0 +1,4 @@
|
||||
DEBREP_ConfigurationNode.cxx
|
||||
DEBREP_ConfigurationNode.hxx
|
||||
DEBREP_Provider.cxx
|
||||
DEBREP_Provider.hxx
|
@ -14,91 +14,9 @@
|
||||
#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
|
||||
|
@ -1,306 +0,0 @@
|
||||
// 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");
|
||||
}
|
@ -14,123 +14,9 @@
|
||||
#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
|
||||
|
@ -1,4 +1,2 @@
|
||||
DEBRepCascade_ConfigurationNode.cxx
|
||||
DEBRepCascade_ConfigurationNode.hxx
|
||||
DEBRepCascade_Provider.cxx
|
||||
DEBRepCascade_Provider.hxx
|
||||
|
@ -11,13 +11,13 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <RWGltf_ConfigurationNode.hxx>
|
||||
#include <DEGLTF_ConfigurationNode.hxx>
|
||||
|
||||
#include <DEGLTF_Provider.hxx>
|
||||
#include <DE_ConfigurationContext.hxx>
|
||||
#include <DE_PluginHolder.hxx>
|
||||
#include <RWGltf_Provider.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(RWGltf_ConfigurationNode, DE_ConfigurationNode)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DEGLTF_ConfigurationNode, DE_ConfigurationNode)
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -28,44 +28,48 @@ namespace
|
||||
}
|
||||
|
||||
// Wrapper to auto-load DE component
|
||||
DE_PluginHolder<RWGltf_ConfigurationNode> THE_OCCT_GLTF_COMPONENT_PLUGIN;
|
||||
DE_PluginHolder<DEGLTF_ConfigurationNode> THE_OCCT_GLTF_COMPONENT_PLUGIN;
|
||||
} // namespace
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
DEGLTF_ConfigurationNode::DEGLTF_ConfigurationNode()
|
||||
: DE_ConfigurationNode()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : RWGltf_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
RWGltf_ConfigurationNode::RWGltf_ConfigurationNode() :
|
||||
DE_ConfigurationNode()
|
||||
{}
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
// function : RWGltf_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
RWGltf_ConfigurationNode::RWGltf_ConfigurationNode(const Handle(RWGltf_ConfigurationNode)& theNode)
|
||||
DEGLTF_ConfigurationNode::DEGLTF_ConfigurationNode(const Handle(DEGLTF_ConfigurationNode)& theNode)
|
||||
: DE_ConfigurationNode(theNode)
|
||||
{
|
||||
InternalParameters = theNode->InternalParameters;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Load
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWGltf_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
|
||||
//=================================================================================================
|
||||
|
||||
bool DEGLTF_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
|
||||
{
|
||||
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
|
||||
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.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);
|
||||
theResource->BooleanVal("read.single.precision",
|
||||
InternalParameters.ReadSinglePrecision,
|
||||
aScope);
|
||||
InternalParameters.ReadCreateShapes =
|
||||
theResource->BooleanVal("read.create.shapes", InternalParameters.ReadCreateShapes, aScope);
|
||||
InternalParameters.ReadRootPrefix =
|
||||
@ -83,53 +87,75 @@ bool RWGltf_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theRe
|
||||
InternalParameters.ReadLoadAllScenes =
|
||||
theResource->BooleanVal("read.load.all.scenes", InternalParameters.ReadLoadAllScenes, aScope);
|
||||
InternalParameters.ReadUseMeshNameAsFallback =
|
||||
theResource->BooleanVal("read.use.mesh.name.as.fallback", InternalParameters.ReadUseMeshNameAsFallback, aScope);
|
||||
theResource->BooleanVal("read.use.mesh.name.as.fallback",
|
||||
InternalParameters.ReadUseMeshNameAsFallback,
|
||||
aScope);
|
||||
InternalParameters.ReadSkipLateDataLoading =
|
||||
theResource->BooleanVal("read.skip.late.data.loading", InternalParameters.ReadSkipLateDataLoading, aScope);
|
||||
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);
|
||||
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.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);
|
||||
theResource->BooleanVal("write.forced.uv.export",
|
||||
InternalParameters.WriteForcedUVExport,
|
||||
aScope);
|
||||
InternalParameters.WriteEmbedTexturesInGlb =
|
||||
theResource->BooleanVal("write.embed.textures.in.glb", InternalParameters.WriteEmbedTexturesInGlb, aScope);
|
||||
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);
|
||||
theResource->BooleanVal("write.split.indices16",
|
||||
InternalParameters.WriteSplitIndices16,
|
||||
aScope);
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Save
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString RWGltf_ConfigurationNode::Save() const
|
||||
//=================================================================================================
|
||||
|
||||
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 =
|
||||
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 += "!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";
|
||||
@ -164,7 +190,8 @@ TCollection_AsciiString RWGltf_ConfigurationNode::Save() const
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Root folder for generating root labels names\n";
|
||||
aResult += "!Default value: ""(empty). Available values: <path>\n";
|
||||
aResult += "!Default value: "
|
||||
"(empty). Available values: <path>\n";
|
||||
aResult += aScope + "read.root.prefix :\t " + InternalParameters.ReadRootPrefix + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
@ -175,7 +202,8 @@ TCollection_AsciiString RWGltf_ConfigurationNode::Save() const
|
||||
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 += "!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";
|
||||
@ -207,17 +235,20 @@ TCollection_AsciiString RWGltf_ConfigurationNode::Save() const
|
||||
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 += 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 +=
|
||||
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 +=
|
||||
"!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";
|
||||
@ -225,7 +256,8 @@ TCollection_AsciiString RWGltf_ConfigurationNode::Save() const
|
||||
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 +=
|
||||
aScope + "read.print.debug.message :\t " + InternalParameters.ReadPrintDebugMessages + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
@ -234,13 +266,15 @@ TCollection_AsciiString RWGltf_ConfigurationNode::Save() const
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Export special comment\n";
|
||||
aResult += "!Default value: ""(empty). Available values: <string>\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 += "!Default value: "
|
||||
"(empty). Available values: <string>\n";
|
||||
aResult += aScope + "write.author :\t " + InternalParameters.WriteAuthor + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
@ -252,13 +286,17 @@ TCollection_AsciiString RWGltf_ConfigurationNode::Save() const
|
||||
|
||||
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 += "!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 += "!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";
|
||||
|
||||
@ -271,7 +309,8 @@ TCollection_AsciiString RWGltf_ConfigurationNode::Save() const
|
||||
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 +=
|
||||
aScope + "write.embed.textures.in.glb :\t " + InternalParameters.WriteEmbedTexturesInGlb + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
@ -290,65 +329,51 @@ TCollection_AsciiString RWGltf_ConfigurationNode::Save() const
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Copy
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_ConfigurationNode) RWGltf_ConfigurationNode::Copy() const
|
||||
//=================================================================================================
|
||||
|
||||
Handle(DE_ConfigurationNode) DEGLTF_ConfigurationNode::Copy() const
|
||||
{
|
||||
return new RWGltf_ConfigurationNode(*this);
|
||||
return new DEGLTF_ConfigurationNode(*this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : BuildProvider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_Provider) RWGltf_ConfigurationNode::BuildProvider()
|
||||
//=================================================================================================
|
||||
|
||||
Handle(DE_Provider) DEGLTF_ConfigurationNode::BuildProvider()
|
||||
{
|
||||
return new RWGltf_Provider(this);
|
||||
return new DEGLTF_Provider(this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsImportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWGltf_ConfigurationNode::IsImportSupported() const
|
||||
//=================================================================================================
|
||||
|
||||
bool DEGLTF_ConfigurationNode::IsImportSupported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsExportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWGltf_ConfigurationNode::IsExportSupported() const
|
||||
//=================================================================================================
|
||||
|
||||
bool DEGLTF_ConfigurationNode::IsExportSupported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetFormat
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString RWGltf_ConfigurationNode::GetFormat() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DEGLTF_ConfigurationNode::GetFormat() const
|
||||
{
|
||||
return TCollection_AsciiString("GLTF");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetVendor
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString RWGltf_ConfigurationNode::GetVendor() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DEGLTF_ConfigurationNode::GetVendor() const
|
||||
{
|
||||
return TCollection_AsciiString("OCC");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetExtensions
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TColStd_ListOfAsciiString RWGltf_ConfigurationNode::GetExtensions() const
|
||||
//=================================================================================================
|
||||
|
||||
TColStd_ListOfAsciiString DEGLTF_ConfigurationNode::GetExtensions() const
|
||||
{
|
||||
TColStd_ListOfAsciiString anExt;
|
||||
anExt.Append("gltf");
|
118
src/DEGLTF/DEGLTF_ConfigurationNode.hxx
Normal file
118
src/DEGLTF/DEGLTF_ConfigurationNode.hxx
Normal file
@ -0,0 +1,118 @@
|
||||
// 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
|
249
src/DEGLTF/DEGLTF_Provider.cxx
Normal file
249
src/DEGLTF/DEGLTF_Provider.cxx
Normal file
@ -0,0 +1,249 @@
|
||||
// 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");
|
||||
}
|
143
src/DEGLTF/DEGLTF_Provider.hxx
Normal file
143
src/DEGLTF/DEGLTF_Provider.hxx
Normal file
@ -0,0 +1,143 @@
|
||||
// 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
|
4
src/DEGLTF/FILES
Normal file
4
src/DEGLTF/FILES
Normal file
@ -0,0 +1,4 @@
|
||||
DEGLTF_ConfigurationNode.cxx
|
||||
DEGLTF_ConfigurationNode.hxx
|
||||
DEGLTF_Provider.cxx
|
||||
DEGLTF_Provider.hxx
|
@ -11,14 +11,14 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <IGESCAFControl_ConfigurationNode.hxx>
|
||||
#include <DEIGES_ConfigurationNode.hxx>
|
||||
|
||||
#include <DEIGES_Provider.hxx>
|
||||
#include <DE_ConfigurationContext.hxx>
|
||||
#include <DE_PluginHolder.hxx>
|
||||
#include <IGESCAFControl_Provider.hxx>
|
||||
#include <NCollection_Buffer.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(IGESCAFControl_ConfigurationNode, DE_ConfigurationNode)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DEIGES_ConfigurationNode, DE_ConfigurationNode)
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -29,49 +29,55 @@ namespace
|
||||
}
|
||||
|
||||
// Wrapper to auto-load DE component
|
||||
DE_PluginHolder<IGESCAFControl_ConfigurationNode> THE_OCCT_IGES_COMPONENT_PLUGIN;
|
||||
DE_PluginHolder<DEIGES_ConfigurationNode> THE_OCCT_IGES_COMPONENT_PLUGIN;
|
||||
} // namespace
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
DEIGES_ConfigurationNode::DEIGES_ConfigurationNode()
|
||||
: DE_ConfigurationNode()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IGESCAFControl_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
IGESCAFControl_ConfigurationNode::IGESCAFControl_ConfigurationNode() :
|
||||
DE_ConfigurationNode()
|
||||
{}
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
// function : IGESCAFControl_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
IGESCAFControl_ConfigurationNode::IGESCAFControl_ConfigurationNode(const Handle(IGESCAFControl_ConfigurationNode)& theNode)
|
||||
DEIGES_ConfigurationNode::DEIGES_ConfigurationNode(const Handle(DEIGES_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);
|
||||
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.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);
|
||||
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);
|
||||
|
||||
@ -92,10 +98,14 @@ bool IGESCAFControl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext
|
||||
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.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 =
|
||||
@ -108,12 +118,16 @@ bool IGESCAFControl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext
|
||||
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.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.WritePlaneMode =
|
||||
(WriteMode_PlaneMode)theResource->IntegerVal("write.plane.mode",
|
||||
InternalParameters.WritePlaneMode,
|
||||
aScope);
|
||||
InternalParameters.WriteOffsetMode =
|
||||
theResource->BooleanVal("write.offset", InternalParameters.WriteOffsetMode, aScope);
|
||||
InternalParameters.WriteColor =
|
||||
@ -126,16 +140,16 @@ bool IGESCAFControl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Save
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString IGESCAFControl_ConfigurationNode::Save() const
|
||||
//=================================================================================================
|
||||
|
||||
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 =
|
||||
aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
|
||||
TCollection_AsciiString aScope =
|
||||
THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Common parameters:\n";
|
||||
@ -145,7 +159,8 @@ TCollection_AsciiString IGESCAFControl_ConfigurationNode::Save() const
|
||||
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 +=
|
||||
aScope + "read.iges.bspline.continuity :\t " + InternalParameters.ReadBSplineContinuity + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
@ -163,12 +178,15 @@ TCollection_AsciiString IGESCAFControl_ConfigurationNode::Save() const
|
||||
|
||||
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 +=
|
||||
"!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 += "!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";
|
||||
@ -177,22 +195,28 @@ TCollection_AsciiString IGESCAFControl_ConfigurationNode::Save() const
|
||||
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 +=
|
||||
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 +=
|
||||
"!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 +=
|
||||
"!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 +=
|
||||
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 += "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";
|
||||
@ -203,8 +227,10 @@ TCollection_AsciiString IGESCAFControl_ConfigurationNode::Save() const
|
||||
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 +=
|
||||
"!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";
|
||||
@ -229,7 +255,8 @@ TCollection_AsciiString IGESCAFControl_ConfigurationNode::Save() const
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Controls transferring invisible sub entities which logically depend on the grouping entities\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";
|
||||
@ -263,11 +290,15 @@ TCollection_AsciiString IGESCAFControl_ConfigurationNode::Save() const
|
||||
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 +=
|
||||
"!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 +=
|
||||
aScope + "write.convertsurface.mode :\t " + InternalParameters.WriteConvertSurfaceMode + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
@ -278,7 +309,8 @@ TCollection_AsciiString IGESCAFControl_ConfigurationNode::Save() const
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Gives the name of the sending company\n";
|
||||
aResult += "!Default value: ""(empty). Available values: <string>\n";
|
||||
aResult += "!Default value: "
|
||||
"(empty). Available values: <string>\n";
|
||||
aResult += aScope + "write.header.company :\t " + InternalParameters.WriteHeaderCompany + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
@ -292,7 +324,8 @@ TCollection_AsciiString IGESCAFControl_ConfigurationNode::Save() const
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Gives the name of the receiving company\n";
|
||||
aResult += "!Default value: ""(empty). Available values: <string>\n";
|
||||
aResult += "!Default value: "
|
||||
"(empty). Available values: <string>\n";
|
||||
aResult += aScope + "write.header.receiver :\t " + InternalParameters.WriteHeaderReciever + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
@ -316,7 +349,8 @@ TCollection_AsciiString IGESCAFControl_ConfigurationNode::Save() const
|
||||
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 += "!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";
|
||||
@ -355,65 +389,51 @@ TCollection_AsciiString IGESCAFControl_ConfigurationNode::Save() const
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Copy
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_ConfigurationNode) IGESCAFControl_ConfigurationNode::Copy() const
|
||||
//=================================================================================================
|
||||
|
||||
Handle(DE_ConfigurationNode) DEIGES_ConfigurationNode::Copy() const
|
||||
{
|
||||
return new IGESCAFControl_ConfigurationNode(*this);
|
||||
return new DEIGES_ConfigurationNode(*this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : BuildProvider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_Provider) IGESCAFControl_ConfigurationNode::BuildProvider()
|
||||
//=================================================================================================
|
||||
|
||||
Handle(DE_Provider) DEIGES_ConfigurationNode::BuildProvider()
|
||||
{
|
||||
return new IGESCAFControl_Provider(this);
|
||||
return new DEIGES_Provider(this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsImportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool IGESCAFControl_ConfigurationNode::IsImportSupported() const
|
||||
//=================================================================================================
|
||||
|
||||
bool DEIGES_ConfigurationNode::IsImportSupported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsExportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool IGESCAFControl_ConfigurationNode::IsExportSupported() const
|
||||
//=================================================================================================
|
||||
|
||||
bool DEIGES_ConfigurationNode::IsExportSupported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetFormat
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString IGESCAFControl_ConfigurationNode::GetFormat() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DEIGES_ConfigurationNode::GetFormat() const
|
||||
{
|
||||
return TCollection_AsciiString("IGES");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetVendor
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString IGESCAFControl_ConfigurationNode::GetVendor() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DEIGES_ConfigurationNode::GetVendor() const
|
||||
{
|
||||
return TCollection_AsciiString("OCC");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetExtensions
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TColStd_ListOfAsciiString IGESCAFControl_ConfigurationNode::GetExtensions() const
|
||||
//=================================================================================================
|
||||
|
||||
TColStd_ListOfAsciiString DEIGES_ConfigurationNode::GetExtensions() const
|
||||
{
|
||||
TColStd_ListOfAsciiString anExt;
|
||||
anExt.Append("igs");
|
||||
@ -421,11 +441,9 @@ TColStd_ListOfAsciiString IGESCAFControl_ConfigurationNode::GetExtensions() cons
|
||||
return anExt;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : CheckContent
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool IGESCAFControl_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
|
||||
//=================================================================================================
|
||||
|
||||
bool DEIGES_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
|
||||
{
|
||||
if (theBuffer.IsNull() || theBuffer->Size() < 83)
|
||||
{
|
184
src/DEIGES/DEIGES_ConfigurationNode.hxx
Normal file
184
src/DEIGES/DEIGES_ConfigurationNode.hxx
Normal file
@ -0,0 +1,184 @@
|
||||
// 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
|
424
src/DEIGES/DEIGES_Provider.cxx
Normal file
424
src/DEIGES/DEIGES_Provider.cxx
Normal file
@ -0,0 +1,424 @@
|
||||
// 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");
|
||||
}
|
160
src/DEIGES/DEIGES_Provider.hxx
Normal file
160
src/DEIGES/DEIGES_Provider.hxx
Normal file
@ -0,0 +1,160 @@
|
||||
// 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
|
4
src/DEIGES/FILES
Normal file
4
src/DEIGES/FILES
Normal file
@ -0,0 +1,4 @@
|
||||
DEIGES_ConfigurationNode.cxx
|
||||
DEIGES_ConfigurationNode.hxx
|
||||
DEIGES_Provider.cxx
|
||||
DEIGES_Provider.hxx
|
@ -11,13 +11,13 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <RWObj_ConfigurationNode.hxx>
|
||||
#include <DEOBJ_ConfigurationNode.hxx>
|
||||
|
||||
#include <DEOBJ_Provider.hxx>
|
||||
#include <DE_ConfigurationContext.hxx>
|
||||
#include <DE_PluginHolder.hxx>
|
||||
#include <RWObj_Provider.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(RWObj_ConfigurationNode, DE_ConfigurationNode)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DEOBJ_ConfigurationNode, DE_ConfigurationNode)
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -28,43 +28,47 @@ namespace
|
||||
}
|
||||
|
||||
// Wrapper to auto-load DE component
|
||||
DE_PluginHolder<RWObj_ConfigurationNode> THE_OCCT_OBJ_COMPONENT_PLUGIN;
|
||||
DE_PluginHolder<DEOBJ_ConfigurationNode> THE_OCCT_OBJ_COMPONENT_PLUGIN;
|
||||
} // namespace
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
DEOBJ_ConfigurationNode::DEOBJ_ConfigurationNode()
|
||||
: DE_ConfigurationNode()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : RWObj_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
RWObj_ConfigurationNode::RWObj_ConfigurationNode() :
|
||||
DE_ConfigurationNode()
|
||||
{}
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
// function : RWObj_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
RWObj_ConfigurationNode::RWObj_ConfigurationNode(const Handle(RWObj_ConfigurationNode)& theNode)
|
||||
DEOBJ_ConfigurationNode::DEOBJ_ConfigurationNode(const Handle(DEOBJ_ConfigurationNode)& theNode)
|
||||
: DE_ConfigurationNode(theNode)
|
||||
{
|
||||
InternalParameters = theNode->InternalParameters;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Load
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWObj_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
|
||||
//=================================================================================================
|
||||
|
||||
bool DEOBJ_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
|
||||
{
|
||||
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
|
||||
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.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);
|
||||
theResource->BooleanVal("read.single.precision",
|
||||
InternalParameters.ReadSinglePrecision,
|
||||
aScope);
|
||||
InternalParameters.ReadCreateShapes =
|
||||
theResource->BooleanVal("read.create.shapes", InternalParameters.ReadCreateShapes, aScope);
|
||||
InternalParameters.ReadRootPrefix =
|
||||
@ -83,23 +87,24 @@ bool RWObj_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theRes
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Save
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString RWObj_ConfigurationNode::Save() const
|
||||
//=================================================================================================
|
||||
|
||||
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 =
|
||||
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 += "!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";
|
||||
@ -134,7 +139,8 @@ TCollection_AsciiString RWObj_ConfigurationNode::Save() const
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Root folder for generating root labels names\n";
|
||||
aResult += "!Default value: ""(empty). Available values: <path>\n";
|
||||
aResult += "!Default value: "
|
||||
"(empty). Available values: <path>\n";
|
||||
aResult += aScope + "read.root.prefix :\t " + InternalParameters.ReadRootPrefix + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
@ -145,7 +151,8 @@ TCollection_AsciiString RWObj_ConfigurationNode::Save() const
|
||||
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 += "!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";
|
||||
@ -162,13 +169,15 @@ TCollection_AsciiString RWObj_ConfigurationNode::Save() const
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Export special comment\n";
|
||||
aResult += "!Default value: ""(empty). Available values: <string>\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 += "!Default value: "
|
||||
"(empty). Available values: <string>\n";
|
||||
aResult += aScope + "write.author :\t " + InternalParameters.WriteAuthor + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
@ -176,65 +185,51 @@ TCollection_AsciiString RWObj_ConfigurationNode::Save() const
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Copy
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_ConfigurationNode) RWObj_ConfigurationNode::Copy() const
|
||||
//=================================================================================================
|
||||
|
||||
Handle(DE_ConfigurationNode) DEOBJ_ConfigurationNode::Copy() const
|
||||
{
|
||||
return new RWObj_ConfigurationNode(*this);
|
||||
return new DEOBJ_ConfigurationNode(*this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : BuildProvider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_Provider) RWObj_ConfigurationNode::BuildProvider()
|
||||
//=================================================================================================
|
||||
|
||||
Handle(DE_Provider) DEOBJ_ConfigurationNode::BuildProvider()
|
||||
{
|
||||
return new RWObj_Provider(this);
|
||||
return new DEOBJ_Provider(this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsImportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWObj_ConfigurationNode::IsImportSupported() const
|
||||
//=================================================================================================
|
||||
|
||||
bool DEOBJ_ConfigurationNode::IsImportSupported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsExportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWObj_ConfigurationNode::IsExportSupported() const
|
||||
//=================================================================================================
|
||||
|
||||
bool DEOBJ_ConfigurationNode::IsExportSupported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetFormat
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString RWObj_ConfigurationNode::GetFormat() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DEOBJ_ConfigurationNode::GetFormat() const
|
||||
{
|
||||
return TCollection_AsciiString("OBJ");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetVendor
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString RWObj_ConfigurationNode::GetVendor() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DEOBJ_ConfigurationNode::GetVendor() const
|
||||
{
|
||||
return TCollection_AsciiString("OCC");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetExtensions
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TColStd_ListOfAsciiString RWObj_ConfigurationNode::GetExtensions() const
|
||||
//=================================================================================================
|
||||
|
||||
TColStd_ListOfAsciiString DEOBJ_ConfigurationNode::GetExtensions() const
|
||||
{
|
||||
TColStd_ListOfAsciiString anExt;
|
||||
anExt.Append("obj");
|
102
src/DEOBJ/DEOBJ_ConfigurationNode.hxx
Normal file
102
src/DEOBJ/DEOBJ_ConfigurationNode.hxx
Normal file
@ -0,0 +1,102 @@
|
||||
// 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
|
@ -11,38 +11,32 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <RWObj_Provider.hxx>
|
||||
#include <DEOBJ_Provider.hxx>
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <RWObj_ConfigurationNode.hxx>
|
||||
#include <DEOBJ_ConfigurationNode.hxx>
|
||||
#include <RWObj_CafReader.hxx>
|
||||
#include <RWObj_CafWriter.hxx>
|
||||
#include <TDocStd_Document.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(RWObj_Provider, DE_Provider)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DEOBJ_Provider, DE_Provider)
|
||||
|
||||
//=======================================================================
|
||||
// function : RWObj_Provider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
RWObj_Provider::RWObj_Provider()
|
||||
{}
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
// function : RWObj_Provider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
RWObj_Provider::RWObj_Provider(const Handle(DE_ConfigurationNode)& theNode)
|
||||
DEOBJ_Provider::DEOBJ_Provider() {}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
DEOBJ_Provider::DEOBJ_Provider(const Handle(DE_ConfigurationNode)& theNode)
|
||||
: DE_Provider(theNode)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
//=================================================================================================
|
||||
|
||||
bool DEOBJ_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
@ -51,11 +45,9 @@ bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
return Read(thePath, theDocument, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
//=================================================================================================
|
||||
|
||||
bool DEOBJ_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
@ -64,27 +56,25 @@ bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
return Write(thePath, theDocument, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
//=================================================================================================
|
||||
|
||||
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 RWObj_Provider during reading the file " <<
|
||||
thePath << "\t: theDocument shouldn't be null";
|
||||
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(RWObj_ConfigurationNode)))
|
||||
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEOBJ_ConfigurationNode)))
|
||||
{
|
||||
Message::SendFail() << "Error in the RWObj_ConfigurationNode during reading the file " <<
|
||||
thePath << "\t: Incorrect or empty Configuration Node";
|
||||
Message::SendFail() << "Error in the DEOBJ_ConfigurationNode during reading the file "
|
||||
<< thePath << "\t: Incorrect or empty Configuration Node";
|
||||
return false;
|
||||
}
|
||||
Handle(RWObj_ConfigurationNode) aNode = Handle(RWObj_ConfigurationNode)::DownCast(GetNode());
|
||||
Handle(DEOBJ_ConfigurationNode) aNode = Handle(DEOBJ_ConfigurationNode)::DownCast(GetNode());
|
||||
RWObj_CafReader aReader;
|
||||
aReader.SetSinglePrecision(aNode->InternalParameters.ReadSinglePrecision);
|
||||
aReader.SetSystemLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
|
||||
@ -96,28 +86,29 @@ bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
aReader.SetMemoryLimitMiB(aNode->InternalParameters.ReadMemoryLimitMiB);
|
||||
if (!aReader.Perform(thePath, theProgress))
|
||||
{
|
||||
Message::SendFail() << "Error in the RWObj_ConfigurationNode during reading the file " << thePath;
|
||||
Message::SendFail() << "Error in the DEOBJ_ConfigurationNode during reading the file "
|
||||
<< thePath;
|
||||
return false;
|
||||
}
|
||||
XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
|
||||
XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
|
||||
aNode->GlobalParameters.LengthUnit,
|
||||
UnitsMethods_LengthUnit_Millimeter);
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
//=================================================================================================
|
||||
|
||||
bool DEOBJ_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWObj_ConfigurationNode)))
|
||||
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEOBJ_ConfigurationNode)))
|
||||
{
|
||||
Message::SendFail() << "Error in the RWObj_ConfigurationNode during writing the file " <<
|
||||
thePath << "\t: Incorrect or empty Configuration Node";
|
||||
Message::SendFail() << "Error in the DEOBJ_ConfigurationNode during writing the file "
|
||||
<< thePath << "\t: Incorrect or empty Configuration Node";
|
||||
return false;
|
||||
}
|
||||
Handle(RWObj_ConfigurationNode) aNode = Handle(RWObj_ConfigurationNode)::DownCast(GetNode());
|
||||
Handle(DEOBJ_ConfigurationNode) aNode = Handle(DEOBJ_ConfigurationNode)::DownCast(GetNode());
|
||||
|
||||
TColStd_IndexedDataMapOfStringString aFileInfo;
|
||||
if (!aNode->InternalParameters.WriteAuthor.IsEmpty())
|
||||
@ -131,15 +122,18 @@ bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
|
||||
RWMesh_CoordinateSystemConverter aConverter;
|
||||
Standard_Real aScaleFactorMM = 1.;
|
||||
if (XCAFDoc_DocumentTool::GetLengthUnit(theDocument, aScaleFactorMM, UnitsMethods_LengthUnit_Millimeter))
|
||||
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.";
|
||||
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.);
|
||||
@ -149,17 +143,16 @@ bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
aWriter.SetCoordinateSystemConverter(aConverter);
|
||||
if (!aWriter.Perform(theDocument, aFileInfo, theProgress))
|
||||
{
|
||||
Message::SendFail() << "Error in the RWObj_ConfigurationNode during writing the file " << thePath;
|
||||
Message::SendFail() << "Error in the DEOBJ_ConfigurationNode during writing the file "
|
||||
<< thePath;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
//=================================================================================================
|
||||
|
||||
bool DEOBJ_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
@ -168,11 +161,9 @@ bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
return Read(thePath, theShape, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
//=================================================================================================
|
||||
|
||||
bool DEOBJ_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
@ -181,21 +172,19 @@ bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
return Write(thePath, theShape, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
//=================================================================================================
|
||||
|
||||
bool DEOBJ_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWObj_ConfigurationNode)))
|
||||
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEOBJ_ConfigurationNode)))
|
||||
{
|
||||
Message::SendFail() << "Error in the RWObj_ConfigurationNode during writing the file " <<
|
||||
thePath << "\t: Incorrect or empty Configuration Node";
|
||||
Message::SendFail() << "Error in the DEOBJ_ConfigurationNode during writing the file "
|
||||
<< thePath << "\t: Incorrect or empty Configuration Node";
|
||||
return false;
|
||||
}
|
||||
Handle(RWObj_ConfigurationNode) aNode = Handle(RWObj_ConfigurationNode)::DownCast(GetNode());
|
||||
Handle(DEOBJ_ConfigurationNode) aNode = Handle(DEOBJ_ConfigurationNode)::DownCast(GetNode());
|
||||
RWMesh_CoordinateSystemConverter aConverter;
|
||||
aConverter.SetOutputLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
|
||||
aConverter.SetOutputCoordinateSystem(aNode->InternalParameters.SystemCS);
|
||||
@ -210,7 +199,8 @@ bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
aSimpleReader.SetMemoryLimit(aNode->InternalParameters.ReadMemoryLimitMiB);
|
||||
if (!aSimpleReader.Read(thePath, theProgress))
|
||||
{
|
||||
Message::SendFail() << "Error in the RWObj_ConfigurationNode during reading the file " << thePath;
|
||||
Message::SendFail() << "Error in the DEOBJ_ConfigurationNode during reading the file "
|
||||
<< thePath;
|
||||
return false;
|
||||
}
|
||||
Handle(Poly_Triangulation) aTriangulation = aSimpleReader.GetTriangulation();
|
||||
@ -222,11 +212,9 @@ bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
//=================================================================================================
|
||||
|
||||
bool DEOBJ_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
@ -236,20 +224,16 @@ bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
return Write(thePath, aDoc, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetFormat
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString RWObj_Provider::GetFormat() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DEOBJ_Provider::GetFormat() const
|
||||
{
|
||||
return TCollection_AsciiString("OBJ");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetVendor
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString RWObj_Provider::GetVendor() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DEOBJ_Provider::GetVendor() const
|
||||
{
|
||||
return TCollection_AsciiString("OCC");
|
||||
}
|
141
src/DEOBJ/DEOBJ_Provider.hxx
Normal file
141
src/DEOBJ/DEOBJ_Provider.hxx
Normal file
@ -0,0 +1,141 @@
|
||||
// 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
|
4
src/DEOBJ/FILES
Normal file
4
src/DEOBJ/FILES
Normal file
@ -0,0 +1,4 @@
|
||||
DEOBJ_ConfigurationNode.cxx
|
||||
DEOBJ_ConfigurationNode.hxx
|
||||
DEOBJ_Provider.cxx
|
||||
DEOBJ_Provider.hxx
|
@ -11,14 +11,14 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <RWPly_ConfigurationNode.hxx>
|
||||
#include <DEPLY_ConfigurationNode.hxx>
|
||||
|
||||
#include <DEPLY_Provider.hxx>
|
||||
#include <DE_ConfigurationContext.hxx>
|
||||
#include <DE_PluginHolder.hxx>
|
||||
#include <NCollection_Buffer.hxx>
|
||||
#include <RWPly_Provider.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(RWPly_ConfigurationNode, DE_ConfigurationNode)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DEPLY_ConfigurationNode, DE_ConfigurationNode)
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -29,40 +29,42 @@ namespace
|
||||
}
|
||||
|
||||
// Wrapper to auto-load DE component
|
||||
DE_PluginHolder<RWPly_ConfigurationNode> THE_OCCT_PLY_COMPONENT_PLUGIN;
|
||||
DE_PluginHolder<DEPLY_ConfigurationNode> THE_OCCT_PLY_COMPONENT_PLUGIN;
|
||||
} // namespace
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
DEPLY_ConfigurationNode::DEPLY_ConfigurationNode()
|
||||
: DE_ConfigurationNode()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : RWPly_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
RWPly_ConfigurationNode::RWPly_ConfigurationNode() :
|
||||
DE_ConfigurationNode()
|
||||
{}
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
// function : RWPly_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
RWPly_ConfigurationNode::RWPly_ConfigurationNode(const Handle(RWPly_ConfigurationNode)& theNode)
|
||||
DEPLY_ConfigurationNode::DEPLY_ConfigurationNode(const Handle(DEPLY_ConfigurationNode)& theNode)
|
||||
: DE_ConfigurationNode(theNode)
|
||||
{
|
||||
InternalParameters = theNode->InternalParameters;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Load
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWPly_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
|
||||
//=================================================================================================
|
||||
|
||||
bool DEPLY_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
|
||||
{
|
||||
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
|
||||
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);
|
||||
(RWMesh_CoordinateSystem)(theResource->IntegerVal("system.cs",
|
||||
(int)InternalParameters.SystemCS,
|
||||
aScope)
|
||||
% 2);
|
||||
InternalParameters.FileCS =
|
||||
(RWMesh_CoordinateSystem)(theResource->IntegerVal("file.cs", (int)InternalParameters.SystemCS, aScope) % 2);
|
||||
(RWMesh_CoordinateSystem)(theResource->IntegerVal("file.cs",
|
||||
(int)InternalParameters.SystemCS,
|
||||
aScope)
|
||||
% 2);
|
||||
|
||||
InternalParameters.WriteNormals =
|
||||
theResource->BooleanVal("write.normals", InternalParameters.WriteNormals, aScope);
|
||||
@ -81,23 +83,24 @@ bool RWPly_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theRes
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Save
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString RWPly_ConfigurationNode::Save() const
|
||||
//=================================================================================================
|
||||
|
||||
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 =
|
||||
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 += "!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";
|
||||
@ -150,13 +153,15 @@ TCollection_AsciiString RWPly_ConfigurationNode::Save() const
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Export special comment\n";
|
||||
aResult += "!Default value: ""(empty). Available values: <string>\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 += "!Default value: "
|
||||
"(empty). Available values: <string>\n";
|
||||
aResult += aScope + "write.author :\t " + InternalParameters.WriteAuthor + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
@ -164,76 +169,60 @@ TCollection_AsciiString RWPly_ConfigurationNode::Save() const
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Copy
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_ConfigurationNode) RWPly_ConfigurationNode::Copy() const
|
||||
//=================================================================================================
|
||||
|
||||
Handle(DE_ConfigurationNode) DEPLY_ConfigurationNode::Copy() const
|
||||
{
|
||||
return new RWPly_ConfigurationNode(*this);
|
||||
return new DEPLY_ConfigurationNode(*this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : BuildProvider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_Provider) RWPly_ConfigurationNode::BuildProvider()
|
||||
//=================================================================================================
|
||||
|
||||
Handle(DE_Provider) DEPLY_ConfigurationNode::BuildProvider()
|
||||
{
|
||||
return new RWPly_Provider(this);
|
||||
return new DEPLY_Provider(this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsImportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWPly_ConfigurationNode::IsImportSupported() const
|
||||
//=================================================================================================
|
||||
|
||||
bool DEPLY_ConfigurationNode::IsImportSupported() const
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsExportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWPly_ConfigurationNode::IsExportSupported() const
|
||||
//=================================================================================================
|
||||
|
||||
bool DEPLY_ConfigurationNode::IsExportSupported() const
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetFormat
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString RWPly_ConfigurationNode::GetFormat() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DEPLY_ConfigurationNode::GetFormat() const
|
||||
{
|
||||
return TCollection_AsciiString("PLY");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetVendor
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString RWPly_ConfigurationNode::GetVendor() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DEPLY_ConfigurationNode::GetVendor() const
|
||||
{
|
||||
return TCollection_AsciiString("OCC");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetExtensions
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TColStd_ListOfAsciiString RWPly_ConfigurationNode::GetExtensions() const
|
||||
//=================================================================================================
|
||||
|
||||
TColStd_ListOfAsciiString DEPLY_ConfigurationNode::GetExtensions() const
|
||||
{
|
||||
TColStd_ListOfAsciiString anExt;
|
||||
anExt.Append("ply");
|
||||
return anExt;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : CheckContent
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWPly_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
|
||||
//=================================================================================================
|
||||
|
||||
bool DEPLY_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
|
||||
{
|
||||
if (theBuffer.IsNull() || theBuffer->Size() < 4)
|
||||
{
|
109
src/DEPLY/DEPLY_ConfigurationNode.hxx
Normal file
109
src/DEPLY/DEPLY_ConfigurationNode.hxx
Normal file
@ -0,0 +1,109 @@
|
||||
// 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
|
@ -11,42 +11,36 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <RWPly_Provider.hxx>
|
||||
#include <DEPLY_Provider.hxx>
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <DEPLY_ConfigurationNode.hxx>
|
||||
#include <DE_Wrapper.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <RWPly_ConfigurationNode.hxx>
|
||||
#include <RWPly_CafWriter.hxx>
|
||||
#include <RWMesh_FaceIterator.hxx>
|
||||
#include <RWPly_CafWriter.hxx>
|
||||
#include <RWPly_PlyWriterContext.hxx>
|
||||
#include <TDocStd_Document.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
#include <XCAFPrs_DocumentExplorer.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(RWPly_Provider, DE_Provider)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DEPLY_Provider, DE_Provider)
|
||||
|
||||
//=======================================================================
|
||||
// function : RWPly_Provider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
RWPly_Provider::RWPly_Provider()
|
||||
{}
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
// function : RWPly_Provider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
RWPly_Provider::RWPly_Provider(const Handle(DE_ConfigurationNode)& theNode)
|
||||
DEPLY_Provider::DEPLY_Provider() {}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
DEPLY_Provider::DEPLY_Provider(const Handle(DE_ConfigurationNode)& theNode)
|
||||
: DE_Provider(theNode)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWPly_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
//=================================================================================================
|
||||
|
||||
bool DEPLY_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
@ -55,21 +49,19 @@ bool RWPly_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
return Write(thePath, theDocument, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWPly_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
//=================================================================================================
|
||||
|
||||
bool DEPLY_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWPly_ConfigurationNode)))
|
||||
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEPLY_ConfigurationNode)))
|
||||
{
|
||||
Message::SendFail() << "Error in the RWPly_Provider during writing the file " <<
|
||||
thePath << "\t: Incorrect or empty Configuration Node";
|
||||
Message::SendFail() << "Error in the DEPLY_Provider during writing the file " << thePath
|
||||
<< "\t: Incorrect or empty Configuration Node";
|
||||
return false;
|
||||
}
|
||||
Handle(RWPly_ConfigurationNode) aNode = Handle(RWPly_ConfigurationNode)::DownCast(GetNode());
|
||||
Handle(DEPLY_ConfigurationNode) aNode = Handle(DEPLY_ConfigurationNode)::DownCast(GetNode());
|
||||
|
||||
TDF_LabelSequence aRootLabels;
|
||||
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
|
||||
@ -97,8 +89,9 @@ bool RWPly_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
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.";
|
||||
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.);
|
||||
@ -112,19 +105,17 @@ bool RWPly_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
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";
|
||||
Message::SendFail() << "Error in the DEPLY_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,
|
||||
//=================================================================================================
|
||||
|
||||
bool DEPLY_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
@ -133,11 +124,9 @@ bool RWPly_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
return Write(thePath, theShape, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWPly_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
//=================================================================================================
|
||||
|
||||
bool DEPLY_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
@ -147,20 +136,16 @@ bool RWPly_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
return Write(thePath, aDoc, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetFormat
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString RWPly_Provider::GetFormat() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DEPLY_Provider::GetFormat() const
|
||||
{
|
||||
return TCollection_AsciiString("PLY");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetVendor
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString RWPly_Provider::GetVendor() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DEPLY_Provider::GetVendor() const
|
||||
{
|
||||
return TCollection_AsciiString("OCC");
|
||||
}
|
97
src/DEPLY/DEPLY_Provider.hxx
Normal file
97
src/DEPLY/DEPLY_Provider.hxx
Normal file
@ -0,0 +1,97 @@
|
||||
// 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
|
4
src/DEPLY/FILES
Normal file
4
src/DEPLY/FILES
Normal file
@ -0,0 +1,4 @@
|
||||
DEPLY_ConfigurationNode.cxx
|
||||
DEPLY_ConfigurationNode.hxx
|
||||
DEPLY_Provider.cxx
|
||||
DEPLY_Provider.hxx
|
@ -11,14 +11,14 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <STEPCAFControl_ConfigurationNode.hxx>
|
||||
#include <DESTEP_ConfigurationNode.hxx>
|
||||
|
||||
#include <DESTEP_Provider.hxx>
|
||||
#include <DE_ConfigurationContext.hxx>
|
||||
#include <DE_PluginHolder.hxx>
|
||||
#include <NCollection_Buffer.hxx>
|
||||
#include <STEPCAFControl_Provider.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(STEPCAFControl_ConfigurationNode, DE_ConfigurationNode)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DESTEP_ConfigurationNode, DE_ConfigurationNode)
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -29,52 +29,63 @@ namespace
|
||||
}
|
||||
|
||||
// Wrapper to auto-load DE component
|
||||
DE_PluginHolder<STEPCAFControl_ConfigurationNode> THE_OCCT_STEP_COMPONENT_PLUGIN;
|
||||
DE_PluginHolder<DESTEP_ConfigurationNode> THE_OCCT_STEP_COMPONENT_PLUGIN;
|
||||
} // namespace
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
DESTEP_ConfigurationNode::DESTEP_ConfigurationNode()
|
||||
: DE_ConfigurationNode()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : STEPCAFControl_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
STEPCAFControl_ConfigurationNode::STEPCAFControl_ConfigurationNode() :
|
||||
DE_ConfigurationNode()
|
||||
{}
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
// function : STEPCAFControl_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
STEPCAFControl_ConfigurationNode::STEPCAFControl_ConfigurationNode(const Handle(STEPCAFControl_ConfigurationNode)& theNode)
|
||||
DESTEP_ConfigurationNode::DESTEP_ConfigurationNode(const Handle(DESTEP_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)
|
||||
//=================================================================================================
|
||||
|
||||
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.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);
|
||||
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.AngleUnit =
|
||||
(StepData_ConfParameters::AngleUnitMode)theResource->IntegerVal("angleunit.mode",
|
||||
InternalParameters.AngleUnit,
|
||||
aScope);
|
||||
|
||||
InternalParameters.ReadResourceName =
|
||||
theResource->StringVal("read.resource.name", InternalParameters.ReadResourceName, aScope);
|
||||
@ -82,24 +93,36 @@ bool STEPCAFControl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext
|
||||
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)
|
||||
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)
|
||||
InternalParameters.ReadTessellated =
|
||||
(StepData_ConfParameters::RWMode_Tessellated)
|
||||
theResource->IntegerVal("read.tessellated", InternalParameters.ReadTessellated, aScope);
|
||||
InternalParameters.ReadAssemblyLevel = (StepData_ConfParameters::ReadMode_AssemblyLevel)
|
||||
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);
|
||||
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);
|
||||
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 =
|
||||
@ -107,7 +130,9 @@ bool STEPCAFControl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext
|
||||
InternalParameters.ReadAllShapes =
|
||||
theResource->BooleanVal("read.all.shapes", InternalParameters.ReadAllShapes, aScope);
|
||||
InternalParameters.ReadRootTransformation =
|
||||
theResource->BooleanVal("read.root.transformation", InternalParameters.ReadRootTransformation, aScope);
|
||||
theResource->BooleanVal("read.root.transformation",
|
||||
InternalParameters.ReadRootTransformation,
|
||||
aScope);
|
||||
InternalParameters.ReadColor =
|
||||
theResource->BooleanVal("read.color", InternalParameters.ReadColor, aScope);
|
||||
InternalParameters.ReadName =
|
||||
@ -119,30 +144,43 @@ bool STEPCAFControl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext
|
||||
InternalParameters.ReadMetadata =
|
||||
theResource->BooleanVal("read.metadata", InternalParameters.ReadMetadata, aScope);
|
||||
|
||||
InternalParameters.WritePrecisionMode = (StepData_ConfParameters::WriteMode_PrecisionMode)
|
||||
theResource->IntegerVal("write.precision.mode", InternalParameters.WritePrecisionMode, 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)
|
||||
InternalParameters.WriteAssembly =
|
||||
(StepData_ConfParameters::WriteMode_Assembly)
|
||||
theResource->IntegerVal("write.assembly", InternalParameters.WriteAssembly, aScope);
|
||||
InternalParameters.WriteSchema = (StepData_ConfParameters::WriteMode_StepSchema)
|
||||
InternalParameters.WriteSchema =
|
||||
(StepData_ConfParameters::WriteMode_StepSchema)
|
||||
theResource->IntegerVal("write.schema", InternalParameters.WriteSchema, aScope);
|
||||
InternalParameters.WriteTessellated = (StepData_ConfParameters::RWMode_Tessellated)
|
||||
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);
|
||||
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)
|
||||
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);
|
||||
theResource->BooleanVal("write.stepcaf.subshapes.name",
|
||||
InternalParameters.WriteSubshapeNames,
|
||||
aScope);
|
||||
InternalParameters.WriteColor =
|
||||
theResource->BooleanVal("write.color", InternalParameters.WriteColor, aScope);
|
||||
InternalParameters.WriteName =
|
||||
@ -151,22 +189,24 @@ bool STEPCAFControl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext
|
||||
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);
|
||||
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 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 =
|
||||
aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
|
||||
TCollection_AsciiString aScope =
|
||||
THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Common parameters:\n";
|
||||
@ -176,7 +216,8 @@ TCollection_AsciiString STEPCAFControl_ConfigurationNode::Save() const
|
||||
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 +=
|
||||
aScope + "read.iges.bspline.continuity :\t " + InternalParameters.ReadBSplineContinuity + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
@ -194,12 +235,15 @@ TCollection_AsciiString STEPCAFControl_ConfigurationNode::Save() const
|
||||
|
||||
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 +=
|
||||
"!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 += "!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";
|
||||
@ -208,22 +252,28 @@ TCollection_AsciiString STEPCAFControl_ConfigurationNode::Save() const
|
||||
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 +=
|
||||
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 +=
|
||||
"!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 +=
|
||||
"!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 +=
|
||||
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 += "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";
|
||||
@ -252,23 +302,29 @@ TCollection_AsciiString STEPCAFControl_ConfigurationNode::Save() const
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Defines the approach used for selection of top-level STEP entities for translation, ";
|
||||
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 +=
|
||||
"!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 +=
|
||||
"!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 += "!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";
|
||||
@ -287,40 +343,52 @@ TCollection_AsciiString STEPCAFControl_ConfigurationNode::Save() const
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Defines whether shapes associated with the main SHAPE_DEFINITION_REPRESENTATION entity";
|
||||
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 +=
|
||||
"!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 += "!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 += "\"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 += 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 += "!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 +=
|
||||
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 +=
|
||||
"!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";
|
||||
|
||||
@ -343,9 +411,11 @@ TCollection_AsciiString STEPCAFControl_ConfigurationNode::Save() const
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Mode to variate apply or not transformation placed in the root shape representation.\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 +=
|
||||
aScope + "read.root.transformation :\t " + InternalParameters.ReadRootTransformation + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
@ -367,13 +437,15 @@ TCollection_AsciiString STEPCAFControl_ConfigurationNode::Save() const
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Setting up the read.props parameter which is used to indicate read Validation properties or not\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 +=
|
||||
"!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";
|
||||
@ -403,7 +475,8 @@ TCollection_AsciiString STEPCAFControl_ConfigurationNode::Save() const
|
||||
|
||||
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 +=
|
||||
"!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";
|
||||
@ -415,20 +488,25 @@ TCollection_AsciiString STEPCAFControl_ConfigurationNode::Save() const
|
||||
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 += "!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 +=
|
||||
"!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 +=
|
||||
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 += "!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";
|
||||
@ -447,14 +525,17 @@ TCollection_AsciiString STEPCAFControl_ConfigurationNode::Save() const
|
||||
|
||||
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 += "!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 += "!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 +=
|
||||
aScope + "write.stepcaf.subshapes.name :\t " + InternalParameters.WriteSubshapeNames + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
@ -470,19 +551,22 @@ TCollection_AsciiString STEPCAFControl_ConfigurationNode::Save() const
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Setting up the write.layer parameter which is used to indicate write Layers or not\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 += "!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 += "!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";
|
||||
@ -493,65 +577,51 @@ TCollection_AsciiString STEPCAFControl_ConfigurationNode::Save() const
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Copy
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_ConfigurationNode) STEPCAFControl_ConfigurationNode::Copy() const
|
||||
//=================================================================================================
|
||||
|
||||
Handle(DE_ConfigurationNode) DESTEP_ConfigurationNode::Copy() const
|
||||
{
|
||||
return new STEPCAFControl_ConfigurationNode(*this);
|
||||
return new DESTEP_ConfigurationNode(*this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : BuildProvider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_Provider) STEPCAFControl_ConfigurationNode::BuildProvider()
|
||||
//=================================================================================================
|
||||
|
||||
Handle(DE_Provider) DESTEP_ConfigurationNode::BuildProvider()
|
||||
{
|
||||
return new STEPCAFControl_Provider(this);
|
||||
return new DESTEP_Provider(this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsImportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool STEPCAFControl_ConfigurationNode::IsImportSupported() const
|
||||
//=================================================================================================
|
||||
|
||||
bool DESTEP_ConfigurationNode::IsImportSupported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsExportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool STEPCAFControl_ConfigurationNode::IsExportSupported() const
|
||||
//=================================================================================================
|
||||
|
||||
bool DESTEP_ConfigurationNode::IsExportSupported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetFormat
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString STEPCAFControl_ConfigurationNode::GetFormat() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DESTEP_ConfigurationNode::GetFormat() const
|
||||
{
|
||||
return TCollection_AsciiString("STEP");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetVendor
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString STEPCAFControl_ConfigurationNode::GetVendor() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DESTEP_ConfigurationNode::GetVendor() const
|
||||
{
|
||||
return TCollection_AsciiString("OCC");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetExtensions
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TColStd_ListOfAsciiString STEPCAFControl_ConfigurationNode::GetExtensions() const
|
||||
//=================================================================================================
|
||||
|
||||
TColStd_ListOfAsciiString DESTEP_ConfigurationNode::GetExtensions() const
|
||||
{
|
||||
TColStd_ListOfAsciiString anExt;
|
||||
anExt.Append("stp");
|
||||
@ -560,11 +630,9 @@ TColStd_ListOfAsciiString STEPCAFControl_ConfigurationNode::GetExtensions() cons
|
||||
return anExt;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : CheckContent
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool STEPCAFControl_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
|
||||
//=================================================================================================
|
||||
|
||||
bool DESTEP_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
|
||||
{
|
||||
if (theBuffer.IsNull() || theBuffer->Size() < 100)
|
||||
{
|
93
src/DESTEP/DESTEP_ConfigurationNode.hxx
Normal file
93
src/DESTEP/DESTEP_ConfigurationNode.hxx
Normal file
@ -0,0 +1,93 @@
|
||||
// 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
|
332
src/DESTEP/DESTEP_Provider.cxx
Normal file
332
src/DESTEP/DESTEP_Provider.cxx
Normal file
@ -0,0 +1,332 @@
|
||||
// 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");
|
||||
}
|
||||
}
|
148
src/DESTEP/DESTEP_Provider.hxx
Normal file
148
src/DESTEP/DESTEP_Provider.hxx
Normal file
@ -0,0 +1,148 @@
|
||||
// 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
|
4
src/DESTEP/FILES
Normal file
4
src/DESTEP/FILES
Normal file
@ -0,0 +1,4 @@
|
||||
DESTEP_ConfigurationNode.cxx
|
||||
DESTEP_ConfigurationNode.hxx
|
||||
DESTEP_Provider.cxx
|
||||
DESTEP_Provider.hxx
|
@ -11,14 +11,14 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <RWStl_ConfigurationNode.hxx>
|
||||
#include <DESTL_ConfigurationNode.hxx>
|
||||
|
||||
#include <DESTL_Provider.hxx>
|
||||
#include <DE_ConfigurationContext.hxx>
|
||||
#include <DE_PluginHolder.hxx>
|
||||
#include <NCollection_Buffer.hxx>
|
||||
#include <RWStl_Provider.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(RWStl_ConfigurationNode, DE_ConfigurationNode)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DESTL_ConfigurationNode, DE_ConfigurationNode)
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -29,34 +29,30 @@ namespace
|
||||
}
|
||||
|
||||
// Wrapper to auto-load DE component
|
||||
DE_PluginHolder<RWStl_ConfigurationNode> THE_OCCT_STL_COMPONENT_PLUGIN;
|
||||
DE_PluginHolder<DESTL_ConfigurationNode> THE_OCCT_STL_COMPONENT_PLUGIN;
|
||||
} // namespace
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
DESTL_ConfigurationNode::DESTL_ConfigurationNode()
|
||||
: DE_ConfigurationNode()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : STEPCAFControl_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
RWStl_ConfigurationNode::RWStl_ConfigurationNode() :
|
||||
DE_ConfigurationNode()
|
||||
{}
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
// function : STEPCAFControl_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
RWStl_ConfigurationNode::RWStl_ConfigurationNode(const Handle(RWStl_ConfigurationNode)& theNode)
|
||||
DESTL_ConfigurationNode::DESTL_ConfigurationNode(const Handle(DESTL_ConfigurationNode)& theNode)
|
||||
: DE_ConfigurationNode(theNode)
|
||||
{
|
||||
InternalParameters = theNode->InternalParameters;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Load
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWStl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
|
||||
//=================================================================================================
|
||||
|
||||
bool DESTL_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
|
||||
{
|
||||
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
|
||||
TCollection_AsciiString aScope =
|
||||
THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
|
||||
|
||||
InternalParameters.ReadMergeAngle =
|
||||
theResource->RealVal("read.merge.angle", InternalParameters.ReadMergeAngle, aScope);
|
||||
@ -67,16 +63,16 @@ bool RWStl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theRes
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Save
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString RWStl_ConfigurationNode::Save() const
|
||||
//=================================================================================================
|
||||
|
||||
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 =
|
||||
aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
|
||||
TCollection_AsciiString aScope =
|
||||
THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Read parameters:\n";
|
||||
@ -108,76 +104,60 @@ TCollection_AsciiString RWStl_ConfigurationNode::Save() const
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Copy
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_ConfigurationNode) RWStl_ConfigurationNode::Copy() const
|
||||
//=================================================================================================
|
||||
|
||||
Handle(DE_ConfigurationNode) DESTL_ConfigurationNode::Copy() const
|
||||
{
|
||||
return new RWStl_ConfigurationNode(*this);
|
||||
return new DESTL_ConfigurationNode(*this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : BuildProvider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_Provider) RWStl_ConfigurationNode::BuildProvider()
|
||||
//=================================================================================================
|
||||
|
||||
Handle(DE_Provider) DESTL_ConfigurationNode::BuildProvider()
|
||||
{
|
||||
return new RWStl_Provider(this);
|
||||
return new DESTL_Provider(this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsImportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWStl_ConfigurationNode::IsImportSupported() const
|
||||
//=================================================================================================
|
||||
|
||||
bool DESTL_ConfigurationNode::IsImportSupported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsExportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWStl_ConfigurationNode::IsExportSupported() const
|
||||
//=================================================================================================
|
||||
|
||||
bool DESTL_ConfigurationNode::IsExportSupported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetFormat
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString RWStl_ConfigurationNode::GetFormat() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DESTL_ConfigurationNode::GetFormat() const
|
||||
{
|
||||
return TCollection_AsciiString("STL");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetVendor
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString RWStl_ConfigurationNode::GetVendor() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DESTL_ConfigurationNode::GetVendor() const
|
||||
{
|
||||
return TCollection_AsciiString("OCC");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetExtensions
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TColStd_ListOfAsciiString RWStl_ConfigurationNode::GetExtensions() const
|
||||
//=================================================================================================
|
||||
|
||||
TColStd_ListOfAsciiString DESTL_ConfigurationNode::GetExtensions() const
|
||||
{
|
||||
TColStd_ListOfAsciiString anExt;
|
||||
anExt.Append("stl");
|
||||
return anExt;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : CheckContent
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool RWStl_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
|
||||
//=================================================================================================
|
||||
|
||||
bool DESTL_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
|
||||
{
|
||||
if (theBuffer.IsNull() || theBuffer->Size() < 7)
|
||||
{
|
98
src/DESTL/DESTL_ConfigurationNode.hxx
Normal file
98
src/DESTL/DESTL_ConfigurationNode.hxx
Normal file
@ -0,0 +1,98 @@
|
||||
// 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
|
242
src/DESTL/DESTL_Provider.cxx
Normal file
242
src/DESTL/DESTL_Provider.cxx
Normal file
@ -0,0 +1,242 @@
|
||||
// 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");
|
||||
}
|
136
src/DESTL/DESTL_Provider.hxx
Normal file
136
src/DESTL/DESTL_Provider.hxx
Normal file
@ -0,0 +1,136 @@
|
||||
// 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
|
4
src/DESTL/FILES
Normal file
4
src/DESTL/FILES
Normal file
@ -0,0 +1,4 @@
|
||||
DESTL_ConfigurationNode.cxx
|
||||
DESTL_ConfigurationNode.hxx
|
||||
DESTL_Provider.cxx
|
||||
DESTL_Provider.hxx
|
195
src/DEVRML/DEVRML_ConfigurationNode.cxx
Normal file
195
src/DEVRML/DEVRML_ConfigurationNode.cxx
Normal file
@ -0,0 +1,195 @@
|
||||
// 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;
|
||||
}
|
111
src/DEVRML/DEVRML_ConfigurationNode.hxx
Normal file
111
src/DEVRML/DEVRML_ConfigurationNode.hxx
Normal file
@ -0,0 +1,111 @@
|
||||
// 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
|
323
src/DEVRML/DEVRML_Provider.cxx
Normal file
323
src/DEVRML/DEVRML_Provider.cxx
Normal file
@ -0,0 +1,323 @@
|
||||
// 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");
|
||||
}
|
141
src/DEVRML/DEVRML_Provider.hxx
Normal file
141
src/DEVRML/DEVRML_Provider.hxx
Normal file
@ -0,0 +1,141 @@
|
||||
// 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
|
4
src/DEVRML/FILES
Normal file
4
src/DEVRML/FILES
Normal file
@ -0,0 +1,4 @@
|
||||
DEVRML_ConfigurationNode.cxx
|
||||
DEVRML_ConfigurationNode.hxx
|
||||
DEVRML_Provider.cxx
|
||||
DEVRML_Provider.hxx
|
@ -11,14 +11,14 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <DEXCAFCascade_ConfigurationNode.hxx>
|
||||
#include <DEXCAF_ConfigurationNode.hxx>
|
||||
|
||||
#include <DEXCAF_Provider.hxx>
|
||||
#include <DE_ConfigurationContext.hxx>
|
||||
#include <DE_PluginHolder.hxx>
|
||||
#include <DEXCAFCascade_Provider.hxx>
|
||||
#include <NCollection_Buffer.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DEXCAFCascade_ConfigurationNode, DE_ConfigurationNode)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DEXCAF_ConfigurationNode, DE_ConfigurationNode)
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -29,53 +29,51 @@ namespace
|
||||
}
|
||||
|
||||
// Wrapper to auto-load DE component
|
||||
DE_PluginHolder<DEXCAFCascade_ConfigurationNode> THE_OCCT_XCAF_COMPONENT_PLUGIN;
|
||||
DE_PluginHolder<DEXCAF_ConfigurationNode> THE_OCCT_XCAF_COMPONENT_PLUGIN;
|
||||
} // namespace
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
DEXCAF_ConfigurationNode::DEXCAF_ConfigurationNode()
|
||||
: DE_ConfigurationNode()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : DEXCAFCascade_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
DEXCAFCascade_ConfigurationNode::DEXCAFCascade_ConfigurationNode() :
|
||||
DE_ConfigurationNode()
|
||||
{}
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
// function : DEXCAFCascade_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
DEXCAFCascade_ConfigurationNode::DEXCAFCascade_ConfigurationNode(const Handle(DEXCAFCascade_ConfigurationNode)& theNode)
|
||||
DEXCAF_ConfigurationNode::DEXCAF_ConfigurationNode(const Handle(DEXCAF_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);
|
||||
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;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Save
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString DEXCAFCascade_ConfigurationNode::Save() const
|
||||
//=================================================================================================
|
||||
|
||||
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 =
|
||||
aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
|
||||
TCollection_AsciiString aScope =
|
||||
THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Read parameters:\n";
|
||||
@ -93,7 +91,8 @@ TCollection_AsciiString DEXCAFCascade_ConfigurationNode::Save() const
|
||||
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())
|
||||
for (TColStd_ListOfAsciiString::Iterator anIt(InternalParameters.ReadSkipValues); anIt.More();
|
||||
anIt.Next())
|
||||
{
|
||||
aResult += anIt.Value() + " ";
|
||||
}
|
||||
@ -101,10 +100,12 @@ TCollection_AsciiString DEXCAFCascade_ConfigurationNode::Save() const
|
||||
|
||||
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 += "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())
|
||||
for (TColStd_ListOfAsciiString::Iterator anIt(InternalParameters.ReadValues); anIt.More();
|
||||
anIt.Next())
|
||||
{
|
||||
aResult += anIt.Value() + " ";
|
||||
}
|
||||
@ -114,76 +115,60 @@ TCollection_AsciiString DEXCAFCascade_ConfigurationNode::Save() const
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Copy
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_ConfigurationNode) DEXCAFCascade_ConfigurationNode::Copy() const
|
||||
//=================================================================================================
|
||||
|
||||
Handle(DE_ConfigurationNode) DEXCAF_ConfigurationNode::Copy() const
|
||||
{
|
||||
return new DEXCAFCascade_ConfigurationNode(*this);
|
||||
return new DEXCAF_ConfigurationNode(*this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : BuildProvider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_Provider) DEXCAFCascade_ConfigurationNode::BuildProvider()
|
||||
//=================================================================================================
|
||||
|
||||
Handle(DE_Provider) DEXCAF_ConfigurationNode::BuildProvider()
|
||||
{
|
||||
return new DEXCAFCascade_Provider (this);
|
||||
return new DEXCAF_Provider(this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsImportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEXCAFCascade_ConfigurationNode::IsImportSupported() const
|
||||
//=================================================================================================
|
||||
|
||||
bool DEXCAF_ConfigurationNode::IsImportSupported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsExportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEXCAFCascade_ConfigurationNode::IsExportSupported() const
|
||||
//=================================================================================================
|
||||
|
||||
bool DEXCAF_ConfigurationNode::IsExportSupported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetFormat
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString DEXCAFCascade_ConfigurationNode::GetFormat() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DEXCAF_ConfigurationNode::GetFormat() const
|
||||
{
|
||||
return TCollection_AsciiString("XCAF");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetVendor
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString DEXCAFCascade_ConfigurationNode::GetVendor() const
|
||||
//=================================================================================================
|
||||
|
||||
TCollection_AsciiString DEXCAF_ConfigurationNode::GetVendor() const
|
||||
{
|
||||
return TCollection_AsciiString("OCC");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetExtensions
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TColStd_ListOfAsciiString DEXCAFCascade_ConfigurationNode::GetExtensions() const
|
||||
//=================================================================================================
|
||||
|
||||
TColStd_ListOfAsciiString DEXCAF_ConfigurationNode::GetExtensions() const
|
||||
{
|
||||
TColStd_ListOfAsciiString anExt;
|
||||
anExt.Append("xbf");
|
||||
return anExt;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : CheckContent
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEXCAFCascade_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
|
||||
//=================================================================================================
|
||||
|
||||
bool DEXCAF_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
|
||||
{
|
||||
if (theBuffer.IsNull() || theBuffer->Size() < 8)
|
||||
{
|
100
src/DEXCAF/DEXCAF_ConfigurationNode.hxx
Normal file
100
src/DEXCAF/DEXCAF_ConfigurationNode.hxx
Normal file
@ -0,0 +1,100 @@
|
||||
// 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
|
297
src/DEXCAF/DEXCAF_Provider.cxx
Normal file
297
src/DEXCAF/DEXCAF_Provider.cxx
Normal file
@ -0,0 +1,297 @@
|
||||
// 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");
|
||||
}
|
141
src/DEXCAF/DEXCAF_Provider.hxx
Normal file
141
src/DEXCAF/DEXCAF_Provider.hxx
Normal file
@ -0,0 +1,141 @@
|
||||
// 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
|
4
src/DEXCAF/FILES
Normal file
4
src/DEXCAF/FILES
Normal file
@ -0,0 +1,4 @@
|
||||
DEXCAF_ConfigurationNode.cxx
|
||||
DEXCAF_ConfigurationNode.hxx
|
||||
DEXCAF_Provider.cxx
|
||||
DEXCAF_Provider.hxx
|
@ -14,88 +14,9 @@
|
||||
#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
|
||||
|
@ -1,316 +0,0 @@
|
||||
// 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");
|
||||
}
|
@ -14,123 +14,9 @@
|
||||
#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
|
||||
|
@ -1,4 +1,2 @@
|
||||
DEXCAFCascade_ConfigurationNode.cxx
|
||||
DEXCAFCascade_ConfigurationNode.hxx
|
||||
DEXCAFCascade_Provider.cxx
|
||||
DEXCAFCascade_Provider.hxx
|
||||
|
@ -1,8 +1,6 @@
|
||||
IGESCAFControl.cxx
|
||||
IGESCAFControl.hxx
|
||||
IGESCAFControl_ConfigurationNode.cxx
|
||||
IGESCAFControl_ConfigurationNode.hxx
|
||||
IGESCAFControl_Provider.cxx
|
||||
IGESCAFControl_Provider.hxx
|
||||
IGESCAFControl_Reader.cxx
|
||||
IGESCAFControl_Reader.hxx
|
||||
|
@ -14,166 +14,9 @@
|
||||
#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
|
||||
|
@ -1,428 +0,0 @@
|
||||
// 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");
|
||||
}
|
@ -14,144 +14,9 @@
|
||||
#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
|
||||
|
@ -2,7 +2,6 @@ RWGltf_CafReader.cxx
|
||||
RWGltf_CafReader.hxx
|
||||
RWGltf_CafWriter.cxx
|
||||
RWGltf_CafWriter.hxx
|
||||
RWGltf_ConfigurationNode.cxx
|
||||
RWGltf_ConfigurationNode.hxx
|
||||
RWGltf_DracoParameters.hxx
|
||||
RWGltf_GltfAccessor.hxx
|
||||
@ -26,7 +25,6 @@ RWGltf_GltfRootElement.hxx
|
||||
RWGltf_GltfSceneNodeMap.hxx
|
||||
RWGltf_MaterialCommon.hxx
|
||||
RWGltf_MaterialMetallicRoughness.hxx
|
||||
RWGltf_Provider.cxx
|
||||
RWGltf_Provider.hxx
|
||||
RWGltf_TriangulationReader.cxx
|
||||
RWGltf_TriangulationReader.hxx
|
||||
|
@ -14,106 +14,9 @@
|
||||
#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
|
||||
|
@ -1,269 +0,0 @@
|
||||
// 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");
|
||||
}
|
@ -14,126 +14,9 @@
|
||||
#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
|
||||
|
@ -4,7 +4,6 @@ RWObj_CafReader.cxx
|
||||
RWObj_CafReader.hxx
|
||||
RWObj_CafWriter.cxx
|
||||
RWObj_CafWriter.hxx
|
||||
RWObj_ConfigurationNode.cxx
|
||||
RWObj_ConfigurationNode.hxx
|
||||
RWObj_Material.hxx
|
||||
RWObj_MtlReader.cxx
|
||||
@ -13,7 +12,6 @@ RWObj_ObjMaterialMap.cxx
|
||||
RWObj_ObjMaterialMap.hxx
|
||||
RWObj_ObjWriterContext.cxx
|
||||
RWObj_ObjWriterContext.hxx
|
||||
RWObj_Provider.cxx
|
||||
RWObj_Provider.hxx
|
||||
RWObj_Reader.cxx
|
||||
RWObj_Reader.hxx
|
||||
|
@ -14,90 +14,9 @@
|
||||
#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
|
||||
|
@ -14,123 +14,9 @@
|
||||
#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
|
||||
|
@ -1,8 +1,6 @@
|
||||
RWPly_CafWriter.cxx
|
||||
RWPly_CafWriter.hxx
|
||||
RWPly_ConfigurationNode.cxx
|
||||
RWPly_ConfigurationNode.hxx
|
||||
RWPly_PlyWriterContext.cxx
|
||||
RWPly_PlyWriterContext.hxx
|
||||
RWPly_Provider.cxx
|
||||
RWPly_Provider.hxx
|
||||
|
@ -14,96 +14,9 @@
|
||||
#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
|
||||
|
@ -14,83 +14,9 @@
|
||||
#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
|
||||
|
@ -2,7 +2,5 @@ RWStl.cxx
|
||||
RWStl.hxx
|
||||
RWStl_Reader.cxx
|
||||
RWStl_Reader.hxx
|
||||
RWStl_ConfigurationNode.cxx
|
||||
RWStl_ConfigurationNode.hxx
|
||||
RWStl_Provider.cxx
|
||||
RWStl_Provider.hxx
|
||||
|
@ -14,86 +14,9 @@
|
||||
#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
|
||||
|
@ -1,262 +0,0 @@
|
||||
// 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");
|
||||
}
|
@ -14,123 +14,9 @@
|
||||
#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
|
||||
|
@ -1,6 +1,5 @@
|
||||
STEPCAFControl_ActorWrite.cxx
|
||||
STEPCAFControl_ActorWrite.hxx
|
||||
STEPCAFControl_ConfigurationNode.cxx
|
||||
STEPCAFControl_ConfigurationNode.hxx
|
||||
STEPCAFControl_Controller.cxx
|
||||
STEPCAFControl_Controller.hxx
|
||||
@ -21,7 +20,6 @@ STEPCAFControl_ExternFile.hxx
|
||||
STEPCAFControl_ExternFile.lxx
|
||||
STEPCAFControl_GDTProperty.hxx
|
||||
STEPCAFControl_GDTProperty.cxx
|
||||
STEPCAFControl_Provider.cxx
|
||||
STEPCAFControl_Provider.hxx
|
||||
STEPCAFControl_Reader.cxx
|
||||
STEPCAFControl_Reader.hxx
|
||||
|
@ -14,82 +14,9 @@
|
||||
#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
|
||||
|
@ -1,342 +0,0 @@
|
||||
// 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");
|
||||
}
|
||||
}
|
@ -14,132 +14,9 @@
|
||||
#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
|
||||
|
@ -1,2 +1,4 @@
|
||||
DEBRepCascade
|
||||
DEXCAFCascade
|
||||
DEBREP
|
||||
DEXCAF
|
||||
|
@ -1 +1,2 @@
|
||||
RWGltf
|
||||
DEGLTF
|
@ -17,3 +17,4 @@ Geom2dToIGES
|
||||
BRepToIGES
|
||||
BRepToIGESBRep
|
||||
IGESControl
|
||||
DEIGES
|
||||
|
@ -1 +1,2 @@
|
||||
RWObj
|
||||
DEOBJ
|
||||
|
@ -1 +1,2 @@
|
||||
RWPly
|
||||
DEPLY
|
||||
|
@ -38,3 +38,4 @@ StepFile
|
||||
RWHeaderSection
|
||||
APIHeaderSection
|
||||
HeaderSection
|
||||
DESTEP
|
||||
|
@ -1,2 +1,3 @@
|
||||
StlAPI
|
||||
RWStl
|
||||
DESTL
|
||||
|
@ -2,3 +2,4 @@ VrmlConverter
|
||||
VrmlAPI
|
||||
Vrml
|
||||
VrmlData
|
||||
DEVRML
|
||||
|
@ -6,7 +6,6 @@ Vrml_AsciiTextJustification.hxx
|
||||
Vrml_Cone.cxx
|
||||
Vrml_Cone.hxx
|
||||
Vrml_ConeParts.hxx
|
||||
Vrml_ConfigurationNode.cxx
|
||||
Vrml_ConfigurationNode.hxx
|
||||
Vrml_Coordinate3.cxx
|
||||
Vrml_Coordinate3.hxx
|
||||
@ -53,7 +52,6 @@ Vrml_PointLight.cxx
|
||||
Vrml_PointLight.hxx
|
||||
Vrml_PointSet.cxx
|
||||
Vrml_PointSet.hxx
|
||||
Vrml_Provider.cxx
|
||||
Vrml_Provider.hxx
|
||||
Vrml_Rotation.cxx
|
||||
Vrml_Rotation.hxx
|
||||
|
@ -1,200 +0,0 @@
|
||||
// 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;
|
||||
}
|
@ -14,99 +14,9 @@
|
||||
#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
|
||||
|
@ -1,308 +0,0 @@
|
||||
// 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");
|
||||
}
|
@ -14,123 +14,9 @@
|
||||
#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
|
||||
|
@ -25,22 +25,22 @@
|
||||
#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>
|
||||
@ -79,7 +79,7 @@
|
||||
#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>
|
||||
|
@ -19,7 +19,7 @@
|
||||
#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>
|
||||
@ -423,7 +423,7 @@ void XSDRAWDE::Factory(Draw_Interpretor& theDI)
|
||||
XSDRAW::LoadDraw(theDI);
|
||||
|
||||
// Workaround to force load TKDECascade lib
|
||||
DEBRepCascade_ConfigurationNode aTmpObj;
|
||||
DEBREP_ConfigurationNode aTmpObj;
|
||||
(void)aTmpObj;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user