0024428: Implementation of LGPL license
[occt.git] / src / BOPAlgo / BOPAlgo_CheckerSI.cxx
CommitLineData
b311480e 1// Created by: Peter KURNEV
973c2be1 2// Copyright (c) 2010-2014 OPEN CASCADE SAS
4e57c75e 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
b311480e 6//
973c2be1 7// This file is part of Open CASCADE Technology software library.
b311480e 8//
973c2be1 9// This library is free software; you can redistribute it and / or modify it
10// under the terms of the GNU Lesser General Public 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.
b311480e 14//
973c2be1 15// Alternatively, this file may be used under the terms of Open CASCADE
16// commercial license or contractual agreement.
17
4e57c75e 18//
19#include <BOPAlgo_CheckerSI.ixx>
b311480e 20
b62b3e07 21#include <Standard_ErrorHandler.hxx>
22#include <Standard_Failure.hxx>
23
4e57c75e 24#include <BOPDS_DS.hxx>
25#include <BOPDS_IteratorSI.hxx>
c1fe53c6 26#include <BOPDS_PIteratorSI.hxx>
4e57c75e 27#include <BOPInt_Context.hxx>
7fd59977 28
7ff8f019 29#include <BOPDS_Interf.hxx>
30#include <BOPDS_MapOfPassKey.hxx>
31#include <BOPDS_PassKey.hxx>
32#include <BOPDS_VectorOfInterfVV.hxx>
33#include <BOPDS_VectorOfInterfVE.hxx>
34#include <BOPDS_VectorOfInterfVE.hxx>
35#include <BOPDS_VectorOfInterfVF.hxx>
36#include <BOPDS_VectorOfInterfEF.hxx>
37#include <BOPDS_VectorOfInterfFF.hxx>
38#include <BOPDS_VectorOfPoint.hxx>
39#include <BOPTools_AlgoTools.hxx>
40
7fd59977 41//=======================================================================
4e57c75e 42//function :
7fd59977 43//purpose :
44//=======================================================================
7ff8f019 45BOPAlgo_CheckerSI::BOPAlgo_CheckerSI()
7fd59977 46:
c1fe53c6 47 BOPAlgo_PaveFiller(),
48 myLevelOfCheck(5)
4e57c75e 49{
50}
7fd59977 51//=======================================================================
4e57c75e 52//function : ~
7fd59977 53//purpose :
54//=======================================================================
7ff8f019 55BOPAlgo_CheckerSI::~BOPAlgo_CheckerSI()
7fd59977 56{
7fd59977 57}
58//=======================================================================
c1fe53c6 59//function : SetLevelOfCheck
60//purpose :
61//=======================================================================
7ff8f019 62void BOPAlgo_CheckerSI::SetLevelOfCheck(const Standard_Integer theLevel)
c1fe53c6 63{
64 if (theLevel >= 0 && theLevel <= 5) {
65 myLevelOfCheck = theLevel;
66 }
67}
68//=======================================================================
4e57c75e 69//function : Init
7fd59977 70//purpose :
71//=======================================================================
7ff8f019 72void BOPAlgo_CheckerSI::Init()
7fd59977 73{
4e57c75e 74 myErrorStatus = 0;
75 //
76 if (!myArguments.Extent()) {
77 myErrorStatus=10;
78 return;
79 }
80 //
81 Clear();
82 //
83 // 1. myDS
84 myDS=new BOPDS_DS(myAllocator);
85 myDS->SetArguments(myArguments);
86 myDS->Init();
87 //
88 // 2.myIterator
c1fe53c6 89 BOPDS_PIteratorSI theIterSI=new BOPDS_IteratorSI(myAllocator);
90 theIterSI->SetDS(myDS);
91 theIterSI->Prepare();
92 theIterSI->UpdateByLevelOfCheck(myLevelOfCheck);
93 //
94 myIterator=theIterSI;
4e57c75e 95 //
96 // 3 myContext
97 myContext=new BOPInt_Context;
98 //
99 myErrorStatus=0;
7fd59977 100}
7ff8f019 101//=======================================================================
102//function : Perform
103//purpose :
104//=======================================================================
105void BOPAlgo_CheckerSI::Perform()
106{
b62b3e07 107 //modified by NIZNHY-PKV Thu Sep 19 08:14:52 2013f
108 try {
109 OCC_CATCH_SIGNALS
110 //
111 BOPAlgo_PaveFiller::Perform();
112 if (myErrorStatus) {
113 return;
114 }
115 //
116 PostTreat();
117 }
118 catch (Standard_Failure) {
119 }
120 /*
7ff8f019 121 BOPAlgo_PaveFiller::Perform();
122 if (myErrorStatus) {
123 return;
124 }
125 //
b62b3e07 126 PostTreat();
127 */
128 //modified by NIZNHY-PKV Thu Sep 19 08:14:56 2013t
7ff8f019 129}
130//=======================================================================
131//function : PostTreat
132//purpose :
133//=======================================================================
134void BOPAlgo_CheckerSI::PostTreat()
135{
136 Standard_Integer i, aNb, n1, n2;
137 BOPDS_PassKey aPK;
138 //
139 BOPDS_MapOfPassKey& aMPK=*((BOPDS_MapOfPassKey*)&myDS->Interferences());
140 aMPK.Clear();
141 //
142 // 0
143 BOPDS_VectorOfInterfVV& aVVs=myDS->InterfVV();
144 aNb=aVVs.Extent();
145 for (i=0; i!=aNb; ++i) {
146 const BOPDS_InterfVV& aVV=aVVs(i);
147 aVV.Indices(n1, n2);
148 aPK.SetIds(n1, n2);
149 aMPK.Add(aPK);
150 }
151 //
152 // 1
153 BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE();
154 aNb=aVEs.Extent();
155 for (i=0; i!=aNb; ++i) {
156 const BOPDS_InterfVE& aVE=aVEs(i);
157 aVE.Indices(n1, n2);
158 aPK.SetIds(n1, n2);
159 aMPK.Add(aPK);
160 }
161 //
162 // 2
163 BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
164 aNb=aEEs.Extent();
165 for (i=0; i!=aNb; ++i) {
166 const BOPDS_InterfEE& aEE=aEEs(i);
167 aEE.Indices(n1, n2);
168 aPK.SetIds(n1, n2);
169 aMPK.Add(aPK);
170 }
171 //
172 // 3
173 BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
174 aNb=aVFs.Extent();
175 for (i=0; i!=aNb; ++i) {
176 const BOPDS_InterfVF& aVF=aVFs(i);
177 aVF.Indices(n1, n2);
178 aPK.SetIds(n1, n2);
179 aMPK.Add(aPK);
180 }
181 //
182 // 4
183 BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF();
184 aNb=aEFs.Extent();
185 for (i=0; i!=aNb; ++i) {
186 const BOPDS_InterfEF& aEF=aEFs(i);
187 if (aEF.CommonPart().Type()==TopAbs_SHAPE) {
188 continue;
189 }
190 aEF.Indices(n1, n2);
191 aPK.SetIds(n1, n2);
192 aMPK.Add(aPK);
193 }
194 //
195 // 5
196 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
197 aNb=aFFs.Extent();
198 for (i=0; i!=aNb; ++i) {
199 Standard_Boolean bTangentFaces, bFlag;
200 Standard_Integer aNbC, aNbP, j, iFound;
201 //
202 const BOPDS_InterfFF& aFF=aFFs(i);
203 aFF.Indices(n1, n2);
204 //
205 bTangentFaces=aFF.TangentFaces();
206 aNbP=aFF.Points().Extent();
207 const BOPDS_VectorOfCurve& aVC=aFF.Curves();
208 aNbC=aVC.Extent();
209 if (!aNbP && !aNbC && !bTangentFaces) {
210 continue;
211 }
212 //
213 iFound=0;
214 if (bTangentFaces) {
215 const TopoDS_Face& aF1 = *((TopoDS_Face*)&myDS->Shape(n1));
216 const TopoDS_Face& aF2 = *((TopoDS_Face*)&myDS->Shape(n2));
217 bFlag=BOPTools_AlgoTools::AreFacesSameDomain(aF1, aF2, myContext);
218 if (bFlag) {
219 ++iFound;
220 }
221 }
222 else {
223 for (j=0; j!=aNbC; ++j) {
224 const BOPDS_Curve& aNC=aVC(j);
225 const BOPDS_ListOfPaveBlock& aLPBC=aNC.PaveBlocks();
226 if (aLPBC.Extent()) {
227 ++iFound;
228 break;
229 }
230 }
231 }
232 //
233 if (!iFound) {
234 continue;
235 }
236 //
237 aPK.SetIds(n1, n2);
238 aMPK.Add(aPK);
239 }
240}