+ myIsComputing = true;
+
+ AttributeSelectionPtr anExternalFeature = selection(EXTERNAL_FEATURE_ID());
+
+ GeomShapePtr aShape;
+ GeomEdgePtr anEdge;
+ if (anExternalFeature)
+ aShape = anExternalFeature->value();
+ if (!aShape && anExternalFeature->context())
+ aShape = anExternalFeature->context()->shape();
+ if (aShape && aShape->isEdge())
+ anEdge = GeomEdgePtr(new GeomAPI_Edge(aShape));
+
+ if (anEdge) {
+ std::shared_ptr<GeomAPI_Pln> aSketchPlane = sketch()->plane();
+
+ std::list<GeomPointPtr> anIntersectionsPoints;
+ anEdge->intersectWithPlane(aSketchPlane, anIntersectionsPoints);
+
+ AttributeRefListPtr anIntersectionsList = reflist(INTERSECTION_POINTS_ID());
+ std::list<ObjectPtr> anExistentIntersections = anIntersectionsList->list();
+ std::list<ObjectPtr>::const_iterator aExistInterIt = anExistentIntersections.begin();
+
+ const std::list<ResultPtr>& aResults = results();
+ std::list<ResultPtr>::const_iterator aResIt = aResults.begin();
+
+ int aResultIndex = 0;
+ for (std::list<GeomPointPtr>::iterator aPntIt = anIntersectionsPoints.begin();
+ aPntIt != anIntersectionsPoints.end(); ++aPntIt, ++aResultIndex) {
+ std::shared_ptr<SketchPlugin_Point> aCurSketchPoint;
+ if (aExistInterIt == anExistentIntersections.end()) {
+ keepCurrentFeature();
+
+ // create new point
+ aCurSketchPoint = std::dynamic_pointer_cast<SketchPlugin_Point>(
+ sketch()->addFeature(SketchPlugin_Point::ID()));
+ aCurSketchPoint->boolean(COPY_ID())->setValue(true);
+ anIntersectionsList->append(aCurSketchPoint);
+
+ restoreCurrentFeature();
+ } else {
+ // update existent point
+ aCurSketchPoint = std::dynamic_pointer_cast<SketchPlugin_Point>(*aExistInterIt);
+ ++aExistInterIt;
+ }
+
+ ResultConstructionPtr aCurResult;
+ if (aResIt == aResults.end()) {
+ // create new result
+ aCurResult = document()->createConstruction(data(), aResultIndex);
+ aCurResult->setIsInHistory(false);
+ aCurResult->setDisplayed(false);
+ } else {
+ // update existent result
+ aCurResult = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aResIt);
+ aCurResult->setShape(std::shared_ptr<GeomAPI_Edge>());
+ ++aResIt;
+ }
+
+ // update coordinates of intersection
+ GeomPnt2dPtr aPointInSketch = sketch()->to2D(*aPntIt);
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aCurSketchPoint->attribute(SketchPlugin_Point::COORD_ID()))->setValue(aPointInSketch);
+ aCurSketchPoint->execute();
+
+ // update result
+ aCurResult->setShape(aCurSketchPoint->lastResult()->shape());
+ setResult(aCurResult, aResultIndex);
+
+ // make intersection point external
+ GeomShapePtr anEmptyVal;
+ aCurSketchPoint->selection(EXTERNAL_ID())->setValue(aCurResult, anEmptyVal);
+ }
+
+ // remove rest results from previous pass
+ removeResults(aResultIndex);
+ std::set<FeaturePtr> aFeaturesToBeRemoved;
+ for (; aExistInterIt != anExistentIntersections.end(); ++aExistInterIt) {
+ aFeaturesToBeRemoved.insert(ModelAPI_Feature::feature(*aExistInterIt));
+ anIntersectionsList->removeLast();
+ }
+ ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToBeRemoved);
+
+ if (theID != EXTERNAL_ID())
+ selection(EXTERNAL_ID())->selectValue(anExternalFeature);
+ }
+ myIsComputing = false;