0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / TopOpeBRep / TopOpeBRep_vprdeg.cxx
CommitLineData
b311480e 1// Created on: 1995-08-04
2// Created by: Jean Yves LEBEY
3// Copyright (c) 1995-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
42cf5bc1 17
18#include <gp_Pnt.hxx>
19#include <TopoDS_Face.hxx>
20#include <TopoDS_Shape.hxx>
21#include <TopOpeBRep_FacesFiller.hxx>
22#include <TopOpeBRep_FacesIntersector.hxx>
23#include <TopOpeBRep_FFDumper.hxx>
24#include <TopOpeBRep_LineInter.hxx>
25#include <TopOpeBRep_PointClassifier.hxx>
26#include <TopOpeBRep_VPointInter.hxx>
27#include <TopOpeBRep_VPointInterClassifier.hxx>
28#include <TopOpeBRep_VPointInterIterator.hxx>
29#include <TopOpeBRepDS_DataStructure.hxx>
30#include <TopOpeBRepDS_HDataStructure.hxx>
31#include <TopOpeBRepDS_Interference.hxx>
32#include <TopOpeBRepDS_Point.hxx>
33#include <TopOpeBRepDS_Transition.hxx>
7fd59977 34
35#ifdef DRAW
36#include <TopOpeBRepDS_DRAW.hxx>
37#endif
38
39#include <Geom_Curve.hxx>
40#include <Geom2d_Line.hxx>
41#include <Geom2d_Curve.hxx>
42
43#include <TopoDS.hxx>
44#include <TopExp.hxx>
45#include <BRepAdaptor_Surface.hxx>
46#include <BRepAdaptor_Curve.hxx>
47//#include <BRepAdaptor_Curve2d.hxx>
48#include <gp_Vec.hxx>
49#include <BRep_Tool.hxx>
50#include <TopAbs.hxx>
51#include <TopExp.hxx>
52#include <Precision.hxx>
53
54#include <TopOpeBRepDS_EXPORT.hxx>
55#include <TopOpeBRep.hxx>
56#include <TopOpeBRep_define.hxx>
57#include <TopOpeBRepTool_ShapeTool.hxx>
58#include <TopOpeBRepTool_TOOL.hxx>
59#include <TopOpeBRepTool_EXPORT.hxx>
60#include <TopOpeBRepTool_mkTondgE.hxx>
61
62#define M_ON(st) (st == TopAbs_ON)
63#define M_REVERSED(st) (st == TopAbs_REVERSED)
64
65// modified by NIZHNY-MKK Tue Nov 21 17:30:23 2000.BEGIN
66static TopTools_DataMapOfShapeListOfShape aMapOfTreatedVertexListOfEdge;
67static TopOpeBRep_PLineInter localCurrentLine=NULL;
68
69static Standard_Boolean local_FindTreatedEdgeOnVertex(const TopoDS_Edge& theEdge,
70 const TopoDS_Vertex& theVertex);
71
72static void local_ReduceMapOfTreatedVertices(const TopOpeBRep_PLineInter& theCurrentLine);
73
74static Standard_Boolean local_FindVertex(const TopOpeBRep_VPointInter& theVP,
75 const TopTools_IndexedDataMapOfShapeListOfShape& theMapOfVertexEdges,
76 TopoDS_Vertex& theVertex);
77// modified by NIZHNY-MKK Tue Nov 21 17:30:27 2000.END
78
0797d9d3 79#ifdef OCCT_DEBUG
7fd59977 80Standard_EXPORT Standard_Boolean FUN_debnull(const TopoDS_Shape& s);
81#endif
82
83Standard_EXPORT Handle(TopOpeBRepDS_Interference) MakeEPVInterference
84(const TopOpeBRepDS_Transition& T, // transition
85 const Standard_Integer S, // curve/edge index
86 const Standard_Integer G, // point/vertex index
87 const Standard_Real P, // parameter of G on S
88 const TopOpeBRepDS_Kind GK,
89 const Standard_Boolean B); // G is a vertex (or not) of the interference master
90
91Standard_EXPORT Handle(TopOpeBRepDS_Interference) MakeEPVInterference
92(const TopOpeBRepDS_Transition& T, // transition
93 const Standard_Integer S, // curve/edge index
94 const Standard_Integer G, // point/vertex index
95 const Standard_Real P, // parameter of G on S
96 const TopOpeBRepDS_Kind GK, // POINT/VERTEX
97 const TopOpeBRepDS_Kind SK,
98 const Standard_Boolean B); // G is a vertex (or not) of the interference master
99
100
101#define M_FINDVP (0) // only look for new vp
102#define M_MKNEWVP (1) // only make newvp
103#define M_GETVP (2) // steps (0) [+(1) if (O) fails]
104Standard_EXPORT void FUN_VPIndex
105(TopOpeBRep_FacesFiller& FF,
106 const TopOpeBRep_LineInter& L,
107 const TopOpeBRep_VPointInter& VP,
108 const Standard_Integer ShapeIndex,
109 const Handle(TopOpeBRepDS_HDataStructure)& HDS,
110 const TopOpeBRepDS_ListOfInterference& DSCIL,
111 TopOpeBRepDS_Kind& PVKind, Standard_Integer& PVIndex, // out
112 Standard_Boolean& EPIfound, Handle(TopOpeBRepDS_Interference)& IEPI, // out
113 Standard_Boolean& CPIfound, Handle(TopOpeBRepDS_Interference)& ICPI, // out
114 const Standard_Integer mkVP);
115
7fd59977 116Standard_EXPORT void FUN_FillVof12
117(const TopOpeBRep_LineInter& L,
118 TopOpeBRepDS_PDataStructure pDS)
119{
120 TopOpeBRep_VPointInterIterator itvp(L);
121 for (; itvp.More(); itvp.Next()) {
122 const TopOpeBRep_VPointInter& vp = itvp.CurrentVP();
123 Standard_Integer sind = vp.ShapeIndex();
124 if (sind != 3) continue;
125 Standard_Boolean isvon1 = vp.IsVertexOnS1();
126 Standard_Boolean isvon2 = vp.IsVertexOnS2();
127 Standard_Boolean isvon12 = isvon1 && isvon2;
128 if (!isvon12) continue;
129 const TopoDS_Shape& v1 = vp.VertexOnS1();
130 const TopoDS_Shape& v2 = vp.VertexOnS2();
131 pDS->FillShapesSameDomain(v1,v2);
132 }
133}
134
135static void FUN_addmapve(TopTools_DataMapOfShapeListOfShape& mapve, const TopoDS_Shape& v, const TopoDS_Shape& e)
136{
137 Standard_Boolean visb = mapve.IsBound(v);
138 Standard_Boolean eisb = mapve.IsBound(e);
139 if (!visb && !eisb)
140 {TopTools_ListOfShape le;le.Append(e);mapve.Bind(v,le);
141 TopTools_ListOfShape lv;lv.Append(v);mapve.Bind(e,lv);}
142 else if (visb && !eisb)
143 {mapve.ChangeFind(v).Append(e);
144 TopTools_ListOfShape lv;lv.Append(v);mapve.Bind(e,lv);}
145 else if (!visb && eisb)
146 {mapve.ChangeFind(e).Append(v);
147 TopTools_ListOfShape le;le.Append(e);mapve.Bind(v,le);}
148 else {
149 Standard_Boolean found = Standard_False;
150 TopTools_ListIteratorOfListOfShape it(mapve.Find(v));
151 for (; it.More(); it.Next())
152 if (it.Value().IsSame(e)) {found = Standard_True; break;}
153 if (!found) {mapve.ChangeFind(v).Append(e); mapve.ChangeFind(e).Append(v);}
154 }
155}
156
157Standard_EXPORT void FUN_GetdgData(TopOpeBRepDS_PDataStructure& pDS,const TopOpeBRep_LineInter& L,
158 const TopoDS_Face& F1,const TopoDS_Face& F2, TopTools_DataMapOfShapeListOfShape& datamap)
159{
160 // purpose : fills up map datamap = {(v, (closinge,degeneratede))}
161 // with shapes with same rank
162
163 TopTools_DataMapOfShapeInteger shaperk; // rkshape = {shape,rank=1,2}
164 TopTools_DataMapOfShapeListOfShape mapvec, mapved; // mapvec = {(v,lec),(ec,lv)}, mapved = {(v,led),(ed,lv)}
165 TopTools_DataMapOfShapeShape mapvvsd; // mapvvsd = {(v,v)}
166
167 TopOpeBRep_VPointInterIterator itvp(L);
168 for (; itvp.More(); itvp.Next()) {
169 const TopOpeBRep_VPointInter& vp = itvp.CurrentVP();
170 Standard_Boolean isv1 = vp.IsVertex(1), isv2 = vp.IsVertex(2);
171 Standard_Boolean isv = isv1 || isv2;
172 if (!isv) continue;
173
174 Standard_Integer sind = vp.ShapeIndex();
175 TopoDS_Shape v = isv1 ? vp.Vertex(1): vp.Vertex(2);
176 for (Standard_Integer i = 1; i <= 2; i++) {
177 TopoDS_Face f = (i == 1)? F1: F2;
178
179 Standard_Boolean isvi = vp.IsVertex(i);
180 if (isvi) {
181 v = vp.Vertex(i);
182 shaperk.Bind(v,i);
183 }
184
185 TopoDS_Edge e; Standard_Boolean isdg, iscl; isdg = iscl = Standard_False;
186 Standard_Boolean ison = (sind == i)||(sind == 3);
187 if (ison) {
188 e = TopoDS::Edge( vp.Edge(i) );
189 shaperk.Bind(e,i);
190
191 isdg = BRep_Tool::Degenerated(e);
192 if (!isdg) iscl = TopOpeBRepTool_ShapeTool::Closed(e,f);
193 if (isdg) FUN_addmapve(mapved,v,e);
194 if (iscl) FUN_addmapve(mapvec,v,e);
195 }//ison
196 }//i = 1..2
197 }//itvp
198
199 // filling up map mapvvsd
200 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(mapved);
201 for (; itm.More(); itm.Next()){
202 const TopoDS_Shape& v = itm.Key();
203 if (v.ShapeType() != TopAbs_VERTEX) continue;
204 Standard_Integer rkv = shaperk.Find(v);
205
206 TopTools_ListIteratorOfListOfShape ite(itm.Value());
207 for (; ite.More(); ite.Next()){
208 const TopoDS_Edge& e = TopoDS::Edge( ite.Value() );
209 Standard_Integer rke = shaperk.Find(e);
210 if (rke != rkv) {
211 TopExp_Explorer ex(e, TopAbs_VERTEX);
212 const TopoDS_Shape& vsd = ex.Current();
213 // recall : if vsd is not bound in shaperk,
214 // it is not bound in <L> either
215 mapvvsd.Bind(v,vsd); mapvvsd.Bind(vsd,v);
216 }
217 }
218 }//itm(mapved)
219
220 itm.Initialize(mapved);
221 for (; itm.More(); itm.Next()){
222 const TopoDS_Shape& dge = itm.Key();
223 Standard_Integer rk = shaperk.Find(dge);
224 TopoDS_Face f = (rk == 1)? F1: F2;
225 if (dge.ShapeType() != TopAbs_EDGE) continue;
226
227 TopExp_Explorer ex(dge, TopAbs_VERTEX);
228 const TopoDS_Vertex& v = TopoDS::Vertex( ex.Current() );
229 Standard_Integer rkv = shaperk.Find(v);
230 Standard_Boolean hassd = mapvvsd.IsBound(v);
231 TopoDS_Vertex vsd; if (hassd) vsd = TopoDS::Vertex( mapvvsd.Find(v) );
232
233 Standard_Boolean hasecl = Standard_False; TopoDS_Shape cle;
234 Standard_Boolean isbv = mapvec.IsBound(v), isbvsd= hassd ? mapvec.IsBound(vsd) : Standard_False;
235 if (!isbv && !isbvsd) {
236 // **************************************************
237 // interference with closing edge is not found,
238 // adding new information to the ds
239 // **************************************************
240 TopTools_IndexedDataMapOfShapeListOfShape mapve; TopExp::MapShapesAndAncestors(f,TopAbs_VERTEX,TopAbs_EDGE,mapve);
241 TopTools_ListIteratorOfListOfShape iteds(mapve.FindFromKey(v));
242 for (; iteds.More(); iteds.Next()){
243 const TopoDS_Edge& ee = TopoDS::Edge(iteds.Value());
244 if (ee.IsSame(dge)) continue;
245 Standard_Boolean iscl = TopOpeBRepTool_ShapeTool::Closed(ee,f);
246 if (!iscl) continue;
247 isbv = Standard_True; cle = ee; hasecl = Standard_True; break;
248 }
249 }
250 if (!hasecl && (isbv || isbvsd)) {
251 TopoDS_Vertex vv = isbv ? v : vsd;
252 TopTools_ListIteratorOfListOfShape ite;
253 if (isbv) ite.Initialize(mapvec.Find(v));
254 for (; ite.More(); ite.Next()){
255 const TopoDS_Shape& e = ite.Value();
256 Standard_Integer rke = shaperk.Find(e);
257 if (rke == rk) {cle = e; hasecl = Standard_True; break;}
258 }
259 }
260 if (!hasecl) continue;
261
262 TopoDS_Vertex vv = (rkv == rk) ? v : vsd;
263 TopTools_ListOfShape ls; ls.Append(cle); ls.Append(dge);
264 datamap.Bind(vv,ls);
265 }//itm(mapved)
266
267 // filling sdm shapes
268 TopTools_DataMapIteratorOfDataMapOfShapeShape ittm(mapvvsd);
269 for (; ittm.More(); ittm.Next()){
270 const TopoDS_Vertex& v = TopoDS::Vertex( ittm.Value() );
271 const TopoDS_Vertex& ov = TopoDS::Vertex( mapvvsd.Find(v) );
272 Standard_Integer rkv = shaperk.Find(v);
273 TopoDS_Vertex v1 = (rkv == 1) ? v : ov;
274 TopoDS_Vertex v2 = (rkv == 2) ? v : ov;
275 pDS->FillShapesSameDomain(v1,v2);
276 }
277}//FUN_GetdgData
278
279#define NOI (0)
280#define MKI1 (1)
281#define MKI2 (2)
282#define MKI12 (3)
283
284static Standard_Integer FUN_putInterfonDegenEd
285(const TopOpeBRep_VPointInter& VP,
286 const TopoDS_Face& F1, const TopoDS_Face& F2,
287 TopTools_DataMapOfShapeListOfShape& DataforDegenEd, // const but for copy &
288 Handle(TopOpeBRepDS_HDataStructure)& HDS,
289 Standard_Integer& is, TopoDS_Edge& dgE,
290// Standard_Integer& makeinterf, // 1,2,3 : compute interf1, or2 or the 2 interfs
291 Standard_Integer& , // 1,2,3 : compute interf1, or2 or the 2 interfs
292 TopOpeBRepDS_Transition& Trans1, Standard_Real& param1,
293 TopOpeBRepDS_Transition& Trans2, Standard_Real& param2,
3d18f1e0 294 TopoDS_Edge& OOEi, Standard_Real& paronOOEi, Standard_Boolean& hasOOEi,
7fd59977 295 Standard_Boolean& isT2d)
296{
7fd59977 297 OOEi.Nullify();
298
299 Standard_Boolean on3 = (VP.ShapeIndex() == 3);// <VP> is shared by edge of 1 and edge of 2.
300 Standard_Boolean onv12 = VP.IsVertexOnS1() && VP.IsVertexOnS2();
301
302 const TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
303 TopoDS_Vertex v; Standard_Integer rkv = 0;
304// Standard_Integer iv;
305 TopoDS_Vertex ov;
306 for (Standard_Integer ShapeIndex = 1; ShapeIndex <= 2; ShapeIndex++) {
307 Standard_Boolean isv = (ShapeIndex == 1) ? (VP.IsVertexOnS1()) : (VP.IsVertexOnS2());
308 if (!isv) continue;
309 v = (ShapeIndex == 1) ? TopoDS::Vertex(VP.VertexOnS1()) : TopoDS::Vertex(VP.VertexOnS2());
310 Standard_Boolean hasdegened = DataforDegenEd.IsBound(v);
311 if (!hasdegened) continue;
312 rkv = ShapeIndex; break;
313 }//ShapeIndex = 1..2
314 if (rkv == 0) return NOI;// compute interference once only.
315 Standard_Boolean isvsd = HDS->HasSameDomain(v);
316
317 // edges dge, cle on shape<rkdg>
318 const TopTools_ListOfShape& loe = DataforDegenEd.Find(v);
319 const TopoDS_Edge& cle = TopoDS::Edge(loe.First());
320 const TopoDS_Edge& dge = TopoDS::Edge(loe.Last()); dgE = dge;
321 Standard_Integer rkdg = 0;
322 if (BDS.HasShape(dge)) rkdg = BDS.AncestorRank(dge);
323 else {
324 Standard_Boolean vindge = FUN_tool_inS(v,dge);
325 if (vindge) rkdg = rkv;
326 else rkdg = (rkv == 1) ? 2 : 1;
327 }
328 is = rkdg;
329 Standard_Integer rki = (rkdg == 1) ? 2 : 1;
330
331 gp_Pnt2d uvi; TopoDS_Face fi,f;
332 {
333 // Standard_Real u,v;
334 // if (rki == 1) VP.ParametersOnS1(u,v);
335 // else VP.ParametersOnS2(u,v);
336 // uvi = gp_Pnt2d(u,v);
337 // modified by NIZHNY-MKK Tue Nov 21 17:44:56 2000.BEGIN
338 Standard_Real upar, vpar;
339 if (rki == 1) VP.ParametersOnS1(upar, vpar);
340 else VP.ParametersOnS2(upar, vpar);
341 uvi = gp_Pnt2d(upar, vpar);
342 // modified by NIZHNY-MKK Tue Nov 21 17:44:59 2000.END
343 fi = (rki == 1) ? F1 : F2;
344 f = (rkdg == 1) ? F1 : F2;
345 }
346 TopOpeBRepTool_mkTondgE mktdg;
347 Standard_Boolean ok = mktdg.Initialize(dge, f, uvi, fi);
348 if (!ok) return NOI;
349 ok = mktdg.SetclE(cle);
350 if (!ok) return NOI;
351
352 if (onv12 || isvsd) {
353 if (onv12)
354 ov = (rkv == 2) ? TopoDS::Vertex(VP.VertexOnS1()) : TopoDS::Vertex(VP.VertexOnS2());
355 else {
356 // modified by NIZHNY-MKK Tue Nov 21 17:45:46 2000.BEGIN
357 // Standard_Boolean ok = FUN_ds_getoov(v,HDS,ov);
358 // if (!ok) return Standard_False;
359 Standard_Boolean found = FUN_ds_getoov(v,HDS,ov);
360 if (!found) return NOI;
361 // modified by NIZHNY-MKK Tue Nov 21 17:45:50 2000.END
362 }
363 if (rkv != rkdg) {TopoDS_Vertex tmp = v; v = ov; ov = tmp; rkv = rkdg;} // ensure v is vertex of dge
364 }
365
1d47d8d0 366 Standard_Integer mkt = 0; Standard_Real par1 = 0.,par2 = 0.;
7fd59977 367 if (on3) {
368 TopoDS_Edge ei = (rki == 1) ? TopoDS::Edge(VP.ArcOnS1()) : TopoDS::Edge(VP.ArcOnS2());
369 Standard_Real pari = (rki == 1) ? VP.ParameterOnArc1() : VP.ParameterOnArc2();
370 // if okrest, ei interfers in the compute of transitions for dge
bcf50875 371 mktdg.SetRest(pari,ei);
7fd59977 372 ok = mktdg.MkTonE(ei,mkt, par1,par2);
373 if ((!ok) || (mkt == NOI)) return NOI;
374 OOEi = ei; paronOOEi = pari; hasOOEi = Standard_True;
375 }//on3
376 else {
377 // modified by NIZHNY-MKK Tue Nov 21 17:31:14 2000.BEGIN
378 // This search, compute and check the data which was not computed by intersector.
379 if((rki == 1 && VP.IsOnDomS1()) || (rki == 2 && VP.IsOnDomS2())) {
380 TopoDS_Edge ei = (rki == 1) ? TopoDS::Edge(VP.ArcOnS1()) : TopoDS::Edge(VP.ArcOnS2());
381 Standard_Real pari = (rki == 1) ? VP.ParameterOnArc1() : VP.ParameterOnArc2();
382 mktdg.SetRest(pari,ei);
383 ok = mktdg.MkTonE(ei,mkt, par1,par2);
384 if(ok && mkt!=NOI) {
385 OOEi = ei; paronOOEi = pari; hasOOEi = Standard_True;
386 }
387 }
388 else {
389 Standard_Boolean edgefound = Standard_False;
390 TopoDS_Face aFace = (rki == 1) ? F1 : F2;
391 TopTools_IndexedDataMapOfShapeListOfShape aMapOfVertexEdges;
392 TopExp::MapShapesAndAncestors(aFace, TopAbs_VERTEX, TopAbs_EDGE, aMapOfVertexEdges);
393 TopoDS_Vertex aVertex;
394 Standard_Boolean vertexfound = local_FindVertex(VP, aMapOfVertexEdges, aVertex);
395
396 if(vertexfound && !aVertex.IsNull()) {
397 TopTools_ListIteratorOfListOfShape anIt(aMapOfVertexEdges.FindFromKey(aVertex));
398 for(; !edgefound && anIt.More(); anIt.Next()) {
399 const TopoDS_Edge& ei = TopoDS::Edge(anIt.Value());
400 Standard_Real pari = BRep_Tool::Parameter(aVertex, ei);
401 if(!BRep_Tool::Degenerated(ei)) {
402 edgefound = !local_FindTreatedEdgeOnVertex(ei, aVertex);
403 }
404 if(edgefound) {
405 mktdg.SetRest(pari,ei);
406 ok = mktdg.MkTonE(ei,mkt, par1,par2);
407 if(ok && mkt!=NOI) {
408 OOEi = ei; paronOOEi = pari; hasOOEi = Standard_True;
409 }
410 if(!aMapOfTreatedVertexListOfEdge.IsBound(aVertex)) {
411 TopTools_ListOfShape thelist;
412 aMapOfTreatedVertexListOfEdge.Bind(aVertex, thelist);
413 }
414 aMapOfTreatedVertexListOfEdge(aVertex).Append(ei);
415 }
416 }
417 }
418 if(!edgefound) {
419 ok = mktdg.MkTonE(mkt, par1,par2);
420 }
421 }
422 // modified by NIZHNY-MKK Tue Nov 21 17:31:36 2000.END
423 if ((!ok) || (mkt == NOI)) return NOI;
424 }
425 isT2d = mktdg.IsT2d();
426
427 if ((mkt == MKI1)||(mkt == MKI12)) {Trans1.Set(TopAbs_FORWARD); param1 = par1;}
428 if ((mkt == MKI2)||(mkt == MKI12)) {Trans2.Set(TopAbs_REVERSED); param2 = par2;}
429 return mkt;
430// ********** iterate on restrictions of fi **********
431// TopTools_ListOfShape lei; mktdg.GetAllRest(lei);
432// TopTools_ListIteratorOfListOfShape ite(lei);
433// for (; ite.More(); ite.Next()){
434// Standard_Boolean oki = mktdg.MkTonE(ei,mkt,par1,par2);
435// ... NYI
436// }
437}//FUN_putInterfonDegenEd
438
439//=======================================================================
440//function : ProcessVPondgE
441//purpose : SUPPLYING INTPATCH when a degenerated edge is touched.
442//=======================================================================
443
444#define s_NOIdgE (0) // do NOT compute any interference
445#define s_IdgE (1) // compute interference(s) on dgE
446#define s_IOOEi (2) // compute interference(s) on OOEi
447
448Standard_Boolean TopOpeBRep_FacesFiller::ProcessVPondgE
449(const TopOpeBRep_VPointInter& VP,
450 const Standard_Integer ShapeIndex,
451 TopOpeBRepDS_Kind& PVKind, Standard_Integer& PVIndex, // out
452 Standard_Boolean& EPIfound, Handle(TopOpeBRepDS_Interference)& IEPI, // out
453 Standard_Boolean& CPIfound, Handle(TopOpeBRepDS_Interference)& ICPI) // out
454{
7fd59977 455 if (PVIndex == 0) FUN_VPIndex ((*this),(*myLine),VP,ShapeIndex,myHDS,myDSCIL, //in
456 PVKind,PVIndex, // out
457 EPIfound,IEPI, // out
458 CPIfound,ICPI, // out
459 M_FINDVP);
460
461 // kpart : sphere/box, with one sphere's degenerated edge lying on one boxe's
462 // face, IN or ON the face
463 // if (mIdgEorOOEi), adds interferences on degenerated edge
464
465 // If interferences should be added, finds out <VP>'s geometry
466 // in existing interferences (see out parameters <EPIfound>..);
467 // adds a new point/vertex to the DS if necessary.
468
469
470 Standard_Boolean hasOOEi=Standard_False; TopoDS_Edge OOEi; Standard_Real parOOEi;
471 TopOpeBRepDS_Transition T1ondg, T2ondg;
472 Standard_Integer rankdg=0, Iiondg=0;
bcf50875 473 Standard_Real par1ondg=0., par2ondg=0.;
7fd59977 474 Standard_Boolean hasdgdata = !myDataforDegenEd.IsEmpty();
475 if (!hasdgdata) {
476 return Standard_False;
477 }
478
479 // modified by NIZHNY-MKK Tue Nov 21 17:35:29 2000
480 local_ReduceMapOfTreatedVertices(myLine);
481
482 Standard_Boolean isT2d = Standard_False; TopoDS_Edge dgEd;
483 Standard_Integer makeI = FUN_putInterfonDegenEd (VP,myF1,myF2,myDataforDegenEd,myHDS,
484 rankdg,dgEd, Iiondg,T1ondg,par1ondg,T2ondg,par2ondg,
485 OOEi,parOOEi,hasOOEi, isT2d);
486 if (makeI == NOI) {
487 return Standard_False;
488 }
489
490 // -------------------------------------------------------------------
491 // --- DS geometry Management ---
492 // -------------------------------------------------------------------
493
494 if (PVIndex == 0) FUN_VPIndex ((*this),(*myLine),VP,ShapeIndex,myHDS,myDSCIL, //in
495 PVKind,PVIndex, // out
496 EPIfound,IEPI, // out
497 CPIfound,ICPI, // out
498 M_MKNEWVP);
499
500 // -------------------------------------------------------------------
501 // --- EVI on degenerated edge ---
502 // --- on OOEi ---
503 // -------------------------------------------------------------------
504
505 Standard_Integer rankFi = (rankdg == 1) ? 2 : 1;
506// TopoDS_Shape dgEd = VP.Edge(rankdg);
507 TopoDS_Face Fi;
508 if (rankFi == 1) Fi = myF1;
509 else Fi = myF2;
510 Standard_Integer iFi = myDS->AddShape(Fi,rankFi);
536a3cb8 511 myDS->AddShape(dgEd,rankdg);
3d18f1e0 512// Standard_Integer iOOEi = 0;
513// if (hasOOEi) iOOEi = myDS->AddShape(OOEi,rankFi);
7fd59977 514
7fd59977 515 Standard_Integer rkv = myDS->AncestorRank(myDS->Shape(PVIndex));
516
517 if ((makeI == MKI1)||(makeI == MKI12)) {
518 T1ondg.Index(iFi);
519 Standard_Boolean isvertex1 = (rkv == 1);
520
3d18f1e0 521/*
7fd59977 522 if (hasOOEi) {
523 Handle(TopOpeBRepDS_Interference) EVI1i = ::MakeEPVInterference(T1ondg,iOOEi,PVIndex,par1ondg,
524 TopOpeBRepDS_VERTEX,TopOpeBRepDS_EDGE,isvertex1);
525 myHDS->StoreInterference(EVI1i,dgEd);
526 }
3d18f1e0 527*/
7fd59977 528 if (!isT2d) {
529 Handle(TopOpeBRepDS_Interference) EVI1 = ::MakeEPVInterference(T1ondg,iFi,PVIndex,par1ondg,
530 TopOpeBRepDS_VERTEX,TopOpeBRepDS_FACE,isvertex1);
531 myHDS->StoreInterference(EVI1,dgEd);
532 }
533 }
534 if ((makeI == MKI2)||(makeI == MKI12)) {
535 T2ondg.Index(iFi);
536 Standard_Boolean isvertex2 = (rkv == 2);
537
3d18f1e0 538/*
7fd59977 539 if (hasOOEi) {
540 Handle(TopOpeBRepDS_Interference) EVI2i = ::MakeEPVInterference(T2ondg,iOOEi,PVIndex,par2ondg,
541 TopOpeBRepDS_VERTEX,TopOpeBRepDS_EDGE,isvertex2);
542 myHDS->StoreInterference(EVI2i,dgEd);
543 }
3d18f1e0 544*/
7fd59977 545 if (!isT2d) {
546 Handle(TopOpeBRepDS_Interference) EVI2 = ::MakeEPVInterference(T2ondg,iFi,PVIndex,par2ondg,
547 TopOpeBRepDS_VERTEX,TopOpeBRepDS_FACE,isvertex2);
548 myHDS->StoreInterference(EVI2,dgEd);
549 }
550 }
551
552 return Standard_True;
553} // ProcessVPondgE
554
555
556// modified by NIZHNY-MKK Tue Nov 21 17:32:52 2000.BEGIN
557static Standard_Boolean local_FindTreatedEdgeOnVertex(const TopoDS_Edge& theEdge,
558 const TopoDS_Vertex& theVertex) {
559 Standard_Boolean found = Standard_False;
560 if(aMapOfTreatedVertexListOfEdge.IsBound(theVertex)) {
561 TopTools_ListIteratorOfListOfShape anIt(aMapOfTreatedVertexListOfEdge(theVertex));
562 for(; !found && anIt.More(); anIt.Next()) {
563 if(theEdge.IsSame(anIt.Value())) {
564 found = Standard_True;
565 }
566 }
567 }
568 return found;
569}
570
571static Standard_Boolean local_FindVertex(const TopOpeBRep_VPointInter& theVP,
572 const TopTools_IndexedDataMapOfShapeListOfShape& theMapOfVertexEdges,
573 TopoDS_Vertex& theVertex) {
574 gp_Pnt aVPPoint = theVP.Value();
575 Standard_Real aVPTolerance = theVP.Tolerance();
576 Standard_Boolean vertexfound = Standard_False;
577 for(Standard_Integer itVertex=1; !vertexfound && itVertex<=theMapOfVertexEdges.Extent(); itVertex++) {
578 theVertex = TopoDS::Vertex(theMapOfVertexEdges.FindKey(itVertex));
579 gp_Pnt aPoint = BRep_Tool::Pnt(theVertex);
580 if(aVPPoint.IsEqual(aPoint, aVPTolerance)) {
581 vertexfound = Standard_True;
582 }
583 }
584 return vertexfound;
585}
586
587static void local_ReduceMapOfTreatedVertices(const TopOpeBRep_PLineInter& theCurrentLine) {
588
589 if(localCurrentLine==NULL) {
590 localCurrentLine = theCurrentLine;
591 aMapOfTreatedVertexListOfEdge.Clear();
592 }
593 else {
594 if(localCurrentLine != theCurrentLine) {
595 localCurrentLine = theCurrentLine;
596 aMapOfTreatedVertexListOfEdge.Clear();
597 }
598 }
599}
600// modified by NIZHNY-MKK Tue Nov 21 17:32:55 2000.END