0025242: Wrong result of cut operation.
[occt.git] / src / BOPAlgo / BOPAlgo_PaveFiller_10.cxx
CommitLineData
ceaa5e27 1// Created by: Peter KURNEV
955b3e71 2// Copyright (c) 2010-2014 OPEN CASCADE SAS
ceaa5e27 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
6//
d5f74e42 7// This file is part of Open CASCADE Technology software library.
ceaa5e27 8//
d5f74e42 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.
ceaa5e27 14//
d5f74e42 15// Alternatively, this file may be used under the terms of Open CASCADE
16// commercial license or contractual agreement.
17
955b3e71 18#include <BOPAlgo_PaveFiller.ixx>
ceaa5e27 19
ceaa5e27 20#include <gp_Pnt.hxx>
955b3e71 21
ceaa5e27 22#include <TopAbs_State.hxx>
955b3e71 23
24#include <TopoDS_Vertex.hxx>
25#include <TopoDS_Solid.hxx>
ceaa5e27 26#include <BRep_Tool.hxx>
955b3e71 27#include <BRepClass3d_SolidClassifier.hxx>
28
29#include <IntTools_Context.hxx>
ceaa5e27 30
955b3e71 31#include <BOPDS_DS.hxx>
32#include <BOPDS_IteratorSI.hxx>
33#include <BOPDS_Interf.hxx>
ceaa5e27 34
35//=======================================================================
36//function : PerformVZ
37//purpose :
38//=======================================================================
955b3e71 39void BOPAlgo_PaveFiller::PerformVZ()
ceaa5e27 40{
41 Standard_Boolean bJustAdd;
42 Standard_Integer iSize, nV, nZ, i;
43 Standard_Real aTol;
44 gp_Pnt aPV;
45 TopAbs_State aState;
46 //
47 myErrorStatus=0;
48 //
49 myIterator->Initialize(TopAbs_VERTEX, TopAbs_SOLID);
50 iSize=myIterator->ExpectedLength();
51 if (!iSize) {
52 return;
53 }
54 //
55 BOPDS_VectorOfInterfVZ& aVZs=myDS->InterfVZ();
56 aVZs.SetStartSize(iSize);
57 aVZs.SetIncrement(iSize);
58 aVZs.Init();
59 //
60 for (; myIterator->More(); myIterator->Next()) {
61 myIterator->Value(nV, nZ, bJustAdd);
62 if(bJustAdd) {
63 continue;
64 }
65 //
66 const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV);
67 const BOPDS_ShapeInfo& aSIZ=myDS->ShapeInfo(nZ);
68 //
69 const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aSIV.Shape());
70 const TopoDS_Solid& aZ=*((TopoDS_Solid*)&aSIZ.Shape());
71 //
72 BRepClass3d_SolidClassifier& aSC=myContext->SolidClassifier(aZ);
73 //
74 aPV=BRep_Tool::Pnt(aV);
75 aTol=BRep_Tool::Tolerance(aV);
76 //
77 aSC.Perform(aPV, aTol);
78 //
79 aState=aSC.State();
80 if (aState==TopAbs_IN) {
81 i=aVZs.Append()-1;
82 BOPDS_InterfVZ& aVZ=aVZs(i);
83 aVZ.SetIndices(nV, nZ);
84 //
85 myDS->AddInterf(nV, nZ);
86 }
87 }
ceaa5e27 88}
89//=======================================================================
90//function : PerformEZ
91//purpose :
92//=======================================================================
955b3e71 93void BOPAlgo_PaveFiller::PerformEZ()
ceaa5e27 94{
955b3e71 95 Standard_Boolean bJustAdd, bHasInterf;
ceaa5e27 96 Standard_Integer iSize, nE, nZ, i;
97 //
98 myErrorStatus=0;
99 //
100 myIterator->Initialize(TopAbs_EDGE, TopAbs_SOLID);
101 iSize=myIterator->ExpectedLength();
102 if (!iSize) {
103 return;
104 }
105 //
106 BOPDS_VectorOfInterfEZ& aEZs=myDS->InterfEZ();
107 aEZs.SetStartSize(iSize);
108 aEZs.SetIncrement(iSize);
109 aEZs.Init();
110 //
111 for (; myIterator->More(); myIterator->Next()) {
112 myIterator->Value(nE, nZ, bJustAdd);
113 if(bJustAdd) {
114 continue;
115 }
116 //
117 bHasInterf=myDS->HasInterfShapeSubShapes(nE, nZ);
118 if (bHasInterf) {
119 continue;
120 }
121 //
122 bHasInterf=myDS->HasInterfShapeSubShapes(nZ, nE);
123 if (!bHasInterf) {
124 continue;
125 }
126 //
127 i=aEZs.Append()-1;
128 BOPDS_InterfEZ& aEZ=aEZs(i);
129 aEZ.SetIndices(nE, nZ);
130 //
131 myDS->AddInterf(nE, nZ);
132 }
133}
134//=======================================================================
135//function : PerformFZ
136//purpose :
137//=======================================================================
955b3e71 138void BOPAlgo_PaveFiller::PerformFZ()
ceaa5e27 139{
140 Standard_Boolean bJustAdd, bHasInterf;
141 Standard_Integer iSize, nF, nZ, i;
142 //
143 myErrorStatus=0;
144 //
145 myIterator->Initialize(TopAbs_FACE, TopAbs_SOLID);
146 iSize=myIterator->ExpectedLength();
147 if (!iSize) {
148 return;
149 }
150 //
151 BOPDS_VectorOfInterfFZ& aFZs=myDS->InterfFZ();
152 aFZs.SetStartSize(iSize);
153 aFZs.SetIncrement(iSize);
154 aFZs.Init();
155 //
156 for (; myIterator->More(); myIterator->Next()) {
157 myIterator->Value(nF, nZ, bJustAdd);
158 if(bJustAdd) {
159 continue;
160 }
161 //
162 bHasInterf=myDS->HasInterfShapeSubShapes(nF, nZ);
163 if (bHasInterf) {
164 continue;
165 }
166 //
167 bHasInterf=myDS->HasInterfShapeSubShapes(nZ, nF);
168 if (!bHasInterf) {
169 continue;
170 }
171 //
172 i=aFZs.Append()-1;
173 BOPDS_InterfFZ& aFZ=aFZs(i);
174 aFZ.SetIndices(nF, nZ);
175 //
176 myDS->AddInterf(nF, nZ);
177 }
178}
179//=======================================================================
180//function : PerformZZ
181//purpose :
182//=======================================================================
955b3e71 183void BOPAlgo_PaveFiller::PerformZZ()
ceaa5e27 184{
185 Standard_Boolean bJustAdd, bHasInterf, bFlag;
186 Standard_Integer iSize, nZ1, nZ, i;
187 //
188 myErrorStatus=0;
189 //
190 myIterator->Initialize(TopAbs_SOLID, TopAbs_SOLID);
191 iSize=myIterator->ExpectedLength();
192 if (!iSize) {
193 return;
194 }
195 //
196 BOPDS_VectorOfInterfZZ& aZZs=myDS->InterfZZ();
197 aZZs.SetStartSize(iSize);
198 aZZs.SetIncrement(iSize);
199 aZZs.Init();
200 //
201 bFlag=Standard_False;
202 //
203 for (; myIterator->More(); myIterator->Next()) {
204 myIterator->Value(nZ1, nZ, bJustAdd);
205 if(bJustAdd) {
206 continue;
207 }
208 //
209 bHasInterf=myDS->HasInterfShapeSubShapes(nZ, nZ1, bFlag);
210 if (!bHasInterf) {
211 bHasInterf=myDS->HasInterfShapeSubShapes(nZ1, nZ, bFlag);
212 }
213 if (!bHasInterf) {
214 continue;
215 }
216 //
217 i=aZZs.Append()-1;
218 BOPDS_InterfZZ& aZZ=aZZs(i);
219 aZZ.SetIndices(nZ1, nZ);
220 //
221 myDS->AddInterf(nZ1, nZ);
222 }
223}