1 // Copyright (C) 2016-20xx CEA/DEN, EDF R&D -->
3 // File: ModelHighAPI_Dumper.cpp
4 // Created: 1 August 2016
5 // Author: Artem ZHIDKOV
7 //--------------------------------------------------------------------------------------
8 #include "ModelHighAPI_Dumper.h"
10 #include <GeomAPI_Pnt.h>
11 #include <GeomAPI_Dir.h>
13 #include <GeomDataAPI_Dir.h>
14 #include <GeomDataAPI_Point.h>
15 #include <GeomDataAPI_Point2D.h>
17 #include <ModelAPI_AttributeBoolean.h>
18 #include <ModelAPI_AttributeDouble.h>
19 #include <ModelAPI_AttributeIntArray.h>
20 #include <ModelAPI_AttributeInteger.h>
21 #include <ModelAPI_AttributeRefAttr.h>
22 #include <ModelAPI_AttributeRefAttrList.h>
23 #include <ModelAPI_AttributeReference.h>
24 #include <ModelAPI_AttributeRefList.h>
25 #include <ModelAPI_AttributeSelection.h>
26 #include <ModelAPI_AttributeSelectionList.h>
27 #include <ModelAPI_AttributeString.h>
28 #include <ModelAPI_CompositeFeature.h>
29 #include <ModelAPI_Document.h>
30 #include <ModelAPI_Entity.h>
31 #include <ModelAPI_Feature.h>
32 #include <ModelAPI_Result.h>
33 #include <ModelAPI_ResultPart.h>
35 #include <PartSetPlugin_Part.h>
37 #include <OSD_OpenFile.hxx>
41 static int gCompositeStackDepth = 0;
43 ModelHighAPI_Dumper* ModelHighAPI_Dumper::mySelf = 0;
45 ModelHighAPI_Dumper::ModelHighAPI_Dumper()
50 void ModelHighAPI_Dumper::setInstance(ModelHighAPI_Dumper* theDumper)
56 ModelHighAPI_Dumper* ModelHighAPI_Dumper::getInstance()
61 void ModelHighAPI_Dumper::clear(bool bufferOnly)
64 myDumpBuffer << std::setprecision(16);
70 myFullDump << std::setprecision(16);
74 myFeatureCount.clear();
75 while (!myEntitiesStack.empty())
76 myEntitiesStack.pop();
80 void ModelHighAPI_Dumper::clearNotDumped()
82 myNotDumpedEntities.clear();
85 const std::string& ModelHighAPI_Dumper::name(const EntityPtr& theEntity,
86 bool theSaveNotDumped,
87 bool theUseEntityName)
89 EntityNameMap::const_iterator aFound = myNames.find(theEntity);
90 if (aFound != myNames.end())
91 return aFound->second.myCurrentName;
93 // entity is not found, store it
95 bool isDefaultName = false;
96 std::ostringstream aDefaultName;
97 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theEntity);
99 aName = aFeature->name();
100 const std::string& aKind = aFeature->getKind();
101 DocumentPtr aDoc = aFeature->document();
102 int& aNbFeatures = myFeatureCount[aDoc][aKind];
105 size_t anIndex = aName.find(aKind);
106 if (anIndex == 0 && aName[aKind.length()] == '_') { // name starts with "FeatureKind_"
107 std::string anIdStr = aName.substr(aKind.length() + 1);
108 int anId = std::stoi(anIdStr);
110 // Check number of already registered objects of such kind. Index of current object
111 // should be the same to identify feature's name as automatically generated.
112 if (aNbFeatures == anId) {
113 // name is not user-defined
115 isDefaultName = true;
119 // obtain default name for the feature
120 if (theUseEntityName)
121 aDefaultName << aName;
124 NbFeaturesMap::const_iterator aFIt = myFeatureCount.begin();
125 for (; aFIt != myFeatureCount.end(); ++aFIt) {
126 std::map<std::string, int>::const_iterator aFound = aFIt->second.find(aKind);
127 if (aFound != aFIt->second.end())
128 aFullIndex += aFound->second;
130 aDefaultName << aKind << "_" << aFullIndex;
134 myNames[theEntity] = EntityName(aDefaultName.str(), aName, isDefaultName);
135 if (theSaveNotDumped)
136 myNotDumpedEntities.insert(theEntity);
138 // store names of results
140 saveResultNames(aFeature);
142 return myNames[theEntity].myCurrentName;
145 const std::string& ModelHighAPI_Dumper::parentName(const FeaturePtr& theEntity)
147 const std::set<AttributePtr>& aRefs = theEntity->data()->refsToMe();
148 std::set<AttributePtr>::const_iterator aRefIt = aRefs.begin();
149 for (; aRefIt != aRefs.end(); ++aRefIt) {
150 CompositeFeaturePtr anOwner = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(
151 ModelAPI_Feature::feature((*aRefIt)->owner()));
153 return name(anOwner);
156 static const std::string DUMMY;
160 void ModelHighAPI_Dumper::saveResultNames(const FeaturePtr& theFeature)
162 const std::string& aFeatureName = myNames[theFeature].myCurrentName;
163 const std::list<ResultPtr>& aResults = theFeature->results();
164 std::list<ResultPtr>::const_iterator aResIt = aResults.begin();
165 for (int i = 1; aResIt != aResults.end(); ++aResIt, ++i) {
166 bool isUserDefined = true;
167 std::string aResName = (*aResIt)->data()->name();
168 size_t anIndex = aResName.find(aFeatureName);
170 std::string aSuffix = aResName.substr(aFeatureName.length());
171 if (aSuffix.empty() && i == 1) // first result may not constain index in the name
172 isUserDefined = false;
174 if (aSuffix[0] == '_' && std::stoi(aSuffix.substr(1)) == i)
175 isUserDefined = false;
179 myNames[*aResIt] = EntityName(aResName,
180 (isUserDefined ? aResName : std::string()), !isUserDefined);
184 bool ModelHighAPI_Dumper::process(const std::shared_ptr<ModelAPI_Document>& theDoc,
185 const std::string& theFileName)
187 // dump top level document feature
188 static const std::string aDocName("partSet");
189 myNames[theDoc] = EntityName(aDocName, std::string(), true);
190 *this << aDocName << " = model.moduleDocument()" << std::endl;
192 // dump subfeatures and store result to file
193 return process(theDoc) && exportTo(theFileName);
196 bool ModelHighAPI_Dumper::process(const std::shared_ptr<ModelAPI_Document>& theDoc)
199 std::list<FeaturePtr> aFeatures = theDoc->allFeatures();
200 std::list<FeaturePtr>::const_iterator aFeatIt = aFeatures.begin();
201 // firstly, dump all parameters
202 for (; aFeatIt != aFeatures.end(); ++ aFeatIt)
203 dumpParameter(*aFeatIt);
204 // dump all other features
205 for (aFeatIt = aFeatures.begin(); aFeatIt != aFeatures.end(); ++aFeatIt) {
206 CompositeFeaturePtr aCompFeat = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(*aFeatIt);
207 if (aCompFeat) // iteratively process composite features
208 isOk = process(aCompFeat) && isOk;
209 else if (!isDumped(*aFeatIt)) // dump common feature
210 dumpFeature(*aFeatIt);
215 bool ModelHighAPI_Dumper::process(const std::shared_ptr<ModelAPI_CompositeFeature>& theComposite, bool isForce)
217 // increase composite features stack
218 ++gCompositeStackDepth;
219 // dump composite itself
220 if (!isDumped(theComposite) || isForce)
221 dumpFeature(theComposite, isForce);
223 // sub-part is processed independently, because it provides separate document
224 if (theComposite->getKind() == PartSetPlugin_Part::ID()) {
225 // decrease composite features stack because we run into separate document
226 --gCompositeStackDepth;
228 ResultPartPtr aPartResult =
229 std::dynamic_pointer_cast<ModelAPI_ResultPart>(theComposite->lastResult());
232 DocumentPtr aSubDoc = aPartResult->partDoc();
235 // set name of document
236 const std::string& aPartName = myNames[theComposite].myCurrentName;
237 std::string aDocName = aPartName + "_doc";
238 myNames[aSubDoc] = EntityName(aDocName, std::string(), true);
240 // dump document in a separate line
241 *this << aDocName << " = " << aPartName << ".document()" << std::endl;
242 // dump features in the document
243 return process(aSubDoc);
247 bool isOk = processSubs(theComposite);
248 // decrease composite features stack
249 --gCompositeStackDepth;
254 bool ModelHighAPI_Dumper::processSubs(const std::shared_ptr<ModelAPI_CompositeFeature>& theComposite,
258 // dump all sub-features;
259 bool isSubDumped = false;
260 int aNbSubs = theComposite->numberOfSubs();
261 for (int anIndex = 0; anIndex < aNbSubs; ++anIndex) {
262 FeaturePtr aFeature = theComposite->subFeature(anIndex);
263 if (isDumped(aFeature))
267 CompositeFeaturePtr aCompFeat = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
268 if (aCompFeat) // iteratively process composite features
269 isOk = process(aCompFeat) && isOk;
271 dumpFeature(aFeature, true);
274 bool isDumpSetName = !myEntitiesStack.empty() &&
275 myEntitiesStack.top().myEntity == EntityPtr(theComposite);
276 bool isForceModelDo = isSubDumped && isDumpSetName &&
277 (myEntitiesStack.top().myUserName || !myEntitiesStack.top().myResults.empty());
278 // It is necessary for the sketch to create its result when complete (command "model.do()").
279 // This option is set by flat theDumpModelDo.
280 // However, nested sketches are rebuilt by parent feature, so, they do not need
281 // explicit call of "model.do()". This will be controlled by the depth of the stack.
282 if (isForceModelDo || (theDumpModelDo && gCompositeStackDepth <= 1))
283 *this << "model.do()" << std::endl;
285 // dump "setName" for composite feature
291 void ModelHighAPI_Dumper::dumpSubFeatureNameAndColor(const std::string theSubFeatureGet,
292 const FeaturePtr& theSubFeature)
294 name(theSubFeature, false);
295 myNames[theSubFeature] = EntityName(theSubFeatureGet, theSubFeature->name(), false);
297 // store results if they have user-defined names or colors
298 std::list<ResultPtr> aResultsWithNameOrColor;
299 const std::list<ResultPtr>& aResults = theSubFeature->results();
300 std::list<ResultPtr>::const_iterator aResIt = aResults.begin();
301 for (; aResIt != aResults.end(); ++aResIt) {
302 std::string aResName = (*aResIt)->data()->name();
303 myNames[*aResIt] = EntityName(aResName, aResName, false);
304 aResultsWithNameOrColor.push_back(*aResIt);
307 // store just dumped entity to stack
308 myEntitiesStack.push(LastDumpedEntity(theSubFeature, true, aResultsWithNameOrColor));
313 bool ModelHighAPI_Dumper::exportTo(const std::string& theFileName)
316 OSD_OpenStream(aFile, theFileName.c_str(), std::ofstream::out);
317 if (!aFile.is_open())
321 for (ModulesMap::const_iterator aModIt = myModules.begin();
322 aModIt != myModules.end(); ++aModIt) {
323 aFile << "from " << aModIt->first << " import ";
324 if (aModIt->second.empty() ||
325 aModIt->second.find(std::string()) != aModIt->second.end())
326 aFile << "*"; // import whole module
328 // import specific features
329 std::set<std::string>::const_iterator anObjIt = aModIt->second.begin();
331 for (++anObjIt; anObjIt != aModIt->second.end(); ++anObjIt)
332 aFile << ", " << *anObjIt;
336 if (!myModules.empty())
339 aFile << "import model" << std::endl << std::endl;
340 aFile << "model.begin()" << std::endl;
342 // dump collected data
343 aFile << myFullDump.str();
344 aFile << myDumpBuffer.str();
347 aFile << "model.end()" << std::endl;
355 void ModelHighAPI_Dumper::importModule(const std::string& theModuleName,
356 const std::string& theObject)
358 myModules[theModuleName].insert(theObject);
361 void ModelHighAPI_Dumper::dumpEntitySetName()
363 const LastDumpedEntity& aLastDumped = myEntitiesStack.top();
365 // dump "setName" for the entity
366 if (aLastDumped.myUserName) {
367 EntityName& anEntityNames = myNames[aLastDumped.myEntity];
368 if (!anEntityNames.myIsDefault)
369 myDumpBuffer << anEntityNames.myCurrentName << ".setName(\""
370 << anEntityNames.myUserName << "\")" << std::endl;
371 // don't dump "setName" for the entity twice
372 anEntityNames.myUserName.clear();
373 anEntityNames.myIsDefault = true;
375 // dump "setName" for results
376 std::list<ResultPtr>::const_iterator aResIt = aLastDumped.myResults.begin();
377 std::list<ResultPtr>::const_iterator aResEnd = aLastDumped.myResults.end();
378 for (; aResIt != aResEnd; ++aResIt) {
380 EntityName& anEntityNames = myNames[*aResIt];
381 if (!anEntityNames.myIsDefault) {
383 myDumpBuffer << ".setName(\"" << anEntityNames.myUserName << "\")" << std::endl;
384 // don't dump "setName" for the entity twice
385 anEntityNames.myUserName.clear();
386 anEntityNames.myIsDefault = true;
389 if (!isDefaultColor(*aResIt)) {
390 AttributeIntArrayPtr aColor = (*aResIt)->data()->intArray(ModelAPI_Result::COLOR_ID());
391 if (aColor && aColor->isInitialized()) {
393 myDumpBuffer << ".setColor(" << aColor->value(0) << ", " << aColor->value(1)
394 << ", " << aColor->value(2) << ")" << std::endl;
399 myEntitiesStack.pop();
402 bool ModelHighAPI_Dumper::isDumped(const EntityPtr& theEntity) const
404 EntityNameMap::const_iterator aFound = myNames.find(theEntity);
405 return aFound != myNames.end();
408 bool ModelHighAPI_Dumper::isDefaultColor(const ResultPtr& theResult) const
410 AttributeIntArrayPtr aColor = theResult->data()->intArray(ModelAPI_Result::COLOR_ID());
411 if (!aColor || !aColor->isInitialized())
414 std::string aSection, aName, aDefault;
415 theResult->colorConfigInfo(aSection, aName, aDefault);
417 // dump current color
418 std::ostringstream aColorInfo;
419 aColorInfo << aColor->value(0) << "," << aColor->value(1) << "," << aColor->value(2);
421 return aDefault == aColorInfo.str();
424 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const char theChar)
426 myDumpBuffer << theChar;
430 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const char* theString)
432 myDumpBuffer << theString;
436 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const std::string& theString)
438 myDumpBuffer << theString;
442 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const bool theValue)
444 myDumpBuffer << (theValue ? "True" : "False");
448 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const int theValue)
450 myDumpBuffer << theValue;
454 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const double theValue)
456 myDumpBuffer << theValue;
460 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const std::shared_ptr<GeomAPI_Pnt>& thePoint)
462 importModule("GeomAPI", "GeomAPI_Pnt");
463 myDumpBuffer << "GeomAPI_Pnt(" << thePoint->x() << ", "
464 << thePoint->y() << ", " << thePoint->z() << ")";
468 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const std::shared_ptr<GeomAPI_Dir>& theDir)
470 importModule("GeomAPI", "GeomAPI_Dir");
471 myDumpBuffer << "GeomAPI_Dir(" << theDir->x() << ", "
472 << theDir->y() << ", " << theDir->z() << ")";
476 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
477 const std::shared_ptr<GeomDataAPI_Dir>& theDir)
479 myDumpBuffer << theDir->x() << ", " << theDir->y() << ", " << theDir->z();
483 static void dumpArray(std::ostringstream& theOutput, int theSize,
484 double* theValues, std::string* theTexts)
486 for (int i = 0; i < theSize; ++i) {
489 if (theTexts[i].empty())
490 theOutput << theValues[i];
492 theOutput << "\"" << theTexts[i] << "\"";
496 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
497 const std::shared_ptr<GeomDataAPI_Point>& thePoint)
499 static const int aSize = 3;
500 double aValues[aSize] = {thePoint->x(), thePoint->y(), thePoint->z()};
501 std::string aTexts[aSize] = {thePoint->textX(), thePoint->textY(), thePoint->textZ()};
502 dumpArray(myDumpBuffer, aSize, aValues, aTexts);
506 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
507 const std::shared_ptr<GeomDataAPI_Point2D>& thePoint)
509 static const int aSize = 2;
510 double aValues[aSize] = {thePoint->x(), thePoint->y()};
511 std::string aTexts[aSize] = {thePoint->textX(), thePoint->textY()};
512 dumpArray(myDumpBuffer, aSize, aValues, aTexts);
516 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
517 const std::shared_ptr<ModelAPI_AttributeBoolean>& theAttrBool)
519 myDumpBuffer << (theAttrBool->value() ? "True" : "False");
523 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
524 const std::shared_ptr<ModelAPI_AttributeInteger>& theAttrInt)
526 std::string aText = theAttrInt->text();
528 myDumpBuffer << theAttrInt->value();
530 myDumpBuffer << "\"" << aText << "\"";
534 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
535 const std::shared_ptr<ModelAPI_AttributeDouble>& theAttrReal)
537 std::string aText = theAttrReal->text();
539 myDumpBuffer << theAttrReal->value();
541 myDumpBuffer << "\"" << aText << "\"";
545 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
546 const std::shared_ptr<ModelAPI_AttributeString>& theAttrStr)
548 myDumpBuffer << "\"" << theAttrStr->value() << "\"";
552 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const FeaturePtr& theEntity)
554 myDumpBuffer << name(theEntity);
556 bool isUserDefinedName = !myNames[theEntity].myIsDefault;
557 // store results if they have user-defined names or colors
558 std::list<ResultPtr> aResultsWithNameOrColor;
559 const std::list<ResultPtr>& aResults = theEntity->results();
560 std::list<ResultPtr>::const_iterator aResIt = aResults.begin();
561 for (; aResIt != aResults.end(); ++aResIt)
562 if (!myNames[*aResIt].myIsDefault || !isDefaultColor(*aResIt))
563 aResultsWithNameOrColor.push_back(*aResIt);
564 // store just dumped entity to stack
565 myEntitiesStack.push(LastDumpedEntity(theEntity, isUserDefinedName, aResultsWithNameOrColor));
567 // remove entity from the list of not dumped items
568 myNotDumpedEntities.erase(theEntity);
572 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const ResultPtr& theResult)
574 FeaturePtr aFeature = ModelAPI_Feature::feature(theResult);
576 std::list<ResultPtr> aResults = aFeature->results();
577 for(std::list<ResultPtr>::const_iterator anIt = aResults.cbegin(); anIt != aResults.cend(); ++anIt, ++anIndex) {
578 if(theResult->isSame(*anIt)) {
582 myDumpBuffer << name(aFeature) << ".result()[" << anIndex << "]";
586 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const ObjectPtr& theObject)
588 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
590 myDumpBuffer << name(aFeature);
594 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
603 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const AttributePtr& theAttr)
605 FeaturePtr anOwner = ModelAPI_Feature::feature(theAttr->owner());
606 myDumpBuffer << name(anOwner) << "." << attributeGetter(anOwner, theAttr->id()) << "()";
610 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
611 const std::shared_ptr<ModelAPI_AttributeRefAttr>& theRefAttr)
613 if (theRefAttr->isObject())
614 *this << theRefAttr->object();
616 *this << theRefAttr->attr();
620 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
621 const std::shared_ptr<ModelAPI_AttributeRefAttrList>& theRefAttrList)
624 std::list<std::pair<ObjectPtr, AttributePtr> > aList = theRefAttrList->list();
625 bool isAdded = false;
626 std::list<std::pair<ObjectPtr, AttributePtr> >::const_iterator anIt = aList.begin();
627 for (; anIt != aList.end(); ++anIt) {
629 myDumpBuffer << ", ";
633 *this << anIt->first;
634 else if (anIt->second)
635 * this << anIt->second;
641 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
642 const std::shared_ptr<ModelAPI_AttributeReference>& theReference)
644 *this << theReference->value();
648 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
649 const std::shared_ptr<ModelAPI_AttributeRefList>& theRefList)
651 static const int aThreshold = 2;
652 // if number of elements in the list if greater than a threshold,
653 // dump it in a separate line with specific name
654 std::string aDumped = myDumpBuffer.str();
655 if (aDumped.empty() || theRefList->size() <= aThreshold) {
657 std::list<ObjectPtr> aList = theRefList->list();
658 bool isAdded = false;
659 std::list<ObjectPtr>::const_iterator anIt = aList.begin();
660 for (; anIt != aList.end(); ++anIt) {
662 myDumpBuffer << ", ";
670 // clear buffer and store list "as is"
671 myDumpBuffer.str("");
673 // save buffer and clear it again
674 std::string aDumpedList = myDumpBuffer.str();
675 myDumpBuffer.str("");
676 // obtain name of list
677 FeaturePtr anOwner = ModelAPI_Feature::feature(theRefList->owner());
678 std::string aListName = name(anOwner) + "_objects";
679 // store all previous data
680 myDumpBuffer << aListName << " = " << aDumpedList << std::endl
681 << aDumped << aListName;
686 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
687 const std::shared_ptr<ModelAPI_AttributeSelection>& theAttrSelect)
689 myDumpBuffer << "model.selection(";
691 if(!theAttrSelect->isInitialized()) {
696 GeomShapePtr aShape = theAttrSelect->value();
698 aShape = theAttrSelect->context()->shape();
706 myDumpBuffer << "\"" << aShape->shapeTypeStr() << "\", \"" << theAttrSelect->namingName() << "\")";
710 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
711 const std::shared_ptr<ModelAPI_AttributeSelectionList>& theAttrSelList)
716 std::string aShapeTypeStr;
718 bool isAdded = false;
720 for(int anIndex = 0; anIndex < theAttrSelList->size(); ++anIndex) {
721 AttributeSelectionPtr anAttribute = theAttrSelList->value(anIndex);
722 aShape = anAttribute->value();
724 aShape = anAttribute->context()->shape();
732 myDumpBuffer << ", ";
736 myDumpBuffer << "model.selection(\"" << aShape->shapeTypeStr() << "\", \"" << anAttribute->namingName() << "\")";
745 ModelHighAPI_Dumper& operator<<(ModelHighAPI_Dumper& theDumper,
746 std::basic_ostream<char>& (*theEndl)(std::basic_ostream<char>&))
748 theDumper.myDumpBuffer << theEndl;
750 if (!theDumper.myEntitiesStack.empty()) {
751 // Name for composite feature is dumped when all sub-entities are dumped
752 // (see method ModelHighAPI_Dumper::processSubs).
753 const ModelHighAPI_Dumper::LastDumpedEntity& aLastDumped = theDumper.myEntitiesStack.top();
754 CompositeFeaturePtr aComposite =
755 std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aLastDumped.myEntity);
757 theDumper.dumpEntitySetName();
760 // store all not-dumped entities first
761 std::set<EntityPtr> aNotDumped = theDumper.myNotDumpedEntities;
762 std::string aBufCopy = theDumper.myDumpBuffer.str();
763 theDumper.clear(true);
764 std::set<EntityPtr>::const_iterator anIt = aNotDumped.begin();
765 for (; anIt != aNotDumped.end(); ++anIt) {
766 // if the feature is composite, dump it with all subs
767 CompositeFeaturePtr aCompFeat =
768 std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(*anIt);
770 theDumper.process(aCompFeat, true);
772 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*anIt);
773 theDumper.dumpFeature(aFeature, true);
777 // avoid multiple empty lines
778 size_t anInd = std::string::npos;
779 while ((anInd = aBufCopy.find("\n\n\n")) != std::string::npos)
780 aBufCopy.erase(anInd, 1);
781 // then store currently dumped string
782 theDumper.myFullDump << aBufCopy;