X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_Circ2d.cpp;h=5df372df7d1762ae09d2ec65984abcd522dc2b2d;hb=f60dc9dd94d5d4b0ea07e3e3cbfd5b3028f0942d;hp=0a7a9a01bd77c3848d9582b0e2e06f502e2af92e;hpb=35a88fdd724349275bbff32b9596a44e7cd422e2;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_Circ2d.cpp b/src/GeomAPI/GeomAPI_Circ2d.cpp index 0a7a9a01b..5df372df7 100644 --- a/src/GeomAPI/GeomAPI_Circ2d.cpp +++ b/src/GeomAPI/GeomAPI_Circ2d.cpp @@ -1,22 +1,35 @@ -// File: GeomAPI_Circ2d.cpp -// Created: 29 May 2014 -// Author: Artem ZHIDKOV +// 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 #include #include -#include #include #include -#include +#include #include -#include #include -#include +#define MY_CIRC2D implPtr() -#define MY_CIRC2D static_cast(myImpl) static gp_Circ2d* newCirc2d(const double theCenterX, const double theCenterY, const gp_Dir2d theDir, const double theRadius) @@ -36,11 +49,13 @@ static gp_Circ2d* newCirc2d(const double theCenterX, const double theCenterY, if (aCenter.IsEqual(aPoint, Precision::Confusion())) return NULL; - gp_Dir2d aDir(theCenterX - thePointX, theCenterY - thePointY); + gp_Dir2d aDir(thePointX - theCenterX, thePointY - theCenterY); return newCirc2d(theCenterX, theCenterY, aDir, aRadius); } + + GeomAPI_Circ2d::GeomAPI_Circ2d(const std::shared_ptr& theCenter, const std::shared_ptr& theCirclePoint) : GeomAPI_Interface( @@ -53,7 +68,6 @@ GeomAPI_Circ2d::GeomAPI_Circ2d(const std::shared_ptr& theCenter, : GeomAPI_Interface( newCirc2d(theCenter->x(), theCenter->y(), theDir->impl(), theRadius)) { - } const std::shared_ptr GeomAPI_Circ2d::project( @@ -86,12 +100,35 @@ const std::shared_ptr GeomAPI_Circ2d::project( const std::shared_ptr GeomAPI_Circ2d::center() const { + if (!MY_CIRC2D) + return std::shared_ptr(); const gp_Pnt2d& aCenter = MY_CIRC2D->Location(); return std::shared_ptr(new GeomAPI_Pnt2d(aCenter.X(), aCenter.Y())); } double GeomAPI_Circ2d::radius() const { + if (!MY_CIRC2D) + return 0.0; return MY_CIRC2D->Radius(); } +//================================================================================================= +const bool GeomAPI_Circ2d::parameter(const std::shared_ptr thePoint, + const double theTolerance, + double& theParameter) const +{ + Handle(Geom2d_Circle) aCurve = new Geom2d_Circle(*MY_CIRC2D); + return GeomLib_Tool::Parameter(aCurve, thePoint->impl(), + theTolerance, theParameter) == Standard_True; +} + +//================================================================================================= +void GeomAPI_Circ2d::D0(const double theU, std::shared_ptr& thePoint) +{ + Handle(Geom2d_Circle) aCurve = new Geom2d_Circle(*MY_CIRC2D); + gp_Pnt2d aPnt; + aCurve->D0(theU, aPnt); + thePoint.reset(new GeomAPI_Pnt2d(aPnt.X(), aPnt.Y())); +} +