X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelHighAPI%2FModelHighAPI_Dumper.cpp;h=cf359fc6559acb4db1150315cb56120237fd05cc;hb=5e2855aa69f9a63236c331efcb57ba433f92e901;hp=f1a61c254903bd4921a664c27d788a7ea71d60da;hpb=2d5fdecf9621cedb860a0ef208fc5f61340fdb71;p=modules%2Fshaper.git diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index f1a61c254..cf359fc65 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -569,12 +569,16 @@ static int toInt(const std::string& theString) const std::string& ModelHighAPI_Dumper::name(const EntityPtr& theEntity, bool theSaveNotDumped, - bool theUseEntityName) -{ - EntityNameMap::const_iterator aFound = myNames.find(theEntity); - if (aFound != myNames.end()) + bool theUseEntityName, + bool theSetIsDumped) +{ + EntityNameMap::iterator aFound = myNames.find(theEntity); + if (aFound != myNames.end()) { + // Set dumped flag for postponed constraints which are without names + if (!aFound->second.myIsDumped) + aFound->second.myIsDumped = theSetIsDumped; return aFound->second.myCurrentName; - + } // entity is not found, store it std::string aName, aKind; bool isDefaultName = false; @@ -650,6 +654,8 @@ const std::string& ModelHighAPI_Dumper::name(const EntityPtr& theEntity, if (aFeature) saveResultNames(aFeature); + myNames[theEntity].myIsDumped = theSetIsDumped; + return myNames[theEntity].myCurrentName; } @@ -772,7 +778,7 @@ bool ModelHighAPI_Dumper::process(const std::shared_ptrvalue()) < 1.e-12; } +bool ModelHighAPI_Dumper::dumpCommentBeforeFeature(const FeaturePtr& theFeature) const +{ + // currently, the comment should not be dumped only before the filters + FiltersFeaturePtr aFilters = std::dynamic_pointer_cast(theFeature); + if (aFilters) + return false; + // all other features should be commented before the dump + return true; +} + ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const char theChar) { *myDumpStorage << theChar; @@ -1447,10 +1463,10 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<( const std::shared_ptr& theAttrSelList) { static const int aThreshold = 2; - static bool aDumpAsIs = false; + static int aNbSpaces = 0; // if number of elements in the list if greater than a threshold, // dump it in a separate line with specific name - if (aDumpAsIs || theAttrSelList->size() <= aThreshold) { + if (aNbSpaces > 0 || theAttrSelList->size() <= aThreshold) { *myDumpStorage << "["; GeomShapePtr aShape; @@ -1473,6 +1489,11 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<( if(isAdded) { *myDumpStorage << ", "; + // print each attribute on separate line with the appropriate shift + if (aNbSpaces > 0) { + std::string aSpaces(aNbSpaces + 1, ' '); + *myDumpStorage << "\n" << aSpaces; + } } else { isAdded = true; } @@ -1506,9 +1527,9 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<( } // reserve dumped buffer and store list "as is" myDumpStorage->reserveBuffer(); - aDumpAsIs = true; + aNbSpaces = (int)aListName.size() + 3; *this << aListName << " = " << theAttrSelList << "\n"; - aDumpAsIs = false; + aNbSpaces = 0; // append reserved data to the end of the current buffer myDumpStorage->restoreReservedBuffer(); *myDumpStorage << aListName; @@ -1533,6 +1554,11 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<( return *this; } +void ModelHighAPI_Dumper::newline() +{ + *this << std::endl; +} + /// Dump std::endl ModelHighAPI_Dumper& operator<<(ModelHighAPI_Dumper& theDumper, std::basic_ostream& (*theEndl)(std::basic_ostream&)) @@ -1562,6 +1588,7 @@ ModelHighAPI_Dumper& operator<<(ModelHighAPI_Dumper& theDumper, // store all not-dumped entities first std::set aNotDumped = theDumper.myNotDumpedEntities; + theDumper.clearNotDumped(); theDumper.myDumpStorage->reserveBuffer(); std::set::const_iterator anIt = aNotDumped.begin(); for (; anIt != aNotDumped.end(); ++anIt) {