Salome HOME
d6b3251a35c051885bd81e43d1ab6e10f79a3807
[modules/geom.git] / NMTTools_PaveFiller_0.cxx
1 // File:        NMTTools_PaveFiller_0.cxx
2 // Created:     Mon Dec  8 11:45:51 2003
3 // Author:      Peter KURNEV
4 //              <pkv@irinox>
5
6
7 #include <NMTTools_PaveFiller.ixx>
8
9 #include <TopAbs_ShapeEnum.hxx>
10 #include <BOPTools_ListOfCoupleOfInteger.hxx>
11 #include <NMTDS_ShapesDataStructure.hxx>
12 #include <BooleanOperations_OnceExplorer.hxx>
13
14 //=======================================================================
15 //function : SortTypes
16 //purpose  : 
17 //=======================================================================
18   void NMTTools_PaveFiller::SortTypes(Standard_Integer& theWhat,
19                                       Standard_Integer& theWith)const 
20
21   Standard_Boolean aReverseFlag=Standard_True;
22
23   TopAbs_ShapeEnum aType1= myDS->GetShapeType(theWhat),
24                    aType2= myDS->GetShapeType(theWith);
25   
26   if (aType1==aType2)
27     return;
28   
29   if (aType1==TopAbs_EDGE && aType2==TopAbs_FACE){
30     aReverseFlag=Standard_False;
31   }
32
33   if (aType1==TopAbs_VERTEX && 
34       (aType2==TopAbs_FACE || aType2==TopAbs_EDGE)) {
35     aReverseFlag=Standard_False;
36   }
37   
38   Standard_Integer aWhat, aWith;
39   aWhat=(aReverseFlag) ? theWith : theWhat;
40   aWith=(aReverseFlag) ? theWhat : theWith;
41   
42   theWhat=aWhat;
43   theWith=aWith;
44 }
45 //=======================================================================
46 // function:  ExpectedPoolLength
47 // purpose: 
48 //=======================================================================
49   Standard_Integer NMTTools_PaveFiller::ExpectedPoolLength()const
50 {
51   Standard_Integer aNbIIs;
52   Standard_Real aCfPredict=.5;
53
54   const BOPTools_ListOfCoupleOfInteger& aLC=myDSIt.ListOfCouple();
55   aNbIIs=aLC.Extent();
56   //
57   if (aNbIIs==1) {
58     return aNbIIs;
59   }
60   //
61   aNbIIs=(Standard_Integer) (aCfPredict*(Standard_Real)aNbIIs);
62   
63   return aNbIIs;
64 }
65 //=======================================================================
66 // function:IsSuccesstorsComputed
67 // purpose: 
68 //=======================================================================
69   Standard_Boolean NMTTools_PaveFiller::IsSuccesstorsComputed(const Standard_Integer aN1,
70                                                               const Standard_Integer aN2)const
71 {
72   Standard_Integer nSuc, n1, n2;
73
74   BooleanOperations_OnceExplorer aExp(*myDS);
75   TopAbs_ShapeEnum aType=myDS->GetShapeType(aN1);
76
77   n1=aN1;
78   n2=aN2;
79
80   if (aType!=TopAbs_VERTEX) {
81     Standard_Integer ntmp=n1;
82     n1=n2;
83     n2=ntmp;
84   }
85
86   aType=myDS->GetShapeType(n2);
87   if (aType==TopAbs_EDGE) {
88     aExp.Init(n2, TopAbs_VERTEX);
89     for (; aExp.More(); aExp.Next()) {
90       nSuc=aExp.Current();
91       if (myIntrPool->IsComputed(n1, nSuc)) {
92         return Standard_True;
93       }
94     }
95   return Standard_False;
96   }
97
98   else if (aType==TopAbs_FACE) {
99     aExp.Init(n2, TopAbs_VERTEX);
100     for (; aExp.More(); aExp.Next()) {
101       nSuc=aExp.Current();
102       if (myIntrPool->IsComputed(n1, nSuc)) {
103         return Standard_True;
104       }
105     }
106
107     aExp.Init(n2, TopAbs_EDGE);
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   return Standard_False;
118 }