Salome HOME
NPAL15216: EDF379: Issue with IGS files import. A fix on Partition algorithm by PKV.
[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 #include <NMTTools_PaveFiller.ixx>
25
26 #include <TColStd_DataMapOfIntegerListOfInteger.hxx>
27 #include <TColStd_ListOfInteger.hxx>
28 #include <TColStd_ListIteratorOfListOfInteger.hxx>
29 #include <TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
30   
31 #include <TopoDS.hxx>
32 #include <TopoDS_Shape.hxx>
33 #include <TopoDS_Vertex.hxx>
34
35 #include <TopTools_ListOfShape.hxx>
36
37 #include <IntTools_Tools.hxx>
38 #include <BOPTools_VVInterference.hxx>
39 #include <BOPTools_CArray1OfVVInterference.hxx>
40 #include <BOPTools_VVInterference.hxx>
41 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
42
43 #include <NMTDS_ShapesDataStructure.hxx>
44 #include <NMTTools_Tools.hxx>
45
46 //=======================================================================
47 // function: PerformVV
48 // purpose: 
49 //=======================================================================
50   void NMTTools_PaveFiller::PerformVV() 
51 {
52   myIsDone=Standard_False;
53   //
54   Standard_Integer anIndexIn, aWhat, aWith, aNbVVs, aBlockLength, aNbVSD; 
55   Standard_Integer nVnew;
56   TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger aIt1;
57   TColStd_ListIteratorOfListOfInteger aIt;
58   TopTools_ListOfShape aLV;
59   TopoDS_Vertex aVnew;
60   TopoDS_Shape aS;
61   //
62   myVSD.Clear();
63   //
64   BOPTools_CArray1OfVVInterference& aVVs=myIntrPool->VVInterferences();
65   //
66   // BlockLength correction
67   aNbVVs=ExpectedPoolLength();
68   aBlockLength=aVVs.BlockLength();
69   if (aNbVVs > aBlockLength) {
70     aVVs.SetBlockLength(aNbVVs);
71   }
72   //
73   const TColStd_DataMapOfIntegerListOfInteger& aMVSD=myDSIt.SDVertices();
74   aNbVSD=aMVSD.Extent();
75   if (!aNbVSD) {
76     return;
77   }
78   //
79   aIt1.Initialize(aMVSD);
80   for (; aIt1.More(); aIt1.Next()) {
81     aLV.Clear();
82     //
83     aWhat=aIt1.Key();
84     const TColStd_ListOfInteger& aLIV=aIt1.Value();
85     //
86     // new vertex
87     aIt.Initialize(aLIV);
88     for (; aIt.More(); aIt.Next()) {
89       aWith=aIt.Value();
90       aS=myDS->Shape(aWith);
91       aLV.Append(aS);
92     }
93     aS=myDS->Shape(aWhat);
94     aLV.Append(aS);
95     //
96     NMTTools_Tools::MakeNewVertex(aLV, aVnew);
97     //
98     BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
99     //
100     myDS->InsertShapeAndAncestorsSuccessors(aVnew, anASSeq);
101     nVnew=myDS->NumberOfInsertedShapes();
102     myDS->SetState (nVnew, BooleanOperations_ON);
103     //
104     // interferences
105     aIt.Initialize(aLIV);
106     for (; aIt.More(); aIt.Next()) {
107       aWith=aIt.Value();
108       BOPTools_VVInterference aVV(aWhat, aWith);
109       aVV.SetNewShape(nVnew);
110       anIndexIn=aVVs.Append(aVV);
111       myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexVertex, anIndexIn);
112       //
113       // to find SD-Vertices
114       myVSD.Bind(aWith, nVnew);
115     }
116      myVSD.Bind(aWhat, nVnew);
117   }//for (; aIt1.More(); aIt1.Next()) {
118   myIsDone=Standard_True;
119 }
120 //=======================================================================
121 // function: PerformNewVertices
122 // purpose: 
123 //=======================================================================
124   void NMTTools_PaveFiller::PerformNewVertices() 
125 {
126 }
127 //=======================================================================
128 // function: FindSDVertex
129 // purpose: 
130 //=======================================================================
131   Standard_Integer NMTTools_PaveFiller::FindSDVertex(const Standard_Integer nV)const
132 {
133   Standard_Integer nVSD;
134   //
135   nVSD=0;
136   if (myVSD.IsBound(nV)) {
137     nVSD=myVSD.Find(nV);
138   }
139   return nVSD;
140 }