#define PRECISION 6
#define TOLERANCE (1.e-7)
-ModelHighAPI_FeatureStore::ModelHighAPI_FeatureStore(FeaturePtr theFeature) {
- storeData(theFeature->data(), myAttrs);
- // iterate results to store
- std::list<ResultPtr> allResults;
- ModelAPI_Tools::allResults(theFeature, allResults);
- std::list<ResultPtr>::iterator aRes = allResults.begin();
- for(; aRes != allResults.end(); aRes++) {
- std::map<std::string, std::string> 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<ModelAPI_Feature>(theObject);
+ if (aFeature) {
+ // iterate results to store
+ std::list<ResultPtr> allResults;
+ ModelAPI_Tools::allResults(aFeature, allResults);
+ std::list<ResultPtr>::iterator aRes = allResults.begin();
+ for(; aRes != allResults.end(); aRes++) {
+ std::map<std::string, std::string> 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<ResultPtr> allResults;
- ModelAPI_Tools::allResults(theFeature, allResults);
- std::list<ResultPtr>::iterator aRes = allResults.begin();
- std::list<std::map<std::string, std::string> >::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<ModelAPI_Feature>(theObject);
+ if (aFeature) {
+ std::list<ResultPtr> allResults;
+ ModelAPI_Tools::allResults(aFeature, allResults);
+ std::list<ResultPtr>::iterator aRes = allResults.begin();
+ std::list<std::map<std::string, std::string> >::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
}
#include <string>
#include <memory>
-class ModelAPI_Feature;
+class ModelAPI_Object;
class ModelAPI_Data;
class GeomAPI_Shape;
class ModelAPI_Attribute;
-typedef std::shared_ptr<ModelAPI_Feature> FeaturePtr;
-typedef std::shared_ptr<ModelAPI_Attribute> AttributePtr;
+typedef std::shared_ptr<ModelAPI_Object> ObjectPtr;
+typedef std::shared_ptr<ModelAPI_Attribute> AttributePtr;
/**\class ModelHighAPI_FeatureStore
* \ingroup CPPHighAPI
// 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
}
}
// 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<std::string> aProcessed; // processed features names (that are in the current document)
- std::list<FeaturePtr> allFeatures = theDoc->allFeatures();
- std::list<FeaturePtr>::iterator allIter = allFeatures.begin();
- for(; allIter != allFeatures.end(); allIter++) {
- FeaturePtr aFeat = *allIter;
+
+ // process all objects (features and folders)
+ std::list<ObjectPtr> allObjects = theDoc->allObjects();
+ std::list<ObjectPtr>::iterator allIter = allObjects.begin();
+ for(; allIter != allObjects.end(); allIter++) {
+ ObjectPtr anObject = *allIter;
if (theCompare) {
std::map<std::string, ModelHighAPI_FeatureStore>::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<ResultPtr> allResults;
- ModelAPI_Tools::allResults(aFeat, allResults);
- std::list<ResultPtr>::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<ModelAPI_ResultPart>(*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<ModelAPI_Feature>(anObject);
+ if (aFeature) {
+ // iterate all results of this feature
+ std::list<ResultPtr> allResults;
+ ModelAPI_Tools::allResults(aFeature, allResults);
+ std::list<ResultPtr>::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<ModelAPI_ResultPart>(*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<std::string, ModelHighAPI_FeatureStore>::iterator aLostIter;