- if (theFeature->getKind() != "Sketch") return false;
-
- // Sub-features
- CompositeFeaturePtr aComposite =
- std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
- if (!aComposite) return false;
- int nbSubs = aComposite->numberOfSubs();
- if (nbSubs < 1) return false;
-
- // The whole sketch shape
- ResultPtr aContext = theFeature->firstResult();
- GeomShapePtr theShape = aContext->shape();
-
- GeomAPI_DataMapOfShapeShape alreadyProcessed;
-
- // 1. Explode on Vertices
- for (GeomAPI_ShapeExplorer anExp (theShape, GeomAPI_Shape::VERTEX); anExp.more(); anExp.next()) {
- GeomShapePtr aSubShape = anExp.current();
-
- if (alreadyProcessed.bind(aSubShape, aSubShape)) {
- // Store result.
- ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex);
- aResultBody->storeModified(theShape, aSubShape);
- setResult(aResultBody, theResultIndex);
- ++theResultIndex;
- }
- }
-
- // 2. If need intersection points, perform Partition
- if (isIntersect) {
- // Partition
- ListOfShape anObjList, aTools;
- anObjList.push_back(theShape);
- std::shared_ptr<GeomAlgoAPI_Partition> aPartitionAlgo (new GeomAlgoAPI_Partition(anObjList, aTools));
-
- std::string anError;
- if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPartitionAlgo, getKind(), anError)) {
- setError(anError);
- return false;
- }
- GeomShapePtr aSplittedSketch = aPartitionAlgo->shape();
-
- // Explode on Vertices, skip vertices of initial sketch
- for (GeomAPI_ShapeExplorer anExp (aSplittedSketch, GeomAPI_Shape::VERTEX); anExp.more(); anExp.next()) {
- GeomShapePtr aSubShape = anExp.current();
-
- //if (!theShape->isSubShape(aSubShape)) { // skip vertices of initial sketch
- if (alreadyProcessed.bind(aSubShape, aSubShape)) {
- // Store result.
- ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex);
- aResultBody->storeGenerated(anObjList, aSubShape, aPartitionAlgo);
- setResult(aResultBody, theResultIndex);
- ++theResultIndex;
+ FeaturePtr aFeature = theSelection->contextFeature();
+ ResultPtr aContext = theSelection->context();
+ GeomShapePtr aShape = theSelection->value();
+ if (aShape)
+ thePrimitives.push_back(aShape);
+ else {
+ if (aContext && !aFeature)
+ aFeature = ModelAPI_Feature::feature(aContext);
+ if (!aFeature)
+ return;
+
+ // process results of the feature
+ const std::list<ResultPtr>& aResults = aFeature->results();
+ std::list<ResultPtr>::const_iterator anIt = aResults.begin();
+ for (; anIt != aResults.end(); ++anIt)
+ thePrimitives.push_back((*anIt)->shape());
+
+ CompositeFeaturePtr aComposite =
+ std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
+ if (!aComposite)
+ return;
+
+ // add construction points (centers of circles, etc.)
+ for (int i = 0, nbSubs = aComposite->numberOfSubs(); i < nbSubs; ++i) {
+ FeaturePtr aSubFeature = aComposite->subFeature(i);
+ const std::list<ResultPtr>& aSubResults = aSubFeature->results();
+ // find all points
+ for (anIt = aSubResults.begin(); anIt != aSubResults.cend(); ++anIt) {
+ GeomShapePtr aSubResShape = (*anIt)->shape();
+ if (aSubResShape->isVertex())
+ thePrimitives.push_back(aSubResShape);