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