diff --git a/src/DE/DE_ShapeFixParameters.hxx b/src/DE/DE_ShapeFixParameters.hxx index 3c9e12af72..cc308295a9 100644 --- a/src/DE/DE_ShapeFixParameters.hxx +++ b/src/DE/DE_ShapeFixParameters.hxx @@ -52,7 +52,7 @@ struct DE_ShapeFixParameters FixMode FixIntersectingWiresMode = FixMode::FixOrNot; FixMode FixLoopWiresMode = FixMode::FixOrNot; FixMode FixSplitFaceMode = FixMode::FixOrNot; - FixMode AutoCorrectPrecisionMode = FixMode::FixOrNot; + FixMode AutoCorrectPrecisionMode = FixMode::Fix; FixMode ModifyTopologyMode = FixMode::NotFix; FixMode ModifyGeometryMode = FixMode::Fix; FixMode ClosedWireMode = FixMode::Fix; diff --git a/src/IGESControl/IGESControl_Writer.cxx b/src/IGESControl/IGESControl_Writer.cxx index c635ba7e86..ed34396126 100644 --- a/src/IGESControl/IGESControl_Writer.cxx +++ b/src/IGESControl/IGESControl_Writer.cxx @@ -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; } //============================================================================= -void IGESControl_Writer::SetShapeFixParameters(ParameterMap&& theParameters) +void IGESControl_Writer::SetShapeFixParameters(XSAlgo_ShapeProcessor::ParameterMap&& theParameters) { myShapeProcParams = std::move(theParameters); } //============================================================================= -void IGESControl_Writer::SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, - const ParameterMap& theAdditionalParameters) +void IGESControl_Writer::SetShapeFixParameters( + const DE_ShapeFixParameters& theParameters, + const XSAlgo_ShapeProcessor::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; - } - } + XSAlgo_ShapeProcessor::SetShapeFixParameters(theParameters, + theAdditionalParameters, + myShapeProcParams); } //============================================================================= @@ -325,7 +321,7 @@ void IGESControl_Writer::SetShapeProcessFlags(const ShapeProcess::OperationsFlag void IGESControl_Writer::InitializeMissingParameters() { - if (GetShapeFixParameters().empty()) + if (GetShapeFixParameters().IsEmpty()) { SetShapeFixParameters(DEIGES_Parameters::GetDefaultShapeFixParameters()); } diff --git a/src/IGESControl/IGESControl_Writer.hxx b/src/IGESControl/IGESControl_Writer.hxx index cce6e0e525..ec3e224d41 100644 --- a/src/IGESControl/IGESControl_Writer.hxx +++ b/src/IGESControl/IGESControl_Writer.hxx @@ -26,8 +26,7 @@ #include #include #include - -#include +#include struct DE_ShapeFixParameters; class Transfer_FinderProcess; @@ -51,12 +50,6 @@ class IGESControl_Writer public: DEFINE_STANDARD_ALLOC - using ParameterMap = std::unordered_map; - // 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; - public: //! Creates a writer object with the //! default unit (millimeters) and write mode (Face). @@ -126,12 +119,13 @@ public: //! Sets 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. //! Parameters are moved from the input map. //! @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. //! Parameters from @p theParameters are copied to the internal map. @@ -139,12 +133,16 @@ public: //! 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 SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, - const ParameterMap& theAdditionalParameters = {}); + Standard_EXPORT void SetShapeFixParameters( + const DE_ShapeFixParameters& theParameters, + const XSAlgo_ShapeProcessor::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& GetShapeFixParameters() const { return myShapeProcParams; } + inline const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const + { + return myShapeProcParams; + } //! Sets 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; Standard_Integer myWriteMode; Standard_Boolean myIsComputed; - ParameterMap myShapeProcParams; //!< Parameters for shape processing. - ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes. + // clang-format off + 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 diff --git a/src/IGESToBRep/IGESToBRep_Actor.cxx b/src/IGESToBRep/IGESToBRep_Actor.cxx index 250eb79861..563c89cbdc 100644 --- a/src/IGESToBRep/IGESToBRep_Actor.cxx +++ b/src/IGESToBRep/IGESToBRep_Actor.cxx @@ -199,7 +199,7 @@ Handle(Transfer_Binder) IGESToBRep_Actor::Transfer(const Handle(Standard_Transie // Set tolerances for shape processing. // These parameters are calculated inside IGESToBRep_Actor::Transfer() and cannot be set from // outside. - Transfer_ActorOfTransientProcess::ParameterMap aParameters = GetShapeFixParameters(); + XSAlgo_ShapeProcessor::ParameterMap aParameters = GetShapeFixParameters(); XSAlgo_ShapeProcessor::SetParameter("FixShape.Tolerance3d", theeps, true, aParameters); XSAlgo_ShapeProcessor::SetParameter("FixShape.MaxTolerance3d", CAS.GetMaxTol(), diff --git a/src/IGESToBRep/IGESToBRep_Reader.cxx b/src/IGESToBRep/IGESToBRep_Reader.cxx index acdb58b862..a8ead9f574 100644 --- a/src/IGESToBRep/IGESToBRep_Reader.cxx +++ b/src/IGESToBRep/IGESToBRep_Reader.cxx @@ -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; } //============================================================================= -void IGESToBRep_Reader::SetShapeFixParameters(ParameterMap&& theParameters) +void IGESToBRep_Reader::SetShapeFixParameters(XSAlgo_ShapeProcessor::ParameterMap&& theParameters) { myShapeProcParams = std::move(theParameters); } //============================================================================= -void IGESToBRep_Reader::SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, - const ParameterMap& theAdditionalParameters) +void IGESToBRep_Reader::SetShapeFixParameters( + const DE_ShapeFixParameters& theParameters, + const XSAlgo_ShapeProcessor::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; - } - } + XSAlgo_ShapeProcessor::SetShapeFixParameters(theParameters, + theAdditionalParameters, + myShapeProcParams); } //============================================================================= @@ -657,7 +653,7 @@ void IGESToBRep_Reader::SetShapeProcessFlags(const ShapeProcess::OperationsFlags void IGESToBRep_Reader::InitializeMissingParameters() { - if (GetShapeFixParameters().empty()) + if (GetShapeFixParameters().IsEmpty()) { SetShapeFixParameters(DEIGES_Parameters::GetDefaultShapeFixParameters()); } diff --git a/src/IGESToBRep/IGESToBRep_Reader.hxx b/src/IGESToBRep/IGESToBRep_Reader.hxx index c064cce730..cc56eb5cb9 100644 --- a/src/IGESToBRep/IGESToBRep_Reader.hxx +++ b/src/IGESToBRep/IGESToBRep_Reader.hxx @@ -25,8 +25,7 @@ #include #include #include - -#include +#include struct DE_ShapeFixParameters; class IGESData_IGESModel; @@ -41,12 +40,6 @@ class IGESToBRep_Reader public: DEFINE_STANDARD_ALLOC - using ParameterMap = std::unordered_map; - // 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; - public: //! Creates a Reader Standard_EXPORT IGESToBRep_Reader(); @@ -120,12 +113,13 @@ public: //! Sets 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. //! Parameters are moved from the input map. //! @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. //! Parameters from @p theParameters are copied to the internal map. @@ -133,12 +127,16 @@ public: //! 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 SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, - const ParameterMap& theAdditionalParameters = {}); + Standard_EXPORT void SetShapeFixParameters( + const DE_ShapeFixParameters& theParameters, + const XSAlgo_ShapeProcessor::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& GetShapeFixParameters() const { return myShapeProcParams; } + inline const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const + { + return myShapeProcParams; + } //! Sets 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; Handle(IGESToBRep_Actor) theActor; Handle(Transfer_TransientProcess) theProc; - ParameterMap myShapeProcParams; //!< Parameters for shape processing. - ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes. + // clang-format off + 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 diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.cxx b/src/STEPCAFControl/STEPCAFControl_Reader.cxx index abe9db9464..fa90a96f35 100644 --- a/src/STEPCAFControl/STEPCAFControl_Reader.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Reader.cxx @@ -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); } //============================================================================= -void STEPCAFControl_Reader::SetShapeFixParameters(ParameterMap&& theParameters) +void STEPCAFControl_Reader::SetShapeFixParameters( + XSAlgo_ShapeProcessor::ParameterMap&& theParameters) { myReader.SetShapeFixParameters(std::move(theParameters)); } //============================================================================= -void STEPCAFControl_Reader::SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, - const ParameterMap& theAdditionalParameters) +void STEPCAFControl_Reader::SetShapeFixParameters( + const DE_ShapeFixParameters& theParameters, + const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters) { myReader.SetShapeFixParameters(theParameters, theAdditionalParameters); } //============================================================================= -const STEPCAFControl_Reader::ParameterMap& STEPCAFControl_Reader::GetShapeFixParameters() const +const XSAlgo_ShapeProcessor::ParameterMap& STEPCAFControl_Reader::GetShapeFixParameters() const { 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(); } diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.hxx b/src/STEPCAFControl/STEPCAFControl_Reader.hxx index b1a6562cc5..85bebe97ba 100644 --- a/src/STEPCAFControl/STEPCAFControl_Reader.hxx +++ b/src/STEPCAFControl/STEPCAFControl_Reader.hxx @@ -62,9 +62,6 @@ class STEPCAFControl_Reader public: DEFINE_STANDARD_ALLOC - using ParameterMap = XSControl_Reader::ParameterMap; - using ProcessingFlags = XSControl_Reader::ProcessingFlags; - public: //! Creates a reader with an empty //! STEP model and sets ColorMode, LayerMode, NameMode and @@ -230,12 +227,13 @@ public: //! Sets 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. //! Parameters are moved from the input map. //! @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. //! Parameters from @p theParameters are copied to the internal map. @@ -243,12 +241,13 @@ public: //! 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 SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, - const ParameterMap& theAdditionalParameters = {}); + Standard_EXPORT void SetShapeFixParameters( + const DE_ShapeFixParameters& theParameters, + const XSAlgo_ShapeProcessor::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. - Standard_EXPORT const ParameterMap& GetShapeFixParameters() const; + Standard_EXPORT const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const; //! Sets 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. //! @return Pair of values defining operations to be performed on shapes and a boolean value //! that indicates whether the flags were set. - Standard_EXPORT const ProcessingFlags& GetShapeProcessFlags() const; + Standard_EXPORT const XSAlgo_ShapeProcessor::ProcessingFlags& GetShapeProcessFlags() const; protected: //! Translates STEP file already loaded into the reader diff --git a/src/STEPCAFControl/STEPCAFControl_Writer.cxx b/src/STEPCAFControl/STEPCAFControl_Writer.cxx index cc513d913e..1353c6d338 100644 --- a/src/STEPCAFControl/STEPCAFControl_Writer.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Writer.cxx @@ -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); } //============================================================================= -void STEPCAFControl_Writer::SetShapeFixParameters(ParameterMap&& theParameters) +void STEPCAFControl_Writer::SetShapeFixParameters( + XSAlgo_ShapeProcessor::ParameterMap&& theParameters) { myWriter.SetShapeFixParameters(std::move(theParameters)); } //============================================================================= -void STEPCAFControl_Writer::SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, - const ParameterMap& theAdditionalParameters) +void STEPCAFControl_Writer::SetShapeFixParameters( + const DE_ShapeFixParameters& theParameters, + const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters) { myWriter.SetShapeFixParameters(theParameters, theAdditionalParameters); } //============================================================================= -const STEPCAFControl_Writer::ParameterMap& STEPCAFControl_Writer::GetShapeFixParameters() const +const XSAlgo_ShapeProcessor::ParameterMap& STEPCAFControl_Writer::GetShapeFixParameters() const { 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(); } diff --git a/src/STEPCAFControl/STEPCAFControl_Writer.hxx b/src/STEPCAFControl/STEPCAFControl_Writer.hxx index c0bb33c96c..bfc0933e8a 100644 --- a/src/STEPCAFControl/STEPCAFControl_Writer.hxx +++ b/src/STEPCAFControl/STEPCAFControl_Writer.hxx @@ -52,9 +52,6 @@ class STEPCAFControl_Writer public: DEFINE_STANDARD_ALLOC - using ParameterMap = STEPControl_Writer::ParameterMap; - using ProcessingFlags = STEPControl_Writer::ProcessingFlags; - public: //! Creates a writer with an empty //! STEP model and sets ColorMode, LayerMode, NameMode and @@ -231,12 +228,13 @@ public: //! Sets 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. //! Parameters are moved from the input map. //! @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. //! Parameters from @p theParameters are copied to the internal map. @@ -244,12 +242,13 @@ public: //! 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 SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, - const ParameterMap& theAdditionalParameters = {}); + Standard_EXPORT void SetShapeFixParameters( + const DE_ShapeFixParameters& theParameters, + const XSAlgo_ShapeProcessor::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. - Standard_EXPORT const ParameterMap& GetShapeFixParameters() const; + Standard_EXPORT const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const; //! Sets 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. //! @return Pair of values defining operations to be performed on shapes and a boolean value //! that indicates whether the flags were set. - Standard_EXPORT const ProcessingFlags& GetShapeProcessFlags() const; + Standard_EXPORT const XSAlgo_ShapeProcessor::ProcessingFlags& GetShapeProcessFlags() const; protected: //! Transfers labels to a STEP model diff --git a/src/STEPControl/STEPControl_ActorRead.cxx b/src/STEPControl/STEPControl_ActorRead.cxx index 8647ec0d71..2f365aac50 100644 --- a/src/STEPControl/STEPControl_ActorRead.cxx +++ b/src/STEPControl/STEPControl_ActorRead.cxx @@ -1000,13 +1000,10 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity( // Set tolerances for shape processing. // These parameters are calculated inside STEPControl_ActorRead::Transfer() and cannot be set // from outside. - Transfer_ActorOfTransientProcess::ParameterMap aParameters = GetShapeFixParameters(); + XSAlgo_ShapeProcessor::ParameterMap aParameters = GetShapeFixParameters(); XSAlgo_ShapeProcessor::SetParameter("FixShape.Tolerance3d", myPrecision, true, aParameters); XSAlgo_ShapeProcessor::SetParameter("FixShape.MaxTolerance3d", myMaxTol, true, aParameters); - XSAlgo_ShapeProcessor::SetParameter("FixShape.NonManifold", - std::to_string(true), - true, - aParameters); + XSAlgo_ShapeProcessor::SetParameter("FixShape.NonManifold", "1", true, aParameters); XSAlgo_ShapeProcessor aShapeProcessor(aParameters); TopoDS_Shape fixedResult = aShapeProcessor.ProcessShape(comp, GetProcessingFlags().first, aPS1.Next()); @@ -1698,7 +1695,7 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity( // Set tolerances for shape processing. // These parameters are calculated inside STEPControl_ActorRead::Transfer() and cannot be set // from outside. - Transfer_ActorOfTransientProcess::ParameterMap aParameters = GetShapeFixParameters(); + XSAlgo_ShapeProcessor::ParameterMap aParameters = GetShapeFixParameters(); XSAlgo_ShapeProcessor::SetParameter("FixShape.Tolerance3d", myPrecision, true, aParameters); XSAlgo_ShapeProcessor::SetParameter("FixShape.MaxTolerance3d", myMaxTol, true, aParameters); XSAlgo_ShapeProcessor aShapeProcessor(aParameters); @@ -1885,7 +1882,7 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity( { 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.MaxTolerance3d", myMaxTol, true, aParameters); XSAlgo_ShapeProcessor aShapeProcessor(aParameters); diff --git a/src/STEPControl/STEPControl_ActorWrite.cxx b/src/STEPControl/STEPControl_ActorWrite.cxx index 283c43e1b0..4f4b1e0dc1 100644 --- a/src/STEPControl/STEPControl_ActorWrite.cxx +++ b/src/STEPControl/STEPControl_ActorWrite.cxx @@ -1045,7 +1045,7 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferShape( 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.MaxTolerance3d", aStepModel->InternalParameters.ReadMaxPrecisionVal, diff --git a/src/STEPControl/STEPControl_Writer.cxx b/src/STEPControl/STEPControl_Writer.cxx index 2437a66de5..6484ec6ff1 100644 --- a/src/STEPControl/STEPControl_Writer.cxx +++ b/src/STEPControl/STEPControl_Writer.cxx @@ -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()) { @@ -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()) { @@ -219,8 +220,9 @@ void STEPControl_Writer::SetShapeFixParameters(ParameterMap&& theParameters) //============================================================================= -void STEPControl_Writer::SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, - const ParameterMap& theAdditionalParameters) +void STEPControl_Writer::SetShapeFixParameters( + const DE_ShapeFixParameters& theParameters, + const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters) { 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; - const Handle(Transfer_ActorOfFinderProcess) anActor = GetActor(); + static const XSAlgo_ShapeProcessor::ParameterMap anEmptyMap; + const Handle(Transfer_ActorOfFinderProcess) anActor = GetActor(); 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; - const Handle(Transfer_ActorOfFinderProcess) anActor = GetActor(); + static const XSAlgo_ShapeProcessor::ProcessingFlags anEmptyFlags; + const Handle(Transfer_ActorOfFinderProcess) anActor = GetActor(); return anActor.IsNull() ? anEmptyFlags : anActor->GetShapeProcessFlags(); } @@ -279,7 +281,7 @@ Handle(Transfer_ActorOfFinderProcess) STEPControl_Writer::GetActor() const void STEPControl_Writer::InitializeMissingParameters() { - if (GetShapeFixParameters().empty()) + if (GetShapeFixParameters().IsEmpty()) { SetShapeFixParameters(DESTEP_Parameters::GetDefaultShapeFixParameters()); } diff --git a/src/STEPControl/STEPControl_Writer.hxx b/src/STEPControl/STEPControl_Writer.hxx index 5c7905095d..81c706f651 100644 --- a/src/STEPControl/STEPControl_Writer.hxx +++ b/src/STEPControl/STEPControl_Writer.hxx @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -46,12 +47,6 @@ class STEPControl_Writer public: DEFINE_STANDARD_ALLOC - using ParameterMap = std::unordered_map; - // 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; - //! Creates a Writer from scratch Standard_EXPORT STEPControl_Writer(); @@ -138,12 +133,13 @@ public: //! Sets 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. //! Parameters are moved from the input map. //! @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. //! Parameters from @p theParameters are copied to the internal map. @@ -151,12 +147,13 @@ public: //! 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 SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, - const ParameterMap& theAdditionalParameters = {}); + Standard_EXPORT void SetShapeFixParameters( + const DE_ShapeFixParameters& theParameters, + const XSAlgo_ShapeProcessor::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. - Standard_EXPORT const ParameterMap& GetShapeFixParameters() const; + Standard_EXPORT const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const; //! Sets 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. //! @return Pair of values defining operations to be performed on shapes and a boolean value //! that indicates whether the flags were set. - Standard_EXPORT const ProcessingFlags& GetShapeProcessFlags() const; + Standard_EXPORT const XSAlgo_ShapeProcessor::ProcessingFlags& GetShapeProcessFlags() const; private: //! Returns the Actor for the Transfer of an Entity. diff --git a/src/ShapeProcess/ShapeProcess.cxx b/src/ShapeProcess/ShapeProcess.cxx index 4d7fcb670b..dd56dd78d0 100644 --- a/src/ShapeProcess/ShapeProcess.cxx +++ b/src/ShapeProcess/ShapeProcess.cxx @@ -180,9 +180,9 @@ Standard_Boolean ShapeProcess::Perform(const Handle(ShapeProcess_Context)& conte //================================================================================================= -Standard_Boolean ShapeProcess::Perform(const Handle(ShapeProcess_Context)& theContext, - const OperationsFlags& theOperations, - const Message_ProgressRange& theProgress) +Standard_Boolean ShapeProcess::Perform(const Handle(ShapeProcess_Context)& theContext, + const ShapeProcess::OperationsFlags& theOperations, + const Message_ProgressRange& theProgress) { if (!theContext) { @@ -246,7 +246,7 @@ std::pair ShapeProcess::ToOperationFlag(const cha //================================================================================================= std::vector> ShapeProcess::getOperators( - const OperationsFlags& theFlags) + const ShapeProcess::OperationsFlags& theFlags) { std::vector> aResult; for (std::underlying_type::type anOperation = Operation::First; diff --git a/src/Transfer/Transfer_ActorOfFinderProcess.cxx b/src/Transfer/Transfer_ActorOfFinderProcess.cxx index 4e94b8e2b8..c286b09661 100644 --- a/src/Transfer/Transfer_ActorOfFinderProcess.cxx +++ b/src/Transfer/Transfer_ActorOfFinderProcess.cxx @@ -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; } //============================================================================= -void Transfer_ActorOfFinderProcess::SetShapeFixParameters(ParameterMap&& theParameters) +void Transfer_ActorOfFinderProcess::SetShapeFixParameters( + XSAlgo_ShapeProcessor::ParameterMap&& theParameters) { myShapeProcParams = std::move(theParameters); } @@ -91,18 +93,12 @@ void Transfer_ActorOfFinderProcess::SetShapeFixParameters(ParameterMap&& thePara //============================================================================= void Transfer_ActorOfFinderProcess::SetShapeFixParameters( - const DE_ShapeFixParameters& theParameters, - const ParameterMap& theAdditionalParameters) + const DE_ShapeFixParameters& theParameters, + const XSAlgo_ShapeProcessor::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; - } - } + XSAlgo_ShapeProcessor::SetShapeFixParameters(theParameters, + theAdditionalParameters, + myShapeProcParams); } //============================================================================= diff --git a/src/Transfer/Transfer_ActorOfFinderProcess.hxx b/src/Transfer/Transfer_ActorOfFinderProcess.hxx index 87603c46cb..be4b675557 100644 --- a/src/Transfer/Transfer_ActorOfFinderProcess.hxx +++ b/src/Transfer/Transfer_ActorOfFinderProcess.hxx @@ -20,8 +20,7 @@ #include #include #include - -#include +#include struct DE_ShapeFixParameters; class Transfer_Binder; @@ -39,13 +38,6 @@ 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; - // 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; - public: Standard_EXPORT Transfer_ActorOfFinderProcess(); @@ -69,12 +61,13 @@ public: //! Sets 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. //! Parameters are moved from the input map. //! @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. //! Parameters from @p theParameters are copied to the internal map. @@ -82,12 +75,16 @@ public: //! 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 SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, - const ParameterMap& theAdditionalParameters = {}); + Standard_EXPORT void SetShapeFixParameters( + const DE_ShapeFixParameters& theParameters, + const XSAlgo_ShapeProcessor::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& GetShapeFixParameters() const { return myShapeProcParams; } + inline const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const + { + return myShapeProcParams; + } //! Sets 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. //! @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; } + inline const XSAlgo_ShapeProcessor::ProcessingFlags& GetShapeProcessFlags() const + { + return myShapeProcFlags; + } DEFINE_STANDARD_RTTIEXT(Transfer_ActorOfFinderProcess, Transfer_ActorOfProcessForFinder) @@ -104,8 +104,10 @@ protected: Standard_Integer themodetrans; private: - ParameterMap myShapeProcParams; //!< Parameters for shape processing. - ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes. + // clang-format off + 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 diff --git a/src/Transfer/Transfer_ActorOfTransientProcess.cxx b/src/Transfer/Transfer_ActorOfTransientProcess.cxx index 520beabbfe..163c7b8366 100644 --- a/src/Transfer/Transfer_ActorOfTransientProcess.cxx +++ b/src/Transfer/Transfer_ActorOfTransientProcess.cxx @@ -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; } //============================================================================= -void Transfer_ActorOfTransientProcess::SetShapeFixParameters(ParameterMap&& theParameters) +void Transfer_ActorOfTransientProcess::SetShapeFixParameters( + XSAlgo_ShapeProcessor::ParameterMap&& theParameters) { myShapeProcParams = std::move(theParameters); } @@ -73,18 +75,12 @@ void Transfer_ActorOfTransientProcess::SetShapeFixParameters(ParameterMap&& theP //============================================================================= void Transfer_ActorOfTransientProcess::SetShapeFixParameters( - const DE_ShapeFixParameters& theParameters, - const ParameterMap& theAdditionalParameters) + const DE_ShapeFixParameters& theParameters, + const XSAlgo_ShapeProcessor::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; - } - } + XSAlgo_ShapeProcessor::SetShapeFixParameters(theParameters, + theAdditionalParameters, + myShapeProcParams); } //============================================================================= diff --git a/src/Transfer/Transfer_ActorOfTransientProcess.hxx b/src/Transfer/Transfer_ActorOfTransientProcess.hxx index c226423abb..650c48d8da 100644 --- a/src/Transfer/Transfer_ActorOfTransientProcess.hxx +++ b/src/Transfer/Transfer_ActorOfTransientProcess.hxx @@ -20,8 +20,7 @@ #include #include #include - -#include +#include struct DE_ShapeFixParameters; class Transfer_Binder; @@ -35,13 +34,6 @@ 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; - // 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; - public: Standard_EXPORT Transfer_ActorOfTransientProcess(); @@ -62,12 +54,13 @@ public: //! Sets 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. //! Parameters are moved from the input map. //! @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. //! Parameters from @p theParameters are copied to the internal map. @@ -75,12 +68,16 @@ public: //! 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 SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, - const ParameterMap& theAdditionalParameters = {}); + Standard_EXPORT void SetShapeFixParameters( + const DE_ShapeFixParameters& theParameters, + const XSAlgo_ShapeProcessor::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& GetShapeFixParameters() const { return myShapeProcParams; } + inline const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const + { + return myShapeProcParams; + } //! Sets 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 //! indicates //! 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) private: - ParameterMap myShapeProcParams; //!< Parameters for shape processing. - ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes. + // clang-format off + 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 diff --git a/src/XSAlgo/XSAlgo_ShapeProcessor.cxx b/src/XSAlgo/XSAlgo_ShapeProcessor.cxx index f8dc121097..511bb08b3a 100644 --- a/src/XSAlgo/XSAlgo_ShapeProcessor.cxx +++ b/src/XSAlgo/XSAlgo_ShapeProcessor.cxx @@ -39,47 +39,11 @@ #include #include -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 splitString(const std::string& aString, - const std::unordered_set& delimiters) -{ - std::vector 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, - const DE_ShapeFixParameters& theShapeFixParameters) +XSAlgo_ShapeProcessor::XSAlgo_ShapeProcessor( + const XSAlgo_ShapeProcessor::ParameterMap& theParameters, + const DE_ShapeFixParameters& theShapeFixParameters) : myParameters(theParameters) { FillParameterMap(theShapeFixParameters, false, myParameters); @@ -89,16 +53,16 @@ XSAlgo_ShapeProcessor::XSAlgo_ShapeProcessor(const ParameterMap& thePar XSAlgo_ShapeProcessor::XSAlgo_ShapeProcessor(const DE_ShapeFixParameters& theParameters) { - ParameterMap aMap; + XSAlgo_ShapeProcessor::ParameterMap aMap; FillParameterMap(theParameters, false, aMap); myParameters = aMap; } //============================================================================= -TopoDS_Shape XSAlgo_ShapeProcessor::ProcessShape(const TopoDS_Shape& theShape, - const OperationsFlags& theOperations, - const Message_ProgressRange& theProgress) +TopoDS_Shape XSAlgo_ShapeProcessor::ProcessShape(const TopoDS_Shape& theShape, + const ShapeProcess::OperationsFlags& theOperations, + const Message_ProgressRange& theProgress) { if (theShape.IsNull()) { @@ -115,24 +79,25 @@ TopoDS_Shape XSAlgo_ShapeProcessor::ProcessShape(const TopoDS_Shape& th void XSAlgo_ShapeProcessor::initializeContext(const TopoDS_Shape& theShape) { 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. - auto aDetalizationLevelPtr = myParameters.find("DetalizationLevel"); - if (aDetalizationLevelPtr != myParameters.end()) + TCollection_AsciiString aResult; + if (myParameters.Find("DetalizationLevel", aResult) && aResult.IsIntegerValue()) { const TopAbs_ShapeEnum aDetalizationLevel = - static_cast(std::stoi(aDetalizationLevelPtr->second.c_str())); + static_cast(aResult.IntegerValue()); myContext->SetDetalisation(aDetalizationLevel); } // Read and set non-manifold flag. - auto aNonManifoldPtr = myParameters.find("NonManifold"); - if (aNonManifoldPtr != myParameters.end()) + if (myParameters.Find("NonManifold", aResult) && aResult.IsIntegerValue()) { - const Standard_Boolean aNonManifold = - static_cast(std::stoi(aNonManifoldPtr->second.c_str())); + const Standard_Boolean aNonManifold = static_cast(aResult.IntegerValue()); myContext->SetNonManifold(aNonManifold); } } @@ -547,10 +512,10 @@ Standard_Boolean XSAlgo_ShapeProcessor::CheckPCurve(const TopoDS_Edge& theEd //============================================================================= XSAlgo_ShapeProcessor::ProcessingData XSAlgo_ShapeProcessor::ReadProcessingData( - const std::string& theFileResourceName, - const std::string& theScopeResourceName) + const TCollection_AsciiString& theFileResourceName, + 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 = new ShapeProcess_ShapeContext(TopoDS_Shape(), aFileName); if (!aContext->ResourceManager()->IsInitialized()) @@ -558,45 +523,49 @@ XSAlgo_ShapeProcessor::ProcessingData XSAlgo_ShapeProcessor::ReadProcessingData( // If resource file wasn't found, use static values instead 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. - ParameterMap aResultParameters; - OperationsFlags aResultFlags; + XSAlgo_ShapeProcessor::ParameterMap aResultParameters; + ShapeProcess::OperationsFlags aResultFlags; 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(); - const size_t aScopePosition = aKey.find(aScope); - if (aScopePosition != 0) + TCollection_AsciiString aKey = anIter.Key(); + if (!aKey.StartsWith(aScope)) { // Ignore all parameters that don't start with the specified scope. continue; } - // Remove the scope from the key + 1 for the dot. + + // Remove scope prefix and dot // "FromIGES.FixShape.FixFreeFaceMode" -> "FixShape.FixFreeFaceMode" - aKey.erase(0, aScope.size() + 1); - if (aKey != "exec.op") + aKey = aKey.SubString(aScope.Length() + 2, aKey.Length()); + + if (aKey.IsEqual("exec.op")) { - // If it is not an operation flag, add it to the parameters. - aResultParameters[aKey] = anIter.Value().ToCString(); - } - else - { - // Parse operations flags. - const std::vector anOperationStrings = - splitString(anIter.Value().ToCString(), {' ', '\t', ',', ';'}); - for (const auto& anOperationString : anOperationStrings) + // Parse operation flags using Token method + Standard_Integer aTokenCount = 1; + TCollection_AsciiString aToken; + const TCollection_AsciiString aSeparators(" \t,;"); + + while (!(aToken = anIter.Value().Token(aSeparators.ToCString(), aTokenCount)).IsEmpty()) { - std::pair anOperationFlag = - ShapeProcess::ToOperationFlag(anOperationString.c_str()); + std::pair anOperationFlag = + ShapeProcess::ToOperationFlag(aToken.ToCString()); if (anOperationFlag.second) { aResultFlags.set(anOperationFlag.first); } + aTokenCount++; } } + else + { + aResultParameters.Bind(aKey, anIter.Value()); + } } return {aResultParameters, aResultFlags}; } @@ -611,10 +580,13 @@ void XSAlgo_ShapeProcessor::FillParameterMap(const DE_ShapeFixParameters& SetParameter("FixShape.MaxTolerance3d", theParameters.MaxTolerance3d, theIsReplace, theMap); SetParameter("FixShape.MinTolerance3d", theParameters.MinTolerance3d, theIsReplace, theMap); SetParameter("DetalizationLevel", - std::to_string(theParameters.DetalizationLevel), + TCollection_AsciiString(static_cast(theParameters.DetalizationLevel)), + theIsReplace, + theMap); + SetParameter("NonManifold", + TCollection_AsciiString(static_cast(theParameters.NonManifold)), theIsReplace, theMap); - SetParameter("NonManifold", std::to_string(theParameters.NonManifold), theIsReplace, theMap); SetParameter("FixShape.FixFreeShellMode", theParameters.FixFreeShellMode, theIsReplace, theMap); SetParameter("FixShape.FixFreeFaceMode", theParameters.FixFreeFaceMode, 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, - DE_ShapeFixParameters::FixMode theValue, - const bool theIsReplace, - ParameterMap& theMap) +void XSAlgo_ShapeProcessor::SetShapeFixParameters( + const DE_ShapeFixParameters& theParameters, + const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters, + XSAlgo_ShapeProcessor::ParameterMap& theTargetParameterMap) { - SetParameter(theKey, - std::to_string( - static_cast::type>(theValue)), - theIsReplace, - theMap); + theTargetParameterMap.Clear(); + XSAlgo_ShapeProcessor::FillParameterMap(theParameters, true, theTargetParameterMap); + for (XSAlgo_ShapeProcessor::ParameterMap::Iterator aParamIter(theAdditionalParameters); + aParamIter.More(); + aParamIter.Next()) + { + if (!theTargetParameterMap.IsBound(aParamIter.Key())) + { + theTargetParameterMap.Bind(aParamIter.Key(), aParamIter.Value()); + } + } } //============================================================================= -void XSAlgo_ShapeProcessor::SetParameter(const char* theKey, - double theValue, - const bool theIsReplace, - ParameterMap& theMap) +void XSAlgo_ShapeProcessor::SetParameter(const char* theKey, + const DE_ShapeFixParameters::FixMode theValue, + const bool theIsReplace, + XSAlgo_ShapeProcessor::ParameterMap& theMap) { - // Note that conversion with std::to_string() here is not possible, since it normally preserves - // only first 6 digits (before C++26). As a result, any value of 1e-7 or below will turn into 0. - // By using std::ostringstream with std::setprecision(6) formatting we will preserve first 6 - // SIGNIFICANT digits. - std::ostringstream aStrStream; - aStrStream << std::setprecision(6) << theValue; - SetParameter(theKey, aStrStream.str(), theIsReplace, theMap); + SetParameter( + theKey, + TCollection_AsciiString(static_cast( + static_cast::type>(theValue))), + theIsReplace, + theMap); } //============================================================================= -void XSAlgo_ShapeProcessor::SetParameter(const char* theKey, - std::string&& theValue, - const bool theIsReplace, - ParameterMap& theMap) +void XSAlgo_ShapeProcessor::SetParameter(const char* theKey, + const double theValue, + const bool theIsReplace, + 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) { - theMap[theKey] = std::move(theValue); + theMap.Bind(theKey, theValue); } else { - theMap.emplace(theKey, std::move(theValue)); + if (!theMap.IsBound(theKey)) + { + theMap.Bind(theKey, theValue); + } } } diff --git a/src/XSAlgo/XSAlgo_ShapeProcessor.hxx b/src/XSAlgo/XSAlgo_ShapeProcessor.hxx index e9f13144b5..58b81fb7b7 100644 --- a/src/XSAlgo/XSAlgo_ShapeProcessor.hxx +++ b/src/XSAlgo/XSAlgo_ShapeProcessor.hxx @@ -21,8 +21,6 @@ #include #include -#include - class ShapeProcess_ShapeContext; class ShapeExtend_MsgRegistrator; class Transfer_TransientProcess; @@ -34,9 +32,12 @@ class Transfer_Binder; class XSAlgo_ShapeProcessor { public: - using OperationsFlags = ShapeProcess::OperationsFlags; - using ParameterMap = std::unordered_map; - using ProcessingData = std::pair; + using ParameterMap = NCollection_DataMap; + using ProcessingData = std::pair; + // 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; public: //! Constructor. @@ -56,9 +57,9 @@ public: //! @param theOperations Operations to be performed. //! @param theProgress Progress indicator. //! @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, - const OperationsFlags& theOperations, - const Message_ProgressRange& theProgress); + Standard_EXPORT TopoDS_Shape ProcessShape(const TopoDS_Shape& theShape, + const ShapeProcess::OperationsFlags& theOperations, + const Message_ProgressRange& theProgress); //! Get the context of the last processing. //! 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 //! "FromIGES". //! @return Read parameter map. - Standard_EXPORT static ProcessingData ReadProcessingData(const std::string& theFileResourceName, - const std::string& theScopeResourceName); + Standard_EXPORT static ProcessingData ReadProcessingData( + const TCollection_AsciiString& theFileResourceName, + const TCollection_AsciiString& theScopeResourceName); //! Fill the parameter map with the values from the specified parameters. //! @param theParameters Parameters to be used in the processing. @@ -108,6 +110,39 @@ public: const bool theIsReplace, 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. //! @param theKey Key of the parameter. //! @param theValue Value of the parameter. @@ -115,32 +150,10 @@ public: //! in the map. //! @param theMap Map to set the parameter in. Standard_EXPORT static void SetParameter(const char* theKey, - DE_ShapeFixParameters::FixMode theValue, + const TCollection_AsciiString& 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, - 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 //! transfer operation. It ensures that the length unit is correctly configured based on the //! value associated with the key "xstep.cascade.unit". diff --git a/src/XSControl/XSControl_Reader.cxx b/src/XSControl/XSControl_Reader.cxx index 911ac72604..bccb1f5e7b 100644 --- a/src/XSControl/XSControl_Reader.cxx +++ b/src/XSControl/XSControl_Reader.cxx @@ -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()) { @@ -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()) { @@ -433,8 +434,9 @@ void XSControl_Reader::SetShapeFixParameters(ParameterMap&& theParameters) //============================================================================= -void XSControl_Reader::SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, - const ParameterMap& theAdditionalParameters) +void XSControl_Reader::SetShapeFixParameters( + const DE_ShapeFixParameters& theParameters, + const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters) { 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; - const Handle(Transfer_ActorOfTransientProcess) anActor = GetActor(); + static const XSAlgo_ShapeProcessor::ParameterMap anEmptyMap; + const Handle(Transfer_ActorOfTransientProcess) anActor = GetActor(); 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; - const Handle(Transfer_ActorOfTransientProcess) anActor = GetActor(); + static const XSAlgo_ShapeProcessor::ProcessingFlags anEmptyFlags; + const Handle(Transfer_ActorOfTransientProcess) anActor = GetActor(); return anActor.IsNull() ? anEmptyFlags : anActor->GetProcessingFlags(); } @@ -493,7 +495,7 @@ Handle(Transfer_ActorOfTransientProcess) XSControl_Reader::GetActor() const void XSControl_Reader::InitializeMissingParameters() { - if (GetShapeFixParameters().empty()) + if (GetShapeFixParameters().IsEmpty()) { SetShapeFixParameters(GetDefaultShapeFixParameters()); } diff --git a/src/XSControl/XSControl_Reader.hxx b/src/XSControl/XSControl_Reader.hxx index c051d0a93e..db6fe26af2 100644 --- a/src/XSControl/XSControl_Reader.hxx +++ b/src/XSControl/XSControl_Reader.hxx @@ -30,8 +30,7 @@ #include #include #include - -#include +#include class XSControl_WorkSession; class Interface_InterfaceModel; @@ -75,12 +74,6 @@ class XSControl_Reader public: DEFINE_STANDARD_ALLOC - using ParameterMap = std::unordered_map; - // 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; - //! Creates a Reader from scratch (creates an empty WorkSession) //! A WorkSession or a Controller must be provided before running Standard_EXPORT XSControl_Reader(); @@ -295,12 +288,13 @@ public: //! Sets 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. //! Parameters are moved from the input map. //! @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. //! Parameters from @p theParameters are copied to the internal map. @@ -308,12 +302,13 @@ public: //! 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 SetShapeFixParameters(const DE_ShapeFixParameters& theParameters, - const ParameterMap& theAdditionalParameters = {}); + Standard_EXPORT void SetShapeFixParameters( + const DE_ShapeFixParameters& theParameters, + const XSAlgo_ShapeProcessor::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. - Standard_EXPORT const ParameterMap& GetShapeFixParameters() const; + Standard_EXPORT const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const; //! Sets 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. //! @return Pair of values defining operations to be performed on shapes and a boolean value //! that indicates whether the flags were set. - Standard_EXPORT const ProcessingFlags& GetShapeProcessFlags() const; + Standard_EXPORT const XSAlgo_ShapeProcessor::ProcessingFlags& GetShapeProcessFlags() const; protected: //! Returns a sequence of produced shapes diff --git a/tests/de_wrapper/configuration/A3 b/tests/de_wrapper/configuration/A3 index 56e1f3e443..da78eeeae4 100644 --- a/tests/de_wrapper/configuration/A3 +++ b/tests/de_wrapper/configuration/A3 @@ -71,7 +71,7 @@ provider.IGES.OCC.healing.remove.small.area.face : -1 provider.IGES.OCC.healing.intersecting.wires : -1 provider.IGES.OCC.healing.loop.wires : -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.geometry : 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.loop.wires : -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.geometry : 1 provider.STEP.OCC.healing.closed.wire : 1 diff --git a/tests/de_wrapper/configuration/A4 b/tests/de_wrapper/configuration/A4 index 105b344817..acb048a175 100644 --- a/tests/de_wrapper/configuration/A4 +++ b/tests/de_wrapper/configuration/A4 @@ -65,7 +65,7 @@ provider.IGES.OCC.healing.remove.small.area.face : -1 provider.IGES.OCC.healing.intersecting.wires : -1 provider.IGES.OCC.healing.loop.wires : -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.geometry : 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.loop.wires : -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.geometry : 1 provider.STEP.OCC.healing.closed.wire : 1