1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

Coding - Refactor ShapeHealingMap to NCollection #346

Update container type to OCCT to avoid allocation on creating.
Refactor shape processing parameter handling to use XSAlgo_ShapeProcessor for consistency.
This commit is contained in:
Pasukhin Dmitry 2025-02-08 22:01:14 +01:00 committed by GitHub
parent 7e3d063cae
commit bd77f8af4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 340 additions and 352 deletions

View File

@ -52,7 +52,7 @@ struct DE_ShapeFixParameters
FixMode FixIntersectingWiresMode = FixMode::FixOrNot; FixMode FixIntersectingWiresMode = FixMode::FixOrNot;
FixMode FixLoopWiresMode = FixMode::FixOrNot; FixMode FixLoopWiresMode = FixMode::FixOrNot;
FixMode FixSplitFaceMode = FixMode::FixOrNot; FixMode FixSplitFaceMode = FixMode::FixOrNot;
FixMode AutoCorrectPrecisionMode = FixMode::FixOrNot; FixMode AutoCorrectPrecisionMode = FixMode::Fix;
FixMode ModifyTopologyMode = FixMode::NotFix; FixMode ModifyTopologyMode = FixMode::NotFix;
FixMode ModifyGeometryMode = FixMode::Fix; FixMode ModifyGeometryMode = FixMode::Fix;
FixMode ClosedWireMode = FixMode::Fix; FixMode ClosedWireMode = FixMode::Fix;

View File

@ -285,32 +285,28 @@ Standard_Boolean IGESControl_Writer::Write(const Standard_CString file, const St
//============================================================================= //=============================================================================
void IGESControl_Writer::SetShapeFixParameters(const ParameterMap& theParameters) void IGESControl_Writer::SetShapeFixParameters(
const XSAlgo_ShapeProcessor::ParameterMap& theParameters)
{ {
myShapeProcParams = theParameters; myShapeProcParams = theParameters;
} }
//============================================================================= //=============================================================================
void IGESControl_Writer::SetShapeFixParameters(ParameterMap&& theParameters) void IGESControl_Writer::SetShapeFixParameters(XSAlgo_ShapeProcessor::ParameterMap&& theParameters)
{ {
myShapeProcParams = std::move(theParameters); myShapeProcParams = std::move(theParameters);
} }
//============================================================================= //=============================================================================
void IGESControl_Writer::SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, void IGESControl_Writer::SetShapeFixParameters(
const ParameterMap& theAdditionalParameters) const DE_ShapeFixParameters& theParameters,
const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters)
{ {
myShapeProcParams.clear(); XSAlgo_ShapeProcessor::SetShapeFixParameters(theParameters,
XSAlgo_ShapeProcessor::FillParameterMap(theParameters, true, myShapeProcParams); theAdditionalParameters,
for (const auto& aParam : theAdditionalParameters) myShapeProcParams);
{
if (myShapeProcParams.find(aParam.first) == myShapeProcParams.end())
{
myShapeProcParams[aParam.first] = aParam.second;
}
}
} }
//============================================================================= //=============================================================================
@ -325,7 +321,7 @@ void IGESControl_Writer::SetShapeProcessFlags(const ShapeProcess::OperationsFlag
void IGESControl_Writer::InitializeMissingParameters() void IGESControl_Writer::InitializeMissingParameters()
{ {
if (GetShapeFixParameters().empty()) if (GetShapeFixParameters().IsEmpty())
{ {
SetShapeFixParameters(DEIGES_Parameters::GetDefaultShapeFixParameters()); SetShapeFixParameters(DEIGES_Parameters::GetDefaultShapeFixParameters());
} }

View File

@ -26,8 +26,7 @@
#include <Standard_CString.hxx> #include <Standard_CString.hxx>
#include <Standard_OStream.hxx> #include <Standard_OStream.hxx>
#include <Message_ProgressRange.hxx> #include <Message_ProgressRange.hxx>
#include <XSAlgo_ShapeProcessor.hxx>
#include <unordered_map>
struct DE_ShapeFixParameters; struct DE_ShapeFixParameters;
class Transfer_FinderProcess; class Transfer_FinderProcess;
@ -51,12 +50,6 @@ class IGESControl_Writer
public: public:
DEFINE_STANDARD_ALLOC DEFINE_STANDARD_ALLOC
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: public:
//! Creates a writer object with the //! Creates a writer object with the
//! default unit (millimeters) and write mode (Face). //! default unit (millimeters) and write mode (Face).
@ -126,12 +119,13 @@ public:
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(const ParameterMap& theParameters); Standard_EXPORT void SetShapeFixParameters(
const XSAlgo_ShapeProcessor::ParameterMap& theParameters);
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! Parameters are moved from the input map. //! Parameters are moved from the input map.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(ParameterMap&& theParameters); Standard_EXPORT void SetShapeFixParameters(XSAlgo_ShapeProcessor::ParameterMap&& theParameters);
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! Parameters from @p theParameters are copied to the internal map. //! Parameters from @p theParameters are copied to the internal map.
@ -139,12 +133,16 @@ public:
//! if they are not present in @p theParameters. //! if they are not present in @p theParameters.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
//! @param theAdditionalParameters the additional parameters for shape processing. //! @param theAdditionalParameters the additional parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, Standard_EXPORT void SetShapeFixParameters(
const ParameterMap& theAdditionalParameters = {}); const DE_ShapeFixParameters& theParameters,
const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters = {});
//! Returns parameters for shape processing that was set by SetParameters() method. //! Returns parameters for shape processing that was set by SetParameters() method.
//! @return the parameters for shape processing. Empty map if no parameters were set. //! @return the parameters for shape processing. Empty map if no parameters were set.
inline const ParameterMap& GetShapeFixParameters() const { return myShapeProcParams; } inline const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const
{
return myShapeProcParams;
}
//! Sets flags defining operations to be performed on shapes. //! Sets flags defining operations to be performed on shapes.
//! @param theFlags The flags defining operations to be performed on shapes. //! @param theFlags The flags defining operations to be performed on shapes.
@ -168,8 +166,10 @@ private:
IGESData_BasicEditor myEditor; IGESData_BasicEditor myEditor;
Standard_Integer myWriteMode; Standard_Integer myWriteMode;
Standard_Boolean myIsComputed; Standard_Boolean myIsComputed;
ParameterMap myShapeProcParams; //!< Parameters for shape processing. // clang-format off
ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes. XSAlgo_ShapeProcessor::ParameterMap myShapeProcParams; //!< Parameters for shape processing.
XSAlgo_ShapeProcessor::ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes.
// clang-format on
}; };
#endif // _IGESControl_Writer_HeaderFile #endif // _IGESControl_Writer_HeaderFile

View File

@ -199,7 +199,7 @@ Handle(Transfer_Binder) IGESToBRep_Actor::Transfer(const Handle(Standard_Transie
// Set tolerances for shape processing. // Set tolerances for shape processing.
// These parameters are calculated inside IGESToBRep_Actor::Transfer() and cannot be set from // These parameters are calculated inside IGESToBRep_Actor::Transfer() and cannot be set from
// outside. // outside.
Transfer_ActorOfTransientProcess::ParameterMap aParameters = GetShapeFixParameters(); XSAlgo_ShapeProcessor::ParameterMap aParameters = GetShapeFixParameters();
XSAlgo_ShapeProcessor::SetParameter("FixShape.Tolerance3d", theeps, true, aParameters); XSAlgo_ShapeProcessor::SetParameter("FixShape.Tolerance3d", theeps, true, aParameters);
XSAlgo_ShapeProcessor::SetParameter("FixShape.MaxTolerance3d", XSAlgo_ShapeProcessor::SetParameter("FixShape.MaxTolerance3d",
CAS.GetMaxTol(), CAS.GetMaxTol(),

View File

@ -617,32 +617,28 @@ TopoDS_Shape IGESToBRep_Reader::OneShape() const
//============================================================================= //=============================================================================
void IGESToBRep_Reader::SetShapeFixParameters(const ParameterMap& theParameters) void IGESToBRep_Reader::SetShapeFixParameters(
const XSAlgo_ShapeProcessor::ParameterMap& theParameters)
{ {
myShapeProcParams = theParameters; myShapeProcParams = theParameters;
} }
//============================================================================= //=============================================================================
void IGESToBRep_Reader::SetShapeFixParameters(ParameterMap&& theParameters) void IGESToBRep_Reader::SetShapeFixParameters(XSAlgo_ShapeProcessor::ParameterMap&& theParameters)
{ {
myShapeProcParams = std::move(theParameters); myShapeProcParams = std::move(theParameters);
} }
//============================================================================= //=============================================================================
void IGESToBRep_Reader::SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, void IGESToBRep_Reader::SetShapeFixParameters(
const ParameterMap& theAdditionalParameters) const DE_ShapeFixParameters& theParameters,
const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters)
{ {
myShapeProcParams.clear(); XSAlgo_ShapeProcessor::SetShapeFixParameters(theParameters,
XSAlgo_ShapeProcessor::FillParameterMap(theParameters, true, myShapeProcParams); theAdditionalParameters,
for (const auto& aParam : theAdditionalParameters) myShapeProcParams);
{
if (myShapeProcParams.find(aParam.first) == myShapeProcParams.end())
{
myShapeProcParams[aParam.first] = aParam.second;
}
}
} }
//============================================================================= //=============================================================================
@ -657,7 +653,7 @@ void IGESToBRep_Reader::SetShapeProcessFlags(const ShapeProcess::OperationsFlags
void IGESToBRep_Reader::InitializeMissingParameters() void IGESToBRep_Reader::InitializeMissingParameters()
{ {
if (GetShapeFixParameters().empty()) if (GetShapeFixParameters().IsEmpty())
{ {
SetShapeFixParameters(DEIGES_Parameters::GetDefaultShapeFixParameters()); SetShapeFixParameters(DEIGES_Parameters::GetDefaultShapeFixParameters());
} }

View File

@ -25,8 +25,7 @@
#include <Standard_Integer.hxx> #include <Standard_Integer.hxx>
#include <Standard_CString.hxx> #include <Standard_CString.hxx>
#include <TopTools_SequenceOfShape.hxx> #include <TopTools_SequenceOfShape.hxx>
#include <XSAlgo_ShapeProcessor.hxx>
#include <unordered_map>
struct DE_ShapeFixParameters; struct DE_ShapeFixParameters;
class IGESData_IGESModel; class IGESData_IGESModel;
@ -41,12 +40,6 @@ class IGESToBRep_Reader
public: public:
DEFINE_STANDARD_ALLOC DEFINE_STANDARD_ALLOC
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: public:
//! Creates a Reader //! Creates a Reader
Standard_EXPORT IGESToBRep_Reader(); Standard_EXPORT IGESToBRep_Reader();
@ -120,12 +113,13 @@ public:
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(const ParameterMap& theParameters); Standard_EXPORT void SetShapeFixParameters(
const XSAlgo_ShapeProcessor::ParameterMap& theParameters);
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! Parameters are moved from the input map. //! Parameters are moved from the input map.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(ParameterMap&& theParameters); Standard_EXPORT void SetShapeFixParameters(XSAlgo_ShapeProcessor::ParameterMap&& theParameters);
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! Parameters from @p theParameters are copied to the internal map. //! Parameters from @p theParameters are copied to the internal map.
@ -133,12 +127,16 @@ public:
//! if they are not present in @p theParameters. //! if they are not present in @p theParameters.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
//! @param theAdditionalParameters the additional parameters for shape processing. //! @param theAdditionalParameters the additional parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, Standard_EXPORT void SetShapeFixParameters(
const ParameterMap& theAdditionalParameters = {}); const DE_ShapeFixParameters& theParameters,
const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters = {});
//! Returns parameters for shape processing that was set by SetParameters() method. //! Returns parameters for shape processing that was set by SetParameters() method.
//! @return the parameters for shape processing. Empty map if no parameters were set. //! @return the parameters for shape processing. Empty map if no parameters were set.
inline const ParameterMap& GetShapeFixParameters() const { return myShapeProcParams; } inline const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const
{
return myShapeProcParams;
}
//! Sets flags defining operations to be performed on shapes. //! Sets flags defining operations to be performed on shapes.
//! @param theFlags The flags defining operations to be performed on shapes. //! @param theFlags The flags defining operations to be performed on shapes.
@ -161,8 +159,10 @@ private:
TopTools_SequenceOfShape theShapes; TopTools_SequenceOfShape theShapes;
Handle(IGESToBRep_Actor) theActor; Handle(IGESToBRep_Actor) theActor;
Handle(Transfer_TransientProcess) theProc; Handle(Transfer_TransientProcess) theProc;
ParameterMap myShapeProcParams; //!< Parameters for shape processing. // clang-format off
ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes. XSAlgo_ShapeProcessor::ParameterMap myShapeProcParams; //!< Parameters for shape processing.
XSAlgo_ShapeProcessor::ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes.
// clang-format on
}; };
#endif // _IGESToBRep_Reader_HeaderFile #endif // _IGESToBRep_Reader_HeaderFile

View File

@ -5809,29 +5809,32 @@ Standard_Boolean STEPCAFControl_Reader::GetViewMode() const
//============================================================================= //=============================================================================
void STEPCAFControl_Reader::SetShapeFixParameters(const ParameterMap& theParameters) void STEPCAFControl_Reader::SetShapeFixParameters(
const XSAlgo_ShapeProcessor::ParameterMap& theParameters)
{ {
myReader.SetShapeFixParameters(theParameters); myReader.SetShapeFixParameters(theParameters);
} }
//============================================================================= //=============================================================================
void STEPCAFControl_Reader::SetShapeFixParameters(ParameterMap&& theParameters) void STEPCAFControl_Reader::SetShapeFixParameters(
XSAlgo_ShapeProcessor::ParameterMap&& theParameters)
{ {
myReader.SetShapeFixParameters(std::move(theParameters)); myReader.SetShapeFixParameters(std::move(theParameters));
} }
//============================================================================= //=============================================================================
void STEPCAFControl_Reader::SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, void STEPCAFControl_Reader::SetShapeFixParameters(
const ParameterMap& theAdditionalParameters) const DE_ShapeFixParameters& theParameters,
const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters)
{ {
myReader.SetShapeFixParameters(theParameters, theAdditionalParameters); myReader.SetShapeFixParameters(theParameters, theAdditionalParameters);
} }
//============================================================================= //=============================================================================
const STEPCAFControl_Reader::ParameterMap& STEPCAFControl_Reader::GetShapeFixParameters() const const XSAlgo_ShapeProcessor::ParameterMap& STEPCAFControl_Reader::GetShapeFixParameters() const
{ {
return myReader.GetShapeFixParameters(); return myReader.GetShapeFixParameters();
} }
@ -5845,7 +5848,7 @@ void STEPCAFControl_Reader::SetShapeProcessFlags(const ShapeProcess::OperationsF
//============================================================================= //=============================================================================
const STEPCAFControl_Reader::ProcessingFlags& STEPCAFControl_Reader::GetShapeProcessFlags() const const XSAlgo_ShapeProcessor::ProcessingFlags& STEPCAFControl_Reader::GetShapeProcessFlags() const
{ {
return myReader.GetShapeProcessFlags(); return myReader.GetShapeProcessFlags();
} }

View File

@ -62,9 +62,6 @@ class STEPCAFControl_Reader
public: public:
DEFINE_STANDARD_ALLOC DEFINE_STANDARD_ALLOC
using ParameterMap = XSControl_Reader::ParameterMap;
using ProcessingFlags = XSControl_Reader::ProcessingFlags;
public: public:
//! Creates a reader with an empty //! Creates a reader with an empty
//! STEP model and sets ColorMode, LayerMode, NameMode and //! STEP model and sets ColorMode, LayerMode, NameMode and
@ -230,12 +227,13 @@ public:
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(const ParameterMap& theParameters); Standard_EXPORT void SetShapeFixParameters(
const XSAlgo_ShapeProcessor::ParameterMap& theParameters);
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! Parameters are moved from the input map. //! Parameters are moved from the input map.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(ParameterMap&& theParameters); Standard_EXPORT void SetShapeFixParameters(XSAlgo_ShapeProcessor::ParameterMap&& theParameters);
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! Parameters from @p theParameters are copied to the internal map. //! Parameters from @p theParameters are copied to the internal map.
@ -243,12 +241,13 @@ public:
//! if they are not present in @p theParameters. //! if they are not present in @p theParameters.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
//! @param theAdditionalParameters the additional parameters for shape processing. //! @param theAdditionalParameters the additional parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, Standard_EXPORT void SetShapeFixParameters(
const ParameterMap& theAdditionalParameters = {}); const DE_ShapeFixParameters& theParameters,
const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters = {});
//! Returns parameters for shape processing that was set by SetParameters() method. //! Returns parameters for shape processing that was set by SetParameters() method.
//! @return the parameters for shape processing. Empty map if no parameters were set. //! @return the parameters for shape processing. Empty map if no parameters were set.
Standard_EXPORT const ParameterMap& GetShapeFixParameters() const; Standard_EXPORT const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const;
//! Sets flags defining operations to be performed on shapes. //! Sets flags defining operations to be performed on shapes.
//! @param theFlags The flags defining operations to be performed on shapes. //! @param theFlags The flags defining operations to be performed on shapes.
@ -257,7 +256,7 @@ public:
//! Returns flags defining operations to be performed on shapes. //! Returns flags defining operations to be performed on shapes.
//! @return Pair of values defining operations to be performed on shapes and a boolean value //! @return Pair of values defining operations to be performed on shapes and a boolean value
//! that indicates whether the flags were set. //! that indicates whether the flags were set.
Standard_EXPORT const ProcessingFlags& GetShapeProcessFlags() const; Standard_EXPORT const XSAlgo_ShapeProcessor::ProcessingFlags& GetShapeProcessFlags() const;
protected: protected:
//! Translates STEP file already loaded into the reader //! Translates STEP file already loaded into the reader

View File

@ -539,29 +539,32 @@ Standard_Boolean STEPCAFControl_Writer::ExternFile(
//============================================================================= //=============================================================================
void STEPCAFControl_Writer::SetShapeFixParameters(const ParameterMap& theParameters) void STEPCAFControl_Writer::SetShapeFixParameters(
const XSAlgo_ShapeProcessor::ParameterMap& theParameters)
{ {
myWriter.SetShapeFixParameters(theParameters); myWriter.SetShapeFixParameters(theParameters);
} }
//============================================================================= //=============================================================================
void STEPCAFControl_Writer::SetShapeFixParameters(ParameterMap&& theParameters) void STEPCAFControl_Writer::SetShapeFixParameters(
XSAlgo_ShapeProcessor::ParameterMap&& theParameters)
{ {
myWriter.SetShapeFixParameters(std::move(theParameters)); myWriter.SetShapeFixParameters(std::move(theParameters));
} }
//============================================================================= //=============================================================================
void STEPCAFControl_Writer::SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, void STEPCAFControl_Writer::SetShapeFixParameters(
const ParameterMap& theAdditionalParameters) const DE_ShapeFixParameters& theParameters,
const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters)
{ {
myWriter.SetShapeFixParameters(theParameters, theAdditionalParameters); myWriter.SetShapeFixParameters(theParameters, theAdditionalParameters);
} }
//============================================================================= //=============================================================================
const STEPCAFControl_Writer::ParameterMap& STEPCAFControl_Writer::GetShapeFixParameters() const const XSAlgo_ShapeProcessor::ParameterMap& STEPCAFControl_Writer::GetShapeFixParameters() const
{ {
return myWriter.GetShapeFixParameters(); return myWriter.GetShapeFixParameters();
} }
@ -575,7 +578,7 @@ void STEPCAFControl_Writer::SetShapeProcessFlags(const ShapeProcess::OperationsF
//============================================================================= //=============================================================================
const STEPCAFControl_Writer::ProcessingFlags& STEPCAFControl_Writer::GetShapeProcessFlags() const const XSAlgo_ShapeProcessor::ProcessingFlags& STEPCAFControl_Writer::GetShapeProcessFlags() const
{ {
return myWriter.GetShapeProcessFlags(); return myWriter.GetShapeProcessFlags();
} }

View File

@ -52,9 +52,6 @@ class STEPCAFControl_Writer
public: public:
DEFINE_STANDARD_ALLOC DEFINE_STANDARD_ALLOC
using ParameterMap = STEPControl_Writer::ParameterMap;
using ProcessingFlags = STEPControl_Writer::ProcessingFlags;
public: public:
//! Creates a writer with an empty //! Creates a writer with an empty
//! STEP model and sets ColorMode, LayerMode, NameMode and //! STEP model and sets ColorMode, LayerMode, NameMode and
@ -231,12 +228,13 @@ public:
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(const ParameterMap& theParameters); Standard_EXPORT void SetShapeFixParameters(
const XSAlgo_ShapeProcessor::ParameterMap& theParameters);
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! Parameters are moved from the input map. //! Parameters are moved from the input map.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(ParameterMap&& theParameters); Standard_EXPORT void SetShapeFixParameters(XSAlgo_ShapeProcessor::ParameterMap&& theParameters);
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! Parameters from @p theParameters are copied to the internal map. //! Parameters from @p theParameters are copied to the internal map.
@ -244,12 +242,13 @@ public:
//! if they are not present in @p theParameters. //! if they are not present in @p theParameters.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
//! @param theAdditionalParameters the additional parameters for shape processing. //! @param theAdditionalParameters the additional parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, Standard_EXPORT void SetShapeFixParameters(
const ParameterMap& theAdditionalParameters = {}); const DE_ShapeFixParameters& theParameters,
const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters = {});
//! Returns parameters for shape processing that was set by SetParameters() method. //! Returns parameters for shape processing that was set by SetParameters() method.
//! @return the parameters for shape processing. Empty map if no parameters were set. //! @return the parameters for shape processing. Empty map if no parameters were set.
Standard_EXPORT const ParameterMap& GetShapeFixParameters() const; Standard_EXPORT const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const;
//! Sets flags defining operations to be performed on shapes. //! Sets flags defining operations to be performed on shapes.
//! @param theFlags The flags defining operations to be performed on shapes. //! @param theFlags The flags defining operations to be performed on shapes.
@ -258,7 +257,7 @@ public:
//! Returns flags defining operations to be performed on shapes. //! Returns flags defining operations to be performed on shapes.
//! @return Pair of values defining operations to be performed on shapes and a boolean value //! @return Pair of values defining operations to be performed on shapes and a boolean value
//! that indicates whether the flags were set. //! that indicates whether the flags were set.
Standard_EXPORT const ProcessingFlags& GetShapeProcessFlags() const; Standard_EXPORT const XSAlgo_ShapeProcessor::ProcessingFlags& GetShapeProcessFlags() const;
protected: protected:
//! Transfers labels to a STEP model //! Transfers labels to a STEP model

View File

@ -1000,13 +1000,10 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(
// Set tolerances for shape processing. // Set tolerances for shape processing.
// These parameters are calculated inside STEPControl_ActorRead::Transfer() and cannot be set // These parameters are calculated inside STEPControl_ActorRead::Transfer() and cannot be set
// from outside. // from outside.
Transfer_ActorOfTransientProcess::ParameterMap aParameters = GetShapeFixParameters(); XSAlgo_ShapeProcessor::ParameterMap aParameters = GetShapeFixParameters();
XSAlgo_ShapeProcessor::SetParameter("FixShape.Tolerance3d", myPrecision, true, aParameters); XSAlgo_ShapeProcessor::SetParameter("FixShape.Tolerance3d", myPrecision, true, aParameters);
XSAlgo_ShapeProcessor::SetParameter("FixShape.MaxTolerance3d", myMaxTol, true, aParameters); XSAlgo_ShapeProcessor::SetParameter("FixShape.MaxTolerance3d", myMaxTol, true, aParameters);
XSAlgo_ShapeProcessor::SetParameter("FixShape.NonManifold", XSAlgo_ShapeProcessor::SetParameter("FixShape.NonManifold", "1", true, aParameters);
std::to_string(true),
true,
aParameters);
XSAlgo_ShapeProcessor aShapeProcessor(aParameters); XSAlgo_ShapeProcessor aShapeProcessor(aParameters);
TopoDS_Shape fixedResult = TopoDS_Shape fixedResult =
aShapeProcessor.ProcessShape(comp, GetProcessingFlags().first, aPS1.Next()); aShapeProcessor.ProcessShape(comp, GetProcessingFlags().first, aPS1.Next());
@ -1698,7 +1695,7 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(
// Set tolerances for shape processing. // Set tolerances for shape processing.
// These parameters are calculated inside STEPControl_ActorRead::Transfer() and cannot be set // These parameters are calculated inside STEPControl_ActorRead::Transfer() and cannot be set
// from outside. // from outside.
Transfer_ActorOfTransientProcess::ParameterMap aParameters = GetShapeFixParameters(); XSAlgo_ShapeProcessor::ParameterMap aParameters = GetShapeFixParameters();
XSAlgo_ShapeProcessor::SetParameter("FixShape.Tolerance3d", myPrecision, true, aParameters); XSAlgo_ShapeProcessor::SetParameter("FixShape.Tolerance3d", myPrecision, true, aParameters);
XSAlgo_ShapeProcessor::SetParameter("FixShape.MaxTolerance3d", myMaxTol, true, aParameters); XSAlgo_ShapeProcessor::SetParameter("FixShape.MaxTolerance3d", myMaxTol, true, aParameters);
XSAlgo_ShapeProcessor aShapeProcessor(aParameters); XSAlgo_ShapeProcessor aShapeProcessor(aParameters);
@ -1885,7 +1882,7 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(
{ {
TopoDS_Shape S = sb->Result(); TopoDS_Shape S = sb->Result();
Transfer_ActorOfTransientProcess::ParameterMap aParameters = GetShapeFixParameters(); XSAlgo_ShapeProcessor::ParameterMap aParameters = GetShapeFixParameters();
XSAlgo_ShapeProcessor::SetParameter("FixShape.Tolerance3d", myPrecision, true, aParameters); XSAlgo_ShapeProcessor::SetParameter("FixShape.Tolerance3d", myPrecision, true, aParameters);
XSAlgo_ShapeProcessor::SetParameter("FixShape.MaxTolerance3d", myMaxTol, true, aParameters); XSAlgo_ShapeProcessor::SetParameter("FixShape.MaxTolerance3d", myMaxTol, true, aParameters);
XSAlgo_ShapeProcessor aShapeProcessor(aParameters); XSAlgo_ShapeProcessor aShapeProcessor(aParameters);

View File

@ -1045,7 +1045,7 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferShape(
TopoDS_Shape aShape = xShape; TopoDS_Shape aShape = xShape;
Transfer_ActorOfFinderProcess::ParameterMap aParameters = GetShapeFixParameters(); XSAlgo_ShapeProcessor::ParameterMap aParameters = GetShapeFixParameters();
XSAlgo_ShapeProcessor::SetParameter("FixShape.Tolerance3d", Tol, true, aParameters); XSAlgo_ShapeProcessor::SetParameter("FixShape.Tolerance3d", Tol, true, aParameters);
XSAlgo_ShapeProcessor::SetParameter("FixShape.MaxTolerance3d", XSAlgo_ShapeProcessor::SetParameter("FixShape.MaxTolerance3d",
aStepModel->InternalParameters.ReadMaxPrecisionVal, aStepModel->InternalParameters.ReadMaxPrecisionVal,

View File

@ -199,7 +199,8 @@ void STEPControl_Writer::PrintStatsTransfer(const Standard_Integer what,
//============================================================================= //=============================================================================
void STEPControl_Writer::SetShapeFixParameters(const ParameterMap& theParameters) void STEPControl_Writer::SetShapeFixParameters(
const XSAlgo_ShapeProcessor::ParameterMap& theParameters)
{ {
if (Handle(Transfer_ActorOfFinderProcess) anActor = GetActor()) if (Handle(Transfer_ActorOfFinderProcess) anActor = GetActor())
{ {
@ -209,7 +210,7 @@ void STEPControl_Writer::SetShapeFixParameters(const ParameterMap& theParameters
//============================================================================= //=============================================================================
void STEPControl_Writer::SetShapeFixParameters(ParameterMap&& theParameters) void STEPControl_Writer::SetShapeFixParameters(XSAlgo_ShapeProcessor::ParameterMap&& theParameters)
{ {
if (Handle(Transfer_ActorOfFinderProcess) anActor = GetActor()) if (Handle(Transfer_ActorOfFinderProcess) anActor = GetActor())
{ {
@ -219,8 +220,9 @@ void STEPControl_Writer::SetShapeFixParameters(ParameterMap&& theParameters)
//============================================================================= //=============================================================================
void STEPControl_Writer::SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, void STEPControl_Writer::SetShapeFixParameters(
const ParameterMap& theAdditionalParameters) const DE_ShapeFixParameters& theParameters,
const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters)
{ {
if (Handle(Transfer_ActorOfFinderProcess) anActor = GetActor()) if (Handle(Transfer_ActorOfFinderProcess) anActor = GetActor())
{ {
@ -230,10 +232,10 @@ void STEPControl_Writer::SetShapeFixParameters(const DE_ShapeFixParameters& theP
//============================================================================= //=============================================================================
const STEPControl_Writer::ParameterMap& STEPControl_Writer::GetShapeFixParameters() const const XSAlgo_ShapeProcessor::ParameterMap& STEPControl_Writer::GetShapeFixParameters() const
{ {
static const ParameterMap anEmptyMap; static const XSAlgo_ShapeProcessor::ParameterMap anEmptyMap;
const Handle(Transfer_ActorOfFinderProcess) anActor = GetActor(); const Handle(Transfer_ActorOfFinderProcess) anActor = GetActor();
return anActor.IsNull() ? anEmptyMap : anActor->GetShapeFixParameters(); return anActor.IsNull() ? anEmptyMap : anActor->GetShapeFixParameters();
} }
@ -249,10 +251,10 @@ void STEPControl_Writer::SetShapeProcessFlags(const ShapeProcess::OperationsFlag
//============================================================================= //=============================================================================
const STEPControl_Writer::ProcessingFlags& STEPControl_Writer::GetShapeProcessFlags() const const XSAlgo_ShapeProcessor::ProcessingFlags& STEPControl_Writer::GetShapeProcessFlags() const
{ {
static const ProcessingFlags anEmptyFlags; static const XSAlgo_ShapeProcessor::ProcessingFlags anEmptyFlags;
const Handle(Transfer_ActorOfFinderProcess) anActor = GetActor(); const Handle(Transfer_ActorOfFinderProcess) anActor = GetActor();
return anActor.IsNull() ? anEmptyFlags : anActor->GetShapeProcessFlags(); return anActor.IsNull() ? anEmptyFlags : anActor->GetShapeProcessFlags();
} }
@ -279,7 +281,7 @@ Handle(Transfer_ActorOfFinderProcess) STEPControl_Writer::GetActor() const
void STEPControl_Writer::InitializeMissingParameters() void STEPControl_Writer::InitializeMissingParameters()
{ {
if (GetShapeFixParameters().empty()) if (GetShapeFixParameters().IsEmpty())
{ {
SetShapeFixParameters(DESTEP_Parameters::GetDefaultShapeFixParameters()); SetShapeFixParameters(DESTEP_Parameters::GetDefaultShapeFixParameters());
} }

View File

@ -27,6 +27,7 @@
#include <STEPControl_StepModelType.hxx> #include <STEPControl_StepModelType.hxx>
#include <Standard_Integer.hxx> #include <Standard_Integer.hxx>
#include <Message_ProgressRange.hxx> #include <Message_ProgressRange.hxx>
#include <XSAlgo_ShapeProcessor.hxx>
#include <unordered_map> #include <unordered_map>
@ -46,12 +47,6 @@ class STEPControl_Writer
public: public:
DEFINE_STANDARD_ALLOC DEFINE_STANDARD_ALLOC
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>;
//! Creates a Writer from scratch //! Creates a Writer from scratch
Standard_EXPORT STEPControl_Writer(); Standard_EXPORT STEPControl_Writer();
@ -138,12 +133,13 @@ public:
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(const ParameterMap& theParameters); Standard_EXPORT void SetShapeFixParameters(
const XSAlgo_ShapeProcessor::ParameterMap& theParameters);
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! Parameters are moved from the input map. //! Parameters are moved from the input map.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(ParameterMap&& theParameters); Standard_EXPORT void SetShapeFixParameters(XSAlgo_ShapeProcessor::ParameterMap&& theParameters);
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! Parameters from @p theParameters are copied to the internal map. //! Parameters from @p theParameters are copied to the internal map.
@ -151,12 +147,13 @@ public:
//! if they are not present in @p theParameters. //! if they are not present in @p theParameters.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
//! @param theAdditionalParameters the additional parameters for shape processing. //! @param theAdditionalParameters the additional parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, Standard_EXPORT void SetShapeFixParameters(
const ParameterMap& theAdditionalParameters = {}); const DE_ShapeFixParameters& theParameters,
const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters = {});
//! Returns parameters for shape processing that was set by SetParameters() method. //! Returns parameters for shape processing that was set by SetParameters() method.
//! @return the parameters for shape processing. Empty map if no parameters were set. //! @return the parameters for shape processing. Empty map if no parameters were set.
Standard_EXPORT const ParameterMap& GetShapeFixParameters() const; Standard_EXPORT const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const;
//! Sets flags defining operations to be performed on shapes. //! Sets flags defining operations to be performed on shapes.
//! @param theFlags The flags defining operations to be performed on shapes. //! @param theFlags The flags defining operations to be performed on shapes.
@ -165,7 +162,7 @@ public:
//! Returns flags defining operations to be performed on shapes. //! Returns flags defining operations to be performed on shapes.
//! @return Pair of values defining operations to be performed on shapes and a boolean value //! @return Pair of values defining operations to be performed on shapes and a boolean value
//! that indicates whether the flags were set. //! that indicates whether the flags were set.
Standard_EXPORT const ProcessingFlags& GetShapeProcessFlags() const; Standard_EXPORT const XSAlgo_ShapeProcessor::ProcessingFlags& GetShapeProcessFlags() const;
private: private:
//! Returns the Actor for the Transfer of an Entity. //! Returns the Actor for the Transfer of an Entity.

View File

@ -180,9 +180,9 @@ Standard_Boolean ShapeProcess::Perform(const Handle(ShapeProcess_Context)& conte
//================================================================================================= //=================================================================================================
Standard_Boolean ShapeProcess::Perform(const Handle(ShapeProcess_Context)& theContext, Standard_Boolean ShapeProcess::Perform(const Handle(ShapeProcess_Context)& theContext,
const OperationsFlags& theOperations, const ShapeProcess::OperationsFlags& theOperations,
const Message_ProgressRange& theProgress) const Message_ProgressRange& theProgress)
{ {
if (!theContext) if (!theContext)
{ {
@ -246,7 +246,7 @@ std::pair<ShapeProcess::Operation, bool> ShapeProcess::ToOperationFlag(const cha
//================================================================================================= //=================================================================================================
std::vector<std::pair<const char*, Handle(ShapeProcess_Operator)>> ShapeProcess::getOperators( std::vector<std::pair<const char*, Handle(ShapeProcess_Operator)>> ShapeProcess::getOperators(
const OperationsFlags& theFlags) const ShapeProcess::OperationsFlags& theFlags)
{ {
std::vector<std::pair<const char*, Handle(ShapeProcess_Operator)>> aResult; std::vector<std::pair<const char*, Handle(ShapeProcess_Operator)>> aResult;
for (std::underlying_type<Operation>::type anOperation = Operation::First; for (std::underlying_type<Operation>::type anOperation = Operation::First;

View File

@ -76,14 +76,16 @@ Handle(Standard_Transient) Transfer_ActorOfFinderProcess::TransferTransient(
//============================================================================= //=============================================================================
void Transfer_ActorOfFinderProcess::SetShapeFixParameters(const ParameterMap& theParameters) void Transfer_ActorOfFinderProcess::SetShapeFixParameters(
const XSAlgo_ShapeProcessor::ParameterMap& theParameters)
{ {
myShapeProcParams = theParameters; myShapeProcParams = theParameters;
} }
//============================================================================= //=============================================================================
void Transfer_ActorOfFinderProcess::SetShapeFixParameters(ParameterMap&& theParameters) void Transfer_ActorOfFinderProcess::SetShapeFixParameters(
XSAlgo_ShapeProcessor::ParameterMap&& theParameters)
{ {
myShapeProcParams = std::move(theParameters); myShapeProcParams = std::move(theParameters);
} }
@ -91,18 +93,12 @@ void Transfer_ActorOfFinderProcess::SetShapeFixParameters(ParameterMap&& thePara
//============================================================================= //=============================================================================
void Transfer_ActorOfFinderProcess::SetShapeFixParameters( void Transfer_ActorOfFinderProcess::SetShapeFixParameters(
const DE_ShapeFixParameters& theParameters, const DE_ShapeFixParameters& theParameters,
const ParameterMap& theAdditionalParameters) const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters)
{ {
myShapeProcParams.clear(); XSAlgo_ShapeProcessor::SetShapeFixParameters(theParameters,
XSAlgo_ShapeProcessor::FillParameterMap(theParameters, true, myShapeProcParams); theAdditionalParameters,
for (const auto& aParam : theAdditionalParameters) myShapeProcParams);
{
if (myShapeProcParams.find(aParam.first) == myShapeProcParams.end())
{
myShapeProcParams[aParam.first] = aParam.second;
}
}
} }
//============================================================================= //=============================================================================

View File

@ -20,8 +20,7 @@
#include <Standard.hxx> #include <Standard.hxx>
#include <ShapeProcess.hxx> #include <ShapeProcess.hxx>
#include <Transfer_ActorOfProcessForFinder.hxx> #include <Transfer_ActorOfProcessForFinder.hxx>
#include <XSAlgo_ShapeProcessor.hxx>
#include <unordered_map>
struct DE_ShapeFixParameters; struct DE_ShapeFixParameters;
class Transfer_Binder; class Transfer_Binder;
@ -39,13 +38,6 @@ DEFINE_STANDARD_HANDLE(Transfer_ActorOfFinderProcess, Transfer_ActorOfProcessFor
//! a user. To be interpreted for each norm //! a user. To be interpreted for each norm
class Transfer_ActorOfFinderProcess : public Transfer_ActorOfProcessForFinder 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: public:
Standard_EXPORT Transfer_ActorOfFinderProcess(); Standard_EXPORT Transfer_ActorOfFinderProcess();
@ -69,12 +61,13 @@ public:
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(const ParameterMap& theParameters); Standard_EXPORT void SetShapeFixParameters(
const XSAlgo_ShapeProcessor::ParameterMap& theParameters);
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! Parameters are moved from the input map. //! Parameters are moved from the input map.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(ParameterMap&& theParameters); Standard_EXPORT void SetShapeFixParameters(XSAlgo_ShapeProcessor::ParameterMap&& theParameters);
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! Parameters from @p theParameters are copied to the internal map. //! Parameters from @p theParameters are copied to the internal map.
@ -82,12 +75,16 @@ public:
//! if they are not present in @p theParameters. //! if they are not present in @p theParameters.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
//! @param theAdditionalParameters the additional parameters for shape processing. //! @param theAdditionalParameters the additional parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, Standard_EXPORT void SetShapeFixParameters(
const ParameterMap& theAdditionalParameters = {}); const DE_ShapeFixParameters& theParameters,
const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters = {});
//! Returns parameters for shape processing that was set by SetParameters() method. //! Returns parameters for shape processing that was set by SetParameters() method.
//! @return the parameters for shape processing. Empty map if no parameters were set. //! @return the parameters for shape processing. Empty map if no parameters were set.
inline const ParameterMap& GetShapeFixParameters() const { return myShapeProcParams; } inline const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const
{
return myShapeProcParams;
}
//! Sets flags defining operations to be performed on shapes. //! Sets flags defining operations to be performed on shapes.
//! @param theFlags The flags defining operations to be performed on shapes. //! @param theFlags The flags defining operations to be performed on shapes.
@ -96,7 +93,10 @@ public:
//! Returns flags defining operations to be performed on shapes. //! Returns flags defining operations to be performed on shapes.
//! @return Pair of values defining operations to be performed on shapes and a boolean value //! @return Pair of values defining operations to be performed on shapes and a boolean value
//! that indicates whether the flags were set. //! that indicates whether the flags were set.
inline const ProcessingFlags& GetShapeProcessFlags() const { return myShapeProcFlags; } inline const XSAlgo_ShapeProcessor::ProcessingFlags& GetShapeProcessFlags() const
{
return myShapeProcFlags;
}
DEFINE_STANDARD_RTTIEXT(Transfer_ActorOfFinderProcess, Transfer_ActorOfProcessForFinder) DEFINE_STANDARD_RTTIEXT(Transfer_ActorOfFinderProcess, Transfer_ActorOfProcessForFinder)
@ -104,8 +104,10 @@ protected:
Standard_Integer themodetrans; Standard_Integer themodetrans;
private: private:
ParameterMap myShapeProcParams; //!< Parameters for shape processing. // clang-format off
ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes. XSAlgo_ShapeProcessor::ParameterMap myShapeProcParams; //!< Parameters for shape processing.
XSAlgo_ShapeProcessor::ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes.
// clang-format on
}; };
#endif // _Transfer_ActorOfFinderProcess_HeaderFile #endif // _Transfer_ActorOfFinderProcess_HeaderFile

View File

@ -58,14 +58,16 @@ Handle(Standard_Transient) Transfer_ActorOfTransientProcess::TransferTransient(
//============================================================================= //=============================================================================
void Transfer_ActorOfTransientProcess::SetShapeFixParameters(const ParameterMap& theParameters) void Transfer_ActorOfTransientProcess::SetShapeFixParameters(
const XSAlgo_ShapeProcessor::ParameterMap& theParameters)
{ {
myShapeProcParams = theParameters; myShapeProcParams = theParameters;
} }
//============================================================================= //=============================================================================
void Transfer_ActorOfTransientProcess::SetShapeFixParameters(ParameterMap&& theParameters) void Transfer_ActorOfTransientProcess::SetShapeFixParameters(
XSAlgo_ShapeProcessor::ParameterMap&& theParameters)
{ {
myShapeProcParams = std::move(theParameters); myShapeProcParams = std::move(theParameters);
} }
@ -73,18 +75,12 @@ void Transfer_ActorOfTransientProcess::SetShapeFixParameters(ParameterMap&& theP
//============================================================================= //=============================================================================
void Transfer_ActorOfTransientProcess::SetShapeFixParameters( void Transfer_ActorOfTransientProcess::SetShapeFixParameters(
const DE_ShapeFixParameters& theParameters, const DE_ShapeFixParameters& theParameters,
const ParameterMap& theAdditionalParameters) const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters)
{ {
myShapeProcParams.clear(); XSAlgo_ShapeProcessor::SetShapeFixParameters(theParameters,
XSAlgo_ShapeProcessor::FillParameterMap(theParameters, true, myShapeProcParams); theAdditionalParameters,
for (const auto& aParam : theAdditionalParameters) myShapeProcParams);
{
if (myShapeProcParams.find(aParam.first) == myShapeProcParams.end())
{
myShapeProcParams[aParam.first] = aParam.second;
}
}
} }
//============================================================================= //=============================================================================

View File

@ -20,8 +20,7 @@
#include <ShapeProcess.hxx> #include <ShapeProcess.hxx>
#include <Standard.hxx> #include <Standard.hxx>
#include <Transfer_ActorOfProcessForTransient.hxx> #include <Transfer_ActorOfProcessForTransient.hxx>
#include <XSAlgo_ShapeProcessor.hxx>
#include <unordered_map>
struct DE_ShapeFixParameters; struct DE_ShapeFixParameters;
class Transfer_Binder; class Transfer_Binder;
@ -35,13 +34,6 @@ DEFINE_STANDARD_HANDLE(Transfer_ActorOfTransientProcess, Transfer_ActorOfProcess
//! The original class was renamed. Compatibility only //! The original class was renamed. Compatibility only
class Transfer_ActorOfTransientProcess : public Transfer_ActorOfProcessForTransient 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: public:
Standard_EXPORT Transfer_ActorOfTransientProcess(); Standard_EXPORT Transfer_ActorOfTransientProcess();
@ -62,12 +54,13 @@ public:
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(const ParameterMap& theParameters); Standard_EXPORT void SetShapeFixParameters(
const XSAlgo_ShapeProcessor::ParameterMap& theParameters);
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! Parameters are moved from the input map. //! Parameters are moved from the input map.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(ParameterMap&& theParameters); Standard_EXPORT void SetShapeFixParameters(XSAlgo_ShapeProcessor::ParameterMap&& theParameters);
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! Parameters from @p theParameters are copied to the internal map. //! Parameters from @p theParameters are copied to the internal map.
@ -75,12 +68,16 @@ public:
//! if they are not present in @p theParameters. //! if they are not present in @p theParameters.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
//! @param theAdditionalParameters the additional parameters for shape processing. //! @param theAdditionalParameters the additional parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, Standard_EXPORT void SetShapeFixParameters(
const ParameterMap& theAdditionalParameters = {}); const DE_ShapeFixParameters& theParameters,
const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters = {});
//! Returns parameters for shape processing that was set by SetParameters() method. //! Returns parameters for shape processing that was set by SetParameters() method.
//! @return the parameters for shape processing. Empty map if no parameters were set. //! @return the parameters for shape processing. Empty map if no parameters were set.
inline const ParameterMap& GetShapeFixParameters() const { return myShapeProcParams; } inline const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const
{
return myShapeProcParams;
}
//! Sets flags defining operations to be performed on shapes. //! Sets flags defining operations to be performed on shapes.
//! @param theFlags The flags defining operations to be performed on shapes. //! @param theFlags The flags defining operations to be performed on shapes.
@ -90,13 +87,18 @@ public:
//! @return Pair: the flags defining operations to be performed on shapes and a boolean value that //! @return Pair: the flags defining operations to be performed on shapes and a boolean value that
//! indicates //! indicates
//! whether the flags were set. //! whether the flags were set.
inline const ProcessingFlags& GetProcessingFlags() const { return myShapeProcFlags; } inline const XSAlgo_ShapeProcessor::ProcessingFlags& GetProcessingFlags() const
{
return myShapeProcFlags;
}
DEFINE_STANDARD_RTTIEXT(Transfer_ActorOfTransientProcess, Transfer_ActorOfProcessForTransient) DEFINE_STANDARD_RTTIEXT(Transfer_ActorOfTransientProcess, Transfer_ActorOfProcessForTransient)
private: private:
ParameterMap myShapeProcParams; //!< Parameters for shape processing. // clang-format off
ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes. XSAlgo_ShapeProcessor::ParameterMap myShapeProcParams; //!< Parameters for shape processing.
XSAlgo_ShapeProcessor::ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes.
// clang-format on
}; };
#endif // _Transfer_ActorOfTransientProcess_HeaderFile #endif // _Transfer_ActorOfTransientProcess_HeaderFile

View File

@ -39,47 +39,11 @@
#include <sstream> #include <sstream>
#include <unordered_set> #include <unordered_set>
namespace
{
//! Function to split a string based on multiple delimiters.
//! @param aString String to split.
//! @param delimiters Set of delimiters.
//! @return Vector of tokens.
std::vector<std::string> splitString(const std::string& aString,
const std::unordered_set<char>& delimiters)
{
std::vector<std::string> aResult;
std::string aCurrentToken;
for (char aCurrentCharacter : aString)
{
if (delimiters.find(aCurrentCharacter) != delimiters.end())
{
if (!aCurrentToken.empty())
{
aResult.emplace_back(std::move(aCurrentToken));
aCurrentToken.clear();
}
}
else
{
aCurrentToken += aCurrentCharacter;
}
}
if (!aCurrentToken.empty())
{
aResult.emplace_back(std::move(aCurrentToken));
}
return aResult;
}
} // namespace
//============================================================================= //=============================================================================
XSAlgo_ShapeProcessor::XSAlgo_ShapeProcessor(const ParameterMap& theParameters, XSAlgo_ShapeProcessor::XSAlgo_ShapeProcessor(
const DE_ShapeFixParameters& theShapeFixParameters) const XSAlgo_ShapeProcessor::ParameterMap& theParameters,
const DE_ShapeFixParameters& theShapeFixParameters)
: myParameters(theParameters) : myParameters(theParameters)
{ {
FillParameterMap(theShapeFixParameters, false, myParameters); FillParameterMap(theShapeFixParameters, false, myParameters);
@ -89,16 +53,16 @@ XSAlgo_ShapeProcessor::XSAlgo_ShapeProcessor(const ParameterMap& thePar
XSAlgo_ShapeProcessor::XSAlgo_ShapeProcessor(const DE_ShapeFixParameters& theParameters) XSAlgo_ShapeProcessor::XSAlgo_ShapeProcessor(const DE_ShapeFixParameters& theParameters)
{ {
ParameterMap aMap; XSAlgo_ShapeProcessor::ParameterMap aMap;
FillParameterMap(theParameters, false, aMap); FillParameterMap(theParameters, false, aMap);
myParameters = aMap; myParameters = aMap;
} }
//============================================================================= //=============================================================================
TopoDS_Shape XSAlgo_ShapeProcessor::ProcessShape(const TopoDS_Shape& theShape, TopoDS_Shape XSAlgo_ShapeProcessor::ProcessShape(const TopoDS_Shape& theShape,
const OperationsFlags& theOperations, const ShapeProcess::OperationsFlags& theOperations,
const Message_ProgressRange& theProgress) const Message_ProgressRange& theProgress)
{ {
if (theShape.IsNull()) if (theShape.IsNull())
{ {
@ -115,24 +79,25 @@ TopoDS_Shape XSAlgo_ShapeProcessor::ProcessShape(const TopoDS_Shape& th
void XSAlgo_ShapeProcessor::initializeContext(const TopoDS_Shape& theShape) void XSAlgo_ShapeProcessor::initializeContext(const TopoDS_Shape& theShape)
{ {
myContext = new ShapeProcess_ShapeContext(theShape, nullptr); myContext = new ShapeProcess_ShapeContext(theShape, nullptr);
for (const auto& aParameter : myParameters) for (XSAlgo_ShapeProcessor::ParameterMap::Iterator aParameterIter(myParameters);
aParameterIter.More();
aParameterIter.Next())
{ {
myContext->ResourceManager()->SetResource(aParameter.first.c_str(), aParameter.second.c_str()); myContext->ResourceManager()->SetResource(aParameterIter.Key().ToCString(),
aParameterIter.Value().ToCString());
} }
// Read and set detalization level. // Read and set detalization level.
auto aDetalizationLevelPtr = myParameters.find("DetalizationLevel"); TCollection_AsciiString aResult;
if (aDetalizationLevelPtr != myParameters.end()) if (myParameters.Find("DetalizationLevel", aResult) && aResult.IsIntegerValue())
{ {
const TopAbs_ShapeEnum aDetalizationLevel = const TopAbs_ShapeEnum aDetalizationLevel =
static_cast<TopAbs_ShapeEnum>(std::stoi(aDetalizationLevelPtr->second.c_str())); static_cast<TopAbs_ShapeEnum>(aResult.IntegerValue());
myContext->SetDetalisation(aDetalizationLevel); myContext->SetDetalisation(aDetalizationLevel);
} }
// Read and set non-manifold flag. // Read and set non-manifold flag.
auto aNonManifoldPtr = myParameters.find("NonManifold"); if (myParameters.Find("NonManifold", aResult) && aResult.IsIntegerValue())
if (aNonManifoldPtr != myParameters.end())
{ {
const Standard_Boolean aNonManifold = const Standard_Boolean aNonManifold = static_cast<Standard_Boolean>(aResult.IntegerValue());
static_cast<Standard_Boolean>(std::stoi(aNonManifoldPtr->second.c_str()));
myContext->SetNonManifold(aNonManifold); myContext->SetNonManifold(aNonManifold);
} }
} }
@ -547,10 +512,10 @@ Standard_Boolean XSAlgo_ShapeProcessor::CheckPCurve(const TopoDS_Edge& theEd
//============================================================================= //=============================================================================
XSAlgo_ShapeProcessor::ProcessingData XSAlgo_ShapeProcessor::ReadProcessingData( XSAlgo_ShapeProcessor::ProcessingData XSAlgo_ShapeProcessor::ReadProcessingData(
const std::string& theFileResourceName, const TCollection_AsciiString& theFileResourceName,
const std::string& theScopeResourceName) const TCollection_AsciiString& theScopeResourceName)
{ {
const Standard_CString aFileName = Interface_Static::CVal(theFileResourceName.c_str()); const Standard_CString aFileName = Interface_Static::CVal(theFileResourceName.ToCString());
Handle(ShapeProcess_ShapeContext) aContext = Handle(ShapeProcess_ShapeContext) aContext =
new ShapeProcess_ShapeContext(TopoDS_Shape(), aFileName); new ShapeProcess_ShapeContext(TopoDS_Shape(), aFileName);
if (!aContext->ResourceManager()->IsInitialized()) if (!aContext->ResourceManager()->IsInitialized())
@ -558,45 +523,49 @@ XSAlgo_ShapeProcessor::ProcessingData XSAlgo_ShapeProcessor::ReadProcessingData(
// If resource file wasn't found, use static values instead // If resource file wasn't found, use static values instead
Interface_Static::FillMap(aContext->ResourceManager()->GetMap()); Interface_Static::FillMap(aContext->ResourceManager()->GetMap());
} }
const std::string aScope = Interface_Static::CVal(theScopeResourceName.c_str()); const TCollection_AsciiString aScope = Interface_Static::CVal(theScopeResourceName.ToCString());
// Copy parameters to the result. // Copy parameters to the result.
ParameterMap aResultParameters; XSAlgo_ShapeProcessor::ParameterMap aResultParameters;
OperationsFlags aResultFlags; ShapeProcess::OperationsFlags aResultFlags;
const Resource_DataMapOfAsciiStringAsciiString& aMap = aContext->ResourceManager()->GetMap(); const Resource_DataMapOfAsciiStringAsciiString& aMap = aContext->ResourceManager()->GetMap();
using RMapIter = Resource_DataMapOfAsciiStringAsciiString::Iterator;
for (RMapIter anIter(aMap); anIter.More(); anIter.Next()) for (Resource_DataMapOfAsciiStringAsciiString::Iterator anIter(aMap); anIter.More();
anIter.Next())
{ {
std::string aKey = anIter.Key().ToCString(); TCollection_AsciiString aKey = anIter.Key();
const size_t aScopePosition = aKey.find(aScope); if (!aKey.StartsWith(aScope))
if (aScopePosition != 0)
{ {
// Ignore all parameters that don't start with the specified scope. // Ignore all parameters that don't start with the specified scope.
continue; continue;
} }
// Remove the scope from the key + 1 for the dot.
// Remove scope prefix and dot
// "FromIGES.FixShape.FixFreeFaceMode" -> "FixShape.FixFreeFaceMode" // "FromIGES.FixShape.FixFreeFaceMode" -> "FixShape.FixFreeFaceMode"
aKey.erase(0, aScope.size() + 1); aKey = aKey.SubString(aScope.Length() + 2, aKey.Length());
if (aKey != "exec.op")
if (aKey.IsEqual("exec.op"))
{ {
// If it is not an operation flag, add it to the parameters. // Parse operation flags using Token method
aResultParameters[aKey] = anIter.Value().ToCString(); Standard_Integer aTokenCount = 1;
} TCollection_AsciiString aToken;
else const TCollection_AsciiString aSeparators(" \t,;");
{
// Parse operations flags. while (!(aToken = anIter.Value().Token(aSeparators.ToCString(), aTokenCount)).IsEmpty())
const std::vector<std::string> anOperationStrings =
splitString(anIter.Value().ToCString(), {' ', '\t', ',', ';'});
for (const auto& anOperationString : anOperationStrings)
{ {
std::pair<ShapeProcess::Operation, bool> anOperationFlag = std::pair<ShapeProcess::Operation, Standard_Boolean> anOperationFlag =
ShapeProcess::ToOperationFlag(anOperationString.c_str()); ShapeProcess::ToOperationFlag(aToken.ToCString());
if (anOperationFlag.second) if (anOperationFlag.second)
{ {
aResultFlags.set(anOperationFlag.first); aResultFlags.set(anOperationFlag.first);
} }
aTokenCount++;
} }
} }
else
{
aResultParameters.Bind(aKey, anIter.Value());
}
} }
return {aResultParameters, aResultFlags}; return {aResultParameters, aResultFlags};
} }
@ -611,10 +580,13 @@ void XSAlgo_ShapeProcessor::FillParameterMap(const DE_ShapeFixParameters&
SetParameter("FixShape.MaxTolerance3d", theParameters.MaxTolerance3d, theIsReplace, theMap); SetParameter("FixShape.MaxTolerance3d", theParameters.MaxTolerance3d, theIsReplace, theMap);
SetParameter("FixShape.MinTolerance3d", theParameters.MinTolerance3d, theIsReplace, theMap); SetParameter("FixShape.MinTolerance3d", theParameters.MinTolerance3d, theIsReplace, theMap);
SetParameter("DetalizationLevel", SetParameter("DetalizationLevel",
std::to_string(theParameters.DetalizationLevel), TCollection_AsciiString(static_cast<int>(theParameters.DetalizationLevel)),
theIsReplace,
theMap);
SetParameter("NonManifold",
TCollection_AsciiString(static_cast<int>(theParameters.NonManifold)),
theIsReplace, theIsReplace,
theMap); theMap);
SetParameter("NonManifold", std::to_string(theParameters.NonManifold), theIsReplace, theMap);
SetParameter("FixShape.FixFreeShellMode", theParameters.FixFreeShellMode, theIsReplace, theMap); SetParameter("FixShape.FixFreeShellMode", theParameters.FixFreeShellMode, theIsReplace, theMap);
SetParameter("FixShape.FixFreeFaceMode", theParameters.FixFreeFaceMode, theIsReplace, theMap); SetParameter("FixShape.FixFreeFaceMode", theParameters.FixFreeFaceMode, theIsReplace, theMap);
SetParameter("FixShape.FixFreeWireMode", theParameters.FixFreeWireMode, theIsReplace, theMap); SetParameter("FixShape.FixFreeWireMode", theParameters.FixFreeWireMode, theIsReplace, theMap);
@ -743,48 +715,66 @@ void XSAlgo_ShapeProcessor::FillParameterMap(const DE_ShapeFixParameters&
//============================================================================= //=============================================================================
void XSAlgo_ShapeProcessor::SetParameter(const char* theKey, void XSAlgo_ShapeProcessor::SetShapeFixParameters(
DE_ShapeFixParameters::FixMode theValue, const DE_ShapeFixParameters& theParameters,
const bool theIsReplace, const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters,
ParameterMap& theMap) XSAlgo_ShapeProcessor::ParameterMap& theTargetParameterMap)
{ {
SetParameter(theKey, theTargetParameterMap.Clear();
std::to_string( XSAlgo_ShapeProcessor::FillParameterMap(theParameters, true, theTargetParameterMap);
static_cast<std::underlying_type<DE_ShapeFixParameters::FixMode>::type>(theValue)), for (XSAlgo_ShapeProcessor::ParameterMap::Iterator aParamIter(theAdditionalParameters);
theIsReplace, aParamIter.More();
theMap); aParamIter.Next())
{
if (!theTargetParameterMap.IsBound(aParamIter.Key()))
{
theTargetParameterMap.Bind(aParamIter.Key(), aParamIter.Value());
}
}
} }
//============================================================================= //=============================================================================
void XSAlgo_ShapeProcessor::SetParameter(const char* theKey, void XSAlgo_ShapeProcessor::SetParameter(const char* theKey,
double theValue, const DE_ShapeFixParameters::FixMode theValue,
const bool theIsReplace, const bool theIsReplace,
ParameterMap& theMap) XSAlgo_ShapeProcessor::ParameterMap& theMap)
{ {
// Note that conversion with std::to_string() here is not possible, since it normally preserves SetParameter(
// only first 6 digits (before C++26). As a result, any value of 1e-7 or below will turn into 0. theKey,
// By using std::ostringstream with std::setprecision(6) formatting we will preserve first 6 TCollection_AsciiString(static_cast<int>(
// SIGNIFICANT digits. static_cast<std::underlying_type<DE_ShapeFixParameters::FixMode>::type>(theValue))),
std::ostringstream aStrStream; theIsReplace,
aStrStream << std::setprecision(6) << theValue; theMap);
SetParameter(theKey, aStrStream.str(), theIsReplace, theMap);
} }
//============================================================================= //=============================================================================
void XSAlgo_ShapeProcessor::SetParameter(const char* theKey, void XSAlgo_ShapeProcessor::SetParameter(const char* theKey,
std::string&& theValue, const double theValue,
const bool theIsReplace, const bool theIsReplace,
ParameterMap& theMap) XSAlgo_ShapeProcessor::ParameterMap& theMap)
{
SetParameter(theKey, TCollection_AsciiString(theValue), theIsReplace, theMap);
}
//=============================================================================
void XSAlgo_ShapeProcessor::SetParameter(const char* theKey,
const TCollection_AsciiString& theValue,
const bool theIsReplace,
XSAlgo_ShapeProcessor::ParameterMap& theMap)
{ {
if (theIsReplace) if (theIsReplace)
{ {
theMap[theKey] = std::move(theValue); theMap.Bind(theKey, theValue);
} }
else else
{ {
theMap.emplace(theKey, std::move(theValue)); if (!theMap.IsBound(theKey))
{
theMap.Bind(theKey, theValue);
}
} }
} }

View File

@ -21,8 +21,6 @@
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx> #include <TopoDS_Face.hxx>
#include <unordered_map>
class ShapeProcess_ShapeContext; class ShapeProcess_ShapeContext;
class ShapeExtend_MsgRegistrator; class ShapeExtend_MsgRegistrator;
class Transfer_TransientProcess; class Transfer_TransientProcess;
@ -34,9 +32,12 @@ class Transfer_Binder;
class XSAlgo_ShapeProcessor class XSAlgo_ShapeProcessor
{ {
public: public:
using OperationsFlags = ShapeProcess::OperationsFlags; using ParameterMap = NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>;
using ParameterMap = std::unordered_map<std::string, std::string>; using ProcessingData = std::pair<ParameterMap, ShapeProcess::OperationsFlags>;
using ProcessingData = std::pair<ParameterMap, OperationsFlags>; // 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: public:
//! Constructor. //! Constructor.
@ -56,9 +57,9 @@ public:
//! @param theOperations Operations to be performed. //! @param theOperations Operations to be performed.
//! @param theProgress Progress indicator. //! @param theProgress Progress indicator.
//! @return Processed shape. May be the same as the input shape if no modifications were made. //! @return Processed shape. May be the same as the input shape if no modifications were made.
Standard_EXPORT TopoDS_Shape ProcessShape(const TopoDS_Shape& theShape, Standard_EXPORT TopoDS_Shape ProcessShape(const TopoDS_Shape& theShape,
const OperationsFlags& theOperations, const ShapeProcess::OperationsFlags& theOperations,
const Message_ProgressRange& theProgress); const Message_ProgressRange& theProgress);
//! Get the context of the last processing. //! Get the context of the last processing.
//! Only valid after the ProcessShape() method was called. //! Only valid after the ProcessShape() method was called.
@ -96,8 +97,9 @@ public:
//! of the scope. For example, parameter "read.iges.sequence" may contain string //! of the scope. For example, parameter "read.iges.sequence" may contain string
//! "FromIGES". //! "FromIGES".
//! @return Read parameter map. //! @return Read parameter map.
Standard_EXPORT static ProcessingData ReadProcessingData(const std::string& theFileResourceName, Standard_EXPORT static ProcessingData ReadProcessingData(
const std::string& theScopeResourceName); const TCollection_AsciiString& theFileResourceName,
const TCollection_AsciiString& theScopeResourceName);
//! Fill the parameter map with the values from the specified parameters. //! Fill the parameter map with the values from the specified parameters.
//! @param theParameters Parameters to be used in the processing. //! @param theParameters Parameters to be used in the processing.
@ -108,6 +110,39 @@ public:
const bool theIsReplace, const bool theIsReplace,
ParameterMap& theMap); ParameterMap& theMap);
//! Sets parameters for shape processing.
//! Parameters from @p theParameters are copied to the output map.
//! Parameters from @p theAdditionalParameters are copied to the output map
//! if they are not present in @p theParameters.
//! @param theParameters the parameters for shape processing.
//! @param theAdditionalParameters the additional parameters for shape processing.
//! @param theTargetParameterMap Map to set the parameters in.
Standard_EXPORT static void SetShapeFixParameters(const DE_ShapeFixParameters& theParameters,
const ParameterMap& theAdditionalParameters,
ParameterMap& theTargetParameterMap);
//! Set the parameter in the map.
//! @param theKey Key of the parameter.
//! @param theValue Value of the parameter.
//! @param theIsReplace Flag indicating whether parameter should be replaced if it already exists
//! in the map.
//! @param theMap Map to set the parameter in.
Standard_EXPORT static void SetParameter(const char* theKey,
const DE_ShapeFixParameters::FixMode theValue,
const bool theIsReplace,
XSAlgo_ShapeProcessor::ParameterMap& theMap);
//! Set the parameter in the map.
//! @param theKey Key of the parameter.
//! @param theValue Value of the parameter.
//! @param theIsReplace Flag indicating whether parameter should be replaced if it already exists
//! in the map.
//! @param theMap Map to set the parameter in.
Standard_EXPORT static void SetParameter(const char* theKey,
const double theValue,
const bool theIsReplace,
ParameterMap& theMap);
//! Set the parameter in the map. //! Set the parameter in the map.
//! @param theKey Key of the parameter. //! @param theKey Key of the parameter.
//! @param theValue Value of the parameter. //! @param theValue Value of the parameter.
@ -115,32 +150,10 @@ public:
//! in the map. //! in the map.
//! @param theMap Map to set the parameter in. //! @param theMap Map to set the parameter in.
Standard_EXPORT static void SetParameter(const char* theKey, Standard_EXPORT static void SetParameter(const char* theKey,
DE_ShapeFixParameters::FixMode theValue, const TCollection_AsciiString& theValue,
const bool theIsReplace, const bool theIsReplace,
ParameterMap& theMap); ParameterMap& theMap);
//! Set the parameter in the map.
//! @param theKey Key of the parameter.
//! @param theValue Value of the parameter.
//! @param theIsReplace Flag indicating whether parameter should be replaced if it already exists
//! in the map.
//! @param theMap Map to set the parameter in.
Standard_EXPORT static void SetParameter(const char* theKey,
double theValue,
const bool theIsReplace,
ParameterMap& theMap);
//! Set the parameter in the map.
//! @param theKey Key of the parameter.
//! @param theValue Value of the parameter.
//! @param theIsReplace Flag indicating whether parameter should be replaced if it already exists
//! in the map.
//! @param theMap Map to set the parameter in.
Standard_EXPORT static void SetParameter(const char* theKey,
std::string&& theValue,
const bool theIsReplace,
ParameterMap& theMap);
//! The function is designed to set the length unit for the application before performing a //! The function is designed to set the length unit for the application before performing a
//! transfer operation. It ensures that the length unit is correctly configured based on the //! transfer operation. It ensures that the length unit is correctly configured based on the
//! value associated with the key "xstep.cascade.unit". //! value associated with the key "xstep.cascade.unit".

View File

@ -413,7 +413,8 @@ void XSControl_Reader::GetStatsTransfer(const Handle(TColStd_HSequenceOfTransien
//============================================================================= //=============================================================================
void XSControl_Reader::SetShapeFixParameters(const ParameterMap& theParameters) void XSControl_Reader::SetShapeFixParameters(
const XSAlgo_ShapeProcessor::ParameterMap& theParameters)
{ {
if (Handle(Transfer_ActorOfTransientProcess) anActor = GetActor()) if (Handle(Transfer_ActorOfTransientProcess) anActor = GetActor())
{ {
@ -423,7 +424,7 @@ void XSControl_Reader::SetShapeFixParameters(const ParameterMap& theParameters)
//============================================================================= //=============================================================================
void XSControl_Reader::SetShapeFixParameters(ParameterMap&& theParameters) void XSControl_Reader::SetShapeFixParameters(XSAlgo_ShapeProcessor::ParameterMap&& theParameters)
{ {
if (Handle(Transfer_ActorOfTransientProcess) anActor = GetActor()) if (Handle(Transfer_ActorOfTransientProcess) anActor = GetActor())
{ {
@ -433,8 +434,9 @@ void XSControl_Reader::SetShapeFixParameters(ParameterMap&& theParameters)
//============================================================================= //=============================================================================
void XSControl_Reader::SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, void XSControl_Reader::SetShapeFixParameters(
const ParameterMap& theAdditionalParameters) const DE_ShapeFixParameters& theParameters,
const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters)
{ {
if (Handle(Transfer_ActorOfTransientProcess) anActor = GetActor()) if (Handle(Transfer_ActorOfTransientProcess) anActor = GetActor())
{ {
@ -444,10 +446,10 @@ void XSControl_Reader::SetShapeFixParameters(const DE_ShapeFixParameters& thePar
//============================================================================= //=============================================================================
const XSControl_Reader::ParameterMap& XSControl_Reader::GetShapeFixParameters() const const XSAlgo_ShapeProcessor::ParameterMap& XSControl_Reader::GetShapeFixParameters() const
{ {
static const ParameterMap anEmptyMap; static const XSAlgo_ShapeProcessor::ParameterMap anEmptyMap;
const Handle(Transfer_ActorOfTransientProcess) anActor = GetActor(); const Handle(Transfer_ActorOfTransientProcess) anActor = GetActor();
return anActor.IsNull() ? anEmptyMap : anActor->GetShapeFixParameters(); return anActor.IsNull() ? anEmptyMap : anActor->GetShapeFixParameters();
} }
@ -463,10 +465,10 @@ void XSControl_Reader::SetShapeProcessFlags(const ShapeProcess::OperationsFlags&
//============================================================================= //=============================================================================
const XSControl_Reader::ProcessingFlags& XSControl_Reader::GetShapeProcessFlags() const const XSAlgo_ShapeProcessor::ProcessingFlags& XSControl_Reader::GetShapeProcessFlags() const
{ {
static const ProcessingFlags anEmptyFlags; static const XSAlgo_ShapeProcessor::ProcessingFlags anEmptyFlags;
const Handle(Transfer_ActorOfTransientProcess) anActor = GetActor(); const Handle(Transfer_ActorOfTransientProcess) anActor = GetActor();
return anActor.IsNull() ? anEmptyFlags : anActor->GetProcessingFlags(); return anActor.IsNull() ? anEmptyFlags : anActor->GetProcessingFlags();
} }
@ -493,7 +495,7 @@ Handle(Transfer_ActorOfTransientProcess) XSControl_Reader::GetActor() const
void XSControl_Reader::InitializeMissingParameters() void XSControl_Reader::InitializeMissingParameters()
{ {
if (GetShapeFixParameters().empty()) if (GetShapeFixParameters().IsEmpty())
{ {
SetShapeFixParameters(GetDefaultShapeFixParameters()); SetShapeFixParameters(GetDefaultShapeFixParameters());
} }

View File

@ -30,8 +30,7 @@
#include <Standard_Integer.hxx> #include <Standard_Integer.hxx>
#include <IFSelect_PrintCount.hxx> #include <IFSelect_PrintCount.hxx>
#include <Message_ProgressRange.hxx> #include <Message_ProgressRange.hxx>
#include <XSAlgo_ShapeProcessor.hxx>
#include <unordered_map>
class XSControl_WorkSession; class XSControl_WorkSession;
class Interface_InterfaceModel; class Interface_InterfaceModel;
@ -75,12 +74,6 @@ class XSControl_Reader
public: public:
DEFINE_STANDARD_ALLOC DEFINE_STANDARD_ALLOC
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>;
//! Creates a Reader from scratch (creates an empty WorkSession) //! Creates a Reader from scratch (creates an empty WorkSession)
//! A WorkSession or a Controller must be provided before running //! A WorkSession or a Controller must be provided before running
Standard_EXPORT XSControl_Reader(); Standard_EXPORT XSControl_Reader();
@ -295,12 +288,13 @@ public:
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(const ParameterMap& theParameters); Standard_EXPORT void SetShapeFixParameters(
const XSAlgo_ShapeProcessor::ParameterMap& theParameters);
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! Parameters are moved from the input map. //! Parameters are moved from the input map.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(ParameterMap&& theParameters); Standard_EXPORT void SetShapeFixParameters(XSAlgo_ShapeProcessor::ParameterMap&& theParameters);
//! Sets parameters for shape processing. //! Sets parameters for shape processing.
//! Parameters from @p theParameters are copied to the internal map. //! Parameters from @p theParameters are copied to the internal map.
@ -308,12 +302,13 @@ public:
//! if they are not present in @p theParameters. //! if they are not present in @p theParameters.
//! @param theParameters the parameters for shape processing. //! @param theParameters the parameters for shape processing.
//! @param theAdditionalParameters the additional parameters for shape processing. //! @param theAdditionalParameters the additional parameters for shape processing.
Standard_EXPORT void SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, Standard_EXPORT void SetShapeFixParameters(
const ParameterMap& theAdditionalParameters = {}); const DE_ShapeFixParameters& theParameters,
const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters = {});
//! Returns parameters for shape processing that was set by SetParameters() method. //! Returns parameters for shape processing that was set by SetParameters() method.
//! @return the parameters for shape processing. Empty map if no parameters were set. //! @return the parameters for shape processing. Empty map if no parameters were set.
Standard_EXPORT const ParameterMap& GetShapeFixParameters() const; Standard_EXPORT const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const;
//! Sets flags defining operations to be performed on shapes. //! Sets flags defining operations to be performed on shapes.
//! @param theFlags The flags defining operations to be performed on shapes. //! @param theFlags The flags defining operations to be performed on shapes.
@ -322,7 +317,7 @@ public:
//! Returns flags defining operations to be performed on shapes. //! Returns flags defining operations to be performed on shapes.
//! @return Pair of values defining operations to be performed on shapes and a boolean value //! @return Pair of values defining operations to be performed on shapes and a boolean value
//! that indicates whether the flags were set. //! that indicates whether the flags were set.
Standard_EXPORT const ProcessingFlags& GetShapeProcessFlags() const; Standard_EXPORT const XSAlgo_ShapeProcessor::ProcessingFlags& GetShapeProcessFlags() const;
protected: protected:
//! Returns a sequence of produced shapes //! Returns a sequence of produced shapes

View File

@ -71,7 +71,7 @@ provider.IGES.OCC.healing.remove.small.area.face : -1
provider.IGES.OCC.healing.intersecting.wires : -1 provider.IGES.OCC.healing.intersecting.wires : -1
provider.IGES.OCC.healing.loop.wires : -1 provider.IGES.OCC.healing.loop.wires : -1
provider.IGES.OCC.healing.split.face : -1 provider.IGES.OCC.healing.split.face : -1
provider.IGES.OCC.healing.auto.correct.precision : -1 provider.IGES.OCC.healing.auto.correct.precision : 1
provider.IGES.OCC.healing.modify.topology : 0 provider.IGES.OCC.healing.modify.topology : 0
provider.IGES.OCC.healing.modify.geometry : 1 provider.IGES.OCC.healing.modify.geometry : 1
provider.IGES.OCC.healing.closed.wire : 1 provider.IGES.OCC.healing.closed.wire : 1
@ -217,7 +217,7 @@ provider.STEP.OCC.healing.remove.small.area.face : -1
provider.STEP.OCC.healing.intersecting.wires : -1 provider.STEP.OCC.healing.intersecting.wires : -1
provider.STEP.OCC.healing.loop.wires : -1 provider.STEP.OCC.healing.loop.wires : -1
provider.STEP.OCC.healing.split.face : -1 provider.STEP.OCC.healing.split.face : -1
provider.STEP.OCC.healing.auto.correct.precision : -1 provider.STEP.OCC.healing.auto.correct.precision : 1
provider.STEP.OCC.healing.modify.topology : 0 provider.STEP.OCC.healing.modify.topology : 0
provider.STEP.OCC.healing.modify.geometry : 1 provider.STEP.OCC.healing.modify.geometry : 1
provider.STEP.OCC.healing.closed.wire : 1 provider.STEP.OCC.healing.closed.wire : 1

View File

@ -65,7 +65,7 @@ provider.IGES.OCC.healing.remove.small.area.face : -1
provider.IGES.OCC.healing.intersecting.wires : -1 provider.IGES.OCC.healing.intersecting.wires : -1
provider.IGES.OCC.healing.loop.wires : -1 provider.IGES.OCC.healing.loop.wires : -1
provider.IGES.OCC.healing.split.face : -1 provider.IGES.OCC.healing.split.face : -1
provider.IGES.OCC.healing.auto.correct.precision : -1 provider.IGES.OCC.healing.auto.correct.precision : 1
provider.IGES.OCC.healing.modify.topology : 0 provider.IGES.OCC.healing.modify.topology : 0
provider.IGES.OCC.healing.modify.geometry : 1 provider.IGES.OCC.healing.modify.geometry : 1
provider.IGES.OCC.healing.closed.wire : 1 provider.IGES.OCC.healing.closed.wire : 1
@ -162,7 +162,7 @@ provider.STEP.OCC.healing.remove.small.area.face : -1
provider.STEP.OCC.healing.intersecting.wires : -1 provider.STEP.OCC.healing.intersecting.wires : -1
provider.STEP.OCC.healing.loop.wires : -1 provider.STEP.OCC.healing.loop.wires : -1
provider.STEP.OCC.healing.split.face : -1 provider.STEP.OCC.healing.split.face : -1
provider.STEP.OCC.healing.auto.correct.precision : -1 provider.STEP.OCC.healing.auto.correct.precision : 1
provider.STEP.OCC.healing.modify.topology : 0 provider.STEP.OCC.healing.modify.topology : 0
provider.STEP.OCC.healing.modify.geometry : 1 provider.STEP.OCC.healing.modify.geometry : 1
provider.STEP.OCC.healing.closed.wire : 1 provider.STEP.OCC.healing.closed.wire : 1