-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File: BuildPlugin_Validators.cpp
-// Created: 22 March 2016
-// Author: Dmitry Bobylev
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
#include "BuildPlugin_Validators.h"
AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
GeomShapePtr aShape = aSelection->value();
if(!aShape.get()) {
- aShape = aSelection->context()->shape();
+ if (aSelection->context().get())
+ aShape = aSelection->context()->shape();
}
- aListOfShapes.push_back(aShape);
+ if (aShape.get())
+ aListOfShapes.push_back(aShape);
}
// Create wire.
AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
GeomShapePtr aShape = aSelection->value();
if(!aShape.get()) {
+ if (!aSelection->context()) {
+ theError = "Objects are not selected.";
+ return false;
+ }
aShape = aSelection->context()->shape();
}
for(GeomAPI_ShapeExplorer anExp(aShape, GeomAPI_Shape::EDGE); anExp.more(); anExp.next()) {
}
}
+ if(anEdges.empty()) {
+ theError = "Objects are not selected.";
+ return false;
+ }
+
// Check that edges does not have intersections.
if(anEdges.size() > 1) {
GeomAlgoAPI_PaveFiller aPaveFiller(anEdges, false);
// Check that they are planar.
std::shared_ptr<GeomAPI_Pln> aPln = GeomAlgoAPI_ShapeTools::findPlane(anEdges);
if(!aPln.get()) {
- theError = "Selected objects are not planar.";
+ theError = "Selected object(s) should belong to only one plane.";
return false;
}
GeomAlgoAPI_SketchBuilder::createFaces(aPln->location(), aPln->xDirection(),
aPln->direction(), anEdges, aFaces);
if(aFaces.empty()) {
- theError = "Selected objects does not have closed contours.";
+ theError = "Selected objects do not generate closed contour.";
return false;
}