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