- FeaturePtr aFeatureOwner = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
- if (aFeatureOwner->document() != theContext->document()) { // reference to the sketch face
- if (theSubShape->shapeType() == GeomAPI_Shape::FACE ||
- theSubShape->shapeType() == GeomAPI_Shape::WIRE) { // sketch face or sketch face wire
- ResultConstructionPtr aConstr =
- std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theContext);
- int aFaceIndex = -1, aFacesNum = aConstr->facesNum();
- for(int a = 0; a < aFacesNum; a++) {
- bool isEqual = false;
- GeomShapePtr aFace = aConstr->face(a);
- if (!aFace.get() || aFace->isNull())
- continue;
- if (theSubShape->shapeType() == GeomAPI_Shape::FACE) {
- isEqual = aFace->isEqual(theSubShape);
- } else {
- GeomAPI_ShapeExplorer anExp(aFace, GeomAPI_Shape::WIRE);
- if (anExp.more())
- isEqual = anExp.current()->isEqual(theSubShape);
- }
- if (isEqual) {
- aFaceIndex = a;
- break;
- }
- }
- if (aFaceIndex >= 0) {
- TDataStd_Integer::Set(aSelLab, theSubShape->shapeType() == GeomAPI_Shape::FACE ?
- kEXT_SKETCH_FACE : kEXT_SKETCH_WIRE, aFaceIndex); // store index of the face
- return;
- }
- } else if (theSubShape->shapeType() == GeomAPI_Shape::WIRE) {
-
- } else if (theSubShape->shapeType() == GeomAPI_Shape::EDGE ||// sketch result edge (full one)
- theSubShape->shapeType() == GeomAPI_Shape::VERTEX) { // or start/end vertex
- bool isVertex = theSubShape->shapeType() == GeomAPI_Shape::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;
- }
- }
- }
- }