void Model_BodyBuilder::clean()
{
- std::vector<TNaming_Builder*>::iterator aBuilder = myBuilders.begin();
+ std::map<int, TNaming_Builder*>::iterator aBuilder = myBuilders.begin();
for(; aBuilder != myBuilders.end(); aBuilder++)
- delete *aBuilder;
+ delete aBuilder->second;
myBuilders.clear();
}
TNaming_Builder* Model_BodyBuilder::builder(const int theTag)
{
- if (myBuilders.size() <= (unsigned int)theTag) {
- myBuilders.insert(myBuilders.end(), theTag - myBuilders.size() + 1, NULL);
- }
- if (!myBuilders[theTag]) {
+ std::map<int, TNaming_Builder*>::iterator aFind = myBuilders.find(theTag);
+ if (aFind == myBuilders.end()) {
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
myBuilders[theTag] = new TNaming_Builder(aData->shapeLab().FindChild(theTag));
- //TCollection_AsciiString entry;//
- //TDF_Tool::Entry(aData->shapeLab().FindChild(theTag), entry);
- //cout << "Label = " <<entry.ToCString() <<endl;
+ aFind = myBuilders.find(theTag);
}
- return myBuilders[theTag];
+ return aFind->second;
}
void Model_BodyBuilder::buildName(const int theTag, const std::string& theName)
*/
class Model_BodyBuilder : public ModelAPI_BodyBuilder
{
- /// builders that tores the naming history: one per label to allow store several shapes to one
+ /// builders that store the naming history: one per label to allow store several shapes to one
/// label; index in vector corresponds to the label tag
- std::vector<TNaming_Builder*> myBuilders;
+ std::map<int, TNaming_Builder*> myBuilders;
public:
/// Stores the shape (called by the execution method).
MODEL_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape,