// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 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 // // #include #include #include #include #include #include #include #include #include #include #include #include #include //======================================================================= //function : GetState //purpose : //======================================================================= Standard_Integer GEOMAlgo_SurfaceTools::GetState(const gp_Pnt& aP, const GeomAdaptor_Surface& aGAS, const Standard_Real aTol, TopAbs_State& aState) { Standard_Integer iErr; Standard_Real aDp, aR; GeomAbs_SurfaceType aType; gp_Sphere aSph; gp_Cylinder aCyl; gp_Pln aPln; // iErr=0; aState=TopAbs_UNKNOWN; // aType=aGAS.GetType(); switch (aType) { case GeomAbs_Plane: aPln=aGAS.Plane(); aR=0.; aDp=GEOMAlgo_SurfaceTools::Distance(aP, aPln); break; case GeomAbs_Cylinder: aCyl=aGAS.Cylinder(); aR=aCyl.Radius(); aDp=GEOMAlgo_SurfaceTools::Distance(aP, aCyl); break; case GeomAbs_Sphere: aSph=aGAS.Sphere(); aR=aSph.Radius(); aDp=GEOMAlgo_SurfaceTools::Distance(aP, aSph); break; default: iErr=1; // unprocessed surface type break; } // if (!iErr) { aState=TopAbs_ON; if (aDp>aR+aTol) { aState=TopAbs_OUT; } else if (aDp aTol) { return bRet; } // return !bRet; } //======================================================================= //function : IsAnalytic //purpose : //======================================================================= Standard_Boolean GEOMAlgo_SurfaceTools::IsAnalytic(const Handle(Geom_Surface)& aSurf) { Standard_Boolean bRet; GeomAbs_SurfaceType aType; GeomAdaptor_Surface aGAS; // aGAS.Load(aSurf); aType=aGAS.GetType(); bRet=(aType==GeomAbs_Plane || aType==GeomAbs_Cylinder || aType==GeomAbs_Sphere); return bRet; } //======================================================================= //function : IsConformState //purpose : //======================================================================= Standard_Boolean GEOMAlgo_SurfaceTools::IsConformState(const TopAbs_State aST1, const GEOMAlgo_State aST2) { Standard_Boolean bRet=Standard_False; // switch (aST2) { case GEOMAlgo_ST_IN: if (aST1==TopAbs_IN) { bRet=!bRet; } break; case GEOMAlgo_ST_OUT: if (aST1==TopAbs_OUT) { bRet=!bRet; } break; case GEOMAlgo_ST_ON: if (aST1==TopAbs_ON) { bRet=!bRet; } break; case GEOMAlgo_ST_ONIN: if (aST1==TopAbs_ON || aST1==TopAbs_IN) { bRet=!bRet; } break; case GEOMAlgo_ST_ONOUT: if (aST1==TopAbs_ON || aST1==TopAbs_OUT) { bRet=!bRet; } break; default: break; } return bRet; }