X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FConstructionPlugin%2FConstructionPlugin_Plane.cpp;h=3680ab50302fd64895e7c84891b99395a6ee83b3;hb=f6bd0f4e080b833c0de7ef25822ebee641073445;hp=754a5aa4680f3e810a636a9d78b9a904d09b8e5f;hpb=6ffc58e695559e8997bbc8b977b537f1c63d45a8;p=modules%2Fshaper.git diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp index 754a5aa46..3680ab503 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp @@ -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 +// #include "ConstructionPlugin_Plane.h" @@ -89,7 +103,7 @@ void ConstructionPlugin_Plane::execute() GeomShapePtr aShape; std::string aCreationMethod = string(CREATION_METHOD())->value(); - if(aCreationMethod == CREATION_METHOD_BY_GENERAL_EQUATION() || + if(aCreationMethod == CREATION_METHOD_BY_GENERAL_EQUATION() || aCreationMethod == "PlaneByGeneralEquation") { aShape = createByGeneralEquation(); } else if(aCreationMethod == CREATION_METHOD_BY_THREE_POINTS()) { @@ -129,7 +143,7 @@ bool ConstructionPlugin_Plane::customisePresentation(ResultPtr theResult, AISObj { std::vector aColor; // get color from the attribute of the result - if (theResult.get() != NULL && + if (theResult.get() != NULL && theResult->data()->attribute(ModelAPI_Result::COLOR_ID()).get() != NULL) { AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID()); if (aColorAttr.get() && aColorAttr->size()) { @@ -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) @@ -165,10 +178,9 @@ std::shared_ptr ConstructionPlugin_Plane::createByGeneralEquation anAttrC->isInitialized() && anAttrD->isInitialized() ) { double aA = anAttrA->value(), aB = anAttrB->value(), aC = anAttrC->value(), aD = anAttrD->value(); - std::shared_ptr aPlane = + std::shared_ptr aPlane = std::shared_ptr(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); } @@ -332,7 +344,7 @@ std::shared_ptr ConstructionPlugin_Plane::createByRotation() } std::shared_ptr anEdge(new GeomAPI_Edge(anAxisShape)); - std::shared_ptr anAxis = + std::shared_ptr anAxis = std::shared_ptr(new GeomAPI_Ax1(anEdge->line()->location(), anEdge->line()->direction())); @@ -340,8 +352,17 @@ std::shared_ptr ConstructionPlugin_Plane::createByRotation() double anAngle = real(ANGLE())->value(); GeomAlgoAPI_Rotation aRotationAlgo(aFace, anAxis, anAngle); - std::shared_ptr 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 aRes(new GeomAPI_Face(aRotationAlgo.shape())); return aRes; } @@ -391,7 +412,7 @@ GeomShapePtr faceByThreeVertices(const std::shared_ptr theV1, anObjects.push_back(theV1); anObjects.push_back(theV2); anObjects.push_back(theV3); - std::list > aBoundingPoints = + std::list > aBoundingPoints = GeomAlgoAPI_ShapeTools::getBoundingBox(anObjects, 1.0); GeomShapePtr aRes = GeomAlgoAPI_ShapeTools::fitPlaneToBox(aFace, aBoundingPoints); @@ -431,7 +452,7 @@ std::shared_ptr makeRectangularFace(const std::shared_ptr aResFace = GeomAlgoAPI_FaceBuilder::planarFace(thePln, - aMinX2d - aWgap, aMinY2d - aHgap, aMaxX2d - aMinX2d + 2. * aWgap, + aMinX2d - aWgap, aMinY2d - aHgap, aMaxX2d - aMinX2d + 2. * aWgap, aMaxY2d - aMinY2d + 2. * aHgap); return aResFace;