Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/geom.git] / src / NMTTools / NMTTools_PaveFiller_0.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:        NMTTools_PaveFiller_0.cxx
21 // Created:     Mon Dec  8 11:45:51 2003
22 // Author:      Peter KURNEV
23 //              <pkv@irinox>
24
25
26 #include <NMTTools_PaveFiller.ixx>
27
28 #include <TopAbs_ShapeEnum.hxx>
29 #include <BOPTools_ListOfCoupleOfInteger.hxx>
30 #include <NMTDS_ShapesDataStructure.hxx>
31 #include <BooleanOperations_OnceExplorer.hxx>
32
33 //=======================================================================
34 //function : SortTypes
35 //purpose  : 
36 //=======================================================================
37   void NMTTools_PaveFiller::SortTypes(Standard_Integer& theWhat,
38                                       Standard_Integer& theWith)const 
39
40   Standard_Boolean aReverseFlag=Standard_True;
41
42   TopAbs_ShapeEnum aType1= myDS->GetShapeType(theWhat),
43                    aType2= myDS->GetShapeType(theWith);
44   
45   if (aType1==aType2)
46     return;
47   
48   if (aType1==TopAbs_EDGE && aType2==TopAbs_FACE){
49     aReverseFlag=Standard_False;
50   }
51
52   if (aType1==TopAbs_VERTEX && 
53       (aType2==TopAbs_FACE || aType2==TopAbs_EDGE)) {
54     aReverseFlag=Standard_False;
55   }
56   
57   Standard_Integer aWhat, aWith;
58   aWhat=(aReverseFlag) ? theWith : theWhat;
59   aWith=(aReverseFlag) ? theWhat : theWith;
60   
61   theWhat=aWhat;
62   theWith=aWith;
63 }
64 //=======================================================================
65 // function:  ExpectedPoolLength
66 // purpose: 
67 //=======================================================================
68   Standard_Integer NMTTools_PaveFiller::ExpectedPoolLength()const
69 {
70   Standard_Integer aNbIIs;
71   Standard_Real aCfPredict=.5;
72
73   const BOPTools_ListOfCoupleOfInteger& aLC=myDSIt.ListOfCouple();
74   aNbIIs=aLC.Extent();
75   //
76   if (aNbIIs==1) {
77     return aNbIIs;
78   }
79   //
80   aNbIIs=(Standard_Integer) (aCfPredict*(Standard_Real)aNbIIs);
81   
82   return aNbIIs;
83 }
84 //=======================================================================
85 // function:IsSuccesstorsComputed
86 // purpose: 
87 //=======================================================================
88   Standard_Boolean NMTTools_PaveFiller::IsSuccesstorsComputed(const Standard_Integer aN1,
89                                                               const Standard_Integer aN2)const
90 {
91   Standard_Integer nSuc, n1, n2;
92
93   BooleanOperations_OnceExplorer aExp(*myDS);
94   TopAbs_ShapeEnum aType=myDS->GetShapeType(aN1);
95
96   n1=aN1;
97   n2=aN2;
98
99   if (aType!=TopAbs_VERTEX) {
100     Standard_Integer ntmp=n1;
101     n1=n2;
102     n2=ntmp;
103   }
104
105   aType=myDS->GetShapeType(n2);
106   if (aType==TopAbs_EDGE) {
107     aExp.Init(n2, TopAbs_VERTEX);
108     for (; aExp.More(); aExp.Next()) {
109       nSuc=aExp.Current();
110       if (myIntrPool->IsComputed(n1, nSuc)) {
111         return Standard_True;
112       }
113     }
114   return Standard_False;
115   }
116
117   else if (aType==TopAbs_FACE) {
118     aExp.Init(n2, TopAbs_VERTEX);
119     for (; aExp.More(); aExp.Next()) {
120       nSuc=aExp.Current();
121       if (myIntrPool->IsComputed(n1, nSuc)) {
122         return Standard_True;
123       }
124     }
125
126     aExp.Init(n2, TopAbs_EDGE);
127     for (; aExp.More(); aExp.Next()) {
128       nSuc=aExp.Current();
129       if (myIntrPool->IsComputed(n1, nSuc)) {
130         return Standard_True;
131       }
132     }
133     return Standard_False;
134   }
135
136   return Standard_False;
137 }