SET(PROJECT_HEADERS
ConstructionAPI.h
+ ConstructionAPI_Plane.h
ConstructionAPI_Point.h
)
SET(PROJECT_SOURCES
+ ConstructionAPI_Plane.cpp
ConstructionAPI_Point.cpp
)
%include "std_shared_ptr.i"
// shared pointers
+%shared_ptr(ConstructionAPI_Plane)
%shared_ptr(ConstructionAPI_Point)
// all supported interfaces
+%include "ConstructionAPI_Plane.h"
%include "ConstructionAPI_Point.h"
--- /dev/null
+// Name : ConstructionAPI_Plane.cpp
+// Purpose:
+//
+// History:
+// 27/05/16 - Sergey POKHODENKO - Creation of the file
+
+//--------------------------------------------------------------------------------------
+#include "ConstructionAPI_Plane.h"
+//--------------------------------------------------------------------------------------
+#include <ModelHighAPI_Double.h>
+#include <ModelHighAPI_Selection.h>
+//--------------------------------------------------------------------------------------
+ConstructionAPI_Plane::ConstructionAPI_Plane(
+ const std::shared_ptr<ModelAPI_Feature> & theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+ConstructionAPI_Plane::ConstructionAPI_Plane(
+ const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ const ModelHighAPI_Selection & theFace,
+ const ModelHighAPI_Double & theDistance)
+: ModelHighAPI_Interface(theFeature)
+{
+ if (initialize())
+ setFaceAndDistance(theFace, theDistance);
+}
+
+ConstructionAPI_Plane::ConstructionAPI_Plane(
+ const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ const ModelHighAPI_Double & theA,
+ const ModelHighAPI_Double & theB,
+ const ModelHighAPI_Double & theC,
+ const ModelHighAPI_Double & theD)
+: ModelHighAPI_Interface(theFeature)
+{
+ if (initialize())
+ setGeneralEquation(theA, theB, theC, theD);
+}
+
+ConstructionAPI_Plane::~ConstructionAPI_Plane()
+{
+
+}
+
+void ConstructionAPI_Plane::setFaceAndDistance(
+ const ModelHighAPI_Selection & theFace,
+ const ModelHighAPI_Double & theDistance)
+{
+ theFace.fillAttribute(myface);
+ theDistance.fillAttribute(mydistance);
+
+ execute();
+}
+
+void ConstructionAPI_Plane::setGeneralEquation(
+ const ModelHighAPI_Double & theA,
+ const ModelHighAPI_Double & theB,
+ const ModelHighAPI_Double & theC,
+ const ModelHighAPI_Double & theD)
+{
+ theA.fillAttribute(myA);
+ theB.fillAttribute(myB);
+ theC.fillAttribute(myC);
+ theD.fillAttribute(myD);
+
+ execute();
+}
--- /dev/null
+// Name : ConstructionAPI_Plane.h
+// Purpose:
+//
+// History:
+// 27/05/16 - Sergey POKHODENKO - Creation of the file
+
+#ifndef SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_PLANE_H_
+#define SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_PLANE_H_
+
+//--------------------------------------------------------------------------------------
+#include "ConstructionAPI.h"
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+//--------------------------------------------------------------------------------------
+class ModelHighAPI_Double;
+class ModelHighAPI_Selection;
+//--------------------------------------------------------------------------------------
+/**\class ConstructionAPI_Plane
+ * \ingroup CPPHighAPI
+ * \brief Interface for Plane feature
+ */
+class ConstructionAPI_Plane : public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values
+ explicit ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature> & theFeature);
+ /// Constructor with values
+ ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ const ModelHighAPI_Selection & theFace,
+ const ModelHighAPI_Double & theDistance);
+ /// Constructor with values
+ ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ const ModelHighAPI_Double & theA,
+ const ModelHighAPI_Double & theB,
+ const ModelHighAPI_Double & theC,
+ const ModelHighAPI_Double & theD);
+ /// Destructor
+ virtual ~ConstructionAPI_Plane();
+
+ INTERFACE_7("Plane",
+ creationMethod, "CreationMethod", String, /** Creation method */,
+ face, "planeFace", Selection, /** Plane face */,
+ distance, "distance", Double, /** Distance */,
+ A, "A", Double, /** Parameter A for general equation */,
+ B, "B", Double, /** Parameter B for general equation */,
+ C, "C", Double, /** Parameter C for general equation */,
+ D, "D", Double, /** Parameter D for general equation */
+ )
+
+ /// Set face and distance
+ void setFaceAndDistance(const ModelHighAPI_Selection & theFace,
+ const ModelHighAPI_Double & theDistance);
+
+ /// Set GeneralEquation parameters of the feature
+ void setGeneralEquation(const ModelHighAPI_Double & theA,
+ const ModelHighAPI_Double & theB,
+ const ModelHighAPI_Double & theC,
+ const ModelHighAPI_Double & theD);
+};
+
+//! Pointer on Plane object
+typedef std::shared_ptr<ConstructionAPI_Plane> PlanePtr;
+
+//--------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------
+#endif /* SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_PLANE_H_ */
#include <ModelHighAPI_swig.h>
+ #include "ConstructionAPI_Plane.h"
#include "ConstructionAPI_Point.h"
#endif /* SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_SWIG_H_ */
ModelHighAPI_Double.h
ModelHighAPI_Interface.h
ModelHighAPI_Macro.h
+ ModelHighAPI_Selection.h
)
SET(PROJECT_SOURCES
ModelHighAPI_Double.cpp
ModelHighAPI_Interface.cpp
+ ModelHighAPI_Selection.cpp
)
SET(PROJECT_LIBRARIES
INCLUDE_DIRECTORIES(
${PROJECT_SOURCE_DIR}/src/Events
+ ${PROJECT_SOURCE_DIR}/src/GeomAPI
${PROJECT_SOURCE_DIR}/src/ModelAPI
)
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#ifndef MockModelAPI_AttributeSelection_H_
+#define MockModelAPI_AttributeSelection_H_
+
+#include <gmock/gmock.h>
+
+#include <ModelAPI_AttributeSelection.h>
+
+class MockModelAPI_AttributeSelection : public ModelAPI_AttributeSelection {
+ public:
+ MOCK_METHOD3(setValue,
+ void(const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
+ const bool theTemporarily));
+ MOCK_METHOD0(value,
+ std::shared_ptr<GeomAPI_Shape>());
+ MOCK_METHOD0(context,
+ ResultPtr());
+ MOCK_METHOD0(update,
+ bool());
+ MOCK_METHOD1(namingName,
+ std::string(const std::string& theDefaultValue));
+ MOCK_METHOD0(Id,
+ int());
+ MOCK_METHOD2(selectSubShape,
+ void(const std::string& theType, const std::string& theSubShapeName));
+ MOCK_METHOD0(isInvalid,
+ bool());
+};
+
+#endif // MockModelAPI_AttributeSelection_H_
--- /dev/null
+// Name : ModelHighAPI_Selection.cpp
+// Purpose:
+//
+// History:
+// 06/06/16 - Sergey POKHODENKO - Creation of the file
+
+//--------------------------------------------------------------------------------------
+#include "ModelHighAPI_Selection.h"
+
+#include <ModelAPI_AttributeSelection.h>
+//--------------------------------------------------------------------------------------
+
+//--------------------------------------------------------------------------------------
+ModelHighAPI_Selection::ModelHighAPI_Selection(const std::shared_ptr<ModelAPI_Result>& theContext,
+ const std::shared_ptr<GeomAPI_Shape>& theSubShape)
+: myValue(ResultSubShapePair(theContext, theSubShape))
+{
+}
+
+ModelHighAPI_Selection::ModelHighAPI_Selection(const std::string& theType,
+ const std::string& theSubShapeName)
+: myValue(TypeSubShapeNamePair(theType, theSubShapeName))
+{
+}
+
+ModelHighAPI_Selection::~ModelHighAPI_Selection()
+{
+}
+
+//--------------------------------------------------------------------------------------
+struct fill_visitor : boost::static_visitor<void>
+{
+ mutable std::shared_ptr<ModelAPI_AttributeSelection> myAttribute;
+
+ fill_visitor(std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute)
+ : myAttribute(theAttribute) {}
+
+ void operator()(const ResultSubShapePair & thePair) const { myAttribute->setValue(thePair.first, thePair.second); }
+ void operator()(const TypeSubShapeNamePair & thePair) const { myAttribute->selectSubShape(thePair.first, thePair.second); }
+};
+
+void ModelHighAPI_Selection::fillAttribute(
+ std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute) const
+{
+ boost::apply_visitor(fill_visitor(theAttribute), myValue);
+}
--- /dev/null
+// Name : ModelHighAPI_Selection.h
+// Purpose:
+//
+// History:
+// 06/06/16 - Sergey POKHODENKO - Creation of the file
+
+#ifndef SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_
+#define SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_
+
+//--------------------------------------------------------------------------------------
+#include <memory>
+#include <string>
+#include <utility>
+
+#include <boost/variant.hpp>
+//--------------------------------------------------------------------------------------
+class GeomAPI_Shape;
+class ModelAPI_AttributeSelection;
+class ModelAPI_Result;
+//--------------------------------------------------------------------------------------
+typedef std::pair<std::shared_ptr<ModelAPI_Result>, std::shared_ptr<GeomAPI_Shape> > ResultSubShapePair;
+typedef std::pair<std::string, std::string> TypeSubShapeNamePair;
+//--------------------------------------------------------------------------------------
+/**\class ModelHighAPI_Selection
+ * \ingroup CPPHighAPI
+ * \brief Class for filling ModelAPI_AttributeSelection
+ */
+class ModelHighAPI_Selection
+{
+public:
+ /// Constructor for result and sub-shape
+ ModelHighAPI_Selection(const std::shared_ptr<ModelAPI_Result>& theContext = std::shared_ptr<ModelAPI_Result>(),
+ const std::shared_ptr<GeomAPI_Shape>& theSubShape = std::shared_ptr<GeomAPI_Shape>());
+ /// Constructor for sub-shape by the textual Name
+ ModelHighAPI_Selection(const std::string& theType,
+ const std::string& theSubShapeName);
+ /// Destructor
+ virtual ~ModelHighAPI_Selection();
+
+ /// Fill attribute values
+ virtual void fillAttribute(std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute) const;
+
+private:
+ boost::variant<ResultSubShapePair, TypeSubShapeNamePair> myValue;
+};
+
+//--------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------
+#endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_ */
set(PROJECT_SOURCES
TestDouble.cpp
+ TestSelection.cpp
)
include_directories(
using ::testing::Test;
// TODO(spo): should be common function
-void null_deleter(void *) {}
+static void null_deleter(void *) {}
class HighModelAPI_Double_Test : public Test {
public:
--- /dev/null
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include <ModelHighAPI_Selection.h>
+
+#include <MockModelAPI_AttributeSelection.h>
+
+using ::testing::_;
+using ::testing::Return;
+using ::testing::ReturnRefOfCopy;
+using ::testing::Test;
+
+// TODO(spo): should be common function
+static void null_deleter(void *) {}
+
+class HighModelAPI_Selection_Test : public Test {
+public:
+ MockModelAPI_AttributeSelection aMockAttributeSelection;
+ std::shared_ptr<ModelAPI_AttributeSelection> anAttributeSelection;
+
+ HighModelAPI_Selection_Test() {
+ anAttributeSelection = std::shared_ptr<ModelAPI_AttributeSelection>(&aMockAttributeSelection, &null_deleter);
+ }
+
+ ~HighModelAPI_Selection_Test() {
+ }
+};
+
+TEST_F(HighModelAPI_Selection_Test, Default) {
+ ModelHighAPI_Selection aValue;
+
+ EXPECT_CALL(aMockAttributeSelection, setValue(_, _, false));
+
+ aValue.fillAttribute(anAttributeSelection);
+}
+
+TEST_F(HighModelAPI_Selection_Test, ResultAndSubShape) {
+ std::shared_ptr<ModelAPI_Result> aResult;
+ std::shared_ptr<GeomAPI_Shape> aShape;
+ ModelHighAPI_Selection aValue(aResult, aShape);
+
+ EXPECT_CALL(aMockAttributeSelection, setValue(_, _, false));
+
+ aValue.fillAttribute(anAttributeSelection);
+}
+
+TEST_F(HighModelAPI_Selection_Test, TypeAndSubShapeName) {
+ ModelHighAPI_Selection aValue("Type", "SubShapeName");
+
+ EXPECT_CALL(aMockAttributeSelection, selectSubShape("Type", "SubShapeName"));
+
+ aValue.fillAttribute(anAttributeSelection);
+}