]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelHighAPI/ModelHighAPI_Selection.cpp
Salome HOME
1c2cca5bfdc887257dcecda85949cd7c6b3cd807
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Selection.cpp
1 // Name   : ModelHighAPI_Selection.cpp
2 // Purpose: 
3 //
4 // History:
5 // 06/06/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "ModelHighAPI_Selection.h"
9
10 #include <ModelAPI_AttributeSelection.h>
11 //--------------------------------------------------------------------------------------
12
13 //--------------------------------------------------------------------------------------
14 ModelHighAPI_Selection::ModelHighAPI_Selection(const std::shared_ptr<ModelAPI_Result>& theContext,
15                                                const std::shared_ptr<GeomAPI_Shape>& theSubShape)
16 : myValue(ResultSubShapePair(theContext, theSubShape))
17 {
18 }
19
20 ModelHighAPI_Selection::ModelHighAPI_Selection(const std::string& theType,
21                                                const std::string& theSubShapeName)
22 : myValue(TypeSubShapeNamePair(theType, theSubShapeName))
23 {
24 }
25
26 ModelHighAPI_Selection::~ModelHighAPI_Selection()
27 {
28 }
29
30 //--------------------------------------------------------------------------------------
31 struct fill_visitor : boost::static_visitor<void>
32 {
33   mutable std::shared_ptr<ModelAPI_AttributeSelection> myAttribute;
34
35   fill_visitor(std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute)
36   : myAttribute(theAttribute) {}
37
38   void operator()(const ResultSubShapePair & thePair) const { myAttribute->setValue(thePair.first, thePair.second); }
39   void operator()(const TypeSubShapeNamePair & thePair) const { myAttribute->selectSubShape(thePair.first, thePair.second); }
40 };
41
42 void ModelHighAPI_Selection::fillAttribute(
43     std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute) const
44 {
45   boost::apply_visitor(fill_visitor(theAttribute), myValue);
46 }