1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: BuildPlugin_Vertex.cpp
4 // Created: 18 April 2016
5 // Author: Dmitry Bobylev
7 #include "BuildPlugin_Vertex.h"
9 #include <ModelAPI_AttributeSelectionList.h>
10 #include <ModelAPI_ResultBody.h>
12 //=================================================================================================
13 BuildPlugin_Vertex::BuildPlugin_Vertex()
17 //=================================================================================================
18 void BuildPlugin_Vertex::initAttributes()
20 data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
23 //=================================================================================================
24 void BuildPlugin_Vertex::execute()
26 // Get base objects list.
27 AttributeSelectionListPtr aSelectionList = selectionList(BASE_OBJECTS_ID());
28 if(!aSelectionList.get()) {
29 setError("Error: Could not get selection list.");
32 if(aSelectionList->size() == 0) {
33 setError("Error: Empty selection list.");
37 // Collect base shapes.
38 ListOfShape aListOfShapes;
40 for(int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
41 AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
42 GeomShapePtr aShape = aSelection->value();
44 ResultPtr aContext = aSelection->context();
46 setError("Error: Attribute has empty context.");
50 aShape = aContext->shape();
53 setError("Error: Empty shape selected.");
57 if(aShape->shapeType() != GeomAPI_Shape::VERTEX) {
58 setError("Error: Selected shape has wrong type. Only vertices acceptable.");
63 ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
64 aResultBody->store(aShape);
65 setResult(aResultBody, aResultIndex);
69 removeResults(aResultIndex);