]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1865 : support while part type in the result of the field
authormpv <mpv@opencascade.com>
Thu, 24 Nov 2016 16:07:38 +0000 (19:07 +0300)
committermpv <mpv@opencascade.com>
Thu, 24 Nov 2016 16:07:38 +0000 (19:07 +0300)
src/CollectionPlugin/CollectionPlugin_Field.cpp
src/Model/Model_ResultField.cpp

index e1921c0b693073480fbbce76a3cdde76277d09a2..ddae4d0425fc3239e43761b4ddd6be2e2d7908e4 100644 (file)
@@ -8,12 +8,13 @@
 
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Document.h>
-#include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_AttributeStringArray.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeIntArray.h>
 #include <ModelAPI_AttributeTables.h>
 #include <ModelAPI_ResultField.h>
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
 
 CollectionPlugin_Field::CollectionPlugin_Field()
 {
@@ -22,6 +23,9 @@ CollectionPlugin_Field::CollectionPlugin_Field()
 void CollectionPlugin_Field::initAttributes()
 {
   data()->addAttribute(SELECTED_ID(), ModelAPI_AttributeSelectionList::typeId());
+  // for the whole part result it is not obligatory
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SELECTED_ID());
+
   data()->addAttribute(COMPONENTS_NAMES_ID(), ModelAPI_AttributeStringArray::typeId());
   data()->addAttribute(STAMPS_ID(), ModelAPI_AttributeIntArray::typeId());
   data()->addAttribute(VALUES_ID(), ModelAPI_AttributeTables::typeId());
index 15509ef2101047fd7f4b24d43e2565c7f1135bb1..f10fe16af5149947712cb3342fee565672f09768 100644 (file)
@@ -6,6 +6,9 @@
 
 #include <Model_ResultField.h>
 #include <ModelAPI_AttributeSelectionList.h>
+#include <Model_Document.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_Feature.h>
 
 #include <GeomAlgoAPI_CompoundBuilder.h>
 
@@ -31,10 +34,36 @@ std::shared_ptr<GeomAPI_Shape> Model_ResultField::shape()
     AttributeSelectionListPtr aList = myOwnerData->selectionList("selected");
     if (aList) {
       std::list<std::shared_ptr<GeomAPI_Shape> > aSubs;
-      for(int a = aList->size() - 1; a >= 0; a--) {
-        std::shared_ptr<GeomAPI_Shape> aSelection = aList->value(a)->value();
-        if (aSelection && !aSelection->isNull()) {
-          aSubs.push_back(aSelection);
+      if (aList->selectionType() == "part") { // all result bodies of the part
+        std::shared_ptr<Model_Document> aDoc =
+          std::dynamic_pointer_cast<Model_Document>(document());
+        if (!aDoc.get())
+          return aResult;
+        FeaturePtr aThisFeature = document()->feature(
+          std::dynamic_pointer_cast<ModelAPI_Result>(data()->owner()));
+        int aResults = document()->size(ModelAPI_ResultBody::group());
+        for(int a = 0; a < aResults; a++) {
+          ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(
+            document()->object(ModelAPI_ResultBody::group(), a));
+          if (!aBody.get()) 
+            continue;
+          // check that only results that were created before this field are used
+          FeaturePtr aResultFeature = document()->feature(aBody);
+          if (!aResultFeature.get())
+            continue;
+          if (aDoc->isLater(aResultFeature, aThisFeature))
+            continue;
+          GeomShapePtr aShape = aBody->shape();
+          if (!aShape.get() || aShape->isNull())
+            continue;
+          aSubs.push_back(aShape);
+        }
+      } else {
+        for(int a = aList->size() - 1; a >= 0; a--) {
+          std::shared_ptr<GeomAPI_Shape> aSelection = aList->value(a)->value();
+          if (aSelection && !aSelection->isNull()) {
+            aSubs.push_back(aSelection);
+          }
         }
       }
       if (!aSubs.empty()) {