]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelHighAPI/ModelHighAPI_Tools.cpp
Salome HOME
0b72c418f795263e3808897a343f6f11068bf968
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Tools.cpp
1 // Copyright (C) 2014-2020  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "ModelHighAPI_Tools.h"
21 #include <ModelHighAPI_FeatureStore.h>
22 //--------------------------------------------------------------------------------------
23 #include <GeomAPI_Dir.h>
24 #include <GeomAPI_Pnt.h>
25 #include <GeomAPI_Pnt2d.h>
26 //--------------------------------------------------------------------------------------
27 #include <GeomDataAPI_Dir.h>
28 #include <GeomDataAPI_Point.h>
29 #include <GeomDataAPI_Point2D.h>
30 #include <GeomDataAPI_Point2DArray.h>
31 //--------------------------------------------------------------------------------------
32 #include <Locale_Convert.h>
33 //--------------------------------------------------------------------------------------
34 #include <ModelAPI_AttributeBoolean.h>
35 #include <ModelAPI_AttributeDocRef.h>
36 #include <ModelAPI_AttributeDouble.h>
37 #include <ModelAPI_AttributeDoubleArray.h>
38 #include <ModelAPI_AttributeIntArray.h>
39 #include <ModelAPI_AttributeInteger.h>
40 #include <ModelAPI_AttributeRefAttr.h>
41 #include <ModelAPI_AttributeRefAttrList.h>
42 #include <ModelAPI_AttributeReference.h>
43 #include <ModelAPI_AttributeRefList.h>
44 #include <ModelAPI_AttributeSelection.h>
45 #include <ModelAPI_AttributeSelectionList.h>
46 #include <ModelAPI_AttributeString.h>
47 #include <ModelAPI_AttributeStringArray.h>
48 #include <ModelAPI_AttributeDoubleArray.h>
49 #include <ModelAPI_Session.h>
50 #include <ModelAPI_Tools.h>
51 #include <ModelAPI_ResultPart.h>
52 #include <ModelAPI_Events.h>
53 //--------------------------------------------------------------------------------------
54 #include <Config_ModuleReader.h>
55 //--------------------------------------------------------------------------------------
56 #include "ModelHighAPI_Double.h"
57 #include "ModelHighAPI_Integer.h"
58 #include "ModelHighAPI_RefAttr.h"
59 #include "ModelHighAPI_Reference.h"
60 #include "ModelHighAPI_Selection.h"
61
62 #include <Events_InfoMessage.h>
63
64 // Have to be included before std headers
65 #include <Python.h>
66
67 #include <algorithm>
68 #include <iostream>
69
70 //--------------------------------------------------------------------------------------
71 void fillAttribute(const std::shared_ptr<GeomAPI_Pnt2d> & theValue,
72                    const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute)
73 {
74   theAttribute->setValue(theValue);
75 }
76
77 void fillAttribute(const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute,
78                    double theX, double theY)
79 {
80   theAttribute->setValue(theX, theY);
81 }
82
83 //--------------------------------------------------------------------------------------
84 void fillAttribute(const std::shared_ptr<GeomAPI_Dir> & theValue,
85                    const std::shared_ptr<GeomDataAPI_Dir> & theAttribute)
86 {
87   theAttribute->setValue(theValue);
88 }
89
90 //--------------------------------------------------------------------------------------
91 void fillAttribute(const std::shared_ptr<GeomAPI_Pnt> & theValue,
92                    const std::shared_ptr<GeomDataAPI_Point> & theAttribute)
93 {
94   theAttribute->setValue(theValue);
95 }
96
97 //--------------------------------------------------------------------------------------
98 void fillAttribute(bool theValue,
99                    const std::shared_ptr<ModelAPI_AttributeBoolean> & theAttribute)
100 {
101   theAttribute->setValue(theValue);
102 }
103
104 //--------------------------------------------------------------------------------------
105 void fillAttribute(const ModelHighAPI_Double & theValue,
106                    const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute)
107 {
108   theValue.fillAttribute(theAttribute);
109 }
110 void fillAttribute(double theValue,
111                    const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute)
112 {
113   theAttribute->setValue(theValue);
114 }
115
116 //--------------------------------------------------------------------------------------
117 void fillAttribute(const ModelHighAPI_Integer & theValue,
118                    const std::shared_ptr<ModelAPI_AttributeInteger> & theAttribute)
119 {
120   theValue.fillAttribute(theAttribute);
121 }
122 void fillAttribute(int theValue,
123                    const std::shared_ptr<ModelAPI_AttributeInteger> & theAttribute)
124 {
125   theAttribute->setValue(theValue);
126 }
127
128 //--------------------------------------------------------------------------------------
129 void fillAttribute(const ModelHighAPI_RefAttr & theValue,
130                    const std::shared_ptr<ModelAPI_AttributeRefAttr> & theAttribute)
131 {
132   theValue.fillAttribute(theAttribute);
133 }
134
135 //--------------------------------------------------------------------------------------
136 void fillAttribute(const std::list<ModelHighAPI_RefAttr> & theValue,
137                    const std::shared_ptr<ModelAPI_AttributeRefAttrList> & theAttribute)
138 {
139   theAttribute->clear();
140   for (auto it = theValue.begin(); it != theValue.end(); ++it)
141     it->appendToList(theAttribute);
142 }
143
144 //--------------------------------------------------------------------------------------
145 void fillAttribute(const ModelHighAPI_Reference & theValue,
146                    const std::shared_ptr<ModelAPI_AttributeReference> & theAttribute)
147 {
148   theValue.fillAttribute(theAttribute);
149 }
150
151 //--------------------------------------------------------------------------------------
152 void fillAttribute(const std::list<ModelHighAPI_Reference> & theValue,
153                    const std::shared_ptr<ModelAPI_AttributeRefList> & theAttribute)
154 {
155   theAttribute->clear();
156   for (auto it = theValue.begin(); it != theValue.end(); ++it)
157     it->appendToList(theAttribute);
158 }
159
160 //--------------------------------------------------------------------------------------
161 void fillAttribute(const std::shared_ptr<ModelAPI_Object> & theValue,
162                    const std::shared_ptr<ModelAPI_AttributeReference> & theAttribute)
163 {
164   theAttribute->setValue(theValue);
165 }
166
167 //--------------------------------------------------------------------------------------
168 void fillAttribute(const std::list<std::shared_ptr<ModelAPI_Object> > & theValue,
169                    const std::shared_ptr<ModelAPI_AttributeRefList> & theAttribute)
170 {
171   theAttribute->clear();
172   for (auto it = theValue.begin(); it != theValue.end(); ++it)
173     theAttribute->append(*it);
174 }
175
176 MODELHIGHAPI_EXPORT
177 void fillAttribute(const std::list<ModelHighAPI_Selection> & theValue,
178                    const std::shared_ptr<ModelAPI_AttributeRefList> & theAttribute)
179 {
180   theAttribute->clear();
181   for (auto it = theValue.begin(); it != theValue.end(); ++it) {
182     if (it->resultSubShapePair().first)
183       theAttribute->append(it->resultSubShapePair().first); // use only context
184   }
185 }
186
187 //--------------------------------------------------------------------------------------
188 void fillAttribute(const ModelHighAPI_Selection & theValue,
189                    const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute)
190 {
191   theValue.fillAttribute(theAttribute);
192 }
193
194 //--------------------------------------------------------------------------------------
195 void fillAttribute(const std::list<ModelHighAPI_Selection> & theValue,
196                    const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute)
197 {
198   theAttribute->clear();
199
200   if(!theValue.empty() && theAttribute->selectionType().empty()) {
201     const ModelHighAPI_Selection& aSelection = theValue.front();
202     GeomAPI_Shape::ShapeType aSelectionType = getShapeType(aSelection);
203     theAttribute->setSelectionType(strByShapeType(aSelectionType));
204   }
205
206   for (auto it = theValue.begin(); it != theValue.end(); ++it)
207     it->appendToList(theAttribute);
208 }
209
210 //--------------------------------------------------------------------------------------
211 void fillAttribute(const std::string & theValue,
212                    const std::shared_ptr<ModelAPI_AttributeString> & theAttribute)
213 {
214   theAttribute->setValue(theValue);
215 }
216
217 //--------------------------------------------------------------------------------------
218 void fillAttribute(const char * theValue,
219                    const std::shared_ptr<ModelAPI_AttributeString> & theAttribute)
220 {
221   theAttribute->setValue(theValue);
222 }
223
224 //--------------------------------------------------------------------------------------
225 void fillAttribute(const std::list<std::string> & theValue,
226                    const std::shared_ptr<ModelAPI_AttributeStringArray> & theAttribute)
227 {
228   theAttribute->setSize(int(theValue.size()));
229
230   int anIndex = 0;
231   for (auto it = theValue.begin(); it != theValue.end(); ++it, ++anIndex)
232     theAttribute->setValue(anIndex, *it);
233 }
234
235 //--------------------------------------------------------------------------------------
236 void fillAttribute(const std::list<ModelHighAPI_Integer> & theValue,
237                    const std::shared_ptr<ModelAPI_AttributeIntArray> & theAttribute)
238 {
239   theAttribute->setSize(int(theValue.size()));
240
241   int anIndex = 0;
242   for (auto it = theValue.begin(); it != theValue.end(); ++it, ++anIndex)
243     theAttribute->setValue(anIndex, it->intValue()); // use only values, no text support in array
244 }
245
246 //--------------------------------------------------------------------------------------
247 void fillAttribute(const std::list<ModelHighAPI_Double> & theValue,
248                    const std::shared_ptr<ModelAPI_AttributeDoubleArray> & theAttribute)
249 {
250   theAttribute->setSize(int(theValue.size()));
251
252   int anIndex = 0;
253   for (auto it = theValue.begin(); it != theValue.end(); ++it, ++anIndex)
254     theAttribute->setValue(anIndex, it->value()); // use only values, no text support in array
255 }
256
257 //--------------------------------------------------------------------------------------
258 void fillAttribute(const std::list<std::shared_ptr<GeomAPI_Pnt2d> > & theValue,
259                    const std::shared_ptr<GeomDataAPI_Point2DArray> & theAttribute)
260 {
261   theAttribute->setSize(int(theValue.size()));
262
263   int anIndex = 0;
264   for (auto it = theValue.begin(); it != theValue.end(); ++it, ++anIndex)
265     theAttribute->setPnt(anIndex, *it);
266 }
267
268 //--------------------------------------------------------------------------------------
269 void fillAttribute(const ModelHighAPI_Double & theX,
270                    const ModelHighAPI_Double & theY,
271                    const ModelHighAPI_Double & theZ,
272                    const std::shared_ptr<GeomDataAPI_Point> & theAttribute)
273 {
274   theX.fillAttribute(theAttribute, theX, theY, theZ);
275 }
276
277 //==================================================================================================
278 GeomAPI_Shape::ShapeType shapeTypeByStr(std::string theShapeTypeStr)
279 {
280   GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::SHAPE;
281
282   std::transform(theShapeTypeStr.begin(), theShapeTypeStr.end(), theShapeTypeStr.begin(),
283                  [](char c) { return static_cast<char>(::tolower(c)); });
284
285   if(theShapeTypeStr == "compound") {
286     aShapeType = GeomAPI_Shape::COMPOUND;
287   } else if(theShapeTypeStr == "compsolid") {
288     aShapeType = GeomAPI_Shape::COMPSOLID;
289   } else if(theShapeTypeStr == "solid") {
290     aShapeType = GeomAPI_Shape::SOLID;
291   } else if(theShapeTypeStr == "shell") {
292     aShapeType = GeomAPI_Shape::SHELL;
293   } else if(theShapeTypeStr == "face") {
294     aShapeType = GeomAPI_Shape::FACE;
295   } else if(theShapeTypeStr == "wire") {
296     aShapeType = GeomAPI_Shape::WIRE;
297   } else if(theShapeTypeStr == "edge") {
298     aShapeType = GeomAPI_Shape::EDGE;
299   } else if(theShapeTypeStr == "vertex") {
300     aShapeType = GeomAPI_Shape::VERTEX;
301   } else if(theShapeTypeStr == "shape") {
302     aShapeType = GeomAPI_Shape::SHAPE;
303   }
304
305   return aShapeType;
306 }
307
308 std::string strByShapeType(GeomAPI_Shape::ShapeType theShapeType)
309 {
310   std::string aShapeTypeStr;
311   switch (theShapeType) {
312   case GeomAPI_Shape::COMPOUND:
313     aShapeTypeStr = "COMPOUND";
314     break;
315   case GeomAPI_Shape::COMPSOLID:
316     aShapeTypeStr = "COMPSOLID";
317     break;
318   case GeomAPI_Shape::SOLID:
319     aShapeTypeStr = "SOLID";
320     break;
321   case GeomAPI_Shape::SHELL:
322     aShapeTypeStr = "SHELL";
323     break;
324   case GeomAPI_Shape::FACE:
325     aShapeTypeStr = "FACE";
326     break;
327   case GeomAPI_Shape::WIRE:
328     aShapeTypeStr = "WIRE";
329     break;
330   case GeomAPI_Shape::EDGE:
331     aShapeTypeStr = "EDGE";
332     break;
333   case GeomAPI_Shape::VERTEX:
334     aShapeTypeStr = "VERTEX";
335     break;
336   default:
337     aShapeTypeStr = "SHAPE";
338     break;
339   }
340   return aShapeTypeStr;
341 }
342
343 //==================================================================================================
344 GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection)
345 {
346   GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::SHAPE;
347
348   switch(theSelection.variantType()) {
349     case ModelHighAPI_Selection::VT_ResultSubShapePair: {
350       ResultSubShapePair aPair = theSelection.resultSubShapePair();
351       GeomShapePtr aShape = aPair.second;
352       if(!aShape.get()) {
353         aShape = aPair.first->shape();
354       }
355       if(!aShape.get()) {
356         return aShapeType;
357       }
358       aShapeType = aShape->shapeType();
359       break;
360     }
361     case ModelHighAPI_Selection::VT_TypeSubShapeNamePair: {
362       TypeSubShapeNamePair aPair = theSelection.typeSubShapeNamePair();
363       std::string aType = aPair.first;
364       aShapeType = shapeTypeByStr(aType);
365       break;
366     }
367     case ModelHighAPI_Selection::VT_TypeInnerPointPair: {
368       TypeInnerPointPair aPair = theSelection.typeInnerPointPair();
369       std::string aType = aPair.first;
370       aType = aType.substr(0, aType.find_first_of('_'));
371       aShapeType = shapeTypeByStr(aType);
372       break;
373     }
374     case ModelHighAPI_Selection::VT_WeakNamingPair: {
375       TypeWeakNamingPair aPair = theSelection.typeWeakNamingPair();
376       std::string aType = aPair.first;
377       aShapeType = shapeTypeByStr(aType);
378       break;
379     }
380     default:
381       break; // do nothing [to avoid compilation warning]
382   }
383
384   return aShapeType;
385 }
386
387 //--------------------------------------------------------------------------------------
388 ModelAPI_AttributeTables::ValueType valueTypeByStr(const std::string& theValueTypeStr)
389 {
390   std::string aType = theValueTypeStr;
391   std::transform(aType.begin(), aType.end(), aType.begin(),
392                  [](char c) { return static_cast<char>(::tolower(c)); });
393   if (aType == "boolean")
394     return ModelAPI_AttributeTables::BOOLEAN;
395   else if (aType == "integer")
396     return ModelAPI_AttributeTables::INTEGER;
397   else if (aType == "string")
398     return ModelAPI_AttributeTables::STRING;
399   return ModelAPI_AttributeTables::DOUBLE; // default
400 }
401
402 //--------------------------------------------------------------------------------------
403 std::string strByValueType(const ModelAPI_AttributeTables::ValueType theType)
404 {
405   switch(theType) {
406   case ModelAPI_AttributeTables::BOOLEAN: return "BOOLEAN";
407   case ModelAPI_AttributeTables::INTEGER: return "INTEGER";
408   case ModelAPI_AttributeTables::DOUBLE: return "DOUBLE";
409   case ModelAPI_AttributeTables::STRING: return "STRING";
410   }
411   return ""; // bad case
412 }
413
414 /// stores the features information, recursively stores sub-documents features
415 std::string storeFeatures(const std::wstring& theDocName, DocumentPtr theDoc,
416   std::map<std::wstring, std::map<std::wstring, ModelHighAPI_FeatureStore> >& theStore,
417   const bool theCompare) // if false => store
418 {
419   std::map<std::wstring, std::map<std::wstring, ModelHighAPI_FeatureStore> >::iterator aDocFind;
420   if (theCompare) {
421      aDocFind = theStore.find(theDocName);
422      if (aDocFind == theStore.end()) {
423        return "Document '" + Locale::Convert::toString(theDocName) + "' not found";
424      }
425   }
426   // store the model features information: iterate all features
427   size_t anObjectsCount = 0; // stores the number of compared features for this document to compare
428   std::set<std::wstring> aProcessed; // processed features names (that are in the current document)
429
430   // process all objects (features and folders)
431   std::list<ObjectPtr> allObjects = theDoc->allObjects();
432   std::list<ObjectPtr>::iterator allIter = allObjects.begin();
433   for(; allIter != allObjects.end(); allIter++) {
434     ObjectPtr anObject = *allIter;
435     FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
436     //if (aFeature && aFeature->getKind() == "SketchConstraintCoincidenceInternal")
437
438     if (aFeature) {
439       std::string aStr = aFeature->getKind().substr(0, 16);
440       if (aStr == "SketchConstraint")
441         continue; // no need to dump and check constraints
442     }
443     if (theCompare) {
444       std::map<std::wstring, ModelHighAPI_FeatureStore>::iterator
445         anObjFind = aDocFind->second.find(anObject->data()->name());
446       if (anObjFind == aDocFind->second.end()) {
447         return "Document '" + Locale::Convert::toString(theDocName)
448           + "' feature '" + Locale::Convert::toString(anObject->data()->name()) + "' not found";
449       }
450       std::string anError = anObjFind->second.compare(anObject);
451       if (!anError.empty()) {
452         anError = "Document " + Locale::Convert::toString(theDocName) + " " + anError;
453         return anError;
454       }
455       anObjectsCount++;
456       aProcessed.insert(anObject->data()->name());
457     } else {
458       theStore[theDocName][anObject->data()->name()] = ModelHighAPI_FeatureStore(anObject);
459     }
460
461     if (aFeature) {
462       // iterate all results of this feature
463       std::list<ResultPtr> allResults;
464       ModelAPI_Tools::allResults(aFeature, allResults);
465       std::list<ResultPtr>::iterator aRes = allResults.begin();
466       for(; aRes != allResults.end(); aRes++) {
467         // recursively store features of sub-documents
468         if ((*aRes)->groupName() == ModelAPI_ResultPart::group()) {
469           DocumentPtr aDoc = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aRes)->partDoc();
470           if (aDoc.get()) {
471             std::string anError =
472                 storeFeatures((*aRes)->data()->name(), aDoc, theStore, theCompare);
473             if (!anError.empty())
474               return anError;
475           }
476         }
477       }
478     }
479   }
480   // checks the number of compared features
481   if (theCompare) {
482     if (aDocFind->second.size() != anObjectsCount) {
483       // search for disappeared feature
484       std::wstring aLostName;
485       std::map<std::wstring, ModelHighAPI_FeatureStore>::iterator aLostIter;
486       for(aLostIter = aDocFind->second.begin(); aLostIter != aDocFind->second.end(); aLostIter++) {
487         if (aProcessed.find(aLostIter->first) == aProcessed.end()) {
488           aLostName = aLostIter->first;
489         }
490       }
491       return "For document '" + Locale::Convert::toString(theDocName) +
492         "' the number of features is decreased, there is no feature '" +
493         Locale::Convert::toString(aLostName) + "'";
494     }
495   }
496   return ""; // ok
497 }
498
499 //==================================================================================================
500 typedef std::map<std::wstring, std::map<std::wstring, ModelHighAPI_FeatureStore> > Storage;
501
502 static bool dumpToPython(SessionPtr theSession,
503                          const std::string& theFilename,
504                          const checkDumpType theSelectionType,
505                          const std::string& theErrorMsgContext)
506 {
507   // 2431: set PartSet as a current document
508   theSession->setActiveDocument(theSession->moduleDocument(), true);
509   // dump all to the python file
510   theSession->startOperation("Check python dump");
511   FeaturePtr aDump = theSession->moduleDocument()->addFeature("Dump");
512   if (aDump.get()) {
513     aDump->string("file_path")->setValue(theFilename);
514     aDump->string("file_format")->setValue("py");
515     aDump->boolean("topological_naming")->setValue((theSelectionType & CHECK_NAMING) != 0);
516     aDump->boolean("geometric_selection")->setValue((theSelectionType & CHECK_GEOMETRICAL) != 0);
517     aDump->boolean("weak_naming")->setValue((theSelectionType & CHECK_WEAK) != 0);
518   }
519   bool isProblem = !aDump.get() || !aDump->error().empty(); // after "finish" dump will be removed
520   if (isProblem && aDump.get()) {
521     std::cout << "Dump feature error " << aDump->error() << std::endl;
522     Events_InfoMessage anErrorMsg(theErrorMsgContext, aDump->error());
523     anErrorMsg.send();
524   }
525   theSession->finishOperation();
526   return !isProblem;
527 }
528
529 static bool checkDump(SessionPtr theSession,
530                       const char* theFilename,
531                       Storage& theStorage,
532                       const std::string& theErrorMsgContext)
533 {
534
535   // close all before importation of the script
536   theSession->closeAll();
537
538   // execute the dumped
539   PyGILState_STATE gstate = PyGILState_Ensure(); /* acquire python thread */
540   static char aReadMode[] = "r";
541   FILE* PyFileObject = _Py_fopen(theFilename, aReadMode);
542   PyRun_SimpleFileEx(PyFileObject, theFilename, 1);
543   PyGILState_Release(gstate); /* release python thread */
544
545   // compare with the stored data
546   std::string anError =
547     storeFeatures(Locale::Convert::toWString(theSession->moduleDocument()->kind()),
548     theSession->moduleDocument(), theStorage, true);
549   if (!anError.empty()) {
550     std::cout << anError << std::endl;
551     Events_InfoMessage anErrorMsg(theErrorMsgContext, anError);
552     anErrorMsg.send();
553     return false;
554   }
555
556   return true;
557 }
558
559 bool checkPyDump(
560 #ifdef _DEBUG
561   const std::string&, const std::string&, const std::string&,
562 #else
563   const std::string& theFilenameNaming,
564   const std::string& theFilenameGeo,
565   const std::string& theFilenameWeak,
566 #endif
567   const checkDumpType theCheckType)
568 {
569   static const std::string anErrorByNaming("checkPythonDump by naming");
570   static const std::string anErrorByGeometry("checkPythonDump by geometry");
571   static const std::string anErrorByWeak("checkPythonDump by weak naming");
572
573 #ifdef _DEBUG
574   std::string aFileForNamingDump("./check_dump.py");
575   std::string aFileForGeometryDump("./check_dump_geo.py");
576   std::string aFileForWeakDump("./check_dump_weak.py");
577 #else
578   std::string aFileForNamingDump = theFilenameNaming;
579   std::string aFileForGeometryDump = theFilenameGeo;
580   std::string aFileForWeakDump = theFilenameWeak;
581 #endif
582
583   SessionPtr aSession = ModelAPI_Session::get();
584   // dump with the specified types
585   std::string aFileName = theCheckType == CHECK_GEOMETRICAL ? aFileForGeometryDump :
586                           (theCheckType == CHECK_WEAK ? aFileForWeakDump : aFileForNamingDump);
587   if (!dumpToPython(aSession, aFileName, theCheckType, anErrorByNaming))
588     return false;
589
590    // map from document name to feature name to feature data
591   std::map<std::wstring, std::map<std::wstring, ModelHighAPI_FeatureStore> > aStore;
592   std::string anError =
593     storeFeatures(Locale::Convert::toWString(aSession->moduleDocument()->kind()),
594     aSession->moduleDocument(), aStore, false);
595   if (!anError.empty()) {
596     Events_InfoMessage anErrorMsg(std::string("checkPythonDump"), anError);
597     anErrorMsg.send();
598     return false;
599   }
600
601   bool isOk = true;
602   if (theCheckType & CHECK_NAMING) {
603     // check dump with the selection by names
604     isOk = checkDump(aSession, aFileForNamingDump.c_str(), aStore, anErrorByNaming);
605   }
606   if (theCheckType & CHECK_GEOMETRICAL) {
607     // check dump with the selection by geometry
608     isOk = isOk && checkDump(aSession, aFileForGeometryDump.c_str(), aStore, anErrorByGeometry);
609   }
610   if (theCheckType & CHECK_WEAK) {
611     isOk = isOk && checkDump(aSession, aFileForWeakDump.c_str(), aStore, anErrorByWeak);
612   }
613
614   return isOk;
615 }
616
617 //--------------------------------------------------------------------------------------