1 // Created on: 1994-02-17
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and / or modify it
9 // under the terms of the GNU Lesser General Public version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <TopOpeBRep_FacesFiller.ixx>
19 #include <Standard_ProgramError.hxx>
20 #include <Standard_DomainError.hxx>
21 #include <Geom_Curve.hxx>
22 #include <Geom2d_Curve.hxx>
23 #include <TopOpeBRep_FFTransitionTool.hxx>
24 #include <TopOpeBRep_PointGeomTool.hxx>
25 #include <TopOpeBRep.hxx>
26 #include <TopOpeBRepDS_InterferenceTool.hxx>
27 #include <TopOpeBRepDS_Config.hxx>
28 #include <TopOpeBRepDS_Curve.hxx>
29 #include <TopOpeBRepDS_PointIterator.hxx>
30 #include <TopOpeBRepTool_ShapeTool.hxx>
31 #include <TopTools_IndexedMapOfShape.hxx>
32 #include <Precision.hxx>
35 #include <TopOpeBRepDS_define.hxx>
38 extern Standard_Boolean TopOpeBRepDS_GettraceDSF();
39 extern Standard_Boolean TopOpeBRep_GetcontextNEWKP();
42 // VP<STATIC_lastVPind> is the vp on which was computed the last CPI.
43 // if no CPI is computed yet, <STATIC_lastVPind> = 0.
44 static Standard_Integer STATIC_lastVPind;
46 #define M_FORWARD( st) (st == TopAbs_FORWARD)
47 #define M_REVERSED(st) (st == TopAbs_REVERSED)
48 #define M_INTERNAL(st) (st == TopAbs_INTERNAL)
49 #define M_EXTERNAL(st) (st == TopAbs_EXTERNAL)
51 //-----------------------------------------------------------------------
52 static void FUNBREP_Periodize
53 (const TopOpeBRep_LineInter& L,const Handle(TopOpeBRepDS_Interference)& Ifound,Standard_Real& PIfound,Standard_Real& parline)
54 //-----------------------------------------------------------------------
56 const TopOpeBRepDS_Transition& TIfound = Ifound->Transition();
57 TopAbs_Orientation OTIfound = TIfound.Orientation(TopAbs_IN);
60 Standard_Real f,l; L.Bounds(f,l);
61 Standard_Boolean onf = Abs(parline-f) < Precision::PConfusion();
62 Standard_Boolean onl = Abs(parline-l) < Precision::PConfusion();
63 Standard_Boolean onfl = onf || onl;
65 if ( OTIfound == TopAbs_FORWARD ) {
69 else if ( OTIfound == TopAbs_REVERSED ) {
74 Standard_ProgramError::Raise("FUNBREP_Periodize");
78 parline = PIfound = Min(parline,PIfound);
82 parline = PIfound = Min(parline,PIfound);
86 //-----------------------------------------------------------------------
87 static Standard_Boolean FUNBREP_HasSameGPoint(const TopOpeBRepDS_Point& DSP,const Handle(TopOpeBRepDS_Interference)& I,
88 const TopOpeBRepDS_DataStructure& BDS)
89 //-----------------------------------------------------------------------
91 // returns <true> if <DSP> shares same geometric point with
93 Standard_Integer G = I->Geometry();
94 Standard_Boolean samegp = Standard_False;
95 if ( I->GeometryType() == TopOpeBRepDS_POINT ) {
96 const TopOpeBRepDS_Point& P = BDS.Point(G);
97 samegp = DSP.IsEqual(P);
99 else if ( I->GeometryType() == TopOpeBRepDS_VERTEX ) {
100 TopOpeBRepDS_Point P(BDS.Shape(G));
101 samegp = DSP.IsEqual(P);
106 //-----------------------------------------------------------------------
107 static Standard_Boolean FUNBREP_SameUV(const TopOpeBRep_VPointInter& VP1,
108 const TopOpeBRep_VPointInter& VP2,
109 const Standard_Integer sind,const Standard_Real toluv)
110 //-----------------------------------------------------------------------
112 Standard_Real u1 = 0.,v1 = 0.,u2 = 0.,v2 = 0.;
114 VP1.ParametersOnS1(u1,v1); VP2.ParametersOnS1(u2,v2);
117 VP1.ParametersOnS2(u1,v1); VP2.ParametersOnS2(u2,v2);
119 gp_Pnt2d p1(u1,v1), p2(u2,v2);
120 Standard_Real dist = p1.Distance(p2);
121 Standard_Boolean sameuv = (dist < toluv);
126 //-------------------------------------------------------------------
127 void FUNBREP_topokpartDEB
128 (const Handle(TopOpeBRepDS_Interference)& /*Ifound*/,
129 const TopOpeBRepDS_ListOfInterference& DSCIL,
130 const TopOpeBRep_LineInter& L,
131 const TopOpeBRep_VPointInter& VP,
132 const TopOpeBRepDS_Transition& lasttransLine,
133 const TopOpeBRepDS_DataStructure& /*BDS*/,
134 const TopoDS_Shape& /*E*/,
135 const TopoDS_Shape& /*F*/,
136 const Standard_Real /*toluv*/,
137 const Standard_Boolean CPIfound,
138 const Standard_Boolean samepar,
139 const Standard_Boolean couture,
140 const Standard_Real& parline,
141 const TopOpeBRepDS_Transition& transLine)
142 //-------------------------------------------------------------------
144 Standard_Integer iVP = VP.Index();
145 Standard_Boolean fermee = L.IsVClosed();
146 Standard_Boolean onsort = (transLine.Orientation(TopAbs_OUT) == TopAbs_FORWARD);
147 Standard_Boolean lastdefinie = ! lasttransLine.IsUnknown();
148 Standard_Boolean lastonsort = Standard_False;
149 if (lastdefinie) lastonsort = (lasttransLine.Orientation(TopAbs_OUT) == TopAbs_FORWARD);
151 Standard_Boolean LITdefinie = Standard_False;
152 Standard_Boolean LITonsort = Standard_False;
153 TopOpeBRepDS_Transition LIT;
154 Standard_Boolean nointerf = DSCIL.IsEmpty();
156 if (nointerf) STATIC_lastVPind = 0;
158 const Handle(TopOpeBRepDS_Interference)& I = DSCIL.Last();
159 LIT = I->Transition();
160 LITdefinie = ! LIT.IsUnknown();
161 if (LITdefinie) LITonsort = (LIT.Orientation(TopAbs_OUT) == TopAbs_FORWARD);
164 Standard_Boolean iswalki = (L.TypeLineCurve() == TopOpeBRep_WALKING);
165 if (iswalki) cout<<"kpwalk ";
166 else cout<<"kpglin ";
168 cout<<"\tVP "<<iVP<<" : ";
170 if (CPIfound && samepar) cout<<"trouve ("<<parline<<")";
171 else if (CPIfound && !samepar) cout<<"trouve";
172 else cout<<"non trouve";
174 if (fermee) cout<<", fermee";
175 else cout<<", ouverte";
177 if (couture) cout<<", couture";
179 if (onsort) cout<<", sortant";
180 else cout<<", entrant";
182 if (lastdefinie && lastonsort) cout<<", prec = sortant";
183 else if (lastdefinie && !lastonsort) cout<<", prec = entrant";
184 else cout<<", prec = ?";
186 if (LITdefinie && LITonsort) cout<<", Lprec = sortant";
187 else if (LITdefinie && !LITonsort) cout<<", Lprec = entrant";
188 else cout<<", Lprec = ?";
193 Standard_Boolean hasfp = L.HasFirstPoint();
194 Standard_Boolean haslp = L.HasLastPoint();
195 Standard_Real f,l; L.Bounds(f,l);
196 if (hasfp) cout<<"\thas fp "<<f;
197 else cout<<"\thas NO fp";
198 if (haslp) cout<<", has lp "<<l;
199 else cout<<", has NO lp";
205 //----------------------------------------------------------------------
206 Standard_Boolean FUNBREP_topowalki_new
207 (const Handle(TopOpeBRepDS_Interference)& Ifound,const TopOpeBRepDS_ListOfInterference& DSCIL,const TopOpeBRep_LineInter& L,
208 const TopOpeBRep_VPointInter& VP,const TopoDS_Shape& E,const Standard_Boolean samepar,const Standard_Boolean couture,
209 TopOpeBRepDS_Transition& transLine)
210 //----------------------------------------------------------------------
213 Standard_Boolean trc = TopOpeBRepDS_GettraceDSF();
216 if (L.TypeLineCurve() != TopOpeBRep_WALKING) {
217 Standard_ProgramError::Raise("FUNBREP_topowalki_new : line is not a walking");
218 return Standard_False;
221 Standard_Boolean CPIfound = !Ifound.IsNull();
222 Standard_Integer iVP = VP.Index();
223 Standard_Integer iINON1,iINONn,nINON; L.VPBounds(iINON1,iINONn,nINON);
224 Standard_Boolean onsort = (transLine.Orientation(TopAbs_OUT) == TopAbs_FORWARD);
226 Standard_Boolean LITdefinie = DSCIL.IsEmpty()? Standard_False: !DSCIL.Last()->Transition().IsUnknown();
228 // dealing with INTERNAL/EXTERNAL <E> :
229 // ------------------------------------
230 TopAbs_Orientation Eori = E.Orientation();
231 Standard_Boolean EFR = M_FORWARD(Eori) || M_REVERSED(Eori);
232 if (!EFR) { // E INTERNAL ou EXTERNAL
233 // we assume transition for first vp on non oriented edge to be FORWARD
234 // last vp on non oriented edge to be REVERSED
235 if (iVP == iINON1) transLine = TopOpeBRepDS_Transition(TopAbs_OUT,TopAbs_IN);
236 if (iVP == iINONn) transLine = TopOpeBRepDS_Transition(TopAbs_IN,TopAbs_OUT);
239 // no last defined transition :
240 // ----------------------------
242 if (onsort) return Standard_False;
243 if (iVP == iINONn) return Standard_False;
246 // has last defined transition :
247 // -----------------------------
248 Standard_Boolean keep = Standard_True;
251 Handle(TopOpeBRepDS_Interference) I = DSCIL.Last();
252 TopOpeBRepDS_Transition LIT = I->Transition();
253 Standard_Boolean LITonsort = M_FORWARD( LIT.Orientation(TopAbs_OUT) );
254 Standard_Boolean LprecIsEntrant = !LITonsort;
255 Standard_Boolean entrantsortant = LprecIsEntrant && onsort;
257 if(EFR && !entrantsortant) keep = Standard_False;
260 // vp describing the same geometric point on closing edge :
261 // it is the same vp described on the FORWARD and REVERSED closing edge -> we keep it only once
262 // INFO : on walking, vp line parameter is the vp index on the walking
263 // samepar => describes same CPI
264 Standard_Boolean samevponcouture = samepar && keep;
265 if (samevponcouture) {
266 keep = Standard_False;
268 if (trc) cout<<"is same vp on couture";
273 { // kpart JYL 971204 for closing walking, first and current VP same parameter,
274 // lastonentre && onsort,
275 // first VP is first walking point (PIfound == 1.0),
276 // current VP is the second one on walking and not the last.
277 const Handle(TopOpeBRepDS_Interference)& I = DSCIL.First();
278 const TopOpeBRepDS_Transition& lasttransLine = I->Transition();
279 // xpu12-12-97 : line is built on only 2 vp,
280 // DSCIL->First() == DSCIL->Last()
281 // lasttransLine = DSCIL's first transition
282 Standard_Real PIfound = TopOpeBRepDS_InterferenceTool::Parameter(Ifound);
283 Standard_Boolean fermee = L.IsVClosed();
284 Standard_Boolean lastonsort = LITdefinie && M_FORWARD(lasttransLine.Orientation(TopAbs_OUT));
286 Standard_Boolean kpartclosingwalki = (LITdefinie && !lastonsort);
287 kpartclosingwalki = kpartclosingwalki && CPIfound && samepar;
288 kpartclosingwalki = kpartclosingwalki && onsort;
289 kpartclosingwalki = kpartclosingwalki && fermee;
290 kpartclosingwalki = kpartclosingwalki && (PIfound == 1.0);
291 kpartclosingwalki = kpartclosingwalki && (iVP == iINON1+1) && (iVP != iINONn);
292 if (kpartclosingwalki) {
293 keep = Standard_False;
299 } // FUNBREP_topowalki_new
302 extern Standard_Boolean GLOBAL_bvpr;
303 Standard_EXPORT void debvpr2(void) {}
306 //----------------------------------------------------------------------
307 Standard_Boolean FUNBREP_topowalki
308 (const Handle(TopOpeBRepDS_Interference)& Ifound,const TopOpeBRepDS_ListOfInterference& DSCIL,const TopOpeBRep_LineInter& L,
309 const TopOpeBRep_VPointInter& VP,const TopOpeBRepDS_Transition& lasttransLine,
310 // const TopOpeBRepDS_DataStructure& BDS,
311 const TopOpeBRepDS_DataStructure& ,
312 const TopoDS_Shape& E,
313 // const TopoDS_Shape& F,
314 const TopoDS_Shape& ,
315 // const Standard_Real toluv,
316 const Standard_Real ,
317 const Standard_Boolean CPIfound,const Standard_Boolean samepar, const Standard_Boolean couture,
318 // Standard_Real& parline,
320 TopOpeBRepDS_Transition& transLine)
321 //----------------------------------------------------------------------
324 Standard_Boolean trc = TopOpeBRepDS_GettraceDSF();
327 if (L.TypeLineCurve() != TopOpeBRep_WALKING) {
328 Standard_ProgramError::Raise("FUNBREP_topowalki : line is not a walking");
329 return Standard_False;
333 Standard_Boolean newkp = TopOpeBRep_GetcontextNEWKP();
335 Standard_Boolean keep = FUNBREP_topowalki_new(Ifound,DSCIL,L,VP,E,samepar,couture,transLine);
340 TopAbs_Orientation Eori = E.Orientation();
341 Standard_Integer iVP = VP.Index();
342 Standard_Integer iINON1,iINONn,nINON; L.VPBounds(iINON1,iINONn,nINON);
343 Standard_Boolean fermee = L.IsVClosed();
344 Standard_Boolean onsort = (transLine.Orientation(TopAbs_OUT) == TopAbs_FORWARD);
345 Standard_Boolean lastdefinie = ! lasttransLine.IsUnknown();
346 Standard_Boolean lastonsort = Standard_False;
347 Standard_Boolean lastinin = Standard_False;
350 lastonsort = (lasttransLine.Orientation(TopAbs_OUT) == TopAbs_FORWARD);
351 lastinin = (lasttransLine.Before() == TopAbs_IN);
352 lastinin = lastinin && (lasttransLine.After() == TopAbs_IN);
355 Standard_Boolean LITdefinie = Standard_False;
356 Standard_Boolean LITonsort = Standard_False;
357 TopOpeBRepDS_Transition LIT;
358 Handle(TopOpeBRepDS_Interference) I;
359 Standard_Boolean nointerf = DSCIL.IsEmpty();
362 LIT = I->Transition();
363 LITdefinie = ! LIT.IsUnknown();
364 if (LITdefinie) LITonsort = (LIT.Orientation(TopAbs_OUT) == TopAbs_FORWARD);
367 Standard_Boolean keep = Standard_True;
368 Standard_Boolean EFR = (Eori == TopAbs_FORWARD || Eori == TopAbs_REVERSED);
372 Standard_Boolean condCTS19305 = Standard_False;
373 // start debug 971216 : CTS19305
374 condCTS19305 = (!CPIfound);
375 condCTS19305 = condCTS19305 && (!fermee);
376 condCTS19305 = condCTS19305 && (!lastdefinie);
377 condCTS19305 = condCTS19305 && (iVP == 1) && (iVP == iINON1);
378 if ( condCTS19305 ) {
379 keep = Standard_True;
380 transLine = TopOpeBRepDS_Transition(TopAbs_OUT,TopAbs_IN);
382 // end debug 971216 :
383 else keep = Standard_False;
385 if (iVP == iINONn) keep = Standard_False;
386 if (!EFR) { // E INTERNAL ou EXTERNAL
388 transLine = TopOpeBRepDS_Transition(TopAbs_OUT,TopAbs_IN);
393 if (keep && LITdefinie) {
394 Standard_Boolean LprecIsEntrant = (LITdefinie && !LITonsort);
395 Standard_Boolean entrantsortant = LprecIsEntrant && onsort;
397 if ( iVP == iINONn) {
398 transLine = TopOpeBRepDS_Transition(TopAbs_IN,TopAbs_OUT);
402 Standard_Boolean condCTS19305 = Standard_False;
403 condCTS19305 = (!CPIfound);
404 condCTS19305 = condCTS19305 && (!fermee);
405 condCTS19305 = condCTS19305 && (lastdefinie && !lastonsort);
406 condCTS19305 = condCTS19305 && (LITdefinie && !LITonsort);
407 condCTS19305 = condCTS19305 && (iVP == iINONn);
409 if ( condCTS19305 ) {
410 keep = Standard_True;
411 transLine = TopOpeBRepDS_Transition(TopAbs_IN,TopAbs_OUT);
414 if ( !entrantsortant ) {
415 keep = Standard_False;
420 // vp describing the same geometric point on closing edge :
421 // it is the same vp described on the FORWARD and REVERSED closing edge -> we keep it only once
422 // INFO : on walking, vp line parameter is the vp index on the walking
423 // samepar => describes same CPI
425 Standard_Boolean samevponcouture = samepar && couture;
426 if (keep && samevponcouture) {
427 keep = Standard_False;
430 if (trc) cout<<"is same vp on couture";
436 if (GLOBAL_bvpr) debvpr2();
439 if (CPIfound && samepar) {
440 Standard_Real PIfound = TopOpeBRepDS_InterferenceTool::Parameter(Ifound);
443 Standard_Boolean cond1 = Standard_True;
444 cond1 = cond1 && (lastdefinie && !lastonsort);
445 cond1 = cond1 && onsort;
446 cond1 = cond1 && fermee;
447 cond1 = cond1 && (CPIfound && samepar);
448 cond1 = cond1 && (PIfound == 1.0);
449 cond1 = cond1 && (iVP==iINON1+1) && (iVP != iINONn);
451 keep = Standard_False;
456 Standard_Boolean cond2 = Standard_True;
457 cond2 = cond2 && (lastdefinie && !lastonsort);
458 cond1 = cond1 && onsort;
459 cond2 = cond2 && (!fermee);
460 cond2 = cond2 && (CPIfound && samepar);
461 cond2 = cond2 && (PIfound == 1.0);
462 cond2 = cond2 && (iVP==iINON1+1) && (iVP != iINONn);
464 keep = Standard_False;
470 } // keep && LITdefinie
472 if (keep) STATIC_lastVPind = iVP;
474 } // FUNBREP_topowalki
476 //----------------------------------------------------------------------
477 Standard_Boolean FUNBREP_topogline_new
478 (const TopOpeBRepDS_ListOfInterference& DSCIL,const TopOpeBRep_LineInter& L, const TopOpeBRep_VPointInter& VP,
479 const TopOpeBRepDS_DataStructure& BDS,const Standard_Real toluv,
480 const Standard_Boolean samepar, const Standard_Boolean couture,
481 Standard_Real& parline,TopOpeBRepDS_Transition& transLine)
482 //----------------------------------------------------------------------
484 if (L.TypeLineCurve() == TopOpeBRep_WALKING) {
485 Standard_ProgramError::Raise("FUNBREP_topogline_new : line is not a GLine");
486 return Standard_False;
489 Standard_Integer iVP = VP.Index();
490 Standard_Integer iINON1,iINONn,nINON; L.VPBounds(iINON1,iINONn,nINON);
492 // if VP<iVP> is on 3
493 // and VP on 1 has transition OUT/IN,
494 // VP on 2 has transition IN/OUT,
495 // same VP will be kept.
497 // the line is described with (VPmin,VPmax) boundaries.
498 // if VP == VPmax, as we are only regarding IN/OUT transitions->ok
500 Standard_Boolean dscilempty = DSCIL.IsEmpty();
501 Standard_Boolean notkept = !dscilempty && (iVP == 1);
502 if (notkept) return Standard_False;
504 // <transLine> : for unknown current transition
506 // (see TopOpeBRep_FacesFiller::ProcessVPonR)
507 // vpmin with transition UNKNOWN => transLine-> OUT/IN
508 // vpmin OUT/IN, vpmax with transition UNKNOWN => transLine-> IN/OUT
509 TopOpeBRepDS_Transition LIT;
510 Handle(TopOpeBRepDS_Interference) I;
511 Standard_Boolean LITdefinie,LITonsort; LITdefinie = LITonsort = Standard_False;
514 LIT = I->Transition();
515 LITdefinie = ! LIT.IsUnknown();
516 if (LITdefinie) LITonsort = M_FORWARD( LIT.Orientation(TopAbs_OUT) );
518 Standard_Boolean trliunk = transLine.IsUnknown();
519 Standard_Boolean isfirstvp = (iVP == iINON1);
520 Standard_Boolean islastvp = (iVP == iINONn);
522 if (isfirstvp) transLine = TopOpeBRepDS_Transition(TopAbs_OUT,TopAbs_IN);
523 if (islastvp && LITdefinie && !LITonsort) transLine = LIT.Complement();
527 Standard_Boolean onsort = M_FORWARD( transLine.Orientation(TopAbs_OUT) );
528 Standard_Boolean hasfp = L.HasFirstPoint(), haslp = L.HasLastPoint();
529 Standard_Boolean hasfol = hasfp || haslp;
530 Standard_Boolean keep = Standard_True;
532 // no last defined transition :
533 // ----------------------------
535 if (onsort) keep = Standard_False;
536 if (iVP == iINONn) keep = Standard_False;
539 // has last defined transition :
540 // -----------------------------
542 Standard_Boolean LprecIsEntrant = (LITdefinie && !LITonsort);
543 Standard_Boolean entrantsortant = LprecIsEntrant && onsort;
544 if(!entrantsortant) keep = Standard_False;
546 Standard_Boolean sameparoncouture = samepar && couture;
547 if (sameparoncouture && hasfol && keep) {
549 // INFO : on geometric line, vp parameter on line is the point on
550 // curve's parameter.
551 TopOpeBRepDS_Point pntVP = TopOpeBRep_PointGeomTool::MakePoint(VP);
552 Standard_Boolean samegp = FUNBREP_HasSameGPoint(pntVP,I,BDS);
554 // !fermee : same p3d && samepar => same CPI
555 // fermee : (same p3d && samepar
556 // && sameUVon1 && sameUVon2) => same CPI
557 Standard_Boolean fermee = L.IsVClosed();
558 if (!fermee && samegp) keep = Standard_False;
559 if (fermee && samegp) {
560 // 2 vp describing a closing line describe the same 3dpoint
561 // have same parameter, but do not describe the same uv
562 // points on the closed surface (cobo121)
563 const TopOpeBRep_VPointInter& lastVP = L.VPoint(STATIC_lastVPind);
564 Standard_Boolean sameUVon1 = FUNBREP_SameUV(VP,lastVP,1,toluv);
565 Standard_Boolean sameUVon2 = FUNBREP_SameUV(VP,lastVP,2,toluv);
566 keep = !(sameUVon1 && sameUVon2);
569 if (sameparoncouture && !hasfol) {
571 // we have to parametrize the found interference (parameter PIfound)
572 // and next interference (parline)
573 Handle(TopOpeBRepDS_Interference) Ifound = DSCIL.First();
574 Standard_Real PIfound = TopOpeBRepDS_InterferenceTool::Parameter(Ifound);
575 FUNBREP_Periodize(L,Ifound,PIfound,parline);
576 TopOpeBRepDS_InterferenceTool::Parameter(Ifound,PIfound);
577 transLine = LIT.Complement();
582 if (keep) STATIC_lastVPind = iVP;
585 } // FUNBREP_topogline_new
587 //----------------------------------------------------------------------
588 static Standard_Boolean FUNBREP_topogline
589 (const Handle(TopOpeBRepDS_Interference)& Ifound,const TopOpeBRepDS_ListOfInterference& DSCIL,const TopOpeBRep_LineInter& L,
590 const TopOpeBRep_VPointInter& VP,
591 const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& E,
592 // const TopoDS_Shape& F,
593 const TopoDS_Shape& ,
594 const Standard_Real toluv,
595 // const Standard_Boolean CPIfound,
596 const Standard_Boolean ,
597 const Standard_Boolean samepar,const Standard_Boolean couture,
598 Standard_Real& parline,TopOpeBRepDS_Transition& transLine)
599 //----------------------------------------------------------------------
601 if (L.TypeLineCurve() == TopOpeBRep_WALKING) {
602 Standard_ProgramError::Raise("FUNBREP_topogline : line is not a GLine");
603 return Standard_False;
607 Standard_Boolean newkp = TopOpeBRep_GetcontextNEWKP();
609 Standard_Boolean keep = FUNBREP_topogline_new(DSCIL,L,VP,BDS,toluv,samepar,couture,parline,transLine);
614 TopAbs_Orientation Eori = E.Orientation();
615 Standard_Boolean EFR = M_FORWARD(Eori) || M_REVERSED(Eori);
616 Standard_Integer iVP = VP.Index();
617 Standard_Integer iINON1,iINONn,nINON; L.VPBounds(iINON1,iINONn,nINON);
618 Standard_Boolean fermee = L.IsVClosed();
620 if (!EFR) { // E INTERNAL ou EXTERNAL
621 if (iVP == iINON1) transLine = TopOpeBRepDS_Transition(TopAbs_OUT,TopAbs_IN);
622 if (iVP == iINONn) transLine = TopOpeBRepDS_Transition(TopAbs_IN,TopAbs_OUT);
624 Standard_Boolean onsort = (transLine.Orientation(TopAbs_OUT) == TopAbs_FORWARD);
626 Standard_Boolean LITdefinie = Standard_False;
627 Standard_Boolean LITonsort = Standard_False;
628 TopOpeBRepDS_Transition LIT;
629 Handle(TopOpeBRepDS_Interference) I;
630 Standard_Boolean dscilempty = DSCIL.IsEmpty();
632 // xpu : 28-05-97 : if VP<iVP> is on 3 and
633 // VP on 1 has transition OUT/IN, VP on 2 has transition IN/OUT,
634 // same VP will be kept.
635 // the line is described with (VPmin,VPmax) boundaries.
636 // if VP is VPmax, as we are only regarding IN/OUT transitions->ok
638 Standard_Boolean newvvv = Standard_True;// xpu : 28-05-97
640 Standard_Boolean notkept = !dscilempty && (iVP == 1);
641 if (notkept) return Standard_False;
646 LIT = I->Transition();
647 LITdefinie = ! LIT.IsUnknown();
648 if (LITdefinie) LITonsort = (LIT.Orientation(TopAbs_OUT) == TopAbs_FORWARD);
651 // xpu : 21-05-97 (see TopOpeBRep_FacesFiller::ProcessVPonR)
652 // vpmin with transition UNKNOWN =>transLine-> OUT/IN
653 // vpmin OUT/IN, vpmax with transition UNKNOWN =>transLine-> IN/OUT
654 Standard_Boolean trliunk = transLine.IsUnknown();
655 Standard_Boolean newvv = Standard_True;// xpu : 21-05-97
656 Standard_Boolean isfirstvp = (iVP == iINON1);
657 Standard_Boolean islastvp = (iVP == iINONn);
658 if (newvv && trliunk) {
660 transLine = TopOpeBRepDS_Transition(TopAbs_OUT,TopAbs_IN);
661 onsort = Standard_False;
664 if (LITdefinie && !LITonsort) {
665 transLine = LIT.Complement();
666 onsort = Standard_True;
670 Standard_Boolean hasfp = L.HasFirstPoint();
671 Standard_Boolean haslp = L.HasLastPoint();
672 Standard_Boolean hasfol = hasfp || haslp;
674 Standard_Boolean keep = Standard_True;
677 if (onsort) keep = Standard_False;
678 if (iVP == iINONn) keep = Standard_False;
681 Standard_Boolean LprecIsEntrant = (LITdefinie && !LITonsort);
682 Standard_Boolean entrantsortant = LprecIsEntrant && onsort;
683 if(!entrantsortant) keep = Standard_False;
685 Standard_Boolean sameparoncouture = samepar && couture;
686 if (sameparoncouture && hasfol) {
688 // INFO : on geometric line, vp parameter on line is the point on
690 TopOpeBRepDS_Point pntVP = TopOpeBRep_PointGeomTool::MakePoint(VP);
691 Standard_Boolean samegp = FUNBREP_HasSameGPoint(pntVP,I,BDS);
692 const TopOpeBRep_VPointInter& lastVP = L.VPoint(STATIC_lastVPind);
693 // if the line is not closed, same p3d and samepar represent
696 // 2 vp describing a closing line describe the same 3dpoint
697 // have same parameter, but do not describe the same uv
698 // points on the closed surface (cobo121)
699 Standard_Boolean sameUVon1 = FUNBREP_SameUV(VP,lastVP,1,toluv);
700 Standard_Boolean sameUVon2 = FUNBREP_SameUV(VP,lastVP,2,toluv);
701 samegp = samegp && sameUVon1 && sameUVon2;
703 if (samegp) keep = Standard_False;
706 if (sameparoncouture && !hasfol) {
707 // parametrize Ifound (parameter PIfound) and next interference (parline)
708 Standard_Real PIfound = TopOpeBRepDS_InterferenceTool::Parameter(Ifound);
709 FUNBREP_Periodize(L,Ifound,PIfound,parline);
710 TopOpeBRepDS_InterferenceTool::Parameter(Ifound,PIfound);
711 if (LITdefinie) transLine = LIT.Complement();
715 if (keep) STATIC_lastVPind = iVP;
718 } // end of FUNBREP_topogline
720 //-----------------------------------------------------------------------
721 static Standard_Boolean TopoParameter(const TopOpeBRep_LineInter& L,const Handle(TopOpeBRepDS_Interference)& I,
722 const Standard_Real parline,const Standard_Boolean closingedge)
723 //-----------------------------------------------------------------------
725 if ( I.IsNull() ) return Standard_False;
726 Standard_Boolean samepar = Standard_False;
727 Standard_Real pCPI = TopOpeBRepDS_InterferenceTool::Parameter(I);
729 samepar = (Abs(parline-pCPI)<Precision::PConfusion());
731 // trouve et couture et courbe periodique :
732 // on retourne vrai pour laisser a FUNBREP_topokpart
733 // le soin de definir correctement les couples
734 // (parametre, transition) pour les points confondus sur couture.
735 Standard_Boolean perio = L.IsPeriodic();
737 samepar = Standard_True;
740 samepar = (Abs(parline-pCPI)<Precision::PConfusion());
746 //----------------------------------------------------------------------
747 Standard_EXPORT Standard_Boolean FUNBREP_topokpart
748 (const Handle(TopOpeBRepDS_Interference)& Ifound,const TopOpeBRepDS_ListOfInterference& DSCIL,
749 const TopOpeBRep_LineInter& L,const TopOpeBRep_VPointInter& VP,
750 const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& E,const TopoDS_Shape& F,const Standard_Real toluv,
751 Standard_Real& parline,TopOpeBRepDS_Transition& transLine)
752 //----------------------------------------------------------------------
754 Standard_Boolean keep = Standard_True;
756 Standard_Boolean CPIfound = !Ifound.IsNull();
757 Standard_Boolean couture = TopOpeBRepTool_ShapeTool::Closed(TopoDS::Edge(E),TopoDS::Face(F));
758 Standard_Boolean samepar = Standard_False; // = True if current VPoint falls on an existing geometry with an equal parameter.
759 if (!CPIfound) samepar = Standard_False;
760 else samepar = CPIfound ? TopoParameter(L,Ifound,parline,couture) : Standard_False;
762 TopOpeBRepDS_Transition lasttransLine;
763 if (!DSCIL.IsEmpty()) lasttransLine = DSCIL.Last()->Transition(); // xpu12-12-97
765 if (TopOpeBRepDS_GettraceDSF()) {
766 FUNBREP_topokpartDEB(Ifound,DSCIL,L,VP,lasttransLine,BDS,E,F,toluv,
767 CPIfound,samepar,couture,parline,transLine);
771 // A line is valid if at least it has VPi1 and VPi2 with i1 < i2 and :
772 // transition on line for VPi1 : OUT/IN and for VPi2 : IN/OUT.
773 // When <VPj> is on j=i1/i2, we keep it (returning true).
774 // Rmq :VP internal to the face is given with transition on line
775 // OUT/IN or IN/OUT if it is on the beginning or on the end
778 if (L.TypeLineCurve() == TopOpeBRep_WALKING) {
779 keep = FUNBREP_topowalki(Ifound,DSCIL,L,VP,lasttransLine,BDS,E,F,toluv,
780 CPIfound,samepar,couture,parline,transLine);
783 keep = FUNBREP_topogline(Ifound,DSCIL,L,VP,BDS,E,F,toluv,
784 CPIfound,samepar,couture,parline,transLine);
787 } // end of FUNBREP_tpokpart