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