X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelHighAPI%2FModelHighAPI_Tools.cpp;h=936775e47ec5e48f9366e107d97dbf8b4f214c2b;hb=5e2855aa69f9a63236c331efcb57ba433f92e901;hp=8f1938720491f21997eee2676bc0b331c92a68e9;hpb=661aafa65364b86fdbfc9fde9462d31bdf3ae151;p=modules%2Fshaper.git diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.cpp b/src/ModelHighAPI/ModelHighAPI_Tools.cpp index 8f1938720..936775e47 100644 --- a/src/ModelHighAPI/ModelHighAPI_Tools.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Tools.cpp @@ -27,10 +27,12 @@ #include #include #include +#include //-------------------------------------------------------------------------------------- #include #include #include +#include #include #include #include @@ -239,6 +241,29 @@ void fillAttribute(const std::list & theValue, theAttribute->setValue(anIndex, it->intValue()); // use only values, no text support in array } +//-------------------------------------------------------------------------------------- +void fillAttribute(const std::list & theValue, + const std::shared_ptr & theAttribute) +{ + theAttribute->setSize(int(theValue.size())); + + int anIndex = 0; + for (auto it = theValue.begin(); it != theValue.end(); ++it, ++anIndex) + theAttribute->setValue(anIndex, it->value()); // use only values, no text support in array +} + +//-------------------------------------------------------------------------------------- +void fillAttribute(const std::list > & theValue, + const std::shared_ptr & theAttribute) +{ + theAttribute->setSize(int(theValue.size())); + + int anIndex = 0; + for (auto it = theValue.begin(); it != theValue.end(); ++it, ++anIndex) + theAttribute->setPnt(anIndex, *it); +} + +//-------------------------------------------------------------------------------------- void fillAttribute(const ModelHighAPI_Double & theX, const ModelHighAPI_Double & theY, const ModelHighAPI_Double & theZ, @@ -247,7 +272,6 @@ void fillAttribute(const ModelHighAPI_Double & theX, theX.fillAttribute(theAttribute, theX, theY, theZ); } - //================================================================================================== GeomAPI_Shape::ShapeType shapeTypeByStr(std::string theShapeTypeStr) { @@ -404,9 +428,13 @@ std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc, for(; allIter != allObjects.end(); allIter++) { ObjectPtr anObject = *allIter; FeaturePtr aFeature = std::dynamic_pointer_cast(anObject); - if (aFeature && aFeature->getKind() == "SketchConstraintCoincidenceInternal") - continue; // no need to dump and check internal constraints + //if (aFeature && aFeature->getKind() == "SketchConstraintCoincidenceInternal") + if (aFeature) { + std::string aStr = aFeature->getKind().substr(0, 16); + if (aStr == "SketchConstraint") + continue; // no need to dump and check constraints + } if (theCompare) { std::map::iterator anObjFind = aDocFind->second.find(anObject->data()->name()); @@ -465,7 +493,7 @@ std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc, typedef std::map > Storage; static bool dumpToPython(SessionPtr theSession, - const char* theFilename, + const std::string& theFilename, const checkDumpType theSelectionType, const std::string& theErrorMsgContext) { @@ -492,7 +520,7 @@ static bool dumpToPython(SessionPtr theSession, } static bool checkDump(SessionPtr theSession, - char* theFilename, + const char* theFilename, Storage& theStorage, const std::string& theErrorMsgContext) { @@ -520,20 +548,29 @@ static bool checkDump(SessionPtr theSession, return true; } -bool checkPythonDump(const checkDumpType theCheckType) +bool checkPyDump(const std::string& theFilenameNaming, + const std::string& theFilenameGeo, + const std::string& theFilenameWeak, + 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.py"; - static char aFileForGeometryDump[] = "./check_dump_geo.py"; - static char aFileForWeakDump[] = "./check_dump_weak.py"; +#ifdef _DEBUG + std::string aFileForNamingDump("./check_dump.py"); + std::string aFileForGeometryDump("./check_dump_geo.py"); + std::string aFileForWeakDump("./check_dump_weak.py"); +#else + std::string aFileForNamingDump = theFilenameNaming; + std::string aFileForGeometryDump = theFilenameGeo; + std::string aFileForWeakDump = theFilenameWeak; +#endif SessionPtr aSession = ModelAPI_Session::get(); // dump with the specified types - char* aFileName = theCheckType == CHECK_GEOMETRICAL ? aFileForGeometryDump : - (theCheckType == CHECK_WEAK ? aFileForWeakDump : aFileForNamingDump); + std::string aFileName = theCheckType == CHECK_GEOMETRICAL ? aFileForGeometryDump : + (theCheckType == CHECK_WEAK ? aFileForWeakDump : aFileForNamingDump); if (!dumpToPython(aSession, aFileName, theCheckType, anErrorByNaming)) return false; @@ -550,14 +587,14 @@ bool checkPythonDump(const checkDumpType theCheckType) bool isOk = true; if (theCheckType & CHECK_NAMING) { // check dump with the selection by names - isOk = checkDump(aSession, aFileForNamingDump, aStore, anErrorByNaming); + isOk = checkDump(aSession, aFileForNamingDump.c_str(), aStore, anErrorByNaming); } if (theCheckType & CHECK_GEOMETRICAL) { // check dump with the selection by geometry - isOk = isOk && checkDump(aSession, aFileForGeometryDump, aStore, anErrorByGeometry); + isOk = isOk && checkDump(aSession, aFileForGeometryDump.c_str(), aStore, anErrorByGeometry); } if (theCheckType & CHECK_WEAK) { - isOk = isOk && checkDump(aSession, aFileForWeakDump, aStore, anErrorByWeak); + isOk = isOk && checkDump(aSession, aFileForWeakDump.c_str(), aStore, anErrorByWeak); } return isOk;