1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: NMTTools_PaveFiller_1.cxx
21 // Created: Mon Dec 8 11:47:55 2003
22 // Author: Peter KURNEV
26 #include <NMTTools_PaveFiller.ixx>
28 #include <TColStd_IndexedMapOfInteger.hxx>
31 #include <TopoDS_Shape.hxx>
32 #include <TopoDS_Vertex.hxx>
34 #include <TopTools_ListOfShape.hxx>
36 #include <IntTools_Tools.hxx>
37 #include <BOPTools_VVInterference.hxx>
38 #include <BOPTools_CArray1OfVVInterference.hxx>
39 #include <BOPTools_VVInterference.hxx>
40 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
41 #include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
43 #include <NMTDS_ShapesDataStructure.hxx>
44 #include <NMTTools_Tools.hxx>
45 #include <TopTools_IndexedMapOfShape.hxx>
49 //=======================================================================
50 // function: PerformVV
52 //=======================================================================
53 void NMTTools_PaveFiller::PerformVV()
55 myIsDone=Standard_False;
57 Standard_Integer n1, n2,anIndexIn, aFlag, aWhat, aWith, aNbVVs, aBlockLength;
58 Standard_Boolean bJustAddInterference;
60 BOPTools_CArray1OfVVInterference& aVVs=myIntrPool->VVInterferences();
62 // BlockLength correction
63 aNbVVs=ExpectedPoolLength();
64 aBlockLength=aVVs.BlockLength();
65 if (aNbVVs > aBlockLength) {
66 aVVs.SetBlockLength(aNbVVs);
69 // V/V BooleanOperations_VertexVertex
70 myDSIt.Initialize(TopAbs_VERTEX, TopAbs_VERTEX);
72 for (; myDSIt.More(); myDSIt.Next()) {
73 myDSIt.Current(n1, n2, bJustAddInterference);
75 if (!myIntrPool->IsComputed(n1, n2)) {
79 SortTypes(aWhat, aWith);
80 if (!bJustAddInterference) {
81 const TopoDS_Shape& aS1=myDS->GetShape(aWhat);
82 const TopoDS_Shape& aS2=myDS->GetShape(aWith);
84 const TopoDS_Vertex& aV1=TopoDS::Vertex(aS1);
85 const TopoDS_Vertex& aV2=TopoDS::Vertex(aS2);
86 aFlag=IntTools_Tools::ComputeVV (aV1, aV2);
89 BOPTools_VVInterference anInterf (aWhat, aWith);
90 anIndexIn=aVVs.Append(anInterf);
93 myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexVertex, anIndexIn);
96 myIsDone=Standard_True;
98 //=======================================================================
99 // function: PerformNewVertices
101 //=======================================================================
102 void NMTTools_PaveFiller::PerformNewVertices()
104 myIsDone=Standard_False;
106 Standard_Integer i, aNb, anIndex1, anIndex2, aNewShape;
107 TopoDS_Vertex aNewVertex;
108 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
110 Standard_Integer aNbChains, j, aNbV, aIdV, aNbL;
111 TColStd_IndexedMapOfInteger aMapWhole;
112 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMapChains;//aMCV
113 TopTools_ListOfShape aLV;
114 TopTools_IndexedMapOfShape aM;
116 // 1. VV Interferences
117 BOPTools_CArray1OfVVInterference& VVs=myIntrPool->VVInterferences();
119 NMTTools_Tools::FindChains(VVs, aMapChains);
121 aNbChains=aMapChains.Extent();
122 for (i=1; i<=aNbChains; ++i) {
123 const TColStd_IndexedMapOfInteger& aChain=aMapChains(i);
127 aNbV=aChain.Extent();
128 for (j=1; j<=aNbV; ++j) {
130 const TopoDS_Shape& aV=myDS->Shape(aIdV);
131 if (!aM.Contains(aV)) {
144 NMTTools_Tools::MakeNewVertex(aLV, aNewVertex);
145 // Insert New Vertex in DS;
146 // aNewShape is # of DS-line, where aNewVertex is kept
147 myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
148 aNewShape=myDS->NumberOfInsertedShapes();
150 // State of New Vertex is ON
151 myDS->SetState (aNewShape, BooleanOperations_ON);
154 // Insert New Vertex in Interference
156 for (j=1; j<=aNb; ++j) {
157 BOPTools_VVInterference& VV=VVs(j);
158 anIndex1=VV.Index1();
159 anIndex2=VV.Index2();
160 if (aChain.Contains(anIndex1) || aChain.Contains(anIndex2)) {
161 VV.SetNewShape(aNewShape);
165 myIsDone=Standard_True;
168 //=======================================================================
169 // function: FindSDVertex
171 //=======================================================================
172 Standard_Integer NMTTools_PaveFiller::FindSDVertex(const Standard_Integer nV)const
174 Standard_Integer i, aNb, anIndex1, anIndex2, aNewShape=0;
176 BOPTools_CArray1OfVVInterference& VVs=myIntrPool->VVInterferences();
179 for (i=1; i<=aNb; i++) {
180 const BOPTools_VVInterference& VV=VVs(i);
181 anIndex1=VV.Index1();
182 anIndex2=VV.Index2();
183 if (nV==anIndex1 || nV==anIndex2) {
184 aNewShape=VV.NewShape();