+
+static void collectEdgesAndVertices(AttributeSelectionPtr theSelection, ListOfShape& thePrimitives)
+{
+ 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);
+ }
+ }
+ }
+}
+
+void BuildPlugin_Vertex::execute()
+{
+ // Get base objects list.
+ AttributeSelectionListPtr aSelectionList = selectionList(BASE_OBJECTS_ID());
+ if (!aSelectionList.get()) {
+ setError("Error: Could not get selection list.");
+ return;
+ }
+ if (aSelectionList->size() == 0) {
+ setError("Error: Empty selection list.");
+ return;
+ }
+
+ // Get "Compute intersections" flag value
+ bool isIntersect = false;
+ if (boolean(INTERSECT_ID()).get() && boolean(INTERSECT_ID())->isInitialized()) {
+ isIntersect = boolean(INTERSECT_ID())->value();
+ }
+
+ // Iterate arguments and collect shapes
+ ListOfShape aShapes;
+ for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
+ AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
+ collectEdgesAndVertices(aSelection, aShapes);
+ }
+
+ buildVertices(aShapes, isIntersect);
+}