return mySelf;
}
+#define CLEAR_STREAM(theStream) { \
+ std::ostringstream anOther; \
+ swap(theStream, anOther); \
+ }
+
void ModelHighAPI_Dumper::clear(bool bufferOnly)
{
- myDumpBuffer = std::ostringstream();
+ CLEAR_STREAM(myDumpBuffer);
myDumpBuffer << std::setprecision(16);
clearNotDumped();
if (!bufferOnly) {
- myFullDump = std::ostringstream();
+ CLEAR_STREAM(myFullDump);
myFullDump << std::setprecision(16);
myNames.clear();
myNotDumpedEntities.clear();
}
-const std::string& ModelHighAPI_Dumper::name(const EntityPtr& theEntity)
+const std::string& ModelHighAPI_Dumper::name(const EntityPtr& theEntity, bool theSaveNotDumped)
{
EntityNameMap::const_iterator aFound = myNames.find(theEntity);
if (aFound != myNames.end())
int anId = std::stoi(anIdStr);
// Check number of already registered objects of such kind. Index of current object
- // should be greater than it to identify feature's name as automatically generated.
- if (aNbFeatures < anId) {
+ // should be the same to identify feature's name as automatically generated.
+ if (aNbFeatures + 1 == anId) {
isUserDefined = false;
- aNbFeatures = anId - 1;
+ //aNbFeatures = anId - 1;
}
}
}
myNames[theEntity] = std::pair<std::string, bool>(aName, isUserDefined);
- myNotDumpedEntities.insert(theEntity);
+ if (theSaveNotDumped)
+ myNotDumpedEntities.insert(theEntity);
return myNames[theEntity].first;
}
bool ModelHighAPI_Dumper::process(const std::shared_ptr<ModelAPI_Document>& theDoc)
{
bool isOk = true;
- // dump all features
std::list<FeaturePtr> aFeatures = theDoc->allFeatures();
std::list<FeaturePtr>::const_iterator aFeatIt = aFeatures.begin();
- for (; aFeatIt != aFeatures.end(); ++aFeatIt) {
+ // firstly, dump all parameters
+ for (; aFeatIt != aFeatures.end(); ++ aFeatIt)
+ dumpParameter(*aFeatIt);
+ // dump all other features
+ for (aFeatIt = aFeatures.begin(); aFeatIt != aFeatures.end(); ++aFeatIt) {
CompositeFeaturePtr aCompFeat = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(*aFeatIt);
if (aCompFeat) // iteratively process composite features
isOk = process(aCompFeat) && isOk;
bool isOk = true;
// dump all sub-features;
int aNbSubs = theComposite->numberOfSubs();
+//////////////////////////////////////
+ std::list<ObjectPtr> aList = theComposite->reflist("Features")->list();
+//////////////////////////////////////
for (int anIndex = 0; anIndex < aNbSubs; ++anIndex) {
FeaturePtr aFeature = theComposite->subFeature(anIndex);
if (isDumped(aFeature))
myDumpBuffer << "]";
} else {
// clear buffer and store list "as is"
- myDumpBuffer = std::ostringstream();
+ CLEAR_STREAM(myDumpBuffer);
*this << theRefList;
// save buffer and clear it again
std::string aDumpedList = myDumpBuffer.str();
- myDumpBuffer = std::ostringstream();
+ CLEAR_STREAM(myDumpBuffer);
// obtain name of list
FeaturePtr anOwner = ModelAPI_Feature::feature(theRefList->owner());
std::string aListName = name(anOwner) + "_objects";