X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FExchangePlugin%2FExchangePlugin_ExportFeature.cpp;h=bf677c743730ed28aecade2876c3acdfd2e9c675;hb=ea593bc59e7e9461f6c4e2afd3f24d621edb1011;hp=da17f46b8eed32edd06fa86f6f000ed72f2276f2;hpb=95375993f1f35e4716475c0b0c8e265c082c875d;p=modules%2Fshaper.git diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp index da17f46b8..bf677c743 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp @@ -38,6 +38,7 @@ #include #include +#include #include #include @@ -255,8 +256,42 @@ 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; @@ -356,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); @@ -366,6 +403,7 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName) // conversion of dimension std::string aSelectionType = aSelectionList->selectionType(); + GeomAPI_Shape::ShapeType aSelType = GeomAPI_Shape::shapeTypeByStr(aSelectionType); std::string aDimensionString = ExchangePlugin_Tools::selectionType2xaoDimension(aSelectionType); XAO::Dimension aGroupDimension = XAO::XaoUtils::stringToDimension(aDimensionString); @@ -374,23 +412,14 @@ 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); - - // complex conversion of reference id to element index - // gives bad id in case the selection is done from python script - // => using GeomAlgoAPI_CompoundBuilder::id instead - // int aReferenceID_old = aSelection->Id(); - - int aReferenceID = GeomAlgoAPI_CompoundBuilder::id(aShape, aSelection->value()); - + 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) {