X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_Transform.cpp;h=437c017e06c77925985d0a7e1dfb5f885f43e3c0;hb=fc72d43b677baa05ae7fd317346fd8b723b799ed;hp=e5409c49e64b11c9004af9470f42712db042abbf;hpb=65bd7c71b6eda2cad73adcc3be6c6ad725c26b94;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Transform.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Transform.cpp index e5409c49e..437c017e0 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Transform.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Transform.cpp @@ -1,10 +1,23 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: GeomAlgoAPI_Transform.cpp -// Created: 29 July 2015 -// Author: Dmitry Bobylev - -#include +// Copyright (C) 2014-2023 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 "GeomAlgoAPI_Transform.h" #include @@ -16,11 +29,6 @@ //================================================================================================= GeomAlgoAPI_Transform::GeomAlgoAPI_Transform(std::shared_ptr theSourceShape, std::shared_ptr theTrsf) -: myDone(false), - myTrsf(theTrsf), - myShape(new GeomAPI_Shape()), - myMap(new GeomAPI_DataMapOfShapeShape()), - myMkShape(new GeomAlgoAPI_MakeShape()) { build(theSourceShape, theTrsf); } @@ -29,77 +37,33 @@ GeomAlgoAPI_Transform::GeomAlgoAPI_Transform(std::shared_ptr theS void GeomAlgoAPI_Transform::build(std::shared_ptr theSourceShape, std::shared_ptr theTrsf) { - if(!theSourceShape || !theTrsf) { + if (!theSourceShape || !theTrsf) { + myError = "Transformation :: incorrect input data."; return; } const TopoDS_Shape& aSourceShape = theSourceShape->impl(); const gp_Trsf& aTrsf = theTrsf->impl(); - if(aSourceShape.IsNull()) { + if (aSourceShape.IsNull()) { + myError = "Transformation :: source shape does not contain any actual shape."; return; } BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, aTrsf, true); - if(!aBuilder) { + if (!aBuilder) return; - } - myDone = aBuilder->IsDone() == Standard_True; - if(!myDone) { + setImpl(aBuilder); + setBuilderType(OCCT_BRepBuilderAPI_MakeShape); + + if (aBuilder->IsDone() != Standard_True) return; - } TopoDS_Shape aResult = aBuilder->Shape(); - // Fill data map to keep correct orientation of sub-shapes. - for(TopExp_Explorer anExp(aResult, TopAbs_FACE); anExp.More(); anExp.Next()) { - std::shared_ptr aCurrentShape(new GeomAPI_Shape()); - aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current())); - myMap->bind(aCurrentShape, aCurrentShape); - } - - myMkShape->setImpl(aBuilder); - myShape->setImpl(new TopoDS_Shape(aResult)); -} - -//================================================================================================= -const bool GeomAlgoAPI_Transform::isValid() const -{ - BRepCheck_Analyzer aChecker(myShape->impl()); - return (aChecker.IsValid() == Standard_True); -} - -//================================================================================================= -const bool GeomAlgoAPI_Transform::hasVolume() const -{ - bool hasVolume(false); - if(isValid() && (GeomAlgoAPI_ShapeTools::volume(myShape) > Precision::Confusion())) { - hasVolume = true; - } - return hasVolume; -} - -//================================================================================================= -const std::shared_ptr& GeomAlgoAPI_Transform::shape() const -{ - return myShape; -} - -//================================================================================================= -std::shared_ptr GeomAlgoAPI_Transform::mapOfShapes() const -{ - return myMap; -} - -//================================================================================================= -std::shared_ptr GeomAlgoAPI_Transform::makeShape() const -{ - return myMkShape; -} - -//================================================================================================= -std::shared_ptr GeomAlgoAPI_Transform::transformation() const -{ - return myTrsf; + std::shared_ptr aShape(new GeomAPI_Shape()); + aShape->setImpl(new TopoDS_Shape(aResult)); + setShape(aShape); + setDone(true); }