Salome HOME
Fix for the issue #2461: crash when changing points on plane creation
[modules/shaper.git] / src / ConstructionPlugin / ConstructionPlugin_Plane.cpp
index a121c4191f56934fbf6a2d487eca2fe194166f13..3680ab50302fd64895e7c84891b99395a6ee83b3 100644 (file)
@@ -1,8 +1,22 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        ConstructionPlugin_Plane.cpp
-// Created:     12 Dec 2014
-// Author:      Vitaly Smetannikov
+// 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 "ConstructionPlugin_Plane.h"
 
@@ -139,8 +153,7 @@ bool ConstructionPlugin_Plane::customisePresentation(ResultPtr theResult, AISObj
     }
   }
   if (aColor.empty())
-    aColor = Config_PropManager::color("Visualization", "construction_plane_color",
-                                       ConstructionPlugin_Plane::DEFAULT_COLOR());
+    aColor = Config_PropManager::color("Visualization", "construction_plane_color");
 
   bool isCustomized = false;
   if (aColor.size() == 3)
@@ -167,8 +180,7 @@ std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createByGeneralEquation
            aC = anAttrC->value(), aD = anAttrD->value();
     std::shared_ptr<GeomAPI_Pln> aPlane =
       std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
-    std::string kDefaultPlaneSize = "200";
-    double aSize = Config_PropManager::integer(SKETCH_TAB_NAME, "planes_size", kDefaultPlaneSize);
+    double aSize = Config_PropManager::integer(SKETCH_TAB_NAME, "planes_size");
     aSize *= 4.;
     aPlaneFace = GeomAlgoAPI_FaceBuilder::squareFace(aPlane, aSize);
   }
@@ -340,8 +352,17 @@ std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createByRotation()
   double anAngle = real(ANGLE())->value();
 
   GeomAlgoAPI_Rotation aRotationAlgo(aFace, anAxis, anAngle);
-  std::shared_ptr<GeomAPI_Face> aRes(new GeomAPI_Face(aRotationAlgo.shape()));
+  if (!aRotationAlgo.check()) {
+    setError(aRotationAlgo.getError());
+    return GeomShapePtr();
+  }
+  aRotationAlgo.build();
+  if (!aRotationAlgo.isDone()) {
+    setError("Error: Failed to rotate plane");
+    return GeomShapePtr();
+  }
 
+  std::shared_ptr<GeomAPI_Face> aRes(new GeomAPI_Face(aRotationAlgo.shape()));
   return aRes;
 }