1 // Created by: Peter KURNEV
2 // Copyright (c) 2010-2014 OPEN CASCADE SAS
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
7 // This file is part of Open CASCADE Technology software library.
9 // This library is free software; you can redistribute it and/or modify it under
10 // the terms of the GNU Lesser General Public License 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.
15 // Alternatively, this file may be used under the terms of Open CASCADE
16 // commercial license or contractual agreement.
18 #include <BOPAlgo_Builder.ixx>
20 #include <TopoDS_Iterator.hxx>
22 #include <BOPCol_ListOfShape.hxx>
23 #include <BOPCol_MapOfShape.hxx>
25 #include <BOPTools_AlgoTools.hxx>
26 #include <BOPTools.hxx>
28 //=======================================================================
29 //function : Generated
31 //=======================================================================
32 const TopTools_ListOfShape& BOPAlgo_Builder::Generated(const TopoDS_Shape&)
37 //=======================================================================
40 //=======================================================================
41 const TopTools_ListOfShape& BOPAlgo_Builder::Modified(const TopoDS_Shape& theS)
43 Standard_Boolean bHasImage, bToReverse;
44 TopAbs_ShapeEnum aType;
45 BOPCol_ListIteratorOfListOfShape aIt;
53 bHasImage=myImages.IsBound(theS);
58 aType=theS.ShapeType();
60 if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE ||
61 aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
67 const BOPCol_ListOfShape& aLSp=myImages.Find(theS);
69 for (; aIt.More(); aIt.Next()) {
70 TopoDS_Shape aSp=aIt.Value();
71 if (myShapesSD.IsBound(aSp)) {
72 aSp = myShapesSD.Find(aSp);
75 if (myMapShape.Contains(aSp)) {
77 if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
78 aSp.Orientation(theS.Orientation());
81 bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSp, theS, myContext);
87 myHistShapes.Append(aSp);
93 //=======================================================================
94 //function : IsDeleted
96 //=======================================================================
97 Standard_Boolean BOPAlgo_Builder::IsDeleted(const TopoDS_Shape& theS)
99 Standard_Boolean bRet, bHasImage, bContains;
100 TopAbs_ShapeEnum aType;
101 BOPCol_ListIteratorOfListOfShape aIt;
109 aType=theS.ShapeType();
110 if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE ||
111 aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
115 bHasImage=myImages.IsBound(theS);
122 bContains=myMapShape.Contains(theS);
127 const BOPCol_ListOfShape& aLSp=myImages.Find(theS);
128 aIt.Initialize(aLSp);
129 for (; aIt.More(); aIt.Next()) {
130 TopoDS_Shape aSp=aIt.Value();
132 if (!myShapesSD.IsBound(aSp)) {
133 if (myMapShape.Contains(aSp)) {
138 TopoDS_Shape aSpR=myShapesSD.Find(aSp);
139 if (myMapShape.Contains(aSpR)) {
144 return !bRet; // true
146 //=======================================================================
147 //function : PrepareHistory
149 //=======================================================================
150 void BOPAlgo_Builder::PrepareHistory()
152 if (!myFlagHistory) {
156 if(myShape.IsNull()) {
160 Standard_Boolean bHasImage;
161 TopAbs_ShapeEnum aType;
162 BOPCol_MapOfShape aMS;
163 BOPCol_ListIteratorOfListOfShape aIt;
164 BOPCol_MapIteratorOfMapOfShape aItM;
167 BOPAlgo_BuilderShape::PrepareHistory();
169 // 2. myMapShape - all shapes of result with theirs sub-shapes
170 BOPTools::MapShapes(myShape, myMapShape);
172 // 3. MS - all argument shapes with theirs sub-shapes
173 aIt.Initialize(myArguments);
174 for (; aIt.More(); aIt.Next()) {
175 const TopoDS_Shape& aSx=aIt.Value();
176 BOPTools::MapShapes(aSx, aMS);
180 aItM.Initialize(aMS);
181 for (; aItM.More(); aItM.Next()) {
182 const TopoDS_Shape& aSx=aItM.Key();
183 aType=aSx.ShapeType();
185 // 4.1 .myImagesResult
186 bHasImage=myImages.IsBound(aSx);
188 BOPCol_ListOfShape aLSx;
190 if (myMapShape.Contains(aSx)) {
192 myImagesResult.Add(aSx, aLSx);
196 const BOPCol_ListOfShape& aLSp=myImages.Find(aSx);
197 aIt.Initialize(aLSp);
198 for (; aIt.More(); aIt.Next()) {
199 const TopoDS_Shape& aSp=aIt.Value();
200 if (myMapShape.Contains(aSp)) {
204 myImagesResult.Add(aSx, aLSx);
210 myHasDeleted=IsDeleted(aSx);
213 if (!myHasModified && bHasImage) {
214 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
215 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
216 myHasModified = Standard_True;
220 if (!myHasGenerated) {
221 if (aType==TopAbs_FACE) {
222 const TopTools_ListOfShape& aLG = Generated(aSx);
223 myHasGenerated = aLG.Extent() > 0;
227 myFlagHistory=Standard_True;