From b1bf4bec5673c87a8e04882d6708bdf98123647a Mon Sep 17 00:00:00 2001 From: spo Date: Tue, 7 Jun 2016 12:42:26 +0300 Subject: [PATCH] Use fillAttribute in *API interfaces --- src/ConstructionAPI/ConstructionAPI_Plane.cpp | 15 +++++----- src/ConstructionAPI/ConstructionAPI_Point.cpp | 12 +++----- src/ModelHighAPI/ModelHighAPI_Double.cpp | 4 +-- src/ModelHighAPI/ModelHighAPI_Double.h | 2 +- src/ModelHighAPI/ModelHighAPI_Tools.cpp | 29 +++++++++++++++++-- src/ModelHighAPI/ModelHighAPI_Tools.h | 19 ++++++++++++ 6 files changed, 60 insertions(+), 21 deletions(-) diff --git a/src/ConstructionAPI/ConstructionAPI_Plane.cpp b/src/ConstructionAPI/ConstructionAPI_Plane.cpp index b8160ca89..5799f5498 100644 --- a/src/ConstructionAPI/ConstructionAPI_Plane.cpp +++ b/src/ConstructionAPI/ConstructionAPI_Plane.cpp @@ -7,8 +7,7 @@ //-------------------------------------------------------------------------------------- #include "ConstructionAPI_Plane.h" //-------------------------------------------------------------------------------------- -#include -#include +#include //-------------------------------------------------------------------------------------- ConstructionAPI_Plane::ConstructionAPI_Plane( const std::shared_ptr & theFeature) @@ -49,8 +48,8 @@ void ConstructionAPI_Plane::setFaceAndDistance( const ModelHighAPI_Selection & theFace, const ModelHighAPI_Double & theDistance) { - theFace.fillAttribute(myface); - theDistance.fillAttribute(mydistance); + fillAttribute(theFace, myface); + fillAttribute(theDistance, mydistance); execute(); } @@ -61,10 +60,10 @@ void ConstructionAPI_Plane::setGeneralEquation( const ModelHighAPI_Double & theC, const ModelHighAPI_Double & theD) { - theA.fillAttribute(myA); - theB.fillAttribute(myB); - theC.fillAttribute(myC); - theD.fillAttribute(myD); + fillAttribute(theA, myA); + fillAttribute(theB, myB); + fillAttribute(theC, myC); + fillAttribute(theD, myD); execute(); } diff --git a/src/ConstructionAPI/ConstructionAPI_Point.cpp b/src/ConstructionAPI/ConstructionAPI_Point.cpp index 26df2de8b..bcfd93848 100644 --- a/src/ConstructionAPI/ConstructionAPI_Point.cpp +++ b/src/ConstructionAPI/ConstructionAPI_Point.cpp @@ -7,11 +7,7 @@ //-------------------------------------------------------------------------------------- #include "ConstructionAPI_Point.h" //-------------------------------------------------------------------------------------- -#include -#include -#include - -#include +#include //-------------------------------------------------------------------------------------- ConstructionAPI_Point::ConstructionAPI_Point( const std::shared_ptr & theFeature) @@ -41,9 +37,9 @@ void ConstructionAPI_Point::setPoint(const ModelHighAPI_Double & theX, const ModelHighAPI_Double & theY, const ModelHighAPI_Double & theZ) { - theX.fillAttribute(myx); - theY.fillAttribute(myy); - theZ.fillAttribute(myz); + fillAttribute(theX, myx); + fillAttribute(theY, myy); + fillAttribute(theZ, myz); execute(); } diff --git a/src/ModelHighAPI/ModelHighAPI_Double.cpp b/src/ModelHighAPI/ModelHighAPI_Double.cpp index b40b89e0c..91cbaac32 100644 --- a/src/ModelHighAPI/ModelHighAPI_Double.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Double.cpp @@ -35,7 +35,7 @@ struct fill_visitor : boost::static_visitor { mutable std::shared_ptr myAttribute; - fill_visitor(std::shared_ptr & theAttribute) + fill_visitor(const std::shared_ptr & theAttribute) : myAttribute(theAttribute) {} void operator()(double theValue) const { myAttribute->setValue(theValue); } @@ -43,7 +43,7 @@ struct fill_visitor : boost::static_visitor }; void ModelHighAPI_Double::fillAttribute( - std::shared_ptr & theAttribute) const + const std::shared_ptr & theAttribute) const { boost::apply_visitor(fill_visitor(theAttribute), myValue); } diff --git a/src/ModelHighAPI/ModelHighAPI_Double.h b/src/ModelHighAPI/ModelHighAPI_Double.h index 5fefb890f..e1b3ce687 100644 --- a/src/ModelHighAPI/ModelHighAPI_Double.h +++ b/src/ModelHighAPI/ModelHighAPI_Double.h @@ -39,7 +39,7 @@ public: /// Fill attribute values MODELHIGHAPI_EXPORT - virtual void fillAttribute(std::shared_ptr & theAttribute) const; + virtual void fillAttribute(const std::shared_ptr & theAttribute) const; private: boost::variant myValue; diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.cpp b/src/ModelHighAPI/ModelHighAPI_Tools.cpp index fed0d7b89..478c19503 100644 --- a/src/ModelHighAPI/ModelHighAPI_Tools.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Tools.cpp @@ -6,11 +6,36 @@ //-------------------------------------------------------------------------------------- #include "ModelHighAPI_Tools.h" - +//-------------------------------------------------------------------------------------- +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include - +//-------------------------------------------------------------------------------------- +#include "ModelHighAPI_Double.h" #include "ModelHighAPI_Selection.h" +//-------------------------------------------------------------------------------------- +void fillAttribute(const ModelHighAPI_Double & theValue, + const std::shared_ptr & theAttribute) +{ + theValue.fillAttribute(theAttribute); +} + +//-------------------------------------------------------------------------------------- +void fillAttribute(const ModelHighAPI_Selection & theValue, + const std::shared_ptr & theAttribute) +{ + theValue.fillAttribute(theAttribute); +} + //-------------------------------------------------------------------------------------- void fillAttribute(const std::list & theValue, const std::shared_ptr & theAttribute) diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.h b/src/ModelHighAPI/ModelHighAPI_Tools.h index fc4dafda2..f8e8b268e 100644 --- a/src/ModelHighAPI/ModelHighAPI_Tools.h +++ b/src/ModelHighAPI/ModelHighAPI_Tools.h @@ -14,11 +14,30 @@ #include #include //-------------------------------------------------------------------------------------- +class ModelAPI_AttributeBoolean; +class ModelAPI_AttributeDocRef; +class ModelAPI_AttributeDouble; +class ModelAPI_AttributeIntArray; +class ModelAPI_AttributeInteger; +class ModelAPI_AttributeRefAttr; +class ModelAPI_AttributeRefAttrList; +class ModelAPI_AttributeReference; +class ModelAPI_AttributeRefList; +class ModelAPI_AttributeSelection; class ModelAPI_AttributeSelectionList; class ModelAPI_AttributeString; //-------------------------------------------------------------------------------------- +class ModelHighAPI_Double; class ModelHighAPI_Selection; //-------------------------------------------------------------------------------------- +MODELHIGHAPI_EXPORT +void fillAttribute(const ModelHighAPI_Double & theValue, + const std::shared_ptr & theAttribute); + +MODELHIGHAPI_EXPORT +void fillAttribute(const ModelHighAPI_Selection & theValue, + const std::shared_ptr & theAttribute); + MODELHIGHAPI_EXPORT void fillAttribute(const std::list & theValue, const std::shared_ptr & theAttribute); -- 2.39.2