Salome HOME
Merge from BR_Dev_For_4_0 branch (from tag mergeto_BR_QT4_Dev_17Jan08)
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_StateCollector.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_StateCollector.cxx
21 // Created:     Thu Mar 10 09:42:11 2005
22 // Author:      Peter KURNEV
23 //              <pkv@irinox>
24
25
26 #include <GEOMAlgo_StateCollector.ixx>
27
28 //=======================================================================
29 //function : GEOMAlgo_StateCollector
30 //purpose  : 
31 //=======================================================================
32 GEOMAlgo_StateCollector::GEOMAlgo_StateCollector() 
33 {
34   myCounter[0]=0;
35   myCounter[1]=0;
36   myCounter[2]=0;
37 }
38 //=======================================================================
39 //function : AppendState
40 //purpose  : 
41 //=======================================================================
42 Standard_Boolean GEOMAlgo_StateCollector::AppendState(const TopAbs_State aSt) 
43 {
44   Standard_Boolean bIsToBreak;
45   //
46   switch(aSt) {
47     case TopAbs_IN:
48       ++myCounter[0];
49       break;
50     case TopAbs_OUT:
51       ++myCounter[1];
52       break; 
53     case TopAbs_ON:
54       ++myCounter[2];
55       break;
56     default:
57       break;
58   }
59   bIsToBreak=(myCounter[0] && myCounter[1]);
60   //
61   return bIsToBreak;
62 }
63 //=======================================================================
64 //function : State
65 //purpose  : 
66 //=======================================================================
67 TopAbs_State GEOMAlgo_StateCollector::State()const 
68 {
69   TopAbs_State aSt;
70   //
71   aSt=TopAbs_UNKNOWN;
72   //
73   if (myCounter[0] && myCounter[1]) {
74     return aSt;
75   }
76   //
77   else if (myCounter[0] && myCounter[2]>=0) {
78     aSt=TopAbs_IN;
79   }
80   //
81   else if (myCounter[1] && myCounter[2]>=0) {
82     aSt=TopAbs_OUT;
83   }
84   //
85   else if (!myCounter[0] && !myCounter[1] && myCounter[2]) {
86     aSt=TopAbs_ON;
87   }
88   //
89   return aSt;
90 }