Skip to content

Commit 427adb0

Browse files
committed
Coding - Separate DE Wrapper's plugins to own packages Open-Cascade-SAS#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.
1 parent f91655b commit 427adb0

File tree

91 files changed

+5781
-5391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+5781
-5391
lines changed

dox/user_guides/de_wrapper/de_wrapper.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ All registered providers are set to the map with information about its vendor an
200200
It is nesessary to register only one ConfigurationNode for all needed formats.
201201
~~~~{.cpp}
202202
Handle(DE_Wrapper) aSession = DE_Wrapper::GlobalWrapper();
203-
Handle(DE_ConfigurationNode) aNode = new STEPCAFControl_ConfigurationNode();
203+
Handle(DE_ConfigurationNode) aNode = new DESTEP_ConfigurationNode();
204204
aSession->Bind(aNode);
205205
~~~~
206206
@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.
216216

217217
~~~~{.cpp}
218218
// global variable
219-
static Handle(STEPCAFControl_ConfigurationNode) THE_STEP_NODE;
219+
static Handle(DESTEP_ConfigurationNode) THE_STEP_NODE;
220220
221221
static Handle(DE_ConfigurationNode) RegisterStepNode()
222222
{
@@ -226,7 +226,7 @@ static Handle(DE_ConfigurationNode) RegisterStepNode()
226226
return THE_STEP_NODE;
227227
}
228228
229-
THE_STEP_NODE = new STEPCAFControl_ConfigurationNode();
229+
THE_STEP_NODE = new DESTEP_ConfigurationNode();
230230
aSession->Bind(THE_STEP_NODE);
231231
return THE_STEP_NODE;
232232
}
@@ -351,7 +351,7 @@ It is possible to read and write CAD files directly from a special provider.
351351

352352
~~~~{.cpp}
353353
// Creating or getting node
354-
Handle(STEPCAFControl_ConfigurationNode) aNode = new STEPCAFControl_ConfigurationNode();
354+
Handle(DESTEP_ConfigurationNode) aNode = new DESTEP_ConfigurationNode();
355355
// Creating an one-time provider
356356
Handle(DE_Provider) aProvider = aNode->BuildProvider();
357357
// Setting configuration with all parameters

src/DEBRepCascade/DEBRepCascade_ConfigurationNode.cxx src/DEBREP/DEBREP_ConfigurationNode.cxx

+67-85
Original file line numberDiff line numberDiff line change
@@ -11,76 +11,76 @@
1111
// Alternatively, this file may be used under the terms of Open CASCADE
1212
// commercial license or contractual agreement.
1313

14-
#include <DEBRepCascade_ConfigurationNode.hxx>
14+
#include <DEBREP_ConfigurationNode.hxx>
1515

16+
#include <DEBREP_Provider.hxx>
1617
#include <DE_ConfigurationContext.hxx>
1718
#include <DE_PluginHolder.hxx>
18-
#include <DEBRepCascade_Provider.hxx>
1919
#include <NCollection_Buffer.hxx>
2020

21-
IMPLEMENT_STANDARD_RTTIEXT(DEBRepCascade_ConfigurationNode, DE_ConfigurationNode)
21+
IMPLEMENT_STANDARD_RTTIEXT(DEBREP_ConfigurationNode, DE_ConfigurationNode)
2222

2323
namespace
2424
{
25-
static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
26-
{
27-
static const TCollection_AsciiString aScope = "provider";
28-
return aScope;
29-
}
25+
static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
26+
{
27+
static const TCollection_AsciiString aScope = "provider";
28+
return aScope;
29+
}
30+
31+
// Wrapper to auto-load DE component
32+
DE_PluginHolder<DEBREP_ConfigurationNode> THE_OCCT_BREP_COMPONENT_PLUGIN;
33+
} // namespace
3034

31-
// Wrapper to auto-load DE component
32-
DE_PluginHolder<DEBRepCascade_ConfigurationNode> THE_OCCT_BREP_COMPONENT_PLUGIN;
35+
//=================================================================================================
36+
37+
DEBREP_ConfigurationNode::DEBREP_ConfigurationNode()
38+
: DE_ConfigurationNode()
39+
{
3340
}
3441

35-
//=======================================================================
36-
// function : DEBRepCascade_ConfigurationNode
37-
// purpose :
38-
//=======================================================================
39-
DEBRepCascade_ConfigurationNode::DEBRepCascade_ConfigurationNode() :
40-
DE_ConfigurationNode()
41-
{}
42-
43-
//=======================================================================
44-
// function : DEBRepCascade_ConfigurationNode
45-
// purpose :
46-
//=======================================================================
47-
DEBRepCascade_ConfigurationNode::DEBRepCascade_ConfigurationNode(const Handle(DEBRepCascade_ConfigurationNode)& theNode)
48-
:DE_ConfigurationNode(theNode)
42+
//=================================================================================================
43+
44+
DEBREP_ConfigurationNode::DEBREP_ConfigurationNode(const Handle(DEBREP_ConfigurationNode)& theNode)
45+
: DE_ConfigurationNode(theNode)
4946
{
5047
InternalParameters = theNode->InternalParameters;
5148
}
5249

53-
//=======================================================================
54-
// function : Load
55-
// purpose :
56-
//=======================================================================
57-
bool DEBRepCascade_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
50+
//=================================================================================================
51+
52+
bool DEBREP_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
5853
{
59-
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
54+
TCollection_AsciiString aScope =
55+
THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
6056

6157
InternalParameters.WriteBinary =
6258
theResource->BooleanVal("write.binary", InternalParameters.WriteBinary, aScope);
6359
InternalParameters.WriteVersionBin =
64-
(BinTools_FormatVersion)theResource->IntegerVal("write.version.binary", InternalParameters.WriteVersionBin, aScope);
60+
(BinTools_FormatVersion)theResource->IntegerVal("write.version.binary",
61+
InternalParameters.WriteVersionBin,
62+
aScope);
6563
InternalParameters.WriteVersionAscii =
66-
(TopTools_FormatVersion)theResource->IntegerVal("write.version.ascii", InternalParameters.WriteVersionAscii, aScope);
64+
(TopTools_FormatVersion)theResource->IntegerVal("write.version.ascii",
65+
InternalParameters.WriteVersionAscii,
66+
aScope);
6767
InternalParameters.WriteTriangles =
6868
theResource->BooleanVal("write.triangles", InternalParameters.WriteTriangles, aScope);
6969
InternalParameters.WriteNormals =
7070
theResource->BooleanVal("write.normals", InternalParameters.WriteNormals, aScope);
7171
return true;
7272
}
7373

74-
//=======================================================================
75-
// function : Save
76-
// purpose :
77-
//=======================================================================
78-
TCollection_AsciiString DEBRepCascade_ConfigurationNode::Save() const
74+
//=================================================================================================
75+
76+
TCollection_AsciiString DEBREP_ConfigurationNode::Save() const
7977
{
8078
TCollection_AsciiString aResult;
8179
aResult += "!*****************************************************************************\n";
82-
aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
83-
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
80+
aResult =
81+
aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
82+
TCollection_AsciiString aScope =
83+
THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
8484

8585
aResult += "!\n";
8686
aResult += "!Write parameters:\n";
@@ -120,88 +120,70 @@ TCollection_AsciiString DEBRepCascade_ConfigurationNode::Save() const
120120
return aResult;
121121
}
122122

123-
//=======================================================================
124-
// function : Copy
125-
// purpose :
126-
//=======================================================================
127-
Handle(DE_ConfigurationNode) DEBRepCascade_ConfigurationNode::Copy() const
123+
//=================================================================================================
124+
125+
Handle(DE_ConfigurationNode) DEBREP_ConfigurationNode::Copy() const
128126
{
129-
return new DEBRepCascade_ConfigurationNode(*this);
127+
return new DEBREP_ConfigurationNode(*this);
130128
}
131129

132-
//=======================================================================
133-
// function : BuildProvider
134-
// purpose :
135-
//=======================================================================
136-
Handle(DE_Provider) DEBRepCascade_ConfigurationNode::BuildProvider()
130+
//=================================================================================================
131+
132+
Handle(DE_Provider) DEBREP_ConfigurationNode::BuildProvider()
137133
{
138-
return new DEBRepCascade_Provider(this);
134+
return new DEBREP_Provider(this);
139135
}
140136

141-
//=======================================================================
142-
// function : IsImportSupported
143-
// purpose :
144-
//=======================================================================
145-
bool DEBRepCascade_ConfigurationNode::IsImportSupported() const
137+
//=================================================================================================
138+
139+
bool DEBREP_ConfigurationNode::IsImportSupported() const
146140
{
147141
return true;
148142
}
149143

150-
//=======================================================================
151-
// function : IsExportSupported
152-
// purpose :
153-
//=======================================================================
154-
bool DEBRepCascade_ConfigurationNode::IsExportSupported() const
144+
//=================================================================================================
145+
146+
bool DEBREP_ConfigurationNode::IsExportSupported() const
155147
{
156148
return true;
157149
}
158150

159-
//=======================================================================
160-
// function : GetFormat
161-
// purpose :
162-
//=======================================================================
163-
TCollection_AsciiString DEBRepCascade_ConfigurationNode::GetFormat() const
151+
//=================================================================================================
152+
153+
TCollection_AsciiString DEBREP_ConfigurationNode::GetFormat() const
164154
{
165155
return TCollection_AsciiString("BREP");
166156
}
167157

168-
//=======================================================================
169-
// function : GetVendor
170-
// purpose :
171-
//=======================================================================
172-
TCollection_AsciiString DEBRepCascade_ConfigurationNode::GetVendor() const
158+
//=================================================================================================
159+
160+
TCollection_AsciiString DEBREP_ConfigurationNode::GetVendor() const
173161
{
174162
return TCollection_AsciiString("OCC");
175163
}
176164

177-
//=======================================================================
178-
// function : GetExtensions
179-
// purpose :
180-
//=======================================================================
181-
TColStd_ListOfAsciiString DEBRepCascade_ConfigurationNode::GetExtensions() const
165+
//=================================================================================================
166+
167+
TColStd_ListOfAsciiString DEBREP_ConfigurationNode::GetExtensions() const
182168
{
183169
TColStd_ListOfAsciiString anExt;
184170
anExt.Append("brep");
185171
return anExt;
186172
}
187173

188-
//=======================================================================
189-
// function : CheckContent
190-
// purpose :
191-
//=======================================================================
192-
bool DEBRepCascade_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
174+
//=================================================================================================
175+
176+
bool DEBREP_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
193177
{
194178
if (theBuffer.IsNull() || theBuffer->Size() < 20)
195179
{
196180
return false;
197181
}
198182
const char* aBytes = (const char*)theBuffer->Data();
199-
if (::strstr(aBytes, "DBRep_DrawableShape") ||
200-
::strstr(aBytes, "CASCADE Topology V1") ||
201-
::strstr(aBytes, "CASCADE Topology V3"))
183+
if (::strstr(aBytes, "DBRep_DrawableShape") || ::strstr(aBytes, "CASCADE Topology V1")
184+
|| ::strstr(aBytes, "CASCADE Topology V3"))
202185
{
203186
return true;
204187
}
205188
return false;
206189
}
207-
+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// Copyright (c) 2022 OPEN CASCADE SAS
2+
//
3+
// This file is part of Open CASCADE Technology software library.
4+
//
5+
// This library is free software; you can redistribute it and/or modify it under
6+
// the terms of the GNU Lesser General Public License version 2.1 as published
7+
// by the Free Software Foundation, with special exception defined in the file
8+
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9+
// distribution for complete text of the license and disclaimer of any warranty.
10+
//
11+
// Alternatively, this file may be used under the terms of Open CASCADE
12+
// commercial license or contractual agreement.
13+
14+
#ifndef _DEBREP_ConfigurationNode_HeaderFile
15+
#define _DEBREP_ConfigurationNode_HeaderFile
16+
17+
#include <DE_ConfigurationNode.hxx>
18+
19+
#include <BinTools_FormatVersion.hxx>
20+
#include <TopTools_FormatVersion.hxx>
21+
22+
//! The purpose of this class is to configure the transfer process for BRep format
23+
//! Stores the necessary settings for DEBREP_Provider.
24+
//! Configures and creates special provider to transfer BRep files.
25+
//!
26+
//! Nodes grouped by Vendor name and Format type.
27+
//! The Vendor name is "OCC"
28+
//! The Format type is "BREP"
29+
//! The supported CAD extension is ".brep"
30+
//! The import process is supported.
31+
//! The export process is supported.
32+
class DEBREP_ConfigurationNode : public DE_ConfigurationNode
33+
{
34+
DEFINE_STANDARD_RTTIEXT(DEBREP_ConfigurationNode, DE_ConfigurationNode)
35+
public:
36+
//! Initializes all field by default
37+
Standard_EXPORT DEBREP_ConfigurationNode();
38+
39+
//! Copies values of all fields
40+
//! @param[in] theNode object to copy
41+
Standard_EXPORT DEBREP_ConfigurationNode(const Handle(DEBREP_ConfigurationNode)& theNode);
42+
43+
//! Updates values according the resource
44+
//! @param[in] theResource input resource to use
45+
//! @return true if theResource loading has ended correctly
46+
Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource)
47+
Standard_OVERRIDE;
48+
49+
//! Writes configuration to the string
50+
//! @return result resource string
51+
Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
52+
53+
//! Copies values of all fields
54+
//! @return new object with the same field values
55+
Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
56+
57+
//! Creates new provider for the own format
58+
//! @return new created provider
59+
Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
60+
61+
public:
62+
//! Checks the import supporting
63+
//! @return true if import is supported
64+
Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
65+
66+
//! Checks the export supporting
67+
//! @return true if export is supported
68+
Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
69+
70+
//! Gets CAD format name of associated provider
71+
//! @return provider CAD format
72+
Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
73+
74+
//! Gets provider's vendor name of associated provider
75+
//! @return provider's vendor name
76+
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
77+
78+
//! Gets list of supported file extensions
79+
//! @return list of extensions
80+
Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
81+
82+
//! Checks the file content to verify a format
83+
//! @param[in] theBuffer read stream buffer to check content
84+
//! @return Standard_True if file is supported by a current provider
85+
Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
86+
Standard_OVERRIDE;
87+
88+
public:
89+
struct DEBRep_InternalSection
90+
{
91+
// Write
92+
bool WriteBinary = true; //!< Defines the binary file format
93+
// clang-format off
94+
BinTools_FormatVersion WriteVersionBin = BinTools_FormatVersion_CURRENT; //!< Defines the writer version for the binary format
95+
TopTools_FormatVersion WriteVersionAscii = TopTools_FormatVersion_CURRENT; //!< Defines the writer version for the ASCII format
96+
// clang-format on
97+
bool WriteTriangles = true; //!< Defines the flag for storing shape with(without) triangles
98+
bool WriteNormals = true; //!< Defines the flag for storing shape with(without) normals
99+
100+
} InternalParameters;
101+
};
102+
103+
#endif // _DEBREP_ConfigurationNode_HeaderFile

0 commit comments

Comments
 (0)