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