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>
11 #include <ModelAPI_ResultConstruction.h>
13 #include <Events_Error.h>
15 #include <GeomAPI_DataMapOfShapeShape.h>
16 #include <GeomAPI_PlanarEdges.h>
17 #include <GeomAPI_ShapeExplorer.h>
19 #include <GeomAlgoAPI_ShapeTools.h>
20 #include <GeomAlgoAPI_WireBuilder.h>
24 //=================================================================================================
25 BuildPlugin_Vertex::BuildPlugin_Vertex()
29 //=================================================================================================
30 void BuildPlugin_Vertex::initAttributes()
32 data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
35 //=================================================================================================
36 void BuildPlugin_Vertex::execute()
38 // Get base objects list.
39 AttributeSelectionListPtr aSelectionList = selectionList(BASE_OBJECTS_ID());
40 if(!aSelectionList.get()) {
41 setError("Error: Could not get selection list.");
44 if(aSelectionList->size() == 0) {
45 setError("Error: Empty selection list.");
49 // Collect base shapes.
50 ListOfShape aListOfShapes;
52 for(int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
53 AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
54 GeomShapePtr aShape = aSelection->value();
56 ResultPtr aContext = aSelection->context();
58 setError("Error: Attribute has empty context.");
62 aShape = aContext->shape();
65 setError("Error: Empty shape selected.");
69 if(aShape->shapeType() != GeomAPI_Shape::VERTEX) {
70 setError("Error: Selected shape has wrong type. Only vertices acceptable.");
75 ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
76 aResultBody->store(aShape);
77 setResult(aResultBody, aResultIndex);
81 removeResults(aResultIndex);