b311480e |
1 | // Created on: 1997-04-17 |
2 | // Created by: Christophe MARION |
3 | // Copyright (c) 1997-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 | #define No_Standard_OutOfRange |
18 | |
7fd59977 |
19 | |
20 | #include <HLRAlgo_Coincidence.hxx> |
21 | #include <HLRAlgo_Interference.hxx> |
22 | #include <HLRAlgo_InterferenceList.hxx> |
7fd59977 |
23 | #include <HLRAlgo_Intersection.hxx> |
42cf5bc1 |
24 | #include <HLRAlgo_ListIteratorOfInterferenceList.hxx> |
25 | #include <HLRBRep_Data.hxx> |
7fd59977 |
26 | #include <HLRBRep_EdgeBuilder.hxx> |
42cf5bc1 |
27 | #include <HLRBRep_EdgeIList.hxx> |
7fd59977 |
28 | #include <HLRBRep_EdgeInterferenceTool.hxx> |
42cf5bc1 |
29 | #include <HLRBRep_Hider.hxx> |
30 | #include <HLRBRep_VertexList.hxx> |
5ae6e53d |
31 | #include <TColStd_SequenceOfReal.hxx> |
7fd59977 |
32 | #include <Standard_ErrorHandler.hxx> |
33 | |
34 | //======================================================================= |
35 | //function : HLRBRep_Hider |
36 | //purpose : |
37 | //======================================================================= |
7fd59977 |
38 | HLRBRep_Hider:: |
39 | HLRBRep_Hider (const Handle(HLRBRep_Data)& DS) : |
40 | myDS(DS) |
41 | {} |
42 | |
43 | //======================================================================= |
44 | //function : OwnHiding |
45 | //purpose : |
46 | //======================================================================= |
47 | |
48 | void HLRBRep_Hider::OwnHiding(const Standard_Integer) |
49 | { |
50 | } |
51 | |
52 | //======================================================================= |
53 | //function : Hide |
54 | //purpose : |
55 | //======================================================================= |
56 | |
57 | void HLRBRep_Hider::Hide(const Standard_Integer FI, |
58 | BRepTopAdaptor_MapOfShapeTool& MST) |
59 | { |
60 | // ***************************************************************** |
61 | // |
62 | // This algorithm hides a set of edges stored in the data structure <myDS> |
63 | // with the hiding face number FI in <myDS>. |
64 | // |
65 | // Outline of the algorithm |
66 | // |
67 | // 1. Loop on the Edges (not hidden and not rejected by the face minmax) |
68 | // |
69 | // The rejections depending of the face are |
70 | // - Edge above the face |
71 | // - Edge belonging to the face |
72 | // - Edge rejected by a wire minmax |
73 | // |
74 | // Compute interferences with the not rejected edges of the face. |
75 | // Store IN and ON interferences in two sorted lists |
76 | // ILHidden and ILOn |
77 | // If ILOn is not empty |
78 | // Resolve ComplexTransitions in ILOn |
79 | // Resolve ON Intersections in ILOn |
80 | // An On interference may become |
81 | // IN : Move it from ILOn to ILHidden |
82 | // OUT : Remove it from ILOn |
83 | // If ILHidden and ILOn are empty |
84 | // intersect the edge with the face and classify the Edge. |
85 | // - if inside and under the face hide it. |
86 | // Else |
87 | // If ILHidden is not empty |
88 | // Resolve ComplexTransitions in ILHidden |
89 | // Build Hidden parts of the edge |
90 | // - Hide them |
91 | // Build visible parts of the edge |
92 | // Build Parts of the edge under the boundary of the face |
93 | // - Hide them as Boundary |
94 | // If ILOn is not empty |
95 | // Build ON parts of the edge |
96 | // - Hide them as ON parts |
97 | // Build Parts of the edge on the boundary of the face |
98 | // - Hide them as ON parts on Boundary |
99 | // |
100 | // |
101 | // ***************************************************************** |
102 | |
103 | myDS->InitEdge(FI,MST); |
104 | if (!myDS->MoreEdge()) // there is nothing to do |
105 | return; // ********************** |
14ea8abd |
106 | if (myDS->IsBadFace()) |
107 | return; |
7fd59977 |
108 | HLRBRep_EdgeInterferenceTool EIT(myDS); // List of Intersections |
109 | HLRBRep_Array1OfEData& myEData = myDS->EDataArray(); |
110 | |
7fd59977 |
111 | for (; myDS->MoreEdge(); myDS->NextEdge()) { // loop on the Edges |
112 | Standard_Integer E = myDS->Edge(); // ***************** |
113 | |
7fd59977 |
114 | try { |
115 | OCC_CATCH_SIGNALS |
116 | Standard_Boolean hasOut = Standard_False; |
117 | HLRAlgo_InterferenceList ILHidden; |
118 | HLRAlgo_InterferenceList ILOn; |
119 | EIT.LoadEdge(); |
120 | |
121 | for (myDS->InitInterference(); // intersections with face-edges |
122 | myDS->MoreInterference(); // ***************************** |
123 | myDS->NextInterference()) { |
124 | if (myDS->RejectedInterference()) { |
125 | if (myDS->AboveInterference() && |
126 | myDS->SimpleHidingFace ()) { |
127 | hasOut = Standard_True; |
128 | } |
129 | } |
130 | else { |
131 | HLRAlgo_Interference& Int = myDS->Interference(); |
132 | switch (Int.Intersection().State()) { |
133 | case TopAbs_IN : |
134 | HLRBRep_EdgeIList::AddInterference(ILHidden,Int,EIT); break; |
135 | case TopAbs_ON : |
136 | HLRBRep_EdgeIList::AddInterference(ILOn ,Int,EIT); break; |
137 | case TopAbs_OUT : |
138 | case TopAbs_UNKNOWN : break; |
139 | } |
140 | } |
141 | } |
142 | |
143 | //-- ============================================================ |
144 | Standard_Boolean Modif; |
145 | do { |
146 | Modif = Standard_False; |
147 | HLRAlgo_ListIteratorOfInterferenceList ItSegHidden1(ILHidden); |
148 | while(ItSegHidden1.More() && Modif==Standard_False) { |
149 | HLRAlgo_Interference& Int1 = ItSegHidden1.Value(); |
150 | Standard_Integer numseg1=Int1.Intersection().SegIndex(); |
151 | if(numseg1!=0) { |
152 | HLRAlgo_ListIteratorOfInterferenceList ItSegHidden2(ILHidden); |
153 | while(ItSegHidden2.More() && Modif==Standard_False) { |
154 | HLRAlgo_Interference& Int2 = ItSegHidden2.Value(); |
155 | Standard_Integer numseg2=Int2.Intersection().SegIndex(); |
156 | if(numseg1+numseg2 == 0) { |
157 | //--printf("\nHidden Traitement du segment %d %d\n",numseg1,numseg2); fflush(stdout); |
158 | TopAbs_State stbef1,staft1,stbef2,staft2; |
159 | Int1.Boundary().State3D(stbef1,staft1); |
160 | Int2.Boundary().State3D(stbef2,staft2); |
161 | if(Int1.Orientation() == Int2.Orientation()) { |
162 | if(Int1.Transition() == Int2.Transition()) { |
163 | if(stbef1==stbef2 && staft1==staft2 && stbef1!=TopAbs_ON && staft1!=TopAbs_ON ) { |
164 | //-- printf("\n Index1 = %d Index2 = %d\n",Int1.Intersection().Index(),Int2.Intersection().Index()); |
165 | Standard_Integer nind=-1; |
166 | if(Int1.Intersection().Index()!=0) { |
167 | nind=Int1.Intersection().Index(); |
168 | } |
169 | if(Int2.Intersection().Index()!=0) { |
170 | if(nind!=-1) { |
171 | if(Int1.Intersection().Index() != Int2.Intersection().Index()) { |
172 | nind=-1; |
173 | } |
174 | } |
175 | else { |
176 | nind=Int2.Intersection().Index(); |
177 | } |
178 | } |
179 | if(Int1.Intersection().Index()==0 && Int2.Intersection().Index()==0) nind=0; |
180 | |
181 | if(nind!=-1) { |
182 | //-- printf("\n Segment Supprime\n"); fflush(stdout); |
183 | HLRAlgo_Intersection& inter = Int1.ChangeIntersection(); |
184 | inter.SegIndex(nind); |
185 | Standard_Real p1 = Int1.Intersection().Parameter(); |
186 | Standard_Real p2 = Int2.Intersection().Parameter(); |
187 | inter.Parameter((p1+p2)*0.5); |
188 | Int1.BoundaryTransition(TopAbs_EXTERNAL); |
189 | |
190 | ILHidden.Remove(ItSegHidden2); |
191 | Modif=Standard_True; |
192 | } |
193 | } |
194 | } |
195 | } |
196 | } |
197 | if(Modif==Standard_False) { |
198 | ItSegHidden2.Next(); |
199 | } |
200 | } |
201 | } |
202 | if(Modif==Standard_False) { |
203 | ItSegHidden1.Next(); |
204 | } |
205 | } |
206 | } |
207 | while(Modif); |
208 | |
209 | |
210 | //-- ============================================================ |
211 | |
212 | |
213 | if (!ILOn.IsEmpty()) { // process the interferences on ILOn |
214 | // ********************************* |
215 | |
216 | HLRBRep_EdgeIList::ProcessComplex // complex transition on ILOn |
217 | (ILOn,EIT); // ************************** |
218 | |
219 | HLRAlgo_ListIteratorOfInterferenceList It(ILOn); |
220 | |
221 | while(It.More()) { // process Intersections on the Face |
222 | // ********************************* |
223 | |
224 | HLRAlgo_Interference& Int = It.Value(); |
225 | TopAbs_State stbef, staft; // read the 3d states |
226 | Int.Boundary().State3D(stbef,staft); // ****************** |
227 | |
228 | switch (Int.Transition()) { |
229 | case TopAbs_FORWARD : |
230 | switch (staft) { |
231 | case TopAbs_OUT : |
232 | ILOn.Remove(It); break; |
233 | case TopAbs_IN : |
234 | HLRBRep_EdgeIList::AddInterference(ILHidden,Int,EIT); |
235 | ILOn.Remove(It); break; |
aefdc31b |
236 | case TopAbs_UNKNOWN : |
0797d9d3 |
237 | #ifdef OCCT_DEBUG |
04232180 |
238 | std::cout << "UNKNOWN state staft" << std::endl; |
aefdc31b |
239 | #endif |
7fd59977 |
240 | case TopAbs_ON : |
241 | It.Next(); break; |
242 | } break; |
243 | case TopAbs_REVERSED : |
244 | switch (stbef) { |
245 | case TopAbs_OUT : |
246 | ILOn.Remove(It); break; |
247 | case TopAbs_IN : |
248 | HLRBRep_EdgeIList::AddInterference(ILHidden,Int,EIT); |
249 | ILOn.Remove(It); break; |
aefdc31b |
250 | case TopAbs_UNKNOWN : |
0797d9d3 |
251 | #ifdef OCCT_DEBUG |
04232180 |
252 | std::cout << "UNKNOWN state stbef" << std::endl; |
aefdc31b |
253 | #endif |
7fd59977 |
254 | case TopAbs_ON : |
255 | It.Next(); break; |
256 | } break; |
257 | case TopAbs_EXTERNAL : |
258 | ILOn.Remove(It); break; |
259 | case TopAbs_INTERNAL : |
260 | switch (stbef) { |
261 | case TopAbs_IN : |
262 | switch (staft) { |
263 | case TopAbs_IN : |
264 | HLRBRep_EdgeIList::AddInterference(ILHidden,Int,EIT); |
265 | ILOn.Remove(It); break; |
266 | case TopAbs_ON : |
267 | Int.Transition(TopAbs_FORWARD ); // FORWARD in ILOn, |
268 | HLRBRep_EdgeIList::AddInterference // REVERSED in ILHidden |
269 | (ILHidden,HLRAlgo_Interference |
270 | (Int.Intersection(), |
271 | Int.Boundary(), |
272 | Int.Orientation(), |
273 | TopAbs_REVERSED, |
274 | Int.BoundaryTransition()),EIT); |
275 | It.Next(); break; |
276 | case TopAbs_OUT : |
277 | Int.Transition(TopAbs_REVERSED); // set REVERSED |
278 | HLRBRep_EdgeIList::AddInterference(ILHidden,Int,EIT); |
279 | ILOn.Remove(It); break; |
280 | case TopAbs_UNKNOWN : |
0797d9d3 |
281 | #ifdef OCCT_DEBUG |
04232180 |
282 | std::cout << "UNKNOWN state after" << std::endl; |
aefdc31b |
283 | #endif |
7fd59977 |
284 | It.Next(); break; |
285 | } break; |
286 | case TopAbs_ON : |
287 | switch (staft) { |
288 | case TopAbs_IN : |
289 | Int.Transition(TopAbs_REVERSED); // REVERSED in ILOn, |
290 | HLRBRep_EdgeIList::AddInterference // REVERSED in ILHidden |
291 | (ILHidden,HLRAlgo_Interference |
292 | (Int.Intersection(), |
293 | Int.Boundary(), |
294 | Int.Orientation(), |
295 | TopAbs_FORWARD, |
296 | Int.BoundaryTransition()),EIT); break; |
297 | case TopAbs_ON : break; |
298 | case TopAbs_OUT : |
299 | Int.Transition(TopAbs_REVERSED); break; |
300 | case TopAbs_UNKNOWN : |
0797d9d3 |
301 | #ifdef OCCT_DEBUG |
04232180 |
302 | std::cout << "UNKNOWN state after" << std::endl; |
aefdc31b |
303 | #endif |
304 | break; |
7fd59977 |
305 | } |
306 | It.Next(); break; |
307 | case TopAbs_OUT : |
308 | switch (staft) { |
309 | case TopAbs_IN : |
310 | Int.Transition(TopAbs_FORWARD); // set FORWARD |
311 | HLRBRep_EdgeIList::AddInterference(ILHidden,Int,EIT); |
312 | ILOn.Remove(It); break; |
313 | case TopAbs_ON : |
314 | Int.Transition(TopAbs_FORWARD ); // FORWARD in ILOn |
315 | It.Next(); break; |
316 | case TopAbs_OUT : |
317 | ILOn.Remove(It); break; |
318 | case TopAbs_UNKNOWN : |
0797d9d3 |
319 | #ifdef OCCT_DEBUG |
04232180 |
320 | std::cout << "UNKNOWN state after" << std::endl; |
aefdc31b |
321 | #endif |
7fd59977 |
322 | It.Next(); break; |
323 | } break; |
324 | case TopAbs_UNKNOWN : |
0797d9d3 |
325 | #ifdef OCCT_DEBUG |
04232180 |
326 | std::cout << "UNKNOWN state stbef" << std::endl; |
aefdc31b |
327 | #endif |
328 | break; |
7fd59977 |
329 | } |
330 | } |
331 | } |
332 | } |
333 | |
334 | if (ILHidden.IsEmpty() && ILOn.IsEmpty() && !hasOut) { |
335 | HLRBRep_EdgeData& ed = myEData(E); |
336 | TopAbs_State st = myDS->Compare(E,ed); // Classification |
337 | if (st == TopAbs_IN || st == TopAbs_ON) // ************** |
338 | ed.Status().HideAll(); |
339 | } |
340 | else { |
341 | Standard_Real p1 = 0.,p2 = 0.; |
342 | Standard_ShortReal tol1 = 0., tol2 = 0.; |
343 | |
344 | HLRBRep_EdgeData& ed = myEData(E); |
345 | HLRAlgo_EdgeStatus& ES = ed.Status(); |
346 | |
347 | Standard_Boolean foundHidden = Standard_False; |
348 | |
7fd59977 |
349 | if (!ILHidden.IsEmpty()) { |
350 | |
351 | HLRBRep_EdgeIList::ProcessComplex // complex transition on ILHidden |
352 | (ILHidden,EIT); // ****************************** |
353 | Standard_Integer level = 0; |
354 | if (!myDS->SimpleHidingFace()) // Level at Start |
355 | level = myDS->HidingStartLevel(E,ed,ILHidden); // ************** |
5ae6e53d |
356 | |
357 | HLRAlgo_ListIteratorOfInterferenceList It(ILHidden); |
358 | if (myDS->SimpleHidingFace()) //remove excess interferences |
359 | { |
360 | TColStd_SequenceOfReal ToRemove; |
361 | TopAbs_Orientation PrevTrans = TopAbs_EXTERNAL; |
362 | Standard_Real PrevParam = 0.; |
363 | for (; It.More(); It.Next()) |
364 | { |
365 | const HLRAlgo_Interference& Int = It.Value(); |
366 | TopAbs_Orientation aTrans = Int.Transition(); |
367 | if (aTrans == PrevTrans) |
368 | { |
369 | if (aTrans == TopAbs_FORWARD) |
370 | { |
371 | ToRemove.Append(Int.Intersection().Parameter()); |
372 | #ifdef OCCT_DEBUG |
04232180 |
373 | std::cout<<"Two adjacent interferences with transition FORWARD"<<std::endl; |
5ae6e53d |
374 | #endif |
375 | } |
376 | else if (aTrans == TopAbs_REVERSED) |
377 | { |
378 | ToRemove.Append(PrevParam); |
379 | #ifdef OCCT_DEBUG |
04232180 |
380 | std::cout<<"Two adjacent interferences with transition REVERSED"<<std::endl; |
5ae6e53d |
381 | #endif |
382 | } |
383 | } |
384 | PrevTrans = aTrans; |
385 | PrevParam = Int.Intersection().Parameter(); |
386 | } |
387 | It.Initialize(ILHidden); |
388 | while (It.More()) |
389 | { |
390 | Standard_Real aParam = It.Value().Intersection().Parameter(); |
391 | Standard_Boolean found = Standard_False; |
392 | for (Standard_Integer i = 1; i <= ToRemove.Length(); i++) |
393 | if (aParam == ToRemove(i)) |
394 | { |
395 | found = Standard_True; |
396 | ILHidden.Remove(It); |
397 | ToRemove.Remove(i); |
398 | break; |
399 | } |
400 | if (!found) |
401 | It.Next(); |
402 | } |
403 | } //remove excess interferences |
404 | |
405 | It.Initialize(ILHidden); |
7fd59977 |
406 | while(It.More()) { // suppress multi-inside Intersections |
407 | // *********************************** |
408 | |
409 | HLRAlgo_Interference& Int = It.Value(); |
410 | switch (Int.Transition()) { |
411 | |
412 | case TopAbs_FORWARD : |
413 | { |
414 | Standard_Integer decal = Int.Intersection().Level(); |
5ae6e53d |
415 | if (level > 0) |
416 | ILHidden.Remove(It); |
417 | else |
418 | It.Next(); |
7fd59977 |
419 | level = level + decal; |
420 | } |
421 | break; |
422 | case TopAbs_REVERSED : |
423 | { |
424 | level = level - Int.Intersection().Level(); |
5ae6e53d |
425 | if (level > 0) |
426 | ILHidden.Remove(It); |
427 | else |
428 | It.Next(); |
7fd59977 |
429 | } |
430 | break; |
431 | case TopAbs_EXTERNAL : |
432 | It.Next(); |
433 | break; |
434 | case TopAbs_INTERNAL : |
435 | It.Next(); |
436 | break; |
437 | default : |
438 | It.Next(); |
439 | break; |
440 | } |
441 | } |
442 | if (ILHidden.IsEmpty()) // Edge hidden |
443 | ES.HideAll(); // *********** |
444 | else |
445 | foundHidden = Standard_True; |
446 | } |
447 | |
448 | |
449 | if (!ILHidden.IsEmpty()) { |
450 | //IFV |
451 | |
452 | TopAbs_State aBuildIN = TopAbs_IN; |
bda83605 |
453 | Standard_Boolean IsSuspicion = Standard_True; |
7fd59977 |
454 | |
455 | Standard_Real pmax, pmin; |
456 | Standard_Boolean allInt = Standard_False; |
457 | Standard_Boolean allFor = Standard_False; |
458 | Standard_Boolean allRev = Standard_False; |
459 | pmin = RealLast(); |
460 | pmax = -pmin; |
461 | |
462 | if(ILHidden.Extent() > 1 ) { |
463 | allInt = Standard_True; |
464 | allFor = Standard_True; |
465 | allRev = Standard_True; |
466 | HLRAlgo_ListIteratorOfInterferenceList It(ILHidden); |
467 | for(;It.More(); It.Next()) { |
468 | Standard_Real p = It.Value().Intersection().Parameter(); |
469 | allFor = allFor && ( It.Value().Transition() == TopAbs_FORWARD); |
470 | allRev = allRev && ( It.Value().Transition() == TopAbs_REVERSED); |
471 | allInt = allInt && ( It.Value().Transition() == TopAbs_INTERNAL); |
472 | if(p < pmin) pmin = p; |
473 | if(p > pmax) pmax = p; |
474 | } |
475 | |
476 | } |
477 | |
478 | HLRAlgo_ListIteratorOfInterferenceList Itl(ILHidden); |
479 | HLRBRep_VertexList IL(EIT,Itl); |
480 | |
481 | |
482 | HLRBRep_EdgeBuilder EB(IL); |
483 | |
484 | EB.Builds(aBuildIN); // build hidden parts |
485 | // ****************** |
486 | while (EB.MoreEdges()) { |
46b2b6af |
487 | p1 = 0.; p2 = 0.; |
488 | Standard_Integer aMaskP1P2 = 0; |
489 | while (EB.MoreVertices()) { |
7fd59977 |
490 | switch (EB.Orientation()) { |
491 | case TopAbs_FORWARD : |
492 | p1 = EB.Current().Parameter(); |
493 | tol1 = EB.Current().Tolerance(); |
46b2b6af |
494 | aMaskP1P2 |= 1; |
7fd59977 |
495 | break; |
496 | case TopAbs_REVERSED : |
497 | p2 = EB.Current().Parameter(); |
498 | tol2 = EB.Current().Tolerance(); |
46b2b6af |
499 | aMaskP1P2 |= 2; |
7fd59977 |
500 | break; |
501 | case TopAbs_INTERNAL : |
502 | case TopAbs_EXTERNAL : |
503 | break; |
504 | } |
505 | EB.NextVertex(); |
506 | } |
507 | |
46b2b6af |
508 | if(aMaskP1P2 != 3 || p2 - p1 <= 1.e-7) { |
7fd59977 |
509 | EB.NextEdge(); |
510 | continue; |
511 | } |
512 | |
513 | if(allInt) { |
514 | if(p1 < pmin) p1 = pmin; |
515 | if(p2 > pmax) p2 = pmax; |
516 | //HLRBRep_EdgeData& ed = myEData(E); |
517 | //TopAbs_State st = myDS->Compare(E,ed); // Classification |
518 | } |
519 | |
520 | TopAbs_State aTestState = TopAbs_IN; |
bda83605 |
521 | if(IsSuspicion) { |
522 | //Standard_Integer aNbp = 1; |
523 | //aTestState = myDS->SimplClassify(E, ed, aNbp, p1, p2); |
524 | Standard_Integer tmplevel = 0; |
525 | aTestState = myDS->Classify(E,ed,Standard_True,tmplevel,(p1+p2)/2.); |
7fd59977 |
526 | } |
527 | |
528 | if(aTestState != TopAbs_OUT) { |
529 | ES.Hide(p1,tol1,p2,tol2, |
530 | Standard_False, // under the Face |
531 | Standard_False); // inside the Face |
532 | } |
533 | |
534 | EB.NextEdge(); |
535 | } |
536 | |
537 | EB.Builds(TopAbs_ON); // build parts under the boundary |
538 | // ****************************** |
539 | while (EB.MoreEdges()) { |
46b2b6af |
540 | p1 = 0.; p2 = 0.; |
541 | Standard_Integer aMaskP1P2 = 0; |
7fd59977 |
542 | while (EB.MoreVertices()) { |
543 | switch (EB.Orientation()) { |
544 | case TopAbs_FORWARD : |
545 | p1 = EB.Current().Parameter(); |
546 | tol1 = EB.Current().Tolerance(); |
46b2b6af |
547 | aMaskP1P2 |= 1; |
7fd59977 |
548 | break; |
549 | case TopAbs_REVERSED : |
550 | p2 = EB.Current().Parameter(); |
551 | tol2 = EB.Current().Tolerance(); |
46b2b6af |
552 | aMaskP1P2 |= 2; |
7fd59977 |
553 | break; |
554 | case TopAbs_INTERNAL : |
555 | case TopAbs_EXTERNAL : |
556 | break; |
557 | } |
558 | EB.NextVertex(); |
559 | } |
46b2b6af |
560 | |
561 | if(aMaskP1P2 != 3 || p2 - p1 <= 1.e-7) { |
562 | EB.NextEdge(); |
563 | continue; |
564 | } |
565 | |
bda83605 |
566 | TopAbs_State aTestState = TopAbs_IN; |
567 | if(IsSuspicion) { |
568 | //Standard_Integer aNbp = 1; |
569 | //aTestState = myDS->SimplClassify(E, ed, aNbp, p1, p2); |
570 | Standard_Integer tmplevel = 0; |
571 | aTestState = myDS->Classify(E,ed,Standard_True,tmplevel,(p1+p2)/2.); |
572 | } |
573 | |
574 | if(aTestState != TopAbs_OUT) |
575 | ES.Hide(p1,tol1,p2,tol2, |
576 | Standard_False, // under the Face |
577 | Standard_True); // on the boundary |
578 | |
7fd59977 |
579 | EB.NextEdge(); |
580 | } |
581 | } |
582 | |
583 | if (!ILOn.IsEmpty()) { |
584 | Standard_Integer level = 0; |
585 | if (!myDS->SimpleHidingFace()) // Level at Start |
586 | level = myDS->HidingStartLevel(E,ed,ILOn); // ************** |
587 | if (level > 0) { |
588 | HLRAlgo_ListIteratorOfInterferenceList It(ILOn); |
589 | |
590 | while(It.More()) { // suppress multi-inside Intersections |
591 | // *********************************** |
592 | |
593 | HLRAlgo_Interference& Int = It.Value(); |
594 | switch (Int.Transition()) { |
595 | |
596 | case TopAbs_FORWARD : |
597 | { |
598 | Standard_Integer decal = Int.Intersection().Level(); |
599 | if (level > 0) ILOn.Remove(It); |
600 | else It.Next(); |
601 | level = level + decal; |
602 | } |
603 | break; |
604 | case TopAbs_REVERSED : |
605 | level = level - Int.Intersection().Level(); |
606 | if (level > 0) ILOn.Remove(It); |
607 | else It.Next(); |
608 | break; |
609 | case TopAbs_EXTERNAL : |
610 | case TopAbs_INTERNAL : |
611 | default : |
612 | It.Next(); |
613 | break; |
614 | } |
615 | } |
616 | if (ILOn.IsEmpty() && !foundHidden) // Edge hidden |
617 | ES.HideAll(); // *********** |
618 | } |
619 | } |
620 | |
621 | if (!ILOn.IsEmpty()) { |
622 | HLRBRep_VertexList IL(EIT,ILOn); |
623 | HLRBRep_EdgeBuilder EB(IL); |
624 | |
625 | EB.Builds (TopAbs_IN); // build parts on the Face |
626 | // *********************** |
627 | while (EB.MoreEdges()) { |
46b2b6af |
628 | p1 = 0.; p2 = 0.; |
629 | Standard_Integer aMaskP1P2 = 0; |
7fd59977 |
630 | while (EB.MoreVertices()) { |
631 | switch (EB.Orientation()) { |
632 | case TopAbs_FORWARD : |
633 | p1 = EB.Current().Parameter(); |
634 | tol1 = EB.Current().Tolerance(); |
46b2b6af |
635 | aMaskP1P2 |= 1; |
7fd59977 |
636 | break; |
637 | case TopAbs_REVERSED : |
638 | p2 = EB.Current().Parameter(); |
639 | tol2 = EB.Current().Tolerance(); |
46b2b6af |
640 | aMaskP1P2 |= 2; |
7fd59977 |
641 | break; |
642 | case TopAbs_INTERNAL : |
643 | case TopAbs_EXTERNAL : |
644 | break; |
645 | } |
646 | EB.NextVertex(); |
647 | } |
46b2b6af |
648 | |
649 | if(aMaskP1P2 != 3 || p2 - p1 <= 1.e-7) { |
650 | EB.NextEdge(); |
651 | continue; |
652 | } |
653 | |
7fd59977 |
654 | ES.Hide(p1,tol1,p2,tol2, |
655 | Standard_True, // on the Face |
656 | Standard_False); // inside the Face |
657 | EB.NextEdge(); |
658 | } |
659 | |
660 | EB.Builds(TopAbs_ON); // build hidden parts under the boundary |
661 | // ************************************* |
662 | while (EB.MoreEdges()) { |
46b2b6af |
663 | p1 = 0.; p2 = 0.; |
664 | Standard_Integer aMaskP1P2 = 0; |
7fd59977 |
665 | while (EB.MoreVertices()) { |
666 | switch (EB.Orientation()) { |
667 | case TopAbs_FORWARD : |
668 | p1 = EB.Current().Parameter(); |
669 | tol1 = EB.Current().Tolerance(); |
46b2b6af |
670 | aMaskP1P2 |= 1; |
7fd59977 |
671 | break; |
672 | case TopAbs_REVERSED : |
673 | p2 = EB.Current().Parameter(); |
674 | tol2 = EB.Current().Tolerance(); |
46b2b6af |
675 | aMaskP1P2 |= 2; |
7fd59977 |
676 | break; |
677 | case TopAbs_INTERNAL : |
678 | case TopAbs_EXTERNAL : |
679 | break; |
680 | } |
681 | EB.NextVertex(); |
682 | } |
46b2b6af |
683 | |
684 | if(aMaskP1P2 != 3 || p2 - p1 <= 1.e-7) { |
685 | EB.NextEdge(); |
686 | continue; |
687 | } |
688 | |
689 | ES.Hide(p1,tol1,p2,tol2, |
7fd59977 |
690 | Standard_True, // on the Face |
691 | Standard_True); // on the boundary |
692 | EB.NextEdge(); |
693 | } |
694 | } |
695 | } |
696 | |
697 | } |
698 | |
9775fa61 |
699 | catch(Standard_Failure const& anException) { |
0797d9d3 |
700 | #ifdef OCCT_DEBUG |
0177fe26 |
701 | std::cout << "An exception was caught when hiding edge " << E; |
04232180 |
702 | std::cout << " by the face " << FI << std::endl; |
703 | std::cout << anException << std::endl; |
7fd59977 |
704 | #endif |
9775fa61 |
705 | (void)anException; |
7fd59977 |
706 | } |
707 | } |
708 | } |