+ if (theSubShape->shapeType() == TopAbs_FACE) { // sketch face
+ ResultConstructionPtr aConstr =
+ std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theContext);
+ int aFaceIndex = -1, aFacesNum = aConstr->facesNum();
+ for(int a = 0; a < aFacesNum; a++) {
+ if (aConstr->face(a)->isEqual(theSubShape)) {
+ aFaceIndex = a;
+ break;
+ }
+ }
+ if (aFaceIndex >= 0) {
+ TDataStd_Integer::Set(aSelLab, kEXT_SKETCH_FACE, aFaceIndex); // store index of the face
+ return;
+ }
+ } else if (theSubShape->shapeType() == TopAbs_EDGE || // sketch result edge (full one)
+ theSubShape->shapeType() == TopAbs_VERTEX) { // or start/end vertex
+ bool isVertex = theSubShape->shapeType() == TopAbs_VERTEX;
+ CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(
+ theContext->document()->feature(theContext));
+ if (aComposite.get()) { // iterate edges of composite to find index of matched with value
+ int aSub, anEdgeIndex = -1, aSubNum = aComposite->numberOfSubs();
+ int aVertIndex = -1, aVertShape = -1; // shape: 0 full, 1 start, 2 end
+ for(aSub = 0; aSub < aSubNum && anEdgeIndex == -1; aSub++) {
+ FeaturePtr aSubFeat = aComposite->subFeature(aSub);
+ const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = aSubFeat->results();
+ std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRes = aResults.cbegin();
+ for (; aRes != aResults.cend(); aRes++) {
+ ResultConstructionPtr aConstr =
+ std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aRes);
+ if (aConstr->shape() && aConstr->shape()->isEdge()) {
+ if (isVertex) {
+ GeomAPI_ShapeExplorer aVertExp(aConstr->shape(), GeomAPI_Shape::VERTEX);
+ for(int aNum = 1; aVertExp.more(); aVertExp.next(), aNum++) {
+ if (aVertExp.current()->isSame(theSubShape) && aVertShape != 0) {
+ aVertIndex = aSub;
+ aVertShape = aNum;
+ }
+ }
+ } else {
+ if (aConstr->shape()->isSame(theSubShape)) {
+ anEdgeIndex = aSub;
+ break;
+ }
+ }
+ } else if (isVertex && aConstr->shape() && aConstr->shape()->isVertex()) {
+ if (aConstr->shape()->isSame(theSubShape)) {
+ aVertIndex = aSub;
+ aVertShape = 0;
+ }
+ }
+ }
+ }
+ if (anEdgeIndex >= 0) {
+ TDataStd_Integer::Set(aSelLab, kEXT_SKETCH_EDGE, anEdgeIndex); // store index of edge
+ return;
+ } else if (aVertIndex >= 0) {
+ aVertIndex += aVertShape * 1000000; // to store both integers: index and shape
+ TDataStd_Integer::Set(aSelLab, kEXT_SKETCH_VERT, aVertIndex); // store index of edge
+ return;
+ }