-// Converts evolution of naming shape to selection evelution and back to avoid
-// naming support on the disabled results. Deeply in the labels tree, recursively.
-static void evolutionToSelectionRec(TDF_Label theLab, const bool theFlag) {
- std::list<std::pair<TopoDS_Shape, TopoDS_Shape> > aShapePairs; // to store old and new shapes
- Handle(TNaming_NamedShape) aName;
- int anEvolution = -1;
- if (theLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
- TNaming_Evolution aNSEvol = aName->Evolution();
- if ((aNSEvol == TNaming_SELECTED && theFlag) ||
- (aNSEvol != TNaming_SELECTED && !theFlag)) { // nothing to do, it is already correct
- return;
- }
- anEvolution = (int)(aNSEvol);
- if (!theFlag) {
- Handle(TDataStd_Integer) anAttrEvol;
- if (theLab.FindAttribute(TDataStd_Integer::GetID(), anAttrEvol)) {
- anEvolution = anAttrEvol->Get();
- }
- } else {
- TDataStd_Integer::Set(theLab, anEvolution);
- }
-
- for(TNaming_Iterator anIter(aName); anIter.More(); anIter.Next()) {
- // iterator goes in reversed order relatively to the Builder, to, make the list reversed
- aShapePairs.push_front(std::pair<TopoDS_Shape, TopoDS_Shape>
- (anIter.OldShape(), anIter.NewShape()));
- }
-
- // create new
- TNaming_Builder aBuilder(theLab);
- TNaming_Evolution anEvol = (TNaming_Evolution)(anEvolution);
- std::list<std::pair<TopoDS_Shape, TopoDS_Shape> >::iterator aPairsIter = aShapePairs.begin();
- for(; aPairsIter != aShapePairs.end(); aPairsIter++) {
- if (theFlag) { // disabled => make selection
- if (anEvolution == TNaming_DELETE) // issue 2274 : don't put too many same null shapes
- aBuilder.Select(aPairsIter->first, aPairsIter->first);
- else if (anEvolution == TNaming_PRIMITIVE)
- aBuilder.Select(aPairsIter->second, aPairsIter->second);
- else
- aBuilder.Select(aPairsIter->second, aPairsIter->first);
- } else if (anEvol == TNaming_GENERATED) {
- aBuilder.Generated(aPairsIter->first, aPairsIter->second);
- } else if (anEvol == TNaming_MODIFY) {
- aBuilder.Modify(aPairsIter->first, aPairsIter->second);
- } else if (anEvol == TNaming_DELETE) {
- aBuilder.Delete(aPairsIter->first);
- } else if (anEvol == TNaming_PRIMITIVE) {
- aBuilder.Generated(aPairsIter->second);
- } else if (anEvol == TNaming_SELECTED) {
- aBuilder.Select(aPairsIter->second, aPairsIter->first);
- }
- }