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.
20 #include <BOPAlgo_CheckerSI.hxx>
21 #include <BOPCol_MapOfShape.hxx>
22 #include <BOPDS_DS.hxx>
23 #include <BOPDS_Interf.hxx>
24 #include <BOPDS_IteratorSI.hxx>
25 #include <BOPDS_MapOfPair.hxx>
26 #include <BOPDS_Pair.hxx>
27 #include <BOPDS_PIteratorSI.hxx>
28 #include <BOPDS_VectorOfInterfEF.hxx>
29 #include <BOPDS_VectorOfInterfFF.hxx>
30 #include <BOPDS_VectorOfInterfVE.hxx>
31 #include <BOPDS_VectorOfInterfVF.hxx>
32 #include <BOPDS_VectorOfInterfVV.hxx>
33 #include <BOPTools.hxx>
34 #include <BOPTools_AlgoTools.hxx>
35 #include <BRepBuilderAPI_Copy.hxx>
36 #include <IntTools_Context.hxx>
37 #include <Standard_ErrorHandler.hxx>
38 #include <Standard_Failure.hxx>
39 #include <TopTools_ListOfShape.hxx>
41 //=======================================================================
44 //=======================================================================
45 BOPAlgo_CheckerSI::BOPAlgo_CheckerSI()
49 myLevelOfCheck=BOPDS_DS::NbInterfTypes()-1;
50 myNonDestructive=Standard_True;
51 SetAvoidBuildPCurve(Standard_True);
53 //=======================================================================
56 //=======================================================================
57 BOPAlgo_CheckerSI::~BOPAlgo_CheckerSI()
60 //=======================================================================
61 //function : SetLevelOfCheck
63 //=======================================================================
64 void BOPAlgo_CheckerSI::SetLevelOfCheck(const Standard_Integer theLevel)
66 Standard_Integer aNbLists;
68 aNbLists=BOPDS_DS::NbInterfTypes();
69 if (theLevel >= 0 && theLevel < aNbLists) {
70 myLevelOfCheck = theLevel;
73 //=======================================================================
76 //=======================================================================
77 void BOPAlgo_CheckerSI::Init()
84 myDS=new BOPDS_DS(myAllocator);
85 myDS->SetArguments(myArguments);
86 myDS->Init(myFuzzyValue);
89 BOPDS_PIteratorSI theIterSI=new BOPDS_IteratorSI(myAllocator);
90 theIterSI->SetDS(myDS);
92 theIterSI->UpdateByLevelOfCheck(myLevelOfCheck);
97 myContext=new IntTools_Context;
101 //=======================================================================
104 //=======================================================================
105 void BOPAlgo_CheckerSI::Perform()
111 if (myArguments.Extent() != 1) {
116 // Perform intersection of sub shapes
117 BOPAlgo_PaveFiller::Perform();
119 // Perform intersection with solids
132 // Treat the intersection results
136 catch (Standard_Failure) {
140 //=======================================================================
141 //function : PostTreat
143 //=======================================================================
144 void BOPAlgo_CheckerSI::PostTreat()
146 Standard_Integer i, aNb, n1, n2;
151 BOPDS_MapOfPair& aMPK=
152 *((BOPDS_MapOfPair*)&myDS->Interferences());
156 BOPDS_VectorOfInterfVV& aVVs=myDS->InterfVV();
158 for (i=0; i!=aNb; ++i) {
159 const BOPDS_InterfVV& aVV=aVVs(i);
161 if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
164 aPK.SetIndices(n1, n2);
169 BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE();
171 for (i=0; i!=aNb; ++i) {
172 const BOPDS_InterfVE& aVE=aVEs(i);
174 if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
177 aPK.SetIndices(n1, n2);
182 BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
184 for (i=0; i!=aNb; ++i) {
185 const BOPDS_InterfEE& aEE=aEEs(i);
187 if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
190 aPK.SetIndices(n1, n2);
195 BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
197 for (i=0; i!=aNb; ++i) {
198 const BOPDS_InterfVF& aVF=aVFs(i);
200 if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
203 aPK.SetIndices(n1, n2);
208 BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF();
210 for (i=0; i!=aNb; ++i) {
211 const BOPDS_InterfEF& aEF=aEFs(i);
212 if (aEF.CommonPart().Type()==TopAbs_SHAPE) {
216 if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
219 aPK.SetIndices(n1, n2);
224 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
226 for (i=0; i!=aNb; ++i) {
227 Standard_Boolean bTangentFaces, bFlag;
228 Standard_Integer aNbC, aNbP, j, iFound;
230 const BOPDS_InterfFF& aFF=aFFs(i);
233 bTangentFaces=aFF.TangentFaces();
234 aNbP=aFF.Points().Extent();
235 const BOPDS_VectorOfCurve& aVC=aFF.Curves();
237 if (!aNbP && !aNbC && !bTangentFaces) {
243 const TopoDS_Face& aF1=*((TopoDS_Face*)&myDS->Shape(n1));
244 const TopoDS_Face& aF2=*((TopoDS_Face*)&myDS->Shape(n2));
245 bFlag=BOPTools_AlgoTools::AreFacesSameDomain
246 (aF1, aF2, myContext, myFuzzyValue);
252 for (j=0; j!=aNbC; ++j) {
253 const BOPDS_Curve& aNC=aVC(j);
254 const BOPDS_ListOfPaveBlock& aLPBC=aNC.PaveBlocks();
255 if (aLPBC.Extent()) {
266 aPK.SetIndices(n1, n2);
272 BOPDS_VectorOfInterfVZ& aVZs=myDS->InterfVZ();
274 for (i=0; i!=aNb; ++i) {
276 const BOPDS_InterfVZ& aVZ=aVZs(i);
278 if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
281 aPK.SetIndices(n1, n2);
286 BOPDS_VectorOfInterfEZ& aEZs=myDS->InterfEZ();
288 for (i=0; i!=aNb; ++i) {
290 const BOPDS_InterfEZ& aEZ=aEZs(i);
292 aPK.SetIndices(n1, n2);
297 BOPDS_VectorOfInterfFZ& aFZs=myDS->InterfFZ();
299 for (i=0; i!=aNb; ++i) {
301 const BOPDS_InterfFZ& aFZ=aFZs(i);
303 aPK.SetIndices(n1, n2);
308 BOPDS_VectorOfInterfZZ& aZZs=myDS->InterfZZ();
310 for (i=0; i!=aNb; ++i) {
312 const BOPDS_InterfZZ& aZZ=aZZs(i);
314 aPK.SetIndices(n1, n2);