1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Model_ResultField.cpp
4 // Created: 08 Jul 2014
5 // Author: Mikhail PONIKAROV
7 #include <Model_ResultField.h>
8 #include <ModelAPI_AttributeSelectionList.h>
9 #include <Model_Document.h>
10 #include <ModelAPI_ResultBody.h>
11 #include <ModelAPI_Feature.h>
13 #include <GeomAlgoAPI_CompoundBuilder.h>
15 #include <Config_PropManager.h>
17 Model_ResultField::Model_ResultField(std::shared_ptr<ModelAPI_Data> theOwnerData)
19 myOwnerData = theOwnerData;
22 void Model_ResultField::colorConfigInfo(std::string& theSection, std::string& theName,
23 std::string& theDefault)
25 theSection = "Visualization";
26 theName = "result_field_color";
27 theDefault = DEFAULT_COLOR();
30 std::shared_ptr<GeomAPI_Shape> Model_ResultField::shape()
32 std::shared_ptr<GeomAPI_Shape> aResult;
34 AttributeSelectionListPtr aList = myOwnerData->selectionList("selected");
36 std::list<std::shared_ptr<GeomAPI_Shape> > aSubs;
37 if (aList->selectionType() == "part") { // all result bodies of the part
38 std::shared_ptr<Model_Document> aDoc =
39 std::dynamic_pointer_cast<Model_Document>(document());
42 FeaturePtr aThisFeature = document()->feature(
43 std::dynamic_pointer_cast<ModelAPI_Result>(data()->owner()));
44 int aResults = document()->size(ModelAPI_ResultBody::group());
45 for(int a = 0; a < aResults; a++) {
46 ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(
47 document()->object(ModelAPI_ResultBody::group(), a));
50 // check that only results that were created before this field are used
51 FeaturePtr aResultFeature = document()->feature(aBody);
52 if (!aResultFeature.get())
54 if (aDoc->isLater(aResultFeature, aThisFeature))
56 GeomShapePtr aShape = aBody->shape();
57 if (!aShape.get() || aShape->isNull())
59 aSubs.push_back(aShape);
62 for(int a = aList->size() - 1; a >= 0; a--) {
63 std::shared_ptr<GeomAPI_Shape> aSelection = aList->value(a)->value();
64 if (aSelection && !aSelection->isNull()) {
65 aSubs.push_back(aSelection);
70 aResult = GeomAlgoAPI_CompoundBuilder::compound(aSubs);