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_MapOfPassKey.hxx>
26 #include <BOPDS_PassKey.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;
52 //=======================================================================
55 //=======================================================================
56 BOPAlgo_CheckerSI::~BOPAlgo_CheckerSI()
59 //=======================================================================
60 //function : SetLevelOfCheck
62 //=======================================================================
63 void BOPAlgo_CheckerSI::SetLevelOfCheck(const Standard_Integer theLevel)
65 Standard_Integer aNbLists;
67 aNbLists=BOPDS_DS::NbInterfTypes();
68 if (theLevel >= 0 && theLevel < aNbLists) {
69 myLevelOfCheck = theLevel;
72 //=======================================================================
75 //=======================================================================
76 void BOPAlgo_CheckerSI::Init()
83 myDS=new BOPDS_DS(myAllocator);
84 myDS->SetArguments(myArguments);
85 myDS->Init(myFuzzyValue);
88 BOPDS_PIteratorSI theIterSI=new BOPDS_IteratorSI(myAllocator);
89 theIterSI->SetDS(myDS);
91 theIterSI->UpdateByLevelOfCheck(myLevelOfCheck);
96 myContext=new IntTools_Context;
100 //=======================================================================
103 //=======================================================================
104 void BOPAlgo_CheckerSI::Perform()
107 Standard_Integer iErr;
112 if (myArguments.Extent()!=1) {
117 if (myNonDestructive) {
124 BOPAlgo_PaveFiller::Perform();
132 if (myNonDestructive) {
144 catch (Standard_Failure) {
145 if (myNonDestructive) {
152 //=======================================================================
153 //function : PostTreat
155 //=======================================================================
156 void BOPAlgo_CheckerSI::PostTreat()
158 Standard_Integer i, aNb, n1, n2;
163 BOPDS_MapOfPassKey& aMPK=
164 *((BOPDS_MapOfPassKey*)&myDS->Interferences());
168 BOPDS_VectorOfInterfVV& aVVs=myDS->InterfVV();
170 for (i=0; i!=aNb; ++i) {
171 const BOPDS_InterfVV& aVV=aVVs(i);
173 if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
181 BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE();
183 for (i=0; i!=aNb; ++i) {
184 const BOPDS_InterfVE& aVE=aVEs(i);
186 if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
194 BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
196 for (i=0; i!=aNb; ++i) {
197 const BOPDS_InterfEE& aEE=aEEs(i);
199 if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
207 BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
209 for (i=0; i!=aNb; ++i) {
210 const BOPDS_InterfVF& aVF=aVFs(i);
212 if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
220 BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF();
222 for (i=0; i!=aNb; ++i) {
223 const BOPDS_InterfEF& aEF=aEFs(i);
224 if (aEF.CommonPart().Type()==TopAbs_SHAPE) {
228 if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
236 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
238 for (i=0; i!=aNb; ++i) {
239 Standard_Boolean bTangentFaces, bFlag;
240 Standard_Integer aNbC, aNbP, j, iFound;
242 const BOPDS_InterfFF& aFF=aFFs(i);
245 bTangentFaces=aFF.TangentFaces();
246 aNbP=aFF.Points().Extent();
247 const BOPDS_VectorOfCurve& aVC=aFF.Curves();
249 if (!aNbP && !aNbC && !bTangentFaces) {
255 const TopoDS_Face& aF1=*((TopoDS_Face*)&myDS->Shape(n1));
256 const TopoDS_Face& aF2=*((TopoDS_Face*)&myDS->Shape(n2));
257 bFlag=BOPTools_AlgoTools::AreFacesSameDomain
258 (aF1, aF2, myContext, myFuzzyValue);
264 for (j=0; j!=aNbC; ++j) {
265 const BOPDS_Curve& aNC=aVC(j);
266 const BOPDS_ListOfPaveBlock& aLPBC=aNC.PaveBlocks();
267 if (aLPBC.Extent()) {
284 BOPDS_VectorOfInterfVZ& aVZs=myDS->InterfVZ();
286 for (i=0; i!=aNb; ++i) {
288 const BOPDS_InterfVZ& aVZ=aVZs(i);
290 if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
298 BOPDS_VectorOfInterfEZ& aEZs=myDS->InterfEZ();
300 for (i=0; i!=aNb; ++i) {
302 const BOPDS_InterfEZ& aEZ=aEZs(i);
309 BOPDS_VectorOfInterfFZ& aFZs=myDS->InterfFZ();
311 for (i=0; i!=aNb; ++i) {
313 const BOPDS_InterfFZ& aFZ=aFZs(i);
320 BOPDS_VectorOfInterfZZ& aZZs=myDS->InterfZZ();
322 for (i=0; i!=aNb; ++i) {
324 const BOPDS_InterfZZ& aZZ=aZZs(i);
330 //=======================================================================
331 //function : PrepareCopy
333 //=======================================================================
334 void BOPAlgo_CheckerSI::PrepareCopy()
336 Standard_Boolean bIsDone;
337 BRepBuilderAPI_Copy aCopier;
338 BOPCol_MapOfShape aMSA;
339 BOPCol_MapIteratorOfMapOfShape aItMS;
345 const TopoDS_Shape& aSA=myArguments.First();
347 BOPTools::MapShapes(aSA, aMSA);
349 aCopier.Perform(aSA, Standard_False);
350 bIsDone=aCopier.IsDone();
356 const TopoDS_Shape& aSC=aCopier.Shape();
358 aItMS.Initialize(aMSA);
359 for(; aItMS.More(); aItMS.Next()) {
360 const TopoDS_Shape& aSAx=aItMS.Value();
361 const TopoDS_Shape& aSCx=aCopier.Modified(aSAx).First();
362 myNewOldMap.Bind(aSCx, aSAx);
366 myArguments.Append(aSC);
368 //=======================================================================
369 //function : PostTreatCopy
371 //=======================================================================
372 void BOPAlgo_CheckerSI::PostTreatCopy()
374 Standard_Integer i, aNb;
378 aNb=myDS->NbSourceShapes();
379 for (i=0; i!=aNb; ++i) {
380 BOPDS_ShapeInfo& aSI=myDS->ChangeShapeInfo(i);
381 const TopoDS_Shape& aSCi=aSI.Shape();
382 if (!myNewOldMap.IsBound(aSCi)) {
387 const TopoDS_Shape& aSAi=myNewOldMap.Find(aSCi);
394 // 10 - The number of the arguments is not 1
395 // 11 - Exception is caught
396 // 12 - BRepBuilderAPI_Copy is not done
397 // 13 - myNewOldMap doe not contain DS shape