From: azv Date: Sat, 25 Nov 2017 09:09:49 +0000 (+0300) Subject: Update checkPythonDump() to store and compare information about the Folder features X-Git-Tag: V_2.10.0RC~123^2~15 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7afac44ea23adaad14ffbba46d04aaa05f31b4e6;p=modules%2Fshaper.git Update checkPythonDump() to store and compare information about the Folder features --- diff --git a/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp b/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp index 97f65b477..995cb344f 100644 --- a/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp +++ b/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp @@ -55,39 +55,47 @@ #define PRECISION 6 #define TOLERANCE (1.e-7) -ModelHighAPI_FeatureStore::ModelHighAPI_FeatureStore(FeaturePtr theFeature) { - storeData(theFeature->data(), myAttrs); - // iterate results to store - std::list allResults; - ModelAPI_Tools::allResults(theFeature, allResults); - std::list::iterator aRes = allResults.begin(); - for(; aRes != allResults.end(); aRes++) { - std::map aResDump; - storeData((*aRes)->data(), aResDump); - myRes.push_back(aResDump); +ModelHighAPI_FeatureStore::ModelHighAPI_FeatureStore(ObjectPtr theObject) { + storeData(theObject->data(), myAttrs); + + FeaturePtr aFeature = std::dynamic_pointer_cast(theObject); + if (aFeature) { + // iterate results to store + std::list allResults; + ModelAPI_Tools::allResults(aFeature, allResults); + std::list::iterator aRes = allResults.begin(); + for(; aRes != allResults.end(); aRes++) { + std::map aResDump; + storeData((*aRes)->data(), aResDump); + myRes.push_back(aResDump); + } } } -std::string ModelHighAPI_FeatureStore::compare(FeaturePtr theFeature) { - std::string anError = compareData(theFeature->data(), myAttrs); +std::string ModelHighAPI_FeatureStore::compare(ObjectPtr theObject) { + std::string anError = compareData(theObject->data(), myAttrs); if (!anError.empty()) { - return "Features '" + theFeature->name() + "' differ:" + anError; - } - std::list allResults; - ModelAPI_Tools::allResults(theFeature, allResults); - std::list::iterator aRes = allResults.begin(); - std::list >::iterator aResIter = myRes.begin(); - for(; aRes != allResults.end() && aResIter != myRes.end(); aRes++, aResIter++) { - anError = compareData((*aRes)->data(), *aResIter); - if (!anError.empty()) - return "Results of feature '" + theFeature->name() + "' '" + (*aRes)->data()->name() + - "' differ:" + anError; - } - if (aRes != allResults.end()) { - return "Current model has more results '" + (*aRes)->data()->name() + "'"; + return "Features '" + theObject->data()->name() + "' differ:" + anError; } - if (aResIter != myRes.end()) { - return "Original model had more results '" + (*aResIter)["__name__"] + "'"; + + FeaturePtr aFeature = std::dynamic_pointer_cast(theObject); + if (aFeature) { + std::list allResults; + ModelAPI_Tools::allResults(aFeature, allResults); + std::list::iterator aRes = allResults.begin(); + std::list >::iterator aResIter = myRes.begin(); + for(; aRes != allResults.end() && aResIter != myRes.end(); aRes++, aResIter++) { + anError = compareData((*aRes)->data(), *aResIter); + if (!anError.empty()) + return "Results of feature '" + aFeature->name() + "' '" + (*aRes)->data()->name() + + "' differ:" + anError; + } + if (aRes != allResults.end()) { + return "Current model has more results '" + (*aRes)->data()->name() + "'"; + } + if (aResIter != myRes.end()) { + return "Original model had more results '" + (*aResIter)["__name__"] + "'"; + } } return ""; // ok } diff --git a/src/ModelHighAPI/ModelHighAPI_FeatureStore.h b/src/ModelHighAPI/ModelHighAPI_FeatureStore.h index 7970b1799..32bea8a3b 100644 --- a/src/ModelHighAPI/ModelHighAPI_FeatureStore.h +++ b/src/ModelHighAPI/ModelHighAPI_FeatureStore.h @@ -28,13 +28,13 @@ #include #include -class ModelAPI_Feature; +class ModelAPI_Object; class ModelAPI_Data; class GeomAPI_Shape; class ModelAPI_Attribute; -typedef std::shared_ptr FeaturePtr; -typedef std::shared_ptr AttributePtr; +typedef std::shared_ptr ObjectPtr; +typedef std::shared_ptr AttributePtr; /**\class ModelHighAPI_FeatureStore * \ingroup CPPHighAPI @@ -49,9 +49,9 @@ public: // unused constructor for the map container needs ModelHighAPI_FeatureStore() {} // constructor that initializes this object by feature to store - ModelHighAPI_FeatureStore(FeaturePtr theFeature); + ModelHighAPI_FeatureStore(ObjectPtr theObject); // compares the stored feature information with the given feature - std::string compare(FeaturePtr theFeature); + std::string compare(ObjectPtr theObject); private: /// stores the information about all attributes of data in map diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.cpp b/src/ModelHighAPI/ModelHighAPI_Tools.cpp index d03130b59..5fe41aee5 100644 --- a/src/ModelHighAPI/ModelHighAPI_Tools.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Tools.cpp @@ -338,47 +338,53 @@ std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc, } } // store the model features information: iterate all features - int aFeaturesCount = 0; // stores the number of compared features for this document to compate + int anObjectsCount = 0; // stores the number of compared features for this document to compate std::set aProcessed; // processed features names (that are in the current document) - std::list allFeatures = theDoc->allFeatures(); - std::list::iterator allIter = allFeatures.begin(); - for(; allIter != allFeatures.end(); allIter++) { - FeaturePtr aFeat = *allIter; + + // process all objects (features and folders) + std::list allObjects = theDoc->allObjects(); + std::list::iterator allIter = allObjects.begin(); + for(; allIter != allObjects.end(); allIter++) { + ObjectPtr anObject = *allIter; if (theCompare) { std::map::iterator - aFeatFind = aDocFind->second.find(aFeat->name()); - if (aFeatFind == aDocFind->second.end()) { - return "Document '" + theDocName + "' feature '" + aFeat->name() + "' not found"; + anObjFind = aDocFind->second.find(anObject->data()->name()); + if (anObjFind == aDocFind->second.end()) { + return "Document '" + theDocName + "' feature '" + anObject->data()->name() + "' not found"; } - std::string anError = aFeatFind->second.compare(aFeat); + std::string anError = anObjFind->second.compare(anObject); if (!anError.empty()) { anError = "Document " + theDocName + " " + anError; return anError; } - aFeaturesCount++; - aProcessed.insert(aFeat->name()); + anObjectsCount++; + aProcessed.insert(anObject->data()->name()); } else { - theStore[theDocName][aFeat->name()] = ModelHighAPI_FeatureStore(aFeat); + theStore[theDocName][anObject->data()->name()] = ModelHighAPI_FeatureStore(anObject); } - // iterate all results of this feature - std::list allResults; - ModelAPI_Tools::allResults(aFeat, allResults); - std::list::iterator aRes = allResults.begin(); - for(; aRes != allResults.end(); aRes++) { - // recoursively store features of sub-documents - if ((*aRes)->groupName() == ModelAPI_ResultPart::group()) { - DocumentPtr aDoc = std::dynamic_pointer_cast(*aRes)->partDoc(); - if (aDoc.get()) { - std::string anError = storeFeatures((*aRes)->data()->name(), aDoc, theStore, theCompare); - if (!anError.empty()) - return anError; + + FeaturePtr aFeature = std::dynamic_pointer_cast(anObject); + if (aFeature) { + // iterate all results of this feature + std::list allResults; + ModelAPI_Tools::allResults(aFeature, allResults); + std::list::iterator aRes = allResults.begin(); + for(; aRes != allResults.end(); aRes++) { + // recoursively store features of sub-documents + if ((*aRes)->groupName() == ModelAPI_ResultPart::group()) { + DocumentPtr aDoc = std::dynamic_pointer_cast(*aRes)->partDoc(); + if (aDoc.get()) { + std::string anError = storeFeatures((*aRes)->data()->name(), aDoc, theStore, theCompare); + if (!anError.empty()) + return anError; + } } } } } // checks the number of compared features if (theCompare) { - if (aDocFind->second.size() != aFeaturesCount) { + if (aDocFind->second.size() != anObjectsCount) { // search for disappeared feature std::string aLostName; std::map::iterator aLostIter;