4e57c75e |
1 | // Created by: Peter KURNEV |
973c2be1 |
2 | // Copyright (c) 2010-2014 OPEN CASCADE SAS |
4e57c75e |
3 | // Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE |
4 | // Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, |
5 | // EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS |
6 | // |
973c2be1 |
7 | // This file is part of Open CASCADE Technology software library. |
4e57c75e |
8 | // |
973c2be1 |
9 | // This library is free software; you can redistribute it and / or modify it |
10 | // under the terms of the GNU Lesser General Public version 2.1 as published |
11 | // by the Free Software Foundation, with special exception defined in the file |
12 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
13 | // distribution for complete text of the license and disclaimer of any warranty. |
4e57c75e |
14 | // |
973c2be1 |
15 | // Alternatively, this file may be used under the terms of Open CASCADE |
16 | // commercial license or contractual agreement. |
4e57c75e |
17 | |
18 | #include <BOPAlgo_PaveFiller.ixx> |
19 | |
20 | #include <NCollection_IncAllocator.hxx> |
21 | |
22 | #include <TopoDS_Vertex.hxx> |
23 | #include <TopoDS_Face.hxx> |
24 | #include <BRep_Tool.hxx> |
25 | #include <BRep_Builder.hxx> |
26 | #include <BRepBndLib.hxx> |
27 | |
28 | #include <BOPCol_MapOfInteger.hxx> |
29 | |
30 | #include <BOPInt_Context.hxx> |
31 | |
32 | #include <BOPDS_Iterator.hxx> |
33 | #include <BOPDS_VectorOfInterfVF.hxx> |
34 | #include <BOPDS_Interf.hxx> |
35 | #include <BOPDS_SubIterator.hxx> |
36 | #include <BOPDS_MapOfPaveBlock.hxx> |
37 | #include <BOPDS_FaceInfo.hxx> |
38 | #include <BOPCol_MapOfInteger.hxx> |
39 | |
40 | //======================================================================= |
41 | // function: PerformVF |
42 | // purpose: |
43 | //======================================================================= |
44 | void BOPAlgo_PaveFiller::PerformVF() |
45 | { |
46 | Standard_Boolean bJustAdd; |
47 | Standard_Integer iSize, nV, nF, nVSD, iFlag, nVx, i; |
48 | Standard_Real aT1, aT2, aTolF, aTolV; |
49 | BRep_Builder aBB; |
50 | // |
51 | myErrorStatus=0; |
52 | // |
53 | myIterator->Initialize(TopAbs_VERTEX, TopAbs_FACE); |
54 | iSize=myIterator->ExpectedLength(); |
55 | if (iSize) { |
56 | // |
57 | BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF(); |
58 | aVFs.SetStartSize(iSize); |
59 | aVFs.SetIncrement(iSize); |
60 | aVFs.Init(); |
61 | // |
62 | for (; myIterator->More(); myIterator->Next()) { |
63 | myIterator->Value(nV, nF, bJustAdd); |
64 | if(bJustAdd) { |
65 | continue; |
66 | } |
67 | // |
68 | if (myDS->IsSubShape(nV, nF)) { |
69 | continue; |
70 | } |
71 | // |
72 | if (myDS->HasInterfShapeSubShapes(nV, nF)) { |
c1746a0a |
73 | myDS->ChangeFaceInfo(nF); |
4e57c75e |
74 | continue; |
75 | } |
76 | // |
77 | nVx=nV; |
78 | if (myDS->HasShapeSD(nV, nVSD)) { |
79 | nVx=nVSD; |
80 | } |
81 | // |
82 | if (myDS->HasInterf(nVx, nF)) { |
83 | continue; |
84 | } |
85 | // |
86 | const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nVx))); |
87 | const TopoDS_Face& aF=(*(TopoDS_Face *)(&myDS->Shape(nF))); |
88 | // |
89 | aTolV = BRep_Tool::Tolerance(aV); |
90 | aTolF = BRep_Tool::Tolerance(aF); |
91 | // |
92 | iFlag=myContext->ComputeVF(aV, aF, aT1, aT2); |
93 | if (!iFlag) { |
94 | // 1 |
95 | i=aVFs.Append()-1; |
96 | BOPDS_InterfVF& aVF=aVFs(i); |
97 | aVF.SetIndices(nVx, nF); |
98 | aVF.SetUV(aT1, aT2); |
99 | // 2 |
100 | myDS->AddInterf(nVx, nF); |
c1746a0a |
101 | // |
102 | BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF); |
103 | BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn(); |
104 | aMVIn.Add(nVx); |
105 | // |
4e57c75e |
106 | if (aTolV < aTolF) { |
107 | aBB.UpdateVertex(aV, aTolF); |
108 | BOPDS_ShapeInfo& aSIV = myDS->ChangeShapeInfo(nVx); |
109 | Bnd_Box& aBoxV = aSIV.ChangeBox(); |
110 | BRepBndLib::Add(aV, aBoxV); |
111 | } |
112 | } |
113 | }// for (; myIterator->More(); myIterator->Next()) { |
114 | }// if (iSize) { |
115 | else { |
116 | iSize=10; |
117 | BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF(); |
118 | aVFs.SetStartSize(iSize); |
119 | aVFs.SetIncrement(iSize); |
120 | aVFs.Init(); |
121 | } |
c1746a0a |
122 | // |
4e57c75e |
123 | TreatVerticesEE(); |
124 | } |
125 | |
126 | |
127 | //======================================================================= |
128 | //function : TreatVerticesEE |
129 | //purpose : |
130 | //======================================================================= |
131 | void BOPAlgo_PaveFiller::TreatVerticesEE() |
132 | { |
133 | Standard_Integer i, aNbS, aNbEEs, nF, nV, iFlag; |
134 | Standard_Real aT1, aT2; |
135 | BOPCol_ListIteratorOfListOfInteger aItLI; |
136 | Handle(NCollection_IncAllocator) aAllocator; |
137 | // |
138 | //-----------------------------------------------------scope_1 f |
139 | aAllocator=new NCollection_IncAllocator(); |
140 | BOPCol_ListOfInteger aLIV(aAllocator), aLIF(aAllocator); |
141 | BOPCol_MapOfInteger aMI(100, aAllocator); |
142 | BOPDS_MapOfPaveBlock aMPBF(100, aAllocator); |
143 | // |
144 | myErrorStatus=0; |
145 | // |
146 | |
147 | aNbS=myDS->NbSourceShapes(); |
148 | // |
149 | BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE(); |
150 | aNbEEs=aEEs.Extent(); |
151 | for (i=0; i<aNbEEs; ++i) { |
152 | BOPDS_InterfEE& aEE=aEEs(i); |
153 | if (aEE.HasIndexNew()) { |
154 | nV=aEE.IndexNew(); |
155 | if (aMI.Add(nV)) { |
156 | aLIV.Append(nV); |
157 | } |
158 | } |
159 | } |
160 | if (!aLIV.Extent()) { |
161 | aAllocator.Nullify(); |
162 | return; |
163 | } |
164 | // |
165 | aNbS=myDS->NbSourceShapes(); |
166 | for (nF=0; nF<aNbS; ++nF) { |
167 | const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(nF); |
168 | if (aSI.ShapeType()==TopAbs_FACE) { |
169 | aLIF.Append(nF); |
170 | } |
171 | } |
172 | if (!aLIF.Extent()) { |
173 | aAllocator.Nullify(); |
174 | return; |
175 | } |
176 | //------------------------------------------------------------- |
177 | BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF(); |
178 | // |
179 | BOPDS_SubIterator aIt(aAllocator); |
180 | // |
181 | aIt.SetDS(myDS); |
182 | aIt.SetSubSet1(aLIF); |
183 | aIt.SetSubSet2(aLIV); |
184 | aIt.Prepare(); |
185 | aIt.Initialize(); |
186 | for (; aIt.More(); aIt.Next()) { |
187 | aIt.Value(nV, nF); |
188 | // |
189 | BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF); |
190 | const BOPCol_MapOfInteger& aMVOn=aFI.VerticesOn(); |
191 | // |
192 | if (!aMVOn.Contains(nV)) { |
193 | const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nV))); |
194 | const TopoDS_Face& aF=(*(TopoDS_Face *)(&myDS->Shape(nF))); |
195 | iFlag=myContext->ComputeVF(aV, aF, aT1, aT2); |
196 | if (!iFlag) { |
197 | // 1 |
198 | i=aVFs.Append()-1; |
199 | BOPDS_InterfVF& aVF=aVFs(i); |
200 | aVF.SetIndices(nV, nF); |
201 | aVF.SetUV(aT1, aT2); |
202 | // 2 |
203 | myDS->AddInterf(nV, nF); |
204 | // |
205 | BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn(); |
206 | aMVIn.Add(nV); |
207 | } |
208 | } |
209 | } |
210 | // |
211 | aAllocator.Nullify(); |
212 | //-----------------------------------------------------scope_1 t |
213 | } |