- for (int i = 0; i < theSketch->numberOfSubs(); i++) {
- FeaturePtr aFeature = theSketch->subFeature(i);
- std::shared_ptr<SketchPlugin_Feature> aSketchFea =
- std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
- if (aSketchFea) {
- if (aSketchFea->isExternal()) {
- std::list<ResultPtr> aResults = aSketchFea->results();
- std::list<ResultPtr>::const_iterator aIt;
- for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
- ResultConstructionPtr aRes =
- std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aIt);
- if (aRes) {
- std::shared_ptr<GeomAPI_Shape> aShape = aRes->shape();
- if (aShape) {
- if (theEdge->isEqual(aShape))
- return aRes;
+ std::shared_ptr<GeomAPI_Pnt2d> aOrig = getCoincedencePoint(theStartCoin);
+ if (aOrig.get() == NULL)
+ return;
+
+ AttributeRefAttrPtr aPnt = theStartCoin->refattr(theAttr);
+ if (!aPnt)
+ return;
+ ObjectPtr aObj = aPnt->object();
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
+ if (aFeature.get()) {
+ if (!theList.contains(aFeature)) {
+ theList.append(aFeature);
+ theCoincidencies.append(theStartCoin);
+ theIsAttributes.append(true); // point attribute on a feature
+ const std::set<AttributePtr>& aRefsList = aFeature->data()->refsToMe();
+ std::set<AttributePtr>::const_iterator aIt;
+ for (aIt = aRefsList.cbegin(); aIt != aRefsList.cend(); ++aIt) {
+ std::shared_ptr<ModelAPI_Attribute> aAttr = (*aIt);
+ FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
+ if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
+ if (!theCoincidencies.contains(aConstrFeature)) {
+ std::shared_ptr<GeomAPI_Pnt2d> aPnt = getCoincedencePoint(aConstrFeature);
+ if (aPnt.get() && aOrig->isEqual(aPnt)) {
+ findCoincidences(aConstrFeature, theList, theCoincidencies,
+ SketchPlugin_ConstraintCoincidence::ENTITY_A(), theIsAttributes);
+ findCoincidences(aConstrFeature, theList, theCoincidencies,
+ SketchPlugin_ConstraintCoincidence::ENTITY_B(), theIsAttributes);
+ }
+ }
+ }
+ }
+ }
+ } else {
+ // Find by Results
+ ResultConstructionPtr aResult = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObj);
+ if (aResult.get()) {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aPnt->object());
+ if (!theList.contains(aFeature))
+ theList.append(aFeature);
+ theCoincidencies.append(theStartCoin);
+ theIsAttributes.append(false); // point attribute on a feature
+
+ const std::set<AttributePtr>& aRefsList = aResult->data()->refsToMe();
+ std::set<AttributePtr>::const_iterator aIt;
+ for (aIt = aRefsList.cbegin(); aIt != aRefsList.cend(); ++aIt) {
+ std::shared_ptr<ModelAPI_Attribute> aAttr = (*aIt);
+ FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
+ if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
+ if (!theCoincidencies.contains(aConstrFeature)) {
+ std::shared_ptr<GeomAPI_Pnt2d> aPnt = getCoincedencePoint(aConstrFeature);
+ if (aPnt.get() && aOrig->isEqual(aPnt)) {
+ findCoincidences(aConstrFeature, theList, theCoincidencies,
+ SketchPlugin_ConstraintCoincidence::ENTITY_A(), theIsAttributes);
+ findCoincidences(aConstrFeature, theList, theCoincidencies,
+ SketchPlugin_ConstraintCoincidence::ENTITY_B(), theIsAttributes);