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.
19 #include <BOPAlgo_CheckerSI.ixx>
21 #include <Standard_ErrorHandler.hxx>
22 #include <Standard_Failure.hxx>
24 #include <BRepBuilderAPI_Copy.hxx>
25 #include <TopTools_ListOfShape.hxx>
27 #include <BOPCol_MapOfShape.hxx>
29 #include <BOPDS_DS.hxx>
30 #include <BOPDS_IteratorSI.hxx>
31 #include <BOPDS_PIteratorSI.hxx>
32 #include <BOPDS_Interf.hxx>
33 #include <BOPDS_MapOfPassKey.hxx>
34 #include <BOPDS_PassKey.hxx>
35 #include <BOPDS_VectorOfInterfVV.hxx>
36 #include <BOPDS_VectorOfInterfVE.hxx>
37 #include <BOPDS_VectorOfInterfVE.hxx>
38 #include <BOPDS_VectorOfInterfVF.hxx>
39 #include <BOPDS_VectorOfInterfEF.hxx>
40 #include <BOPDS_VectorOfInterfFF.hxx>
42 #include <IntTools_Context.hxx>
44 #include <BOPTools.hxx>
45 #include <BOPTools_AlgoTools.hxx>
47 //=======================================================================
50 //=======================================================================
51 BOPAlgo_CheckerSI::BOPAlgo_CheckerSI()
55 myLevelOfCheck=BOPDS_DS::NbInterfTypes()-1;
56 myNonDestructive=Standard_True;
58 //=======================================================================
61 //=======================================================================
62 BOPAlgo_CheckerSI::~BOPAlgo_CheckerSI()
65 //=======================================================================
66 //function : SetLevelOfCheck
68 //=======================================================================
69 void BOPAlgo_CheckerSI::SetLevelOfCheck(const Standard_Integer theLevel)
71 Standard_Integer aNbLists;
73 aNbLists=BOPDS_DS::NbInterfTypes();
74 if (theLevel >= 0 && theLevel < aNbLists) {
75 myLevelOfCheck = theLevel;
78 //=======================================================================
79 //function : SetNonDestructive
81 //=======================================================================
82 void BOPAlgo_CheckerSI::SetNonDestructive(const Standard_Boolean theFlag)
84 myNonDestructive=theFlag;
86 //=======================================================================
87 //function : NonDestructive
89 //=======================================================================
90 Standard_Boolean BOPAlgo_CheckerSI::NonDestructive() const
92 return myNonDestructive;
94 //=======================================================================
97 //=======================================================================
98 void BOPAlgo_CheckerSI::Init()
105 myDS=new BOPDS_DS(myAllocator);
106 myDS->SetArguments(myArguments);
107 myDS->SetFuzzyValue(myFuzzyValue);
111 BOPDS_PIteratorSI theIterSI=new BOPDS_IteratorSI(myAllocator);
112 theIterSI->SetDS(myDS);
113 theIterSI->Prepare();
114 theIterSI->UpdateByLevelOfCheck(myLevelOfCheck);
116 myIterator=theIterSI;
119 myContext=new IntTools_Context;
123 //=======================================================================
126 //=======================================================================
127 void BOPAlgo_CheckerSI::Perform()
130 Standard_Integer iErr;
135 if (myArguments.Extent()!=1) {
140 if (myNonDestructive) {
147 BOPAlgo_PaveFiller::Perform();
155 if (myNonDestructive) {
167 catch (Standard_Failure) {
168 if (myNonDestructive) {
175 //=======================================================================
176 //function : PostTreat
178 //=======================================================================
179 void BOPAlgo_CheckerSI::PostTreat()
181 Standard_Integer i, aNb, n1, n2;
186 BOPDS_MapOfPassKey& aMPK=
187 *((BOPDS_MapOfPassKey*)&myDS->Interferences());
191 BOPDS_VectorOfInterfVV& aVVs=myDS->InterfVV();
193 for (i=0; i!=aNb; ++i) {
194 const BOPDS_InterfVV& aVV=aVVs(i);
196 if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
204 BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE();
206 for (i=0; i!=aNb; ++i) {
207 const BOPDS_InterfVE& aVE=aVEs(i);
209 if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
217 BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
219 for (i=0; i!=aNb; ++i) {
220 const BOPDS_InterfEE& aEE=aEEs(i);
222 if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
230 BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
232 for (i=0; i!=aNb; ++i) {
233 const BOPDS_InterfVF& aVF=aVFs(i);
235 if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
243 BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF();
245 for (i=0; i!=aNb; ++i) {
246 const BOPDS_InterfEF& aEF=aEFs(i);
247 if (aEF.CommonPart().Type()==TopAbs_SHAPE) {
251 if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
259 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
261 for (i=0; i!=aNb; ++i) {
262 Standard_Boolean bTangentFaces, bFlag;
263 Standard_Integer aNbC, aNbP, j, iFound;
265 const BOPDS_InterfFF& aFF=aFFs(i);
268 bTangentFaces=aFF.TangentFaces();
269 aNbP=aFF.Points().Extent();
270 const BOPDS_VectorOfCurve& aVC=aFF.Curves();
272 if (!aNbP && !aNbC && !bTangentFaces) {
278 const TopoDS_Face& aF1=*((TopoDS_Face*)&myDS->Shape(n1));
279 const TopoDS_Face& aF2=*((TopoDS_Face*)&myDS->Shape(n2));
280 bFlag=BOPTools_AlgoTools::AreFacesSameDomain
281 (aF1, aF2, myContext);
287 for (j=0; j!=aNbC; ++j) {
288 const BOPDS_Curve& aNC=aVC(j);
289 const BOPDS_ListOfPaveBlock& aLPBC=aNC.PaveBlocks();
290 if (aLPBC.Extent()) {
307 BOPDS_VectorOfInterfVZ& aVZs=myDS->InterfVZ();
309 for (i=0; i!=aNb; ++i) {
311 const BOPDS_InterfVZ& aVZ=aVZs(i);
313 if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
321 BOPDS_VectorOfInterfEZ& aEZs=myDS->InterfEZ();
323 for (i=0; i!=aNb; ++i) {
325 const BOPDS_InterfEZ& aEZ=aEZs(i);
332 BOPDS_VectorOfInterfFZ& aFZs=myDS->InterfFZ();
334 for (i=0; i!=aNb; ++i) {
336 const BOPDS_InterfFZ& aFZ=aFZs(i);
343 BOPDS_VectorOfInterfZZ& aZZs=myDS->InterfZZ();
345 for (i=0; i!=aNb; ++i) {
347 const BOPDS_InterfZZ& aZZ=aZZs(i);
353 //=======================================================================
354 //function : PrepareCopy
356 //=======================================================================
357 void BOPAlgo_CheckerSI::PrepareCopy()
359 Standard_Boolean bIsDone;
360 BRepBuilderAPI_Copy aCopier;
361 BOPCol_MapOfShape aMSA;
362 BOPCol_MapIteratorOfMapOfShape aItMS;
368 const TopoDS_Shape& aSA=myArguments.First();
370 BOPTools::MapShapes(aSA, aMSA);
372 aCopier.Perform(aSA, Standard_False);
373 bIsDone=aCopier.IsDone();
379 const TopoDS_Shape& aSC=aCopier.Shape();
381 aItMS.Initialize(aMSA);
382 for(; aItMS.More(); aItMS.Next()) {
383 const TopoDS_Shape& aSAx=aItMS.Value();
384 const TopoDS_Shape& aSCx=aCopier.Modified(aSAx).First();
385 myNewOldMap.Bind(aSCx, aSAx);
389 myArguments.Append(aSC);
391 //=======================================================================
392 //function : PostTreatCopy
394 //=======================================================================
395 void BOPAlgo_CheckerSI::PostTreatCopy()
397 Standard_Integer i, aNb;
401 aNb=myDS->NbSourceShapes();
402 for (i=0; i!=aNb; ++i) {
403 BOPDS_ShapeInfo& aSI=myDS->ChangeShapeInfo(i);
404 const TopoDS_Shape& aSCi=aSI.Shape();
405 if (!myNewOldMap.IsBound(aSCi)) {
410 const TopoDS_Shape& aSAi=myNewOldMap.Find(aSCi);
417 // 10 - The number of the arguments is not 1
418 // 11 - Exception is caught
419 // 12 - BRepBuilderAPI_Copy is not done
420 // 13 - myNewOldMap doe not contain DS shape