Salome HOME
Coding rules fixes.
[modules/shaper.git] / src / BuildPlugin / BuildPlugin_Validators.cpp
index 613e343629388cc70f11c205ccccd512b75b4233..244ddb6e4f7ae9d0ed8ee89500e2c8e8b6c2b8a5 100644 (file)
@@ -1,8 +1,22 @@
-// 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"
 
@@ -135,9 +149,11 @@ bool BuildPlugin_ValidatorBaseForWire::isValid(const std::shared_ptr<ModelAPI_Fe
     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.
@@ -182,6 +198,10 @@ bool BuildPlugin_ValidatorBaseForFace::isValid(const std::shared_ptr<ModelAPI_Fe
     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()) {
@@ -190,6 +210,11 @@ bool BuildPlugin_ValidatorBaseForFace::isValid(const std::shared_ptr<ModelAPI_Fe
     }
   }
 
+  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);
@@ -213,7 +238,7 @@ bool BuildPlugin_ValidatorBaseForFace::isValid(const std::shared_ptr<ModelAPI_Fe
   // 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;
   }
 
@@ -222,7 +247,7 @@ bool BuildPlugin_ValidatorBaseForFace::isValid(const std::shared_ptr<ModelAPI_Fe
   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;
   }