Salome HOME
Copyright update 2022
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_ClsfSurf.cxx
1 // Copyright (C) 2007-2022  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_RTTIEXT(GEOMAlgo_ClsfSurf, GEOMAlgo_Clsf)
36
37 //=======================================================================
38 //function :
39 //purpose  :
40 //=======================================================================
41   GEOMAlgo_ClsfSurf::GEOMAlgo_ClsfSurf()
42 :
43   GEOMAlgo_Clsf()
44 {
45 }
46 //=======================================================================
47 //function : ~
48 //purpose  :
49 //=======================================================================
50   GEOMAlgo_ClsfSurf::~GEOMAlgo_ClsfSurf()
51 {
52 }
53 //=======================================================================
54 //function : SetSurface
55 //purpose  :
56 //=======================================================================
57   void GEOMAlgo_ClsfSurf::SetSurface(const Handle(Geom_Surface)& aS)
58 {
59   myS=aS;
60 }
61 //=======================================================================
62 //function : Surface
63 //purpose  :
64 //=======================================================================
65   const Handle(Geom_Surface)& GEOMAlgo_ClsfSurf::Surface() const
66 {
67   return myS;
68 }
69 //=======================================================================
70 //function : CheckData
71 //purpose  :
72 //=======================================================================
73   void GEOMAlgo_ClsfSurf::CheckData()
74 {
75   GeomAbs_SurfaceType aType;
76   //
77   myErrorStatus=0;
78   //
79   if(myS.IsNull()) {
80     myErrorStatus=10; // mySurface=NULL
81     return;
82   }
83   //
84   myGAS.Load(myS);
85   aType=myGAS.GetType();
86   if (!(aType==GeomAbs_Plane ||
87         aType==GeomAbs_Cylinder ||
88         aType==GeomAbs_Sphere)) {
89     myErrorStatus=11; // unallowed surface type
90   }
91 }
92 //=======================================================================
93 //function : Perform
94 //purpose  :
95 //=======================================================================
96   void GEOMAlgo_ClsfSurf::Perform()
97 {
98   myErrorStatus=0;
99   /*
100   CheckData();
101   if(myErrorStatus) {
102     return;
103   }
104   */
105   GEOMAlgo_SurfaceTools::GetState(myPnt, myGAS, myTolerance, myState);
106 }
107 //=======================================================================
108 //function : CanBeON
109 //purpose  :
110 //=======================================================================
111   Standard_Boolean GEOMAlgo_ClsfSurf::CanBeON(const Handle(Geom_Curve)& aC) const
112 {
113   GeomAbs_SurfaceType aST;
114   GeomAbs_CurveType aCT;
115   GeomAdaptor_Curve aGAC;
116   //
117   aGAC.Load(aC);
118   aCT=aGAC.GetType();
119   //
120   aST=myGAS.GetType();
121   if (aCT==GeomAbs_Line && aST==GeomAbs_Sphere) {
122     return Standard_False;
123   }
124   return Standard_True;
125 }
126 //=======================================================================
127 //function : CanBeON
128 //purpose  :
129 //=======================================================================
130   Standard_Boolean GEOMAlgo_ClsfSurf::CanBeON(const Handle(Geom_Surface)& aS1) const
131 {
132   Standard_Boolean bRet;
133   GeomAbs_SurfaceType aST, aST1;
134   GeomAdaptor_Surface aGAS1;
135   //
136   aST=myGAS.GetType();
137   aGAS1.Load(aS1);
138   aST1=aGAS1.GetType();
139   bRet=(aST1==aST);
140   //
141   return bRet;
142 }