0024190: Exception raised during topological operation.
[occt.git] / src / BOPAlgo / BOPAlgo_CheckerSI.cxx
CommitLineData
b311480e 1// Created by: Peter KURNEV
4e57c75e 2// Copyright (c) 2010-2012 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
b311480e 6//
7// The content of this file is subject to the Open CASCADE Technology Public
8// License Version 6.5 (the "License"). You may not use the content of this file
9// except in compliance with the License. Please obtain a copy of the License
10// at http://www.opencascade.org and read it completely before using this file.
11//
12// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
13// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14//
15// The Original Code and all software distributed under the License is
16// distributed on an "AS IS" basis, without warranty of any kind, and the
17// Initial Developer hereby disclaims all such warranties, including without
18// limitation, any warranties of merchantability, fitness for a particular
19// purpose or non-infringement. Please see the License for the specific terms
20// and conditions governing the rights and limitations under the License.
4e57c75e 21//
22#include <BOPAlgo_CheckerSI.ixx>
b311480e 23
b62b3e07 24#include <Standard_ErrorHandler.hxx>
25#include <Standard_Failure.hxx>
26
4e57c75e 27#include <BOPDS_DS.hxx>
28#include <BOPDS_IteratorSI.hxx>
c1fe53c6 29#include <BOPDS_PIteratorSI.hxx>
4e57c75e 30#include <BOPInt_Context.hxx>
7fd59977 31
7ff8f019 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>
41#include <BOPDS_VectorOfPoint.hxx>
42#include <BOPTools_AlgoTools.hxx>
43
7fd59977 44//=======================================================================
4e57c75e 45//function :
7fd59977 46//purpose :
47//=======================================================================
7ff8f019 48BOPAlgo_CheckerSI::BOPAlgo_CheckerSI()
7fd59977 49:
c1fe53c6 50 BOPAlgo_PaveFiller(),
51 myLevelOfCheck(5)
4e57c75e 52{
53}
7fd59977 54//=======================================================================
4e57c75e 55//function : ~
7fd59977 56//purpose :
57//=======================================================================
7ff8f019 58BOPAlgo_CheckerSI::~BOPAlgo_CheckerSI()
7fd59977 59{
7fd59977 60}
61//=======================================================================
c1fe53c6 62//function : SetLevelOfCheck
63//purpose :
64//=======================================================================
7ff8f019 65void BOPAlgo_CheckerSI::SetLevelOfCheck(const Standard_Integer theLevel)
c1fe53c6 66{
67 if (theLevel >= 0 && theLevel <= 5) {
68 myLevelOfCheck = theLevel;
69 }
70}
71//=======================================================================
4e57c75e 72//function : Init
7fd59977 73//purpose :
74//=======================================================================
7ff8f019 75void BOPAlgo_CheckerSI::Init()
7fd59977 76{
4e57c75e 77 myErrorStatus = 0;
78 //
79 if (!myArguments.Extent()) {
80 myErrorStatus=10;
81 return;
82 }
83 //
84 Clear();
85 //
86 // 1. myDS
87 myDS=new BOPDS_DS(myAllocator);
88 myDS->SetArguments(myArguments);
89 myDS->Init();
90 //
91 // 2.myIterator
c1fe53c6 92 BOPDS_PIteratorSI theIterSI=new BOPDS_IteratorSI(myAllocator);
93 theIterSI->SetDS(myDS);
94 theIterSI->Prepare();
95 theIterSI->UpdateByLevelOfCheck(myLevelOfCheck);
96 //
97 myIterator=theIterSI;
4e57c75e 98 //
99 // 3 myContext
100 myContext=new BOPInt_Context;
101 //
102 myErrorStatus=0;
7fd59977 103}
7ff8f019 104//=======================================================================
105//function : Perform
106//purpose :
107//=======================================================================
108void BOPAlgo_CheckerSI::Perform()
109{
b62b3e07 110 //modified by NIZNHY-PKV Thu Sep 19 08:14:52 2013f
111 try {
112 OCC_CATCH_SIGNALS
113 //
114 BOPAlgo_PaveFiller::Perform();
115 if (myErrorStatus) {
116 return;
117 }
118 //
119 PostTreat();
120 }
121 catch (Standard_Failure) {
122 }
123 /*
7ff8f019 124 BOPAlgo_PaveFiller::Perform();
125 if (myErrorStatus) {
126 return;
127 }
128 //
b62b3e07 129 PostTreat();
130 */
131 //modified by NIZNHY-PKV Thu Sep 19 08:14:56 2013t
7ff8f019 132}
133//=======================================================================
134//function : PostTreat
135//purpose :
136//=======================================================================
137void BOPAlgo_CheckerSI::PostTreat()
138{
139 Standard_Integer i, aNb, n1, n2;
140 BOPDS_PassKey aPK;
141 //
142 BOPDS_MapOfPassKey& aMPK=*((BOPDS_MapOfPassKey*)&myDS->Interferences());
143 aMPK.Clear();
144 //
145 // 0
146 BOPDS_VectorOfInterfVV& aVVs=myDS->InterfVV();
147 aNb=aVVs.Extent();
148 for (i=0; i!=aNb; ++i) {
149 const BOPDS_InterfVV& aVV=aVVs(i);
150 aVV.Indices(n1, n2);
151 aPK.SetIds(n1, n2);
152 aMPK.Add(aPK);
153 }
154 //
155 // 1
156 BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE();
157 aNb=aVEs.Extent();
158 for (i=0; i!=aNb; ++i) {
159 const BOPDS_InterfVE& aVE=aVEs(i);
160 aVE.Indices(n1, n2);
161 aPK.SetIds(n1, n2);
162 aMPK.Add(aPK);
163 }
164 //
165 // 2
166 BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
167 aNb=aEEs.Extent();
168 for (i=0; i!=aNb; ++i) {
169 const BOPDS_InterfEE& aEE=aEEs(i);
170 aEE.Indices(n1, n2);
171 aPK.SetIds(n1, n2);
172 aMPK.Add(aPK);
173 }
174 //
175 // 3
176 BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
177 aNb=aVFs.Extent();
178 for (i=0; i!=aNb; ++i) {
179 const BOPDS_InterfVF& aVF=aVFs(i);
180 aVF.Indices(n1, n2);
181 aPK.SetIds(n1, n2);
182 aMPK.Add(aPK);
183 }
184 //
185 // 4
186 BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF();
187 aNb=aEFs.Extent();
188 for (i=0; i!=aNb; ++i) {
189 const BOPDS_InterfEF& aEF=aEFs(i);
190 if (aEF.CommonPart().Type()==TopAbs_SHAPE) {
191 continue;
192 }
193 aEF.Indices(n1, n2);
194 aPK.SetIds(n1, n2);
195 aMPK.Add(aPK);
196 }
197 //
198 // 5
199 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
200 aNb=aFFs.Extent();
201 for (i=0; i!=aNb; ++i) {
202 Standard_Boolean bTangentFaces, bFlag;
203 Standard_Integer aNbC, aNbP, j, iFound;
204 //
205 const BOPDS_InterfFF& aFF=aFFs(i);
206 aFF.Indices(n1, n2);
207 //
208 bTangentFaces=aFF.TangentFaces();
209 aNbP=aFF.Points().Extent();
210 const BOPDS_VectorOfCurve& aVC=aFF.Curves();
211 aNbC=aVC.Extent();
212 if (!aNbP && !aNbC && !bTangentFaces) {
213 continue;
214 }
215 //
216 iFound=0;
217 if (bTangentFaces) {
218 const TopoDS_Face& aF1 = *((TopoDS_Face*)&myDS->Shape(n1));
219 const TopoDS_Face& aF2 = *((TopoDS_Face*)&myDS->Shape(n2));
220 bFlag=BOPTools_AlgoTools::AreFacesSameDomain(aF1, aF2, myContext);
221 if (bFlag) {
222 ++iFound;
223 }
224 }
225 else {
226 for (j=0; j!=aNbC; ++j) {
227 const BOPDS_Curve& aNC=aVC(j);
228 const BOPDS_ListOfPaveBlock& aLPBC=aNC.PaveBlocks();
229 if (aLPBC.Extent()) {
230 ++iFound;
231 break;
232 }
233 }
234 }
235 //
236 if (!iFound) {
237 continue;
238 }
239 //
240 aPK.SetIds(n1, n2);
241 aMPK.Add(aPK);
242 }
243}