1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

Data Exchange - Update Readers with ShapeHealing parameters #247

All instances of using XSAlgo_AlgoContainer are replaced with
XSAlgo_ShapeProcessor.

Parameters for XSAlgo_ShapeProcessor operations are now can be passes
via the updated interface of respective classes.

Staqtic function to read processing parameters from file is added to
XSAlgo_ShapeProcessor.
This commit is contained in:
dkulikov
2024-12-20 14:31:04 +00:00
committed by Pasukhin Dmitry
parent bb84ecf5c6
commit f5a02d2b0c
53 changed files with 1880 additions and 839 deletions

View File

@@ -20,14 +20,21 @@
#include <Transfer_ProcessForFinder.hxx>
#include <Transfer_SimpleBinderOfTransient.hxx>
#include <Transfer_TransientMapper.hxx>
#include <XSAlgo_ShapeProcessor.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Transfer_ActorOfFinderProcess,Transfer_ActorOfProcessForFinder)
//=============================================================================
Transfer_ActorOfFinderProcess::Transfer_ActorOfFinderProcess () { themodetrans = 0; }
//=============================================================================
Standard_Integer& Transfer_ActorOfFinderProcess::ModeTrans ()
{ return themodetrans; }
//=============================================================================
Handle(Transfer_Binder) Transfer_ActorOfFinderProcess::Transfer
(const Handle(Transfer_Finder)& fnd,
const Handle(Transfer_FinderProcess)& FP,
@@ -40,6 +47,8 @@ Handle(Transfer_Binder) Transfer_ActorOfFinderProcess::Transfer
return TransientResult (res);
}
//=============================================================================
Handle(Transfer_Binder) Transfer_ActorOfFinderProcess::Transferring
(const Handle(Transfer_Finder)& ent,
const Handle(Transfer_ProcessForFinder)& TP,
@@ -48,6 +57,8 @@ Handle(Transfer_Binder) Transfer_ActorOfFinderProcess::Transferring
return Transfer(ent,Handle(Transfer_FinderProcess)::DownCast(TP), theProgress);
}
//=============================================================================
Handle(Standard_Transient) Transfer_ActorOfFinderProcess::TransferTransient
(const Handle(Standard_Transient)& /*ent*/,
const Handle(Transfer_FinderProcess)&,
@@ -56,3 +67,41 @@ Handle(Standard_Transient) Transfer_ActorOfFinderProcess::TransferTransient
Handle(Standard_Transient) nulres;
return nulres;
}
//=============================================================================
void Transfer_ActorOfFinderProcess::SetParameters(const ParameterMap& theParameters)
{
myShapeProcParams = theParameters;
}
//=============================================================================
void Transfer_ActorOfFinderProcess::SetParameters(ParameterMap&& theParameters)
{
myShapeProcParams = std::move(theParameters);
}
//=============================================================================
void Transfer_ActorOfFinderProcess::SetParameters(const DE_ShapeFixParameters& theParameters,
const ParameterMap& theAdditionalParameters)
{
myShapeProcParams.clear();
XSAlgo_ShapeProcessor::FillParameterMap(theParameters, true, myShapeProcParams);
for (const auto& aParam : theAdditionalParameters)
{
if (myShapeProcParams.find(aParam.first) == myShapeProcParams.end())
{
myShapeProcParams[aParam.first] = aParam.second;
}
}
}
//=============================================================================
void Transfer_ActorOfFinderProcess::SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags)
{
myShapeProcFlags.first = theFlags;
myShapeProcFlags.second = true;
}

View File

@@ -18,8 +18,12 @@
#define _Transfer_ActorOfFinderProcess_HeaderFile
#include <Standard.hxx>
#include <ShapeProcess.hxx>
#include <Transfer_ActorOfProcessForFinder.hxx>
#include <unordered_map>
struct DE_ShapeFixParameters;
class Transfer_Binder;
class Transfer_Finder;
class Transfer_ProcessForFinder;
@@ -36,10 +40,14 @@ DEFINE_STANDARD_HANDLE(Transfer_ActorOfFinderProcess, Transfer_ActorOfProcessFor
//! a user. To be interpreted for each norm
class Transfer_ActorOfFinderProcess : public Transfer_ActorOfProcessForFinder
{
public:
using ParameterMap = std::unordered_map<std::string, std::string>;
// Flags defining operations to be performed on shapes. Since there is no std::optional in C++11,
// we use a pair. The first element is the flags, the second element is a boolean value that indicates
// whether the flags were set.
using ProcessingFlags = std::pair<ShapeProcess::OperationsFlags, bool>;
public:
Standard_EXPORT Transfer_ActorOfFinderProcess();
//! Returns the Transfer Mode, modifiable
@@ -60,22 +68,45 @@ public:
const Handle(Transfer_FinderProcess)& TP,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Sets parameters for shape processing.
//! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetParameters(const ParameterMap& theParameters);
//! Sets parameters for shape processing.
//! Parameters are moved from the input map.
//! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetParameters(ParameterMap&& theParameters);
//! Sets parameters for shape processing.
//! Parameters from @p theParameters are copied to the internal map.
//! Parameters from @p theAdditionalParameters are copied to the internal map
//! if they are not present in @p theParameters.
//! @param theParameters the parameters for shape processing.
//! @param theAdditionalParameters the additional parameters for shape processing.
Standard_EXPORT void SetParameters(const DE_ShapeFixParameters& theParameters,
const ParameterMap& theAdditionalParameters = {});
//! Returns parameters for shape processing that was set by SetParameters() method.
//! @return the parameters for shape processing. Empty map if no parameters were set.
inline const ParameterMap& GetParameters() const { return myShapeProcParams; }
//! Sets flags defining operations to be performed on shapes.
//! @param theFlags The flags defining operations to be performed on shapes.
Standard_EXPORT void SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags);
//! Returns flags defining operations to be performed on shapes.
//! @return Pair of values defining operations to be performed on shapes and a boolean value
//! that indicates whether the flags were set.
inline const ProcessingFlags& GetShapeProcessFlags() const { return myShapeProcFlags; }
DEFINE_STANDARD_RTTIEXT(Transfer_ActorOfFinderProcess,Transfer_ActorOfProcessForFinder)
protected:
Standard_Integer themodetrans;
private:
ParameterMap myShapeProcParams; //!< Parameters for shape processing.
ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes.
};

View File

@@ -17,10 +17,14 @@
#include <Transfer_ProcessForTransient.hxx>
#include <Transfer_SimpleBinderOfTransient.hxx>
#include <Transfer_TransientProcess.hxx>
#include <XSAlgo_ShapeProcessor.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Transfer_ActorOfTransientProcess,Transfer_ActorOfProcessForTransient)
Transfer_ActorOfTransientProcess::Transfer_ActorOfTransientProcess () { }
Transfer_ActorOfTransientProcess::Transfer_ActorOfTransientProcess()
{}
//=============================================================================
Handle(Transfer_Binder) Transfer_ActorOfTransientProcess::Transfer
(const Handle(Standard_Transient)& start,
@@ -32,6 +36,8 @@ Handle(Transfer_Binder) Transfer_ActorOfTransientProcess::Transfer
return TransientResult (res);
}
//=============================================================================
Handle(Transfer_Binder) Transfer_ActorOfTransientProcess::Transferring
(const Handle(Standard_Transient)& ent,
const Handle(Transfer_ProcessForTransient)& TP,
@@ -40,6 +46,8 @@ Handle(Transfer_Binder) Transfer_ActorOfTransientProcess::Transferring
return Transfer(ent,Handle(Transfer_TransientProcess)::DownCast(TP), theProgress);
}
//=============================================================================
Handle(Standard_Transient) Transfer_ActorOfTransientProcess::TransferTransient
(const Handle(Standard_Transient)& /*ent*/,
const Handle(Transfer_TransientProcess)& /*TP*/,
@@ -48,3 +56,41 @@ Handle(Standard_Transient) Transfer_ActorOfTransientProcess::TransferTransient
Handle(Standard_Transient) nulres;
return nulres;
}
//=============================================================================
void Transfer_ActorOfTransientProcess::SetParameters(const ParameterMap& theParameters)
{
myShapeProcParams = theParameters;
}
//=============================================================================
void Transfer_ActorOfTransientProcess::SetParameters(ParameterMap&& theParameters)
{
myShapeProcParams = std::move(theParameters);
}
//=============================================================================
void Transfer_ActorOfTransientProcess::SetParameters(const DE_ShapeFixParameters& theParameters,
const ParameterMap& theAdditionalParameters)
{
myShapeProcParams.clear();
XSAlgo_ShapeProcessor::FillParameterMap(theParameters, true, myShapeProcParams);
for (const auto& aParam : theAdditionalParameters)
{
if (myShapeProcParams.find(aParam.first) == myShapeProcParams.end())
{
myShapeProcParams[aParam.first] = aParam.second;
}
}
}
//=============================================================================
void Transfer_ActorOfTransientProcess::SetProcessingFlags(const ShapeProcess::OperationsFlags& theFlags)
{
myShapeProcFlags.first = theFlags;
myShapeProcFlags.second = true;
}

View File

@@ -17,9 +17,13 @@
#ifndef _Transfer_ActorOfTransientProcess_HeaderFile
#define _Transfer_ActorOfTransientProcess_HeaderFile
#include <ShapeProcess.hxx>
#include <Standard.hxx>
#include <Transfer_ActorOfProcessForTransient.hxx>
#include <unordered_map>
struct DE_ShapeFixParameters;
class Transfer_Binder;
class Standard_Transient;
class Transfer_ProcessForTransient;
@@ -31,10 +35,14 @@ DEFINE_STANDARD_HANDLE(Transfer_ActorOfTransientProcess, Transfer_ActorOfProcess
//! The original class was renamed. Compatibility only
class Transfer_ActorOfTransientProcess : public Transfer_ActorOfProcessForTransient
{
public:
using ParameterMap = std::unordered_map<std::string, std::string>;
// Flags defining operations to be performed on shapes. Since there is no std::optional in C++11,
// we use a pair. The first element is the flags, the second element is a boolean value that indicates
// whether the flags were set.
using ProcessingFlags = std::pair<ShapeProcess::OperationsFlags, bool>;
public:
Standard_EXPORT Transfer_ActorOfTransientProcess();
Standard_EXPORT virtual Handle(Transfer_Binder) Transferring
@@ -52,27 +60,42 @@ public:
const Handle(Transfer_TransientProcess)& TP,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Sets parameters for shape processing.
//! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetParameters(const ParameterMap& theParameters);
//! Sets parameters for shape processing.
//! Parameters are moved from the input map.
//! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetParameters(ParameterMap&& theParameters);
//! Sets parameters for shape processing.
//! Parameters from @p theParameters are copied to the internal map.
//! Parameters from @p theAdditionalParameters are copied to the internal map
//! if they are not present in @p theParameters.
//! @param theParameters the parameters for shape processing.
//! @param theAdditionalParameters the additional parameters for shape processing.
Standard_EXPORT void SetParameters(const DE_ShapeFixParameters& theParameters,
const ParameterMap& theAdditionalParameters = {});
//! Returns parameters for shape processing that was set by SetParameters() method.
//! @return the parameters for shape processing. Empty map if no parameters were set.
inline const ParameterMap& GetParameters() const { return myShapeProcParams; }
//! Sets flags defining operations to be performed on shapes.
//! @param theFlags The flags defining operations to be performed on shapes.
Standard_EXPORT void SetProcessingFlags(const ShapeProcess::OperationsFlags& theFlags);
//! Returns flags defining operations to be performed on shapes.
//! @return Pair: the flags defining operations to be performed on shapes and a boolean value that indicates
//! whether the flags were set.
inline const ProcessingFlags& GetProcessingFlags() const { return myShapeProcFlags; }
DEFINE_STANDARD_RTTIEXT(Transfer_ActorOfTransientProcess,Transfer_ActorOfProcessForTransient)
protected:
private:
ParameterMap myShapeProcParams; //!< Parameters for shape processing.
ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes.
};
#endif // _Transfer_ActorOfTransientProcess_HeaderFile

View File

@@ -922,9 +922,18 @@ Handle(Transfer_Binder) Transfer_ProcessForTransient::TransferProduct
Message_ProgressScope aScope(theProgress, NULL, 1, true);
while (!actor.IsNull())
{
if (actor->Recognize(start)) binder = actor->Transferring(start, this, aScope.Next());
else binder.Nullify();
if (!binder.IsNull()) break;
if (actor->Recognize(start))
{
binder = actor->Transferring(start, this, aScope.Next());
}
else
{
binder.Nullify();
}
if (!binder.IsNull())
{
break;
}
actor = actor->Next();
}
if (aScope.UserBreak())