#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()
{
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());
#include <Model_ResultField.h>
#include <ModelAPI_AttributeSelectionList.h>
+#include <Model_Document.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_Feature.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
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()) {