0023308: A typo in if-clause, in TopOpeBRepDS_EXPORT.cxx
[occt.git] / src / TopOpeBRepDS / TopOpeBRepDS_EXPORT.cxx
CommitLineData
b311480e 1// Created on: 1997-12-15
2// Created by: Jean Yves LEBEY
3// Copyright (c) 1997-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21// Modified by xpu, Wed May 20 10:47:38 1998
22
23#include <gp_Dir.hxx>
24#include <gp_Pnt.hxx>
25#include <gp_Pnt2d.hxx>
26#include <Geom_Curve.hxx>
27#include <TopoDS.hxx>
28#include <BRep_Tool.hxx>
29#include <BRepTools.hxx>
30#include <TopExp.hxx>
31#include <TopExp_Explorer.hxx>
32#include <Precision.hxx>
33#include <GeomAdaptor_Surface.hxx>
34#include <TColStd_DataMapOfIntegerInteger.hxx>
35#include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
36
37#include <TopOpeBRepTool_CurveTool.hxx>
38#include <TopOpeBRepTool_ShapeTool.hxx>
39#include <TopOpeBRepTool_TOOL.hxx>
40#include <TopOpeBRepTool_EXPORT.hxx>
41#include <TopOpeBRepTool_SC.hxx>
42#include <TopOpeBRepTool_makeTransition.hxx>
43#include <Standard_ProgramError.hxx>
44
45#include <TopOpeBRepDS_InterferenceTool.hxx>
46#include <TopOpeBRepDS_BuildTool.hxx>
47#include <TopOpeBRepDS_PointIterator.hxx>
48#include <TopOpeBRepDS_BuildTool.hxx>
49#include <TopOpeBRepDS_EXPORT.hxx>
50#include <TopOpeBRepDS_connex.hxx>
51#include <TopOpeBRepDS_TKI.hxx>
52#include <TopOpeBRepDS_ProcessInterferencesTool.hxx>
53#include <TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State.hxx>
54#include <TopOpeBRepDS_TOOL.hxx>
55#include <TopOpeBRepDS_define.hxx>
56
57#ifdef DEB
58#include <TopOpeBRepDS_reDEB.hxx>
59Standard_IMPORT Standard_Boolean TopOpeBRepDS_GettraceSPSX(const Standard_Integer);
60Standard_EXPORT void debse1(const Standard_Integer i) {cout<<"+ debse1 se"<<i<<endl;}
61Standard_EXPORT void debse2(const Standard_Integer i) {cout<<"+ debse2 se"<<i<<endl;}
62Standard_EXPORT void debse3(const Standard_Integer i) {cout<<"+ debse3 se"<<i<<endl;}
63Standard_EXPORT void debse4(const Standard_Integer i) {cout<<"+ debse4 se"<<i<<endl;}
64Standard_EXPORT void debse5(const Standard_Integer i) {cout<<"+ debse5 se"<<i<<endl;}
65Standard_EXPORT void debse6(const Standard_Integer i) {cout<<"+ debse6 se"<<i<<endl;}
66Standard_EXPORT void debe7(const Standard_Integer i) {cout<<"+ debe7 se"<<i<<endl;}
67Standard_EXPORT void debse8(const Standard_Integer i) {cout<<"+ debse8 se"<<i<<endl;}
68Standard_EXPORT void debe9(const Standard_Integer i) {cout<<"+ debe9 se"<<i<<endl;}
69Standard_EXPORT void debgb1(const Standard_Integer i) {cout<<"+ debgb1 se"<<i<<endl;}
70Standard_EXPORT void debse9(const Standard_Integer i) {cout<<"+ debse9 se"<<i<<endl;}
71Standard_EXPORT void debsdm1(const Standard_Integer i) {cout<<"+ debsdm1 se"<<i<<endl;}
72Standard_EXPORT void debsamsha(const Standard_Integer i) {cout<<"+ debsamsha se"<<i<<endl;}
73Standard_EXPORT void debcompletefei(const Standard_Integer i) {cout<<"+ debcompletefei f"<<i<<endl;}
74#endif
75static void FUN_Raise()
76{
77#ifdef DEB
78// cout<<"FUN_ds_completeforSE"<<endl;
79// Standard_ProgramError::Raise("FUN_ds_completeforSE");
80#endif
81}
82
83#define M_IN(st) (st == TopAbs_IN)
84#define M_ON(st) (st == TopAbs_ON)
85#define M_OUT(st) (st == TopAbs_OUT)
86#define M_FORWARD(st) (st == TopAbs_FORWARD)
87#define M_UNKNOWN(st) (st == TopAbs_UNKNOWN)
88#define M_REVERSED(st) (st == TopAbs_REVERSED)
89#define M_INTERNAL(st) (st == TopAbs_INTERNAL)
90#define M_EXTERNAL(st) (st == TopAbs_EXTERNAL)
91
92//------------------------------------------------------
93Standard_EXPORT void FDS_SetT(TopOpeBRepDS_Transition& T, const TopOpeBRepDS_Transition& T0)
94//------------------------------------------------------
95{
96 TopAbs_State stb = T0.Before(), sta = T0.After();
97 T.Before(stb); T.After(sta);
98}
99
100//------------------------------------------------------
101Standard_EXPORT Standard_Boolean FDS_hasUNK(const TopOpeBRepDS_Transition& T)
102//------------------------------------------------------
103{
104 TopAbs_State stb = T.Before(), sta = T.After();
105 Standard_Boolean hasunknown = (M_UNKNOWN(stb) || M_UNKNOWN(sta));
106 return hasunknown;
107}
108
109//------------------------------------------------------
110Standard_EXPORT void FDS_copy(const TopOpeBRepDS_ListOfInterference& LI, TopOpeBRepDS_ListOfInterference& LII)
111//------------------------------------------------------
112{
113 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LI); it.More(); it.Next()) LII.Append(it.Value());
114}
115
116//------------------------------------------------------
117Standard_EXPORT void FDS_copy(const TopTools_ListOfShape& LI, TopTools_ListOfShape& LII)
118//------------------------------------------------------
119{
120 for (TopTools_ListIteratorOfListOfShape it(LI); it.More(); it.Next()) LII.Append(it.Value());
121}
122//------------------------------------------------------
123Standard_EXPORT void FDS_assign(const TopOpeBRepDS_ListOfInterference& LI, TopOpeBRepDS_ListOfInterference& LII)
124//------------------------------------------------------
125{
126 LII.Clear(); FDS_copy(LI,LII);
127}
128
129//------------------------------------------------------
130Standard_EXPORT void FDS_assign(const TopTools_ListOfShape& LI, TopTools_ListOfShape& LII)
131//------------------------------------------------------
132{
133 LII.Clear(); FDS_copy(LI,LII);
134}
135
136//------------------------------------------------------
137Standard_EXPORT void FUN_ds_samRk(const TopOpeBRepDS_DataStructure& BDS, const Standard_Integer Rk,
138 TopTools_ListOfShape& LI, TopTools_ListOfShape & LIsrk)
139//------------------------------------------------------
140{
141 LIsrk.Clear();
142 TopTools_ListIteratorOfListOfShape it(LI);
143 while (it.More()) {
144 const TopoDS_Shape& S = it.Value(); Standard_Integer rk = BDS.AncestorRank(S);
145 if (rk == Rk) {LIsrk.Append(S);LI.Remove(it);}
146 else it.Next();
147 }
148}
149
150//------------------------------------------------------
151Standard_EXPORT void FDS_dumpLI
152//------------------------------------------------------
153#ifndef DEB
154(const TopOpeBRepDS_ListOfInterference& ,const char* )
155{
156#else
157(const TopOpeBRepDS_ListOfInterference& LI,const char* str)
158{
159 for(TopOpeBRepDS_ListIteratorOfListOfInterference itD(LI);itD.More();itD.Next()) {
160 if(str) cout<<str; itD.Value()->Dump(cout); cout<<endl;
161 }
162#endif
163}
164
165//------------------------------------------------------
166Standard_EXPORT void FDS_Tdata
167//------------------------------------------------------
168(const Handle(TopOpeBRepDS_Interference)& I,TopAbs_ShapeEnum& SB,Standard_Integer& IB,TopAbs_ShapeEnum& SA,Standard_Integer& IA)
169{
170 if (I.IsNull()) return;
171 const TopOpeBRepDS_Transition T = I->Transition();
172 SB = T.ShapeBefore(); IB = T.IndexBefore();
173 SA = T.ShapeAfter(); IA = T.IndexAfter();
174}
175
176//------------------------------------------------------
177Standard_EXPORT void FDS_data
178//------------------------------------------------------
179(const Handle(TopOpeBRepDS_Interference)& I,TopOpeBRepDS_Kind& GT1,Standard_Integer& G1,TopOpeBRepDS_Kind& ST1,Standard_Integer& S1)
180{
181 if (I.IsNull()) return;
182 GT1 = I->GeometryType(); G1 = I->Geometry();
183 ST1 = I->SupportType(); S1 = I->Support();
184}
185
186// true si la transition de l'interference courante es UNKNOWN
187//------------------------------------------------------
188Standard_EXPORT Standard_Boolean FDS_data
189//------------------------------------------------------
190(const TopOpeBRepDS_ListIteratorOfListOfInterference& it1,Handle(TopOpeBRepDS_Interference)& I1,TopOpeBRepDS_Kind& GT1,Standard_Integer& G1,TopOpeBRepDS_Kind& ST1,Standard_Integer& S1)
191{
192 if (!it1.More()) return Standard_False;
193 I1 = it1.Value(); const TopOpeBRepDS_Transition& T1 = I1->Transition();
194 FDS_data(I1,GT1,G1,ST1,S1);
195 Standard_Boolean isunk1 = T1.IsUnknown();
196 return isunk1;
197}
198
199//------------------------------------------------------
200Standard_EXPORT void FDS_Idata
201//------------------------------------------------------
202(const Handle(TopOpeBRepDS_Interference)& I,TopAbs_ShapeEnum& SB,Standard_Integer& IB,TopAbs_ShapeEnum& SA,Standard_Integer& IA,
203 TopOpeBRepDS_Kind& GT1,Standard_Integer& G1,TopOpeBRepDS_Kind& ST1,Standard_Integer& S1)
204{
205 if (I.IsNull()) return;
206 FDS_Tdata(I,SB,IB,SA,IA);
207 FDS_data(I,GT1,G1,ST1,S1);
208}
209
210//------------------------------------------------------
211Standard_EXPORT Standard_Boolean FUN_ds_getVsdm
212(const TopOpeBRepDS_DataStructure& BDS, const Standard_Integer iV, Standard_Integer& iVsdm)
213//------------------------------------------------------
214{
215 iVsdm = 0;
216 Standard_Boolean found = Standard_False;
217 // getting <Vsdm> shape same domain with <V>.
218 Standard_Integer imax = BDS.NbShapes();
219 Standard_Boolean undef = (iV < 1) || (iV > imax);
220 if (undef) return Standard_False;
221 const TopoDS_Shape& V = BDS.Shape(iV);
222 TopTools_ListIteratorOfListOfShape issdm(BDS.ShapeSameDomain(V));
223 for (; issdm.More(); issdm.Next()){
224 const TopoDS_Shape& VV = issdm.Value();
225 if (V.IsSame(VV)) continue;
226 iVsdm = BDS.Shape(VV);
227 found = Standard_True; break;
228 }
229 return found;
230}
231
232//------------------------------------------------------
233Standard_EXPORT Standard_Boolean FUN_ds_sdm
234(const TopOpeBRepDS_DataStructure& BDS, const TopoDS_Shape& s1, const TopoDS_Shape& s2)
235//------------------------------------------------------
236{
237 if (!BDS.HasShape(s1) || !BDS.HasShape(s2)) return Standard_False;
238 const TopTools_ListOfShape& sdm1 = BDS.ShapeSameDomain(s1);
239 TopTools_ListIteratorOfListOfShape it1(sdm1);
240 for (; it1.More(); it1.Next())
241 if (it1.Value().IsSame(s2)) return Standard_True;
242 return Standard_False;
243}
244
245// True si les faces isb1,isb2, issues du meme shape origine, connexes par l'arete SI, sont tangentes.
246// 1/ analyse du codage SameDomain dans la DS.
247// 2/ si pas de codage SameDomain dans la DS, analyse geometrique.
248// cette deuxieme analyse est necessaire car l'info SameDomain n'est pas recherchee entre les
249// faces d'un meme shape origine.
250//------------------------------------------------------------------------------------
251Standard_EXPORT Standard_Boolean FDS_aresamdom(const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& ES,const TopoDS_Shape& F1,const TopoDS_Shape& F2)
252//------------------------------------------------------------------------------------
253{
254 Standard_Boolean trfa_samdom = Standard_False;
255 const TopTools_ListOfShape& ls = BDS.ShapeSameDomain(F1);
256 TopTools_ListIteratorOfListOfShape it(ls);
257 for(;it.More();it.Next()) { // NYI : syntaxe rapide de BDS IsShapeSameDomainofShape
258 const TopoDS_Shape& ss = it.Value();
259 trfa_samdom = ss.IsSame(F2);
260 if (trfa_samdom) break;
261 }
262 if ( !trfa_samdom ) {
263 Handle(Geom_Surface) su1 = TopOpeBRepTool_ShapeTool::BASISSURFACE(TopoDS::Face(F1));
264 GeomAdaptor_Surface gs1(su1); GeomAbs_SurfaceType st1 = gs1.GetType();
265 Handle(Geom_Surface) su2 = TopOpeBRepTool_ShapeTool::BASISSURFACE(TopoDS::Face(F2));
266 GeomAdaptor_Surface gs2(su2); GeomAbs_SurfaceType st2 = gs2.GetType();
267 Standard_Boolean plpl = (st1 == GeomAbs_Plane) && ( st2 == GeomAbs_Plane);
268 if (plpl) {
269 // NYI a arranger
270 gp_Pnt2d p2d1,p2d2; BRep_Tool::UVPoints(TopoDS::Edge(ES),TopoDS::Face(F1),p2d1,p2d2);
271 gp_Dir d1 = FUN_tool_ngS(p2d1,su1);
272 gp_Dir d2 = FUN_tool_ngS(p2d2,su2);
273 Standard_Real tola = Precision::Angular();
274 Standard_Real dot = d1.Dot(d2);
275 trfa_samdom = (Abs(1. - Abs(dot)) < tola);
276 }
277 }
278 return trfa_samdom;
279}
280
281// True si les faces isb1,isb2, issues du meme shape origine, connexes par l'arete SI, sont tangentes.
282// 1/ analyse du codage SameDomain dans la DS.
283// 2/ si pas de codage SameDomain dans la DS, analyse geometrique.
284// cette deuxieme analyse est necessaire car l'info SameDomain n'est pas recherchee entre les
285// faces d'un meme shape origine.
286//------------------------------------------------------------------------------------
287Standard_EXPORT Standard_Boolean FDS_aresamdom(const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer SI,const Standard_Integer isb1,const Standard_Integer isb2)
288//------------------------------------------------------------------------------------
289{
290 Standard_Boolean trfa_samdom = Standard_False;
291 const TopoDS_Shape& ES = BDS.Shape(SI); // edge de F1 et F2
292 if (ES.ShapeType() != TopAbs_EDGE) return Standard_False;
293 const TopoDS_Shape& F1 = BDS.Shape(isb1);
294 if (F1.ShapeType() != TopAbs_FACE) return Standard_False;
295 const TopoDS_Shape& F2 = BDS.Shape(isb2);
296 if (F2.ShapeType() != TopAbs_FACE) return Standard_False;
297 trfa_samdom = FDS_aresamdom(BDS,ES,F1,F2);
298 return trfa_samdom;
299}
300
301//----------------------------------------------------
302Standard_EXPORT Standard_Boolean FDS_EdgeIsConnexToSameDomainFaces
303(const TopoDS_Shape& E,const Handle(TopOpeBRepDS_HDataStructure)& HDS) // not used
304//----------------------------------------------------
305{
306#ifdef DEB
307 Standard_Integer if1 = 0, if2 = 0;
308#endif
309
310 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
311 const TopTools_ListOfShape& lf = FDSCNX_EdgeConnexitySameShape(E,HDS);
312 Standard_Integer nlf = lf.Extent();
313 if (nlf < 2) return Standard_False;
314
315 Standard_Boolean samdom = Standard_False;
316 TopTools_ListIteratorOfListOfShape i1(lf);
317 for(;i1.More();i1.Next()) {
318 const TopoDS_Shape& f1 = i1.Value();
319 TopTools_ListIteratorOfListOfShape i2(i1);
320 for(;i2.More();i2.Next()) {
321 const TopoDS_Shape& f2 = i2.Value();
322#ifdef DEB
323 if1 = BDS.Shape(f1);if2 = BDS.Shape(f2);
324#endif
325 samdom = FDS_aresamdom(BDS,E,f1,f2);
326 if (samdom) break;
327 }
328 if (samdom) break;
329 }
330 if (samdom) return Standard_True;
331 return Standard_False;
332} // not used
333
334
335// T si ShapeIndex SI est la GeometrieIndex d'une Interference
336// d'un Shape (Before ou After) de la Transition de I
337//----------------------------------------------------
338Standard_EXPORT Standard_Boolean FDS_SIisGIofIofSBAofTofI(const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer SI,const Handle(TopOpeBRepDS_Interference)& I)
339//----------------------------------------------------
340{
341 if (SI == 0) return Standard_False;
342 if (I.IsNull()) return Standard_False;
343 Standard_Boolean ya = Standard_False;
344
345#ifdef DEB
346// const TopOpeBRepDS_Transition& T1 = I->Transition();
347#endif
348 TopAbs_ShapeEnum SB1,SA1;Standard_Integer IB1,IA1;TopOpeBRepDS_Kind GT1,ST1;Standard_Integer G1,S1;
349 FDS_Idata(I,SB1,IB1,SA1,IA1,GT1,G1,ST1,S1);
350
351 if (SB1 == TopAbs_FACE) {
352 const TopOpeBRepDS_ListOfInterference& Bloi = BDS.ShapeInterferences(IB1);
353 TopOpeBRepDS_ListIteratorOfListOfInterference it(Bloi);
354 for(; it.More(); it.Next()) {
355 const Handle(TopOpeBRepDS_Interference)& IB = it.Value();
356 TopAbs_ShapeEnum SBB,SAB;Standard_Integer IBB,IAB;TopOpeBRepDS_Kind GTB,STB;Standard_Integer GB,SB;
357 FDS_Idata(IB,SBB,IBB,SAB,IAB,GTB,GB,STB,SB);
358 if (GTB == TopOpeBRepDS_EDGE && GB == SI) {
359 // la face IB1 a une interference dont la geometrie est l'arete SI.
360 ya = Standard_True;
361 break;
362 }
363 }
364 } // SB1 == FACE
365 else if (SA1 == TopAbs_FACE) {
366 const TopOpeBRepDS_ListOfInterference& Aloi = BDS.ShapeInterferences(IA1);
367 TopOpeBRepDS_ListIteratorOfListOfInterference it(Aloi);
368 for(; it.More(); it.Next()) {
369 const Handle(TopOpeBRepDS_Interference)& IA = it.Value();
370 TopAbs_ShapeEnum SBA,SAA;Standard_Integer IBA,IAA;TopOpeBRepDS_Kind GTA,STA;Standard_Integer GA,SA;
371 FDS_Idata(IA,SBA,IBA,SAA,IAA,GTA,GA,STA,SA);
372 if (GTA == TopOpeBRepDS_EDGE && GA == SI) {
373 // la face IA1 a une interference dont la geometrie est l'arete IS.
374 ya = Standard_True;
375 break;
376 }
377 }
378 } // SA1 == FACE
379
380 return ya;
381}
382
383//---------------------------------------------------------
384Standard_EXPORT Standard_Boolean FDS_Parameter(const Handle(TopOpeBRepDS_Interference)& I, Standard_Real& par)
385//---------------------------------------------------------
386{
387 Standard_Boolean isEVI = I->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference));
388 Standard_Boolean isCPI = I->IsKind(STANDARD_TYPE(TopOpeBRepDS_CurvePointInterference));
389 if (!isEVI && !isCPI) return Standard_False;
390 par = FDS_Parameter(I);
391 return Standard_True;
392}
393
394//----------------------------------------------------
395Standard_EXPORT Standard_Real FDS_Parameter(const Handle(TopOpeBRepDS_Interference)& I)
396//----------------------------------------------------
397{
398 Standard_Real p = 0;
399 if ( I->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference)) )
400 p = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I)->Parameter();
401 else if ( I->IsKind(STANDARD_TYPE(TopOpeBRepDS_CurvePointInterference)) )
402 p = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I)->Parameter();
403 else {
404#ifdef DEB
405 cout<<"EdgeInterference : mauvais type d'interference"<<endl;
406#endif
407 Standard_Failure::Raise("FDS_Parameter");
408 }
409 return p;
410}
411
412//----------------------------------------------------------------------
413Standard_EXPORT Standard_Boolean FDS_HasSameDomain3d(const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& E,TopTools_ListOfShape* PLSD)
414//-----------------------------------------------------------------------
415{
416 const TopTools_ListOfShape& lssd = BDS.ShapeSameDomain(E);
417 Standard_Boolean hsd = (! lssd.IsEmpty());
418 if (PLSD != NULL) PLSD->Clear();
419 if (!hsd) return Standard_False;
420
421 Standard_Boolean hsd3d = Standard_False;
422 TopTools_ListIteratorOfListOfShape it(lssd);
423 for (; it.More(); it.Next()) {
424 const TopoDS_Shape& esd = it.Value();
425#ifdef DEB
426// Standard_Integer iesd = BDS.Shape(esd);
427// Standard_Integer resd = BDS.SameDomainInd(esd);
428#endif
429 TopOpeBRepDS_Config c = BDS.SameDomainOri(esd);
430 Standard_Boolean ok = Standard_True;
431 ok = ok && (c == TopOpeBRepDS_UNSHGEOMETRY);
432 if (ok) {
433 hsd3d = Standard_True;
434 if (PLSD != NULL) PLSD->Append(esd);
435 else break;
436 }
437 }
438 return hsd3d;
439}
440
441//-----------------------------------------------------------------------
442Standard_EXPORT Standard_Boolean FDS_Config3d(const TopoDS_Shape& E1,const TopoDS_Shape& E2,TopOpeBRepDS_Config& c)
443//-----------------------------------------------------------------------
444{
445 Standard_Boolean same = Standard_True;
446
447 gp_Pnt PE1;Standard_Real pE1;
448 Standard_Boolean ok1 = FUN_tool_findPinE(TopoDS::Edge(E1),PE1,pE1);
449 gp_Vec VE1; if (ok1) ok1 = TopOpeBRepTool_TOOL::TggeomE(pE1,TopoDS::Edge(E1),VE1);
450
451 Standard_Real pE2,dE2;
452 Standard_Boolean ok2 = FUN_tool_projPonE(PE1,TopoDS::Edge(E2),pE2,dE2);
453 gp_Vec VE2; if (ok2) ok2 = TopOpeBRepTool_TOOL::TggeomE(pE2,TopoDS::Edge(E2),VE2);
454
455 if (!ok1 || !ok2) return Standard_False;
456
457 gp_Dir DE1(VE1);
458 gp_Dir DE2(VE2);
459 Standard_Real dot = DE1.Dot(DE2);
460 same = (dot > 0);
461 c = (same) ? TopOpeBRepDS_SAMEORIENTED : TopOpeBRepDS_DIFFORIENTED;
462 return Standard_True;
463}
464
465//----------------------------------------------------------------------
466Standard_EXPORT Standard_Boolean FDS_HasSameDomain2d(const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& E,TopTools_ListOfShape* PLSD)
467//-----------------------------------------------------------------------
468{
469 const TopTools_ListOfShape& lssd = BDS.ShapeSameDomain(E);
470 Standard_Boolean hsd = (! lssd.IsEmpty());
471 if (PLSD != NULL) PLSD->Clear();
472 if (!hsd) return Standard_False;
473
474 Standard_Boolean hsd2d = Standard_False;
475 TopTools_ListIteratorOfListOfShape it(lssd);
476 for (; it.More(); it.Next()) {
477 const TopoDS_Shape& esd = it.Value();
478#ifdef DEB
479// Standard_Integer iesd = BDS.Shape(esd);
480// Standard_Integer resd = BDS.SameDomainInd(esd);
481#endif
482 TopOpeBRepDS_Config c = BDS.SameDomainOri(esd);
483 Standard_Boolean ok = (c == TopOpeBRepDS_SAMEORIENTED || c == TopOpeBRepDS_DIFFORIENTED);
484 if (ok) {
485 hsd2d = Standard_True;
486 if (PLSD != NULL) PLSD->Append(esd);
487 else break;
488 }
489 }
490 return hsd2d;
491}
492
493//-----------------------------------------------------------------------
494Standard_EXPORT void FDS_getupperlower
495(const Handle(TopOpeBRepDS_HDataStructure)& HDS,
496 const Standard_Integer edgeIndex,
497 const Standard_Real paredge,
498 Standard_Real& p1, Standard_Real& p2)
499//-----------------------------------------------------------------------
500{
501 TopoDS_Edge E = TopoDS::Edge(HDS->Shape(edgeIndex));
502 FUN_tool_bounds(E,p1,p2);
503
504 // get p1, p2, p1<paredge<p2 with pmin, pmax nearest parameters
505 Standard_Real par;
506 TopOpeBRepDS_PointIterator pIte = HDS->EdgePoints(E);
507 for (;pIte.More();pIte.Next()) {
508 par = pIte.Parameter();
509 Standard_Boolean parsup1 = (par > p1), parinfe = (par < paredge);
510 Standard_Boolean parinf2 = (par < p2), parsupe = (par > paredge);
511 if (parsup1 && parinfe) p1 = par;
512 if (parinf2 && parsupe) p2 = par;
513 }
514}
515
516// ----------------------------------------------------------------------
517Standard_EXPORT Standard_Boolean FUN_ds_getoov(const TopoDS_Shape& v, const TopOpeBRepDS_DataStructure& BDS, TopoDS_Shape& oov)
518//-----------------------------------------------------------------------
519{
520 // prequesitory : the DS binds at most 2 vertices same domain
521 TopoDS_Shape nullS; oov = nullS;
522 const TopTools_ListOfShape& vsd = BDS.ShapeSameDomain(v);
523 TopTools_ListIteratorOfListOfShape itlov(vsd);
524 for (; itlov.More(); itlov.Next()){
525 const TopoDS_Shape& vcur = itlov.Value();
526 if (vcur.IsSame(v)) continue;
527 oov = vcur;
528 return Standard_True;
529 }
530 return Standard_False;
531}
532
533// ----------------------------------------------------------------------
534Standard_EXPORT Standard_Boolean FUN_ds_getoov(const TopoDS_Shape& v, const Handle(TopOpeBRepDS_HDataStructure)& HDS, TopoDS_Shape& oov)
535//-----------------------------------------------------------------------
536{
537 // prequesitory : the DS binds at most 2 vertices same domain
538 TopoDS_Shape nullS; oov = nullS;
539 if (HDS->HasSameDomain(v)) {
540 TopTools_ListIteratorOfListOfShape itlov(HDS->SameDomain(v));
541 for (; itlov.More(); itlov.Next()){
542 const TopoDS_Shape& vcur = itlov.Value();
543 if (vcur.IsSame(v)) continue;
544 oov = vcur;
545 return Standard_True;
546 }
547 }
548 return Standard_False;
549}
550
551Standard_EXPORT Standard_Boolean FUN_selectTRAINTinterference(const TopOpeBRepDS_ListOfInterference& li, TopOpeBRepDS_ListOfInterference& liINTERNAL)
552{
553 liINTERNAL.Clear();
554 TopOpeBRepDS_ListIteratorOfListOfInterference it(li);
555 for (; it.More(); it.Next()){
556 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
557 const TopAbs_Orientation ori = I->Transition().Orientation(TopAbs_IN);
558 if (M_INTERNAL(ori)) liINTERNAL.Append(I);
559 }
560 Standard_Boolean hasINT = !liINTERNAL.IsEmpty();
561 return hasINT;
562}
563
564static Standard_Boolean FUN_ds_hasSDMancestorfaces
565(const Handle(TopOpeBRepDS_HDataStructure)& HDS, const TopoDS_Edge& E1,const TopoDS_Edge& E2, TopoDS_Face& Fsd1,TopoDS_Face& Fsd2)
566{
567 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
568
569 const TopTools_ListOfShape& lFcE1 = FDSCNX_EdgeConnexitySameShape(E1,HDS);
570 const TopTools_ListOfShape& lFcE2 = FDSCNX_EdgeConnexitySameShape(E2,HDS);
571
572 TopTools_IndexedMapOfShape mapfcE2;
573 TopTools_ListIteratorOfListOfShape it2(lFcE2);
574 for (; it2.More(); it2.Next()) mapfcE2.Add(it2.Value());
575
576 TopTools_ListIteratorOfListOfShape it1(lFcE1);
577 for (; it1.More(); it1.Next()){
578 const TopoDS_Shape& fcE1 = it1.Value();
579 Standard_Boolean hsdm1 = HDS->HasSameDomain(fcE1);
580 if (!hsdm1) continue;
581 const TopTools_ListOfShape& fsdm2 = BDS.ShapeSameDomain(fcE1);
582 it2.Initialize(fsdm2);
583 for (; it2.More(); it2.Next()){
584 const TopoDS_Shape& f2 = it2.Value();
585 Standard_Boolean isb2 = mapfcE2.Contains(f2);
586 if (!isb2) continue;
587 Fsd1 = TopoDS::Face(fcE1); Fsd2 = TopoDS::Face(f2);
588 return Standard_True;
589 }
590 }
591 return Standard_False;
592}
593
594//unreferenced function, commented
595/*#ifdef DEB
596static Standard_Integer FUN_ds_FaceConnexitySameShape(const TopoDS_Vertex& V, const TopoDS_Edge& E, const Handle(TopOpeBRepDS_HDataStructure)& HDS,
597 TopTools_ListOfShape& lFcx)
598// very expensive, but found no other way (nyi : modify DS_connex.cxx)
599{
600 lFcx.Clear();
601#ifdef DEB
602// const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
603#endif
604 const TopTools_ListOfShape& lf1 = FDSCNX_EdgeConnexitySameShape(E,HDS);
605 Standard_Integer nlf1 = lf1.Extent();
606 if (nlf1 < 2) return Standard_False;
607
608 TopTools_MapOfShape mapf;
609 TopTools_ListIteratorOfListOfShape it1(lf1);
610 for (; it1.More(); it1.Next()){
611 const TopoDS_Shape& f = it1.Value();
612 mapf.Add(f);
613 TopExp_Explorer exe(f,TopAbs_EDGE);
614 for (; exe.More(); exe.Next()){
615 const TopoDS_Edge& e = TopoDS::Edge(exe.Current());
616 if (e.IsSame(E)) continue;
617 Standard_Integer iori = FUN_tool_orientVinE(V,e);
618 if (iori == 0) continue;
619 const TopTools_ListOfShape& lf2 = FDSCNX_EdgeConnexitySameShape(e,HDS);
620 TopTools_ListIteratorOfListOfShape it2(lf2);
621 for (; it2.More(); it2.Next()) mapf.Add(it2.Value());
622 } // exe
623 } // it1
624 TopTools_MapIteratorOfMapOfShape itm(mapf);
625 for (; itm.More(); itm.Next()) lFcx.Append(itm.Key());
626 return lFcx.Extent();
627}
628#endif*/
629
630// ----------------------------------------------------------------------
631Standard_EXPORT void FUN_ds_PURGEforE9(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
632// ----------------------------------------------------------------------
633{
634 // xpu040998 : line gives myLineINL=true, interference on geometry
635 // edge/face describing contact on geometry -> EPIe + EPIf = 3dI
636 // EPIf is faulty if edge is in face's geometry
637 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
638 Standard_Integer ns = BDS.NbShapes();
639 for (Standard_Integer i = 1; i <= ns; i++) {
640 const TopoDS_Shape& EE = BDS.Shape(i);
641 if (EE.ShapeType() != TopAbs_EDGE) continue;
642
643 const TopoDS_Edge& E = TopoDS::Edge(EE);
644 Standard_Boolean isdgE = BRep_Tool::Degenerated(E);
645 if (isdgE) continue;
646
647 Standard_Integer IE = BDS.Shape(E);
648#ifdef DEB
649 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(IE);
650 if (trc) debe9(IE);
651#endif
652 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(E);
653 TopOpeBRepDS_ListOfInterference LIcopy; FDS_assign(LI,LIcopy);
654 TopOpeBRepDS_ListOfInterference l3dF; Standard_Integer n3dF = FUN_selectSKinterference(LIcopy,TopOpeBRepDS_FACE,l3dF);
655 if (n3dF == 0) continue;
656
657 const TopTools_ListOfShape& lfcxE = FDSCNX_EdgeConnexitySameShape(E,HDS);
658 Standard_Integer nlfcxE = lfcxE.Extent();
659 if (nlfcxE == 0) continue; // NYIRaise
660 TopTools_ListIteratorOfListOfShape itf(lfcxE);
661 TopTools_IndexedMapOfShape mapf; for (; itf.More(); itf.Next()) mapf.Add(itf.Value());
662
663 Standard_Boolean removed = Standard_False;
664 TopOpeBRepDS_ListIteratorOfListOfInterference it(l3dF);
665 while (it.More()) {
666 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
667 TopAbs_ShapeEnum SB,SA;Standard_Integer IB,IA;TopOpeBRepDS_Kind GT,ST;Standard_Integer G,S;
668 FDS_Idata(I,SB,IB,SA,IA,GT,G,ST,S);
669 Standard_Boolean FhasGE = FDS_SIisGIofIofSBAofTofI(BDS,IE,I);
670 if (FhasGE) {removed = Standard_True; l3dF.Remove(it); continue;} // E has split ON F (cto904A3;e19,f14)
671 const TopoDS_Shape& F = BDS.Shape(S);
672 Standard_Boolean hsdm = HDS->HasSameDomain(F);
673 if (!hsdm) {it.Next(); continue;}
674 TopTools_ListIteratorOfListOfShape issdm(BDS.ShapeSameDomain(F));
675 Standard_Boolean foundinsdm = Standard_False;
676 for (; issdm.More(); issdm.Next())
677 if (mapf.Contains(issdm.Value())) {foundinsdm = Standard_True; break;}
678 if (!foundinsdm) {it.Next(); continue;} // E is IN geometry(F) (cto002D2;e33,f31)
679
680 // E is edge of FF sdm with F
681#ifdef DEB
682 if (trc) {cout<<"-> SE9 removing I3dF :";I->Dump(cout);cout<<endl;}
683#endif
684 removed = Standard_True; l3dF.Remove(it);
685 } //it(l3dF)
686
687 if (!removed) continue;
688 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(E);
689 LII.Clear(); LII.Append(LIcopy); LII.Append(l3dF);
690 } //i=1..ns
691} // PURGEforE9
692
693// ----------------------------------------------------------------------
694Standard_EXPORT void FUN_ds_completeforSE1(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
695// ----------------------------------------------------------------------
696{
697 // xpu160398 complement for INTERNAL transitions on section edge
698 // recall : we add geometry G on section edge SE only if
699 // SE has ISE=(T(face F),G,edge ES),
700 // && F has IF =(T,SE,S).
701 //
702 // purpose : SE has ISE=(T(face F'),G,edge),
703 // F' has no interference with support==SE
704 // => looking for F / F and F' share ES,
705 // F sdm with Fanc (one face ancestor of ES)
706 // F has I' = (T,SE,S).
707 // cto 009 D1
708
709 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
710 Standard_Integer nse = BDS.NbSectionEdges();
711
712 for (Standard_Integer i = 1; i <= nse; i++) {
713 const TopoDS_Edge& SE = BDS.SectionEdge(i);
714 Standard_Integer ISE = BDS.Shape(SE);
715 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
716#ifdef DEB
717 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
718 if (trc) debse1(ISE);
719#endif
720
721 TopOpeBRepDS_TKI tki;
722 tki.FillOnGeometry(LI);
723 for (tki.Init(); tki.More(); tki.Next()) {
724
725 // ISE = (INTERNAL(FACE),G,EDGE) :
726 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
727 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
728 TopOpeBRepDS_ListOfInterference lI1; Standard_Boolean hasINT = ::FUN_selectTRAINTinterference(loicopy,lI1);
729 if (!hasINT) continue;
730 TopOpeBRepDS_ListOfInterference lI2; Standard_Integer nI = FUN_selectTRASHAinterference(lI1,TopAbs_FACE,lI2);
731 if (nI < 1) continue;
732 TopOpeBRepDS_ListOfInterference lI3; nI = FUN_selectSKinterference(lI2,TopOpeBRepDS_EDGE,lI3);
733 if (nI < 1) continue;
734
735 Standard_Boolean keepI = Standard_False;
736// for (TopOpeBRepDS_ListIteratorOfListOfInterference it(lI3) ;it.More(); it.Next()){
737 TopOpeBRepDS_ListIteratorOfListOfInterference it(lI3) ;
738 for ( ;it.More(); it.Next()){
739 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
740 keepI = FDS_SIisGIofIofSBAofTofI(BDS,ISE,I);
741 if (keepI) break;
742 }
743 if (keepI) continue;
744
745 // ISE = (INTERNAL(F),G,ES), F has no I with G==SE
746 // find fSE / fSE (SE's ancestor face) has IfSE = (T,SE,support)
747 // - fSE sdm & fES (ES's ancestor face) -
748// for (it.Initialize(lI3) ;it.More(); it.Next()){
749 it.Initialize(lI3) ;
750 for ( ;it.More(); it.Next()){
751 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
752#ifdef DEB
753// const TopOpeBRepDS_Transition& T = I->Transition();
754#endif
755 TopOpeBRepDS_Kind GT,ST;
756 Standard_Integer G1,S;
757 FDS_data(I,GT,G1,ST,S);
758 TopAbs_ShapeEnum tsb,tsa; Standard_Integer isb,isa; FDS_Tdata(I,tsb,isb,tsa,isa);
759 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(S));
760 TopoDS_Face fSE,fES; Standard_Boolean sdmf = ::FUN_ds_hasSDMancestorfaces(HDS,SE,ES, fSE,fES);
761 if (!sdmf) continue;
762 Standard_Integer IfES = BDS.Shape(fES);
763
764 const TopOpeBRepDS_ListOfInterference& LIf = BDS.ShapeInterferences(fES);
765 TopOpeBRepDS_ListOfInterference LIfcopy; FDS_copy(LIf,LIfcopy);
766 TopOpeBRepDS_ListOfInterference LIfound; Standard_Integer nfound = FUN_selectGIinterference(LIfcopy,ISE,LIfound);
767 if (nfound < 1) continue;
768
769 // cto 009 B1 : Ifor=(FORWARD(IfES),G1,S) && Irev=(REVERSED(IfES),G1,S)
770 // -> do NOT reduce to I = (INTERNAL(IfES),G1,S) (we can have EXTERNAL Tr)
771 FDS_copy(loi,loicopy);
772 TopOpeBRepDS_ListOfInterference lI4;
773#ifdef DEB
774// Standard_Integer nI4 =
775#endif
776 FUN_selectITRASHAinterference(loicopy,IfES,lI4);
777 Standard_Boolean hasFORREV=Standard_False;
778 TopOpeBRepDS_ListOfInterference lfor; Standard_Integer nFOR = FUN_selectTRAORIinterference(lI4,TopAbs_FORWARD,lfor);
779 TopOpeBRepDS_ListOfInterference lrev; Standard_Integer nREV = FUN_selectTRAORIinterference(lI4,TopAbs_REVERSED,lrev);
780 hasFORREV = (nFOR > 0) || (nREV > 0);
781 if (hasFORREV) break;
782
783 // newI :
784 // -----
785 TopOpeBRepDS_Transition newT(TopAbs_INTERNAL);
786 newT.Index(IfES);
787 Standard_Real par = FDS_Parameter(I);
788 Standard_Boolean isevi = I->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference));
789 Standard_Boolean B = Standard_False;
790 if (isevi) B = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I)->GBound();
791 Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(newT,S,G1,par,K,TopOpeBRepDS_EDGE,B);
792#ifdef DEB
793 if (trc) {
794 cout<<"completeforSE1 on section edge "<<ISE<<" ";
795 newI->Dump(cout);
796 cout<<endl;
797 }
798#endif
799 HDS->StoreInterference(newI,SE);
800 break;
801 } // it(lI3)
802 } // tki
803 } // i=1..nse
804} // completeforSE1
805
806// ----------------------------------------------------------------------
807Standard_EXPORT void FUN_ds_completeforSE2(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
808// ----------------------------------------------------------------------
809{
810 // xpu250398 compute 3dI
811 // recall : to have spOUT(SE) / spIN(SE) with SE section edge on bound G
812 // we need IF = (T(F),G,F) with G not SE bound.
813 //
814 // purpose : Sometimes for gap's reasons we can miss such interference.
815 // attached to ES, IFE = (T(FTRA),G,ES) with G not Gbound
816 // we find no IF = (T(FTRA),G,FTRA)
817 // 1. look for FCX / FCX shares ES with FTA (recall : rkG==rkFCX)
818 // 2. compute I3d = (T2(FCX),G,FCX)
819 // !!! if SE has splits ON F near G (if we have a 2dI near G) -> do NOT add I3d
820 // PRO12696 : on se 46 (create FEI/ f50)
821
822 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
823 Standard_Integer nse = BDS.NbSectionEdges();
824
825 for (Standard_Integer i = 1; i <= nse; i++) {
826 const TopoDS_Edge& SE = TopoDS::Edge(BDS.SectionEdge(i));
827 Standard_Integer rkSE = BDS.AncestorRank(SE);
828#ifdef DEB
829 Standard_Integer ISE =
830#endif
831 BDS.Shape(SE);
832 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
833#ifdef DEB
834 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
835 if (trc) debse2(ISE);
836#endif
837
838 TopOpeBRepDS_TKI tki;
839 tki.FillOnGeometry(LI);
840 for (tki.Init(); tki.More(); tki.Next()) {
841
842 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
843 Standard_Boolean point = (K == TopOpeBRepDS_POINT);
844 Standard_Boolean vertex = (K == TopOpeBRepDS_VERTEX);
845
846 // interferences on GBound=1 not treated
847 Standard_Boolean try1 = Standard_True;
848 if (vertex) {
849 const TopoDS_Vertex& vG = TopoDS::Vertex(BDS.Shape(G));
850 TopoDS_Vertex OOv; Standard_Boolean hasOO = FUN_ds_getoov(vG,HDS,OOv);
851 Standard_Integer ovSE = FUN_tool_orientVinE(vG,SE);
852 if ((ovSE == 0) && hasOO) ovSE = FUN_tool_orientVinE(OOv,SE);
853 if (ovSE != 0) try1 = Standard_False;
854 }
855 if (!try1) continue;
856
857 // SE has {I=(T(face), G not Gbound, edge)}
858 // has NO {I'=(T'(face'), G not Gbound, face')}
859 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
860 TopOpeBRepDS_ListOfInterference l1;
861#ifdef DEB
862// Standard_Integer nI =
863#endif
864 FUN_selectTRASHAinterference(loicopy,TopAbs_FACE,l1);
865 TopOpeBRepDS_ListOfInterference lF; Standard_Integer nF = FUN_selectSKinterference(l1,TopOpeBRepDS_FACE,lF);
866 if (nF > 1) continue;
867 TopOpeBRepDS_ListOfInterference lFE; Standard_Integer nFE = FUN_selectSKinterference(l1,TopOpeBRepDS_EDGE,lFE);
868 if (nFE == 0) continue;
869
870 // I = (T(FTRA),G not Gbound, ES)
871 const Handle(TopOpeBRepDS_Interference)& I = lFE.First();
872 Standard_Real par = FDS_Parameter(I);
873#ifdef DEB
874// const TopOpeBRepDS_Transition& T = I->Transition();
875#endif
876 TopOpeBRepDS_Kind ST; Standard_Integer S; FDS_data(I,K,G,ST,S);
877 TopAbs_ShapeEnum tsb,tsa; Standard_Integer isb,isa; FDS_Tdata(I,tsb,isb,tsa,isa);
878 const TopoDS_Face& FTRA= TopoDS::Face(BDS.Shape(isb));
879 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(S));
880
881 // lfCX = {fCX / fCX shares ES with FTRA}
882 const TopTools_ListOfShape& lfCX = FDSCNX_EdgeConnexitySameShape(ES,HDS);
883 for (TopTools_ListIteratorOfListOfShape itfcx(lfCX); itfcx.More(); itfcx.Next()){
884 const TopoDS_Face& FCX = TopoDS::Face(itfcx.Value());
885 Standard_Integer IFCX = BDS.Shape(FCX);
886 if (FCX.IsSame(FTRA)) continue;
887
888 // xpu140498 : NYI check SE has part ON FCX(with bound G)
889 TopOpeBRepDS_ListOfInterference l2; Standard_Integer n2 = FUN_selectITRASHAinterference(lFE,IFCX,l2);
890 if (n2 > 0) continue;
891
892 Standard_Real OOpar = 0.;
893 if (point) {
894 gp_Pnt p3d = BDS.Point(G).Point();
895 Standard_Real t1 = BDS.Point(G).Tolerance(); Standard_Real t2 = FUN_tool_maxtol(ES);
896 Standard_Real t = (t1 > t2) ? t1 : t2;
897 Standard_Real d = 1.e1;Standard_Boolean ok = FUN_tool_projPonE(p3d,ES,OOpar,d);
898 if (!ok) {FUN_Raise(); continue;}
899 if (d > t) {FUN_Raise(); continue;}
900 }
901 if (vertex) { // rkG == rkES
902 const TopoDS_Vertex& vG = TopoDS::Vertex(BDS.Shape(G));
903 Standard_Integer rkG = BDS.AncestorRank(G);
904
905 // modified by NIZHNY-MKK Mon Apr 2 15:38:11 2001.BEGIN
906 // if (rkG == rkSE) OOpar = BRep_Tool::Parameter(vG,ES);
907 if (rkG == rkSE) {
908 Standard_Integer hasvG = FUN_tool_orientVinE(vG,ES);
909 if(hasvG==0) {
910 continue;
911 }
912 OOpar = BRep_Tool::Parameter(vG,ES);
913 }
914 // modified by NIZHNY-MKK Mon Apr 2 15:38:30 2001.END
915 else {
916 TopoDS_Shape oov; Standard_Boolean hasoov = FUN_ds_getoov(vG,BDS,oov);
917 if (!hasoov) {
918 Standard_Real t1 = BRep_Tool::Tolerance(vG); Standard_Real t2 = FUN_tool_maxtol(ES);
919 Standard_Real t = (t1 > t2) ? t1 : t2;
920 gp_Pnt p = BRep_Tool::Pnt(vG);
921 Standard_Real parES,dd=1.e1;
922 Standard_Boolean ok = FUN_tool_projPonE(p,ES,parES,dd);
923 if (!ok) {FUN_Raise(); continue;}
924 if (dd > t) {FUN_Raise(); continue;}
925 OOpar = parES;
926 }
927 else OOpar = BRep_Tool::Parameter(TopoDS::Vertex(oov),ES);
928 }
929 }
930
931 gp_Pnt2d OOuv; Standard_Boolean ok = FUN_tool_paronEF(ES,OOpar,FCX,OOuv);
932 if (!ok) {FUN_Raise(); continue;}
933
934 TopOpeBRepDS_Transition newT;
935 // -------
936 Standard_Boolean isonper; Standard_Real par1,par2; Standard_Real factor = 1.e-4;
937 FDS_LOIinfsup(BDS,SE,par,K,G,
938 BDS.ShapeInterferences(SE),par1,par2,isonper);
939
940 TopOpeBRepTool_makeTransition MKT;
941 TopAbs_State stb,sta;
942 ok = MKT.Initialize(SE,par1,par2,par, FCX,OOuv, factor);
943 if (ok) ok = MKT.SetRest(ES,OOpar);
944 if (ok) ok = MKT.MkTonE(stb,sta);
945 if (!ok) {FUN_Raise(); continue;}
946 newT.Before(stb); newT.After(sta); newT.Index(IFCX);
947
948 Handle(TopOpeBRepDS_Interference) newI;
949 // --------
950 Standard_Boolean B = Standard_False;
951 if (vertex) B = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I)->GBound();
952 newI = MakeEPVInterference(newT,IFCX,G,par,K,TopOpeBRepDS_FACE,B);
953#ifdef DEB
954 if (trc) {cout<<"completeforSE2 on section edge "<<ISE<<" ";newI->Dump(cout);cout<<endl;}
955#endif
956 HDS->StoreInterference(newI,SE);
957 } // itfcx
958 } // tki
959 } // nse
960} // completeforSE2
961
962
963static Standard_Boolean FUN_ds_completeforSE3(const TopOpeBRepDS_DataStructure& BDS, const TopoDS_Edge& SE,
964 const TopOpeBRepDS_Kind K,
965// const Standard_Integer G,
966 const Standard_Integer ,
967 const TopOpeBRepDS_ListOfInterference& loi,
968 Standard_Real& parE, Standard_Integer& IES, Standard_Integer& ITRASHA, TopOpeBRepDS_Transition& Tr)
969{
970 if (K == TopOpeBRepDS_VERTEX) return Standard_False;
971 Standard_Integer ISE = BDS.Shape(SE);
972
973 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
974 TopOpeBRepDS_ListOfInterference lINT; Standard_Integer nINT = FUN_selectTRAORIinterference(loicopy,TopAbs_INTERNAL,lINT);
975 TopOpeBRepDS_ListOfInterference lEXT; Standard_Integer nEXT = FUN_selectTRAORIinterference(loicopy,TopAbs_EXTERNAL,lEXT);
976 Standard_Integer n1 = nINT + nEXT;
977 if (n1 < 1) return Standard_False;
978 TopOpeBRepDS_ListOfInterference l1; l1.Append(lINT); l1.Append(lEXT);
979
980 // b. I = (INT/EXT(F),G,S), F has I with G==ES
981 TopOpeBRepDS_ListOfInterference l2; Standard_Integer n2 = FUN_selectTRASHAinterference(l1,TopAbs_FACE,l2);
982 if (n2 < 1) return Standard_False;
983 Standard_Boolean okb = Standard_False;
984 for (TopOpeBRepDS_ListIteratorOfListOfInterference it2(l2); it2.More(); it2.Next()){
985 const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value();
986 okb = FDS_SIisGIofIofSBAofTofI(BDS,ISE,I2);
987 if (okb) break;
988 }
989 if (!okb) return Standard_False;
990
991 // a. I3d = IFE+IF
992 TopOpeBRepDS_ListOfInterference l2e; Standard_Integer n2e = FUN_selectSKinterference(l2,TopOpeBRepDS_EDGE,l2e);
993 TopOpeBRepDS_ListOfInterference l2f; Standard_Integer n2f = FUN_selectSKinterference(l2,TopOpeBRepDS_FACE,l2f);
994 if ((n2e == 0) || (n2f == 0)) return Standard_False;
995 Standard_Integer sI3d = l2f.First()->Support();
996 TopOpeBRepDS_ListOfInterference l3d; Standard_Integer n3d = FUN_selectITRASHAinterference(l2e,sI3d,l3d);
997 if (n3d < 1) return Standard_False;
998
999 // Tr
1000 //---
1001 const Handle(TopOpeBRepDS_Interference)& I3 = l3d.First();
1002 TopOpeBRepDS_Kind K3,ST3; Standard_Integer G3,S3; FDS_data(I3,K3,G3,ST3,S3);
1003 TopAbs_ShapeEnum tsb3,tsa3; Standard_Integer isb3,isa3; FDS_Tdata(I3,tsb3,isb3,tsa3,isa3);
1004 IES = S3; ITRASHA = isb3;
1005
1006 const TopoDS_Edge& Eline = TopoDS::Edge(BDS.Shape(IES));
1007 const TopoDS_Face& F = TopoDS::Face(BDS.Shape(ITRASHA));
1008 parE = FDS_Parameter(I3);
1009
1010 Standard_Real parline; Standard_Boolean ok = FUN_tool_parE(SE,parE,Eline,parline);
1011 if (!ok) {FUN_Raise(); return Standard_False;}
1012 gp_Pnt2d uv; ok = FUN_tool_paronEF(Eline,parline,F,uv);
1013 if (!ok) {FUN_Raise(); return Standard_False;}
1014 Standard_Real par1,par2; FUN_tool_bounds(SE,par1,par2);
1015 Standard_Real factor = 1.e-4;
1016
1017
1018 TopOpeBRepTool_makeTransition MKT; TopAbs_State stb,sta;
1019 ok = MKT.Initialize(SE,par1,par2,parE, F,uv, factor);
1020 if (ok) ok = MKT.SetRest(Eline,parline);
1021 if (ok) ok = MKT.MkTonE(stb,sta);
1022 if (!ok) {FUN_Raise(); return Standard_False;}
1023 Tr.Before(stb); Tr.After(sta); Tr.Index(ITRASHA);
1024 return Standard_True;
1025}
1026
1027// ----------------------------------------------------------------------
1028Standard_EXPORT void FUN_ds_completeforSE3(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1029// ----------------------------------------------------------------------
1030{
1031 // xpu170498 : t3 (splits of e7)
1032 // prequesitory :
1033 // edge SE - a. is tangent to FTRA on ES at G, has NO SPLIT ON FTRA (near G).
1034 // - b. has splitON FCX (FCX and FTRA share ES)
1035 // a. IFE=(T(FTRA),Gpoint,ES) && IF=(T(FTRA),Gpoint,FTRA)
1036 // T describes T3d
1037 // b. IFE=(T'(FCX),Gpoint,S) / FCX has I=(T'',SE,SS)
1038 //
1039 // purpose : when T(FTRA) is INTERNAL/EXTERNAL, the compute of spIN/spOU fails,
1040 // => compute interference I3d=IFE + IF with T==FORWARD/REVERSED.
1041
1042 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1043 Standard_Integer nse = BDS.NbSectionEdges();
1044 for (Standard_Integer i = 1; i <= nse; i++) {
1045 const TopoDS_Edge& SE = BDS.SectionEdge(i);
1046 Standard_Integer ISE = BDS.Shape(SE);
1047 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
1048#ifdef DEB
1049 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
1050 if (trc) debse3(ISE);
1051#endif
1052
1053 TopOpeBRepDS_ListOfInterference newLI; Standard_Boolean hasnewLI = Standard_False;
1054 TopOpeBRepDS_TKI tki;
1055 tki.FillOnGeometry(LI);
1056 for (tki.Init(); tki.More(); tki.Next()) {
1057
1058 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
1059 Standard_Real parE; Standard_Integer IES=0, ITRASHA=0; TopOpeBRepDS_Transition Tr;
1060 Standard_Boolean ok = FUN_ds_completeforSE3(BDS,SE,K,G,loi,parE,IES,ITRASHA,Tr);
1061
1062 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
1063 if (!ok) {newLI.Append(loicopy); continue;}
1064
1065 // delete interferences =(T(face IF),G,S)
1066 TopOpeBRepDS_ListOfInterference lIdel;
1067 FUN_selectITRASHAinterference(loicopy,ITRASHA,lIdel);
1068#ifdef DEB
1069 if (trc) {FDS_dumpLI(lIdel,"completeforSE3, delete :");}
1070#endif
1071
1072 Handle(TopOpeBRepDS_Interference) TrFE, TrFF;
1073 //--------------
1074 hasnewLI = Standard_True;
1075 TrFE = MakeEPVInterference(Tr, ISE,G,parE,K,TopOpeBRepDS_EDGE,Standard_False);
1076 TrFF = MakeEPVInterference(Tr,ITRASHA,G,parE,K,TopOpeBRepDS_FACE,Standard_False);
1077#ifdef DEB
1078 if (trc) {cout<<"completeforSE3 on section edge "<<ISE<<" ";TrFE->Dump(cout);cout<<endl;}
1079 if (trc) {cout<<"completeforSE3 on section edge "<<ISE<<" ";TrFF->Dump(cout);cout<<endl;}
1080#endif
1081
1082 newLI.Append(TrFF); newLI.Append(TrFE); newLI.Append(loicopy);
1083 } // tki
1084
1085 if (hasnewLI) {
1086 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(SE); LII.Clear();
1087 LII.Append(newLI);
1088 }
1089
1090 } //i=1..nse
1091} // completeforSE3
1092
1093// ----------------------------------------------------------------------
1094Standard_EXPORT Standard_Boolean FUN_ds_shareG
1095(const Handle(TopOpeBRepDS_HDataStructure)& HDS, const Standard_Integer iF1,const Standard_Integer iF2,
1096 const Standard_Integer iE2, const TopoDS_Edge& Esp, Standard_Boolean& shareG)
1097// ----------------------------------------------------------------------
1098// F1 sdm F2, share Esp (split of E2)
1099{
1100 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
1101 Standard_Boolean hsdm = HDS->HasSameDomain(BDS.Shape(iE2));
1102 if (!hsdm) return Standard_False;
1103
1104 const TopoDS_Face& F1 = TopoDS::Face(BDS.Shape(iF1));
1105 const TopoDS_Face& F2 = TopoDS::Face(BDS.Shape(iF2));
1106 const TopoDS_Edge& E2 = TopoDS::Edge(BDS.Shape(iE2));
1107
1108 Standard_Real tol = Precision::Confusion()*1.e3;
1109 Standard_Real f,l; FUN_tool_bounds(Esp,f,l);
1110 Standard_Real x = 0.45678; Standard_Real par = (1-x)*f + x*l;
1111 gp_Pnt P; Standard_Boolean ok = FUN_tool_value(par,Esp,P);
1112 if (!ok) return Standard_False;
1113
1114 Standard_Real d2,par2; ok = FUN_tool_projPonE(P,E2,par2,d2);
1115 if (!ok) return Standard_False;
1116 if (d2 > tol) return Standard_False;
1117
1118 gp_Vec nggeomF2; ok = FUN_tool_nggeomF(par2,E2,F2,nggeomF2);
1119 if (!ok) return Standard_False;
1120 gp_Dir nxx2; ok = FUN_tool_getxx(F2,E2,par2,nggeomF2,nxx2);
1121 if (!ok) return Standard_False;
1122
1123
1124 TopTools_IndexedMapOfShape mE1; TopExp::MapShapes(F1,TopAbs_EDGE,mE1);
1125 const TopTools_ListOfShape& sdmE1 = BDS.ShapeSameDomain(iE2);
1126 for (TopTools_ListIteratorOfListOfShape it(sdmE1); it.More(); it.Next()){
1127 const TopoDS_Edge& E1 = TopoDS::Edge(it.Value());
1128 Standard_Boolean isb = mE1.Contains(E1);
1129 if (!isb) continue;
1130
1131 Standard_Real d1,par1; ok = FUN_tool_projPonE(P,E1,par1,d1);
1132 if (!ok) continue;
1133 if (d1 > tol) continue;
1134
1135 // E1 on F1, E2 on F2, E1 and E2 share split Esp(nyi : check it)
1136 gp_Vec nggeomF1; ok = FUN_tool_nggeomF(par1,E1,F1,nggeomF1);
1137 if (!ok) return Standard_False;
1138 gp_Dir nxx1; ok = FUN_tool_getxx(F1,E1,par1,nggeomF1,nxx1);
1139 if (!ok) return Standard_False;
1140
1141#ifdef DEB
1142// Standard_Real tol = 1.e3*
1143#endif
1144 Precision::Angular();
1145 Standard_Real prod = nxx1.Dot(nxx2);
1146 shareG = (prod > 0.);
1147 return Standard_True;
1148 }
1149 return Standard_False;
1150}
1151// ----------------------------------------------------------------------
1152Standard_EXPORT Standard_Boolean FUN_ds_mkTonFsdm
1153(const Handle(TopOpeBRepDS_HDataStructure)& HDS, const Standard_Integer iF1, const Standard_Integer iF2, const Standard_Integer iE2,
1154 const Standard_Integer iEG, const Standard_Real paronEG, const TopoDS_Edge& Esp, const Standard_Boolean pardef,
1155 TopOpeBRepDS_Transition& T)
1156// ----------------------------------------------------------------------
1157// =================================
1158// prequesitory : F1 and F2 are SDSO
1159// =================================
1160// F1 sdm F2, EG has split ON F1 shared by F2
1161//
1162// EG and E2 share geometric point G (of param paronEG)
1163// pardef = Standard_True : paronEG is defined
1164// else : use Esp to find paronEG, Esp is split of EG
1165// (!! we can have EG==E2)
1166//
1167// purpose : computes 2d transition of F1 when crossing EG relative to
1168// 2dmatter(F2) limited by E2 :
1169// -> 2d FEI attached to F1 = (T(F2), G=EG, S=F2)
1170{
1171 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
1172 Standard_Boolean hsdm = HDS->HasSameDomain(BDS.Shape(iE2));
1173 if (!hsdm) return Standard_False;
1174
1175 const TopoDS_Face& F1 = TopoDS::Face(BDS.Shape(iF1));
1176 const TopoDS_Face& F2 = TopoDS::Face(BDS.Shape(iF2));
1177 const TopoDS_Edge& E2 = TopoDS::Edge(BDS.Shape(iE2));
1178 const TopoDS_Edge& EG = TopoDS::Edge(BDS.Shape(iEG));
1179
1180 Standard_Boolean EGisE2 = (iEG == iE2);
1181 Standard_Real tol = Precision::Confusion()*1.e3;
1182
1183 // beafter :
1184 // ---------
1185 Standard_Boolean ok = Standard_False;
1186 gp_Pnt P; Standard_Real parEG;
1187 if (pardef) parEG = paronEG;
1188 else {
1189 Standard_Real f,l; FUN_tool_bounds(Esp,f,l);
1190#ifdef DEB
1191 // Standard_Real x = 0.45678;
1192 // Standard_Real par = (1-x)*f + x*l;
1193#endif
1194 Standard_Real dEG; ok = FUN_tool_projPonE(P,EG,parEG,dEG);
1195 if (!ok) return Standard_False;
1196 if (dEG > tol) return Standard_False;
1197 }
1198 ok = FUN_tool_value(parEG,EG,P);
1199 if (!ok) return Standard_False;
1200 gp_Vec tgtEG ; ok = TopOpeBRepTool_TOOL::TggeomE(parEG,EG,tgtEG);
1201 if (!ok) return Standard_False;
1202 gp_Vec ngF1; ok = FUN_tool_nggeomF(parEG,EG,F1,ngF1);
1203 if (!ok) return Standard_False;
1204 gp_Vec beafter = ngF1^tgtEG;
1205
1206 // nxx2 :
1207 // ------
1208 Standard_Real par2;
1209 if (EGisE2) par2 = parEG;
1210 else {
1211 Standard_Real d2; ok = FUN_tool_projPonE(P,E2,par2,d2);
1212 if (!ok) return Standard_False;
1213 if (d2 > tol) return Standard_False;
1214 }
1215 gp_Vec ngF2; ok = FUN_tool_nggeomF(par2,E2,F2,ngF2);
1216 if (!ok) return Standard_False;
1217 gp_Dir nxx2; ok = FUN_tool_getxx(F2,E2,par2,ngF2,nxx2);
1218 if (!ok) return Standard_False;
1219
1220 // T :
1221 // ---
1222 Standard_Boolean sdmEGE2 = EGisE2;
1223 if (!sdmEGE2) sdmEGE2 = FUN_ds_sdm(BDS,EG,E2);
1224 if (!sdmEGE2) return Standard_False;
1225
1226 Standard_Real prod = beafter.Dot(nxx2);
1227 Standard_Real tola = Precision::Angular()*1.e3;
1228 ok = (Abs(1- Abs(prod)) < tola);
1229 if (!ok) return Standard_False;
1230
1231 if (prod > 0.) T = TopOpeBRepDS_Transition(TopAbs_OUT,TopAbs_IN);
1232 else T = TopOpeBRepDS_Transition(TopAbs_IN,TopAbs_OUT);
1233 return Standard_True;
1234}
1235
1236#define UNKNOWN (0)
1237#define ONSAMESHA (1)
1238#define CLOSESAME (11)
1239#define ONOPPOSHA (2)
1240#define CLOSEOPPO (22)
1241#define FORREVOPPO (222)
1242
1243Standard_EXPORT Standard_Integer FUN_ds_oriEinF(const TopOpeBRepDS_DataStructure& BDS, const TopoDS_Edge& E, const TopoDS_Shape& F,
1244 TopAbs_Orientation& O)
1245// purpose :
1246// * E is edge of F :returns orientation of E in F
1247// * E is edge of Fsd : Fsd sdm with F,
1248// returns orientation of E in F /E describes the same 2d area in F as in Fsd
1249// * !! if E is closing edge, returns CLOSESAME or CLOSEOPPO
1250{
1251 O = TopAbs_EXTERNAL;
1252 Standard_Integer rkF = BDS.AncestorRank(F);
1253 Standard_Integer rkE = BDS.AncestorRank(E);
1254
1255 const TopoDS_Edge& EE = TopoDS::Edge(E);
1256 const TopoDS_Face& FF = TopoDS::Face(F);
1257 Standard_Integer iF = BDS.Shape(F);
1258 TopAbs_Orientation oF = BDS.Shape(iF).Orientation();
1259
1260 if (rkF == rkE) {
1261 Standard_Boolean samsha = FUN_tool_orientEinFFORWARD(EE,FF,O);
1262 if (samsha) {
1263 Standard_Boolean iscE = BRep_Tool::IsClosed(EE,FF);
1264 if (iscE) return CLOSESAME;
1265 else return ONSAMESHA;
1266 }
1267 else return UNKNOWN;
1268 }
1269 else {
1270 const TopTools_ListOfShape& sdmFs = BDS.ShapeSameDomain(FF);
1271 Standard_Boolean hsdm = (sdmFs.Extent() > 0);
1272
1273 if (hsdm) {
1274 Standard_Boolean hasFOR=Standard_False, hasREV=Standard_False; // xpu120898 (PRO14785 : e36 shared by f34 & f39,
1275 // faces sdm with f16)
1276 TopOpeBRepDS_Config C = BDS.SameDomainOri(FF);
1277
1278 for (TopTools_ListIteratorOfListOfShape it(sdmFs); it.More(); it.Next()){
1279 const TopoDS_Face& Fsdm = TopoDS::Face(it.Value());
1280 Standard_Integer iFsdm = BDS.Shape(Fsdm);
1281 Standard_Integer rksdm = BDS.AncestorRank(Fsdm);
1282 if (rksdm == rkF) continue;
1283
1284 Standard_Boolean samsha = FUN_tool_orientEinFFORWARD(EE,Fsdm,O);
1285 if (!samsha) continue;
1286
1287 Standard_Boolean iscE = BRep_Tool::IsClosed(EE,Fsdm);
1288 if (iscE) return CLOSEOPPO;
1289 else {
1290 TopOpeBRepDS_Config Csdm = BDS.SameDomainOri(Fsdm);
1291 Standard_Boolean toreverse1 = (Csdm != C) && (!M_INTERNAL(O)) && (!M_EXTERNAL(O));
1292 if (toreverse1) O = TopAbs::Complement(O);
1293
1294 TopAbs_Orientation oFsdm = BDS.Shape(iFsdm).Orientation();
1295 Standard_Boolean toreverse2 = (oF != oFsdm) && (!M_INTERNAL(oFsdm)) && (!M_EXTERNAL(oFsdm));
1296 if (toreverse2) O = TopAbs::Complement(O);
1297 if (!hasFOR) hasFOR = M_FORWARD(O);
1298 if (!hasREV) hasREV = M_REVERSED(O);
1299 }
1300 } // it(sdmFs)
1301 if (hasFOR && hasREV) return FORREVOPPO;
1302 if (hasFOR || hasREV) {
1303 O = hasFOR ? TopAbs_FORWARD : TopAbs_REVERSED;
1304 return ONOPPOSHA;
1305 }
1306 }
1307 else return UNKNOWN;
1308 }
1309 return UNKNOWN;
1310}
1311
1312#define NONE (0)
1313#define EREFandESUP (2)
1314#define FIRST (1)
1315#define LAST (2)
1316static Standard_Integer FUN_EisSE2(const TopOpeBRepDS_DataStructure& BDS,
1317// const TopTools_MapOfShape& Fsdm,
1318 const TopTools_MapOfShape& ,
1319 const TopoDS_Edge& E,
1320 const Handle(TopOpeBRepDS_Interference)& I)
1321{
1322 const TopOpeBRepDS_Transition& T = I->Transition();
1323 const TopAbs_Orientation O = T.Orientation(TopAbs_IN);
1324 TopAbs_ShapeEnum SB,SA;Standard_Integer IB,IA;TopOpeBRepDS_Kind GT,ST;Standard_Integer G,S;
1325 FDS_Idata(I,SB,IB,SA,IA,GT,G,ST,S);
1326 if (GT != TopOpeBRepDS_VERTEX) return NONE;
1327 if (M_EXTERNAL(O)) return NONE;
1328
1329 // E sdm ES
1330 if (SB != TopAbs_EDGE) return NONE;
1331// BDS.Shape(S);
1332
1333 Standard_Integer rkE = BDS.AncestorRank(E);
1334 Standard_Integer rkG = BDS.AncestorRank(G);
1335 const TopoDS_Vertex& VG = TopoDS::Vertex(BDS.Shape(G));
1336 Standard_Integer Gsd; Standard_Boolean Ghsd = FUN_ds_getVsdm(BDS,G,Gsd);
1337 Standard_Integer oGinE = 0;
1338 if (Ghsd) {
1339 const TopoDS_Vertex& VGsd = TopoDS::Vertex(BDS.Shape(Gsd));
1340 if (rkE == rkG) oGinE = FUN_tool_orientVinE(VG,E);
1341 else oGinE = FUN_tool_orientVinE(VGsd,E);
1342 }
1343 else oGinE = FUN_tool_orientVinE(VG,E);
1344
1345 if (oGinE == 0) return EREFandESUP; // G in IN E
1346
1347 Standard_Boolean noshare = ((oGinE == LAST) && M_FORWARD(O));
1348 noshare = noshare || ((oGinE == FIRST) && M_REVERSED(O));
1349 if (noshare) return NONE;
1350
1351 if (SB == TopAbs_EDGE) {// E sdm edge(ST)
1352 if (!Ghsd) return EREFandESUP;
1353 return EREFandESUP;
1354 }
1355
1356 return NONE;
1357}
1358Standard_EXPORT void FUN_ds_FillSDMFaces(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1359{
1360 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1361 Standard_Integer ns = BDS.NbShapes();
1362
1363 for (Standard_Integer i= 1; i <= ns; i++) {
1364 const TopoDS_Shape& S = BDS.Shape(i);
1365 if (S.ShapeType() != TopAbs_FACE) continue;
1366
1367 Standard_Integer rkS = BDS.AncestorRank(S);
1368 TopTools_MapOfShape Fsdm;
1369 TopTools_ListIteratorOfListOfShape itf(BDS.ShapeSameDomain(S));
1370 for (; itf.More(); itf.Next()){
1371 const TopoDS_Shape& f = itf.Value();
1372 Standard_Integer rkf = BDS.AncestorRank(f);
1373 if (rkf != rkS) Fsdm.Add(f);
1374 }
1375 Standard_Boolean hsd = (Fsdm.Extent() > 0);
1376 if (!hsd) continue;
1377
1378 TopExp_Explorer ex(S, TopAbs_EDGE);
1379 for (; ex.More(); ex.Next()){
1380 const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
1381 Standard_Boolean hase = BDS.HasShape(E);
1382 if (!hase) continue;
1383 Standard_Boolean isse = BDS.IsSectionEdge(E);
1384 if (isse) continue;
1385 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(E);
1386 Standard_Integer nI = LI.Extent();
1387 if (nI < 1) continue;
1388
1389 TopOpeBRepDS_ListIteratorOfListOfInterference it;
1390 for (it.Initialize(LI); it.More(); it.Next()){
1391 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
1392 Standard_Integer isSE2 = FUN_EisSE2(BDS,Fsdm,E,I);
1393 if (isSE2 == NONE) continue;
1394 BDS.AddSectionEdge(E);
1395 if (isSE2 == EREFandESUP) {
1396 Standard_Integer ST = I->Support();
1397 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(ST));
1398 BDS.AddSectionEdge(ES);
1399 }
1400 break;
1401 }
1402 } // ex(S, TopAbs_EDGE);
1403 } // i = i..ns
1404}
1405
1406Standard_EXPORT void FUN_ds_addSEsdm1d(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1407{
1408 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1409 Standard_Integer ns = BDS.NbShapes();
1410 for (Standard_Integer i= 1; i <= ns; i++) {
1411#ifdef DEB
1412 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(i);
1413 if (trc) debsdm1(i);
1414#endif
1415 const TopoDS_Shape& S = BDS.Shape(i);
1416 if (S.ShapeType() != TopAbs_EDGE) continue;
1417 const TopoDS_Edge& E = TopoDS::Edge(S);
1418 Standard_Boolean dgE = BRep_Tool::Degenerated(E);
1419 if (dgE) continue;
1420
1421 Standard_Boolean isse = BDS.IsSectionEdge(E);
1422 if (isse) continue;
1423 Standard_Integer rkE = BDS.AncestorRank(E);
1424 if (rkE != 1) continue;
1425
1426 Standard_Boolean shareG = Standard_False;
1427 TopTools_ListOfShape lsd;
1428 TopOpeBRepDS_TOOL::EShareG(HDS,E,lsd);
1429 TopTools_ListIteratorOfListOfShape itsd(lsd);
1430 if (itsd.More()) shareG = Standard_True;
1431 for (; itsd.More(); itsd.Next()) BDS.AddSectionEdge(TopoDS::Edge(itsd.Value()));
1432 if (shareG) BDS.AddSectionEdge(E);
1433 }//i=1..ns
1434}// FUN_ds_addSEsdm1d
1435
1436Standard_EXPORT Standard_Integer FUN_ds_hasI2d(
1437// const Standard_Integer EIX,
1438 const Standard_Integer ,
1439 const TopOpeBRepDS_ListOfInterference& LLI,
1440 TopOpeBRepDS_ListOfInterference& LI2d)
1441{
1442 // LI : attached to EIX at given G
1443 // recall : I3d if I1=(T(FTRA),G,FTRA) && I2=(T(FTRA),G,E)
1444 // I2d if only I=(T(FTRA),G,E) (=>EIX is on FF sdm with FTRA)
1445
1446 TopOpeBRepDS_ListOfInterference LI; FDS_assign(LLI,LI);
1447 TopOpeBRepDS_ListOfInterference L1dE; FUN_selectTRASHAinterference(LI,TopAbs_EDGE,L1dE);
1448 TopOpeBRepDS_ListOfInterference LIF;FUN_selectSKinterference(LI,TopOpeBRepDS_FACE,LIF);
1449 TopOpeBRepDS_ListOfInterference LIE;FUN_selectSKinterference(LI,TopOpeBRepDS_EDGE,LIE);
1450 LI.Append(L1dE);
1451 TopOpeBRepDS_ListIteratorOfListOfInterference itE(LIE);
1452 for (; itE.More(); itE.Next()){
1453 const Handle(TopOpeBRepDS_Interference)& IE = itE.Value();
1454 TopOpeBRepDS_Kind GTE,STE; Standard_Integer GE,SE; FDS_data(IE,GTE,GE,STE,SE);
1455 TopAbs_ShapeEnum tsb,tsa; Standard_Integer isb,isa; FDS_Tdata(IE,tsb,isb,tsa,isa);
1456
1457 TopOpeBRepDS_ListIteratorOfListOfInterference itF(LIF);
1458 Standard_Boolean is3d = Standard_False;
1459 for (; itF.More(); itF.Next()){
1460 const Handle(TopOpeBRepDS_Interference)& IF = itF.Value();
1461 TopOpeBRepDS_Kind GTF,STF; Standard_Integer GF,SF; FDS_data(IF,GTF,GF,STF,SF);
1462 if (GE != GF) continue;
1463 if (SF==isb) {
1464 is3d = Standard_True;
1465 break;
1466 }
1467 } // itF
1468 if (!is3d) LI2d.Append(IE);
1469 } // itE
1470 Standard_Integer nLI2d = LI2d.Extent();
1471 return nLI2d;
1472}
1473
1474// ----------------------------------------------------------------------
1475Standard_EXPORT void FUN_ds_completeforSE4(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1476// ----------------------------------------------------------------------
1477// xpu160698 : section edge SE intersects ES at G=point
1478// ES closing edge on FTRA
1479// we need to have transitions :
1480// T1=(OU/IN(FTRA),GP,ES)
1481// T2=(IN/OU(FTRA),GP,ES), for the compute of splitON
1482// PRO6965, (SE=e13,F=f6,ES=e12)
1483{
1484 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1485 Standard_Integer nse = BDS.NbSectionEdges();
1486 for (Standard_Integer i = 1; i <= nse; i++) {
1487 const TopoDS_Edge& SE = BDS.SectionEdge(i);
1488#ifdef DEB
1489 Standard_Integer ISE =
1490#endif
1491 BDS.Shape(SE);
1492 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
1493#ifdef DEB
1494 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
1495 if (trc) debse4(ISE);
1496#endif
1497
1498 TopOpeBRepDS_ListOfInterference newLI;
1499 TopOpeBRepDS_TKI tki;
1500 tki.FillOnGeometry(LI);
1501 for (tki.Init(); tki.More(); tki.Next()) {
1502 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
1503 if (K != TopOpeBRepDS_POINT) continue;
1504
1505 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
1506 TopOpeBRepDS_ListOfInterference l1;
1507 FUN_selectSKinterference(loicopy,TopOpeBRepDS_EDGE,l1);
1508 TopOpeBRepDS_ListOfInterference l2; Standard_Integer n2 = FUN_selectTRASHAinterference(l1,TopAbs_FACE,l2);
1509 if (n2 < 1) continue;
1510
1511 const Handle(TopOpeBRepDS_Interference)& I = l2.First();
1512 TopOpeBRepDS_Kind GT,ST; Standard_Integer S; FDS_data(I,GT,G,ST,S);
1513 TopAbs_ShapeEnum tsb,tsa; Standard_Integer isb,isa; FDS_Tdata(I,tsb,isb,tsa,isa);
1514 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(S));
1515 const TopoDS_Face& FTRA = TopoDS::Face(BDS.Shape(isb));
1516
1517 Standard_Boolean closing = FUN_tool_IsClosingE(ES,FTRA,FTRA);
1518 if (!closing) continue;
1519
1520 Standard_Boolean hasFOR=Standard_False,hasREV=Standard_False;
1521 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(l2); it.More(); it.Next()){
1522 const Handle(TopOpeBRepDS_Interference)& I2 = it.Value();
1523 TopOpeBRepDS_Kind GT2,ST2; Standard_Integer G2,S2; FDS_data(I2,GT2,G2,ST2,S2);
1524 TopAbs_ShapeEnum tsb2,tsa2; Standard_Integer isb2,isa2; FDS_Tdata(I2,tsb2,isb2,tsa2,isa2);
1525 Standard_Boolean error = (S2 != S) || (isb2 != isb);
1526 if (error) return; // nyi raise
1527 TopAbs_Orientation O2 = I2->Transition().Orientation(TopAbs_IN);
1528 if (!hasFOR) hasFOR = M_FORWARD(O2);
1529 if (!hasREV) hasREV = M_REVERSED(O2);
1530 }
1531 if (!hasFOR && !hasREV) continue;
1532 if ( hasFOR && hasREV ) continue;
1533 TopAbs_Orientation newO = hasFOR ? TopAbs_REVERSED : TopAbs_FORWARD;
1534 TopOpeBRepDS_Transition newT(newO); newT.Index(isb);
1535 Standard_Real par = FDS_Parameter(I);
1536 Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(newT,S,G,par,K,Standard_False);
1537#ifdef DEB
1538 if (trc) {cout<<"completeforSE4 on section edge "<<ISE<<" ";newI->Dump(cout);cout<<endl;}
1539#endif
1540 HDS->StoreInterference(newI,SE);
1541 } // tki
1542 } // i=1..nse
1543}//completeforSE4
1544
1545// ----------------------------------------------------------------------
1546Standard_EXPORT void FUN_ds_completeforSE5(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1547// ----------------------------------------------------------------------
1548// xpu190698 : section edge SE has spON face F,
1549// FCX is tangent to F at G (FCX and F are on same shape)
1550// SE has I = (T(F),G,S), T=(OUT,OUT)
1551// I' = (T'(Fsd),G,Sedge), T' FORWARD or REVERSED
1552// T describes states (ON/OUT) or (OUT/ON)
1553// PRO12695 (SE20,P1,FCX16,F29)
1554// xpu131098 : SE has I = (T(F),G,S), T=(IN,IN)
1555// I' = (T'(Fsd),G,Sedge), T' FORWARD or REVERSED
1556// T describes states (ON/IN) or (OUT/IN)
1557//
1558// recall : for the compute of spOU/IN(ES), we need to interferences
1559// TskFACE = (T(FF),G,FF) T=FORWARD/REVERSED
1560// cto 902 D9 (SE17,P4,F29,FCX4)
1561{
1562 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1563 Standard_Integer nse = BDS.NbSectionEdges();
1564 for (Standard_Integer i = 1; i <= nse; i++) {
1565 const TopoDS_Edge& SE = BDS.SectionEdge(i);
1566#ifdef DEB
1567 Standard_Integer ISE =
1568#endif
1569 BDS.Shape(SE);
1570 const TopOpeBRepDS_ListOfInterference& LOI = BDS.ShapeInterferences(SE);
1571#ifdef DEB
1572 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
1573 if (trc) debse5(ISE);
1574#endif
1575
1576 // xpu020399 : cto901A2 (e26)
1577 TopOpeBRepDS_ListOfInterference LOIc; FDS_copy(LOI,LOIc);
1578 TopOpeBRepDS_ListOfInterference LI; Standard_Integer nI = FUN_selectSKinterference(LOIc,TopOpeBRepDS_EDGE,LI);
1579 if (nI < 1) continue;
1580
1581 TopOpeBRepDS_ListOfInterference newLI; Standard_Boolean hasnewLI = Standard_False;
1582 TopOpeBRepDS_TKI tki;
1583 tki.FillOnGeometry(LI);
1584 for (tki.Init(); tki.More(); tki.Next()) {
1585 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
1586 if (K != TopOpeBRepDS_POINT) {FDS_copy(loi,newLI); continue;}
1587
1588 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
1589 TopOpeBRepDS_ListOfInterference lext; Standard_Integer iext = FUN_selectTRAORIinterference(loicopy,TopAbs_EXTERNAL,lext);
1590 Standard_Boolean hasext = (iext > 0);
1591 TopOpeBRepDS_ListOfInterference lint; Standard_Integer iint = FUN_selectTRAORIinterference(loicopy,TopAbs_INTERNAL,lint);
1592 Standard_Boolean hasint = (iint > 0);
1593 if (!hasext && !hasint) {FDS_copy(loi,newLI); continue;}
1594 if (hasext && hasint) {FDS_copy(loi,newLI); continue;} // nyiFUN_RAISE : incoherent data
1595 // ------------------------------
1596
1597 // NYI : only select among 2dI!!! ******************************
1598 TopOpeBRepDS_ListOfInterference lfor; Standard_Integer ifor = FUN_selectTRAORIinterference(loicopy,TopAbs_FORWARD,lfor);
1599 TopOpeBRepDS_ListOfInterference lrev; Standard_Integer irev = FUN_selectTRAORIinterference(loicopy,TopAbs_REVERSED,lrev);
1600 Standard_Boolean hasrev=(irev > 0), hasfor=(ifor > 0);
1601 if (!hasrev && !hasfor) {FDS_copy(loi,newLI); continue;}
1602 if (hasrev && hasfor) {FDS_copy(loi,newLI); continue;} // nyiFUN_RAISE : incoherent data
1603
1604 // newO :
1605 // -----
1606 Handle(TopOpeBRepDS_Interference) I2d = hasfor ? lfor.First() : lrev.First();
1607 Standard_Integer S2 = I2d->Support(); Standard_Integer iF2 = I2d->Transition().Index();
1608 const TopoDS_Edge& E2 = TopoDS::Edge(BDS.Shape(S2)); Standard_Real parSE = FDS_Parameter(I2d);
1609 const TopoDS_Face& F2 = TopoDS::Face(BDS.Shape(iF2));
1610 Standard_Real parE2; Standard_Boolean ok = FUN_tool_parE(SE,parSE,E2,parE2);
1611 if (!ok) return;
1612 gp_Pnt2d uv2; ok = FUN_tool_paronEF(E2,parE2,F2,uv2);
1613 if (!ok) return;
1614 gp_Dir ngF2 = FUN_tool_nggeomF(uv2,F2);
1615 gp_Dir xxF2; ok = FUN_tool_getxx(F2,E2,parE2,ngF2,xxF2);
1616 if (!ok) return;
1617
1618 Handle(TopOpeBRepDS_Interference) I3d = hasext ? lext.First() : lint.First();
1619 Standard_Integer iF3 = I3d->Transition().Index();
1620 const TopoDS_Face& F3 = TopoDS::Face(BDS.Shape(iF3));
1621 // recall : G is a point => E2 = edge(S3) (I3d : {(T,G,S3),(T,G,F3)})
1622 gp_Pnt2d uv3; ok = FUN_tool_paronEF(E2,parE2,F3,uv3);
1623 if (!ok) return;
1624 gp_Dir ngF3 = FUN_tool_nggeomF(uv3,F3);
1625 gp_Dir xxF3; ok = FUN_tool_getxx(F3,E2,parE2,ngF3,xxF3);
1626 if (!ok) return;
1627
1628 Standard_Real dot = xxF2.Dot(xxF3);
1629 Standard_Boolean positive = (dot > 0); // as F and FCX are tangent, dot= +1 or -1
1630 if (positive) continue;
1631
1632 TopAbs_Orientation newO = hasfor ? TopAbs_FORWARD : TopAbs_REVERSED;
1633 if (hasint) newO = TopAbs::Complement(newO);
1634
1635 TopOpeBRepDS_ListIteratorOfListOfInterference it;
1636 if (hasint) it.Initialize(lint);
1637 else it.Initialize(lext);
1638 for (; it.More(); it.Next()){
1639 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
1640 Handle(TopOpeBRepDS_Interference) newI = I; newI->ChangeTransition().Set(newO);
1641#ifdef DEB
1642 if (trc) {cout<<"completeforSE5 se"<<ISE<<"->";newI->Dump(cout);cout<<endl;}
1643#endif
1644 newLI.Append(I);
1645 hasnewLI = Standard_True;
1646 } // it
1647 newLI.Append(lrev);
1648 newLI.Append(lfor);
1649 newLI.Append(loicopy);
1650 } // tki
1651 if (hasnewLI) {
1652 newLI.Append(LOIc);
1653 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(SE); LII.Clear();
1654 LII.Append(newLI);
1655 }
1656 } // i=1..nse
1657}//completeforSE5
1658
1659// ----------------------------------------------------------------------
1660Standard_EXPORT void FUN_ds_completeforSE6(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1661// ----------------------------------------------------------------------
1662// xpu280798 : - section edge E sdm3d Esd,
1663// - E has I2d(T(F),VG,E'),
1664// - VG vertex of Esd, VG not sdm
1665// - Esd edge of F
1666// => add newI1d(newT(Esd),VG,Esd)
1667// cto902B4 (e15,v22)
1668{
1669 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1670 Standard_Integer nse = BDS.NbSectionEdges();
1671 for (Standard_Integer i = 1; i <= nse; i++) {
1672 const TopoDS_Edge& SE = BDS.SectionEdge(i);
1673 Standard_Integer ISE = BDS.Shape(SE);
1674#ifdef DEB
1675 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
1676 if (trc) debse6(ISE);
1677#endif
1678
1679 TopTools_ListOfShape lEsd3d; Standard_Boolean hassd3d = FDS_HasSameDomain3d(BDS,SE,&lEsd3d);
1680 if (!hassd3d) continue;
1681
1682 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
1683 TopOpeBRepDS_ListOfInterference LIcopy;
1684 TopOpeBRepDS_ListOfInterference LIa; FDS_assign(LI,LIcopy); Standard_Integer na = FUN_selectGKinterference(LIcopy,TopOpeBRepDS_VERTEX,LIa);
1685 if (na == 0) continue;
1686 TopOpeBRepDS_ListOfInterference LIb;
1687 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LIa); it.More(); it.Next()){
1688 const Handle(TopOpeBRepDS_Interference)& Ia = it.Value();
1689 Standard_Integer G = Ia->Geometry();
1690 TopoDS_Shape vGsd; Standard_Boolean hassd = FUN_ds_getoov(BDS.Shape(G), HDS, vGsd);
1691 if (!hassd) LIb.Append(Ia);
1692 }
1693
1694 TopOpeBRepDS_ListOfInterference l2dFE; FDS_assign(LIb,LIcopy);
1695#ifdef DEB
1696// Standard_Integer n2d =
1697#endif
1698 FUN_ds_hasI2d(ISE,LIcopy,l2dFE);
1699 TopOpeBRepDS_ListOfInterference l1dE; FDS_assign(LIb,LIcopy);
1700#ifdef DEB
1701// Standard_Integer n1d =
1702#endif
1703 FUN_selectTRASHAinterference(LIcopy,TopAbs_EDGE,l1dE);
1704
1705 // attached to SE : l1dE = {I1d=(T(Esd),vG,Esd) / vG !hsd}
1706 // l2dFE = {I2dF=(T(F),vG,E) / vG !hsd}
1707
1708 for (TopTools_ListIteratorOfListOfShape itsd3(lEsd3d); itsd3.More(); itsd3.Next()){
1709 const TopoDS_Edge& Esd = TopoDS::Edge(itsd3.Value());
1710 TopoDS_Vertex vf,vl; TopExp::Vertices(Esd,vf,vl);
1711 Standard_Boolean degen = BRep_Tool::Degenerated(Esd);
1712 if (degen) continue;
1713
1714 Standard_Boolean closed = vf.IsSame(vl);
1715 Standard_Integer iEsd = BDS.Shape(Esd);
1716 Standard_Integer ivf = BDS.Shape(vf);
1717 Standard_Integer ivl = BDS.Shape(vl);
1718
1719 for (Standard_Integer iv = 1; iv <= 2; iv++) {
1720 Standard_Integer G = (iv == 1)? ivf : ivl;
1721 if (G == 0) continue;
1722 const TopoDS_Vertex& vG = TopoDS::Vertex(BDS.Shape(G));
1723 TopoDS_Shape vGsd; Standard_Boolean hassd = FUN_ds_getoov(vG, HDS, vGsd);
1724 if (hassd) continue;
1725
1726 TopOpeBRepDS_ListOfInterference l1dG;
1727 FUN_selectGIinterference(l1dE,G,l1dG);
1728 TopOpeBRepDS_ListOfInterference l2dG; Standard_Integer n2dG = FUN_selectGIinterference(l2dFE,G,l2dG);
1729 if (n2dG == 0) continue; // no 2dI at G
1730
1731 TopOpeBRepDS_ListOfInterference l1dGEsd; Standard_Integer n1dGEsd = FUN_selectITRASHAinterference(l1dG,iEsd,l1dGEsd);
1732 if (n1dGEsd != 0) continue; // 1dI(Esd) at G exists already
1733
1734 for (TopOpeBRepDS_ListIteratorOfListOfInterference it2d(l2dG); it2d.More(); it2d.Next()){
1735 const Handle(TopOpeBRepDS_Interference)& I2d = it2d.Value();
1736 Standard_Integer iTRASHA = I2d->Transition().IndexBefore();
1737 TopAbs_Orientation O = I2d->Transition().Orientation(TopAbs_IN);
1738 const TopoDS_Face& F = TopoDS::Face(BDS.Shape(iTRASHA));
1739 TopAbs_Orientation dum; Standard_Boolean EsdofF = FUN_tool_orientEinF(Esd,F,dum);
1740 if (!EsdofF) continue;
1741
1742 // we found I2d = (T(F),vG,E'), vG is vertex of Esd, vG !hsdm, Esd is edge of F
1743 // compute newI1d=(newT(Esd),vG,Esd)
1744 TopOpeBRepDS_Transition newT(TopAbs_OUT,TopAbs_OUT, TopAbs_EDGE,TopAbs_EDGE);
1745 Standard_Real parE = FDS_Parameter(I2d);
1746 if (closed) newT.Set(TopAbs_INTERNAL);
1747 else {
1748 if (M_FORWARD(O) || M_REVERSED(O)) {newT.Set(O);}
1749 else if (M_EXTERNAL(O)) {newT.Set(O);}
1750 else if (M_INTERNAL(O)) {
1751 Standard_Real parEsd = BRep_Tool::Parameter(vG,Esd);
1752 gp_Vec tgEsd; Standard_Boolean ok = TopOpeBRepTool_TOOL::TggeomE(parEsd,Esd,tgEsd); // dir
1753 gp_Vec tgE ; ok = TopOpeBRepTool_TOOL::TggeomE(parE,SE,tgE); // dir
1754 Standard_Real dot = tgEsd.Dot(tgE);
1755#ifdef DEB
1756 Standard_Real tola =
1757#endif
1758 Precision::Angular();
1759#ifdef DEB
1760 if (Abs(dot) < tola) Standard_Failure::Raise("completeforSE6");
1761#endif
1762 Standard_Boolean SO = (dot > 0.);
1763 Standard_Boolean isvf = (iv == 1);
1764 Standard_Boolean isforw = (SO && isvf) || (!SO && !isvf);
1765 if (isforw) {newT.Set(TopAbs_FORWARD);}
1766 else {newT.Set(TopAbs_REVERSED);}
1767 }
1768 }
1769 newT.Index(iEsd);
1770 Handle(TopOpeBRepDS_Interference) newI1d = MakeEPVInterference(newT,iEsd,G,parE,TopOpeBRepDS_VERTEX,Standard_False);
1771#ifdef DEB
1772 if (trc) {cout<<"completeforS61 on section edge "<<ISE<<" ";newI1d->Dump(cout);cout<<endl;}
1773#endif
1774 HDS->StoreInterference(newI1d,SE);
1775 } // it2d(l2dFE)
1776
1777 }
1778 } //itsd3
1779
1780 } //i=1..nse
1781}// completeforSE6
1782
1783// ----------------------------------------------------------------------
1784Standard_EXPORT void FUN_ds_completeforE7(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1785// ----------------------------------------------------------------------
1786// xpu130898 : attached to edge E, lI3d = {I=(FOR/REV(F),G,F)}
1787// reduction of lI3d if it describes INTERNAL/EXTERNAL transitions
1788// purpose : I3dFOR/REV => faulty spIN/OU of E on G
1789// CTS21199 (E6, G=v7/p3, FTR=f5)
1790{
1791 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1792 Standard_Integer ns = BDS.NbShapes();
1793 for (Standard_Integer i = 1; i <= ns; i++) {
1794 const TopoDS_Shape& EE = BDS.Shape(i);
1795 if (EE.ShapeType() != TopAbs_EDGE) continue;
1796
1797 const TopoDS_Edge& E = TopoDS::Edge(EE);
1798 Standard_Boolean isdgE = BRep_Tool::Degenerated(E);
1799 if (isdgE) continue;
1800
1801#ifdef DEB
1802 Standard_Integer IE =
1803#endif
1804 BDS.Shape(E);
1805#ifdef DEB
1806 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(IE);
1807 if (trc) debe7(IE);
1808#endif
1809 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(E);
1810
1811 TopOpeBRepDS_TKI tki;
1812 tki.FillOnGeometry(LI);
1813 for (tki.Init(); tki.More(); tki.Next()) {
1814 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
1815 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
1816 TopOpeBRepDS_ListOfInterference l1;
1817#ifdef DEB
1818// Standard_Integer n1 =
1819#endif
1820 FUN_selectSKinterference(loicopy,TopOpeBRepDS_FACE,l1);
1821 TopOpeBRepDS_ListOfInterference lFOR; Standard_Integer nFOR = FUN_selectTRAORIinterference(l1,TopAbs_FORWARD,lFOR);
1822 TopOpeBRepDS_ListOfInterference lREV; Standard_Integer nREV = FUN_selectTRAORIinterference(l1,TopAbs_REVERSED,lREV);
431258f7 1823 if ((nFOR == 0) || (nREV == 0)) continue;
7fd59977 1824
1825 TopOpeBRepDS_ListOfInterference lnewI; Standard_Integer iFS=0;
1826 TopOpeBRepDS_ListIteratorOfListOfInterference it(lFOR);
1827 for (; it.More(); it.Next()){
1828 const Handle(TopOpeBRepDS_Interference)& IFOR = it.Value();
1829 Standard_Integer IFS = IFOR->Support(); const TopoDS_Face& FS = TopoDS::Face(BDS.Shape(IFS));
1830 TopOpeBRepDS_ListOfInterference lFS; Standard_Integer nFS = FUN_selectSIinterference(loicopy,IFS,lREV);
1831 if (nFS == 0) continue;
1832
1833 TopOpeBRepDS_ListOfInterference lFSE; Standard_Integer nFSE = FUN_selectITRASHAinterference(loicopy,IFS,lFSE);
1834 Standard_Real par = FDS_Parameter(IFOR);
1835 Standard_Boolean isonper; Standard_Real par1,par2; Standard_Real factor = 1.e-4;
1836 FDS_LOIinfsup(BDS,E,par,K,G,BDS.ShapeInterferences(E),par1,par2,isonper);
1837
1838 TopOpeBRepDS_Transition newT;
1839 // -------
1840 // we have IFOR=(FORWARD(FS),G,FS) + IREV=(REVERSED(FS),G,FS)
1841 Standard_Integer IES = 0;
1842 if (nFSE == 0) {
1843 gp_Pnt2d uvFS; Standard_Boolean ok = FUN_tool_parF(E,par,FS,uvFS);
1844 if (!ok) {FUN_Raise(); continue;}
1845
1846 TopOpeBRepTool_makeTransition MKT; TopAbs_State stb,sta;
1847 ok = MKT.Initialize(E,par1,par2,par, FS,uvFS, factor);
1848 if (ok) ok = MKT.MkTonE(stb,sta);
1849 if (!ok) {FUN_Raise(); continue;}
1850 newT.Before(stb); newT.After(sta);
1851 }
1852 else {
1853 IES = lFSE.First()->Support();
1854 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(IES));
1855 Standard_Real parES; Standard_Boolean ok = FUN_tool_parE(E,par,ES,parES);
1856 if (!ok) {FUN_Raise(); continue;}
1857 gp_Pnt2d uvFS; ok = FUN_tool_paronEF(ES,parES,FS,uvFS);
1858 if (!ok) {FUN_Raise(); continue;}
1859
1860 TopOpeBRepTool_makeTransition MKT; TopAbs_State stb,sta;
1861 ok = MKT.Initialize(E,par1,par2,par, FS,uvFS, factor);
1862 if (ok) ok = MKT.SetRest(ES,parES);
1863 if (ok) ok = MKT.MkTonE(stb,sta);
1864 if (!ok) {FUN_Raise(); continue;}
1865 newT.Before(stb); newT.After(sta);
1866 }
1867
1868 // newI :
1869 //------
1870 iFS = IFS;
1871 newT.Index(IFS);
1872 Standard_Boolean B = Standard_False;
1873 if (K == TopOpeBRepDS_VERTEX) B = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(IFOR)->GBound();
1874 Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(newT,IFS,G,par,K,TopOpeBRepDS_FACE,B);
1875 lnewI.Append(newI);
1876 if (nFSE != 0) {
1877 Handle(TopOpeBRepDS_Interference) newIFE = MakeEPVInterference(newT,IES,G,par,K,TopOpeBRepDS_EDGE,B);
1878 lnewI.Append(newIFE);
1879 }
1880 } // it(lFOR)
1881
1882 if (iFS != 0) {
1883 TopOpeBRepDS_ListOfInterference& loii = tki.ChangeValue(K,G);
1884 TopOpeBRepDS_ListOfInterference lEFS;
1885#ifdef DEB
1886// Standard_Integer nIFS =
1887#endif
1888 FUN_selectITRASHAinterference(loii,iFS,lEFS);
1889 for (TopOpeBRepDS_ListIteratorOfListOfInterference iti(lnewI); iti.More(); iti.Next()) {
1890 Handle(TopOpeBRepDS_Interference) newI = iti.Value();
1891 loii.Append(newI);
1892#ifdef DEB
1893 if (trc) {cout<<"completeforE7 on edge "<<IE<<" ";newI->Dump(cout);cout<<endl;}
1894#endif
1895 }
1896 }
1897 } // tki
1898
1899 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(E);
1900 LII.Clear();
1901 for (tki.Init(); tki.More(); tki.Next()) {
1902 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
1903 FDS_copy(loi,LII);
1904 }
1905 } //i = 1..ns
1906} //completeforE7
1907
1908// ----------------------------------------------------------------------
1909Standard_EXPORT void FUN_ds_completeforSE8(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1910// ----------------------------------------------------------------------
1911// xpu020998 : Attached to section edge SE :
1912// - {I1d=(Tr(Esd),vG,Esd), I2d=(Tr(F),vG,E)}
1913// - E and Esd are F edges
1914// I2d may be incomplete, "reduce" 2d/1d -> {I1d,newI2d}
1915// cto902A6 (ES5,Esd10,vG7,F35)
1916// prequesitory : A vertex is shared by at most 2 edges in the same face.
1917// An edge is shared by at most 2 faces of same rank.
1918{
1919 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1920 Standard_Integer nse = BDS.NbSectionEdges();
1921
1922 for (Standard_Integer i = 1; i <= nse; i++) {
1923 const TopoDS_Edge& SE = BDS.SectionEdge(i);
1924 Standard_Integer ISE = BDS.Shape(SE);
1925 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
1926#ifdef DEB
1927 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
1928 if (trc) debse8(ISE);
1929#endif
1930
1931 Standard_Boolean hasnew = Standard_False;
1932 TopOpeBRepDS_TKI tki;
1933 tki.FillOnGeometry(LI);
1934 for (tki.Init(); tki.More(); tki.Next()) {
1935 TopOpeBRepDS_Kind KK; Standard_Integer GG; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(KK,GG);
1936 Standard_Boolean isvertex = (KK == TopOpeBRepDS_VERTEX);
1937#ifdef DEB
1938// Standard_Boolean ispoint = (KK == TopOpeBRepDS_POINT);
1939#endif
1940 if (isvertex) {
1941 Standard_Boolean Ghsdm = HDS->HasSameDomain(BDS.Shape(GG));
1942 if (Ghsdm) continue;
1943 }
1944 // li -> l1dE + l2dFE + lFE(<=>l3dFE) + li(<=>lFF)
1945 TopOpeBRepDS_ListOfInterference li; FDS_assign(loi,li);
1946 TopOpeBRepDS_ListOfInterference l1dE; Standard_Integer n1d = FUN_selectTRASHAinterference(li,TopAbs_EDGE,l1dE); // li->l1dE+li(<=>lF?)
1947 TopOpeBRepDS_ListOfInterference lFE;
1948#ifdef DEB
1949// Standard_Integer nFE =
1950#endif
1951 FUN_selectSKinterference(li,TopOpeBRepDS_EDGE,lFE); // li(<=>lF?)->lFE+li(<=>lFF)
1952 TopOpeBRepDS_ListOfInterference l2dFE; Standard_Integer n2d = FUN_selectpure2dI(li,lFE,l2dFE); // lFE->l2dFE+lFE(<=>l3dFE)
1953#ifdef DEB
1954// Standard_Integer n3d = lFE.Extent();
1955#endif
1956
1957 Standard_Boolean redu2d = (n1d > 0)&&(n2d > 0);
1958 // -------------------------------
1959 if (redu2d) { // {I1d=(Tr(Esd),vG,Esd), I2d=(Tr(F),vG,E)}
1960 TopOpeBRepDS_ListIteratorOfListOfInterference it(l2dFE); TopOpeBRepDS_ListOfInterference al2dFE;
1961 while (it.More()) {
1962 Handle(TopOpeBRepDS_Interference)& I2dFE = it.Value();
1963 TopOpeBRepDS_Transition newT2d; Standard_Boolean ok = FUN_ds_redu2d1d(BDS,ISE,I2dFE,l1dE, newT2d);
1964 if (!ok) {it.Next(); continue;}
1965 I2dFE->ChangeTransition() = newT2d; al2dFE.Append(I2dFE);
1966#ifdef DEB
1967 if (trc) {cout<<"SE8 -> on SE"<<ISE<<" reducedI :";I2dFE->Dump(cout);cout<<endl;}
1968#endif
1969 l2dFE.Remove(it);
1970 }
1971 l2dFE.Append(al2dFE);
1972 } // redu2d
1973
1974 TopOpeBRepDS_ListOfInterference& loii = tki.ChangeValue(KK,GG);
1975 loii.Clear();
1976 loii.Append(l1dE); loii.Append(lFE); loii.Append(l2dFE); loii.Append(li);
1977 }// tki
1978
1979 if (!hasnew) continue;
1980 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(SE);
1981 LII.Clear();
1982 for (tki.Init(); tki.More(); tki.Next()) {
1983 TopOpeBRepDS_Kind KK; Standard_Integer GG; TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(KK,GG);
1984 LII.Append(loi);
1985 }
1986 }// i=1..nse
1987}// completeforSE8
1988
1989// ----------------------------------------------------------------------
1990Standard_EXPORT void FUN_ds_completeforSE9(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1991// ----------------------------------------------------------------------
1992// xpu011098 : CTS21180(ES13)
1993// purpose : ES Section edge, sdm with EsdSE={Esd}, ES has no interference
1994// compute interferences for ES.
1995{
1996 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1997 Standard_Integer nse = BDS.NbSectionEdges();
1998
1999 for (Standard_Integer i = 1; i <= nse; i++) {
2000 const TopoDS_Edge& SE = BDS.SectionEdge(i);
2001 Standard_Integer rkSE = BDS.AncestorRank(SE);
2002 Standard_Integer ISE = BDS.Shape(SE);
2003#ifdef DEB
2004 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
2005 if (trc) debse9(ISE);
2006#endif
2007 Standard_Boolean hsd = HDS->HasSameDomain(SE);
2008 if (!hsd) continue;
2009 if (!BDS.ShapeInterferences(SE).IsEmpty()) continue;
2010
2011 const TopTools_ListOfShape& EsdSE = BDS.ShapeSameDomain(SE);
2012 TopTools_ListIteratorOfListOfShape ite(EsdSE);
2013 for (; ite.More(); ite.Next()){
2014 const TopoDS_Edge& Esd = TopoDS::Edge(ite.Value()); Standard_Integer iEsd = BDS.Shape(Esd);
2015 Standard_Integer rkEsd = BDS.AncestorRank(Esd);
2016 if (rkEsd == rkSE) continue;
2017 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(Esd);
2018 if (LI.IsEmpty()) continue;
2019
2020 TopOpeBRepDS_ListOfInterference LIcopy; FDS_assign(LI,LIcopy);
2021 TopOpeBRepDS_ListOfInterference LISE;
2022#ifdef DEB
2023// Standard_Integer nise =
2024#endif
2025 FUN_selectSIinterference(LIcopy,ISE,LISE);
2026
2027 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LISE);
2028 for (tki.Init(); tki.More(); tki.Next()) {
2029 TopOpeBRepDS_Kind K;
2030 Standard_Integer G;
2031// const TopOpeBRepDS_ListOfInterference& loi =
2032 tki.Value(K,G);
2033#ifdef DEB
2034// const Handle(TopOpeBRepDS_Interference)& I = loi.First();
2035// TopAbs_Orientation O = I->Transition().Orientation(TopAbs_IN);
2036#endif
2037 const TopoDS_Vertex& vG = TopoDS::Vertex(BDS.Shape(G));
2038 Standard_Boolean hsd1 = HDS->HasSameDomain(vG);
2039 if (hsd1) continue; //nyixpu011098
2040 Standard_Integer rkG = BDS.AncestorRank(G);
2041 if (rkG != rkSE) continue; //nyixpu011098
2042
2043 // newI :
2044 // -----
2045 TopOpeBRepDS_Transition newT(TopAbs_IN,TopAbs_IN,TopAbs_EDGE,TopAbs_EDGE); newT.Index(iEsd);
2046 // modified by NIZHNY-MKK Mon Apr 2 15:39:14 2001.BEGIN
2047 Standard_Integer hasvG = FUN_tool_orientVinE(vG,SE);
2048 if(hasvG==0) {
2049 continue;
2050 }
2051 // modified by NIZHNY-MKK Mon Apr 2 15:39:17 2001.END
2052
2053 Standard_Real par = BRep_Tool::Parameter(vG,SE);
2054 Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(newT,iEsd,G,par,TopOpeBRepDS_VERTEX,TopOpeBRepDS_EDGE,Standard_True);
2055#ifdef DEB
2056 if (trc) {cout<<"completeforSE6 on section edge "<<ISE<<" ";newI->Dump(cout);cout<<endl;}
2057#endif
2058 HDS->StoreInterference(newI,SE);
2059 }
2060 }//ite(EsdSE)
2061 }//i=1..nse
2062} //completeforSE9
2063
2064// ----------------------------------------------------------------------
2065Standard_EXPORT void FUN_ds_PointToVertex(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
2066// ----------------------------------------------------------------------
2067// xpu090698 : for gap reasons, intersector IntPatch can find a intersection
2068// point POINT, whereas it should be a VERTEX,
2069// if we find edge eb / eb : EPI(T1,G,ea1),
2070// EPI(T2,G,a2) with rk(ea1) = rk(ea2),
2071// then G should be VERTEX (2 edges of same shape cannot
2072// intersect) - recall : in the DS, we do not bind twice the same closing edge-
2073// CTS20339
2074{
2075 Standard_Integer i ;
2076 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
2077 Standard_Integer ns = BDS.NbShapes();
2078 TColStd_DataMapOfIntegerInteger iPiV;
2079
2080 for ( i = 1; i <= ns; i++) {
2081 const TopoDS_Shape& s = BDS.Shape(i);
2082 if (s.ShapeType() != TopAbs_EDGE) continue;
2083 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(s);
2084 if (LI.IsEmpty()) continue;
2085
2086 TopOpeBRepDS_TKI tki;
2087 tki.FillOnGeometry(LI);
2088 for (tki.Init(); tki.More(); tki.Next()) {
2089 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
2090 if (K == TopOpeBRepDS_VERTEX) continue;
2091
2092 Standard_Integer Scur = 0; Standard_Boolean Gfaulty = Standard_False;
2093 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(loi); it.More(); it.Next()){
2094 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
2095 TopOpeBRepDS_Kind GT,ST;
2096 Standard_Integer G1,S;
2097 FDS_data(I,GT,G1,ST,S);
2098 if (ST != TopOpeBRepDS_EDGE) continue;
2099 if (Scur == 0) {
2100 Scur = S;
2101 }
2102 if (S != Scur) {
2103 Gfaulty = Standard_True; break;
2104 }
2105 } // it
2106 if (Gfaulty) {
2107 // in DS : pG --> vG
2108 gp_Pnt pG = BDS.Point(G).Point();
2109 Standard_Integer rkES = BDS.AncestorRank(Scur);
2110 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(Scur));
2111 TopoDS_Vertex vf,vl; TopExp::Vertices(ES,vf,vl);
2112 gp_Pnt pf = BRep_Tool::Pnt(vf); gp_Pnt pl = BRep_Tool::Pnt(vl);
2113 Standard_Real df = pf.Distance(pG); Standard_Real dl = pl.Distance(pG);
2114 TopoDS_Vertex vG;
2115 if (df < dl) vG = vf;
2116 else vG = vl;
2117
2118 Standard_Integer ivG = BDS.AddShape(vG,rkES);
2119 iPiV.Bind(G,ivG);
2120 } // Gfaulty
2121 } // tki
2122 } // i
2123
2124 if (iPiV.IsEmpty()) return;
2125 for (i = 1; i <= ns; i++) {
2126 const TopoDS_Shape& s = BDS.Shape(i);
2127 if (s.ShapeType() != TopAbs_EDGE) continue;
2128 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(s);
2129 if (LI.IsEmpty()) continue;
2130
2131 TopOpeBRepDS_ListOfInterference newLI;
2132 Standard_Integer rks = BDS.AncestorRank(s);
2133 TopOpeBRepDS_TKI tki;
2134 tki.FillOnGeometry(LI);
2135 for (tki.Init(); tki.More(); tki.Next()) {
2136 TopOpeBRepDS_Kind K;
2137 Standard_Integer G;
2138 const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
2139 Standard_Boolean Gisbound = iPiV.IsBound(G);
2140 if (!Gisbound) {
2141 FDS_copy(loi,newLI);
2142 continue;
2143 }
2144
2145 Standard_Integer ivG = iPiV.Find(G);
2146 const TopoDS_Vertex& vG = TopoDS::Vertex(BDS.Shape(ivG));
2147 Standard_Integer rkG = BDS.AncestorRank(ivG);
2148 Standard_Boolean Gbound = (rkG == rks);
2149
2150 for (TopOpeBRepDS_ListIteratorOfListOfInterference itl(loi); itl.More(); itl.Next()){
2151 const Handle(TopOpeBRepDS_Interference)& I = itl.Value();
2152 const Handle(TopOpeBRepDS_CurvePointInterference)& CPI = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I);
2153 if (CPI.IsNull()) continue;
2154
2155 Standard_Real par = CPI->Parameter();
2156 TopOpeBRepDS_Kind GT,ST;
2157 Standard_Integer G1,S;
2158 FDS_data(I,GT,G1,ST,S);
2159 const TopOpeBRepDS_Transition& T = I->Transition();
2160 Standard_Real parvG; Standard_Boolean ok = FUN_tool_parVonE(vG,TopoDS::Edge(s),parvG);
2161 // modified by NIZHNY-MKK Mon Apr 2 15:39:59 2001.BEGIN
2162 // if (!ok) par = parvG;
2163 if (!ok)
2164 continue;
2165 par = parvG;
2166 // modified by NIZHNY-MKK Mon Apr 2 15:40:04 2001.END
2167 Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(T,S,ivG,par,TopOpeBRepDS_VERTEX,ST,Gbound);
2168 newLI.Append(newI);
2169 }
2170 } // tki
2171 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(s);
2172 LII.Clear(); LII.Append(newLI);
2173 } // i
2174
2175 TColStd_DataMapIteratorOfDataMapOfIntegerInteger itm(iPiV);
2176 for (; itm.More(); itm.Next()){
2177 Standard_Integer G = itm.Key();
2178 BDS.RemovePoint(G);
2179 }
2180}//PointToVertex
2181
2182static Standard_Boolean FUN_redusamshaonE(const TopOpeBRepDS_DataStructure& BDS,const Handle(TopOpeBRepDS_Interference)& I,const Standard_Integer EIX, Handle(TopOpeBRepDS_Interference)& newI)
2183// attached to edge(EIX) : IFOR=(FORWARD(ES),G,ES) + IREV=(REVERSED(ES),G,ES)
2184{
2185 newI.Nullify();
2186 TopAbs_ShapeEnum SB,SA;Standard_Integer IB,IA;TopOpeBRepDS_Kind GT,ST;Standard_Integer G,S;
2187 FDS_Idata(I,SB,IB,SA,IA,GT,G,ST,S);
2188 const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(EIX));
2189 Standard_Real parE = FDS_Parameter(I); Standard_Real f,l; FUN_tool_bounds(E,f,l);
2190 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(S));
2191 const TopoDS_Face& FTRA = TopoDS::Face(BDS.Shape(IB));
2192 Standard_Real parES; Standard_Boolean ok = FUN_tool_parE(E,parE,ES,parES);
2193 if (!ok) return Standard_False;
2194 gp_Pnt2d uv; ok = FUN_tool_paronEF(ES,parES,FTRA,uv);
2195 if (!ok) return Standard_False;
2196
2197 Standard_Real factor = 1.e-2; TopAbs_State stb,sta;
2198 TopOpeBRepTool_makeTransition MKT;
2199 ok = MKT.Initialize(E,f,l,parE, FTRA,uv, factor);
2200 if (ok) ok = MKT.SetRest(ES,parES);
2201 if (ok) ok = MKT.MkTonE(stb,sta);
2202 if (!ok) return Standard_False;
2203 TopOpeBRepDS_Transition newT; newT.Index(IB); newT.Before(stb);newT.After(sta);
2204
2205 ok = FDS_stateEwithF2d(BDS,E,parE,GT,G,FTRA,newT);
2206 if (!ok) return Standard_False;
2207
2208 Standard_Boolean B = Standard_False; if (GT == TopOpeBRepDS_VERTEX) B = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I)->GBound();
2209 newI = MakeEPVInterference(newT,S,G,parE,GT,TopOpeBRepDS_EDGE,B);
2210 return Standard_True;
2211}//FUN_redusamshaonE
2212
2213// ----------------------------------------------------------------------
2214Standard_EXPORT void FUN_ds_redusamsha(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
2215// ----------------------------------------------------------------------
2216// xpu201098 : reduce 2d interferences on same G and same S :
2217// {I1=(OU/IN(F),G,ES), I2=(IN/OU(F),G,ES)}
2218// cto009K1 (SE7,ES8,G2,FTRA27)
2219//xpu050299 (FRA60618 e13,ftrasha14)
2220{
2221 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
2222 Standard_Integer ns = BDS.NbShapes();
2223
2224 for (Standard_Integer i = 1; i <= ns; i++) {
2225 if (BDS.Shape(i).ShapeType() != TopAbs_EDGE) continue;
2226
2227 const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(i));
2228#ifdef DEB
2229// Standard_Boolean isse = BDS.IsSectionEdge(E);
2230// Standard_Integer rkE = BDS.AncestorRank(E);
2231#endif
2232 Standard_Integer IE = BDS.Shape(E);
2233#ifdef DEB
2234 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(IE);
2235 if (trc) debsamsha(IE);
2236#endif
2237 TopOpeBRepDS_TKI tki;
2238 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(i);
2239 tki.FillOnGeometry(LI);
2240 for (tki.Init(); tki.More(); tki.Next()) {
2241 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
2242 TopOpeBRepDS_ListOfInterference loicopy; FDS_copy(loi,loicopy); // loi -> l1+l2
2243 TopOpeBRepDS_ListOfInterference l0;
2244#ifdef DEB
2245// Standard_Integer n0 =
2246#endif
2247 FUN_selectTRASHAinterference(loicopy,TopAbs_EDGE,l0);//xpu091198(cylcong)
2248 TopOpeBRepDS_ListOfInterference l1; Standard_Integer nfound = FUN_selectTRASHAinterference(loicopy,TopAbs_FACE,l1);
2249 TopOpeBRepDS_ListOfInterference l2; nfound = FUN_selectSKinterference(l1,TopOpeBRepDS_EDGE,l2);
2250 // l2 = {I=(T(faceTRASHA),G,Sedge)}
2251 if (nfound == 0) continue;
2252
2253 //***
2254 TopOpeBRepDS_TKI tkis; tkis.FillOnSupport(l2);
2255 for (tkis.Init(); tkis.More(); tkis.Next()) {
2256 TopOpeBRepDS_Kind k; Standard_Integer s; TopOpeBRepDS_ListOfInterference& li = tkis.ChangeValue(k,s);
2257 Standard_Integer nli = li.Extent();
2258 if (nli < 2) continue;
2259
2260 Handle(TopOpeBRepDS_Interference) newI;
2261 TopOpeBRepDS_ListIteratorOfListOfInterference it1(li);
2262 while (it1.More()) {
2263 const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
2264 const TopOpeBRepDS_Transition& T1 = I1->Transition();
2265 TopAbs_Orientation O1 = T1.Orientation(TopAbs_IN);
2266 if (!M_FORWARD(O1) && !M_REVERSED(O1)) {it1.Next(); continue;}
2267 TopAbs_ShapeEnum SB1,SA1;Standard_Integer IB1,IA1;TopOpeBRepDS_Kind GT1,ST1;Standard_Integer G1,S1;
2268 FDS_Idata(I1,SB1,IB1,SA1,IA1,GT1,G1,ST1,S1);
2269 if (IB1 != IA1) {it1.Next(); continue;}
2270
2271 Standard_Boolean oppofound = Standard_False;
2272 TopOpeBRepDS_ListIteratorOfListOfInterference it2(it1); it2.Next();
2273 while (it2.More()) {
2274 const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value();
2275 const TopOpeBRepDS_Transition& T2 = I2->Transition();
2276 TopAbs_Orientation O2 = T2.Orientation(TopAbs_IN);
2277 TopAbs_ShapeEnum SB2,SA2;Standard_Integer IB2,IA2;TopOpeBRepDS_Kind GT2,ST2;Standard_Integer G2,S2;
2278 FDS_Idata(I2,SB2,IB2,SA2,IA2,GT2,G2,ST2,S2);
2279 if (IB2 != IA2) {it2.Next(); continue;}
2280 if (IB1 != IB2) {it2.Next(); continue;} // same fTRASHA
2281 if (S1 != S2) {it2.Next(); continue;} // same Sedge
2282
2283 if (O1 == TopAbs::Complement(O2)) {oppofound=Standard_True; break;}
2284 else {it2.Next(); continue;}
2285 } // it2(it1)
2286
2287 if (!oppofound) {it1.Next(); continue;}
2288 Standard_Boolean ok = FUN_redusamshaonE(BDS,I1,IE,newI);
2289 if (!ok) {it1.Next(); continue;}
2290 else break;
2291 } //it1(li)
2292 if (newI.IsNull()) continue;
2293#ifdef DEB
2294 if (trc) {cout<<"redusamsha se"<<IE<<"FORWARD/REVERSED ->";newI->Dump(cout);cout<<endl;}
2295#endif
2296 li.Clear(); li.Append(newI);
2297 }//tkis(l2)
2298 //***
2299
2300 TopOpeBRepDS_ListOfInterference& newloi = tki.ChangeValue(K,G); newloi.Clear();
2301 for (tkis.Init(); tkis.More(); tkis.Next()) {
2302 TopOpeBRepDS_Kind k; Standard_Integer g; TopOpeBRepDS_ListOfInterference& li = tkis.ChangeValue(k,g);
2303 newloi.Append(li);
2304 }
2305 newloi.Append(l0); newloi.Append(l1);
2306 }// tki(LI)
2307
2308 TopOpeBRepDS_ListOfInterference& newLI = BDS.ChangeShapeInterferences(E);
2309 newLI.Clear();
2310 for (tki.Init(); tki.More(); tki.Next()) {
2311 TopOpeBRepDS_Kind KK; Standard_Integer GG; TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(KK,GG);
2312 newLI.Append(loi);
2313 }
2314 }// i=1..nse
2315} //FUN_ds_redusamsha
2316
2317Standard_EXPORT Standard_Boolean FUN_ds_hasFEI(const TopOpeBRepDS_PDataStructure& pDS2d, const TopoDS_Shape& F, const Standard_Integer GI, const Standard_Integer ITRA)
2318{
2319 Standard_Boolean hasF = pDS2d->HasShape(F);
2320 if (!hasF) return Standard_False;
2321
2322 const TopOpeBRepDS_ListOfInterference& LI = pDS2d->ShapeInterferences(F);
2323 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LI); it.More(); it.Next()){
2324 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
2325 const TopOpeBRepDS_Transition& T = I->Transition();
2326 TopOpeBRepDS_Kind GT,ST; Standard_Integer G,S; FDS_data(I,GT,G,ST,S);
2327 Standard_Boolean found = (G == GI) && (T.Index() == ITRA);
2328 if (found) return Standard_True;
2329 }
2330 return Standard_False;
2331} //FUN_ds_hasFEI
2332
2333Standard_EXPORT Standard_Boolean FUN_ds_ONesd(const TopOpeBRepDS_DataStructure& BDS, const Standard_Integer IE, const TopoDS_Shape& EspON, Standard_Integer& IEsd)
2334{
2335 const TopoDS_Shape& E = BDS.Shape(IE);
2336 TopTools_ListIteratorOfListOfShape it(BDS.ShapeSameDomain(E));
2337 Standard_Real f,l; FUN_tool_bounds(TopoDS::Edge(EspON),f,l);
2338 Standard_Real x = 0.456789; Standard_Real par = (1-x)*f + x*l;
2339 gp_Pnt p3d; Standard_Boolean ok = FUN_tool_value(par,TopoDS::Edge(EspON),p3d);
2340 if (!ok) return Standard_False;
2341
2342 for (; it.More(); it.Next()) {
2343 const TopoDS_Edge& esd = TopoDS::Edge(it.Value());
2344 Standard_Real d=0., parp; ok = FUN_tool_projPonE(p3d,esd,parp,d);
2345 if (!ok) continue;
2346 Standard_Real tolesd = BRep_Tool::Tolerance(esd);
2347 ok = (d < tolesd*1.e3); //nyi checktole
2348 if (!ok) continue;
2349 IEsd = BDS.Shape(esd);
2350 return Standard_True;
2351 }
2352 return Standard_False;
2353} //FUN_ds_ONesd
2354
2355/*#define FIRST (1)
2356#define LAST (2)
2357static Standard_Boolean FUN_oriTOsta(const Standard_Integer o, const TopAbs_State sta, TopAbs_Orientation& ori)
2358{
2359 Standard_Boolean ok = (sta == TopAbs_OUT) || (sta == TopAbs_IN);
2360 if (!ok) return Standard_False;
2361 ok = (o == FIRST) || (o == LAST);
2362 if (!ok) return Standard_False;
2363
2364 ori = TopAbs_EXTERNAL;
2365 if (o == FIRST) ori = TopAbs_FORWARD;
2366 if (o == LAST) ori = TopAbs_REVERSED;
2367 if (sta == TopAbs_OUT) ori = TopAbs::Complement(ori);
2368 return Standard_True;
2369} //FUN_oriTOsta
2370
2371Standard_EXPORT void FUN_ds_unkeepEVIonGb1(const Handle(TopOpeBRepDS_HDataStructure)& HDS, const TopAbs_State sta)
2372// xpu290698 :
2373// Completing filter process for edges : delete of interferences
2374// EVI on gbound1, we keep only interferences on Gb1 describing transitions
2375// on e / e is IN the solid (if sta = IN)
2376// e is OU the solid (if sta = OU)
2377{
2378 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
2379 Standard_Integer ns = BDS.NbShapes();
2380 for (Standard_Integer i = 1; i <= ns; i++) {
2381#ifdef DEB
2382 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(i);
2383 if (trc) debgb1(i);
2384#endif
2385 const TopoDS_Shape& s = BDS.Shape(i);
2386 if (s.ShapeType() != TopAbs_EDGE) continue;
2387
2388 const TopoDS_Edge& E = TopoDS::Edge(s);
2389 TopOpeBRepDS_ListOfInterference& LI = BDS.ChangeShapeInterferences(s);
2390 if (LI.IsEmpty()) continue;
2391
2392 Standard_Boolean dgE = BRep_Tool::Degenerated(E);
2393 if (dgE) continue;
2394 TopoDS_Vertex dum; Standard_Boolean closed = FUN_tool_ClosedE(E,dum);
2395 if (closed) continue;
2396
2397 TopOpeBRepDS_Kind K; Standard_Integer G; Standard_Boolean ok = Standard_False;
2398 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LI);
2399
2400 for (tki.Init(); tki.More(); tki.Next()) {
2401 tki.Value(K,G);
2402 if (K != TopOpeBRepDS_VERTEX) break;
2403 ok = Standard_True;
2404 } // tki
2405 if (!ok) continue;
2406
2407 TopOpeBRepDS_ListOfInterference newLI;
2408 for (tki.Init(); tki.More(); tki.Next()) {
2409 tki.Value(K,G);
2410 const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
2411
2412 const TopoDS_Vertex& V = TopoDS::Vertex(BDS.Shape(G));
2413 Standard_Integer o = FUN_tool_orientVinE(V,E);
2414 if (o == 0) {FDS_copy(loi,newLI); continue;}
2415 TopAbs_Orientation ori; Standard_Boolean okk = FUN_oriTOsta(o,sta,ori);
2416 if (!okk) {FDS_copy(loi,newLI); continue;}
2417
2418 // attached to E at G : loi = {I} / I is EVIonGb1
2419 TopOpeBRepDS_ListOfInterference newloi;
2420 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(loi); it.More(); it.Next()) {
2421 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
2422 const TopAbs_Orientation& O = I->Transition().Orientation(TopAbs_IN);
2423 if (O == ori) {
2424 newloi.Append(I);
2425 continue;
2426 }
2427#ifdef DEB
2428 if (trc) {cout<<"unkeepEVIonGb1 on e"<<i<<" ";I->Dump(cout);cout<<endl;}
2429#endif
2430 }
2431 Standard_Integer nnewI = newloi.Extent();
2432 Standard_Integer nI = loi.Extent();
2433 Standard_Boolean ko = (nnewI > 1) && (nnewI != nI); // complex transitions at G
2434 // NYI : correcting reducing cto 001 W3 (e35)
2435 if (!ko) newLI.Append(newloi);
2436// newLI.Append(newloi); //xpu280898 : cto905J1 (e25,v8)
2437 } // tki
2438 LI.Clear(); LI.Append(newLI);
2439
2440 } // i=1..ns
2441} //FUN_ds_unkeepEVIonGb1*/
2442
2443Standard_EXPORT Standard_Boolean FDS_LOIinfsup(
2444 const TopOpeBRepDS_DataStructure&
2445#ifdef DEB
2446 BDS
2447#endif
2448 ,const TopoDS_Edge& E,
2449 const Standard_Real pE,
2450 const TopOpeBRepDS_Kind KDS,
2451 const Standard_Integer GDS,
2452 const TopOpeBRepDS_ListOfInterference& LOI,
2453 Standard_Real& pbef,
2454 Standard_Real& paft,
2455 Standard_Boolean& isonboundper)
2456{
2457#ifdef DEB
2458 Standard_Integer EIX = BDS.Shape(E);
2459 Standard_Boolean TRC=DSREDUEDGETRCE(EIX);
2460 TRC = Standard_False; // xpu170898
2461 if (TRC) cout<<endl<<"FDS_LOIinfsup.1 E"<<EIX<<" : "<<LOI.Extent()<<endl;
2462 if (TRC) debredpvg(EIX);
2463#endif
2464
2465 Standard_Real f,l; FUN_tool_bounds(E,f,l);
2466 pbef = f; paft = l;
2467 Standard_Integer n = LOI.Extent();
2468 if (n == 0) return Standard_True;
2469
2470
2471 TopOpeBRepDS_ListOfInterference LOIsansGDS;
2472 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LOI);
2473#ifdef DEB
2474 if (TRC) cout<<endl<<"FDS_LOIinfsup E"<<EIX<<" tki"<<endl;
2475 if (TRC) tki.DumpTKIIterator("","\n");
2476 if (TRC) debredpvg(EIX);
2477#endif
2478
2479 for(tki.Init();tki.More();tki.Next()) {
2480 TopOpeBRepDS_Kind K; Standard_Integer G; tki.Value(K,G);
2481 Standard_Boolean PV =(K==TopOpeBRepDS_POINT)||(K==TopOpeBRepDS_VERTEX);if (!PV) continue;
2482 Standard_Boolean mk = (K == KDS); Standard_Boolean mg = (G == GDS);
2483 Standard_Boolean mkg = (mk && mg); if ( mkg ) continue;
2484
2485#ifdef DEB
2486 if (TRC) {tki.DumpTKI(K,G,"","\n");debredpvg(EIX);}
2487#endif
2488
2489 TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G);
2490#ifdef DEB
2491// Standard_Integer nloi = loi.Extent();
2492#endif
2493 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(loi);it.More();it.Next()) {
2494 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
2495 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; TopAbs_ShapeEnum tsb1,tsa1; Standard_Integer isb1,isa1;
2496 FDS_Idata(I,tsb1,isb1,tsa1,isa1,GT1,G1,ST1,S1);
2497 if (tsb1 != TopAbs_FACE) continue;
2498 if (tsa1 != TopAbs_FACE) continue;
2499 const Handle(TopOpeBRepDS_CurvePointInterference)& cpi = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I);
2500 const Handle(TopOpeBRepDS_EdgeVertexInterference)& evi = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I);
2501 if (cpi.IsNull() && evi.IsNull()) continue;
2502 LOIsansGDS.Append(I);
2503 break;
2504 }
2505 }
2506
2507#ifdef DEB
2508 if (TRC) cout<<endl<<"FDS_LOIinfsup.2 E"<<EIX<<" : "<<LOIsansGDS.Extent()<<endl;
2509 if (TRC) debredpvg(EIX);
2510#endif
2511
2512 n = LOIsansGDS.Extent();
2513 if (n == 0) return Standard_True;
2514
2515 TopoDS_Vertex v; Standard_Boolean Eclosed = TopOpeBRepTool_TOOL::ClosedE(E,v);
2516 Standard_Real tole = BRep_Tool::Tolerance(E);
2517 Standard_Real tol = Precision::Parametric(tole);
2518 isonboundper = Standard_False;
2519 if (Eclosed) {
2520 Standard_Real tolv = BRep_Tool::Tolerance(v);
2521 tolv = Precision::Parametric(tolv);
2522 if (tolv > tol) tol = tolv;
2523 Standard_Boolean pEisEf = (Abs(pE-f) <= tol);
2524 Standard_Boolean pEisEl = (Abs(pE-l) <= tol);
2525 isonboundper = pEisEf || pEisEl;
2526 }
2527
2528 if (isonboundper) {
2529 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LOIsansGDS);it.More();it.Next()) {
2530 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
2531 Standard_Real p = FDS_Parameter(I);
2532 // pbef > paft
2533 if (p > pbef) pbef = p;
2534 if (p < paft) paft = p;
2535 }
2536 return Standard_True;
2537 }
2538 else {
2539 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LOIsansGDS);it.More();it.Next()) {
2540 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
2541 Standard_Real p = FDS_Parameter(I);
2542 if (p > pbef && p < pE) pbef = p;
2543 if (p < paft && p > pE) paft = p;
2544 }
2545 }
2546 return Standard_True;
2547} // FDS_LOIinfsup
2548
2549// sur arete E : pbef < pE < paft, calcul de p1,t2 / :
2550// p1 dans [pbef,pE[
2551// p2 dans ]pE,paft]
2552// si isonboundper = T, les bornes pbef et paft sont prises sur les bornes de E.
2553Standard_EXPORT Standard_Boolean FDS_parbefaft(
2554// const TopOpeBRepDS_DataStructure& BDS,
2555 const TopOpeBRepDS_DataStructure& ,
2556 const TopoDS_Edge& E,
2557 const Standard_Real pE,
2558 const Standard_Real& pbef,
2559 const Standard_Real& paft,
2560 const Standard_Boolean& isonboundper,
2561 Standard_Real& p1, Standard_Real& p2)
2562{
2563 Standard_Real t = 0.3178947713;
2564 Standard_Real f,l; FUN_tool_bounds(E,f,l);
2565 if (isonboundper) {
2566 p1 = (1-t)*pbef + t*l;
2567 p2 = (1-t)*f + t*paft;
2568 }
2569 else {
2570 p1 = (1-t)*pbef + t*pE;
2571 p2 = (1-t)*pE + t*paft;
2572 }
2573 return Standard_True;
2574} // FDS_parbefaft
2575
2576Standard_EXPORT Standard_Boolean FDS_stateEwithF2d(const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Edge& E,const Standard_Real pE,
2577 const TopOpeBRepDS_Kind KDS,const Standard_Integer GDS,
2578 const TopoDS_Face& F1,
2579 TopOpeBRepDS_Transition& TrmemeS)
2580{
2581 const TopOpeBRepDS_ListOfInterference& LOI = BDS.ShapeInterferences(E);
2582 Standard_Real pbef,paft; Standard_Boolean isonper; Standard_Boolean ok = FDS_LOIinfsup(BDS,E,pE,KDS,GDS,LOI,pbef,paft,isonper);
2583 if (!ok) return Standard_False;
2584 Standard_Real t1,t2; ok = FDS_parbefaft(BDS,E,pE,pbef,paft,isonper,t1,t2);
2585 gp_Pnt P1; Standard_Boolean ok1 = FUN_tool_value(t1,E,P1);
2586 gp_Pnt P2; Standard_Boolean ok2 = FUN_tool_value(t2,E,P2);
2587 if (!ok1 || !ok2) return Standard_False;
2588
2589 TopOpeBRepTool_ShapeClassifier& PSC = FSC_GetPSC(F1);
2590 TopAbs_State sta1 = FSC_StatePonFace(P1,F1,PSC);
2591 TopAbs_State sta2 = FSC_StatePonFace(P2,F1,PSC);
2592
2593 // xpu190898 : cto014I2 (e5,fTRASHA14,vG7,eS10)
2594 if (sta1 == TopAbs_ON) sta1 = TopAbs_IN;
2595 if (sta2 == TopAbs_ON) sta2 = TopAbs_IN;
2596
2597 TrmemeS.Before(sta1,TopAbs_FACE);
2598 TrmemeS.After (sta2,TopAbs_FACE);
2599 return Standard_True;
2600}//FDS_stateEwithF2d
2601
2602#define SAMEORIENTED (1)
2603#define DIFFORIENTED (2)
2604Standard_EXPORT void FUN_ds_FEIGb1TO0(Handle(TopOpeBRepDS_HDataStructure)& HDS,
2605 const TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State& MEspON)
2606{
2607 //xpu250199 : F has FEI(Gb1, EG, FS), EG sdm Esd
2608 // -> to prevent from the loss of information, replace interference with
2609 // FEI'(Gb0, EGsd, FS)
2610 //CTS21754, f26 has FEI(Gb1,EG=e13, FS=f16), EG13 sd Esd11
2611
2612 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
2613 Standard_Integer ns = BDS.NbShapes();
2614 for (Standard_Integer I=1; I<=ns; I++) {
2615
2616 const TopoDS_Shape& F = BDS.Shape(I);
2617 if (F. ShapeType() != TopAbs_FACE) continue;
2618 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(F);
2619#ifdef DEB
2620 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(I);
2621 if (trc) debgb1(I);
2622#endif
2623
2624 TopOpeBRepDS_ListOfInterference LGb1; // LI = LII + LGb1 (= {FEI with GB1})
2625 TopOpeBRepDS_ListOfInterference LII; FDS_copy(LI,LII);
2626 TopOpeBRepDS_ListIteratorOfListOfInterference it(LII);
2627 while (it.More()) {
2628 const Handle(TopOpeBRepDS_Interference)& Intf = it.Value();
2629 Handle(TopOpeBRepDS_FaceEdgeInterference) FEI =
2630 Handle(TopOpeBRepDS_FaceEdgeInterference)::DownCast(Intf);
2631 if (FEI.IsNull()) {
2632 it.Next();
2633 continue;
2634 }
2635 Standard_Boolean GB = FEI->GBound();
2636 if (GB != 1) {
2637 it.Next();
2638 continue;
2639 }
2640 LGb1.Append(Intf);
2641 LII.Remove(it);
2642 }//it(LII)
2643 Standard_Integer nGb1 = LGb1.Extent();
2644 if (nGb1 == 0) continue;
2645
2646 TopOpeBRepDS_ListOfInterference LGb0; // LGb1={FEIGb1(EG,FS)} -> LGb0={FEIGb0(Esd,FS)}
2647 it.Initialize(LGb1);
2648 while (it.More()) {
2649 Handle(TopOpeBRepDS_FaceEdgeInterference) IGb1 = Handle(TopOpeBRepDS_FaceEdgeInterference)::DownCast(it.Value());
2650 Standard_Integer S = IGb1->Support(); const TopoDS_Face& FS = TopoDS::Face(BDS.Shape(S));
2651 Standard_Integer G = IGb1->Geometry();
2652 Standard_Integer Gsd; Standard_Boolean findSD = TopOpeBRepDS_TOOL::GetEsd(HDS,FS,G,Gsd);
2653 if (!findSD) {it.Next(); continue;}
2654
2655 // IGb0 is already stored in the list of interferences :
2656 TopOpeBRepDS_ListIteratorOfListOfInterference itt(LII); Standard_Boolean stored = Standard_False;
2657 for (; itt.More(); itt.Next()){
2658 const Handle(TopOpeBRepDS_Interference)& II = itt.Value();
2659 Standard_Boolean isfound = (II->Support() == S)&&(II->Geometry() == Gsd);
2660 if (isfound) {stored = Standard_True; break;}
2661 }//itt(LII)
2662 if (stored) {LGb1.Remove(it); continue;}
2663
2664 TopOpeBRepDS_Transition newT = IGb1->Transition();
2665 TopAbs_Orientation newO = newT.Orientation(TopAbs_IN);
2666 if (M_INTERNAL(newO) || M_EXTERNAL(newO)) {
2667 // nothing's done
2668 }
2669 else {
2670 Standard_Integer conf; Standard_Boolean ok = TopOpeBRepDS_TOOL::GetConfig(HDS,MEspON,G,Gsd,conf);
2671 if (!ok) {it.Next(); continue;}
2672 if (conf == DIFFORIENTED) newO = TopAbs::Complement(newO);
2673 }
2674#ifdef DEB
2675 if (trc) {cout<<"**FUN_ds_FEIGb1TO0 : IGb1";IGb1->Dump(cout);cout<<" ->";}
2676#endif
2677 newT.Set(newO);
2678 IGb1->SetGeometry(Gsd); IGb1->SetGBound(Standard_False); IGb1->Transition(newT);
2679#ifdef DEB
2680 if (trc) {IGb1->Dump(cout);cout<<endl;}
2681#endif
2682 LGb0.Append(IGb1); LGb1.Remove(it);
2683 }//it(LGb1)
2684
2685 if (LGb0.IsEmpty()) continue;
2686 TopOpeBRepDS_ListOfInterference& newLI = BDS.ChangeShapeInterferences(F);
2687 newLI.Clear();
2688 newLI.Append(LII); newLI.Append(LGb1); newLI.Append(LGb0);
2689 }//i=1..ns
2690}//FUN_ds_FEIGb1TO0
2691
2692// ----------------------------------------------------------------------
2693Standard_EXPORT void FUN_ds_complete1dForSESDM(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
2694// ----------------------------------------------------------------------
2695// MSV 25.03.2002 : OCC251
2696// purpose : SE Section edge, SDM with Esd, SE has no interference
2697// for one of vertices of Esd while should.
2698{
2699 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
2700 Standard_Integer nse = BDS.NbSectionEdges();
2701
2702 for (Standard_Integer is = 1; is <= nse; is++) {
2703 const TopoDS_Edge& SE = BDS.SectionEdge(is);
2704 if (BRep_Tool::Degenerated(SE)) continue;
2705 Standard_Integer rkSE = BDS.AncestorRank(SE);
2706 Standard_Integer iSE = BDS.Shape(SE);
2707 Standard_Boolean hsd = HDS->HasSameDomain(SE);
2708 if (!hsd) continue;
2709 const TopTools_ListOfShape& LEsd = BDS.ShapeSameDomain(SE);
2710 if (LEsd.IsEmpty()) continue;
2711
2712 Standard_Real tolSE = BRep_Tool::Tolerance(SE);
2713 // map of vertices of SE or same domain with them
2714 TopTools_MapOfShape aGBMap;
2715 TopoDS_Vertex VSE[2];
2716 TopExp::Vertices(SE,VSE[0],VSE[1]);
2717 Standard_Integer i;
2718 for (i=0; i < 2; i++)
2719 if (!VSE[i].IsNull()) {
2720 aGBMap.Add(VSE[i]);
2721 const TopTools_ListOfShape& LV = BDS.ShapeSameDomain(VSE[i]);
2722 TopTools_ListIteratorOfListOfShape it(LV);
2723 for (; it.More(); it.Next())
2724 aGBMap.Add(it.Value());
2725 }
2726
2727 TopTools_ListIteratorOfListOfShape ite(LEsd);
2728 for (; ite.More(); ite.Next()){
2729 const TopoDS_Edge& Esd = TopoDS::Edge(ite.Value());
2730 Standard_Integer iEsd = BDS.Shape(Esd);
2731 Standard_Integer rkEsd = BDS.AncestorRank(Esd);
2732 if (rkEsd == rkSE) continue;
2733
2734 if (BRep_Tool::Degenerated(Esd)) continue;
2735 Standard_Boolean isSO;
2736 Standard_Boolean ok = FUN_tool_curvesSO(Esd,SE,isSO);
2737 if (!ok) continue;
2738
2739 Standard_Real tolEsd = Max (BRep_Tool::Tolerance(Esd), tolSE);
2740 // prepare the list of interferences of SE with Esd
2741 const TopOpeBRepDS_ListOfInterference& LIall = BDS.ShapeInterferences(iSE);
2742 TopOpeBRepDS_ListOfInterference LI,LI1;
2743 FDS_assign(LIall,LI);
2744 Standard_Integer ni = FUN_selectTRAUNKinterference(LI,LI1);
2745 LI1.Clear(); ni = FUN_selectTRASHAinterference(LI,TopAbs_EDGE,LI1);
2746 LI.Clear(); ni = FUN_selectITRASHAinterference(LI1,iEsd,LI);
2747 LI1.Clear(); ni = FUN_selectSKinterference(LI,TopOpeBRepDS_EDGE,LI1);
2748 LI.Clear(); ni = FUN_selectSIinterference(LI1,iEsd,LI);
2749 LI1.Clear(); ni = FUN_selectGKinterference(LI,TopOpeBRepDS_VERTEX,LI1);
2750 LI.Clear(); LI.Append(LI1);
2751
2752 // process vertices of Esd
2753 TopoDS_Vertex Vsd[2];
2754 TopExp::Vertices(Esd,Vsd[0],Vsd[1]);
2755 for (i=0; i < 2; i++) {
2756 const TopoDS_Vertex& aV = Vsd[i];
2757 if (aV.IsNull()) continue;
2758 // do not create interferences on GBound
2759 if (aGBMap.Contains(aV)) continue;
2760
2761 TopAbs_Orientation ori = aV.Orientation();
2762 if (!isSO) ori = TopAbs::Reverse(ori);
2763
2764 // check that SE has no yet interference with geometry aV oriented ori
2765 if (ni) {
2766 TopOpeBRepDS_ListOfInterference LI2;
2767 FDS_assign(LI,LI1);
2768 Standard_Integer nio = FUN_selectTRAORIinterference(LI1,ori,LI2);
2769 if (nio) {
2770 TopTools_MapOfShape aVGMap;
2771 aVGMap.Add(aV);
2772 const TopTools_ListOfShape& LV = BDS.ShapeSameDomain(aV);
2773 TopTools_ListIteratorOfListOfShape it(LV);
2774 for (; it.More(); it.Next())
2775 aVGMap.Add(it.Value());
2776 TopOpeBRepDS_ListIteratorOfListOfInterference iti(LI2);
2777 for (; iti.More(); iti.Next()) {
2778 const Handle(TopOpeBRepDS_Interference)& I1 = iti.Value();
2779 Standard_Integer gi = I1->Geometry();
2780 const TopoDS_Shape& aVG = BDS.Shape(gi);
2781 if (aVGMap.Contains(aVG)) break;
2782 }
2783 if (iti.More()) continue; // has already
2784 }
2785 }
2786
2787 // make new interference
2788 Standard_Real par;
2789 Standard_Real tol = Max (BRep_Tool::Tolerance(aV), tolEsd);
2790 Standard_Real parEsd = BRep_Tool::Parameter(aV,Esd);
2791 ok = FUN_tool_parE (Esd,parEsd,SE,par,tol);
2792 if (!ok) continue;
2793 TopOpeBRepDS_Transition aT(ori);
2794 aT.ShapeBefore(TopAbs_EDGE); aT.ShapeAfter(TopAbs_EDGE);
2795 aT.Index(iEsd);
2796 Standard_Integer iV = BDS.AddShape(aV,rkEsd);
2797 Standard_Boolean isGBound = Standard_False;
2798 TopOpeBRepDS_Config aConfig = (isSO
2799 ? TopOpeBRepDS_SAMEORIENTED
2800 : TopOpeBRepDS_DIFFORIENTED);
2801 Handle(TopOpeBRepDS_Interference) aI =
2802 TopOpeBRepDS_InterferenceTool::MakeEdgeVertexInterference
2803 (aT,iEsd,iV,isGBound,aConfig,par);
2804 HDS->StoreInterference(aI,SE);
2805 }
2806 }
2807 }
2808}