From 0b7860f6ea3d1b8389227f337ec507833cbadb06 Mon Sep 17 00:00:00 2001 From: mpv Date: Tue, 4 Jun 2019 10:28:59 +0300 Subject: [PATCH] Debug of filters arguments processing --- src/Model/Model_Data.cpp | 2 +- src/Model/Model_Filter.cpp | 31 +++++++++++++++++++------------ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 5f867fca1..16355161a 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -240,7 +240,7 @@ AttributePtr Model_Data::addFloatingAttribute( int anIndex; TDF_Label aLab; if (myLab.IsAttribute(TDF_TagSource::GetID())) { - TDF_Label aLab = myLab.NewChild(); // already exists a floating attribute, create the next + aLab = myLab.NewChild(); // already exists a floating attribute, create the next anIndex = aLab.Tag(); } else { // put the first floating attribute, quite far from other standard attributes anIndex = int(myAttrs.size()) + 1000; diff --git a/src/Model/Model_Filter.cpp b/src/Model/Model_Filter.cpp index 84b0bd5f7..b0592b35e 100644 --- a/src/Model/Model_Filter.cpp +++ b/src/Model/Model_Filter.cpp @@ -38,21 +38,28 @@ bool Model_FiltersFactory::isValid(FeaturePtr theFiltersFeature, GeomShapePtr th // prepare all filters args ModelAPI_FiltersArgs anArgs; std::map aReverseFlags; /// map of all filters to the reverse values - static const std::string& anEmptyType(""); - std::list > allAttrs = - theFiltersFeature->data()->attributes(anEmptyType); - std::list >::iterator anAttr = allAttrs.begin(); - for(; anAttr != allAttrs.end(); anAttr++) { - const std::string& anAttrID = (*anAttr)->id(); - if (anAttrID.find(kFilterSeparator) == std::string::npos) { // possible a filter reverse flag - std::shared_ptr aReverse = theFiltersFeature->boolean(anAttrID); - if (aReverse.get() && myFilters.find(anAttrID) != myFilters.end()) { - aReverseFlags[myFilters[anAttrID] ] = aReverse->value(); + + std::list aGroups; + theFiltersFeature->data()->allGroups(aGroups); + for(std::list::iterator aGIter = aGroups.begin(); aGIter != aGroups.end(); aGIter++) + { + if (myFilters.find(*aGIter) == myFilters.end()) + continue; + std::list > anAttrs; + theFiltersFeature->data()->attributesOfGroup(*aGIter, anAttrs); + std::list >::iterator anAttrIter = anAttrs.begin(); + for(; anAttrIter != anAttrs.end(); anAttrIter++) { + std::string anArgID = (*anAttrIter)->id().substr((*aGIter).length() + 2); + if (anArgID.empty()) { // reverse flag + std::shared_ptr aReverse = + std::dynamic_pointer_cast(*anAttrIter); + aReverseFlags[myFilters[*aGIter] ] = aReverse->value(); + } else { + anArgs.add(*anAttrIter); } - } else { // an argument of a filter - anArgs.add(*anAttr); } } + // iterate filters and check shape for validity for all of them std::map::iterator aFilter = aReverseFlags.begin(); for(; aFilter != aReverseFlags.end(); aFilter++) { -- 2.39.2