1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: FeaturesPlugin_Partition.cpp
4 // Created: 31 Jul 2015
5 // Author: Natalia ERMOLAEVA
7 #include "FeaturesPlugin_Partition.h"
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>
19 //=================================================================================================
20 FeaturesPlugin_Partition::FeaturesPlugin_Partition()
24 //=================================================================================================
25 void FeaturesPlugin_Partition::initAttributes()
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");
33 aSelection = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
34 FeaturesPlugin_Partition::TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
35 aSelection->setSelectionType("SOLID");
37 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TOOL_LIST_ID());
40 //=================================================================================================
41 std::shared_ptr<GeomAPI_Shape> FeaturesPlugin_Partition::getShape(const std::string& theAttrName)
43 std::shared_ptr<ModelAPI_AttributeReference> aObjRef = std::dynamic_pointer_cast<
44 ModelAPI_AttributeReference>(data()->attribute(theAttrName));
46 std::shared_ptr<ModelAPI_ResultBody> aConstr = std::dynamic_pointer_cast<
47 ModelAPI_ResultBody>(aObjRef->value());
49 return aConstr->shape();
51 return std::shared_ptr<GeomAPI_Shape>();
54 //=================================================================================================
55 void FeaturesPlugin_Partition::execute()