0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / BRepFeat / BRepFeat_RibSlot.cxx
CommitLineData
b311480e 1// Created on: 1997-10-08
2// Created by: Olga KOULECHOVA
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
7fd59977 17
f1b2eddc 18#include <BRep_Builder.hxx>
7fd59977 19#include <BRepAlgo.hxx>
7fd59977 20#include <BRepAlgoAPI_Cut.hxx>
7fd59977 21#include <BRepBndLib.hxx>
7fd59977 22#include <BRepClass3d_SolidClassifier.hxx>
42cf5bc1 23#include <BRepFeat.hxx>
24#include <BRepFeat_Builder.hxx>
25#include <BRepFeat_RibSlot.hxx>
26#include <BRepIntCurveSurface_Inter.hxx>
27#include <BRepLib.hxx>
7fd59977 28#include <BRepLib_MakeEdge.hxx>
7fd59977 29#include <BRepLib_MakeFace.hxx>
42cf5bc1 30#include <BRepLib_MakeVertex.hxx>
31#include <BRepLib_MakeWire.hxx>
32#include <BRepTools_WireExplorer.hxx>
33#include <BRepTopAdaptor_FClass2d.hxx>
34#include <CSLib.hxx>
35#include <ElCLib.hxx>
36#include <ElSLib.hxx>
37#include <Geom2dAPI_InterCurveCurve.hxx>
7fd59977 38#include <Geom_Circle.hxx>
42cf5bc1 39#include <Geom_Curve.hxx>
7fd59977 40#include <Geom_Ellipse.hxx>
7fd59977 41#include <Geom_Hyperbola.hxx>
42cf5bc1 42#include <Geom_Line.hxx>
43#include <Geom_Parabola.hxx>
44#include <Geom_Plane.hxx>
45#include <Geom_TrimmedCurve.hxx>
46#include <GeomAdaptor_Curve.hxx>
7fd59977 47#include <GeomAPI.hxx>
48#include <GeomAPI_ProjectPointOnCurve.hxx>
42cf5bc1 49#include <GeomLib.hxx>
7fd59977 50#include <gp_Ax1.hxx>
42cf5bc1 51#include <gp_Dir.hxx>
7fd59977 52#include <gp_Pln.hxx>
53#include <gp_Pnt.hxx>
42cf5bc1 54#include <gp_Vec.hxx>
55#include <LocOpe.hxx>
56#include <LocOpe_CSIntersector.hxx>
57#include <LocOpe_FindEdges.hxx>
58#include <LocOpe_Gluer.hxx>
59#include <LocOpe_PntFace.hxx>
7fd59977 60#include <Precision.hxx>
7fd59977 61#include <TColGeom_SequenceOfCurve.hxx>
42cf5bc1 62#include <TopExp.hxx>
63#include <TopExp_Explorer.hxx>
64#include <TopoDS.hxx>
65#include <TopoDS_Edge.hxx>
66#include <TopoDS_Face.hxx>
67#include <TopoDS_Shape.hxx>
68#include <TopoDS_Vertex.hxx>
42cf5bc1 69#include <TopTools_ListOfShape.hxx>
42cf5bc1 70#include <TopTools_MapOfShape.hxx>
7fd59977 71
0797d9d3 72#ifdef OCCT_DEBUG
1d0a9d4d 73extern Standard_Boolean BRepFeat_GettraceFEAT();
74extern Standard_Boolean BRepFeat_GettraceFEATRIB();
7fd59977 75#endif
76
77//=======================================================================
78//function : LFPerform
0d969553 79//purpose : topological reconstruction of ribs
7fd59977 80//=======================================================================
81
82void BRepFeat_RibSlot::LFPerform()
83{
0797d9d3 84#ifdef OCCT_DEBUG
7fd59977 85 Standard_Boolean trc = BRepFeat_GettraceFEAT();
04232180 86 if (trc) std::cout << "BRepFeat_RibSlot::LFPerform()" << std::endl;
7fd59977 87#endif
88 if (mySbase.IsNull() || myPbase.IsNull() || mySkface.IsNull()
89 || myGShape.IsNull() || myLFMap.IsEmpty()) {
0797d9d3 90#ifdef OCCT_DEBUG
04232180 91 std::cout << "Topological reconstruction is impossible" << std::endl;
92 if (trc) std::cout << " Fields not initialized" << std::endl;
7fd59977 93#endif
94 myStatusError = BRepFeat_NotInitialized;
95 NotDone();
96 return;
97 }
98
99 TopExp_Explorer exp,exp2;
100 Standard_Integer theOpe = 2;
101
102 if (!myGluedF.IsEmpty()) {
103 theOpe = 1;
104 }
105
0d969553 106 // Hope that there is just a solid in the result
7fd59977 107 if (!mySUntil.IsNull()) {
7fd59977 108 for (exp2.Init(mySUntil,TopAbs_FACE); exp2.More(); exp2.Next()) {
109 const TopoDS_Shape& funtil = exp2.Current();
110 for (exp.Init(mySbase,TopAbs_FACE); exp.More(); exp.Next()) {
4e57c75e 111 if (exp.Current().IsSame(funtil)) {
112 break;
113 }
7fd59977 114 }
115 if (!exp.More()) {
4e57c75e 116 break;
7fd59977 117 }
118 }
119 }
120
121 TopTools_ListIteratorOfListOfShape it,it2;
122 TopTools_DataMapIteratorOfDataMapOfShapeShape itm;
123 //Standard_Integer sens = 0;
124
7fd59977 125 LocOpe_Gluer theGlue;
126
0d969553 127 //case of gluing
7fd59977 128
129 if (theOpe == 1) {
130 Standard_Boolean Collage = Standard_True;
7fd59977 131
132 LocOpe_FindEdges theFE;
133 TopTools_DataMapOfShapeListOfShape locmap;
134 theGlue.Init(mySbase,myGShape);
135 for (itm.Initialize(myGluedF); itm.More();itm.Next()) {
136 const TopoDS_Face& glface = TopoDS::Face(itm.Key());
137 const TopoDS_Face& fac = TopoDS::Face(myGluedF(glface));
138 for (exp.Init(myGShape,TopAbs_FACE); exp.More(); exp.Next()) {
4e57c75e 139 if (exp.Current().IsSame(glface)) {
140 break;
141 }
7fd59977 142 }
143 if (exp.More()) {
4e57c75e 144 Collage = BRepFeat::IsInside(glface, fac);
145 if(!Collage) {
146 theOpe = 2;
4e57c75e 147 break;
148 }
149 else {
150 theGlue.Bind(glface, fac);
151 theFE.Set(glface, fac);
152 for (theFE.InitIterator(); theFE.More();theFE.Next()) {
153 theGlue.Bind(theFE.EdgeFrom(),theFE.EdgeTo());
154 }
155 }
7fd59977 156 }
157 }
158
159 LocOpe_Operation ope = theGlue.OpeType();
160 if (ope == LocOpe_INVALID ||
4e57c75e 161 (myFuse && ope != LocOpe_FUSE) ||
162 (!myFuse && ope != LocOpe_CUT) ||
163 (!Collage)) {
7fd59977 164 theOpe = 2;
0797d9d3 165#ifdef OCCT_DEBUG
04232180 166 std::cout << "Passage to topological operations" << std::endl;
7fd59977 167#endif
168 }
169 }
170
0d969553 171// gluing is always applicable
7fd59977 172
173 if (theOpe == 1) {
174 theGlue.Perform();
175 if (theGlue.IsDone()) {
176 UpdateDescendants(theGlue);
177 myNewEdges = theGlue.Edges();
178 myTgtEdges = theGlue.TgtEdges();
4e57c75e 179 //
180 Done();
181 myShape = theGlue.ResultingShape();
182 BRepLib::SameParameter(myShape, 1.e-7, Standard_True);
7fd59977 183 }
184 else {
185 theOpe = 2;
0797d9d3 186#ifdef OCCT_DEBUG
04232180 187 std::cout << "Passage to topologic operation" << std::endl;
7fd59977 188#endif
189 }
190 }
191
4e57c75e 192 // case without gluing
7fd59977 193 if (theOpe == 2) {
4e57c75e 194 BRepFeat_Builder theBuilder;
195 TopTools_ListOfShape partsoftool;
196 BRepClass3d_SolidClassifier oussa;
197 Standard_Boolean bFlag;
198 TopTools_ListIteratorOfListOfShape aIt;
199
200 bFlag = (myPerfSelection == BRepFeat_NoSelection) ? 0 : 1;
201 //
202 theBuilder.Init(mySbase, myGShape);
203 theBuilder.SetOperation(myFuse, bFlag);
204 //
205 theBuilder.Perform();
206 if (bFlag) {
207 theBuilder.PartsOfTool(partsoftool);
208 aIt.Initialize(partsoftool);
209 if (aIt.More() && myPerfSelection != BRepFeat_NoSelection) {
210 Standard_Real toler = (BRep_Tool::Tolerance(myPbase))*2;
211 //
212 for(; aIt.More(); aIt.Next()) {
213 oussa.Load(aIt.Value());
214 oussa.Perform(myFirstPnt, toler);
215 TopAbs_State sp1=oussa.State();
216 oussa.Perform(myLastPnt, toler);
217 TopAbs_State sp2=oussa.State();
218 if (!(sp1 == TopAbs_OUT || sp2 == TopAbs_OUT)) {
219 const TopoDS_Shape& S = aIt.Value();
220 theBuilder.KeepPart(S);
221 }
222 }
223 }
224 //
225 theBuilder.PerformResult();
226 myShape = theBuilder.Shape();
227 } else {
228 myShape = theBuilder.Shape();
229 }
230 Done();
7fd59977 231 }
232}
233
7fd59977 234//=======================================================================
235//function : IsDeleted
236//purpose :
237//=======================================================================
238
239Standard_Boolean BRepFeat_RibSlot::IsDeleted(const TopoDS_Shape& F)
240{
241 return (myMap(F).IsEmpty());
242}
243
244
245//=======================================================================
246//function : Modified
247//purpose :
248//=======================================================================
249
250const TopTools_ListOfShape& BRepFeat_RibSlot::Modified
251 (const TopoDS_Shape& F)
252{
0797d9d3 253#ifdef OCCT_DEBUG
7fd59977 254 Standard_Boolean trc = BRepFeat_GettraceFEAT();
04232180 255 if (trc) std::cout << "BRepFeat_RibSlot::Modified" << std::endl;
7fd59977 256#endif
257 if (myMap.IsBound(F)) {
258 static TopTools_ListOfShape list;
259 list.Clear();
260 TopTools_ListIteratorOfListOfShape ite(myMap(F));
261 for(; ite.More(); ite.Next()) {
262 const TopoDS_Shape& sh = ite.Value();
263 if(!sh.IsSame(F))
4e57c75e 264 list.Append(sh);
7fd59977 265 }
266 return list;
267 }
268 return myGenerated; // empty list
269}
270
271//=======================================================================
272//function : Generated
273//purpose :
274//=======================================================================
275
276const TopTools_ListOfShape& BRepFeat_RibSlot::Generated
277 (const TopoDS_Shape& S)
278{
0797d9d3 279#ifdef OCCT_DEBUG
7fd59977 280 Standard_Boolean trc = BRepFeat_GettraceFEAT();
04232180 281 if (trc) std::cout << "BRepFeat_RibSlot::Generated" << std::endl;
7fd59977 282#endif
283 if(S.ShapeType() != TopAbs_FACE) {
284 myGenerated.Clear();
285 if(myLFMap.IsEmpty() || !myLFMap.IsBound(S)) {
0d969553 286 if (myMap.IsBound(S)) { // check if filter on face or not
4e57c75e 287 static TopTools_ListOfShape list;
288 list.Clear();
289 TopTools_ListIteratorOfListOfShape ite(myMap(S));
290 for(; ite.More(); ite.Next()) {
291 const TopoDS_Shape& sh = ite.Value();
292 if(!sh.IsSame(S))
293 list.Append(sh);
294 }
295 return list;
7fd59977 296 }
297 else return myGenerated;
298 }
299 else {
300 myGenerated.Clear();
301 TopTools_ListIteratorOfListOfShape it(myLFMap(S));
302 static TopTools_ListOfShape list;
303 list.Clear();
304 for(; it.More(); it.Next()) {
4e57c75e 305 if(myMap.IsBound(it.Value())) {
306 TopTools_ListIteratorOfListOfShape it1(myMap(it.Value()));
307 for(; it1.More(); it1.Next()) {
308 const TopoDS_Shape& sh = it1.Value();
309 if(!sh.IsSame(S))
310 list.Append(sh);
311 }
312 }
7fd59977 313 }
314 return list;
315 }
316 }
317 else return myGenerated;
318}
319
320
321//=======================================================================
322//function : UpdateDescendants
323//purpose :
324//=======================================================================
325
326void BRepFeat_RibSlot::UpdateDescendants(const LocOpe_Gluer& G)
327{
328 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm;
329 TopTools_ListIteratorOfListOfShape it,it2;
330 TopTools_MapIteratorOfMapOfShape itm;
331
332 for (itdm.Initialize(myMap);itdm.More();itdm.Next()) {
333 const TopoDS_Shape& orig = itdm.Key();
334 TopTools_MapOfShape newdsc;
335 for (it.Initialize(itdm.Value());it.More();it.Next()) {
336 const TopoDS_Face& fdsc = TopoDS::Face(it.Value());
337 for (it2.Initialize(G.DescendantFaces(fdsc));
4e57c75e 338 it2.More();it2.Next()) {
339 newdsc.Add(it2.Value());
7fd59977 340 }
341 }
342 myMap.ChangeFind(orig).Clear();
343 for (itm.Initialize(newdsc);itm.More();itm.Next()) {
344 myMap.ChangeFind(orig).Append(itm.Key());
345 }
346 }
347}
348
7fd59977 349
350//=======================================================================
351//function : FirstShape
352//purpose :
353//=======================================================================
354
355const TopTools_ListOfShape& BRepFeat_RibSlot::FirstShape() const
356{
357 if (!myFShape.IsNull()) {
358 return myMap(myFShape);
359 }
360 return myGenerated; // empty list
361}
362
363
364//=======================================================================
365//function : LastShape
366//purpose :
367//=======================================================================
368
369const TopTools_ListOfShape& BRepFeat_RibSlot::LastShape() const
370{
371 if (!myLShape.IsNull()) {
372 return myMap(myLShape);
373 }
374 return myGenerated; // empty list
375}
376
377//=======================================================================
378//function : FacesForDraft
379//purpose :
380//=======================================================================
381
382const TopTools_ListOfShape& BRepFeat_RibSlot::FacesForDraft() const
383{
384 return myFacesForDraft;
385}
386
387
388//=======================================================================
389//function : NewEdges
390//purpose :
391//=======================================================================
392
393const TopTools_ListOfShape& BRepFeat_RibSlot::NewEdges() const
394{
395 return myNewEdges;
396}
397
398//=======================================================================
399//function : TgtEdges
400//purpose :
401//=======================================================================
402
403const TopTools_ListOfShape& BRepFeat_RibSlot::TgtEdges() const
404{
405 return myTgtEdges;
406}
407
408
409//=======================================================================
410//function : CurrentStatusError
411//purpose :
412//=======================================================================
413
414BRepFeat_StatusError BRepFeat_RibSlot::CurrentStatusError() const
415{
416 return myStatusError;
417}
418
419
420//=======================================================================
421//function : CheckPoint
0d969553 422//purpose : Proofing point material side (side of extrusion)
7fd59977 423//=======================================================================
424
425gp_Pnt BRepFeat_RibSlot::CheckPoint(const TopoDS_Edge& e,
4e57c75e 426 const Standard_Real ,//bnd,
427 const Handle(Geom_Plane)& Pln)
7fd59977 428
429{
0797d9d3 430#ifdef OCCT_DEBUG
7fd59977 431 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
04232180 432 if (trc) std::cout << "BRepFeat_RibSlot::CheckPoint" << std::endl;
7fd59977 433#endif
0d969553
Y
434// Vector product : normal to plane X direction Wire
435// -> gives the material side
436// Proofing point somewhat inside the material side
7fd59977 437 Standard_Real f, l;
438 Handle(Geom_Curve) cc = BRep_Tool::Curve(e, f, l);
439
440 gp_Vec tgt; gp_Pnt pp;
441 Standard_Real par = ( f + l) / 2.;
442
443 cc->D1(par, pp, tgt);
444
445 if ( e.Orientation() == TopAbs_REVERSED) tgt.Reverse();
446
447 gp_Vec D = -tgt.Crossed(Pln->Pln().Position().Direction())/10.;
448 pp.Translate(D);
449
450 return pp;
451
452}
453
454
455//=======================================================================
456//function : Normal
0d969553 457//purpose : calculate the normal to a face in a point
7fd59977 458//=======================================================================
459
460gp_Dir BRepFeat_RibSlot::Normal(const TopoDS_Face& F,const gp_Pnt& P)
461
462{
0797d9d3 463#ifdef OCCT_DEBUG
7fd59977 464 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
04232180 465 if (trc) std::cout << "BRepFeat_RibSlot::Normal" << std::endl;
7fd59977 466#endif
467 Standard_Real U, V;
468 gp_Pnt pt;
469
470 BRepAdaptor_Surface AS(F, Standard_True);
471
472 switch ( AS.GetType()) {
473
474 case GeomAbs_Plane:
475 ElSLib::Parameters(AS.Plane(),P,U,V); break;
476
477 case GeomAbs_Cylinder:
478 ElSLib::Parameters(AS.Cylinder(),P,U,V); break;
479
480 case GeomAbs_Cone:
481 ElSLib::Parameters(AS.Cone(),P,U,V); break;
482
483 case GeomAbs_Torus:
484 ElSLib::Parameters(AS.Torus(),P,U,V); break;
485
486 default:
487 {
488 return gp_Dir(1., 0., 0.);
489 }
490 }
491
492 gp_Vec D1U, D1V;
493
4e57c75e 494 AS.D1(U, V, pt, D1U, D1V);
7fd59977 495 gp_Dir N;
496 CSLib_DerivativeStatus St;
497 CSLib::Normal(D1U, D1V, Precision::Confusion(), St, N);
498 if(F.Orientation() == TopAbs_FORWARD) N.Reverse();
499 return N;
500}
501
502//=======================================================================
503//function : IntPar
0d969553 504//purpose : calculate the parameter of a point on a curve
7fd59977 505//=======================================================================
506
507Standard_Real BRepFeat_RibSlot::IntPar(const Handle(Geom_Curve)& C,
4e57c75e 508 const gp_Pnt& P)
7fd59977 509
510{
511 if ( C.IsNull()) return 0.;
512
513 GeomAdaptor_Curve AC(C);
514 Standard_Real U;
515
516 switch ( AC.GetType()) {
517
518 case GeomAbs_Line:
519 U = ElCLib::Parameter(AC.Line(),P); break;
520
521 case GeomAbs_Circle:
522 U = ElCLib::Parameter(AC.Circle(),P); break;
523
524 case GeomAbs_Ellipse:
525 U = ElCLib::Parameter(AC.Ellipse(),P); break;
526
527 case GeomAbs_Hyperbola:
528 U = ElCLib::Parameter(AC.Hyperbola(),P); break;
529
530 case GeomAbs_Parabola:
531 U = ElCLib::Parameter(AC.Parabola(),P); break;
532
533 default:
534 U = 0.;
535 }
536
537 return U;
538}
539
540
541//=======================================================================
542//function : EdgeExtention
0d969553 543//purpose : extention of a edge by tangence
7fd59977 544//=======================================================================
545
546void BRepFeat_RibSlot::EdgeExtention(TopoDS_Edge& e,
4e57c75e 547 const Standard_Real bnd,
548 const Standard_Boolean FirstLast)
7fd59977 549{
0797d9d3 550#ifdef OCCT_DEBUG
7fd59977 551 Standard_Boolean trc = BRepFeat_GettraceFEAT();
04232180 552 if (trc) std::cout << "BRepFeat_RibSlot::EdgeExtention" << std::endl;
7fd59977 553#endif
554 Standard_Real f, l;
555 Handle(Geom_Curve) cu = BRep_Tool::Curve(e, f, l);
543a9964 556 Handle(Geom_BoundedCurve) C =
7fd59977 557 new Geom_TrimmedCurve(cu, f, l);
558
559 TopoDS_Edge E;
560
561 if(cu->DynamicType() == STANDARD_TYPE(Geom_Line) ||
562 cu->DynamicType() == STANDARD_TYPE(Geom_Circle) ||
563 cu->DynamicType() == STANDARD_TYPE(Geom_Ellipse) ||
564 cu->DynamicType() == STANDARD_TYPE(Geom_Hyperbola) ||
565 cu->DynamicType() == STANDARD_TYPE(Geom_Parabola)) {
566 if(FirstLast) {
567 BRepLib_MakeEdge Edg(cu, f-bnd/10., l);
568 E = TopoDS::Edge(Edg.Shape());
569 }
570 else {
571 BRepLib_MakeEdge Edg(cu, f, l+bnd/10.);
572 E = TopoDS::Edge(Edg.Shape());
573 }
574 }
575 else {
576 Handle(Geom_Line) ln;
577 gp_Pnt Pt;
578 gp_Pnt pnt;
579 gp_Vec vct;
580 if(FirstLast) {
581 C->D1(f, pnt, vct);
582 ln = new Geom_Line(pnt, -vct);
583 ln->D0(bnd/1000., Pt);
584 GeomLib::ExtendCurveToPoint(C, Pt, GeomAbs_G1, Standard_False);
585 BRepLib_MakeEdge Edg(C, Pt, BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True)));
586 E = TopoDS::Edge(Edg.Shape());
587 }
588 else {
589 C->D1(l, pnt, vct);
590 ln = new Geom_Line(pnt, vct);
591 ln->D0(bnd/1000., Pt);
592 GeomLib::ExtendCurveToPoint(C, Pt, GeomAbs_G1, Standard_True);
593 BRepLib_MakeEdge Edg(C, BRep_Tool::Pnt(TopExp::FirstVertex(e,Standard_True)), Pt);
594 E = TopoDS::Edge(Edg.Shape());
595 }
596 }
597 e = E;
598}
599
600
601//=======================================================================
602//function : ChoiceOfFaces
0d969553 603//purpose : choose face of support in case of support on an edge
7fd59977 604//=======================================================================
605
606TopoDS_Face BRepFeat_RibSlot::ChoiceOfFaces(TopTools_ListOfShape& faces,
4e57c75e 607 const Handle(Geom_Curve)& cc,
608 const Standard_Real par,
609 const Standard_Real ,//bnd,
610 const Handle(Geom_Plane)& Pln)
7fd59977 611
612{
0797d9d3 613#ifdef OCCT_DEBUG
7fd59977 614 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
04232180 615 if (trc) std::cout << "BRepFeat_RibSlot::ChoiceOfFaces" << std::endl;
7fd59977 616#endif
617 TopoDS_Face FFF;
618
619 gp_Pnt pp;
620 gp_Vec tgt;
621
622 cc->D1(par, pp, tgt);
623
624 Handle(Geom_Line) l1 = new Geom_Line(pp, tgt);
625
626 TColGeom_SequenceOfCurve scur;
627 Standard_Integer Counter = 0;
628
629
630 gp_Ax1 Axe(pp, Pln->Position().Direction());
631 for ( Standard_Integer i = 1; i <=8; i++) {
632 Handle(Geom_Curve) L =
c6541a0c 633 Handle(Geom_Curve)::DownCast(l1->Rotated(Axe, i*M_PI/9.));
7fd59977 634 scur.Append(L);
635 Counter++;
636 }
637
638 TopTools_ListIteratorOfListOfShape it;
639 it.Initialize(faces);
640 Standard_Real Par = RealLast();
641 for(; it.More(); it.Next()) {
642 const TopoDS_Face& f = TopoDS::Face(it.Value());
643 LocOpe_CSIntersector ASI(f);
644 ASI.Perform(scur);
645 if(!ASI.IsDone()) continue;
646 for(Standard_Integer jj = 1; jj<=Counter; jj++) {
647 if(ASI.NbPoints(jj) >= 1) {
e45b5ff7 648 Standard_Real app = ASI.Point(jj,1).Parameter();
4e57c75e 649 if(app >= 0 && app < Par) {
650 Par = app;
651 FFF = f;
652 }
7fd59977 653 }
654 }
655 }
656
657 return FFF;
658}
659
660
661//=======================================================================
662//function : HeightMax
0d969553 663//purpose : Calculate the height of the prism following the parameters of a bounding box
7fd59977 664//=======================================================================
665
666Standard_Real BRepFeat_RibSlot::HeightMax(const TopoDS_Shape& theSbase,
4e57c75e 667 const TopoDS_Shape& theSUntil,
668 gp_Pnt& p1,
7fd59977 669 gp_Pnt& p2)
670{
0797d9d3 671#ifdef OCCT_DEBUG
7fd59977 672 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
04232180 673 if (trc) std::cout << "BRepFeat_RibSlot::HeightMax" << std::endl;
7fd59977 674#endif
675 Bnd_Box Box;
676 BRepBndLib::Add(theSbase,Box);
677 if(!theSUntil.IsNull()) {
678 BRepBndLib::Add(theSUntil,Box);
679 }
680 Standard_Real c[6], bnd;
681 Box.Get(c[0],c[2],c[4],c[1],c[3],c[5]);
682 bnd = c[0];
683 for(Standard_Integer i = 0 ; i < 6; i++) {
684 if(c[i] > bnd) bnd = c[i];
685 }
686 p1.SetCoord(c[0]-2.*bnd, c[1]-2.*bnd, c[2]-2.*bnd);
687 p2.SetCoord(c[3]+2.*bnd, c[4]+2.*bnd, c[5]+2.*bnd);
688 return(bnd);
689}
690
691//=======================================================================
692//function : ExtremeFaces
0d969553 693//purpose : Calculate the base faces of the rib
7fd59977 694//=======================================================================
695
696Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib,
4e57c75e 697 const Standard_Real bnd,
698 const Handle(Geom_Plane)& Pln,
699 TopoDS_Edge& FirstEdge,
700 TopoDS_Edge& LastEdge,
701 TopoDS_Face& FirstFace,
702 TopoDS_Face& LastFace,
703 TopoDS_Vertex& FirstVertex,
704 TopoDS_Vertex& LastVertex,
705 Standard_Boolean& OnFirstFace,
706 Standard_Boolean& OnLastFace,
707 Standard_Boolean& PtOnFirstEdge,
708 Standard_Boolean& PtOnLastEdge,
709 TopoDS_Edge& OnFirstEdge,
710 TopoDS_Edge& OnLastEdge)
7fd59977 711
712{
0797d9d3 713#ifdef OCCT_DEBUG
7fd59977 714 Standard_Boolean trc = BRepFeat_GettraceFEAT();
04232180 715 if (trc) std::cout << "BRepFeat_RibSlot::ExtremeFaces" << std::endl;
7fd59977 716#endif
717 Standard_Boolean Data = Standard_True;
718 FirstFace.Nullify();
719 LastFace.Nullify();
720 FirstEdge.Nullify();
721 LastEdge.Nullify();
722 PtOnFirstEdge = Standard_False;
723 PtOnLastEdge = Standard_False;
724 OnFirstEdge.Nullify();
725 OnLastEdge.Nullify();
726
727 BRepIntCurveSurface_Inter inter;
728 BRep_Builder B;
729 TopExp_Explorer ex1;
730
731 Standard_Boolean FirstOK = Standard_False, LastOK = Standard_False;
732
733 Standard_Integer NumberOfEdges = 0;
734 TopExp_Explorer exp(myWire, TopAbs_EDGE);
735
736 for(; exp.More(); exp.Next()) {
737 NumberOfEdges++;
738 }
739
0d969553 740// ---the wire includes only one edge
7fd59977 741 if(NumberOfEdges == 1) {
0797d9d3 742#ifdef OCCT_DEBUG
04232180 743 if (trc) std::cout << " One Edge" << std::endl;
7fd59977 744#endif
745 exp.ReInit();
746 Standard_Real f, l;//, f1, l1, temp;
747 gp_Pnt firstpoint, lastpoint;
748
0d969553 749// Points limit the unique edge
7fd59977 750 const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
751 Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l);
752 gp_Pnt p1 = BRep_Tool::Pnt(TopExp::FirstVertex(E,Standard_True));
753 gp_Pnt p2 = BRep_Tool::Pnt(TopExp::LastVertex(E,Standard_True));
754
755 Standard_Real FirstPar = f; Standard_Real LastPar = l;
756
757
0d969553
Y
758// ---Find if 2 points limiting the unique edge of the wire
759// are on an edge or a vertex of the base shape
7fd59977 760 Standard_Boolean PtOnFirstVertex = Standard_False;
761 Standard_Boolean PtOnLastVertex = Standard_False;
762 TopoDS_Vertex OnFirstVertex, OnLastVertex;
763 PtOnEdgeVertex(RevolRib, mySbase, p1, FirstVertex, LastVertex,
4e57c75e 764 PtOnFirstEdge, OnFirstEdge, PtOnFirstVertex, OnFirstVertex);
7fd59977 765 PtOnEdgeVertex(RevolRib, mySbase, p2, FirstVertex, LastVertex,
4e57c75e 766 PtOnLastEdge, OnLastEdge, PtOnLastVertex, OnLastVertex);
7fd59977 767
768 TopTools_MapOfShape Map;
769
770 if(PtOnFirstEdge) {
771 if (!PtOnFirstVertex) {
0d969553
Y
772// Find FirstFace : face of the base shape containing OnFirstEdge
773// meeting ChoiceOfFaces
4e57c75e 774 TopExp_Explorer ex4, ex5;
775 ex4.Init(mySbase, TopAbs_FACE);
776 TopTools_ListOfShape faces;
777 faces.Clear();
778 Map.Clear();
779 for(; ex4.More(); ex4.Next()) {
e45b5ff7 780 const TopoDS_Face& fx = TopoDS::Face(ex4.Current());
4e57c75e 781 if ( !Map.Add(fx)) continue;
782 ex5.Init(ex4.Current(), TopAbs_EDGE);
783 for(; ex5.More(); ex5.Next()) {
784 const TopoDS_Edge& ee = TopoDS::Edge(ex5.Current());
785 if(ee.IsSame(OnFirstEdge)) {
786 faces.Append(fx);
787 }
788 }
789 }
790 if(!faces.IsEmpty()) {
791 TopoDS_Face FFF = ChoiceOfFaces(faces, cc, FirstPar+bnd/50., bnd/50., Pln);
792 if(!FFF.IsNull()) FirstFace = FFF;
793 }
7fd59977 794 }
795 else if(PtOnFirstVertex) {
0d969553
Y
796// Find FirstFace : face of the base shape containing OnFirstVertex
797// meeting ChoiceOfFaces
4e57c75e 798 TopExp_Explorer ex4, ex5;
799 ex4.Init(mySbase, TopAbs_FACE);
800 TopTools_ListOfShape faces;
801 faces.Clear();
802 Map.Clear();
803 for(; ex4.More(); ex4.Next()) {
e45b5ff7 804 const TopoDS_Face& fx = TopoDS::Face(ex4.Current());
4e57c75e 805 if ( !Map.Add(fx)) continue;
806 ex5.Init(ex4.Current(), TopAbs_VERTEX);
807 for(; ex5.More(); ex5.Next()) {
808 const TopoDS_Vertex& vv = TopoDS::Vertex(ex5.Current());
809 if(vv.IsSame(OnFirstVertex)) {
810 faces.Append(fx);
811 break;
812 }
813 }
814 }
815 if(!faces.IsEmpty()) {
816 TopoDS_Face FFF = ChoiceOfFaces(faces, cc, FirstPar+bnd/50., bnd/50., Pln);
817 if(!FFF.IsNull()) FirstFace = FFF;
818 }
7fd59977 819 }
820 FirstEdge = E;
821 BRepLib_MakeVertex v(p1);
822 FirstVertex = v;
823 OnFirstFace = Standard_True;
824 }
825
826 if(PtOnLastEdge) {
827 if (!PtOnLastVertex) {
0d969553
Y
828// Find LastFace : face of the base shape containing OnLastEdge
829// meeting ChoiceOfFaces
4e57c75e 830 TopExp_Explorer ex4, ex5;
831 ex4.Init(mySbase, TopAbs_FACE);
832 TopTools_ListOfShape faces;
833 faces.Clear();
834 Map.Clear();
835 for(; ex4.More(); ex4.Next()) {
e45b5ff7 836 const TopoDS_Face& fx = TopoDS::Face(ex4.Current());
4e57c75e 837 if ( !Map.Add(fx)) continue;
838 ex5.Init(ex4.Current(), TopAbs_EDGE);
839 for(; ex5.More(); ex5.Next()) {
840 const TopoDS_Edge& ee = TopoDS::Edge(ex5.Current());
841 if(ee.IsSame(OnLastEdge)) {
842 faces.Append(fx);
843 break;
844 }
845 }
846 }
847 if(!faces.IsEmpty()) {
848 TopoDS_Face FFF = ChoiceOfFaces(faces, cc, LastPar-bnd/50., bnd/50., Pln);
849 if(!FFF.IsNull()) LastFace = FFF;
850 }
7fd59977 851 }
852 else if(PtOnLastEdge && PtOnLastVertex) {
0d969553
Y
853// Find LastFace : face of the base shape containing OnLastVertex
854// meeting ChoiceOfFaces
4e57c75e 855 TopExp_Explorer ex4, ex5;
856 ex4.Init(mySbase, TopAbs_FACE);
857 TopTools_ListOfShape faces;
858 faces.Clear();
859 Map.Clear();
860 for(; ex4.More(); ex4.Next()) {
e45b5ff7 861 const TopoDS_Face& fx = TopoDS::Face(ex4.Current());
4e57c75e 862 if ( !Map.Add(fx)) continue;
863 ex5.Init(ex4.Current(), TopAbs_VERTEX);
864 for(; ex5.More(); ex5.Next()) {
865 const TopoDS_Vertex& vv = TopoDS::Vertex(ex5.Current());
866 if(vv.IsSame(OnLastVertex)) {
867 faces.Append(fx);
868 break;
869 }
870 }
871 }
872 if(!faces.IsEmpty()) {
873 TopoDS_Face FFF = ChoiceOfFaces(faces, cc, LastPar-bnd/50., bnd/50., Pln);
874 if(!FFF.IsNull()) LastFace = FFF;
875 }
7fd59977 876 }
877 LastEdge = E;
878 BRepLib_MakeVertex v(p2);
879 LastVertex = v;
880 OnLastFace = Standard_True;
881 }
882
883 if(!FirstFace.IsNull() && !LastFace.IsNull()) {
884 return Standard_True;
885 }
886
0d969553 887//--- FirstFace or LastFace was not found
0797d9d3 888#ifdef OCCT_DEBUG
04232180 889 if (trc) std::cout << " FirstFace or LastFace null" << std::endl;
7fd59977 890#endif
891 LocOpe_CSIntersector ASI(mySbase);
892 TColGeom_SequenceOfCurve scur;
893 scur.Clear();
894 scur.Append(cc);
895 ASI.Perform(scur);
896 Standard_Real lastpar, firstpar;
897 if(ASI.IsDone() && ASI.NbPoints(1) >= 2) {
898 lastpar = ASI.Point(1, ASI.NbPoints(1)).Parameter();
899 Standard_Integer lastindex = ASI.NbPoints(1);
900 if(lastpar > l) {
4e57c75e 901 for(Standard_Integer jj=ASI.NbPoints(1)-1; jj>=1; jj--) {
902 Standard_Real par = ASI.Point(1,jj).Parameter();
903 if(par <= l) {
904 lastpar = par;
905 lastindex = jj;
906 break;
907 }
908 }
7fd59977 909 }
910 Standard_Integer firstindex = lastindex -1;
911 firstpar = ASI.Point(1,firstindex).Parameter();
912
913 if(FirstFace.IsNull()) {
4e57c75e 914 FirstFace = ASI.Point(1, firstindex).Face();
915 cc->D0(firstpar, firstpoint);
916 BRepLib_MakeVertex v1(firstpoint);
917 FirstVertex = TopoDS::Vertex(v1.Shape());
918 FirstEdge = E;
7fd59977 919 }
920
921 if(LastFace.IsNull()) {
4e57c75e 922 LastFace = ASI.Point(1, lastindex).Face();
923 cc->D0(lastpar, lastpoint);
924 BRepLib_MakeVertex v2(lastpoint);
925 LastVertex = TopoDS::Vertex(v2.Shape());
926 LastEdge = E;
7fd59977 927 }
928 }
929 else {
0797d9d3 930#ifdef OCCT_DEBUG
04232180 931 if (trc) std::cout << " Less than 2 intersection points" << std::endl;
7fd59977 932#endif
933 Data = Standard_False;
934 return Data;
935 }
936
937 if(!OnFirstFace) {
938 if(p1.Distance(firstpoint) <= Precision::Confusion())
4e57c75e 939 OnFirstFace = Standard_True;
7fd59977 940 else OnFirstFace = Standard_False;
941 }
942
943 if(!OnLastFace) {
944 if(p2.Distance(lastpoint) <= Precision::Confusion())
4e57c75e 945 OnLastFace = Standard_True;
7fd59977 946 else OnLastFace = Standard_False;
947 }
948
949 if(FirstFace.IsNull() || LastFace.IsNull()) {
0797d9d3 950#ifdef OCCT_DEBUG
04232180 951 if (trc) std::cout << " First or Last Faces still null" << std::endl;
7fd59977 952#endif
953 Data = Standard_False;
954 }
955 else {
0797d9d3 956#ifdef OCCT_DEBUG
04232180 957 if (trc) std::cout << " FirstFace and LastFace OK" << std::endl;
7fd59977 958#endif
959 Data = Standard_True;
960 }
961
962 return Data;
963 }
0d969553 964// ---The wire consists of several edges
7fd59977 965 else {
0797d9d3 966#ifdef OCCT_DEBUG
04232180 967 if (trc) std::cout << " Multiple Edges" << std::endl;
7fd59977 968#endif
969 BRepTools_WireExplorer ex(myWire);
970 for(; ex.More(); ex.Next()) {
971 const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
972 Standard_Real f, l;
973 Handle(Geom_Curve) Cur = BRep_Tool::Curve(E, f, l);
974 f = f - bnd/10000; l = l +bnd/10000;
975 Handle(Geom_TrimmedCurve) curve;
976 curve = new Geom_TrimmedCurve(Cur, f, l, Standard_True);
0797d9d3 977#ifdef OCCT_DEBUG
76363522 978 gp_Pnt P1 = BRep_Tool::Pnt(TopExp::FirstVertex(E,Standard_True)); (void)P1;
7fd59977 979#endif
7fd59977 980 gp_Pnt P2 = BRep_Tool::Pnt(TopExp::LastVertex(E,Standard_True));
981 ex1.Init(mySbase, TopAbs_FACE);
982 TopoDS_Vertex theVertex;
983 TopoDS_Edge theEdge;
984 TopoDS_Face theFace;
985 Standard_Boolean PtOnEdge = Standard_False;
986 Standard_Boolean PtOnVertex = Standard_False;
987 TopoDS_Edge OnEdge;
988 TopoDS_Vertex OnVertex;
989 Standard_Real intpar;
990 for(; ex1.More(); ex1.Next()) {
51740958 991 const TopoDS_Face& aCurFace = TopoDS::Face(ex1.Current());
543a9964 992 GeomAdaptor_Curve aGAC (curve);
51740958 993 inter.Init (aCurFace, aGAC, BRep_Tool::Tolerance(aCurFace));
4e57c75e 994 if(!inter.More()) continue;
995 for(; inter.More(); inter.Next()) {
996 gp_Pnt thePoint = inter.Pnt();
997 if(!FirstVertex.IsNull()) {
998 gp_Pnt point = BRep_Tool::Pnt(FirstVertex);
51740958 999 if(point.Distance(thePoint) <= BRep_Tool::Tolerance(aCurFace)) {
4e57c75e 1000 continue;
1001 }
1002 }
1003 intpar = IntPar(curve, thePoint);
1004 theEdge = E;
51740958 1005 theFace = aCurFace;
4e57c75e 1006 B.MakeVertex(theVertex, thePoint, Precision::Confusion());
1007 if(!FirstOK) {
1008 if(thePoint.Distance(P2) <= Precision::Confusion()) {
1009 continue;
1010 }
1011 }
7fd59977 1012
0d969553 1013// ---Find thepoint on an edge or a vertex of face f
51740958 1014 PtOnEdgeVertex(RevolRib, aCurFace, thePoint, FirstVertex, LastVertex,
4e57c75e 1015 PtOnEdge,OnEdge,PtOnVertex,OnVertex);
1016
1017
1018// if(!theEdge.IsNull()) break;
1019
1020 if (FirstEdge.IsNull() && !theEdge.IsNull() &&
1021 !theFace.IsNull() && !theVertex.IsNull()) {
1022 FirstEdge = theEdge;
1023 FirstFace = theFace;
1024 FirstVertex = theVertex;
1025 PtOnFirstEdge = PtOnEdge;
1026 OnFirstEdge = OnEdge;
1027 theEdge.Nullify(); theFace.Nullify(); theVertex.Nullify();
1028 if(PtOnEdge && !PtOnVertex) {
1029 TopTools_ListOfShape faces;
1030 faces.Clear();
1031 faces.Append(FirstFace);
1032 TopExp_Explorer ex2;
1033 ex2.Init(mySbase, TopAbs_FACE);
1034 for(; ex2.More(); ex2.Next()) {
e45b5ff7 1035 TopoDS_Face fx = TopoDS::Face(ex2.Current());
4e57c75e 1036 TopExp_Explorer ex3;
1037 ex3.Init(fx, TopAbs_EDGE);
1038 for(; ex3.More(); ex3.Next()) {
1039 const TopoDS_Edge& e = TopoDS::Edge(ex3.Current());
1040 if(e.IsSame(OnEdge) && !fx.IsSame(FirstFace)) {
1041 faces.Append(fx);
1042 }
1043 }
1044 }
1045 TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar+bnd/10., bnd/10., Pln);
1046 if(!FFF.IsNull()) FirstFace = FFF;
1047 }
1048 else if(PtOnEdge && PtOnVertex) {
1049 TopTools_ListOfShape faces;
1050 faces.Clear();
1051 faces.Append(FirstFace);
1052 TopExp_Explorer ex2;
1053 ex2.Init(mySbase, TopAbs_FACE);
1054 for(; ex2.More(); ex2.Next()) {
e45b5ff7 1055 TopoDS_Face fx = TopoDS::Face(ex2.Current());
4e57c75e 1056 TopExp_Explorer ex3;
1057 ex3.Init(fx, TopAbs_VERTEX);
1058 for(; ex3.More(); ex3.Next()) {
1059 const TopoDS_Vertex& v = TopoDS::Vertex(ex3.Current());
1060 if(v.IsSame(OnVertex) && !fx.IsSame(FirstFace)) {
1061 faces.Append(fx);
1062 }
1063 }
1064 }
1065 TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar+bnd/10., bnd/10., Pln);
1066 if(!FFF.IsNull()) FirstFace = FFF;
1067 }
1068 if(!FirstEdge.IsNull() && !FirstFace.IsNull()
1069 && !FirstVertex.IsNull()) {
1070 FirstOK = Standard_True;
1071 }
1072 }
1073 if(LastEdge.IsNull() && !theEdge.IsNull() &&
1074 !theFace.IsNull() && !theVertex.IsNull() &&
1075 !FirstEdge.IsNull()) {
1076 LastEdge = theEdge;
1077 LastFace = theFace;
1078 LastVertex = theVertex;
1079 PtOnLastEdge = PtOnEdge;
1080 OnLastEdge = OnEdge;
1081 if(PtOnEdge && !PtOnVertex) {
1082 TopTools_ListOfShape faces;
1083 faces.Clear();
1084 faces.Append(LastFace);
1085 TopExp_Explorer ex2;
1086 ex2.Init(mySbase, TopAbs_FACE);
1087 for(; ex2.More(); ex2.Next()) {
e45b5ff7 1088 TopoDS_Face fx = TopoDS::Face(ex2.Current());
4e57c75e 1089 TopExp_Explorer ex3;
1090 ex3.Init(fx, TopAbs_EDGE);
1091 for(; ex3.More(); ex3.Next()) {
1092 const TopoDS_Edge& e = TopoDS::Edge(ex3.Current());
1093 if(e.IsSame(OnEdge) && !fx.IsSame(LastFace)) {
1094 faces.Append(fx);
1095 }
1096 }
1097 }
1098 TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar-bnd/10.,bnd/10., Pln);
1099 if(!FFF.IsNull()) LastFace = FFF;
1100 }
1101 else if(PtOnEdge && PtOnVertex) {
1102 TopTools_ListOfShape faces;
1103 faces.Clear();
1104 faces.Append(LastFace);
1105 TopExp_Explorer ex2;
1106 ex2.Init(mySbase, TopAbs_FACE);
1107 for(; ex2.More(); ex2.Next()) {
e45b5ff7 1108 TopoDS_Face fx = TopoDS::Face(ex2.Current());
4e57c75e 1109 TopExp_Explorer ex3;
1110 ex3.Init(fx, TopAbs_VERTEX);
1111 for(; ex3.More(); ex3.Next()) {
1112 const TopoDS_Vertex& v = TopoDS::Vertex(ex3.Current());
1113 if(v.IsSame(OnVertex) && !fx.IsSame(LastFace)) {
1114 faces.Append(fx);
1115 }
1116 }
1117 }
1118 TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar-bnd/10.,bnd/10., Pln);
1119 if(!FFF.IsNull()) LastFace = FFF;
1120 }
1121 if(!LastEdge.IsNull() && !LastFace.IsNull()
1122 && !LastVertex.IsNull()) {
1123 LastOK = Standard_True;
1124 }
1125 break;
1126 }
1127 }
7fd59977 1128 }
1129 }
1130
1131 if(FirstOK && LastOK) {
1132 Data = Standard_True;
1133 gp_Pnt PP1 = BRep_Tool::Pnt(TopExp::FirstVertex(FirstEdge,Standard_True));
1134 gp_Pnt PP2 = BRep_Tool::Pnt(TopExp::LastVertex(LastEdge,Standard_True));
1135 gp_Pnt p1 = BRep_Tool::Pnt(FirstVertex);
1136 gp_Pnt p2 = BRep_Tool::Pnt(LastVertex);
1137 if(p1.Distance(PP1) <= BRep_Tool::Tolerance(FirstFace)) {
4e57c75e 1138 OnFirstFace = Standard_True;
7fd59977 1139 }
1140 if(p2.Distance(PP2) <= BRep_Tool::Tolerance(LastFace)) {
4e57c75e 1141 OnLastFace = Standard_True;
7fd59977 1142 }
1143 return Standard_True;
1144 }
1145 else {
0797d9d3 1146#ifdef OCCT_DEBUG
04232180 1147 if (trc) std::cout << " First or Last not OK" << std::endl;
7fd59977 1148#endif
1149 return Standard_False;
1150 }
1151 }
1152}
1153
1154
1155//=======================================================================
1156//function : PtOnEdgeVertex
0d969553
Y
1157//purpose : Find if 2 limit points of the unique edge of a wire
1158// are on an edge or a vertex of the base shape
7fd59977 1159//=======================================================================
1160
1161void BRepFeat_RibSlot::PtOnEdgeVertex(const Standard_Boolean RevolRib,
4e57c75e 1162 const TopoDS_Shape& shape,
1163 const gp_Pnt& point,
1164 const TopoDS_Vertex& ,//FirstVertex,
1165 const TopoDS_Vertex& ,//LastVertex,
1166 Standard_Boolean& PtOnEdge,
1167 TopoDS_Edge& OnEdge,
1168 Standard_Boolean& PtOnVertex,
1169 TopoDS_Vertex& OnVertex)
7fd59977 1170
1171{
0797d9d3 1172#ifdef OCCT_DEBUG
7fd59977 1173 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
04232180 1174 if (trc) std::cout << "BRepFeat_RibSlot::PtOnEdgeVertex" << std::endl;
7fd59977 1175#endif
1176 Standard_Boolean TestOK;
1177// PtOnEdge = Standard_False;
1178// OnEdge.Nullify();
1179// PtOnVertex = Standard_False;
1180// OnVertex.Nullify();
1181
1182 TopExp_Explorer EXP;
1183 EXP.Init(shape, TopAbs_EDGE);
1184 TopTools_MapOfShape Map;
1185 for(; EXP.More(); EXP.Next()) {
1186 const TopoDS_Edge& e = TopoDS::Edge(EXP.Current());
1187 if ( !Map.Add(e)) continue;
1188 if (!RevolRib) {
1189 if (BRep_Tool::Degenerated(e)) continue;
1190 }
1191 Standard_Real fff, lll;
1192 Handle(Geom_Curve) ccc = BRep_Tool::Curve(e, fff, lll);
1193 if (!RevolRib) {
1194 ccc = new Geom_TrimmedCurve(ccc, fff, lll);
1195 }
1196 GeomAPI_ProjectPointOnCurve proj(point, ccc);
1197 TestOK = Standard_False;
1198 if (!RevolRib) {
1199 if(proj.NbPoints() == 1) TestOK = Standard_True;
1200 }
1201 else {
1202 if(proj.NbPoints() >= 1) TestOK = Standard_True;
1203 }
1204 if(TestOK && proj.Distance(1) <= BRep_Tool::Tolerance(e)) {
1205 PtOnEdge = Standard_True;
4e57c75e 1206 OnEdge = e;
7fd59977 1207 TopoDS_Vertex ev1 = TopExp::FirstVertex(e,Standard_True);
1208 TopoDS_Vertex ev2 = TopExp::LastVertex(e,Standard_True);
1209 gp_Pnt ep1 = BRep_Tool::Pnt(ev1);
1210 gp_Pnt ep2 = BRep_Tool::Pnt(ev2);
1211 if(point.Distance(ep1) <= BRep_Tool::Tolerance(ev1)) {
4e57c75e 1212 PtOnVertex = Standard_True;
1213 OnVertex = ev1;
1214 break;
7fd59977 1215 }
1216 else if(point.Distance(ep2) <= BRep_Tool::Tolerance(ev1)) {
4e57c75e 1217 PtOnVertex = Standard_True;
1218 OnVertex = ev2;
1219 break;
1220 }
7fd59977 1221 break;
1222 }
1223 }
1224}
1225
1226
1227//=======================================================================
1228//function : SlidingProfile
0d969553 1229//purpose : construction of the profile face in case of sliding
7fd59977 1230//=======================================================================
1231
1232Standard_Boolean BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof,
4e57c75e 1233 const Standard_Boolean RevolRib,
1234 const Standard_Real myTol,
1235 Standard_Integer& Concavite,
1236 const Handle(Geom_Plane)& myPln,
1237 const TopoDS_Face& BndFace,
1238 const gp_Pnt& CheckPnt,
1239 const TopoDS_Face& FirstFace,
1240 const TopoDS_Face& LastFace,
1241 const TopoDS_Vertex& ,//FirstVertex,
1242 const TopoDS_Vertex& ,//LastVertex,
1243 const TopoDS_Edge& FirstEdge,
1244 const TopoDS_Edge& LastEdge)
7fd59977 1245
1246{
0797d9d3 1247#ifdef OCCT_DEBUG
7fd59977 1248 Standard_Boolean trc = BRepFeat_GettraceFEAT();
04232180 1249 if (trc) std::cout << "BRepFeat_RibSlot::SlidingProfile" << std::endl;
7fd59977 1250#endif
1251 Standard_Boolean ProfileOK = Standard_True;
0d969553
Y
1252// --case of sliding : construction of the wire of the profile
1253// --> 1 part bounding box + 1 part wire
1254// attention to the compatibility of orientations
7fd59977 1255
1256 gp_Dir FN, LN;
1257 BRepLib_MakeWire WW;
1258
1259 FN = Normal(FirstFace, myFirstPnt);
1260 LN = Normal(LastFace, myLastPnt);
1261
0d969553
Y
1262// Case of the groove (cut) <> rib (fuse)
1263// -> we are in the material
1264// -> make everything in 2d in the working plane : easier
7fd59977 1265 if(!myFuse) {
1266 FN = -FN;
1267 LN = -LN;
1268 }
1269
1270
1271 Handle(Geom_Line) ln1, ln2;
1272 gp_Pnt Pt;//,p1, p2;
1273
1274 ln2 = new Geom_Line(myFirstPnt, FN);
1275 ln1 = new Geom_Line(myLastPnt, LN);
1276
1277 Handle(Geom2d_Curve) ln2d1 = GeomAPI::To2d(ln1, myPln->Pln());
1278 Handle(Geom2d_Curve) ln2d2 = GeomAPI::To2d(ln2, myPln->Pln());
1279
1280 Geom2dAPI_InterCurveCurve inter(ln2d1, ln2d2, Precision::Confusion());
1281
1282 Standard_Boolean TestOK = Standard_True;
1283 if (RevolRib) {
1284 gp_Dir d1, d2;
1285 d1 = ln1->Position().Direction();
1286 d2 = ln2->Position().Direction();
1287 if(d1.IsOpposite(d2, myTol)) {
1288 Standard_Real par1 = ElCLib::Parameter(ln1->Lin(), myFirstPnt);
1289 Standard_Real par2 = ElCLib::Parameter(ln2->Lin(), myLastPnt);
1290 if(par1 >= myTol || par2 >= myTol) {
b81b237f 1291 Concavite = 2; //parallel and concave
4e57c75e 1292 BRepLib_MakeEdge e1(myLastPnt, myFirstPnt);
1293 WW.Add(e1);
7fd59977 1294 }
1295 }
1296 if(d1.IsEqual(d2, myTol)) {
1297 if(Concavite == 3) TestOK = Standard_False;
1298 }
1299 }
1300
1301 if(TestOK) {
1302 if(inter.NbPoints() > 0) {
1303 gp_Pnt2d P = inter.Point(1);
1304 myPln->D0(P.X(), P.Y(), Pt);
1305 Standard_Real par = IntPar(ln1, Pt);
1306 if(par>0) Concavite = 1; //concave
1307 }
1308 }
1309
0d969553 1310// ---Construction of the profile face
7fd59977 1311 if(Concavite == 1) {
0d969553
Y
1312// if concave : it is possible to extend first and last edges of the wire
1313// to the bounding box
7fd59977 1314 BRepLib_MakeEdge e1(myLastPnt, Pt);
1315 WW.Add(e1);
1316 BRepLib_MakeEdge e2(Pt, myFirstPnt);
1317 WW.Add(e2);
1318 }
1319 else if(Concavite == 3) {
0d969553 1320// BndEdge : edges of intersection with the bounding box
7fd59977 1321 TopoDS_Edge BndEdge1, BndEdge2;
0d969553 1322// Points of intersection with the bounding box / Find Profile
7fd59977 1323 gp_Pnt BndPnt1, BndPnt2, LastPnt;
1324 TopExp_Explorer expl;
1325 expl.Init(BndFace, TopAbs_WIRE);
1326 BRepTools_WireExplorer explo;
1327 TopoDS_Wire BndWire = TopoDS::Wire(expl.Current());
1328 explo.Init(BndWire);
1329 for(; explo.More(); explo.Next()) {
1330 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1331 Standard_Real first, last;
1332 Handle(Geom_Curve) c = BRep_Tool::Curve(e, first, last);
1333 Handle(Geom2d_Curve) c2d = GeomAPI::To2d(c, myPln->Pln());
1334 Geom2dAPI_InterCurveCurve intcln1(ln2d1, c2d,
4e57c75e 1335 Precision::Confusion());
7fd59977 1336 if(intcln1.NbPoints() > 0) {
4e57c75e 1337 gp_Pnt2d p2d = intcln1.Point(1);
1338 gp_Pnt p;
1339 myPln->D0(p2d.X(), p2d.Y(), p);
1340 Standard_Real parl = IntPar(ln1, p);
1341 Standard_Real parc = IntPar(c, p);
1342 if(parc >= first && parc <= last && parl >= 0) {
1343 BndEdge1 = e;
1344 BndPnt1 = p;
1345 }
7fd59977 1346 }
1347
1348 Geom2dAPI_InterCurveCurve intcln2(ln2d2, c2d,
4e57c75e 1349 Precision::Confusion());
7fd59977 1350 if(intcln2.NbPoints() > 0) {
4e57c75e 1351 gp_Pnt2d p2d = intcln2.Point(1);
1352 gp_Pnt p;
1353 myPln->D0(p2d.X(), p2d.Y(), p);
1354 Standard_Real parl = IntPar(ln2, p);
1355 Standard_Real parc = IntPar(c, p);
1356 if(parc >= first && parc <= last && parl >= 0) {
1357 BndEdge2 = e;
1358 BndPnt2 = p;
1359 }
7fd59977 1360 }
1361 if(!BndEdge1.IsNull() && !BndEdge2.IsNull()) break;
1362 }
1363
1364 if(BndEdge1.IsNull() || BndEdge2.IsNull()) {
0797d9d3 1365#ifdef OCCT_DEBUG
04232180 1366 if (trc) std::cout << " Null bounding edge" << std::endl;
7fd59977 1367#endif
1368 ProfileOK = Standard_False;
1369 return ProfileOK;
1370 }
1371
1372
1373 BRepLib_MakeEdge e1(myLastPnt, BndPnt1);
1374 WW.Add(e1);
1375
1376 if(BndEdge1.IsSame(BndEdge2)) {
0d969553 1377// Particular case : same edge -> simply determined path
7fd59977 1378 BRepLib_MakeEdge e2(BndPnt1, BndPnt2);
1379 WW.Add(e2);
1380 BRepLib_MakeEdge e3(BndPnt2, myFirstPnt);
4e57c75e 1381 WW.Add(e3);
7fd59977 1382 }
1383 else {
1384 explo.Init(BndWire);
1385 for(; explo.More(); explo.Next()) {
4e57c75e 1386 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1387 if(e.IsSame(BndEdge1)) {
1388 gp_Pnt pp;
1389 pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True));
1390 if(pp.Distance(BndPnt1) >= BRep_Tool::Tolerance(e)) {
1391 LastPnt = pp;
1392 }
1393// else { //LinearForm
1394// gp_Pnt ppp = BRep_Tool::Pnt(TopExp::FirstVertex(e,Standard_True));
1395// LastPnt = ppp;
1396// }
1397 BRepLib_MakeEdge e2(BndPnt1, LastPnt);
1398 WW.Add(e2);
1399 break;
1400 }
7fd59977 1401 }
1402
1403 if(explo.More()) {
4e57c75e 1404 explo.Next();
1405 if(explo.Current().IsNull()) explo.Init(BndWire);
7fd59977 1406 }
1407 else explo.Init(BndWire);
1408
0d969553
Y
1409// Check if this is BndEdge2
1410// -> if yes : it is required to turn to join FirstPnt
1411// -> if no : add edges
7fd59977 1412 Standard_Boolean Fin = Standard_False;
1413 while(!Fin) {
4e57c75e 1414 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1415 if(!e.IsSame(BndEdge2)) {
1416 gp_Pnt pp;
1417 pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True));
1418 BRepLib_MakeEdge ee(LastPnt, pp);
1419 WW.Add(ee);
1420 LastPnt = pp;
1421 }
1422 else {
0d969553
Y
1423// the path is closed
1424// -> since met BndEdge2, end of borders on BndFace
4e57c75e 1425 Fin = Standard_True;
1426 BRepLib_MakeEdge ee(LastPnt, BndPnt2);
1427 WW.Add(ee);
1428 LastPnt = BndPnt2;
1429 }
1430 if(explo.More()) {
1431 explo.Next();
1432 if(explo.Current().IsNull()) {
1433 explo.Init(BndWire);
1434 }
1435 }
1436 else explo.Init(BndWire);
7fd59977 1437 }
1438
1439 BRepLib_MakeEdge e3(BndPnt2, myFirstPnt);
1440 WW.Add(e3);
1441 }
1442 }
1443
0d969553 1444// ---Construction of the profile
7fd59977 1445
0d969553
Y
1446// Explore the wire provided by the user
1447// BRepTools_WireExplorer : correct order - without repetition <> TopExp : non ordered
7fd59977 1448 BRepTools_WireExplorer EX(myWire);
1449
1450 Standard_Real ff, ll;
1451 Handle(Geom_Curve) FirstCurve = BRep_Tool::Curve(FirstEdge, ff, ll);
1452
1453 if(!FirstEdge.IsSame(LastEdge)) {
1454 TopoDS_Vertex FLVert = TopExp::LastVertex(FirstEdge,Standard_True);
1455 gp_Pnt FLPnt = BRep_Tool::Pnt(FLVert);
1456 BRepLib_MakeEdge ef(FirstCurve, myFirstPnt, FLPnt);
1457 WW.Add(ef);
1458 for(; EX.More(); EX.Next()) {
1459 const TopoDS_Edge& E = EX.Current();
4e57c75e 1460 if(E.IsSame(FirstEdge)) break;
7fd59977 1461 }
1462 EX.Next();
1463 for(; EX.More(); EX.Next()) {
1464 const TopoDS_Edge& E = EX.Current();
1465 if(!E.IsSame(LastEdge)) {
4e57c75e 1466 WW.Add(E);
1467 }
7fd59977 1468 else break;
1469 }
1470 Handle(Geom_Curve) LastCurve = BRep_Tool::Curve(LastEdge, ff, ll);
1471 TopoDS_Vertex LFVert = TopExp::FirstVertex(LastEdge,Standard_True);
1472 gp_Pnt LFPnt = BRep_Tool::Pnt(LFVert);
1473 BRepLib_MakeEdge el(LastCurve, LFPnt, myLastPnt);
1474 WW.Add(el);
1475 }
1476 else {
0d969553 1477// only one edge : particular processing
7fd59977 1478 Standard_Real fpar = IntPar(FirstCurve, myFirstPnt);
1479 Standard_Real lpar = IntPar(FirstCurve, myLastPnt);
1480 Handle(Geom_Curve) c;
1481 if(fpar > lpar)
a9dde4a3 1482 c = FirstCurve->Reversed();
7fd59977 1483 else
1484 c = FirstCurve;
1485
1486 BRepLib_MakeEdge ef(c, myFirstPnt, myLastPnt);
1487 WW.Add(ef);
1488 }
1489
1490 BRepLib_MakeFace f(myPln->Pln(), WW, Standard_True);
1491 TopoDS_Face fac = TopoDS::Face(f.Shape());
1492
1493 if (!BRepAlgo::IsValid(fac)) {
0797d9d3 1494#ifdef OCCT_DEBUG
04232180 1495 if (trc) std::cout << " Invalid Face" << std::endl;
7fd59977 1496#endif
1497 ProfileOK = Standard_False;
1498 return ProfileOK;
1499 }
1500
1501 if(Concavite != 3) {
0d969553 1502// if concave : face is OK
7fd59977 1503 Prof = fac;
1504 }
1505 else {
0d969553
Y
1506// if not concave
1507// CheckPnt : point slightly inside the material side
1508// Bndface : face/cut of the bounding box in the plane of the profile
7fd59977 1509 BRepTopAdaptor_FClass2d Cl(fac, BRep_Tool::Tolerance(fac));
1510 Standard_Real u, v;
1511 ElSLib::Parameters(myPln->Pln(), CheckPnt, u, v);
1512 gp_Pnt2d checkpnt2d(u, v);
1513 if(Cl.Perform(checkpnt2d, Standard_True) == TopAbs_OUT) {
0d969553 1514// If face is not the correct part of BndFace take the complementary
7fd59977 1515 BRepAlgoAPI_Cut c(BndFace, fac);
7fd59977 1516 TopExp_Explorer exp(c.Shape(), TopAbs_WIRE);
1517 const TopoDS_Wire& w = TopoDS::Wire(exp.Current());
e45b5ff7 1518 BRepLib_MakeFace ffx(w);
7fd59977 1519 Prof = TopoDS::Face(ffx.Shape());
1520 }
1521 else {
0d969553 1522// If face is the correct part of BndFace : face is OK
7fd59977 1523 Prof = fac;
1524 }
1525 }
1526
1527 if (!BRepAlgo::IsValid(Prof)) {
0797d9d3 1528#ifdef OCCT_DEBUG
04232180 1529 if (trc) std::cout << " Invalid Face Profile" << std::endl;
7fd59977 1530#endif
1531 ProfileOK = Standard_False;
1532 return ProfileOK;
1533 }
1534 return ProfileOK;
1535}
1536//=======================================================================
1537//function : NoSlidingProfile
0d969553 1538//purpose : construction of the face profile in case of sliding
7fd59977 1539//=======================================================================
1540
1541Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof,
4e57c75e 1542 const Standard_Boolean RevolRib,
1543 const Standard_Real myTol,
1544 Standard_Integer& Concavite,
1545 const Handle(Geom_Plane)& myPln,
1546 const Standard_Real bnd,
1547 const TopoDS_Face& BndFace,
1548 const gp_Pnt& CheckPnt,
1549 const TopoDS_Face& ,//FirstFace,
1550 const TopoDS_Face& ,//LastFace,
1551 const TopoDS_Vertex& ,//FirstVertex,
1552 const TopoDS_Vertex& ,//LastVertex,
1553 const TopoDS_Edge& FirstEdge,
1554 const TopoDS_Edge& LastEdge,
1555 const Standard_Boolean OnFirstFace,
1556 const Standard_Boolean OnLastFace)
7fd59977 1557
1558{
0797d9d3 1559#ifdef OCCT_DEBUG
7fd59977 1560 Standard_Boolean trc = BRepFeat_GettraceFEAT();
04232180 1561 if (trc) std::cout << "BRepFeat_RibSlot::NoSlidingProfile" << std::endl;
7fd59977 1562#endif
1563 Standard_Boolean ProfileOK = Standard_True;
1564
4e57c75e 1565 Standard_Real l1, f1, f2, l2;//, p;
7fd59977 1566 TopoDS_Vertex theFV; theFV.Nullify();
1567 gp_Pnt theFirstpoint;
1568 TopoDS_Edge theLastEdge; theLastEdge.Nullify();
1569 gp_Pnt firstpoint, lastpoint;//, pp1, pp2;
1570 gp_Vec firstvect, lastvect;
1571 TopoDS_Wire w;
1572 BRep_Builder BB;
1573 BB.MakeWire(w);
1574 //gp_Pnt p1, p3;
1575 TopoDS_Edge FalseFirstEdge, FalseLastEdge, FalseOnlyOne;
1576
1577 Handle(Geom_Curve) FirstCurve = BRep_Tool::Curve(FirstEdge, f1, l1);
1578 Handle(Geom_Curve) LastCurve = BRep_Tool::Curve(LastEdge, f2, l2);
1579
1580 Handle(Geom_Line) firstln, lastln;
1581 FirstCurve->D1(f1, firstpoint, firstvect);
1582 lastln = new Geom_Line(firstpoint, -firstvect);
1583 LastCurve->D1(l2, lastpoint, lastvect);
1584 firstln = new Geom_Line(lastpoint, lastvect);
1585
1586 gp_Pnt Pt;
1587
1588 Handle(Geom2d_Curve) ln2d1 = GeomAPI::To2d(firstln, myPln->Pln());
1589 Handle(Geom2d_Curve) ln2d2 = GeomAPI::To2d(lastln, myPln->Pln());
1590
1591 Geom2dAPI_InterCurveCurve inter(ln2d1, ln2d2, Precision::Confusion());
1592
1593 Standard_Boolean TestOK = Standard_True;
1594 if (RevolRib) {
1595 gp_Dir d1, d2;
1596 d1 = firstln->Position().Direction();
1597 d2 = lastln->Position().Direction();
1598 if(d1.IsOpposite(d2, myTol)) {
1599 Standard_Real par1 = ElCLib::Parameter(firstln->Lin(), myFirstPnt);
1600 Standard_Real par2 = ElCLib::Parameter(lastln->Lin(), myLastPnt);
1601 if(par1 >= myTol || par2 >= myTol)
4e57c75e 1602 Concavite = 2; //parallel and concave
7fd59977 1603 }
1604 if(d1.IsEqual(d2, myTol)) {
1605 if(Concavite == 3) TestOK = Standard_False;
1606 }
1607 }
1608
1609 if(TestOK) {
1610 if(inter.NbPoints() > 0) {
1611 gp_Pnt2d P = inter.Point(1);
1612 myPln->D0(P.X(), P.Y(), Pt);
1613 Standard_Real par = IntPar(firstln, Pt);
1614 if(par>0) Concavite = 1; //concave
1615 }
1616 }
1617
0d969553 1618// ---Construction of the face profile
7fd59977 1619 if(Concavite == 3) {
1620 if(OnFirstFace) {
1621 Standard_Real f, l;
1622 FalseFirstEdge = FirstEdge;
1623 EdgeExtention(FalseFirstEdge, bnd, Standard_True);
1624 const TopoDS_Vertex& vv1 = TopExp::FirstVertex(FalseFirstEdge,Standard_True);
1625 firstpoint = BRep_Tool::Pnt(vv1);
1626 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseFirstEdge, f, l);
1627 cc->D1(f, firstpoint, firstvect);
1628 lastln = new Geom_Line(firstpoint, -firstvect);
4e57c75e 1629 if(FirstEdge.IsSame(LastEdge)) FalseOnlyOne = FalseFirstEdge;
7fd59977 1630 ln2d2 = GeomAPI::To2d(lastln, myPln->Pln());
1631 }
1632 if(OnLastFace) {
1633 Standard_Real f, l;
1634 if(!FirstEdge.IsSame(LastEdge)) {
4e57c75e 1635 FalseLastEdge = LastEdge;
7fd59977 1636 }
1637 else {
4e57c75e 1638 if(FalseOnlyOne.IsNull()) FalseOnlyOne = LastEdge;
1639 FalseLastEdge = FalseOnlyOne;
7fd59977 1640 }
1641 EdgeExtention(FalseLastEdge, bnd, Standard_False);
1642 if(FirstEdge.IsSame(LastEdge)) {
4e57c75e 1643 FalseOnlyOne = FalseLastEdge;
7fd59977 1644 }
1645 const TopoDS_Vertex& vv2 = TopExp::LastVertex(FalseLastEdge,Standard_True);
1646 lastpoint = BRep_Tool::Pnt(vv2);
1647 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseLastEdge, f, l);
1648 cc->D1(l, lastpoint, lastvect);
1649 lastpoint = BRep_Tool::Pnt(vv2);
1650 firstln = new Geom_Line(lastpoint, lastvect);
1651 ln2d1 = GeomAPI::To2d(firstln, myPln->Pln());
1652 }
1653
1654 TopoDS_Edge BndEdge1, BndEdge2;
1655 gp_Pnt BndPnt1, BndPnt2, LastPnt;
1656 TopExp_Explorer expl;
1657 expl.Init(BndFace, TopAbs_WIRE);
1658 BRepTools_WireExplorer explo;
1659 TopoDS_Wire BndWire = TopoDS::Wire(expl.Current());
1660 explo.Init(BndWire);
1661 for(; explo.More(); explo.Next()) {
1662 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1663 Standard_Real first, last;
1664 Handle(Geom_Curve) c = BRep_Tool::Curve(e, first, last);
1665 Handle(Geom2d_Curve) c2d = GeomAPI::To2d(c, myPln->Pln());
1666 Geom2dAPI_InterCurveCurve intcln1(ln2d1, c2d,
4e57c75e 1667 Precision::Confusion());
7fd59977 1668 if(intcln1.NbPoints() > 0) {
4e57c75e 1669 gp_Pnt2d p2d = intcln1.Point(1);
1670 gp_Pnt p;
1671 myPln->D0(p2d.X(), p2d.Y(), p);
1672 Standard_Real parl = IntPar(firstln, p);
1673 Standard_Real parc = IntPar(c, p);
1674 if(parc >= first && parc <= last && parl >= 0) {
1675 BndEdge1 = e;
1676 BndPnt1 = p;
1677 }
7fd59977 1678 }
1679
1680 Geom2dAPI_InterCurveCurve intcln2(ln2d2, c2d,
4e57c75e 1681 Precision::Confusion());
7fd59977 1682 if(intcln2.NbPoints() > 0) {
4e57c75e 1683 gp_Pnt2d p2d = intcln2.Point(1);
1684 gp_Pnt p;
1685 myPln->D0(p2d.X(), p2d.Y(), p);
1686 Standard_Real parl = IntPar(lastln, p);
1687 Standard_Real parc = IntPar(c, p);
1688 if(parc >= first && parc <= last && parl >= 0) {
1689 BndEdge2 = e;
1690 BndPnt2 = p;
1691 }
7fd59977 1692 }
1693 if(!BndEdge1.IsNull() && !BndEdge2.IsNull()) break;
1694 }
1695
1696 if(BndEdge1.IsNull() || BndEdge2.IsNull()) {
0797d9d3 1697#ifdef OCCT_DEBUG
04232180 1698 if (trc) std::cout << " Null bounding edge" << std::endl;
7fd59977 1699#endif
1700 ProfileOK = Standard_False;
1701 return ProfileOK;
1702 }
1703
1704 TopoDS_Edge ee1;
1705 if(theLastEdge.IsNull()) {
1706 BRepLib_MakeEdge e1(lastpoint, BndPnt1);
1707 ee1 = TopoDS::Edge(e1.Shape());
1708 }
1709 else {
1710 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1711 BRepLib_MakeVertex v2(BndPnt1);
1712 BRepLib_MakeEdge e1(v1, v2);
1713 ee1 = TopoDS::Edge(e1.Shape());
1714 }
1715 BB.Add(w, ee1);
1716 theLastEdge = ee1;
1717 if(theFV.IsNull()) {
1718 theFV = TopExp::FirstVertex(ee1,Standard_True);
1719 theFirstpoint = BRep_Tool::Pnt(theFV);
1720 }
1721
1722 if(BndEdge1.IsSame(BndEdge2)) {
1723 TopoDS_Edge ee2, ee3;
1724 if(theLastEdge.IsNull()) {
4e57c75e 1725 BRepLib_MakeEdge e2(BndPnt1, BndPnt2);
1726 ee2 = TopoDS::Edge(e2.Shape());
7fd59977 1727 }
1728 else {
4e57c75e 1729 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1730 BRepLib_MakeVertex v2(BndPnt2);
1731 BRepLib_MakeEdge e2(v1, v2);
1732 ee2 = TopoDS::Edge(e2.Shape());
7fd59977 1733 }
1734 BB.Add(w, ee2);
1735 theLastEdge = ee2;
1736 if(theFV.IsNull()) {
4e57c75e 1737 theFV = TopExp::FirstVertex(ee2,Standard_True);
1738 theFirstpoint = BRep_Tool::Pnt(theFV);
7fd59977 1739 }
1740 if(theLastEdge.IsNull()) {
4e57c75e 1741 BRepLib_MakeEdge e3(BndPnt2, firstpoint);
1742 ee3 = TopoDS::Edge(e3.Shape());
7fd59977 1743 }
1744 else {
4e57c75e 1745 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1746 BRepLib_MakeVertex v2(firstpoint);
1747 BRepLib_MakeEdge e3(v1, v2);
1748 ee3 = TopoDS::Edge(e3.Shape());
7fd59977 1749 }
4e57c75e 1750 BB.Add(w, ee3);
7fd59977 1751 theLastEdge = ee3;
1752 if(theFV.IsNull()) {
4e57c75e 1753 theFV = TopExp::FirstVertex(ee3,Standard_True);
1754 theFirstpoint = BRep_Tool::Pnt(theFV);
7fd59977 1755 }
1756 }
1757 else {
1758 explo.Init(BndWire);
1759 for(; explo.More(); explo.Next()) {
4e57c75e 1760 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1761 if(e.IsSame(BndEdge1)) {
1762 gp_Pnt pp;
1763 pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True));
1764 if(pp.Distance(BndPnt1) > BRep_Tool::Tolerance(e)) {
1765 LastPnt = pp;
1766 }
1767 TopoDS_Edge eee;
1768 if(theLastEdge.IsNull()) {
1769 BRepLib_MakeEdge e2(BndPnt1, LastPnt);
1770 eee = TopoDS::Edge(e2.Shape());
1771 }
1772 else {
1773 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1774 BRepLib_MakeVertex v2(LastPnt);
1775 BRepLib_MakeEdge e2(v1, v2);
1776 eee = TopoDS::Edge(e2.Shape());
1777 }
1778 BB.Add(w, eee);
1779 theLastEdge = eee;
1780 if(theFV.IsNull()) {
1781 theFV = TopExp::FirstVertex(eee,Standard_True);
1782 theFirstpoint = BRep_Tool::Pnt(theFV);
1783 }
1784 break;
1785 }
7fd59977 1786 }
1787
1788 if(explo.More()) {
4e57c75e 1789 explo.Next();
1790 if(explo.Current().IsNull()) explo.Init(BndWire);
7fd59977 1791 }
1792 else explo.Init(BndWire);
1793 Standard_Boolean Fin = Standard_False;
1794 while(!Fin) {
4e57c75e 1795 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1796 if(!e.IsSame(BndEdge2)) {
1797 gp_Pnt pp;
1798 pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True));
1799 TopoDS_Edge eee1;
1800 if(theLastEdge.IsNull()) {
1801 BRepLib_MakeEdge ee(LastPnt, pp);
1802 eee1 = TopoDS::Edge(ee.Shape());
1803 }
1804 else {
1805 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1806 BRepLib_MakeVertex v2(pp);
1807 BRepLib_MakeEdge ee(v1, v2);
1808 eee1 = TopoDS::Edge(ee.Shape());
1809 }
1810 BB.Add(w, eee1);
1811 theLastEdge = eee1;
1812 if(theFV.IsNull()) {
1813 theFV = TopExp::FirstVertex(eee1,Standard_True);
1814 theFirstpoint = BRep_Tool::Pnt(theFV);
1815 }
1816 LastPnt = pp;
1817 }
1818 else {
1819 Fin = Standard_True;
1820 TopoDS_Edge eee2;
1821 if(theLastEdge.IsNull()) {
1822 BRepLib_MakeEdge ee(LastPnt, BndPnt2);
1823 eee2 = TopoDS::Edge(ee.Shape());
1824 }
1825 else {
1826 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1827 BRepLib_MakeVertex v2(BndPnt2);
1828 BRepLib_MakeEdge ee(v1, v2);
1829 eee2 = TopoDS::Edge(ee.Shape());
1830 }
1831 BB.Add(w, eee2);
1832 theLastEdge = eee2;
1833 if(theFV.IsNull()) {
1834 theFV = TopExp::FirstVertex(eee2,Standard_True);
1835 theFirstpoint = BRep_Tool::Pnt(theFV);
1836 }
1837 LastPnt = BndPnt2;
1838 }
1839 if(explo.More()) {
1840 explo.Next();
1841 if(explo.Current().IsNull()) {
1842 explo.Init(BndWire);
1843 }
1844 }
1845 else explo.Init(BndWire);
7fd59977 1846 }
1847
1848 TopoDS_Edge eee3;
1849 if(theLastEdge.IsNull()) {
4e57c75e 1850 BRepLib_MakeEdge e3(BndPnt2, firstpoint);
1851 eee3 = TopoDS::Edge(e3.Shape());
7fd59977 1852 }
1853 else {
4e57c75e 1854 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1855 BRepLib_MakeVertex v2(firstpoint);
1856 BRepLib_MakeEdge e3(v1, v2);
1857 eee3 = TopoDS::Edge(e3.Shape());
7fd59977 1858 }
1859 BB.Add(w, eee3);
1860 theLastEdge = eee3;
1861 if(theFV.IsNull()) {
4e57c75e 1862 theFV = TopExp::FirstVertex(eee3,Standard_True);
1863 theFirstpoint = BRep_Tool::Pnt(theFV);
7fd59977 1864 }
1865 }
1866 }
1867
1868 if(Concavite == 1) {
1869 TopoDS_Edge eee4;
1870 if(theLastEdge.IsNull()) {
1871 BRepLib_MakeEdge e(Pt, firstpoint);
1872 eee4 = TopoDS::Edge(e.Shape());
1873 }
1874 else {
1875 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1876 BRepLib_MakeVertex v2(firstpoint);
1877 BRepLib_MakeEdge e(v1, v2);
1878 eee4 = TopoDS::Edge(e.Shape());
1879 }
1880 BB.Add(w, eee4);
1881 if(theFV.IsNull()) {
1882 theFV = TopExp::FirstVertex(eee4,Standard_True);
1883 theFirstpoint = BRep_Tool::Pnt(theFV);
1884 }
1885 theLastEdge = eee4;
1886 }
1887
1888
1889 if(FirstEdge.IsSame(LastEdge)) {
1890 if(!myLFMap.IsBound(FirstEdge)) {
1891 TopTools_ListOfShape thelist;
1892 myLFMap.Bind(FirstEdge, thelist);
1893 }
1894 if(OnFirstFace || OnLastFace) {
1895 TopoDS_Edge theEdge;
1896 Standard_Real f, l;
1897 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseOnlyOne, f, l);
1898 if(!theLastEdge.IsNull()) {
4e57c75e 1899 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1900 TopoDS_Vertex v2;
1901 const gp_Pnt& pp = BRep_Tool::
1902 Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True));
1903 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
1904 v2 = theFV;
1905 }
1906 else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True);
1907 BRepLib_MakeEdge e(cc, v1, v2);
1908 theEdge = TopoDS::Edge(e.Shape());
7fd59977 1909 }
1910 else {
4e57c75e 1911 const TopoDS_Vertex& v1 = TopExp::FirstVertex(FalseOnlyOne,Standard_True);
1912 TopoDS_Vertex v2;
1913 const gp_Pnt& pp = BRep_Tool::
1914 Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True));
1915 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
1916 v2 = theFV;
1917 }
1918 else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True);
1919 BRepLib_MakeEdge e(cc, v1, v2);
1920 theEdge = TopoDS::Edge(e.Shape());
7fd59977 1921 }
1922 myLFMap(FirstEdge).Append(theEdge);
1923 BB.Add(w, theEdge);
1924 if(theFV.IsNull()) theFV = TopExp::FirstVertex(theEdge,Standard_True);
1925 theLastEdge = theEdge;
1926 }
1927 else {
1928 Standard_Real f, l;
1929 Handle(Geom_Curve) cc = BRep_Tool::Curve(FirstEdge, f, l);
1930 TopoDS_Edge theEdge;
1931 if(!theLastEdge.IsNull()) {
4e57c75e 1932 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1933 TopoDS_Vertex v2;
0d969553 1934// Attention case Wire Reversed -> LastVertex without Standard_True
4e57c75e 1935 const gp_Pnt& pp = BRep_Tool::Pnt(TopExp::LastVertex(FirstEdge));
1936 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
1937 v2 = theFV;
1938 }
1939 else v2 = TopExp::LastVertex(FirstEdge);
1940 BRepLib_MakeEdge e(cc, v1, v2);
1941 theEdge = TopoDS::Edge(e.Shape());
7fd59977 1942 }
1943 else {
4e57c75e 1944 const TopoDS_Vertex& v1 = TopExp::FirstVertex(FirstEdge,Standard_True);
1945 TopoDS_Vertex v2;
1946 const gp_Pnt& pp = BRep_Tool::
1947 Pnt(TopExp::LastVertex(FirstEdge,Standard_True));
1948 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
1949 v2 = theFV;
1950 }
1951 else v2 = TopExp::LastVertex(FirstEdge,Standard_True);
1952 BRepLib_MakeEdge e(cc, v1, v2);
1953 theEdge = TopoDS::Edge(e.Shape());
7fd59977 1954 }
1955 myLFMap(FirstEdge).Append(theEdge);
1956 BB.Add(w, theEdge);
1957 if(theFV.IsNull()) theFV = TopExp::FirstVertex(theEdge,Standard_True);
1958 theLastEdge = theEdge;
1959 }
1960 }
1961 else {
1962 if(!myLFMap.IsBound(FirstEdge)) {
1963 TopTools_ListOfShape thelist1;
1964 myLFMap.Bind(FirstEdge, thelist1);
1965 }
1966 if(!OnFirstFace) {
1967 TopoDS_Edge theEdge;
1968 Standard_Real f, l;
1969 Handle(Geom_Curve) cc = BRep_Tool::Curve(FirstEdge, f, l);
1970 if(!theLastEdge.IsNull()) {
4e57c75e 1971 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1972 const TopoDS_Vertex& v2 = TopExp::LastVertex(FirstEdge,Standard_True);
1973 BRepLib_MakeEdge e(cc, v1, v2);
1974 theEdge = TopoDS::Edge(e.Shape());
7fd59977 1975 }
1976 else {
4e57c75e 1977 theEdge = FirstEdge;
7fd59977 1978 }
1979 myLFMap(FirstEdge).Append(theEdge);
1980 BB.Add(w, theEdge);
1981 if(theFV.IsNull()) theFV = TopExp::FirstVertex(theEdge,Standard_True);
1982 theLastEdge = theEdge;
1983 }
1984 else {
1985 TopoDS_Edge theEdge;
1986 Standard_Real f, l;
1987 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseFirstEdge, f, l);
1988 if(!theLastEdge.IsNull()) {
4e57c75e 1989 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1990 const TopoDS_Vertex& v2 = TopExp::LastVertex(FalseFirstEdge,Standard_True);
1991 BRepLib_MakeEdge e(cc, v1, v2);
1992 theEdge = TopoDS::Edge(e.Shape());
7fd59977 1993 }
1994 else {
4e57c75e 1995 theEdge = FalseFirstEdge;
7fd59977 1996 }
1997 myLFMap(FirstEdge).Append(theEdge);
1998 BB.Add(w, theEdge);
1999 if(theFV.IsNull()) theFV = TopExp::FirstVertex(theEdge,Standard_True);
2000 theLastEdge = theEdge;
2001 }
2002
2003 BRepTools_WireExplorer ex(myWire);
2004 for(; ex.More(); ex.Next()) {
2005 const TopoDS_Edge& E = ex.Current();
2006 if(E.IsSame(FirstEdge)) break;
2007 }
2008
2009 ex.Next();
2010
2011 for(; ex.More(); ex.Next()) {
2012 const TopoDS_Edge& E = ex.Current();
2013 if(!E.IsSame(LastEdge)) {
4e57c75e 2014 if(!myLFMap.IsBound(E)) {
7fd59977 2015 TopTools_ListOfShape thelist2;
4e57c75e 2016 myLFMap.Bind(E, thelist2);
2017 }
2018 TopoDS_Edge eee;
2019 Standard_Real f, l;
2020 Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l);
2021 if(!theLastEdge.IsNull()) {
2022 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2023 const TopoDS_Vertex& v2 = TopExp::LastVertex(E,Standard_True);
2024 BRepLib_MakeEdge e(cc, v1, v2);
2025 eee = TopoDS::Edge(e.Shape());
2026 }
2027 else {
2028 eee = E;
2029 }
2030 myLFMap(E).Append(eee);
2031 BB.Add(w, eee);
2032 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True);
2033 theLastEdge = eee;
7fd59977 2034 }
2035 else break;
2036 }
2037
2038
2039 if(!OnLastFace) {
2040 if(!FirstEdge.IsSame(LastEdge)) {
4e57c75e 2041 const TopoDS_Edge& edg = TopoDS::Edge(ex.Current());
2042 if(!myLFMap.IsBound(edg)) {
7fd59977 2043 TopTools_ListOfShape thelist3;
4e57c75e 2044 myLFMap.Bind(edg, thelist3);
2045 }
2046 TopoDS_Edge eee;
2047 Standard_Real f, l;
2048 Handle(Geom_Curve) cc = BRep_Tool::Curve(edg, f, l);
2049 if(!theLastEdge.IsNull()) {
2050 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2051 TopoDS_Vertex v2;
2052 const gp_Pnt& pp = BRep_Tool::
2053 Pnt(TopExp::LastVertex(edg,Standard_True));
2054 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2055 v2 = theFV;
2056 }
2057 else v2 = TopExp::LastVertex(edg,Standard_True);
2058 BRepLib_MakeEdge e(cc, v1, v2);
2059 eee = TopoDS::Edge(e.Shape());
2060 }
2061 else {
2062 const TopoDS_Vertex& v1 = TopExp::FirstVertex(edg,Standard_True);
2063 TopoDS_Vertex v2;
2064 const gp_Pnt& pp = BRep_Tool::
2065 Pnt(TopExp::LastVertex(edg,Standard_True));
2066 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2067 v2 = theFV;
2068 }
2069 else v2 = TopExp::LastVertex(edg,Standard_True);
2070 BRepLib_MakeEdge e(cc, v1, v2);
2071 eee = TopoDS::Edge(e.Shape());
2072 }
2073 myLFMap(edg).Append(eee);
2074 BB.Add(w, eee);
2075 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True);
2076 theLastEdge = eee;
7fd59977 2077 }
2078 else {
4e57c75e 2079 TopoDS_Edge eee;
2080 Standard_Real f, l;
2081 if(!myLFMap.IsBound(LastEdge)) {
7fd59977 2082 TopTools_ListOfShape thelist4;
4e57c75e 2083 myLFMap.Bind(LastEdge, thelist4);
2084 }
2085 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseOnlyOne, f, l);
2086 if(!theLastEdge.IsNull()) {
2087 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2088 TopoDS_Vertex v2;
2089 const gp_Pnt& pp = BRep_Tool::
2090 Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True));
2091 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2092 v2 = theFV;
2093 }
2094 else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True);
2095 BRepLib_MakeEdge e(cc, v1, v2);
2096 eee = TopoDS::Edge(e.Shape());
2097 }
2098 else {
2099 const TopoDS_Vertex& v1 = TopExp::FirstVertex(FalseOnlyOne,Standard_True);
2100 TopoDS_Vertex v2;
2101 const gp_Pnt& pp = BRep_Tool::
2102 Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True));
2103 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2104 v2 = theFV;
2105 }
2106 else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True);
2107 BRepLib_MakeEdge e(cc, v1, v2);
2108 eee = TopoDS::Edge(e.Shape());
2109 }
2110 myLFMap(LastEdge).Append(eee);
2111 BB.Add(w, eee);
2112 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True);
2113 theLastEdge = eee;
7fd59977 2114 }
2115 }
2116 else {
2117 TopoDS_Edge eee;
2118 Standard_Real f, l;
2119 if(!myLFMap.IsBound(LastEdge)) {
2120 TopTools_ListOfShape thelist5;
4e57c75e 2121 myLFMap.Bind(LastEdge, thelist5);
7fd59977 2122 }
2123 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseLastEdge, f, l);
2124 if(!theLastEdge.IsNull()) {
4e57c75e 2125 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2126 TopoDS_Vertex v2;
2127 const gp_Pnt& pp = BRep_Tool::
2128 Pnt(TopExp::LastVertex(FalseLastEdge,Standard_True));
2129 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2130 v2 = theFV;
2131 }
2132 else v2 = TopExp::LastVertex(FalseLastEdge,Standard_True);
2133 BRepLib_MakeEdge e(cc, v1, v2);
2134 eee = TopoDS::Edge(e.Shape());
2135 }
7fd59977 2136 else {
4e57c75e 2137 const TopoDS_Vertex& v1 = TopExp::FirstVertex(FalseLastEdge,Standard_True);
2138 TopoDS_Vertex v2;
2139 const gp_Pnt& pp = BRep_Tool::
2140 Pnt(TopExp::LastVertex(FalseLastEdge,Standard_True));
2141 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2142 v2 = theFV;
2143 }
2144 else v2 = TopExp::LastVertex(FalseLastEdge,Standard_True);
2145 BRepLib_MakeEdge e(cc, v1, v2);
2146 eee = TopoDS::Edge(e.Shape());
7fd59977 2147 }
2148 myLFMap(LastEdge).Append(eee);
2149 BB.Add(w, eee);
2150 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True);
2151 theLastEdge = eee;
2152 }
2153 }
2154
2155 if(Concavite == 1) {
2156 TopoDS_Edge eef;
4e57c75e 2157 if(theLastEdge.IsNull()) {
7fd59977 2158 BRepLib_MakeEdge ef(lastpoint, Pt);
2159 eef = TopoDS::Edge(ef.Shape());
2160 }
2161 else {
2162 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2163 BRepLib_MakeVertex vv(Pt);
2164 TopoDS_Vertex v2 = TopoDS::Vertex(vv.Shape());
2165 if(!theFV.IsNull() &&
4e57c75e 2166 Pt.Distance(theFirstpoint) <= myTol) v2 = theFV;
7fd59977 2167
2168 BRepLib_MakeEdge ef(v1, v2);
4e57c75e 2169 eef = TopoDS::Edge(ef.Shape());
7fd59977 2170 }
2171 BB.Add(w, eef);
2172 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eef,Standard_True);
2173 theLastEdge = eef;
2174 }
2175
2176 if(Concavite == 2) {
2177 BRepLib_MakeEdge ee(lastpoint, firstpoint);
2178 const TopoDS_Edge& e = ee.Edge();
2179 BB.Add(w, e);
2180 }
2181
ab860031 2182 w.Closed (BRep_Tool::IsClosed (w));
7fd59977 2183 BRepLib_MakeFace fa(myPln->Pln(), w, Standard_True);
2184 TopoDS_Face fac = TopoDS::Face(fa.Shape());
2185
2186 if (!BRepAlgo::IsValid(fac)) {
0797d9d3 2187#ifdef OCCT_DEBUG
04232180 2188 if (trc) std::cout << " Invalid Face" << std::endl;
7fd59977 2189#endif
2190 ProfileOK = Standard_False;
2191 return ProfileOK;
2192 }
2193
2194// if(!Concavite) {
2195 if(Concavite == 3) {
2196 BRepTopAdaptor_FClass2d Cl(fac, BRep_Tool::Tolerance(fac));
2197 Standard_Real u, v;
2198 ElSLib::Parameters(myPln->Pln(), CheckPnt, u, v);
2199 gp_Pnt2d checkpnt2d(u, v);
2200 if(Cl.Perform(checkpnt2d, Standard_True) == TopAbs_OUT) {
7fd59977 2201 BRepAlgoAPI_Cut c(BndFace, fac);
7fd59977 2202 TopExp_Explorer exp(c.Shape(), TopAbs_WIRE);
7fd59977 2203 UpdateDescendants(c, c.Shape(), Standard_False);
e45b5ff7 2204 const TopoDS_Wire& ww = TopoDS::Wire(exp.Current());
7fd59977 2205 BRepLib_MakeFace ff(ww);
2206 Prof = TopoDS::Face(ff.Shape());
2207 }
2208 else {
2209 Prof = fac;
2210 }
2211 }
2212 else {
2213 Prof = fac;
2214 }
2215
2216 if (!BRepAlgo::IsValid(Prof)) {
0797d9d3 2217#ifdef OCCT_DEBUG
04232180 2218 if (trc) std::cout << " Invalid Face Profile" << std::endl;
7fd59977 2219#endif
2220 ProfileOK = Standard_False;
2221 return ProfileOK;
2222 }
2223 return ProfileOK;
2224}
2225
7fd59977 2226//=======================================================================
2227//function : UpdateDescendants
2228//purpose :
2229//=======================================================================
2230 void BRepFeat_RibSlot::UpdateDescendants(const BRepAlgoAPI_BooleanOperation& aBOP,
4e57c75e 2231 const TopoDS_Shape& S,
2232 const Standard_Boolean SkipFace)
7fd59977 2233{
2234 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm;
2235 TopTools_ListIteratorOfListOfShape it,it2;
2236 TopTools_MapIteratorOfMapOfShape itm;
2237 TopExp_Explorer exp;
2238
2239 for (itdm.Initialize(myMap);itdm.More();itdm.Next()) {
2240 const TopoDS_Shape& orig = itdm.Key();
2241 if (SkipFace && orig.ShapeType() == TopAbs_FACE) {
2242 continue;
2243 }
2244 TopTools_MapOfShape newdsc;
2245
2246 //if (itdm.Value().IsEmpty()) {myMap.ChangeFind(orig).Append(orig);}
2247
2248 for (it.Initialize(itdm.Value());it.More();it.Next()) {
2249 const TopoDS_Shape& sh = it.Value();
2250 if(sh.ShapeType() != TopAbs_FACE) continue;
2251 const TopoDS_Face& fdsc = TopoDS::Face(it.Value());
2252 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
4e57c75e 2253 if (exp.Current().IsSame(fdsc)) { // preserved
2254 newdsc.Add(fdsc);
2255 break;
2256 }
7fd59977 2257 }
2258 if (!exp.More()) {
4e57c75e 2259 BRepAlgoAPI_BooleanOperation* pBOP=(BRepAlgoAPI_BooleanOperation*)&aBOP;
2260 const TopTools_ListOfShape& aLM=pBOP->Modified(fdsc);
2261 it2.Initialize(aLM);
2262 for (; it2.More(); it2.Next()) {
2263 const TopoDS_Shape& aS=it2.Value();
2264 newdsc.Add(aS);
2265 }
2266
7fd59977 2267 }
2268 }
2269 myMap.ChangeFind(orig).Clear();
2270 for (itm.Initialize(newdsc); itm.More(); itm.Next()) {
0d969553 2271 // check the belonging to the shape...
7fd59977 2272 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
4e57c75e 2273 if (exp.Current().IsSame(itm.Key())) {
2274// const TopoDS_Shape& sh = itm.Key();
2275 myMap.ChangeFind(orig).Append(itm.Key());
2276 break;
2277 }
7fd59977 2278 }
2279 }
2280 }
2281}