Salome HOME
Merge tag 'V_1.3.1' into HEAD
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Partition.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        FeaturesPlugin_Partition.cpp
4 // Created:     31 Jul 2015
5 // Author:      Natalia ERMOLAEVA
6
7 #include "FeaturesPlugin_Partition.h"
8
9 #include <ModelAPI_Data.h>
10 #include <ModelAPI_Document.h>
11 #include <ModelAPI_AttributeReference.h>
12 #include <ModelAPI_AttributeInteger.h>
13 #include <ModelAPI_BodyBuilder.h>
14 #include <ModelAPI_ResultBody.h>
15 #include <ModelAPI_AttributeSelectionList.h>
16 #include <ModelAPI_Session.h>
17 #include <ModelAPI_Validator.h>
18
19 //=================================================================================================
20 FeaturesPlugin_Partition::FeaturesPlugin_Partition()
21 {
22 }
23
24 //=================================================================================================
25 void FeaturesPlugin_Partition::initAttributes()
26 {
27
28   AttributeSelectionListPtr aSelection = 
29     std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
30     FeaturesPlugin_Partition::OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
31   aSelection->setSelectionType("SOLID");
32
33   aSelection = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
34     FeaturesPlugin_Partition::TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
35   aSelection->setSelectionType("SOLID");
36
37   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TOOL_LIST_ID());
38 }
39
40 //=================================================================================================
41 std::shared_ptr<GeomAPI_Shape> FeaturesPlugin_Partition::getShape(const std::string& theAttrName)
42 {
43   std::shared_ptr<ModelAPI_AttributeReference> aObjRef = std::dynamic_pointer_cast<
44       ModelAPI_AttributeReference>(data()->attribute(theAttrName));
45   if (aObjRef) {
46     std::shared_ptr<ModelAPI_ResultBody> aConstr = std::dynamic_pointer_cast<
47         ModelAPI_ResultBody>(aObjRef->value());
48     if (aConstr)
49       return aConstr->shape();
50   }
51   return std::shared_ptr<GeomAPI_Shape>();
52 }
53
54 //=================================================================================================
55 void FeaturesPlugin_Partition::execute()
56 {
57 }