return anIter->current();
}
+const vector<string>& Model_Document::getGroups() const
+{
+ return myGroupsNames;
+}
+
Model_Document::Model_Document(const std::string theID)
: myID(theID), myDoc(new TDocStd_Document("BinOcaf")) // binary OCAF format
{
{
if (myGroups.find(theGroup) == myGroups.end()) {
myGroups[theGroup] = myDoc->Main().FindChild(TAG_OBJECTS).NewChild();
+ myGroupsNames.push_back(theGroup);
}
return myGroups[theGroup];
}
MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Feature>
feature(const std::string& theGroupID, const int theIndex);
+ ///! Returns the vector of groups already added to the document
+ MODEL_EXPORT virtual const std::vector<std::string>& getGroups() const;
+
protected:
//! Returns (creates if needed) the group label
Handle_TDocStd_Document myDoc; ///< OCAF document
int myTransactionsAfterSave; ///< number of transactions after the last "save" call, used for "IsModified" method
std::map<std::string, TDF_Label> myGroups; ///< root labels of the features groups identified by names
+ std::vector<std::string> myGroupsNames; ///< names of added groups to the document
};
#endif
#include <ModelAPI.h>
#include <string>
#include <memory>
+#include <vector>
class ModelAPI_Feature;
class ModelAPI_Iterator;
MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Feature>
feature(const std::string& theGroupID, const int theIndex) = 0;
+ ///! Returns the vector of groups already added to the document
+ MODELAPI_EXPORT virtual const std::vector<std::string>& getGroups() const = 0;
+
protected:
/// Only for SWIG wrapping it is here
MODELAPI_EXPORT ModelAPI_Document()
{
std::shared_ptr<ModelAPI_Feature> aCreated;
bool isCurrent = true; // to create a feature in the current document
+ std::string aGroup;
if (theFeatureID == "Part") {
aCreated = std::shared_ptr<ModelAPI_Feature>(new PartSetPlugin_Part);
isCurrent = false; // allways create in the root document
+ aGroup = PARTS_GROUP;
} else if (theFeatureID == "Point") {
aCreated = std::shared_ptr<ModelAPI_Feature>(new PartSetPlugin_Point);
+ aGroup = CONSTRUCTIONS_GROUP;
}
// add to a root document for the current moment
shared_ptr<ModelAPI_Document> aDoc = isCurrent ?
ModelAPI_PluginManager::get()->currentDocument() :
ModelAPI_PluginManager::get()->rootDocument();
- aDoc->addFeature(aCreated, PARTS_GROUP);
+ aDoc->addFeature(aCreated, aGroup);
}
// feature of such kind is not found
return aCreated;