Salome HOME
Additional fix for bug NPAL19028 (see remarks from Olivier Giorgis).
[modules/geom.git] / src / NMTTools / NMTTools_PaveFiller_1.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 <TColStd_DataMapOfIntegerListOfInteger.hxx>
28 #include <TColStd_ListOfInteger.hxx>
29 #include <TColStd_ListIteratorOfListOfInteger.hxx>
30 #include <TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
31
32 #include <TopoDS.hxx>
33 #include <TopoDS_Shape.hxx>
34 #include <TopoDS_Vertex.hxx>
35
36 #include <TopTools_ListOfShape.hxx>
37
38 #include <IntTools_Tools.hxx>
39 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
40 #include <BOPTools_VVInterference.hxx>
41 #include <BOPTools_CArray1OfVVInterference.hxx>
42
43 #include <NMTDS_Iterator.hxx>
44 #include <NMTDS_InterfPool.hxx>
45 #include <NMTDS_ShapesDataStructure.hxx>
46
47 #include <NMTTools_Tools.hxx>
48
49 //=======================================================================
50 // function: PerformVV
51 // purpose: 
52 //=======================================================================
53   void NMTTools_PaveFiller::PerformVV() 
54 {
55   myIsDone=Standard_False;
56   //
57   Standard_Integer aNbVVs, aBL, aNbVSD, nVnew, i, j, n1, n2;
58   TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger aIt1;
59   TColStd_ListIteratorOfListOfInteger aItX, aItY;
60   TColStd_ListOfInteger aLIX;
61   TopTools_ListOfShape aLV;
62   TopoDS_Vertex aVnew;
63   //
64   myVSD.Clear();
65   //
66   const TColStd_DataMapOfIntegerListOfInteger& aMVSD=myDSIt->SDVertices();
67   aNbVSD=aMVSD.Extent();
68   if (!aNbVSD) {
69     return;
70   }
71   //
72   BOPTools_CArray1OfVVInterference& aVVs=myIP->VVInterferences();
73   //
74   // BlockLength correction
75   myDSIt->Initialize(TopAbs_VERTEX, TopAbs_VERTEX);
76   aNbVVs=myDSIt->BlockLength();
77   aBL=aVVs.BlockLength();
78   if (aNbVVs > aBL) {
79     aVVs.SetBlockLength(aNbVVs);
80   }
81   //
82   aIt1.Initialize(aMVSD);
83   for (; aIt1.More(); aIt1.Next()) {
84     aLV.Clear();
85     //
86     n1=aIt1.Key();
87     const TColStd_ListOfInteger& aLIV=aIt1.Value();
88     //
89     // new vertex
90     const TopoDS_Shape& aS1=myDS->Shape(n1);
91     aLV.Append(aS1);
92     aItX.Initialize(aLIV);
93     for (; aItX.More(); aItX.Next()) {
94       n2=aItX.Value();
95       const TopoDS_Shape& aS2=myDS->Shape(n2);
96       aLV.Append(aS2);
97     }
98     //
99     NMTTools_Tools::MakeNewVertex(aLV, aVnew);
100     //
101     BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
102     //
103     myDS->InsertShapeAndAncestorsSuccessors(aVnew, anASSeq);
104     nVnew=myDS->NumberOfInsertedShapes();
105     myDS->SetState (nVnew, BooleanOperations_ON);
106     //
107     // myVSD, aLIX
108     aLIX.Clear();
109     aLIX.Append(n1);
110     myVSD.Bind(n1, nVnew);
111     //
112     aItX.Initialize(aLIV);
113     for (; aItX.More(); aItX.Next()) {
114       n2=aItX.Value();
115       aLIX.Append(n2);
116       myVSD.Bind(n2, nVnew);
117     }
118     //
119     // interferences
120     aItX.Initialize(aLIX);
121     for (i=0; aItX.More(); aItX.Next(), ++i) {
122       aItY.Initialize(aLIX);
123       for (j=0; aItY.More(); aItY.Next(), ++j) {
124         if (j>i) {
125           n1=aItX.Value();
126           n2=aItY.Value();
127           myIP->Add(n1, n2, Standard_True, NMTDS_TI_VV);
128           //
129           BOPTools_VVInterference aVV(n1, n2);
130           aVV.SetNewShape(nVnew);
131           aVVs.Append(aVV);    
132         }
133       }
134     }
135   }//for (; aIt1.More(); aIt1.Next()) {
136   myIsDone=Standard_True;
137 }
138 //=======================================================================
139 // function: FindSDVertex
140 // purpose: 
141 //=======================================================================
142   Standard_Integer NMTTools_PaveFiller::FindSDVertex(const Standard_Integer nV)const
143 {
144   Standard_Integer nVSD;
145   //
146   nVSD=0;
147   if (myVSD.IsBound(nV)) {
148     nVSD=myVSD.Find(nV);
149   }
150   return nVSD;
151 }
152 /*
153 //=======================================================================
154 // function: PerformNewVertices
155 // purpose: 
156 //=======================================================================
157   void NMTTools_PaveFiller::PerformNewVertices() 
158 {
159 }
160 */