X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelHighAPI%2FModelHighAPI_FeatureStore.cpp;h=e0fde8b2285fa3cd935446be3b84405dd32c54d1;hb=fc72d43b677baa05ae7fd317346fd8b723b799ed;hp=6bbc96cecd44a02827618d91bf08f16543c54d23;hpb=f14192492e36f4febc93b2ad7ab7f866cbbdf71b;p=modules%2Fshaper.git diff --git a/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp b/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp index 6bbc96cec..e0fde8b22 100644 --- a/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp +++ b/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// Copyright (C) 2014-2023 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -44,13 +44,15 @@ #include #include #include +#include #include -#include -#include +#include #include #include +#include +#include #define PRECISION 6 #define TOLERANCE (1.e-7) @@ -75,7 +77,7 @@ ModelHighAPI_FeatureStore::ModelHighAPI_FeatureStore(ObjectPtr theObject) { std::string ModelHighAPI_FeatureStore::compare(ObjectPtr theObject) { std::string anError = compareData(theObject->data(), myAttrs); if (!anError.empty()) { - return "Features '" + ModelAPI_Tools::toString(theObject->data()->name()) + + return "Features '" + Locale::Convert::toString(theObject->data()->name()) + "' differ:" + anError; } @@ -88,13 +90,13 @@ std::string ModelHighAPI_FeatureStore::compare(ObjectPtr theObject) { for(; aRes != allResults.end() && aResIter != myRes.end(); aRes++, aResIter++) { anError = compareData((*aRes)->data(), *aResIter); if (!anError.empty()) - return "Results of feature '" + ModelAPI_Tools::toString(aFeature->name()) + - "' '" + ModelAPI_Tools::toString((*aRes)->data()->name()) + + return "Results of feature '" + Locale::Convert::toString(aFeature->name()) + + "' '" + Locale::Convert::toString((*aRes)->data()->name()) + "' differ:" + anError; } if (aRes != allResults.end()) { return "Current model has more results '" + - ModelAPI_Tools::toString((*aRes)->data()->name()) + "'"; + Locale::Convert::toString((*aRes)->data()->name()) + "'"; } if (aResIter != myRes.end()) { return "Original model had more results '" + (*aResIter)["__name__"] + "'"; @@ -107,7 +109,7 @@ void ModelHighAPI_FeatureStore::storeData(std::shared_ptr theData std::map& theAttrs) { // store name to keep also this information and output if needed - theAttrs["__name__"] = ModelAPI_Tools::toString(theData->name()); + theAttrs["__name__"] = Locale::Convert::toString(theData->name()); std::list > allAttrs = theData->attributes(""); std::list >::iterator anAttr = allAttrs.begin(); for(; anAttr != allAttrs.end(); anAttr++) { @@ -193,7 +195,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { ResultPtr aRes = ModelAPI_Tools::findPartResult(aDoc, anAttr->value()); if (aRes.get()) { // Part result name (the same as saved file name) - aResult<< ModelAPI_Tools::toString(aRes->data()->name()); + aResult<< Locale::Convert::toString(aRes->data()->name()); } } else { aResult<kind(); // PartSet @@ -209,7 +211,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { if (anAttr->text().empty()) aResult<value(); else - aResult<text(); + aResult << Locale::Convert::toString(anAttr->text()); } else if (aType == ModelAPI_AttributeDouble::typeId()) { AttributeDoublePtr anAttr = std::dynamic_pointer_cast(theAttr); if (anAttr->id() == "ConstraintValue") { @@ -228,7 +230,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { double aVal = anAttr->value(); dumpArray(aResult, &aVal, 1, aPrecision); } else - aResult<text(); + aResult << Locale::Convert::toString(anAttr->text()); } else if (aType == ModelAPI_AttributeBoolean::typeId()) { AttributeBooleanPtr anAttr = std::dynamic_pointer_cast(theAttr); // do not dump internal flags of ConstraintAngle @@ -239,7 +241,12 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { } else if (aType == ModelAPI_AttributeString::typeId()) { AttributeStringPtr anAttr = std::dynamic_pointer_cast(theAttr); // do not dump solver DOF for sketch as it may be changed unexpectedly - if(anAttr->id() == "SolverDOF") { + if (anAttr->id() == "SolverDOF") { + return ""; + } + // do not dump file path for Image as it is changed after DumpPython + if (aFeatOwner->getKind() == "ImportImage" && + anAttr->id() == "file_path") { return ""; } aResult<value(); @@ -247,7 +254,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { AttributeReferencePtr anAttr = std::dynamic_pointer_cast(theAttr); if (anAttr->value().get()) { - aResult<< ModelAPI_Tools::toString(anAttr->value()->data()->name()); + aResult<< Locale::Convert::toString(anAttr->value()->data()->name()); } else { aResult<<"__empty__"; } @@ -255,7 +262,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { AttributeSelectionPtr anAttr = std::dynamic_pointer_cast(theAttr); if (anAttr->context().get()) - aResult<< ModelAPI_Tools::toString(anAttr->namingName()); + aResult<< Locale::Convert::toString(anAttr->namingName()); else aResult<<"__notinitialized__"; } else if (aType == ModelAPI_AttributeSelectionList::typeId()) { @@ -264,14 +271,14 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { for(int a = 0; a < anAttr->size(); a++) { if (a != 0) aResult<<" "; - aResult<< ModelAPI_Tools::toString(anAttr->value(a)->namingName()); + aResult<< Locale::Convert::toString(anAttr->value(a)->namingName()); } } else if (aType == ModelAPI_AttributeRefAttr::typeId()) { AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast(theAttr); ObjectPtr anObj = anAttr->isObject() ? anAttr->object() : anAttr->attr()->owner(); if (anObj.get()) { - aResult<< ModelAPI_Tools::toString(anObj->data()->name()); + aResult<< Locale::Convert::toString(anObj->data()->name()); if (!anAttr->isObject()) { aResult<<" "<attr()->id(); } @@ -297,7 +304,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { if (aStr == "SketchConstraint") continue; // no need to dump and check constraints } - aResList.push_back(ModelAPI_Tools::toString((*aL)->data()->name())); + aResList.push_back(Locale::Convert::toString((*aL)->data()->name())); } else if (!isSketchFeatures) { aResList.push_back("__empty__"); } @@ -317,7 +324,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { aResult<<" "; ObjectPtr anObj = aL->second.get() ? aL->second->owner() : aL->first; if (anObj.get()) { - aResult<< ModelAPI_Tools::toString(anObj->data()->name()); + aResult<< Locale::Convert::toString(anObj->data()->name()); if (aL->second.get()) { aResult<<" "<second->id(); } @@ -396,19 +403,17 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { } std::string ModelHighAPI_FeatureStore::dumpShape(std::shared_ptr& theShape) { - TopoDS_Shape aShape = theShape->impl(); - if (aShape.IsNull()) { + if (theShape->isNull()) { return "null"; } std::ostringstream aResult; // output the number of shapes of different types - TopAbs_ShapeEnum aType = TopAbs_COMPOUND; - for(; aType <= TopAbs_VERTEX; aType = TopAbs_ShapeEnum((int)aType + 1)) { - TopExp_Explorer anExp(aShape, aType); + GeomAPI_Shape::ShapeType aType = GeomAPI_Shape::COMPOUND; + for (; aType <= GeomAPI_Shape::VERTEX; aType = GeomAPI_Shape::ShapeType((int)aType + 1)) { + GeomAPI_ShapeExplorer anExp(theShape, aType); int aCount = 0; - for(; anExp.More(); anExp.Next()) aCount++; - TopAbs::Print(aType, aResult); - aResult<<": "<shapeTypeStr().c_str() << ": " << aCount << std::endl; } // output the main characteristics double aVolume = GeomAlgoAPI_ShapeTools::volume(theShape); @@ -421,6 +426,16 @@ std::string ModelHighAPI_FeatureStore::dumpShape(std::shared_ptr& aResult< 1.e-5) { + aResult << "Area: "; + // volumes of too huge shapes write in the scientific format + if (anArea >= 1.e5) + aResult << std::scientific << std::setprecision(7); + else + aResult << std::fixed << std::setprecision(3); + aResult << anArea << std::endl; + } std::shared_ptr aCenter = GeomAlgoAPI_ShapeTools::centreOfMass(theShape); aResult<<"Center of mass: "; double aCenterVals[3] = {aCenter->x(), aCenter->y(), aCenter->z()};