+static TDF_Label findGoodLabelWithShape(const TDF_Label theAccess, const TopoDS_Shape& theShape) {
+ TDF_Label aResult;
+ TDF_Label aMyOpLab;
+ bool aMyOpLabIsComputed = false;
+ if (TNaming_Tool::HasLabel(theAccess, theShape)) { // selection and delete evolution are not used
+ for(TNaming_SameShapeIterator aShapes(theShape, theAccess); aShapes.More(); aShapes.Next())
+ {
+ Handle(TNaming_NamedShape) aNS;
+ if (aShapes.Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
+ if (aNS->Evolution() == TNaming_MODIFY || aNS->Evolution() == TNaming_GENERATED ||
+ aNS->Evolution() == TNaming_PRIMITIVE) {
+ // getting label of this operation to avoid usage of ready shapes of this
+ if (!aMyOpLabIsComputed) {
+ aMyOpLab = theAccess;
+ if (!aMyOpLab.IsNull()) {
+ int aDepth = aMyOpLab.Depth();
+ if (aDepth < 3)
+ aMyOpLab.Nullify();
+ else {
+ for(; aDepth != 3; aDepth--)
+ aMyOpLab = aMyOpLab.Father();
+ }
+ }
+ aMyOpLabIsComputed = true;
+ }
+ if (!aMyOpLab.IsNull() && aNS->Label().IsDescendant(aMyOpLab))
+ continue;
+ aResult = aNS->Label();
+ break;
+ }
+ }
+ }
+ }
+ return aResult;
+}
+