0027961: Visualization - remove unused and no more working OpenGl_AVIWriter
[occt.git] / src / TopOpeBRep / TopOpeBRep_kpart.cxx
CommitLineData
b311480e 1// Created on: 1994-02-17
2// Created by: Jean Yves LEBEY
3// Copyright (c) 1994-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17
7fd59977 18#include <Geom2d_Curve.hxx>
42cf5bc1 19#include <Geom_Curve.hxx>
20#include <gp_Pnt.hxx>
21#include <Precision.hxx>
22#include <Standard_DomainError.hxx>
23#include <Standard_ProgramError.hxx>
24#include <TopoDS.hxx>
25#include <TopoDS_Face.hxx>
26#include <TopoDS_Shape.hxx>
27#include <TopOpeBRep.hxx>
28#include <TopOpeBRep_FacesFiller.hxx>
29#include <TopOpeBRep_FacesIntersector.hxx>
30#include <TopOpeBRep_FFDumper.hxx>
7fd59977 31#include <TopOpeBRep_FFTransitionTool.hxx>
42cf5bc1 32#include <TopOpeBRep_LineInter.hxx>
33#include <TopOpeBRep_PointClassifier.hxx>
7fd59977 34#include <TopOpeBRep_PointGeomTool.hxx>
42cf5bc1 35#include <TopOpeBRep_VPointInter.hxx>
36#include <TopOpeBRep_VPointInterClassifier.hxx>
37#include <TopOpeBRep_VPointInterIterator.hxx>
7fd59977 38#include <TopOpeBRepDS_Config.hxx>
39#include <TopOpeBRepDS_Curve.hxx>
42cf5bc1 40#include <TopOpeBRepDS_DataStructure.hxx>
41#include <TopOpeBRepDS_define.hxx>
42#include <TopOpeBRepDS_HDataStructure.hxx>
43#include <TopOpeBRepDS_Interference.hxx>
44#include <TopOpeBRepDS_InterferenceTool.hxx>
45#include <TopOpeBRepDS_Point.hxx>
7fd59977 46#include <TopOpeBRepDS_PointIterator.hxx>
42cf5bc1 47#include <TopOpeBRepDS_Transition.hxx>
7fd59977 48#include <TopOpeBRepTool_ShapeTool.hxx>
49#include <TopTools_IndexedMapOfShape.hxx>
7fd59977 50
0797d9d3 51#ifdef OCCT_DEBUG
1d0a9d4d 52extern Standard_Boolean TopOpeBRep_GetcontextNEWKP();
7fd59977 53#endif
54
55// VP<STATIC_lastVPind> is the vp on which was computed the last CPI.
56// if no CPI is computed yet, <STATIC_lastVPind> = 0.
57static Standard_Integer STATIC_lastVPind;
58
59#define M_FORWARD( st) (st == TopAbs_FORWARD)
60#define M_REVERSED(st) (st == TopAbs_REVERSED)
61#define M_INTERNAL(st) (st == TopAbs_INTERNAL)
62#define M_EXTERNAL(st) (st == TopAbs_EXTERNAL)
63
64//-----------------------------------------------------------------------
65static void FUNBREP_Periodize
66(const TopOpeBRep_LineInter& L,const Handle(TopOpeBRepDS_Interference)& Ifound,Standard_Real& PIfound,Standard_Real& parline)
67//-----------------------------------------------------------------------
68{
69 const TopOpeBRepDS_Transition& TIfound = Ifound->Transition();
70 TopAbs_Orientation OTIfound = TIfound.Orientation(TopAbs_IN);
71
72 if (L.IsPeriodic()) {
73 Standard_Real f,l; L.Bounds(f,l);
74 Standard_Boolean onf = Abs(parline-f) < Precision::PConfusion();
75 Standard_Boolean onl = Abs(parline-l) < Precision::PConfusion();
76 Standard_Boolean onfl = onf || onl;
77 if ( onfl ) {
78 if ( OTIfound == TopAbs_FORWARD ) {
79 PIfound = f;
80 parline = l;
81 }
82 else if ( OTIfound == TopAbs_REVERSED ) {
83 PIfound = l;
84 parline = f;
85 }
86 else {
87 Standard_ProgramError::Raise("FUNBREP_Periodize");
88 }
89 } // onfl
90 else {
91 parline = PIfound = Min(parline,PIfound);
92 }
93 } // IsPeriodic
94 else {
95 parline = PIfound = Min(parline,PIfound);
96 }
97}
98
99//-----------------------------------------------------------------------
100static Standard_Boolean FUNBREP_HasSameGPoint(const TopOpeBRepDS_Point& DSP,const Handle(TopOpeBRepDS_Interference)& I,
101 const TopOpeBRepDS_DataStructure& BDS)
102//-----------------------------------------------------------------------
103{
104 // returns <true> if <DSP> shares same geometric point with
105 // <I> geometry.
106 Standard_Integer G = I->Geometry();
107 Standard_Boolean samegp = Standard_False;
108 if ( I->GeometryType() == TopOpeBRepDS_POINT ) {
109 const TopOpeBRepDS_Point& P = BDS.Point(G);
110 samegp = DSP.IsEqual(P);
111 }
112 else if ( I->GeometryType() == TopOpeBRepDS_VERTEX ) {
113 TopOpeBRepDS_Point P(BDS.Shape(G));
114 samegp = DSP.IsEqual(P);
115 }
116 return samegp;
117}
118
119//-----------------------------------------------------------------------
120static Standard_Boolean FUNBREP_SameUV(const TopOpeBRep_VPointInter& VP1,
121 const TopOpeBRep_VPointInter& VP2,
122 const Standard_Integer sind,const Standard_Real toluv)
123//-----------------------------------------------------------------------
124{
1d47d8d0 125 Standard_Real u1 = 0.,v1 = 0.,u2 = 0.,v2 = 0.;
7fd59977 126 if (sind == 1) {
127 VP1.ParametersOnS1(u1,v1); VP2.ParametersOnS1(u2,v2);
128 }
129 if (sind == 2) {
130 VP1.ParametersOnS2(u1,v1); VP2.ParametersOnS2(u2,v2);
131 }
132 gp_Pnt2d p1(u1,v1), p2(u2,v2);
133 Standard_Real dist = p1.Distance(p2);
134 Standard_Boolean sameuv = (dist < toluv);
135 return sameuv;
136}
137
7fd59977 138//----------------------------------------------------------------------
139Standard_Boolean FUNBREP_topowalki_new
140(const Handle(TopOpeBRepDS_Interference)& Ifound,const TopOpeBRepDS_ListOfInterference& DSCIL,const TopOpeBRep_LineInter& L,
141 const TopOpeBRep_VPointInter& VP,const TopoDS_Shape& E,const Standard_Boolean samepar,const Standard_Boolean couture,
142 TopOpeBRepDS_Transition& transLine)
143//----------------------------------------------------------------------
144{
7fd59977 145 if (L.TypeLineCurve() != TopOpeBRep_WALKING) {
146 Standard_ProgramError::Raise("FUNBREP_topowalki_new : line is not a walking");
147 return Standard_False;
148 }
149
150 Standard_Boolean CPIfound = !Ifound.IsNull();
151 Standard_Integer iVP = VP.Index();
152 Standard_Integer iINON1,iINONn,nINON; L.VPBounds(iINON1,iINONn,nINON);
153 Standard_Boolean onsort = (transLine.Orientation(TopAbs_OUT) == TopAbs_FORWARD);
154
155 Standard_Boolean LITdefinie = DSCIL.IsEmpty()? Standard_False: !DSCIL.Last()->Transition().IsUnknown();
156
157 // dealing with INTERNAL/EXTERNAL <E> :
158 // ------------------------------------
159 TopAbs_Orientation Eori = E.Orientation();
160 Standard_Boolean EFR = M_FORWARD(Eori) || M_REVERSED(Eori);
161 if (!EFR) { // E INTERNAL ou EXTERNAL
162 // we assume transition for first vp on non oriented edge to be FORWARD
163 // last vp on non oriented edge to be REVERSED
164 if (iVP == iINON1) transLine = TopOpeBRepDS_Transition(TopAbs_OUT,TopAbs_IN);
165 if (iVP == iINONn) transLine = TopOpeBRepDS_Transition(TopAbs_IN,TopAbs_OUT);
166 }
167
168 // no last defined transition :
169 // ----------------------------
170 if (!LITdefinie) {
171 if (onsort) return Standard_False;
172 if (iVP == iINONn) return Standard_False;
173 }
174
175 // has last defined transition :
176 // -----------------------------
177 Standard_Boolean keep = Standard_True;
178 if (LITdefinie) {
179
180 Handle(TopOpeBRepDS_Interference) I = DSCIL.Last();
181 TopOpeBRepDS_Transition LIT = I->Transition();
182 Standard_Boolean LITonsort = M_FORWARD( LIT.Orientation(TopAbs_OUT) );
183 Standard_Boolean LprecIsEntrant = !LITonsort;
184 Standard_Boolean entrantsortant = LprecIsEntrant && onsort;
185
186 if(EFR && !entrantsortant) keep = Standard_False;
187
188 if (couture) {
189 // vp describing the same geometric point on closing edge :
190 // it is the same vp described on the FORWARD and REVERSED closing edge -> we keep it only once
191 // INFO : on walking, vp line parameter is the vp index on the walking
192 // samepar => describes same CPI
193 Standard_Boolean samevponcouture = samepar && keep;
194 if (samevponcouture) {
195 keep = Standard_False;
7fd59977 196 }
197 }
198
199 { // kpart JYL 971204 for closing walking, first and current VP same parameter,
200 // lastonentre && onsort,
201 // first VP is first walking point (PIfound == 1.0),
202 // current VP is the second one on walking and not the last.
51740958 203 const Handle(TopOpeBRepDS_Interference)& anI = DSCIL.First();
204 const TopOpeBRepDS_Transition& lasttransLine = anI->Transition();
7fd59977 205 // xpu12-12-97 : line is built on only 2 vp,
206 // DSCIL->First() == DSCIL->Last()
207 // lasttransLine = DSCIL's first transition
208 Standard_Real PIfound = TopOpeBRepDS_InterferenceTool::Parameter(Ifound);
209 Standard_Boolean fermee = L.IsVClosed();
210 Standard_Boolean lastonsort = LITdefinie && M_FORWARD(lasttransLine.Orientation(TopAbs_OUT));
211
212 Standard_Boolean kpartclosingwalki = (LITdefinie && !lastonsort);
213 kpartclosingwalki = kpartclosingwalki && CPIfound && samepar;
214 kpartclosingwalki = kpartclosingwalki && onsort;
215 kpartclosingwalki = kpartclosingwalki && fermee;
216 kpartclosingwalki = kpartclosingwalki && (PIfound == 1.0);
217 kpartclosingwalki = kpartclosingwalki && (iVP == iINON1+1) && (iVP != iINONn);
218 if (kpartclosingwalki) {
219 keep = Standard_False;
220 }
221 }
222 } // LITdefinie
223
224 return keep;
225} // FUNBREP_topowalki_new
226
0797d9d3 227#ifdef OCCT_DEBUG
1d0a9d4d 228extern Standard_Boolean GLOBAL_bvpr;
7fd59977 229Standard_EXPORT void debvpr2(void) {}
230#endif
231
232//----------------------------------------------------------------------
233Standard_Boolean FUNBREP_topowalki
234(const Handle(TopOpeBRepDS_Interference)& Ifound,const TopOpeBRepDS_ListOfInterference& DSCIL,const TopOpeBRep_LineInter& L,
235 const TopOpeBRep_VPointInter& VP,const TopOpeBRepDS_Transition& lasttransLine,
236// const TopOpeBRepDS_DataStructure& BDS,
237 const TopOpeBRepDS_DataStructure& ,
238 const TopoDS_Shape& E,
239// const TopoDS_Shape& F,
240 const TopoDS_Shape& ,
241// const Standard_Real toluv,
242 const Standard_Real ,
243 const Standard_Boolean CPIfound,const Standard_Boolean samepar, const Standard_Boolean couture,
244// Standard_Real& parline,
245 Standard_Real& ,
246 TopOpeBRepDS_Transition& transLine)
247//----------------------------------------------------------------------
248{
7fd59977 249 if (L.TypeLineCurve() != TopOpeBRep_WALKING) {
250 Standard_ProgramError::Raise("FUNBREP_topowalki : line is not a walking");
251 return Standard_False;
252 }
253
0797d9d3 254#ifdef OCCT_DEBUG
7fd59977 255 Standard_Boolean newkp = TopOpeBRep_GetcontextNEWKP();
256 if (newkp) {
257 Standard_Boolean keep = FUNBREP_topowalki_new(Ifound,DSCIL,L,VP,E,samepar,couture,transLine);
258 return keep;
259 }
260#endif
261
262 TopAbs_Orientation Eori = E.Orientation();
263 Standard_Integer iVP = VP.Index();
264 Standard_Integer iINON1,iINONn,nINON; L.VPBounds(iINON1,iINONn,nINON);
265 Standard_Boolean fermee = L.IsVClosed();
266 Standard_Boolean onsort = (transLine.Orientation(TopAbs_OUT) == TopAbs_FORWARD);
267 Standard_Boolean lastdefinie = ! lasttransLine.IsUnknown();
268 Standard_Boolean lastonsort = Standard_False;
269 Standard_Boolean lastinin = Standard_False;
270
271 if (lastdefinie) {
272 lastonsort = (lasttransLine.Orientation(TopAbs_OUT) == TopAbs_FORWARD);
273 lastinin = (lasttransLine.Before() == TopAbs_IN);
274 lastinin = lastinin && (lasttransLine.After() == TopAbs_IN);
275 }
276
7fd59977 277 Standard_Boolean LITdefinie = Standard_False;
278 Standard_Boolean LITonsort = Standard_False;
279 TopOpeBRepDS_Transition LIT;
280 Handle(TopOpeBRepDS_Interference) I;
281 Standard_Boolean nointerf = DSCIL.IsEmpty();
282 if (!nointerf) {
283 I = DSCIL.Last();
7fd59977 284 LIT = I->Transition();
285 LITdefinie = ! LIT.IsUnknown();
286 if (LITdefinie) LITonsort = (LIT.Orientation(TopAbs_OUT) == TopAbs_FORWARD);
287 }
288
289 Standard_Boolean keep = Standard_True;
290 Standard_Boolean EFR = (Eori == TopAbs_FORWARD || Eori == TopAbs_REVERSED);
291
292 if (!LITdefinie) {
293 if (onsort) {
294 Standard_Boolean condCTS19305 = Standard_False;
295 // start debug 971216 : CTS19305
296 condCTS19305 = (!CPIfound);
297 condCTS19305 = condCTS19305 && (!fermee);
298 condCTS19305 = condCTS19305 && (!lastdefinie);
299 condCTS19305 = condCTS19305 && (iVP == 1) && (iVP == iINON1);
300 if ( condCTS19305 ) {
301 keep = Standard_True;
302 transLine = TopOpeBRepDS_Transition(TopAbs_OUT,TopAbs_IN);
303 }
304 // end debug 971216 :
305 else keep = Standard_False;
306 }
307 if (iVP == iINONn) keep = Standard_False;
308 if (!EFR) { // E INTERNAL ou EXTERNAL
309 if (iVP == iINON1) {
310 transLine = TopOpeBRepDS_Transition(TopAbs_OUT,TopAbs_IN);
311 }
312 }
313 }
314
315 if (keep && LITdefinie) {
316 Standard_Boolean LprecIsEntrant = (LITdefinie && !LITonsort);
317 Standard_Boolean entrantsortant = LprecIsEntrant && onsort;
318 if (!EFR) {
319 if ( iVP == iINONn) {
320 transLine = TopOpeBRepDS_Transition(TopAbs_IN,TopAbs_OUT);
321 }
322 }
323 else {
324 Standard_Boolean condCTS19305 = Standard_False;
325 condCTS19305 = (!CPIfound);
326 condCTS19305 = condCTS19305 && (!fermee);
327 condCTS19305 = condCTS19305 && (lastdefinie && !lastonsort);
328 condCTS19305 = condCTS19305 && (LITdefinie && !LITonsort);
329 condCTS19305 = condCTS19305 && (iVP == iINONn);
330
331 if ( condCTS19305 ) {
332 keep = Standard_True;
333 transLine = TopOpeBRepDS_Transition(TopAbs_IN,TopAbs_OUT);
334 }
335 else {
336 if ( !entrantsortant ) {
337 keep = Standard_False;
338 }
339 }
340 }
341
342 // vp describing the same geometric point on closing edge :
343 // it is the same vp described on the FORWARD and REVERSED closing edge -> we keep it only once
344 // INFO : on walking, vp line parameter is the vp index on the walking
345 // samepar => describes same CPI
346
347 Standard_Boolean samevponcouture = samepar && couture;
348 if (keep && samevponcouture) {
349 keep = Standard_False;
7fd59977 350 }
351
352 if (keep) {
0797d9d3 353#ifdef OCCT_DEBUG
7fd59977 354 if (GLOBAL_bvpr) debvpr2();
355#endif
356
357 if (CPIfound && samepar) {
358 Standard_Real PIfound = TopOpeBRepDS_InterferenceTool::Parameter(Ifound);
359
360 // 971204
361 Standard_Boolean cond1 = Standard_True;
362 cond1 = cond1 && (lastdefinie && !lastonsort);
363 cond1 = cond1 && onsort;
364 cond1 = cond1 && fermee;
365 cond1 = cond1 && (CPIfound && samepar);
366 cond1 = cond1 && (PIfound == 1.0);
367 cond1 = cond1 && (iVP==iINON1+1) && (iVP != iINONn);
368 if ( cond1 ) {
369 keep = Standard_False;
370 return keep;
371 }
372
373 // PRO12107
374 Standard_Boolean cond2 = Standard_True;
375 cond2 = cond2 && (lastdefinie && !lastonsort);
376 cond1 = cond1 && onsort;
377 cond2 = cond2 && (!fermee);
378 cond2 = cond2 && (CPIfound && samepar);
379 cond2 = cond2 && (PIfound == 1.0);
380 cond2 = cond2 && (iVP==iINON1+1) && (iVP != iINONn);
381 if ( cond2 ) {
382 keep = Standard_False;
383 return keep;
384 }
385 }
386 } // keep
387
388 } // keep && LITdefinie
389
390 if (keep) STATIC_lastVPind = iVP;
391 return keep;
392} // FUNBREP_topowalki
393
394//----------------------------------------------------------------------
395Standard_Boolean FUNBREP_topogline_new
396(const TopOpeBRepDS_ListOfInterference& DSCIL,const TopOpeBRep_LineInter& L, const TopOpeBRep_VPointInter& VP,
397 const TopOpeBRepDS_DataStructure& BDS,const Standard_Real toluv,
398 const Standard_Boolean samepar, const Standard_Boolean couture,
399 Standard_Real& parline,TopOpeBRepDS_Transition& transLine)
400//----------------------------------------------------------------------
401{
402 if (L.TypeLineCurve() == TopOpeBRep_WALKING) {
403 Standard_ProgramError::Raise("FUNBREP_topogline_new : line is not a GLine");
404 return Standard_False;
405 }
7fd59977 406
407 Standard_Integer iVP = VP.Index();
408 Standard_Integer iINON1,iINONn,nINON; L.VPBounds(iINON1,iINONn,nINON);
409
410 // if VP<iVP> is on 3
411 // and VP on 1 has transition OUT/IN,
412 // VP on 2 has transition IN/OUT,
413 // same VP will be kept.
414
415 // the line is described with (VPmin,VPmax) boundaries.
416 // if VP == VPmax, as we are only regarding IN/OUT transitions->ok
417 // if VP == VPmin :
418 Standard_Boolean dscilempty = DSCIL.IsEmpty();
419 Standard_Boolean notkept = !dscilempty && (iVP == 1);
420 if (notkept) return Standard_False;
421
422 // <transLine> : for unknown current transition
423 // ------------
424 // (see TopOpeBRep_FacesFiller::ProcessVPonR)
425 // vpmin with transition UNKNOWN => transLine-> OUT/IN
426 // vpmin OUT/IN, vpmax with transition UNKNOWN => transLine-> IN/OUT
427 TopOpeBRepDS_Transition LIT;
428 Handle(TopOpeBRepDS_Interference) I;
429 Standard_Boolean LITdefinie,LITonsort; LITdefinie = LITonsort = Standard_False;
430 if ( !dscilempty ) {
431 I = DSCIL.Last();
432 LIT = I->Transition();
433 LITdefinie = ! LIT.IsUnknown();
434 if (LITdefinie) LITonsort = M_FORWARD( LIT.Orientation(TopAbs_OUT) );
435 }
436 Standard_Boolean trliunk = transLine.IsUnknown();
437 Standard_Boolean isfirstvp = (iVP == iINON1);
438 Standard_Boolean islastvp = (iVP == iINONn);
439 if (trliunk) {
440 if (isfirstvp) transLine = TopOpeBRepDS_Transition(TopAbs_OUT,TopAbs_IN);
441 if (islastvp && LITdefinie && !LITonsort) transLine = LIT.Complement();
442 }
443
444
445 Standard_Boolean onsort = M_FORWARD( transLine.Orientation(TopAbs_OUT) );
446 Standard_Boolean hasfp = L.HasFirstPoint(), haslp = L.HasLastPoint();
447 Standard_Boolean hasfol = hasfp || haslp;
448 Standard_Boolean keep = Standard_True;
449
450 // no last defined transition :
451 // ----------------------------
452 if (!LITdefinie) {
453 if (onsort) keep = Standard_False;
454 if (iVP == iINONn) keep = Standard_False;
455 }
456
457 // has last defined transition :
458 // -----------------------------
459 if (LITdefinie) {
460 Standard_Boolean LprecIsEntrant = (LITdefinie && !LITonsort);
461 Standard_Boolean entrantsortant = LprecIsEntrant && onsort;
462 if(!entrantsortant) keep = Standard_False;
463
464 Standard_Boolean sameparoncouture = samepar && couture;
465 if (sameparoncouture && hasfol && keep) {
466
467 // INFO : on geometric line, vp parameter on line is the point on
468 // curve's parameter.
469 TopOpeBRepDS_Point pntVP = TopOpeBRep_PointGeomTool::MakePoint(VP);
470 Standard_Boolean samegp = FUNBREP_HasSameGPoint(pntVP,I,BDS);
471
472 // !fermee : same p3d && samepar => same CPI
473 // fermee : (same p3d && samepar
474 // && sameUVon1 && sameUVon2) => same CPI
475 Standard_Boolean fermee = L.IsVClosed();
476 if (!fermee && samegp) keep = Standard_False;
477 if (fermee && samegp) {
478 // 2 vp describing a closing line describe the same 3dpoint
479 // have same parameter, but do not describe the same uv
480 // points on the closed surface (cobo121)
481 const TopOpeBRep_VPointInter& lastVP = L.VPoint(STATIC_lastVPind);
482 Standard_Boolean sameUVon1 = FUNBREP_SameUV(VP,lastVP,1,toluv);
483 Standard_Boolean sameUVon2 = FUNBREP_SameUV(VP,lastVP,2,toluv);
484 keep = !(sameUVon1 && sameUVon2);
485 }
486 }
487 if (sameparoncouture && !hasfol) {
488
489 // we have to parametrize the found interference (parameter PIfound)
490 // and next interference (parline)
491 Handle(TopOpeBRepDS_Interference) Ifound = DSCIL.First();
492 Standard_Real PIfound = TopOpeBRepDS_InterferenceTool::Parameter(Ifound);
493 FUNBREP_Periodize(L,Ifound,PIfound,parline);
494 TopOpeBRepDS_InterferenceTool::Parameter(Ifound,PIfound);
495 transLine = LIT.Complement();
496
497 }
498 } // LITdefinie
499
500 if (keep) STATIC_lastVPind = iVP;
501 return keep;
502
503} // FUNBREP_topogline_new
504
505//----------------------------------------------------------------------
96a95605 506static Standard_Boolean FUNBREP_topogline
7fd59977 507(const Handle(TopOpeBRepDS_Interference)& Ifound,const TopOpeBRepDS_ListOfInterference& DSCIL,const TopOpeBRep_LineInter& L,
96a95605 508 const TopOpeBRep_VPointInter& VP,
7fd59977 509 const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& E,
510// const TopoDS_Shape& F,
511 const TopoDS_Shape& ,
512 const Standard_Real toluv,
513// const Standard_Boolean CPIfound,
514 const Standard_Boolean ,
515 const Standard_Boolean samepar,const Standard_Boolean couture,
516 Standard_Real& parline,TopOpeBRepDS_Transition& transLine)
517//----------------------------------------------------------------------
518{
7fd59977 519 if (L.TypeLineCurve() == TopOpeBRep_WALKING) {
520 Standard_ProgramError::Raise("FUNBREP_topogline : line is not a GLine");
521 return Standard_False;
522 }
523
0797d9d3 524#ifdef OCCT_DEBUG
7fd59977 525 Standard_Boolean newkp = TopOpeBRep_GetcontextNEWKP();
526 if (newkp) {
527 Standard_Boolean keep = FUNBREP_topogline_new(DSCIL,L,VP,BDS,toluv,samepar,couture,parline,transLine);
528 return keep;
529 }
530#endif
531
532 TopAbs_Orientation Eori = E.Orientation();
533 Standard_Boolean EFR = M_FORWARD(Eori) || M_REVERSED(Eori);
534 Standard_Integer iVP = VP.Index();
535 Standard_Integer iINON1,iINONn,nINON; L.VPBounds(iINON1,iINONn,nINON);
536 Standard_Boolean fermee = L.IsVClosed();
537
538 if (!EFR) { // E INTERNAL ou EXTERNAL
539 if (iVP == iINON1) transLine = TopOpeBRepDS_Transition(TopAbs_OUT,TopAbs_IN);
540 if (iVP == iINONn) transLine = TopOpeBRepDS_Transition(TopAbs_IN,TopAbs_OUT);
541 }
542 Standard_Boolean onsort = (transLine.Orientation(TopAbs_OUT) == TopAbs_FORWARD);
7fd59977 543
544 Standard_Boolean LITdefinie = Standard_False;
545 Standard_Boolean LITonsort = Standard_False;
546 TopOpeBRepDS_Transition LIT;
547 Handle(TopOpeBRepDS_Interference) I;
548 Standard_Boolean dscilempty = DSCIL.IsEmpty();
549
550 // xpu : 28-05-97 : if VP<iVP> is on 3 and
551 // VP on 1 has transition OUT/IN, VP on 2 has transition IN/OUT,
552 // same VP will be kept.
553 // the line is described with (VPmin,VPmax) boundaries.
554 // if VP is VPmax, as we are only regarding IN/OUT transitions->ok
555 // if VP is VPmin :
556 Standard_Boolean newvvv = Standard_True;// xpu : 28-05-97
557 if (newvvv) {
558 Standard_Boolean notkept = !dscilempty && (iVP == 1);
559 if (notkept) return Standard_False;
560 }// 28-05-97 : xpu
561
562 if ( !dscilempty ) {
563 I = DSCIL.Last();
564 LIT = I->Transition();
565 LITdefinie = ! LIT.IsUnknown();
566 if (LITdefinie) LITonsort = (LIT.Orientation(TopAbs_OUT) == TopAbs_FORWARD);
567 }
568
569 // xpu : 21-05-97 (see TopOpeBRep_FacesFiller::ProcessVPonR)
570 // vpmin with transition UNKNOWN =>transLine-> OUT/IN
571 // vpmin OUT/IN, vpmax with transition UNKNOWN =>transLine-> IN/OUT
572 Standard_Boolean trliunk = transLine.IsUnknown();
573 Standard_Boolean newvv = Standard_True;// xpu : 21-05-97
574 Standard_Boolean isfirstvp = (iVP == iINON1);
575 Standard_Boolean islastvp = (iVP == iINONn);
576 if (newvv && trliunk) {
577 if (isfirstvp) {
578 transLine = TopOpeBRepDS_Transition(TopAbs_OUT,TopAbs_IN);
579 onsort = Standard_False;
580 }
581 if (islastvp)
582 if (LITdefinie && !LITonsort) {
583 transLine = LIT.Complement();
584 onsort = Standard_True;
585 }
586 }//21-05-97 :xpu
587
588 Standard_Boolean hasfp = L.HasFirstPoint();
589 Standard_Boolean haslp = L.HasLastPoint();
590 Standard_Boolean hasfol = hasfp || haslp;
591
592 Standard_Boolean keep = Standard_True;
593
594 if (!LITdefinie) {
595 if (onsort) keep = Standard_False;
596 if (iVP == iINONn) keep = Standard_False;
597 }
598 if (LITdefinie) {
599 Standard_Boolean LprecIsEntrant = (LITdefinie && !LITonsort);
600 Standard_Boolean entrantsortant = LprecIsEntrant && onsort;
601 if(!entrantsortant) keep = Standard_False;
602
603 Standard_Boolean sameparoncouture = samepar && couture;
604 if (sameparoncouture && hasfol) {
605 if (keep) {
606 // INFO : on geometric line, vp parameter on line is the point on
607 // curve parameter.
608 TopOpeBRepDS_Point pntVP = TopOpeBRep_PointGeomTool::MakePoint(VP);
609 Standard_Boolean samegp = FUNBREP_HasSameGPoint(pntVP,I,BDS);
610 const TopOpeBRep_VPointInter& lastVP = L.VPoint(STATIC_lastVPind);
611 // if the line is not closed, same p3d and samepar represent
612 // same CPI.else :
613 if (fermee) {
614 // 2 vp describing a closing line describe the same 3dpoint
615 // have same parameter, but do not describe the same uv
616 // points on the closed surface (cobo121)
617 Standard_Boolean sameUVon1 = FUNBREP_SameUV(VP,lastVP,1,toluv);
618 Standard_Boolean sameUVon2 = FUNBREP_SameUV(VP,lastVP,2,toluv);
619 samegp = samegp && sameUVon1 && sameUVon2;
620 }
621 if (samegp) keep = Standard_False;
622 }
623 }
624 if (sameparoncouture && !hasfol) {
625 // parametrize Ifound (parameter PIfound) and next interference (parline)
626 Standard_Real PIfound = TopOpeBRepDS_InterferenceTool::Parameter(Ifound);
627 FUNBREP_Periodize(L,Ifound,PIfound,parline);
628 TopOpeBRepDS_InterferenceTool::Parameter(Ifound,PIfound);
629 if (LITdefinie) transLine = LIT.Complement();
630 }
631 }
632
633 if (keep) STATIC_lastVPind = iVP;
634 return keep;
635
636} // end of FUNBREP_topogline
637
638//-----------------------------------------------------------------------
639static Standard_Boolean TopoParameter(const TopOpeBRep_LineInter& L,const Handle(TopOpeBRepDS_Interference)& I,
640 const Standard_Real parline,const Standard_Boolean closingedge)
641//-----------------------------------------------------------------------
642{
643 if ( I.IsNull() ) return Standard_False;
644 Standard_Boolean samepar = Standard_False;
645 Standard_Real pCPI = TopOpeBRepDS_InterferenceTool::Parameter(I);
646 if (! closingedge )
647 samepar = (Abs(parline-pCPI)<Precision::PConfusion());
648 else {
649 // trouve et couture et courbe periodique :
650 // on retourne vrai pour laisser a FUNBREP_topokpart
651 // le soin de definir correctement les couples
652 // (parametre, transition) pour les points confondus sur couture.
653 Standard_Boolean perio = L.IsPeriodic();
654 if ( perio ) {
655 samepar = Standard_True;
656 }
657 else {
658 samepar = (Abs(parline-pCPI)<Precision::PConfusion());
659 }
660 }
661 return samepar;
662}
663
664//----------------------------------------------------------------------
665Standard_EXPORT Standard_Boolean FUNBREP_topokpart
666(const Handle(TopOpeBRepDS_Interference)& Ifound,const TopOpeBRepDS_ListOfInterference& DSCIL,
667 const TopOpeBRep_LineInter& L,const TopOpeBRep_VPointInter& VP,
668 const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& E,const TopoDS_Shape& F,const Standard_Real toluv,
669 Standard_Real& parline,TopOpeBRepDS_Transition& transLine)
670//----------------------------------------------------------------------
671{
672 Standard_Boolean keep = Standard_True;
673
674 Standard_Boolean CPIfound = !Ifound.IsNull();
675 Standard_Boolean couture = TopOpeBRepTool_ShapeTool::Closed(TopoDS::Edge(E),TopoDS::Face(F));
676 Standard_Boolean samepar = Standard_False; // = True if current VPoint falls on an existing geometry with an equal parameter.
677 if (!CPIfound) samepar = Standard_False;
678 else samepar = CPIfound ? TopoParameter(L,Ifound,parline,couture) : Standard_False;
679
96a95605
DB
680 TopOpeBRepDS_Transition lasttransLine;
681 if (!DSCIL.IsEmpty()) lasttransLine = DSCIL.Last()->Transition(); // xpu12-12-97
7fd59977 682
683 // A line is valid if at least it has VPi1 and VPi2 with i1 < i2 and :
684 // transition on line for VPi1 : OUT/IN and for VPi2 : IN/OUT.
685 // When <VPj> is on j=i1/i2, we keep it (returning true).
686 // Rmq :VP internal to the face is given with transition on line
687 // OUT/IN or IN/OUT if it is on the beginning or on the end
688 // of the line.
689
690 if (L.TypeLineCurve() == TopOpeBRep_WALKING) {
691 keep = FUNBREP_topowalki(Ifound,DSCIL,L,VP,lasttransLine,BDS,E,F,toluv,
692 CPIfound,samepar,couture,parline,transLine);
693 }
694 else {
96a95605 695 keep = FUNBREP_topogline(Ifound,DSCIL,L,VP,BDS,E,F,toluv,
7fd59977 696 CPIfound,samepar,couture,parline,transLine);
697 }
698 return keep;
699} // end of FUNBREP_tpokpart
700