X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FExchangePlugin%2FExchangePlugin_ExportFeature.cpp;h=bf677c743730ed28aecade2876c3acdfd2e9c675;hb=ea593bc59e7e9461f6c4e2afd3f24d621edb1011;hp=60cae7e2fc88a29b63a060f49c7fbef0f2115b60;hpb=2df35f62c4741dc49a95ececaf04c1e5f6bf685e;p=modules%2Fshaper.git diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp index 60cae7e2f..bf677c743 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp @@ -256,28 +256,47 @@ static bool isInResults(AttributeSelectionListPtr theSelection, // if context is in results, return true for(int a = 0; a < theSelection->size(); a++) { AttributeSelectionPtr anAttr = theSelection->value(a); - ResultBodyPtr aSelected= std::dynamic_pointer_cast(anAttr->context()); - if (aSelected.get() && theCashedResults.count(aSelected)) + ResultPtr aContext = anAttr->context(); + // check is it group selected for groups BOP + if (aContext.get() && aContext->groupName() == ModelAPI_ResultGroup::group()) { + // it is impossible by used results check which result is used in this group result, + // so check the results shapes is it in results of this document or not + FeaturePtr aSelFeature = + std::dynamic_pointer_cast(theSelection->owner()); + if (!aSelFeature.get() || aSelFeature->results().empty()) + continue; + GeomShapePtr aGroupResShape = aSelFeature->firstResult()->shape(); + + std::set::iterator allResultsIter = theCashedResults.begin(); + for(; allResultsIter != theCashedResults.end(); allResultsIter++) { + GeomShapePtr aResultShape = (*allResultsIter)->shape(); + + GeomAPI_Shape::ShapeType aType = + GeomAPI_Shape::shapeTypeByStr(theSelection->selectionType()); + GeomAPI_ShapeExplorer aGroupResExp(aGroupResShape, aType); + for(; aGroupResExp.more(); aGroupResExp.next()) { + if (aResultShape->isSubShape(aGroupResExp.current(), false)) + return true; // at least one shape of the group is in the used results + } + } + } + ResultBodyPtr aSelected = std::dynamic_pointer_cast(anAttr->context()); + if (!aSelected.get()) { // try to get selected feature and all its results + FeaturePtr aContextFeature = anAttr->contextFeature(); + if (aContextFeature.get() && !aContextFeature->results().empty()) { + const std::list& allResluts = aContextFeature->results(); + std::list::const_iterator aResIter = allResluts.cbegin(); + for(; aResIter != allResluts.cend(); aResIter++) { + if (aResIter->get() && theCashedResults.count(*aResIter)) + return true; + } + } + } else if (aSelected.get() && theCashedResults.count(aSelected)) return true; } return false; } -/// Returns all sub-shapes of the given shape in theResult -static void allSubShapes(const GeomShapePtr theShape, GeomAPI_Shape::ShapeType theType, - std::list& theResult) -{ - if (theShape->shapeType() == theType) { - theResult.push_back(theShape); - } else { - GeomAPI_DataMapOfShapeShape aUnique; // to keep only unique shapes - for(GeomAPI_ShapeExplorer anExp(theShape, theType); anExp.more(); anExp.next()) { - if (aUnique.bind(anExp.current(), anExp.current())) - theResult.push_back(anExp.current()); - } - } -} - void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName) { try { @@ -372,6 +391,8 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName) for (int aGroupIndex = 0; aGroupIndex < aGroupCount; ++aGroupIndex) { ResultGroupPtr aResultGroup = std::dynamic_pointer_cast( (*aDoc)->object(ModelAPI_ResultGroup::group(), aGroupIndex)); + if (!aResultGroup.get() || !aResultGroup->shape().get()) + continue; FeaturePtr aGroupFeature = (*aDoc)->feature(aResultGroup); @@ -391,26 +412,15 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName) aResultGroup->data()->name()); try { - for (int aSelectionIndex = 0; aSelectionIndex < aSelectionList->size(); ++aSelectionIndex){ - AttributeSelectionPtr aSelection = aSelectionList->value(aSelectionIndex); - GeomShapePtr aSelShape = aSelection->value(); - if (!aSelShape.get() && aSelection->context().get()) { - aSelShape = aSelection->context()->shape(); - } - - std::list allSubs; - allSubShapes(aSelShape, aSelType, allSubs); - - std::list::iterator anIter = allSubs.begin(); - for(; anIter != allSubs.end(); anIter++) { - int aReferenceID = GeomAlgoAPI_CompoundBuilder::id(aShape, *anIter); - if (aReferenceID == 0) // selected value does not found in the exported shape - continue; - std::string aReferenceString = XAO::XaoUtils::intToString(aReferenceID); - int anElementID = - aXao.getGeometry()->getElementIndexByReference(aGroupDimension, aReferenceString); - aXaoGroup->add(anElementID); - } + GeomAPI_ShapeExplorer aGroupResExplorer(aResultGroup->shape(), aSelType); + for(; aGroupResExplorer.more(); aGroupResExplorer.next()) { + int aReferenceID = GeomAlgoAPI_CompoundBuilder::id(aShape, aGroupResExplorer.current()); + if (aReferenceID == 0) // selected value does not found in the exported shape + continue; + std::string aReferenceString = XAO::XaoUtils::intToString(aReferenceID); + int anElementID = + aXao.getGeometry()->getElementIndexByReference(aGroupDimension, aReferenceString); + aXaoGroup->add(anElementID); } } catch (XAO::XAO_Exception& e) { // LCOV_EXCL_START