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