Salome HOME
Use fillAttribute in *API interfaces
authorspo <sergey.pokhodenko@opencascade.com>
Tue, 7 Jun 2016 09:42:26 +0000 (12:42 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 17 Jun 2016 11:41:04 +0000 (14:41 +0300)
src/ConstructionAPI/ConstructionAPI_Plane.cpp
src/ConstructionAPI/ConstructionAPI_Point.cpp
src/ModelHighAPI/ModelHighAPI_Double.cpp
src/ModelHighAPI/ModelHighAPI_Double.h
src/ModelHighAPI/ModelHighAPI_Tools.cpp
src/ModelHighAPI/ModelHighAPI_Tools.h

index b8160ca89367790a266a78be6792c27dd6245459..5799f54985be2fc3c5036ce5132d399d00d146fc 100644 (file)
@@ -7,8 +7,7 @@
 //--------------------------------------------------------------------------------------
 #include "ConstructionAPI_Plane.h"
 //--------------------------------------------------------------------------------------
-#include <ModelHighAPI_Double.h>
-#include <ModelHighAPI_Selection.h>
+#include <ModelHighAPI_Tools.h>
 //--------------------------------------------------------------------------------------
 ConstructionAPI_Plane::ConstructionAPI_Plane(
     const std::shared_ptr<ModelAPI_Feature> & 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();
 }
index 26df2de8b15e6261ae423312947583c99a706fc4..bcfd9384899eafe093e95a6bb1c059e64931b3b9 100644 (file)
@@ -7,11 +7,7 @@
 //--------------------------------------------------------------------------------------
 #include "ConstructionAPI_Point.h"
 //--------------------------------------------------------------------------------------
-#include <ModelAPI_AttributeDouble.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_Feature.h>
-
-#include <ModelHighAPI_Double.h>
+#include <ModelHighAPI_Tools.h>
 //--------------------------------------------------------------------------------------
 ConstructionAPI_Point::ConstructionAPI_Point(
     const std::shared_ptr<ModelAPI_Feature> & 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();
 }
index b40b89e0cd99c4c5ff1449c1b77f26b0beeec874..91cbaac32914e30e1e68db9c6f0f18bd3bd0158c 100644 (file)
@@ -35,7 +35,7 @@ struct fill_visitor : boost::static_visitor<void>
 {
   mutable std::shared_ptr<ModelAPI_AttributeDouble> myAttribute;
 
-  fill_visitor(std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute)
+  fill_visitor(const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute)
   : myAttribute(theAttribute) {}
 
   void operator()(double theValue) const { myAttribute->setValue(theValue); }
@@ -43,7 +43,7 @@ struct fill_visitor : boost::static_visitor<void>
 };
 
 void ModelHighAPI_Double::fillAttribute(
-    std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute) const
+    const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute) const
 {
   boost::apply_visitor(fill_visitor(theAttribute), myValue);
 }
index 5fefb890fd3ee06bee9a6614e56e61b4efc93e70..e1b3ce6872758fab3095907c7a1acd367c4e7016 100644 (file)
@@ -39,7 +39,7 @@ public:
 
   /// Fill attribute values
   MODELHIGHAPI_EXPORT
-  virtual void fillAttribute(std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute) const;
+  virtual void fillAttribute(const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute) const;
 
 private:
   boost::variant<double, std::string> myValue;
index fed0d7b898cc34ef9646f9eb5502f27637d23cb8..478c19503c1ca3b163c84a076371d0b2d2f78873 100644 (file)
@@ -6,11 +6,36 @@
 
 //--------------------------------------------------------------------------------------
 #include "ModelHighAPI_Tools.h"
-
+//--------------------------------------------------------------------------------------
+#include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_AttributeDocRef.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeIntArray.h>
+#include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_AttributeRefAttrList.h>
+#include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeString.h>
-
+//--------------------------------------------------------------------------------------
+#include "ModelHighAPI_Double.h"
 #include "ModelHighAPI_Selection.h"
+//--------------------------------------------------------------------------------------
+void fillAttribute(const ModelHighAPI_Double & theValue,
+                   const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute)
+{
+  theValue.fillAttribute(theAttribute);
+}
+
+//--------------------------------------------------------------------------------------
+void fillAttribute(const ModelHighAPI_Selection & theValue,
+                   const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute)
+{
+  theValue.fillAttribute(theAttribute);
+}
+
 //--------------------------------------------------------------------------------------
 void fillAttribute(const std::list<ModelHighAPI_Selection> & theValue,
                    const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute)
index fc4dafda250ad7c6efb5e428a07669170c908a07..f8e8b268e0a7eb2793da69ca0202dc531844f533 100644 (file)
 #include <memory>
 #include <string>
 //--------------------------------------------------------------------------------------
+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<ModelAPI_AttributeDouble> & theAttribute);
+
+MODELHIGHAPI_EXPORT
+void fillAttribute(const ModelHighAPI_Selection & theValue,
+                   const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute);
+
 MODELHIGHAPI_EXPORT
 void fillAttribute(const std::list<ModelHighAPI_Selection> & theValue,
                    const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute);