Commit | Line | Data |
---|---|---|
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 | |
17 | #include <TopOpeBRep_FacesFiller.ixx> | |
18 | ||
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> | |
33 | #include <TopoDS.hxx> | |
34 | ||
35 | #include <TopOpeBRepDS_define.hxx> | |
36 | ||
0797d9d3 | 37 | #ifdef OCCT_DEBUG |
1d0a9d4d | 38 | extern Standard_Boolean TopOpeBRepDS_GettraceDSF(); |
39 | extern Standard_Boolean TopOpeBRep_GetcontextNEWKP(); | |
7fd59977 | 40 | #endif |
41 | ||
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; | |
45 | ||
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) | |
50 | ||
51 | //----------------------------------------------------------------------- | |
52 | static void FUNBREP_Periodize | |
53 | (const TopOpeBRep_LineInter& L,const Handle(TopOpeBRepDS_Interference)& Ifound,Standard_Real& PIfound,Standard_Real& parline) | |
54 | //----------------------------------------------------------------------- | |
55 | { | |
56 | const TopOpeBRepDS_Transition& TIfound = Ifound->Transition(); | |
57 | TopAbs_Orientation OTIfound = TIfound.Orientation(TopAbs_IN); | |
58 | ||
59 | if (L.IsPeriodic()) { | |
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; | |
64 | if ( onfl ) { | |
65 | if ( OTIfound == TopAbs_FORWARD ) { | |
66 | PIfound = f; | |
67 | parline = l; | |
68 | } | |
69 | else if ( OTIfound == TopAbs_REVERSED ) { | |
70 | PIfound = l; | |
71 | parline = f; | |
72 | } | |
73 | else { | |
74 | Standard_ProgramError::Raise("FUNBREP_Periodize"); | |
75 | } | |
76 | } // onfl | |
77 | else { | |
78 | parline = PIfound = Min(parline,PIfound); | |
79 | } | |
80 | } // IsPeriodic | |
81 | else { | |
82 | parline = PIfound = Min(parline,PIfound); | |
83 | } | |
84 | } | |
85 | ||
86 | //----------------------------------------------------------------------- | |
87 | static Standard_Boolean FUNBREP_HasSameGPoint(const TopOpeBRepDS_Point& DSP,const Handle(TopOpeBRepDS_Interference)& I, | |
88 | const TopOpeBRepDS_DataStructure& BDS) | |
89 | //----------------------------------------------------------------------- | |
90 | { | |
91 | // returns <true> if <DSP> shares same geometric point with | |
92 | // <I> geometry. | |
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); | |
98 | } | |
99 | else if ( I->GeometryType() == TopOpeBRepDS_VERTEX ) { | |
100 | TopOpeBRepDS_Point P(BDS.Shape(G)); | |
101 | samegp = DSP.IsEqual(P); | |
102 | } | |
103 | return samegp; | |
104 | } | |
105 | ||
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 | //----------------------------------------------------------------------- | |
111 | { | |
1d47d8d0 | 112 | Standard_Real u1 = 0.,v1 = 0.,u2 = 0.,v2 = 0.; |
7fd59977 | 113 | if (sind == 1) { |
114 | VP1.ParametersOnS1(u1,v1); VP2.ParametersOnS1(u2,v2); | |
115 | } | |
116 | if (sind == 2) { | |
117 | VP1.ParametersOnS2(u1,v1); VP2.ParametersOnS2(u2,v2); | |
118 | } | |
119 | gp_Pnt2d p1(u1,v1), p2(u2,v2); | |
120 | Standard_Real dist = p1.Distance(p2); | |
121 | Standard_Boolean sameuv = (dist < toluv); | |
122 | return sameuv; | |
123 | } | |
124 | ||
0797d9d3 | 125 | #ifdef OCCT_DEBUG |
7fd59977 | 126 | //------------------------------------------------------------------- |
127 | void FUNBREP_topokpartDEB | |
35e08fe8 | 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) | |
7fd59977 | 142 | //------------------------------------------------------------------- |
143 | { | |
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); | |
150 | ||
151 | Standard_Boolean LITdefinie = Standard_False; | |
152 | Standard_Boolean LITonsort = Standard_False; | |
153 | TopOpeBRepDS_Transition LIT; | |
154 | Standard_Boolean nointerf = DSCIL.IsEmpty(); | |
155 | ||
156 | if (nointerf) STATIC_lastVPind = 0; | |
157 | if (!nointerf) { | |
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); | |
162 | } | |
163 | ||
164 | Standard_Boolean iswalki = (L.TypeLineCurve() == TopOpeBRep_WALKING); | |
165 | if (iswalki) cout<<"kpwalk "; | |
166 | else cout<<"kpglin "; | |
167 | ||
168 | cout<<"\tVP "<<iVP<<" : "; | |
169 | ||
170 | if (CPIfound && samepar) cout<<"trouve ("<<parline<<")"; | |
171 | else if (CPIfound && !samepar) cout<<"trouve"; | |
172 | else cout<<"non trouve"; | |
173 | ||
174 | if (fermee) cout<<", fermee"; | |
175 | else cout<<", ouverte"; | |
176 | ||
177 | if (couture) cout<<", couture"; | |
178 | ||
179 | if (onsort) cout<<", sortant"; | |
180 | else cout<<", entrant"; | |
181 | ||
182 | if (lastdefinie && lastonsort) cout<<", prec = sortant"; | |
183 | else if (lastdefinie && !lastonsort) cout<<", prec = entrant"; | |
184 | else cout<<", prec = ?"; | |
185 | ||
186 | if (LITdefinie && LITonsort) cout<<", Lprec = sortant"; | |
187 | else if (LITdefinie && !LITonsort) cout<<", Lprec = entrant"; | |
188 | else cout<<", Lprec = ?"; | |
189 | cout<<endl; | |
190 | ||
191 | if (!iswalki) { | |
192 | cout<<"kpglin "; | |
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"; | |
200 | cout<<endl; | |
201 | } | |
202 | } | |
203 | #endif | |
204 | ||
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 | //---------------------------------------------------------------------- | |
211 | { | |
0797d9d3 | 212 | #ifdef OCCT_DEBUG |
7fd59977 | 213 | Standard_Boolean trc = TopOpeBRepDS_GettraceDSF(); |
214 | #endif | |
215 | ||
216 | if (L.TypeLineCurve() != TopOpeBRep_WALKING) { | |
217 | Standard_ProgramError::Raise("FUNBREP_topowalki_new : line is not a walking"); | |
218 | return Standard_False; | |
219 | } | |
220 | ||
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); | |
225 | ||
226 | Standard_Boolean LITdefinie = DSCIL.IsEmpty()? Standard_False: !DSCIL.Last()->Transition().IsUnknown(); | |
227 | ||
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); | |
237 | } | |
238 | ||
239 | // no last defined transition : | |
240 | // ---------------------------- | |
241 | if (!LITdefinie) { | |
242 | if (onsort) return Standard_False; | |
243 | if (iVP == iINONn) return Standard_False; | |
244 | } | |
245 | ||
246 | // has last defined transition : | |
247 | // ----------------------------- | |
248 | Standard_Boolean keep = Standard_True; | |
249 | if (LITdefinie) { | |
250 | ||
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; | |
256 | ||
257 | if(EFR && !entrantsortant) keep = Standard_False; | |
258 | ||
259 | if (couture) { | |
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; | |
0797d9d3 | 267 | #ifdef OCCT_DEBUG |
7fd59977 | 268 | if (trc) cout<<"is same vp on couture"; |
269 | #endif | |
270 | } | |
271 | } | |
272 | ||
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)); | |
285 | ||
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; | |
294 | } | |
295 | } | |
296 | } // LITdefinie | |
297 | ||
298 | return keep; | |
299 | } // FUNBREP_topowalki_new | |
300 | ||
0797d9d3 | 301 | #ifdef OCCT_DEBUG |
1d0a9d4d | 302 | extern Standard_Boolean GLOBAL_bvpr; |
7fd59977 | 303 | Standard_EXPORT void debvpr2(void) {} |
304 | #endif | |
305 | ||
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, | |
319 | Standard_Real& , | |
320 | TopOpeBRepDS_Transition& transLine) | |
321 | //---------------------------------------------------------------------- | |
322 | { | |
0797d9d3 | 323 | #ifdef OCCT_DEBUG |
7fd59977 | 324 | Standard_Boolean trc = TopOpeBRepDS_GettraceDSF(); |
325 | #endif | |
326 | ||
327 | if (L.TypeLineCurve() != TopOpeBRep_WALKING) { | |
328 | Standard_ProgramError::Raise("FUNBREP_topowalki : line is not a walking"); | |
329 | return Standard_False; | |
330 | } | |
331 | ||
0797d9d3 | 332 | #ifdef OCCT_DEBUG |
7fd59977 | 333 | Standard_Boolean newkp = TopOpeBRep_GetcontextNEWKP(); |
334 | if (newkp) { | |
335 | Standard_Boolean keep = FUNBREP_topowalki_new(Ifound,DSCIL,L,VP,E,samepar,couture,transLine); | |
336 | return keep; | |
337 | } | |
338 | #endif | |
339 | ||
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; | |
348 | ||
349 | if (lastdefinie) { | |
350 | lastonsort = (lasttransLine.Orientation(TopAbs_OUT) == TopAbs_FORWARD); | |
351 | lastinin = (lasttransLine.Before() == TopAbs_IN); | |
352 | lastinin = lastinin && (lasttransLine.After() == TopAbs_IN); | |
353 | } | |
354 | ||
7fd59977 | 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(); | |
360 | if (!nointerf) { | |
361 | I = DSCIL.Last(); | |
7fd59977 | 362 | LIT = I->Transition(); |
363 | LITdefinie = ! LIT.IsUnknown(); | |
364 | if (LITdefinie) LITonsort = (LIT.Orientation(TopAbs_OUT) == TopAbs_FORWARD); | |
365 | } | |
366 | ||
367 | Standard_Boolean keep = Standard_True; | |
368 | Standard_Boolean EFR = (Eori == TopAbs_FORWARD || Eori == TopAbs_REVERSED); | |
369 | ||
370 | if (!LITdefinie) { | |
371 | if (onsort) { | |
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); | |
381 | } | |
382 | // end debug 971216 : | |
383 | else keep = Standard_False; | |
384 | } | |
385 | if (iVP == iINONn) keep = Standard_False; | |
386 | if (!EFR) { // E INTERNAL ou EXTERNAL | |
387 | if (iVP == iINON1) { | |
388 | transLine = TopOpeBRepDS_Transition(TopAbs_OUT,TopAbs_IN); | |
389 | } | |
390 | } | |
391 | } | |
392 | ||
393 | if (keep && LITdefinie) { | |
394 | Standard_Boolean LprecIsEntrant = (LITdefinie && !LITonsort); | |
395 | Standard_Boolean entrantsortant = LprecIsEntrant && onsort; | |
396 | if (!EFR) { | |
397 | if ( iVP == iINONn) { | |
398 | transLine = TopOpeBRepDS_Transition(TopAbs_IN,TopAbs_OUT); | |
399 | } | |
400 | } | |
401 | else { | |
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); | |
408 | ||
409 | if ( condCTS19305 ) { | |
410 | keep = Standard_True; | |
411 | transLine = TopOpeBRepDS_Transition(TopAbs_IN,TopAbs_OUT); | |
412 | } | |
413 | else { | |
414 | if ( !entrantsortant ) { | |
415 | keep = Standard_False; | |
416 | } | |
417 | } | |
418 | } | |
419 | ||
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 | |
424 | ||
425 | Standard_Boolean samevponcouture = samepar && couture; | |
426 | if (keep && samevponcouture) { | |
427 | keep = Standard_False; | |
428 | ||
0797d9d3 | 429 | #ifdef OCCT_DEBUG |
7fd59977 | 430 | if (trc) cout<<"is same vp on couture"; |
431 | #endif | |
432 | } | |
433 | ||
434 | if (keep) { | |
0797d9d3 | 435 | #ifdef OCCT_DEBUG |
7fd59977 | 436 | if (GLOBAL_bvpr) debvpr2(); |
437 | #endif | |
438 | ||
439 | if (CPIfound && samepar) { | |
440 | Standard_Real PIfound = TopOpeBRepDS_InterferenceTool::Parameter(Ifound); | |
441 | ||
442 | // 971204 | |
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); | |
450 | if ( cond1 ) { | |
451 | keep = Standard_False; | |
452 | return keep; | |
453 | } | |
454 | ||
455 | // PRO12107 | |
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); | |
463 | if ( cond2 ) { | |
464 | keep = Standard_False; | |
465 | return keep; | |
466 | } | |
467 | } | |
468 | } // keep | |
469 | ||
470 | } // keep && LITdefinie | |
471 | ||
472 | if (keep) STATIC_lastVPind = iVP; | |
473 | return keep; | |
474 | } // FUNBREP_topowalki | |
475 | ||
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 | //---------------------------------------------------------------------- | |
483 | { | |
484 | if (L.TypeLineCurve() == TopOpeBRep_WALKING) { | |
485 | Standard_ProgramError::Raise("FUNBREP_topogline_new : line is not a GLine"); | |
486 | return Standard_False; | |
487 | } | |
7fd59977 | 488 | |
489 | Standard_Integer iVP = VP.Index(); | |
490 | Standard_Integer iINON1,iINONn,nINON; L.VPBounds(iINON1,iINONn,nINON); | |
491 | ||
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. | |
496 | ||
497 | // the line is described with (VPmin,VPmax) boundaries. | |
498 | // if VP == VPmax, as we are only regarding IN/OUT transitions->ok | |
499 | // if VP == VPmin : | |
500 | Standard_Boolean dscilempty = DSCIL.IsEmpty(); | |
501 | Standard_Boolean notkept = !dscilempty && (iVP == 1); | |
502 | if (notkept) return Standard_False; | |
503 | ||
504 | // <transLine> : for unknown current transition | |
505 | // ------------ | |
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; | |
512 | if ( !dscilempty ) { | |
513 | I = DSCIL.Last(); | |
514 | LIT = I->Transition(); | |
515 | LITdefinie = ! LIT.IsUnknown(); | |
516 | if (LITdefinie) LITonsort = M_FORWARD( LIT.Orientation(TopAbs_OUT) ); | |
517 | } | |
518 | Standard_Boolean trliunk = transLine.IsUnknown(); | |
519 | Standard_Boolean isfirstvp = (iVP == iINON1); | |
520 | Standard_Boolean islastvp = (iVP == iINONn); | |
521 | if (trliunk) { | |
522 | if (isfirstvp) transLine = TopOpeBRepDS_Transition(TopAbs_OUT,TopAbs_IN); | |
523 | if (islastvp && LITdefinie && !LITonsort) transLine = LIT.Complement(); | |
524 | } | |
525 | ||
526 | ||
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; | |
531 | ||
532 | // no last defined transition : | |
533 | // ---------------------------- | |
534 | if (!LITdefinie) { | |
535 | if (onsort) keep = Standard_False; | |
536 | if (iVP == iINONn) keep = Standard_False; | |
537 | } | |
538 | ||
539 | // has last defined transition : | |
540 | // ----------------------------- | |
541 | if (LITdefinie) { | |
542 | Standard_Boolean LprecIsEntrant = (LITdefinie && !LITonsort); | |
543 | Standard_Boolean entrantsortant = LprecIsEntrant && onsort; | |
544 | if(!entrantsortant) keep = Standard_False; | |
545 | ||
546 | Standard_Boolean sameparoncouture = samepar && couture; | |
547 | if (sameparoncouture && hasfol && keep) { | |
548 | ||
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); | |
553 | ||
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); | |
567 | } | |
568 | } | |
569 | if (sameparoncouture && !hasfol) { | |
570 | ||
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(); | |
578 | ||
579 | } | |
580 | } // LITdefinie | |
581 | ||
582 | if (keep) STATIC_lastVPind = iVP; | |
583 | return keep; | |
584 | ||
585 | } // FUNBREP_topogline_new | |
586 | ||
587 | //---------------------------------------------------------------------- | |
96a95605 | 588 | static Standard_Boolean FUNBREP_topogline |
7fd59977 | 589 | (const Handle(TopOpeBRepDS_Interference)& Ifound,const TopOpeBRepDS_ListOfInterference& DSCIL,const TopOpeBRep_LineInter& L, |
96a95605 | 590 | const TopOpeBRep_VPointInter& VP, |
7fd59977 | 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 | //---------------------------------------------------------------------- | |
600 | { | |
7fd59977 | 601 | if (L.TypeLineCurve() == TopOpeBRep_WALKING) { |
602 | Standard_ProgramError::Raise("FUNBREP_topogline : line is not a GLine"); | |
603 | return Standard_False; | |
604 | } | |
605 | ||
0797d9d3 | 606 | #ifdef OCCT_DEBUG |
7fd59977 | 607 | Standard_Boolean newkp = TopOpeBRep_GetcontextNEWKP(); |
608 | if (newkp) { | |
609 | Standard_Boolean keep = FUNBREP_topogline_new(DSCIL,L,VP,BDS,toluv,samepar,couture,parline,transLine); | |
610 | return keep; | |
611 | } | |
612 | #endif | |
613 | ||
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(); | |
619 | ||
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); | |
623 | } | |
624 | Standard_Boolean onsort = (transLine.Orientation(TopAbs_OUT) == TopAbs_FORWARD); | |
7fd59977 | 625 | |
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(); | |
631 | ||
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 | |
637 | // if VP is VPmin : | |
638 | Standard_Boolean newvvv = Standard_True;// xpu : 28-05-97 | |
639 | if (newvvv) { | |
640 | Standard_Boolean notkept = !dscilempty && (iVP == 1); | |
641 | if (notkept) return Standard_False; | |
642 | }// 28-05-97 : xpu | |
643 | ||
644 | if ( !dscilempty ) { | |
645 | I = DSCIL.Last(); | |
646 | LIT = I->Transition(); | |
647 | LITdefinie = ! LIT.IsUnknown(); | |
648 | if (LITdefinie) LITonsort = (LIT.Orientation(TopAbs_OUT) == TopAbs_FORWARD); | |
649 | } | |
650 | ||
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) { | |
659 | if (isfirstvp) { | |
660 | transLine = TopOpeBRepDS_Transition(TopAbs_OUT,TopAbs_IN); | |
661 | onsort = Standard_False; | |
662 | } | |
663 | if (islastvp) | |
664 | if (LITdefinie && !LITonsort) { | |
665 | transLine = LIT.Complement(); | |
666 | onsort = Standard_True; | |
667 | } | |
668 | }//21-05-97 :xpu | |
669 | ||
670 | Standard_Boolean hasfp = L.HasFirstPoint(); | |
671 | Standard_Boolean haslp = L.HasLastPoint(); | |
672 | Standard_Boolean hasfol = hasfp || haslp; | |
673 | ||
674 | Standard_Boolean keep = Standard_True; | |
675 | ||
676 | if (!LITdefinie) { | |
677 | if (onsort) keep = Standard_False; | |
678 | if (iVP == iINONn) keep = Standard_False; | |
679 | } | |
680 | if (LITdefinie) { | |
681 | Standard_Boolean LprecIsEntrant = (LITdefinie && !LITonsort); | |
682 | Standard_Boolean entrantsortant = LprecIsEntrant && onsort; | |
683 | if(!entrantsortant) keep = Standard_False; | |
684 | ||
685 | Standard_Boolean sameparoncouture = samepar && couture; | |
686 | if (sameparoncouture && hasfol) { | |
687 | if (keep) { | |
688 | // INFO : on geometric line, vp parameter on line is the point on | |
689 | // curve parameter. | |
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 | |
694 | // same CPI.else : | |
695 | if (fermee) { | |
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; | |
702 | } | |
703 | if (samegp) keep = Standard_False; | |
704 | } | |
705 | } | |
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(); | |
712 | } | |
713 | } | |
714 | ||
715 | if (keep) STATIC_lastVPind = iVP; | |
716 | return keep; | |
717 | ||
718 | } // end of FUNBREP_topogline | |
719 | ||
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 | //----------------------------------------------------------------------- | |
724 | { | |
725 | if ( I.IsNull() ) return Standard_False; | |
726 | Standard_Boolean samepar = Standard_False; | |
727 | Standard_Real pCPI = TopOpeBRepDS_InterferenceTool::Parameter(I); | |
728 | if (! closingedge ) | |
729 | samepar = (Abs(parline-pCPI)<Precision::PConfusion()); | |
730 | else { | |
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(); | |
736 | if ( perio ) { | |
737 | samepar = Standard_True; | |
738 | } | |
739 | else { | |
740 | samepar = (Abs(parline-pCPI)<Precision::PConfusion()); | |
741 | } | |
742 | } | |
743 | return samepar; | |
744 | } | |
745 | ||
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 | //---------------------------------------------------------------------- | |
753 | { | |
754 | Standard_Boolean keep = Standard_True; | |
755 | ||
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; | |
761 | ||
96a95605 DB |
762 | TopOpeBRepDS_Transition lasttransLine; |
763 | if (!DSCIL.IsEmpty()) lasttransLine = DSCIL.Last()->Transition(); // xpu12-12-97 | |
0797d9d3 | 764 | #ifdef OCCT_DEBUG |
7fd59977 | 765 | if (TopOpeBRepDS_GettraceDSF()) { |
766 | FUNBREP_topokpartDEB(Ifound,DSCIL,L,VP,lasttransLine,BDS,E,F,toluv, | |
767 | CPIfound,samepar,couture,parline,transLine); | |
768 | } | |
769 | #endif | |
770 | ||
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 | |
776 | // of the line. | |
777 | ||
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); | |
781 | } | |
782 | else { | |
96a95605 | 783 | keep = FUNBREP_topogline(Ifound,DSCIL,L,VP,BDS,E,F,toluv, |
7fd59977 | 784 | CPIfound,samepar,couture,parline,transLine); |
785 | } | |
786 | return keep; | |
787 | } // end of FUNBREP_tpokpart | |
788 |