0023024: Update headers of OCCT files
[occt.git] / src / BOP / BOP_SolidSolidHistoryCollector.cxx
CommitLineData
b311480e 1// Copyright (c) 1999-2012 OPEN CASCADE SAS
2//
3// The content of this file is subject to the Open CASCADE Technology Public
4// License Version 6.5 (the "License"). You may not use the content of this file
5// except in compliance with the License. Please obtain a copy of the License
6// at http://www.opencascade.org and read it completely before using this file.
7//
8// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10//
11// The Original Code and all software distributed under the License is
12// distributed on an "AS IS" basis, without warranty of any kind, and the
13// Initial Developer hereby disclaims all such warranties, including without
14// limitation, any warranties of merchantability, fitness for a particular
15// purpose or non-infringement. Please see the License for the specific terms
16// and conditions governing the rights and limitations under the License.
17
7fd59977 18#include <BOP_SolidSolidHistoryCollector.ixx>
19
20#include <TopAbs.hxx>
21#include <TopExp_Explorer.hxx>
22#include <BooleanOperations_ShapesDataStructure.hxx>
23#include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
24#include <BOPTools_SSInterference.hxx>
25#include <BOPTools_InterferencePool.hxx>
26#include <BOPTools_CArray1OfSSInterference.hxx>
27#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
28#include <BOPTools_Curve.hxx>
29#include <BOPTools_PaveBlock.hxx>
30#include <BOPTools_DSFiller.hxx>
31#include <BOPTools_PaveFiller.hxx>
32#include <BOPTools_CommonBlock.hxx>
33#include <BOPTools_ListOfCommonBlock.hxx>
34#include <BOPTools_ListIteratorOfListOfCommonBlock.hxx>
35#include <BOPTools_ListIteratorOfListOfPave.hxx>
36#include <BOP_BuilderTools.hxx>
37#include <TopTools_IndexedMapOfShape.hxx>
38#include <TopExp.hxx>
39#include <TColStd_ListIteratorOfListOfInteger.hxx>
40
41// ======================================================================================================
42// function: Constructor
43// purpose:
44// ======================================================================================================
45BOP_SolidSolidHistoryCollector::BOP_SolidSolidHistoryCollector(const TopoDS_Shape& theShape1,
46 const TopoDS_Shape& theShape2,
47 const BOP_Operation theOperation):
48BOP_HistoryCollector(theShape1, theShape2, theOperation)
49{
50}
51
52// ======================================================================================================
53// function: AddNewShape
54// purpose:
55// warning: Treats only faces
56// ======================================================================================================
57void BOP_SolidSolidHistoryCollector::AddNewShape(const TopoDS_Shape& theOldShape,
58 const TopoDS_Shape& theNewShape,
59 const BOPTools_PDSFiller& theDSFiller)
60{
61 if(theOldShape.ShapeType() != theNewShape.ShapeType())
62 return;
63
64 if(theOldShape.ShapeType() != TopAbs_FACE) {
65 return;
66 }
67 Standard_Integer iRank = 0;
68 const BooleanOperations_IndexedDataMapOfShapeInteger& aMap1 =
69 theDSFiller->DS().ShapeIndexMap(1);
70
71 const BooleanOperations_IndexedDataMapOfShapeInteger& aMap2 =
72 theDSFiller->DS().ShapeIndexMap(2);
73
74 if(aMap1.Contains(theOldShape))
75 iRank = 1;
76 else {
77 if(aMap2.Contains(theOldShape))
78 iRank = 2;
79 }
80
81 if(iRank == 0)
82 return;
83
84 TopTools_DataMapOfShapeListOfShape& aHistoryMap = myModifMap;
85
86 if(aHistoryMap.IsBound(theOldShape)) {
87 aHistoryMap.ChangeFind(theOldShape).Append(theNewShape);
88 }
89 else {
90 TopTools_ListOfShape aShapeList;
91 aShapeList.Append(theNewShape);
92 aHistoryMap.Bind(theOldShape, aShapeList);
93 }
94}
95
96// ======================================================================================================
97// function: SetResult
98// purpose:
99// ======================================================================================================
100void BOP_SolidSolidHistoryCollector::SetResult(const TopoDS_Shape& theResult,
101 const BOPTools_PDSFiller& theDSFiller)
102{
103 myResult = theResult;
104 myHasDeleted = Standard_False;
105
106 TopAbs_ShapeEnum aType = TopAbs_FACE;
107 TopTools_IndexedMapOfShape aMap;
108 TopExp::MapShapes(myResult, aType, aMap);
109
110 TopExp_Explorer anExpObj(myS1, aType);
111
112 for(; anExpObj.More(); anExpObj.Next()) {
113 const TopoDS_Shape& aS = anExpObj.Current();
114
115 if(!aMap.Contains(aS)) {
116
117 if(!myModifMap.IsBound(aS) || myModifMap(aS).IsEmpty()) {
118
119 if(!myGenMap.IsBound(aS) || myGenMap(aS).IsEmpty()) {
120 myHasDeleted = Standard_True;
121 break;
122 }
123 }
124 }
125 }
126
127 if(!myHasDeleted) {
128 TopExp_Explorer anExpTool(myS2, aType);
129
130 for(; anExpTool.More(); anExpTool.Next()) {
131 const TopoDS_Shape& aS = anExpTool.Current();
132
133 if(!aMap.Contains(aS)) {
134 if(!myModifMap.IsBound(aS) || myModifMap(aS).IsEmpty()) {
135
136 if(!myGenMap.IsBound(aS) || myGenMap(aS).IsEmpty()) {
137 myHasDeleted = Standard_True;
138 break;
139 }
140 }
141 }
142 }
143 }
144}