X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPrimitivesAPI%2FPrimitivesAPI_Sphere.cpp;h=ce4a51bc261785fcd6cd2d435638605c9fd1c624;hb=refs%2Fheads%2F30735;hp=dc8b6aba6b36e17bc208617183f8c07c24ebe4b6;hpb=15d511a49a2b8f1fa39496c7abf79ea285d23ce5;p=modules%2Fshaper.git diff --git a/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp b/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp index dc8b6aba6..ce4a51bc2 100644 --- a/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp +++ b/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp @@ -1,4 +1,21 @@ -// Copyright (C) 2014-201x CEA/DEN, EDF R&D --> +// Copyright (C) 2017-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 +// // File: PrimitivesAPI_Sphere.h // Created: 16 Mar 2017 @@ -24,11 +41,34 @@ PrimitivesAPI_Sphere::PrimitivesAPI_Sphere(const std::shared_ptr& theFeature, + const ModelHighAPI_Double& theRMin, + const ModelHighAPI_Double& theRMax, + const ModelHighAPI_Double& thePhiMin, + const ModelHighAPI_Double& thePhiMax, + const ModelHighAPI_Double& theThetaMin, + const ModelHighAPI_Double& theThetaMax) +: ModelHighAPI_Interface(theFeature) +{ + if (initialize()) { + fillAttribute(PrimitivesPlugin_Sphere::CREATION_METHOD_BY_DIMENSIONS(), creationMethod()); + fillAttribute(theRMin, rmin()); + fillAttribute(theRMax, rmax()); + fillAttribute(thePhiMin, phimin()); + fillAttribute(thePhiMax, phimax()); + fillAttribute(theThetaMin, thetamin()); + fillAttribute(theThetaMax, thetamax()); + execute(); + } +} + //================================================================================================== PrimitivesAPI_Sphere::~PrimitivesAPI_Sphere() { @@ -48,6 +88,33 @@ void PrimitivesAPI_Sphere::setRadius(const ModelHighAPI_Double& theRadius) execute(); } +//================================================================================================== +void PrimitivesAPI_Sphere::setRadius(const ModelHighAPI_Double& theRMin, + const ModelHighAPI_Double& theRMax) +{ + fillAttribute(theRMin, rmin()); + fillAttribute(theRMax, rmax()); + execute(); +} + +//================================================================================================== +void PrimitivesAPI_Sphere::setPhi(const ModelHighAPI_Double& thePhiMin, + const ModelHighAPI_Double& thePhiMax) +{ + fillAttribute(thePhiMin, phimin()); + fillAttribute(thePhiMax, phimax()); + execute(); +} + +//================================================================================================== +void PrimitivesAPI_Sphere::setTheta(const ModelHighAPI_Double& theThetaMin, + const ModelHighAPI_Double& theThetaMax) +{ + fillAttribute(theThetaMin, thetamin()); + fillAttribute(theThetaMax, thetamax()); + execute(); +} + //================================================================================================== void PrimitivesAPI_Sphere::dump(ModelHighAPI_Dumper& theDumper) const { @@ -56,10 +123,24 @@ void PrimitivesAPI_Sphere::dump(ModelHighAPI_Dumper& theDumper) const theDumper << aBase << " = model.addSphere(" << aDocName; - AttributeSelectionPtr anAttrCenterPoint = - aBase->selection(PrimitivesPlugin_Sphere::CENTER_POINT_ID()); - AttributeDoublePtr anAttrRadius = aBase->real(PrimitivesPlugin_Sphere::RADIUS_ID()); - theDumper << ", " << anAttrCenterPoint << ", " << anAttrRadius; + std::string aCreationMethod = aBase->string(PrimitivesPlugin_Sphere::CREATION_METHOD())->value(); + + if (aCreationMethod == PrimitivesPlugin_Sphere::CREATION_METHOD_BY_DIMENSIONS()) { + AttributeDoublePtr anAttrRMin = aBase->real(PrimitivesPlugin_Sphere::RMIN_ID()); + AttributeDoublePtr anAttrRMax = aBase->real(PrimitivesPlugin_Sphere::RMAX_ID()); + AttributeDoublePtr anAttrPhiMin = aBase->real(PrimitivesPlugin_Sphere::PHIMIN_ID()); + AttributeDoublePtr anAttrPhiMax = aBase->real(PrimitivesPlugin_Sphere::PHIMAX_ID()); + AttributeDoublePtr anAttrThetaMin = aBase->real(PrimitivesPlugin_Sphere::THETAMIN_ID()); + AttributeDoublePtr anAttrThetaMax = aBase->real(PrimitivesPlugin_Sphere::THETAMAX_ID()); + theDumper << ", " << anAttrRMin << ", " << anAttrRMax; + theDumper << ", " << anAttrPhiMin << ", " << anAttrPhiMax; + theDumper << ", " << anAttrThetaMin << ", " << anAttrThetaMax; + } else { // CREATION_METHOD_BY_PT_RADIUS by default to support versions with undefined method + AttributeSelectionPtr anAttrCenterPoint = + aBase->selection(PrimitivesPlugin_Sphere::CENTER_POINT_ID()); + AttributeDoublePtr anAttrRadius = aBase->real(PrimitivesPlugin_Sphere::RADIUS_ID()); + theDumper << ", " << anAttrCenterPoint << ", " << anAttrRadius; + } theDumper << ")" << std::endl; } @@ -77,7 +158,21 @@ SpherePtr addSphere(const std::shared_ptr& thePart, SpherePtr addSphere(const std::shared_ptr& thePart, const ModelHighAPI_Double& theRadius) { - ModelHighAPI_Selection aCenterPoint("VERTEX", "PartSet/Origin"); + ModelHighAPI_Selection aCenterPoint("VERTEX", L"PartSet/Origin"); std::shared_ptr aFeature = thePart->addFeature(PrimitivesAPI_Sphere::ID()); return SpherePtr(new PrimitivesAPI_Sphere(aFeature, aCenterPoint, theRadius)); } + +//================================================================================================== +SpherePtr addSphere(const std::shared_ptr& thePart, + const ModelHighAPI_Double& theRMin, + const ModelHighAPI_Double& theRMax, + const ModelHighAPI_Double& thePhiMin, + const ModelHighAPI_Double& thePhiMax, + const ModelHighAPI_Double& theThetaMin, + const ModelHighAPI_Double& theThetaMax) +{ + std::shared_ptr aFeature = thePart->addFeature(PrimitivesAPI_Sphere::ID()); + return SpherePtr(new PrimitivesAPI_Sphere(aFeature, theRMin, theRMax, thePhiMin, thePhiMax, + theThetaMin, theThetaMax)); +}