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