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