X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_Symmetry.cpp;h=66b15106ed23768216ebb0c9f8c2f09571317f4c;hb=b3f7b461d00b6ddf3736c8284498a9f33428577c;hp=143f41c4bfc26356b19d1ca76d497b43a38695b6;hpb=68eaab2e9a4d4c8c729b790e61f506ebb21928b0;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Symmetry.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Symmetry.cpp index 143f41c4b..66b15106e 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Symmetry.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Symmetry.cpp @@ -1,137 +1,69 @@ -// Copyright (C) 2014-2016 CEA/DEN, EDF R&D - -// File: GeomAlgoAPI_Symmetry.cpp -// Created: 30 Nov 2016 -// Author: Clarisse Genrault (CEA) - -#include "GeomAlgoAPI_Symmetry.h" - -#include +// Copyright (C) 2014-2022 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 + +#include +#include +#include //================================================================================================= GeomAlgoAPI_Symmetry::GeomAlgoAPI_Symmetry(std::shared_ptr theSourceShape, std::shared_ptr thePoint) { - myMethodType = BY_POINT; - mySourceShape = theSourceShape; - myPoint = thePoint; + if (!thePoint) { + myError = "Symmetry builder :: point is not valid."; + return; + } + + GeomTrsfPtr aTrsf(new GeomAPI_Trsf); + aTrsf->setSymmetry(thePoint); + + build(theSourceShape, aTrsf); } //================================================================================================= GeomAlgoAPI_Symmetry::GeomAlgoAPI_Symmetry(std::shared_ptr theSourceShape, std::shared_ptr theAxis) { - myMethodType = BY_AXIS; - mySourceShape = theSourceShape; - myAxis = theAxis; -} + if (!theAxis) { + myError = "Symmetry builder :: axis is not valid."; + return; + } -//================================================================================================= -GeomAlgoAPI_Symmetry::GeomAlgoAPI_Symmetry(std::shared_ptr theSourceShape, - std::shared_ptr thePlane) -{ - myMethodType = BY_PLANE; - mySourceShape = theSourceShape; - myPlane = thePlane; -} + GeomTrsfPtr aTrsf(new GeomAPI_Trsf); + aTrsf->setSymmetry(theAxis); -//================================================================================================= -bool GeomAlgoAPI_Symmetry::check() -{ - switch (myMethodType) { - case BY_POINT: { - if (!myPoint) { - myError = "Symmetry builder :: point is invalid."; - return false; - } - if (!mySourceShape) { - myError = "Symmetry builder :: source shape is invalid."; - return false; - } - return true; - } - case BY_AXIS: { - if (!myAxis) { - myError = "Symmetry builder :: axis is invalid."; - return false; - } - if (!mySourceShape) { - myError = "Symmetry builder :: source shape is invalid."; - return false; - } - return true; - } - case BY_PLANE: { - if (!myPlane) { - myError = "Symmetry builder :: plane is invalid."; - return false; - } - if (!mySourceShape) { - myError = "Symmetry builder :: source shape is invalid."; - return false; - } - return true; - } - default: { - myError = "Symmetry builder :: method not implemented."; - return false; - } - } + build(theSourceShape, aTrsf); } //================================================================================================= -void GeomAlgoAPI_Symmetry::build() +GeomAlgoAPI_Symmetry::GeomAlgoAPI_Symmetry(std::shared_ptr theSourceShape, + std::shared_ptr thePlane) { - gp_Trsf* aTrsf = new gp_Trsf(); - - switch (myMethodType) { - case BY_POINT: { - const gp_Pnt& aPoint = myPoint->impl(); - aTrsf->SetMirror(aPoint); - break; - } - case BY_AXIS: { - const gp_Ax1& anAxis = myAxis->impl(); - aTrsf->SetMirror(anAxis); - break; - } - case BY_PLANE: { - const gp_Ax2& aPlane = myPlane->impl(); - aTrsf->SetMirror(aPlane); - break; - } - default: { - myError = "Mirror builder :: method not supported"; - return; - } - } - - const TopoDS_Shape& aSourceShape = mySourceShape->impl(); - - if(aSourceShape.IsNull()) { - myError = "Mirror builder :: source shape does not contain any actual shape."; + if (!thePlane) { + myError = "Symmetry builder :: plane is not valid."; return; } - // Transform the shape while copying it. - BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, *aTrsf, true); - if(!aBuilder) { - myError = "Mirror builder :: source shape does not contain any actual shape."; - return; - } - - setImpl(aBuilder); - setBuilderType(OCCT_BRepBuilderAPI_MakeShape); - - if(!aBuilder->IsDone()) { - myError = "Mirror builder :: source shape does not contain any actual shape."; - return; - } + GeomTrsfPtr aTrsf(new GeomAPI_Trsf); + aTrsf->setSymmetry(thePlane); - TopoDS_Shape aResult = aBuilder->Shape(); - - std::shared_ptr aShape(new GeomAPI_Shape()); - aShape->setImpl(new TopoDS_Shape(aResult)); - setShape(aShape); - setDone(true); -} \ No newline at end of file + build(theSourceShape, aTrsf); +}