1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
|
// File: BOP_ShellShell.cxx
// Created: Mon Oct 29 11:31:31 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOP_ShellShell.ixx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Compound.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <TopAbs_Orientation.hxx>
#include <TopExp_Explorer.hxx>
#include <TopExp.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <BOPTColStd_Dump.hxx>
#include <BooleanOperations_ShapesDataStructure.hxx>
#include <BooleanOperations_StateOfShape.hxx>
#include <BOPTools_PaveFiller.hxx>
#include <BOPTools_InterferencePool.hxx>
#include <BOPTools_CArray1OfSSInterference.hxx>
#include <BOPTools_CArray1OfInterferenceLine.hxx>
#include <BOPTools_InterferenceLine.hxx>
#include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
#include <BOPTools_SSInterference.hxx>
#include <BOP_WireEdgeSet.hxx>
#include <BOP_SDFWESFiller.hxx>
#include <BOP_FaceBuilder.hxx>
#include <BOP_Draw.hxx>
#include <BOP_CorrectTolerances.hxx>
#include <BOP_BuilderTools.hxx>
#include <BOP_Refiner.hxx>
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx>
//=======================================================================
// function: BOP_ShellShell::BOP_ShellShell
// purpose:
//=======================================================================
BOP_ShellShell::BOP_ShellShell()
{
}
//=======================================================================
// function: Destroy
// purpose:
//=======================================================================
void BOP_ShellShell::Destroy() {}
//=======================================================================
// function: DoWithFiller
// purpose:
//=======================================================================
void BOP_ShellShell::DoWithFiller(const BOPTools_DSFiller& aDSFiller)
{
myErrorStatus=0;
myIsDone=Standard_False;
//
myResultMap.Clear();
myModifiedMap.Clear();
//
myDSFiller=(BOPTools_DSFiller*) &aDSFiller;
//
try {
OCC_CATCH_SIGNALS
// modified by NIZHNY-MKK Fri Sep 3 15:14:17 2004.BEGIN
if(!myDSFiller->IsDone()) {
myErrorStatus = 1;
BOPTColStd_Dump::PrintMessage("DSFiller is invalid: Can not build result\n");
return;
}
// modified by NIZHNY-MKK Fri Sep 3 15:14:20 2004.END
Standard_Boolean bIsNewFiller;
bIsNewFiller=aDSFiller.IsNewFiller();
if (bIsNewFiller) {
Prepare();
aDSFiller.SetNewFiller(!bIsNewFiller);
}
//
DoNewFaces();
//
BuildResult();
//
// Treat of internals
CollectInternals();
BOP_Refiner aRefiner;
aRefiner.SetShape(myResult);
aRefiner.SetInternals(myInternals);
aRefiner.Do();
//
BOP_CorrectTolerances::CorrectTolerances(myResult, 0.01);
//
FillModified();
myIsDone=Standard_True;
}
catch ( Standard_Failure ) {
myErrorStatus = 1;
BOPTColStd_Dump::PrintMessage("Can not build result\n");
}
}
//=================================================================================
// function: BuildResult
// purpose:
//=================================================================================
void BOP_ShellShell::BuildResult()
{
const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS();
Standard_Integer i, j, aNb, iRank, aNbFaces;
BooleanOperations_StateOfShape aState, aStateToCompare;
BRep_Builder aBB;
TopoDS_Compound aFCompound, aRes;
//
Standard_Boolean bHasInterference;
BOPTools_InterferencePool* pInterfPool=
(BOPTools_InterferencePool*) &myDSFiller->InterfPool();
BOPTools_CArray1OfInterferenceLine* pTable=
(BOPTools_CArray1OfInterferenceLine*) &pInterfPool->InterferenceTable();
//
aBB.MakeCompound(aRes);
//
// 1. Make aCompound containing all faces for thr Result
aBB.MakeCompound(aFCompound);
//
// 1.1. Old Faces with right 3D-state
aNb=aDS.NumberOfSourceShapes();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aS=aDS.Shape(i);
if (aS.ShapeType()==TopAbs_FACE){
//
BOPTools_InterferenceLine& anInterfLine=pTable->ChangeValue(i);
bHasInterference=anInterfLine.HasInterference();
if (bHasInterference) {
continue;
}
//
aState=aDS.GetState(i);
if (aState==BooleanOperations_IN ||
aState==BooleanOperations_OUT) {
iRank=aDS.Rank(i);
aStateToCompare=BOP_BuilderTools::StateToCompare(iRank, myOperation);
if (aState==aStateToCompare) {
aBB.Add(aFCompound, aS);
}
}
}
}
//
// 1.2. aListOfNewFaces
TopTools_ListIteratorOfListOfShape anIt(myNewFaces);
for(; anIt.More(); anIt.Next()) {
aBB.Add(aFCompound, anIt.Value());
}
//
// 2.
TopTools_IndexedDataMapOfShapeListOfShape aEFMap;
TopTools_IndexedMapOfShape aProcessedEdges;
TopExp::MapShapesAndAncestors(aFCompound, TopAbs_EDGE, TopAbs_FACE, aEFMap);
aNb=aEFMap.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Shape& aE=aEFMap.FindKey(i);
TopTools_IndexedMapOfShape aFaces;
Path (aE, aEFMap, aFaces, aProcessedEdges);
TopoDS_Shell aShell, aShellNew;
aBB.MakeShell(aShell);
aNbFaces=aFaces.Extent();
if (aNbFaces) {
for (j=1; j<=aNbFaces; j++) {
const TopoDS_Shape& aF=aFaces(j);
aBB.Add(aShell, aF);
}
OrientFacesOnShell(aShell, aShellNew);
aBB.Add(aRes, aShellNew);
}
}
myResult=aRes;
}
//=======================================================================
// function: DoNewFaces
// purpose:
//=======================================================================
void BOP_ShellShell::DoNewFaces()
{
const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS();
BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool();
BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences();
//
// vars
Standard_Boolean bIsTouchCase, bIsTouch;
Standard_Integer i, aNb, j, aNbj, iFF, nF1;
TopTools_ListOfShape aListOfNewFaces;
TopTools_IndexedMapOfShape anEMap;
TopAbs_Orientation anOriF1;
//
// DoMap
BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aFFMap;
BOP_BuilderTools::DoMap(aFFs, aFFMap);
//
aNb=aFFMap.Extent();
//
for (i=1; i<=aNb; i++) {
//
// a. Prepare info about the Face nF1 and create WES for nF1
nF1=aFFMap.FindKey(i);
const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1));
anOriF1=aF1.Orientation();
myFace=aF1;
myFace.Orientation(TopAbs_FORWARD);
BOP_WireEdgeSet aWES (myFace);
const TColStd_IndexedMapOfInteger& aFFIndicesMap=aFFMap.FindFromIndex(i);
aNbj=aFFIndicesMap.Extent();
//
// b. The Switch: Same Domain Faces or Non-Same Domain Faces
bIsTouchCase=Standard_False;
for (j=1; j<=aNbj; j++) {
iFF=aFFIndicesMap(j);
BOPTools_SSInterference& aFF=aFFs(iFF);
bIsTouchCase=aFF.IsTangentFaces();
if (bIsTouchCase) {
break;
}
}
//
// c. Filling the WES for nF1
if (bIsTouchCase) {
// 1. Add Split Parts having states in accordance with operation
AddSplitPartsINOUT (nF1, aWES);
// 2. Add Section Edges to the WES
for (j=1; j<=aNbj; j++) {
iFF=aFFIndicesMap(j);
BOPTools_SSInterference& aFF=aFFs(iFF);
bIsTouch=aFF.IsTangentFaces();
if (!bIsTouch) {
AddSectionPartsSh(nF1, iFF, aWES);
}
}
// 3. Add IN2D, ON2D Parts to the WES
for (j=1; j<=aNbj; j++) {
iFF=aFFIndicesMap(j);
BOPTools_SSInterference& aFF=aFFs(iFF);
bIsTouch=aFF.IsTangentFaces();
if (bIsTouch) {
AddINON2DPartsSh(nF1, iFF, aWES);
}
}
// 4. Add EF parts (E (from F2) on F1 ),
// where F2 is non-same-domain face to F1
anEMap.Clear();
//
// anEMap will contain all Split parts that has already in aWES
const TopTools_ListOfShape& aLE=aWES.StartElements();
Standard_Integer aNbEdges1 = aLE.Extent();
TopTools_ListIteratorOfListOfShape anIt;
anIt.Initialize (aLE);
for (; anIt.More(); anIt.Next()) {
TopoDS_Shape& anE=anIt.Value();
anEMap.Add(anE);
}
//
// IFV's workaround for occ13538:
// It is necessary to avoid building SD faces twice in case if SD faces of object and tool
// fully coincide and face of object has adjacent faces along all boundaries.
// For such cases WES for second SD faces are built from EE edges.
// The sence of workarond is to find such situation by checking of number of EF edges.
// If number of EF edges == 0, it means that SD faces fully coincide.
Standard_Integer aNbEF;
for (j=1; j<=aNbj; j++) {
iFF=aFFIndicesMap(j);
BOPTools_SSInterference& aFF=aFFs(iFF);
bIsTouch=aFF.IsTangentFaces();
if (!bIsTouch) {
AddPartsEFNonSDSh (nF1, iFF, anEMap, aWES);
}
}
//
aNbEF = aWES.StartElements().Extent() - aNbEdges1;
//
if((aNbEdges1 > 0) && (aNbEF > 0)) {
for (j=1; j<=aNbj; j++) {
iFF=aFFIndicesMap(j);
BOPTools_SSInterference& aFF=aFFs(iFF);
bIsTouch=aFF.IsTangentFaces();
if (!bIsTouch) {
AddPartsEENonSDSh (nF1, iFF, anEMap, aWES);
}
}
}
// IFV's workaround for occ13538 - end
//
}// end of if (bIsTouchCase)
else {
// 1. Add Split Parts having states in accordance with operation
AddSplitPartsINOUT (nF1, aWES);
// 2. Add Split Parts with state ON
AddSplitPartsONSh (nF1, aWES);
// 3. Add Section Edges to the WES
for (j=1; j<=aNbj; j++) {
iFF=aFFIndicesMap(j);
AddSectionPartsSh(nF1, iFF, aWES);
}
// 4. Add EF parts (E (from F2) on F1 )
anEMap.Clear();
for (j=1; j<=aNbj; j++) {
iFF=aFFIndicesMap(j);
AddPartsEFSh(nF1, iFF, anEMap, aWES);
}
}// end of (bIsTouchCase)'s else
//
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Display the WES
if (myDraw) {
const TopTools_ListOfShape& aWESL=aWES.StartElements();
BOP_Draw::DrawListOfEdgesWithPC (myFace, aWESL, i, "ew_");
BOP_Draw::Wait();
}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// d. Build new Faces from myFace
BOP_FaceBuilder aFB;
aFB.SetTreatment(0); // 0-Do Internal Edges
aFB.SetTreatSDScales(1);
aFB.Do(aWES);
const TopTools_ListOfShape& aLF=aFB.NewFaces();
//
// e. Do Internal Vertices
//
DoInternalVertices(nF1, aLF);
//
// f. Orient new faces
TopTools_ListOfShape aLFx;
TopTools_ListIteratorOfListOfShape anIt;
anIt.Initialize(aLF);
for (; anIt.More(); anIt.Next()) {
TopoDS_Shape& aFx=anIt.Value();
aFx.Orientation(anOriF1);
aListOfNewFaces.Append(aFx);
aLFx.Append(aFx);
}
//
// Fill "Modified"
FillModified(aF1, aLFx);
//
}// for (i=1; i<=aNb; i++)
//
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Display the new Faces
if (myDraw) {
BOP_Draw::DrawListOfShape(aListOfNewFaces, "fn_");
}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
myNewFaces.Clear();
myNewFaces.Append(aListOfNewFaces);
}
|