X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelHighAPI%2FModelHighAPI_Tools.cpp;h=3aa3579ad19d4df58f63c5c2c0bdae55f275466d;hb=f03c02cd62fe508c65818d31fdf9dcf69f8cbf35;hp=ffdab15225c33898e756327f385a0401c7d900ea;hpb=d2d54415aa7bc73156a11016dbc79e0ca592ce6a;p=modules%2Fshaper.git diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.cpp b/src/ModelHighAPI/ModelHighAPI_Tools.cpp index ffdab1522..3aa3579ad 100644 --- a/src/ModelHighAPI/ModelHighAPI_Tools.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Tools.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2019 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 @@ -12,10 +12,9 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "ModelHighAPI_Tools.h" @@ -346,6 +345,12 @@ GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection aShapeType = shapeTypeByStr(aType); break; } + case ModelHighAPI_Selection::VT_WeakNamingPair: { + TypeWeakNamingPair aPair = theSelection.typeWeakNamingPair(); + std::string aType = aPair.first; + aShapeType = shapeTypeByStr(aType); + break; + } } return aShapeType; @@ -377,7 +382,7 @@ std::string strByValueType(const ModelAPI_AttributeTables::ValueType theType) return ""; // bad case } -/// stores the features information, recoursively stores sub-documetns features +/// stores the features information, recursively stores sub-documents features std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc, std::map >& theStore, const bool theCompare) // if false => store @@ -390,7 +395,7 @@ std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc, } } // store the model features information: iterate all features - int anObjectsCount = 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 compare std::set aProcessed; // processed features names (that are in the current document) // process all objects (features and folders) @@ -422,7 +427,7 @@ std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc, ModelAPI_Tools::allResults(aFeature, allResults); std::list::iterator aRes = allResults.begin(); for(; aRes != allResults.end(); aRes++) { - // recoursively store features of sub-documents + // recursively store features of sub-documents if ((*aRes)->groupName() == ModelAPI_ResultPart::group()) { DocumentPtr aDoc = std::dynamic_pointer_cast(*aRes)->partDoc(); if (aDoc.get()) { @@ -458,7 +463,7 @@ typedef std::map > static bool dumpToPython(SessionPtr theSession, const char* theFilename, - const char* theSelectionType, + const checkDumpType theSelectionType, const std::string& theErrorMsgContext) { // 2431: set PartSet as a current document @@ -469,8 +474,9 @@ static bool dumpToPython(SessionPtr theSession, if (aDump.get()) { aDump->string("file_path")->setValue(theFilename); aDump->string("file_format")->setValue("py"); - aDump->string("selection_type")->setValue(theSelectionType); - aDump->execute(); + aDump->boolean("topological_naming")->setValue(theSelectionType & CHECK_NAMING); + aDump->boolean("geometric_selection")->setValue(theSelectionType & CHECK_GEOMETRICAL); + aDump->boolean("weak_naming")->setValue(theSelectionType & CHECK_WEAK); } bool isProblem = !aDump.get() || !aDump->error().empty(); // after "finish" dump will be removed if (isProblem && aDump.get()) { @@ -511,20 +517,21 @@ static bool checkDump(SessionPtr theSession, return true; } -bool checkPythonDump() +bool checkPythonDump(const checkDumpType theCheckType) { static const std::string anErrorByNaming("checkPythonDump by naming"); static const std::string anErrorByGeometry("checkPythonDump by geometry"); + static const std::string anErrorByWeak("checkPythonDump by weak naming"); - static char aFileForNamingDump[] = "./check_dump_byname.py"; - static char aFileForGeometryDump[] = "./check_dump_bygeom.py"; + static char aFileForNamingDump[] = "./check_dump.py"; + static char aFileForGeometryDump[] = "./check_dump_geo.py"; + static char aFileForWeakDump[] = "./check_dump_weak.py"; SessionPtr aSession = ModelAPI_Session::get(); - // dump with the selection by names - if (!dumpToPython(aSession, aFileForNamingDump, "topological_naming", anErrorByNaming)) - return false; - // dump with the selection by geometry - if (!dumpToPython(aSession, aFileForGeometryDump, "geometric_selection", anErrorByGeometry)) + // dump with the specified types + char* aFileName = theCheckType == CHECK_GEOMETRICAL ? aFileForGeometryDump : + (theCheckType == CHECK_WEAK ? aFileForWeakDump : aFileForNamingDump); + if (!dumpToPython(aSession, aFileName, theCheckType, anErrorByNaming)) return false; // map from document name to feature name to feature data @@ -537,10 +544,18 @@ bool checkPythonDump() return false; } - // check dump with the selection by names - bool isOk = checkDump(aSession, aFileForNamingDump, aStore, anErrorByNaming); - // check dump with the selection by geometry - isOk = isOk && checkDump(aSession, aFileForGeometryDump, aStore, anErrorByGeometry); + bool isOk = true; + if (theCheckType & CHECK_NAMING) { + // check dump with the selection by names + isOk = checkDump(aSession, aFileForNamingDump, aStore, anErrorByNaming); + } + if (theCheckType & CHECK_GEOMETRICAL) { + // check dump with the selection by geometry + isOk = isOk && checkDump(aSession, aFileForGeometryDump, aStore, anErrorByGeometry); + } + if (theCheckType & CHECK_WEAK) { + isOk = isOk && checkDump(aSession, aFileForWeakDump, aStore, anErrorByWeak); + } return isOk; }