- bool found = false;
- list<const SMDS_MeshGroup*>::iterator itgroup;
- for(itgroup=myChildren.begin(); itgroup!=myChildren.end(); itgroup++)
- {
- const SMDS_MeshGroup* subgroup=*itgroup;
- if (subgroup == theGroup)
- {
- found = true;
- myChildren.erase(itgroup);
- }
- }
-
- return found;
+ // the type of the group is determined by the first element added
+ if ( myElements.empty() ) {
+ myType = theElem->GetType();
+ }
+ else if ( theElem->GetType() != myType ) {
+ MESSAGE("SMDS_MeshGroup::Add : Type Mismatch "<<theElem->GetType()<<"!="<<myType);
+ return false;
+ }
+
+ bool added = myElements.insert( theElem ).second;
+
+ ++myTic;
+
+ return added;