Salome HOME
0f566f21865a3555eac7a1a3d60ac8778ac2e59d
[modules/geom.git] / src / NMTTools / NMTTools_PaveFiller_1.cxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File:        NMTTools_PaveFiller_1.cxx
24 // Created:     Mon Dec  8 11:47:55 2003
25 // Author:      Peter KURNEV
26 //              <pkv@irinox>
27 //
28 #include <NMTTools_PaveFiller.hxx>
29
30 #include <TColStd_DataMapOfIntegerListOfInteger.hxx>
31 #include <TColStd_ListOfInteger.hxx>
32 #include <TColStd_ListIteratorOfListOfInteger.hxx>
33 #include <TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
34
35 #include <TopoDS.hxx>
36 #include <TopoDS_Shape.hxx>
37 #include <TopoDS_Vertex.hxx>
38
39 #include <TopTools_ListOfShape.hxx>
40
41 #include <IntTools_Tools.hxx>
42 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
43 #include <BOPTools_VVInterference.hxx>
44 #include <BOPTools_CArray1OfVVInterference.hxx>
45
46 #include <NMTDS_Iterator.hxx>
47 #include <NMTDS_InterfPool.hxx>
48 #include <NMTDS_ShapesDataStructure.hxx>
49
50 #include <NMTTools_Tools.hxx>
51
52 //=======================================================================
53 // function: PerformVV
54 // purpose:
55 //=======================================================================
56   void NMTTools_PaveFiller::PerformVV()
57 {
58   myIsDone=Standard_False;
59   //
60   Standard_Integer aNbVVs, aBL, aNbVSD, nVnew, i, j, n1, n2;
61   TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger aIt1;
62   TColStd_ListIteratorOfListOfInteger aItX, aItY;
63   TColStd_ListOfInteger aLIX;
64   TopTools_ListOfShape aLV;
65   TopoDS_Vertex aVnew;
66   //
67   myVSD.Clear();
68   //
69   const TColStd_DataMapOfIntegerListOfInteger& aMVSD=myDSIt->SDVertices();
70   aNbVSD=aMVSD.Extent();
71   if (!aNbVSD) {
72     return;
73   }
74   //
75   BOPTools_CArray1OfVVInterference& aVVs=myIP->VVInterferences();
76   //
77   // BlockLength correction
78   myDSIt->Initialize(TopAbs_VERTEX, TopAbs_VERTEX);
79   aNbVVs=myDSIt->BlockLength();
80   aBL=aVVs.BlockLength();
81   if (aNbVVs > aBL) {
82     aVVs.SetBlockLength(aNbVVs);
83   }
84   //
85   aIt1.Initialize(aMVSD);
86   for (; aIt1.More(); aIt1.Next()) {
87     aLV.Clear();
88     //
89     n1=aIt1.Key();
90     const TColStd_ListOfInteger& aLIV=aIt1.Value();
91     //
92     // new vertex
93     const TopoDS_Shape& aS1=myDS->Shape(n1);
94     aLV.Append(aS1);
95     aItX.Initialize(aLIV);
96     for (; aItX.More(); aItX.Next()) {
97       n2=aItX.Value();
98       const TopoDS_Shape& aS2=myDS->Shape(n2);
99       aLV.Append(aS2);
100     }
101     //
102     NMTTools_Tools::MakeNewVertex(aLV, aVnew);
103     //
104     BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
105     //
106     myDS->InsertShapeAndAncestorsSuccessors(aVnew, anASSeq);
107     nVnew=myDS->NumberOfInsertedShapes();
108     myDS->SetState (nVnew, BooleanOperations_ON);
109     //
110     // myVSD, aLIX
111     aLIX.Clear();
112     aLIX.Append(n1);
113     myVSD.Bind(n1, nVnew);
114     //
115     aItX.Initialize(aLIV);
116     for (; aItX.More(); aItX.Next()) {
117       n2=aItX.Value();
118       aLIX.Append(n2);
119       myVSD.Bind(n2, nVnew);
120     }
121     //
122     // interferences
123     aItX.Initialize(aLIX);
124     for (i=0; aItX.More(); aItX.Next(), ++i) {
125       aItY.Initialize(aLIX);
126       for (j=0; aItY.More(); aItY.Next(), ++j) {
127         if (j>i) {
128           n1=aItX.Value();
129           n2=aItY.Value();
130           myIP->Add(n1, n2, Standard_True, NMTDS_TI_VV);
131           //
132           BOPTools_VVInterference aVV(n1, n2);
133           aVV.SetNewShape(nVnew);
134           aVVs.Append(aVV);
135         }
136       }
137     }
138   }//for (; aIt1.More(); aIt1.Next()) {
139   myIsDone=Standard_True;
140 }
141 //=======================================================================
142 // function: FindSDVertex
143 // purpose:
144 //=======================================================================
145   Standard_Integer NMTTools_PaveFiller::FindSDVertex(const Standard_Integer nV)const
146 {
147   Standard_Integer nVSD;
148   //
149   nVSD=0;
150   if (myVSD.IsBound(nV)) {
151     nVSD=myVSD.Find(nV);
152   }
153   return nVSD;
154 }
155 /*
156 //=======================================================================
157 // function: PerformNewVertices
158 // purpose:
159 //=======================================================================
160   void NMTTools_PaveFiller::PerformNewVertices()
161 {
162 }
163 */