X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMAlgo%2FGEOMAlgo_SurfaceTools.cxx;h=fd2171e632ea8a40a81dceb84c02a0a4bf985d01;hb=04f3d723da1ae9133d108921c8f10338a9656d12;hp=b07749692d85e256c433e9417ba857cde1461290;hpb=d85baed10766f28c2465ba7e47cced8e52b1c644;p=modules%2Fgeom.git diff --git a/src/GEOMAlgo/GEOMAlgo_SurfaceTools.cxx b/src/GEOMAlgo/GEOMAlgo_SurfaceTools.cxx index b07749692..fd2171e63 100644 --- a/src/GEOMAlgo/GEOMAlgo_SurfaceTools.cxx +++ b/src/GEOMAlgo/GEOMAlgo_SurfaceTools.cxx @@ -1,3 +1,22 @@ +// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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. +// +// 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: GEOMAlgo_SurfaceTools.cxx // Created: Thu Jan 27 11:05:16 2005 // Author: Peter KURNEV @@ -6,6 +25,8 @@ #include +#include + #include #include #include @@ -13,30 +34,31 @@ #include #include #include +#include +#include #include #include + //======================================================================= //function : GetState //purpose : //======================================================================= Standard_Integer GEOMAlgo_SurfaceTools::GetState(const gp_Pnt& aP, - const Handle(Geom_Surface)& aSurf, + const GeomAdaptor_Surface& aGAS, const Standard_Real aTol, TopAbs_State& aState) { Standard_Integer iErr; Standard_Real aDp, aR; GeomAbs_SurfaceType aType; - GeomAdaptor_Surface aGAS; gp_Sphere aSph; gp_Cylinder aCyl; gp_Pln aPln; // iErr=0; aState=TopAbs_UNKNOWN; - aGAS.Load(aSurf); // aType=aGAS.GetType(); switch (aType) { @@ -76,6 +98,25 @@ return iErr; } //======================================================================= +//function : GetState +//purpose : +//======================================================================= + Standard_Integer GEOMAlgo_SurfaceTools::GetState(const gp_Pnt& aP, + const Handle(Geom_Surface)& aSurf, + const Standard_Real aTol, + TopAbs_State& aState) +{ + Standard_Integer iErr; + GeomAdaptor_Surface aGAS; + // + aState=TopAbs_UNKNOWN; + aGAS.Load(aSurf); + // + iErr=GEOMAlgo_SurfaceTools::GetState(aP, aGAS, aTol, aState); + // + return iErr; +} +//======================================================================= //function : ReverseState //purpose : //======================================================================= @@ -103,9 +144,8 @@ Standard_Real GEOMAlgo_SurfaceTools::Distance(const gp_Pnt& aP, const gp_Sphere& aSph) { - Standard_Real aD, aR; + Standard_Real aD; // - aR=aSph.Radius(); const gp_Pnt& aLoc=aSph.Location(); aD=aLoc.Distance(aP); // @@ -118,9 +158,8 @@ Standard_Real GEOMAlgo_SurfaceTools::Distance(const gp_Pnt& aP, Standard_Real GEOMAlgo_SurfaceTools::Distance(const gp_Pnt& aP, const gp_Cylinder& aCyl) { - Standard_Real aD, aR; + Standard_Real aD; // - aR=aCyl.Radius(); const gp_Ax1& aAxis=aCyl.Axis(); gp_Lin aLin(aAxis); aD=aLin.Distance(aP); @@ -146,6 +185,31 @@ Standard_Real GEOMAlgo_SurfaceTools::Distance(const gp_Pnt& aP, return aD; } //======================================================================= +//function : IsCoaxial +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_SurfaceTools::IsCoaxial(const gp_Pnt& aP1, + const gp_Pnt& aP2, + const gp_Cylinder& aCyl, + const Standard_Real aTol) +{ + Standard_Boolean bRet=Standard_False; + Standard_Real aSM; + // + gp_Vec aV12(aP1, aP2); + gp_Dir aD12(aV12); + // + const gp_Ax1& aAxis=aCyl.Axis(); + const gp_Dir& aDAxis=aAxis.Direction(); + // + aSM=fabs(aD12*aDAxis); + if (fabs(1.-aSM) > aTol) { + return bRet; + } + // + return !bRet; +} +//======================================================================= //function : IsAnalytic //purpose : //=======================================================================