Salome HOME
Revert "Synchronize adm files"
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_ClsfSurf.cxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File:        GEOMAlgo_ClsfSurf.cxx
24 // Created:     Wed Nov 22 10:41:47 2006
25 // Author:      Peter KURNEV
26 //              <pkv@irinox>
27 //
28 #include <GEOMAlgo_ClsfSurf.hxx>
29
30 #include <GeomAbs_SurfaceType.hxx>
31 #include <GeomAdaptor_Curve.hxx>
32
33 #include <GEOMAlgo_SurfaceTools.hxx>
34
35 IMPLEMENT_STANDARD_HANDLE(GEOMAlgo_ClsfSurf, GEOMAlgo_Clsf);
36 IMPLEMENT_STANDARD_RTTIEXT(GEOMAlgo_ClsfSurf, GEOMAlgo_Clsf);
37
38 //=======================================================================
39 //function :
40 //purpose  :
41 //=======================================================================
42   GEOMAlgo_ClsfSurf::GEOMAlgo_ClsfSurf()
43 :
44   GEOMAlgo_Clsf()
45 {
46 }
47 //=======================================================================
48 //function : ~
49 //purpose  :
50 //=======================================================================
51   GEOMAlgo_ClsfSurf::~GEOMAlgo_ClsfSurf()
52 {
53 }
54 //=======================================================================
55 //function : SetSurface
56 //purpose  :
57 //=======================================================================
58   void GEOMAlgo_ClsfSurf::SetSurface(const Handle(Geom_Surface)& aS)
59 {
60   myS=aS;
61 }
62 //=======================================================================
63 //function : Surface
64 //purpose  :
65 //=======================================================================
66   const Handle(Geom_Surface)& GEOMAlgo_ClsfSurf::Surface() const
67 {
68   return myS;
69 }
70 //=======================================================================
71 //function : CheckData
72 //purpose  :
73 //=======================================================================
74   void GEOMAlgo_ClsfSurf::CheckData()
75 {
76   GeomAbs_SurfaceType aType;
77   //
78   myErrorStatus=0;
79   //
80   if(myS.IsNull()) {
81     myErrorStatus=10; // mySurface=NULL
82     return;
83   }
84   //
85   myGAS.Load(myS);
86   aType=myGAS.GetType();
87   if (!(aType==GeomAbs_Plane ||
88         aType==GeomAbs_Cylinder ||
89         aType==GeomAbs_Sphere)) {
90     myErrorStatus=11; // unallowed surface type
91   }
92 }
93 //=======================================================================
94 //function : Perform
95 //purpose  :
96 //=======================================================================
97   void GEOMAlgo_ClsfSurf::Perform()
98 {
99   myErrorStatus=0;
100   /*
101   CheckData();
102   if(myErrorStatus) {
103     return;
104   }
105   */
106   GEOMAlgo_SurfaceTools::GetState(myPnt, myGAS, myTolerance, myState);
107 }
108 //=======================================================================
109 //function : CanBeON
110 //purpose  :
111 //=======================================================================
112   Standard_Boolean GEOMAlgo_ClsfSurf::CanBeON(const Handle(Geom_Curve)& aC) const
113 {
114   GeomAbs_SurfaceType aST;
115   GeomAbs_CurveType aCT;
116   GeomAdaptor_Curve aGAC;
117   //
118   aGAC.Load(aC);
119   aCT=aGAC.GetType();
120   //
121   aST=myGAS.GetType();
122   if (aCT==GeomAbs_Line && aST==GeomAbs_Sphere) {
123     return Standard_False;
124   }
125   return Standard_True;
126 }
127 //=======================================================================
128 //function : CanBeON
129 //purpose  :
130 //=======================================================================
131   Standard_Boolean GEOMAlgo_ClsfSurf::CanBeON(const Handle(Geom_Surface)& aS1) const
132 {
133   Standard_Boolean bRet;
134   GeomAbs_SurfaceType aST, aST1;
135   GeomAdaptor_Surface aGAS1;
136   //
137   aST=myGAS.GetType();
138   aGAS1.Load(aS1);
139   aST1=aGAS1.GetType();
140   bRet=(aST1==aST);
141   //
142   return bRet;
143 }