// dump all other features
for (anObjIt = anObjects.begin(); anObjIt != anObjects.end(); ++anObjIt) {
CompositeFeaturePtr aCompFeat = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(*anObjIt);
- if (aCompFeat) // iteratively process composite features
- isOk = process(aCompFeat) && isOk;
+ if (aCompFeat) {
+ // iteratively process composite features,
+ // if the composite feature is the last in the document, no need to dump "model.do()" action
+ std::list<ObjectPtr>::const_iterator aNext = anObjIt;
+ isOk = process(aCompFeat, false, ++aNext != anObjects.end()) && isOk;
+ }
else if (!isDumped(EntityPtr(*anObjIt))) {
// dump folder
FolderPtr aFolder = std::dynamic_pointer_cast<ModelAPI_Folder>(*anObjIt);
}
bool ModelHighAPI_Dumper::process(const std::shared_ptr<ModelAPI_CompositeFeature>& theComposite,
- bool isForce)
+ bool isForce, bool isDumpModelDo)
{
// increase composite features stack
++gCompositeStackDepth;
*this << aDocName << " = " << aPartName << ".document()" << std::endl;
// dump features in the document
bool aRes = process(aSubDoc);
- *this << "model.do()" << std::endl;
+ if (isDumpModelDo)
+ *this << "model.do()\n";
+ *this << std::endl;
return aRes;
}
/// Dump composite feature and all it sub-features
bool process(const std::shared_ptr<ModelAPI_CompositeFeature>& theComposite,
- bool isForce = false);
+ bool isForce = false,
+ bool isDumpModelDo = true);
/// Iterate all features in composite feature and dump them into intermediate buffer
/// \param theComposite [in] parent composite feature
#include <ModelAPI_Events.h>
#include <cmath>
+#include <sstream>
//--------------------------------------------------------------------------------------
std::shared_ptr<ModelAPI_Document> moduleDocument()
//--------------------------------------------------------------------------------------
void begin()
{
- ModelAPI_Session::get()->startOperation();
+ static int aTransactionID = 0;
+ std::ostringstream aTransactionName;
+ aTransactionName << "Operation_" << ++aTransactionID;
+ ModelAPI_Session::get()->startOperation(aTransactionName.str());
}
void end()
{
auto aSession = ModelAPI_Session::get();
aSession->finishOperation();
- aSession->startOperation();
+ begin();
}
void updateFeatures()