]> SALOME platform Git repositories - modules/shaper.git/blob - src/Model/Model_ResultGroup.cpp
Salome HOME
Issue #1315 Middle point constraint problem
[modules/shaper.git] / src / Model / Model_ResultGroup.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_ResultGroup.cpp
4 // Created:     08 Jul 2014
5 // Author:      Mikhail PONIKAROV
6
7 #include <Model_ResultGroup.h>
8 #include <ModelAPI_AttributeSelectionList.h>
9 #include <ModelAPI_AttributeIntArray.h>
10
11 #include <GeomAlgoAPI_CompoundBuilder.h>
12
13 #include <Config_PropManager.h>
14
15 Model_ResultGroup::Model_ResultGroup(std::shared_ptr<ModelAPI_Data> theOwnerData)
16 {
17   myOwnerData = theOwnerData;
18 }
19
20 void Model_ResultGroup::initAttributes()
21 {
22   // append the color attribute. It is empty, the attribute will be filled by a request
23   DataPtr aData = data();
24   aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId());
25 }
26
27 void Model_ResultGroup::colorConfigInfo(std::string& theSection, std::string& theName,
28                                        std::string& theDefault)
29 {
30   theSection = "Visualization";
31   theName = "result_group_color";
32   theDefault = DEFAULT_COLOR();
33 }
34
35 std::shared_ptr<GeomAPI_Shape> Model_ResultGroup::shape()
36 {
37   std::shared_ptr<GeomAPI_Shape> aResult;
38   if (myOwnerData) {
39     AttributeSelectionListPtr aList = myOwnerData->selectionList("group_list");
40     if (aList) {
41       std::list<std::shared_ptr<GeomAPI_Shape> > aSubs;
42       for(int a = aList->size() - 1; a >= 0; a--) {
43         std::shared_ptr<GeomAPI_Shape> aSelection = aList->value(a)->value();
44         if (aSelection && !aSelection->isNull()) {
45           aSubs.push_back(aSelection);
46         }
47       }
48       if (!aSubs.empty()) {
49         aResult = GeomAlgoAPI_CompoundBuilder::compound(aSubs);
50       }
51     }
52   }
53   return aResult;
54 }