1 // Created on: 1997-10-08
2 // Created by: Olga KOULECHOVA
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <BRepFeat_RibSlot.ixx>
18 #include <BRepFeat.hxx>
21 #include <LocOpe_Gluer.hxx>
22 #include <LocOpe_FindEdges.hxx>
23 #include <LocOpe_CSIntersector.hxx>
24 #include <LocOpe_PntFace.hxx>
28 #include <TopExp_Explorer.hxx>
32 #include <TopoDS_Shape.hxx>
33 #include <TopoDS_Face.hxx>
35 #include <TopTools_ListOfShape.hxx>
36 #include <TopTools_ListIteratorOfListOfShape.hxx>
37 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
38 #include <TopTools_MapIteratorOfMapOfShape.hxx>
39 #include <TopTools_MapOfShape.hxx>
40 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
42 #include <TopOpeBRepBuild_HBuilder.hxx>
44 #include <BRep_Tool.hxx>
46 #include <BRepAlgo.hxx>
47 //modified by NIZNHY-PKV Fri Mar 22 16:48:13 2002 f
48 //#include <BRepAlgo_Cut.hxx>
49 //#include <BRepAlgo_Fuse.hxx>
50 #include <BRepAlgoAPI_Cut.hxx>
51 #include <BRepAlgoAPI_Fuse.hxx>
52 //modified by NIZNHY-PKV Fri Mar 22 16:48:16 2002 t
54 #include <BRepAdaptor_Surface.hxx>
55 #include <BRepBndLib.hxx>
56 #include <BRepIntCurveSurface_Inter.hxx>
57 #include <BRepTools_WireExplorer.hxx>
58 #include <BRepTopAdaptor_FClass2d.hxx>
59 #include <BRepClass3d_SolidClassifier.hxx>
61 #include <BRepLib_MakeVertex.hxx>
62 #include <BRepLib_MakeEdge.hxx>
63 #include <BRepLib_MakeWire.hxx>
64 #include <BRepLib_MakeFace.hxx>
65 #include <BRepLib.hxx>
67 #include <Bnd_Box.hxx>
69 #include <Standard_ConstructionError.hxx>
70 #include <Standard_NoSuchObject.hxx>
72 #include <GeomLib.hxx>
73 #include <GeomAdaptor_Curve.hxx>
75 #include <Geom_Curve.hxx>
76 #include <Geom_TrimmedCurve.hxx>
77 #include <Geom_Line.hxx>
78 #include <Geom_Circle.hxx>
79 #include <Geom_Plane.hxx>
80 #include <Geom_Ellipse.hxx>
81 #include <Geom_Parabola.hxx>
82 #include <Geom_Hyperbola.hxx>
84 #include <Geom2dAPI_InterCurveCurve.hxx>
85 #include <GeomAPI.hxx>
86 #include <GeomAPI_ProjectPointOnCurve.hxx>
99 #include <Precision.hxx>
101 #include <TColGeom_SequenceOfCurve.hxx>
102 #include <BRepFeat_Builder.hxx>
106 extern Standard_Boolean BRepFeat_GettraceFEAT();
107 extern Standard_Boolean BRepFeat_GettraceFEATRIB();
110 //=======================================================================
111 //function : LFPerform
112 //purpose : topological reconstruction of ribs
113 //=======================================================================
115 void BRepFeat_RibSlot::LFPerform()
118 Standard_Boolean trc = BRepFeat_GettraceFEAT();
119 if (trc) cout << "BRepFeat_RibSlot::LFPerform()" << endl;
121 if (mySbase.IsNull() || myPbase.IsNull() || mySkface.IsNull()
122 || myGShape.IsNull() || myLFMap.IsEmpty()) {
124 cout << "Topological reconstruction is impossible" << endl;
125 if (trc) cout << " Fields not initialized" << endl;
127 myStatusError = BRepFeat_NotInitialized;
132 TopExp_Explorer exp,exp2;
133 Standard_Integer theOpe = 2;
135 if (!myGluedF.IsEmpty()) {
139 // Hope that there is just a solid in the result
140 if (!mySUntil.IsNull()) {
141 for (exp2.Init(mySUntil,TopAbs_FACE); exp2.More(); exp2.Next()) {
142 const TopoDS_Shape& funtil = exp2.Current();
143 for (exp.Init(mySbase,TopAbs_FACE); exp.More(); exp.Next()) {
144 if (exp.Current().IsSame(funtil)) {
154 TopTools_ListIteratorOfListOfShape it,it2;
155 TopTools_DataMapIteratorOfDataMapOfShapeShape itm;
156 //Standard_Integer sens = 0;
158 LocOpe_Gluer theGlue;
163 Standard_Boolean Collage = Standard_True;
165 LocOpe_FindEdges theFE;
166 TopTools_DataMapOfShapeListOfShape locmap;
167 theGlue.Init(mySbase,myGShape);
168 for (itm.Initialize(myGluedF); itm.More();itm.Next()) {
169 const TopoDS_Face& glface = TopoDS::Face(itm.Key());
170 const TopoDS_Face& fac = TopoDS::Face(myGluedF(glface));
171 for (exp.Init(myGShape,TopAbs_FACE); exp.More(); exp.Next()) {
172 if (exp.Current().IsSame(glface)) {
177 Collage = BRepFeat::IsInside(glface, fac);
183 theGlue.Bind(glface, fac);
184 theFE.Set(glface, fac);
185 for (theFE.InitIterator(); theFE.More();theFE.Next()) {
186 theGlue.Bind(theFE.EdgeFrom(),theFE.EdgeTo());
192 LocOpe_Operation ope = theGlue.OpeType();
193 if (ope == LocOpe_INVALID ||
194 (myFuse && ope != LocOpe_FUSE) ||
195 (!myFuse && ope != LocOpe_CUT) ||
199 cout << "Passage to topological operations" << endl;
204 // gluing is always applicable
208 if (theGlue.IsDone()) {
209 UpdateDescendants(theGlue);
210 myNewEdges = theGlue.Edges();
211 myTgtEdges = theGlue.TgtEdges();
214 myShape = theGlue.ResultingShape();
215 BRepLib::SameParameter(myShape, 1.e-7, Standard_True);
220 cout << "Passage to topologic operation" << endl;
225 // case without gluing
227 BRepFeat_Builder theBuilder;
228 TopTools_ListOfShape partsoftool;
229 BRepClass3d_SolidClassifier oussa;
230 Standard_Boolean bFlag;
231 TopTools_ListIteratorOfListOfShape aIt;
233 bFlag = (myPerfSelection == BRepFeat_NoSelection) ? 0 : 1;
235 theBuilder.Init(mySbase, myGShape);
236 theBuilder.SetOperation(myFuse, bFlag);
238 theBuilder.Perform();
240 theBuilder.PartsOfTool(partsoftool);
241 aIt.Initialize(partsoftool);
242 if (aIt.More() && myPerfSelection != BRepFeat_NoSelection) {
243 Standard_Real toler = (BRep_Tool::Tolerance(myPbase))*2;
245 for(; aIt.More(); aIt.Next()) {
246 oussa.Load(aIt.Value());
247 oussa.Perform(myFirstPnt, toler);
248 TopAbs_State sp1=oussa.State();
249 oussa.Perform(myLastPnt, toler);
250 TopAbs_State sp2=oussa.State();
251 if (!(sp1 == TopAbs_OUT || sp2 == TopAbs_OUT)) {
252 const TopoDS_Shape& S = aIt.Value();
253 theBuilder.KeepPart(S);
258 theBuilder.PerformResult();
259 myShape = theBuilder.Shape();
261 myShape = theBuilder.Shape();
267 //=======================================================================
268 //function : IsDeleted
270 //=======================================================================
272 Standard_Boolean BRepFeat_RibSlot::IsDeleted(const TopoDS_Shape& F)
274 return (myMap(F).IsEmpty());
278 //=======================================================================
279 //function : Modified
281 //=======================================================================
283 const TopTools_ListOfShape& BRepFeat_RibSlot::Modified
284 (const TopoDS_Shape& F)
287 Standard_Boolean trc = BRepFeat_GettraceFEAT();
288 if (trc) cout << "BRepFeat_RibSlot::Modified" << endl;
290 if (myMap.IsBound(F)) {
291 static TopTools_ListOfShape list;
293 TopTools_ListIteratorOfListOfShape ite(myMap(F));
294 for(; ite.More(); ite.Next()) {
295 const TopoDS_Shape& sh = ite.Value();
301 return myGenerated; // empty list
304 //=======================================================================
305 //function : Generated
307 //=======================================================================
309 const TopTools_ListOfShape& BRepFeat_RibSlot::Generated
310 (const TopoDS_Shape& S)
313 Standard_Boolean trc = BRepFeat_GettraceFEAT();
314 if (trc) cout << "BRepFeat_RibSlot::Generated" << endl;
316 if(S.ShapeType() != TopAbs_FACE) {
318 if(myLFMap.IsEmpty() || !myLFMap.IsBound(S)) {
319 if (myMap.IsBound(S)) { // check if filter on face or not
320 static TopTools_ListOfShape list;
322 TopTools_ListIteratorOfListOfShape ite(myMap(S));
323 for(; ite.More(); ite.Next()) {
324 const TopoDS_Shape& sh = ite.Value();
330 else return myGenerated;
334 TopTools_ListIteratorOfListOfShape it(myLFMap(S));
335 static TopTools_ListOfShape list;
337 for(; it.More(); it.Next()) {
338 if(myMap.IsBound(it.Value())) {
339 TopTools_ListIteratorOfListOfShape it1(myMap(it.Value()));
340 for(; it1.More(); it1.Next()) {
341 const TopoDS_Shape& sh = it1.Value();
350 else return myGenerated;
354 //=======================================================================
355 //function : UpdateDescendants
357 //=======================================================================
359 void BRepFeat_RibSlot::UpdateDescendants(const LocOpe_Gluer& G)
361 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm;
362 TopTools_ListIteratorOfListOfShape it,it2;
363 TopTools_MapIteratorOfMapOfShape itm;
365 for (itdm.Initialize(myMap);itdm.More();itdm.Next()) {
366 const TopoDS_Shape& orig = itdm.Key();
367 TopTools_MapOfShape newdsc;
368 for (it.Initialize(itdm.Value());it.More();it.Next()) {
369 const TopoDS_Face& fdsc = TopoDS::Face(it.Value());
370 for (it2.Initialize(G.DescendantFaces(fdsc));
371 it2.More();it2.Next()) {
372 newdsc.Add(it2.Value());
375 myMap.ChangeFind(orig).Clear();
376 for (itm.Initialize(newdsc);itm.More();itm.Next()) {
377 myMap.ChangeFind(orig).Append(itm.Key());
382 //=======================================================================
383 //function : UpdateDescendants
385 //=======================================================================
386 void BRepFeat_RibSlot::UpdateDescendants (const Handle(TopOpeBRepBuild_HBuilder)& B,
387 const TopoDS_Shape& S,
388 const Standard_Boolean SkipFace)
390 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm;
391 TopTools_ListIteratorOfListOfShape it,it2;
392 TopTools_MapIteratorOfMapOfShape itm;
395 for (itdm.Initialize(myMap);itdm.More();itdm.Next()) {
396 const TopoDS_Shape& orig = itdm.Key();
397 if (SkipFace && orig.ShapeType() == TopAbs_FACE) {
400 TopTools_MapOfShape newdsc;
401 for (it.Initialize(itdm.Value());it.More();it.Next()) {
402 const TopoDS_Shape& sh = it.Value();
403 if(sh.ShapeType() != TopAbs_FACE) continue;
404 const TopoDS_Face& fdsc = TopoDS::Face(it.Value());
405 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
406 if (exp.Current().IsSame(fdsc)) { // preserved
412 if (B->IsSplit(fdsc, TopAbs_OUT)) {
413 for (it2.Initialize(B->Splits(fdsc,TopAbs_OUT));
414 it2.More();it2.Next()) {
415 newdsc.Add(it2.Value());
418 if (B->IsSplit(fdsc, TopAbs_IN)) {
419 for (it2.Initialize(B->Splits(fdsc,TopAbs_IN));
420 it2.More();it2.Next()) {
421 newdsc.Add(it2.Value());
424 if (B->IsSplit(fdsc, TopAbs_ON)) {
425 for (it2.Initialize(B->Splits(fdsc,TopAbs_ON));
426 it2.More();it2.Next()) {
427 newdsc.Add(it2.Value());
430 if (B->IsMerged(fdsc, TopAbs_OUT)) {
431 for (it2.Initialize(B->Merged(fdsc,TopAbs_OUT));
432 it2.More();it2.Next()) {
433 newdsc.Add(it2.Value());
436 if (B->IsMerged(fdsc, TopAbs_IN)) {
437 for (it2.Initialize(B->Merged(fdsc,TopAbs_IN));
438 it2.More();it2.Next()) {
439 newdsc.Add(it2.Value());
442 if (B->IsMerged(fdsc, TopAbs_ON)) {
443 for (it2.Initialize(B->Merged(fdsc,TopAbs_ON));
444 it2.More();it2.Next()) {
445 newdsc.Add(it2.Value());
450 myMap.ChangeFind(orig).Clear();
451 for (itm.Initialize(newdsc); itm.More(); itm.Next()) {
452 // check the belonging to the shape...
453 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
454 if (exp.Current().IsSame(itm.Key())) {
455 myMap.ChangeFind(orig).Append(itm.Key());
465 //=======================================================================
466 //function : FirstShape
468 //=======================================================================
470 const TopTools_ListOfShape& BRepFeat_RibSlot::FirstShape() const
472 if (!myFShape.IsNull()) {
473 return myMap(myFShape);
475 return myGenerated; // empty list
479 //=======================================================================
480 //function : LastShape
482 //=======================================================================
484 const TopTools_ListOfShape& BRepFeat_RibSlot::LastShape() const
486 if (!myLShape.IsNull()) {
487 return myMap(myLShape);
489 return myGenerated; // empty list
492 //=======================================================================
493 //function : FacesForDraft
495 //=======================================================================
497 const TopTools_ListOfShape& BRepFeat_RibSlot::FacesForDraft() const
499 return myFacesForDraft;
503 //=======================================================================
504 //function : NewEdges
506 //=======================================================================
508 const TopTools_ListOfShape& BRepFeat_RibSlot::NewEdges() const
513 //=======================================================================
514 //function : TgtEdges
516 //=======================================================================
518 const TopTools_ListOfShape& BRepFeat_RibSlot::TgtEdges() const
524 //=======================================================================
525 //function : CurrentStatusError
527 //=======================================================================
529 BRepFeat_StatusError BRepFeat_RibSlot::CurrentStatusError() const
531 return myStatusError;
535 //=======================================================================
536 //function : CheckPoint
537 //purpose : Proofing point material side (side of extrusion)
538 //=======================================================================
540 gp_Pnt BRepFeat_RibSlot::CheckPoint(const TopoDS_Edge& e,
541 const Standard_Real ,//bnd,
542 const Handle(Geom_Plane)& Pln)
546 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
547 if (trc) cout << "BRepFeat_RibSlot::CheckPoint" << endl;
549 // Vector product : normal to plane X direction Wire
550 // -> gives the material side
551 // Proofing point somewhat inside the material side
553 Handle(Geom_Curve) cc = BRep_Tool::Curve(e, f, l);
555 gp_Vec tgt; gp_Pnt pp;
556 Standard_Real par = ( f + l) / 2.;
558 cc->D1(par, pp, tgt);
560 if ( e.Orientation() == TopAbs_REVERSED) tgt.Reverse();
562 gp_Vec D = -tgt.Crossed(Pln->Pln().Position().Direction())/10.;
570 //=======================================================================
572 //purpose : calculate the normal to a face in a point
573 //=======================================================================
575 gp_Dir BRepFeat_RibSlot::Normal(const TopoDS_Face& F,const gp_Pnt& P)
579 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
580 if (trc) cout << "BRepFeat_RibSlot::Normal" << endl;
585 BRepAdaptor_Surface AS(F, Standard_True);
587 switch ( AS.GetType()) {
590 ElSLib::Parameters(AS.Plane(),P,U,V); break;
592 case GeomAbs_Cylinder:
593 ElSLib::Parameters(AS.Cylinder(),P,U,V); break;
596 ElSLib::Parameters(AS.Cone(),P,U,V); break;
599 ElSLib::Parameters(AS.Torus(),P,U,V); break;
603 return gp_Dir(1., 0., 0.);
609 AS.D1(U, V, pt, D1U, D1V);
611 CSLib_DerivativeStatus St;
612 CSLib::Normal(D1U, D1V, Precision::Confusion(), St, N);
613 if(F.Orientation() == TopAbs_FORWARD) N.Reverse();
617 //=======================================================================
619 //purpose : calculate the parameter of a point on a curve
620 //=======================================================================
622 Standard_Real BRepFeat_RibSlot::IntPar(const Handle(Geom_Curve)& C,
626 if ( C.IsNull()) return 0.;
628 GeomAdaptor_Curve AC(C);
631 switch ( AC.GetType()) {
634 U = ElCLib::Parameter(AC.Line(),P); break;
637 U = ElCLib::Parameter(AC.Circle(),P); break;
639 case GeomAbs_Ellipse:
640 U = ElCLib::Parameter(AC.Ellipse(),P); break;
642 case GeomAbs_Hyperbola:
643 U = ElCLib::Parameter(AC.Hyperbola(),P); break;
645 case GeomAbs_Parabola:
646 U = ElCLib::Parameter(AC.Parabola(),P); break;
656 //=======================================================================
657 //function : EdgeExtention
658 //purpose : extention of a edge by tangence
659 //=======================================================================
661 void BRepFeat_RibSlot::EdgeExtention(TopoDS_Edge& e,
662 const Standard_Real bnd,
663 const Standard_Boolean FirstLast)
666 Standard_Boolean trc = BRepFeat_GettraceFEAT();
667 if (trc) cout << "BRepFeat_RibSlot::EdgeExtention" << endl;
670 Handle(Geom_Curve) cu = BRep_Tool::Curve(e, f, l);
671 Handle(Geom_TrimmedCurve) C =
672 new Geom_TrimmedCurve(cu, f, l);
676 if(cu->DynamicType() == STANDARD_TYPE(Geom_Line) ||
677 cu->DynamicType() == STANDARD_TYPE(Geom_Circle) ||
678 cu->DynamicType() == STANDARD_TYPE(Geom_Ellipse) ||
679 cu->DynamicType() == STANDARD_TYPE(Geom_Hyperbola) ||
680 cu->DynamicType() == STANDARD_TYPE(Geom_Parabola)) {
682 BRepLib_MakeEdge Edg(cu, f-bnd/10., l);
683 E = TopoDS::Edge(Edg.Shape());
686 BRepLib_MakeEdge Edg(cu, f, l+bnd/10.);
687 E = TopoDS::Edge(Edg.Shape());
691 Handle(Geom_Line) ln;
697 ln = new Geom_Line(pnt, -vct);
698 ln->D0(bnd/1000., Pt);
699 GeomLib::ExtendCurveToPoint(C, Pt, GeomAbs_G1, Standard_False);
700 BRepLib_MakeEdge Edg(C, Pt, BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True)));
701 E = TopoDS::Edge(Edg.Shape());
705 ln = new Geom_Line(pnt, vct);
706 ln->D0(bnd/1000., Pt);
707 GeomLib::ExtendCurveToPoint(C, Pt, GeomAbs_G1, Standard_True);
708 BRepLib_MakeEdge Edg(C, BRep_Tool::Pnt(TopExp::FirstVertex(e,Standard_True)), Pt);
709 E = TopoDS::Edge(Edg.Shape());
716 //=======================================================================
717 //function : ChoiceOfFaces
718 //purpose : choose face of support in case of support on an edge
719 //=======================================================================
721 TopoDS_Face BRepFeat_RibSlot::ChoiceOfFaces(TopTools_ListOfShape& faces,
722 const Handle(Geom_Curve)& cc,
723 const Standard_Real par,
724 const Standard_Real ,//bnd,
725 const Handle(Geom_Plane)& Pln)
729 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
730 if (trc) cout << "BRepFeat_RibSlot::ChoiceOfFaces" << endl;
737 cc->D1(par, pp, tgt);
739 Handle(Geom_Line) l1 = new Geom_Line(pp, tgt);
741 TColGeom_SequenceOfCurve scur;
742 Standard_Integer Counter = 0;
745 gp_Ax1 Axe(pp, Pln->Position().Direction());
746 for ( Standard_Integer i = 1; i <=8; i++) {
747 Handle(Geom_Curve) L =
748 Handle(Geom_Curve)::DownCast(l1->Rotated(Axe, i*M_PI/9.));
753 TopTools_ListIteratorOfListOfShape it;
754 it.Initialize(faces);
755 Standard_Real Par = RealLast();
756 for(; it.More(); it.Next()) {
757 const TopoDS_Face& f = TopoDS::Face(it.Value());
758 LocOpe_CSIntersector ASI(f);
760 if(!ASI.IsDone()) continue;
761 for(Standard_Integer jj = 1; jj<=Counter; jj++) {
762 if(ASI.NbPoints(jj) >= 1) {
763 Standard_Real app = ASI.Point(jj,1).Parameter();//modified by NIZNHY-PKV Fri Mar 22 17:05:23 2002 pp
764 if(app >= 0 && app < Par) {
776 //=======================================================================
777 //function : HeightMax
778 //purpose : Calculate the height of the prism following the parameters of a bounding box
779 //=======================================================================
781 Standard_Real BRepFeat_RibSlot::HeightMax(const TopoDS_Shape& theSbase,
782 const TopoDS_Shape& theSUntil,
787 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
788 if (trc) cout << "BRepFeat_RibSlot::HeightMax" << endl;
791 BRepBndLib::Add(theSbase,Box);
792 if(!theSUntil.IsNull()) {
793 BRepBndLib::Add(theSUntil,Box);
795 Standard_Real c[6], bnd;
796 Box.Get(c[0],c[2],c[4],c[1],c[3],c[5]);
798 for(Standard_Integer i = 0 ; i < 6; i++) {
799 if(c[i] > bnd) bnd = c[i];
801 p1.SetCoord(c[0]-2.*bnd, c[1]-2.*bnd, c[2]-2.*bnd);
802 p2.SetCoord(c[3]+2.*bnd, c[4]+2.*bnd, c[5]+2.*bnd);
806 //=======================================================================
807 //function : ExtremeFaces
808 //purpose : Calculate the base faces of the rib
809 //=======================================================================
811 Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib,
812 const Standard_Real bnd,
813 const Handle(Geom_Plane)& Pln,
814 TopoDS_Edge& FirstEdge,
815 TopoDS_Edge& LastEdge,
816 TopoDS_Face& FirstFace,
817 TopoDS_Face& LastFace,
818 TopoDS_Vertex& FirstVertex,
819 TopoDS_Vertex& LastVertex,
820 Standard_Boolean& OnFirstFace,
821 Standard_Boolean& OnLastFace,
822 Standard_Boolean& PtOnFirstEdge,
823 Standard_Boolean& PtOnLastEdge,
824 TopoDS_Edge& OnFirstEdge,
825 TopoDS_Edge& OnLastEdge)
829 Standard_Boolean trc = BRepFeat_GettraceFEAT();
830 if (trc) cout << "BRepFeat_RibSlot::ExtremeFaces" << endl;
832 Standard_Boolean Data = Standard_True;
837 PtOnFirstEdge = Standard_False;
838 PtOnLastEdge = Standard_False;
839 OnFirstEdge.Nullify();
840 OnLastEdge.Nullify();
842 BRepIntCurveSurface_Inter inter;
846 Standard_Boolean FirstOK = Standard_False, LastOK = Standard_False;
848 Standard_Integer NumberOfEdges = 0;
849 TopExp_Explorer exp(myWire, TopAbs_EDGE);
851 for(; exp.More(); exp.Next()) {
855 // ---the wire includes only one edge
856 if(NumberOfEdges == 1) {
858 if (trc) cout << " One Edge" << endl;
861 Standard_Real f, l;//, f1, l1, temp;
862 gp_Pnt firstpoint, lastpoint;
864 // Points limit the unique edge
865 const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
866 Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l);
867 gp_Pnt p1 = BRep_Tool::Pnt(TopExp::FirstVertex(E,Standard_True));
868 gp_Pnt p2 = BRep_Tool::Pnt(TopExp::LastVertex(E,Standard_True));
870 Standard_Real FirstPar = f; Standard_Real LastPar = l;
873 // ---Find if 2 points limiting the unique edge of the wire
874 // are on an edge or a vertex of the base shape
875 Standard_Boolean PtOnFirstVertex = Standard_False;
876 Standard_Boolean PtOnLastVertex = Standard_False;
877 TopoDS_Vertex OnFirstVertex, OnLastVertex;
878 PtOnEdgeVertex(RevolRib, mySbase, p1, FirstVertex, LastVertex,
879 PtOnFirstEdge, OnFirstEdge, PtOnFirstVertex, OnFirstVertex);
880 PtOnEdgeVertex(RevolRib, mySbase, p2, FirstVertex, LastVertex,
881 PtOnLastEdge, OnLastEdge, PtOnLastVertex, OnLastVertex);
883 TopTools_MapOfShape Map;
886 if (!PtOnFirstVertex) {
887 // Find FirstFace : face of the base shape containing OnFirstEdge
888 // meeting ChoiceOfFaces
889 TopExp_Explorer ex4, ex5;
890 ex4.Init(mySbase, TopAbs_FACE);
891 TopTools_ListOfShape faces;
894 for(; ex4.More(); ex4.Next()) {
895 const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:04 2002 fx instead f
896 if ( !Map.Add(fx)) continue;
897 ex5.Init(ex4.Current(), TopAbs_EDGE);
898 for(; ex5.More(); ex5.Next()) {
899 const TopoDS_Edge& ee = TopoDS::Edge(ex5.Current());
900 if(ee.IsSame(OnFirstEdge)) {
905 if(!faces.IsEmpty()) {
906 TopoDS_Face FFF = ChoiceOfFaces(faces, cc, FirstPar+bnd/50., bnd/50., Pln);
907 if(!FFF.IsNull()) FirstFace = FFF;
910 else if(PtOnFirstVertex) {
911 // Find FirstFace : face of the base shape containing OnFirstVertex
912 // meeting ChoiceOfFaces
913 TopExp_Explorer ex4, ex5;
914 ex4.Init(mySbase, TopAbs_FACE);
915 TopTools_ListOfShape faces;
918 for(; ex4.More(); ex4.Next()) {
919 const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:36 2002 fx instead of f
920 if ( !Map.Add(fx)) continue;
921 ex5.Init(ex4.Current(), TopAbs_VERTEX);
922 for(; ex5.More(); ex5.Next()) {
923 const TopoDS_Vertex& vv = TopoDS::Vertex(ex5.Current());
924 if(vv.IsSame(OnFirstVertex)) {
930 if(!faces.IsEmpty()) {
931 TopoDS_Face FFF = ChoiceOfFaces(faces, cc, FirstPar+bnd/50., bnd/50., Pln);
932 if(!FFF.IsNull()) FirstFace = FFF;
936 BRepLib_MakeVertex v(p1);
938 OnFirstFace = Standard_True;
942 if (!PtOnLastVertex) {
943 // Find LastFace : face of the base shape containing OnLastEdge
944 // meeting ChoiceOfFaces
945 TopExp_Explorer ex4, ex5;
946 ex4.Init(mySbase, TopAbs_FACE);
947 TopTools_ListOfShape faces;
950 for(; ex4.More(); ex4.Next()) {
951 const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:36 2002 fx instead of f
952 if ( !Map.Add(fx)) continue;
953 ex5.Init(ex4.Current(), TopAbs_EDGE);
954 for(; ex5.More(); ex5.Next()) {
955 const TopoDS_Edge& ee = TopoDS::Edge(ex5.Current());
956 if(ee.IsSame(OnLastEdge)) {
962 if(!faces.IsEmpty()) {
963 TopoDS_Face FFF = ChoiceOfFaces(faces, cc, LastPar-bnd/50., bnd/50., Pln);
964 if(!FFF.IsNull()) LastFace = FFF;
967 else if(PtOnLastEdge && PtOnLastVertex) {
968 // Find LastFace : face of the base shape containing OnLastVertex
969 // meeting ChoiceOfFaces
970 TopExp_Explorer ex4, ex5;
971 ex4.Init(mySbase, TopAbs_FACE);
972 TopTools_ListOfShape faces;
975 for(; ex4.More(); ex4.Next()) {
976 const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:36 2002 fx instead of f
977 if ( !Map.Add(fx)) continue;
978 ex5.Init(ex4.Current(), TopAbs_VERTEX);
979 for(; ex5.More(); ex5.Next()) {
980 const TopoDS_Vertex& vv = TopoDS::Vertex(ex5.Current());
981 if(vv.IsSame(OnLastVertex)) {
987 if(!faces.IsEmpty()) {
988 TopoDS_Face FFF = ChoiceOfFaces(faces, cc, LastPar-bnd/50., bnd/50., Pln);
989 if(!FFF.IsNull()) LastFace = FFF;
993 BRepLib_MakeVertex v(p2);
995 OnLastFace = Standard_True;
998 if(!FirstFace.IsNull() && !LastFace.IsNull()) {
999 return Standard_True;
1002 //--- FirstFace or LastFace was not found
1004 if (trc) cout << " FirstFace or LastFace null" << endl;
1006 LocOpe_CSIntersector ASI(mySbase);
1007 TColGeom_SequenceOfCurve scur;
1011 Standard_Real lastpar, firstpar;
1012 if(ASI.IsDone() && ASI.NbPoints(1) >= 2) {
1013 lastpar = ASI.Point(1, ASI.NbPoints(1)).Parameter();
1014 Standard_Integer lastindex = ASI.NbPoints(1);
1016 for(Standard_Integer jj=ASI.NbPoints(1)-1; jj>=1; jj--) {
1017 Standard_Real par = ASI.Point(1,jj).Parameter();
1025 Standard_Integer firstindex = lastindex -1;
1026 firstpar = ASI.Point(1,firstindex).Parameter();
1028 if(FirstFace.IsNull()) {
1029 FirstFace = ASI.Point(1, firstindex).Face();
1030 cc->D0(firstpar, firstpoint);
1031 BRepLib_MakeVertex v1(firstpoint);
1032 FirstVertex = TopoDS::Vertex(v1.Shape());
1036 if(LastFace.IsNull()) {
1037 LastFace = ASI.Point(1, lastindex).Face();
1038 cc->D0(lastpar, lastpoint);
1039 BRepLib_MakeVertex v2(lastpoint);
1040 LastVertex = TopoDS::Vertex(v2.Shape());
1046 if (trc) cout << " Less than 2 intersection points" << endl;
1048 Data = Standard_False;
1053 if(p1.Distance(firstpoint) <= Precision::Confusion())
1054 OnFirstFace = Standard_True;
1055 else OnFirstFace = Standard_False;
1059 if(p2.Distance(lastpoint) <= Precision::Confusion())
1060 OnLastFace = Standard_True;
1061 else OnLastFace = Standard_False;
1064 if(FirstFace.IsNull() || LastFace.IsNull()) {
1066 if (trc) cout << " First or Last Faces still null" << endl;
1068 Data = Standard_False;
1072 if (trc) cout << " FirstFace and LastFace OK" << endl;
1074 Data = Standard_True;
1079 // ---The wire consists of several edges
1082 if (trc) cout << " Multiple Edges" << endl;
1084 BRepTools_WireExplorer ex(myWire);
1085 for(; ex.More(); ex.Next()) {
1086 const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
1088 Handle(Geom_Curve) Cur = BRep_Tool::Curve(E, f, l);
1089 f = f - bnd/10000; l = l +bnd/10000;
1090 Handle(Geom_TrimmedCurve) curve;
1091 curve = new Geom_TrimmedCurve(Cur, f, l, Standard_True);
1095 BRep_Tool::Pnt(TopExp::FirstVertex(E,Standard_True));
1096 gp_Pnt P2 = BRep_Tool::Pnt(TopExp::LastVertex(E,Standard_True));
1097 ex1.Init(mySbase, TopAbs_FACE);
1098 TopoDS_Vertex theVertex;
1099 TopoDS_Edge theEdge;
1100 TopoDS_Face theFace;
1101 Standard_Boolean PtOnEdge = Standard_False;
1102 Standard_Boolean PtOnVertex = Standard_False;
1104 TopoDS_Vertex OnVertex;
1105 Standard_Real intpar;
1106 for(; ex1.More(); ex1.Next()) {
1107 const TopoDS_Face& f = TopoDS::Face(ex1.Current());
1108 inter.Init(f,curve, BRep_Tool::Tolerance(f));
1109 if(!inter.More()) continue;
1110 for(; inter.More(); inter.Next()) {
1111 gp_Pnt thePoint = inter.Pnt();
1112 if(!FirstVertex.IsNull()) {
1113 gp_Pnt point = BRep_Tool::Pnt(FirstVertex);
1114 if(point.Distance(thePoint) <= BRep_Tool::Tolerance(f)) {
1118 intpar = IntPar(curve, thePoint);
1121 B.MakeVertex(theVertex, thePoint, Precision::Confusion());
1123 if(thePoint.Distance(P2) <= Precision::Confusion()) {
1128 // ---Find thepoint on an edge or a vertex of face f
1129 PtOnEdgeVertex(RevolRib, f, thePoint, FirstVertex, LastVertex,
1130 PtOnEdge,OnEdge,PtOnVertex,OnVertex);
1133 // if(!theEdge.IsNull()) break;
1135 if (FirstEdge.IsNull() && !theEdge.IsNull() &&
1136 !theFace.IsNull() && !theVertex.IsNull()) {
1137 FirstEdge = theEdge;
1138 FirstFace = theFace;
1139 FirstVertex = theVertex;
1140 PtOnFirstEdge = PtOnEdge;
1141 OnFirstEdge = OnEdge;
1142 theEdge.Nullify(); theFace.Nullify(); theVertex.Nullify();
1143 if(PtOnEdge && !PtOnVertex) {
1144 TopTools_ListOfShape faces;
1146 faces.Append(FirstFace);
1147 TopExp_Explorer ex2;
1148 ex2.Init(mySbase, TopAbs_FACE);
1149 for(; ex2.More(); ex2.Next()) {
1150 TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:16:44 2002 fx/f
1151 TopExp_Explorer ex3;
1152 ex3.Init(fx, TopAbs_EDGE);
1153 for(; ex3.More(); ex3.Next()) {
1154 const TopoDS_Edge& e = TopoDS::Edge(ex3.Current());
1155 if(e.IsSame(OnEdge) && !fx.IsSame(FirstFace)) {
1160 TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar+bnd/10., bnd/10., Pln);
1161 if(!FFF.IsNull()) FirstFace = FFF;
1163 else if(PtOnEdge && PtOnVertex) {
1164 TopTools_ListOfShape faces;
1166 faces.Append(FirstFace);
1167 TopExp_Explorer ex2;
1168 ex2.Init(mySbase, TopAbs_FACE);
1169 for(; ex2.More(); ex2.Next()) {
1170 TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:13:08 2002 fx/f
1171 TopExp_Explorer ex3;
1172 ex3.Init(fx, TopAbs_VERTEX);
1173 for(; ex3.More(); ex3.Next()) {
1174 const TopoDS_Vertex& v = TopoDS::Vertex(ex3.Current());
1175 if(v.IsSame(OnVertex) && !fx.IsSame(FirstFace)) {
1180 TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar+bnd/10., bnd/10., Pln);
1181 if(!FFF.IsNull()) FirstFace = FFF;
1183 if(!FirstEdge.IsNull() && !FirstFace.IsNull()
1184 && !FirstVertex.IsNull()) {
1185 FirstOK = Standard_True;
1188 if(LastEdge.IsNull() && !theEdge.IsNull() &&
1189 !theFace.IsNull() && !theVertex.IsNull() &&
1190 !FirstEdge.IsNull()) {
1193 LastVertex = theVertex;
1194 PtOnLastEdge = PtOnEdge;
1195 OnLastEdge = OnEdge;
1196 if(PtOnEdge && !PtOnVertex) {
1197 TopTools_ListOfShape faces;
1199 faces.Append(LastFace);
1200 TopExp_Explorer ex2;
1201 ex2.Init(mySbase, TopAbs_FACE);
1202 for(; ex2.More(); ex2.Next()) {
1203 TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:12:06 2002 fx/f
1204 TopExp_Explorer ex3;
1205 ex3.Init(fx, TopAbs_EDGE);
1206 for(; ex3.More(); ex3.Next()) {
1207 const TopoDS_Edge& e = TopoDS::Edge(ex3.Current());
1208 if(e.IsSame(OnEdge) && !fx.IsSame(LastFace)) {
1213 TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar-bnd/10.,bnd/10., Pln);
1214 if(!FFF.IsNull()) LastFace = FFF;
1216 else if(PtOnEdge && PtOnVertex) {
1217 TopTools_ListOfShape faces;
1219 faces.Append(LastFace);
1220 TopExp_Explorer ex2;
1221 ex2.Init(mySbase, TopAbs_FACE);
1222 for(; ex2.More(); ex2.Next()) {
1223 TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:11:36 2002 fx/f
1224 TopExp_Explorer ex3;
1225 ex3.Init(fx, TopAbs_VERTEX);
1226 for(; ex3.More(); ex3.Next()) {
1227 const TopoDS_Vertex& v = TopoDS::Vertex(ex3.Current());
1228 if(v.IsSame(OnVertex) && !fx.IsSame(LastFace)) {
1233 TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar-bnd/10.,bnd/10., Pln);
1234 if(!FFF.IsNull()) LastFace = FFF;
1236 if(!LastEdge.IsNull() && !LastFace.IsNull()
1237 && !LastVertex.IsNull()) {
1238 LastOK = Standard_True;
1246 if(FirstOK && LastOK) {
1247 Data = Standard_True;
1248 gp_Pnt PP1 = BRep_Tool::Pnt(TopExp::FirstVertex(FirstEdge,Standard_True));
1249 gp_Pnt PP2 = BRep_Tool::Pnt(TopExp::LastVertex(LastEdge,Standard_True));
1250 gp_Pnt p1 = BRep_Tool::Pnt(FirstVertex);
1251 gp_Pnt p2 = BRep_Tool::Pnt(LastVertex);
1252 if(p1.Distance(PP1) <= BRep_Tool::Tolerance(FirstFace)) {
1253 OnFirstFace = Standard_True;
1255 if(p2.Distance(PP2) <= BRep_Tool::Tolerance(LastFace)) {
1256 OnLastFace = Standard_True;
1258 return Standard_True;
1262 if (trc) cout << " First or Last not OK" << endl;
1264 return Standard_False;
1270 //=======================================================================
1271 //function : PtOnEdgeVertex
1272 //purpose : Find if 2 limit points of the unique edge of a wire
1273 // are on an edge or a vertex of the base shape
1274 //=======================================================================
1276 void BRepFeat_RibSlot::PtOnEdgeVertex(const Standard_Boolean RevolRib,
1277 const TopoDS_Shape& shape,
1278 const gp_Pnt& point,
1279 const TopoDS_Vertex& ,//FirstVertex,
1280 const TopoDS_Vertex& ,//LastVertex,
1281 Standard_Boolean& PtOnEdge,
1282 TopoDS_Edge& OnEdge,
1283 Standard_Boolean& PtOnVertex,
1284 TopoDS_Vertex& OnVertex)
1288 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
1289 if (trc) cout << "BRepFeat_RibSlot::PtOnEdgeVertex" << endl;
1291 Standard_Boolean TestOK;
1292 // PtOnEdge = Standard_False;
1293 // OnEdge.Nullify();
1294 // PtOnVertex = Standard_False;
1295 // OnVertex.Nullify();
1297 TopExp_Explorer EXP;
1298 EXP.Init(shape, TopAbs_EDGE);
1299 TopTools_MapOfShape Map;
1300 for(; EXP.More(); EXP.Next()) {
1301 const TopoDS_Edge& e = TopoDS::Edge(EXP.Current());
1302 if ( !Map.Add(e)) continue;
1304 if (BRep_Tool::Degenerated(e)) continue;
1306 Standard_Real fff, lll;
1307 Handle(Geom_Curve) ccc = BRep_Tool::Curve(e, fff, lll);
1309 ccc = new Geom_TrimmedCurve(ccc, fff, lll);
1311 GeomAPI_ProjectPointOnCurve proj(point, ccc);
1312 TestOK = Standard_False;
1314 if(proj.NbPoints() == 1) TestOK = Standard_True;
1317 if(proj.NbPoints() >= 1) TestOK = Standard_True;
1319 if(TestOK && proj.Distance(1) <= BRep_Tool::Tolerance(e)) {
1320 PtOnEdge = Standard_True;
1322 TopoDS_Vertex ev1 = TopExp::FirstVertex(e,Standard_True);
1323 TopoDS_Vertex ev2 = TopExp::LastVertex(e,Standard_True);
1324 gp_Pnt ep1 = BRep_Tool::Pnt(ev1);
1325 gp_Pnt ep2 = BRep_Tool::Pnt(ev2);
1326 if(point.Distance(ep1) <= BRep_Tool::Tolerance(ev1)) {
1327 PtOnVertex = Standard_True;
1331 else if(point.Distance(ep2) <= BRep_Tool::Tolerance(ev1)) {
1332 PtOnVertex = Standard_True;
1342 //=======================================================================
1343 //function : SlidingProfile
1344 //purpose : construction of the profile face in case of sliding
1345 //=======================================================================
1347 Standard_Boolean BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof,
1348 const Standard_Boolean RevolRib,
1349 const Standard_Real myTol,
1350 Standard_Integer& Concavite,
1351 const Handle(Geom_Plane)& myPln,
1352 const TopoDS_Face& BndFace,
1353 const gp_Pnt& CheckPnt,
1354 const TopoDS_Face& FirstFace,
1355 const TopoDS_Face& LastFace,
1356 const TopoDS_Vertex& ,//FirstVertex,
1357 const TopoDS_Vertex& ,//LastVertex,
1358 const TopoDS_Edge& FirstEdge,
1359 const TopoDS_Edge& LastEdge)
1363 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1364 if (trc) cout << "BRepFeat_RibSlot::SlidingProfile" << endl;
1366 Standard_Boolean ProfileOK = Standard_True;
1367 // --case of sliding : construction of the wire of the profile
1368 // --> 1 part bounding box + 1 part wire
1369 // attention to the compatibility of orientations
1372 BRepLib_MakeWire WW;
1374 FN = Normal(FirstFace, myFirstPnt);
1375 LN = Normal(LastFace, myLastPnt);
1377 // Case of the groove (cut) <> rib (fuse)
1378 // -> we are in the material
1379 // -> make everything in 2d in the working plane : easier
1386 Handle(Geom_Line) ln1, ln2;
1387 gp_Pnt Pt;//,p1, p2;
1389 ln2 = new Geom_Line(myFirstPnt, FN);
1390 ln1 = new Geom_Line(myLastPnt, LN);
1392 Handle(Geom2d_Curve) ln2d1 = GeomAPI::To2d(ln1, myPln->Pln());
1393 Handle(Geom2d_Curve) ln2d2 = GeomAPI::To2d(ln2, myPln->Pln());
1395 Geom2dAPI_InterCurveCurve inter(ln2d1, ln2d2, Precision::Confusion());
1397 Standard_Boolean TestOK = Standard_True;
1400 d1 = ln1->Position().Direction();
1401 d2 = ln2->Position().Direction();
1402 if(d1.IsOpposite(d2, myTol)) {
1403 Standard_Real par1 = ElCLib::Parameter(ln1->Lin(), myFirstPnt);
1404 Standard_Real par2 = ElCLib::Parameter(ln2->Lin(), myLastPnt);
1405 if(par1 >= myTol || par2 >= myTol) {
1406 Concavite = 2; //paralel and concave
1407 BRepLib_MakeEdge e1(myLastPnt, myFirstPnt);
1411 if(d1.IsEqual(d2, myTol)) {
1412 if(Concavite == 3) TestOK = Standard_False;
1417 if(inter.NbPoints() > 0) {
1418 gp_Pnt2d P = inter.Point(1);
1419 myPln->D0(P.X(), P.Y(), Pt);
1420 Standard_Real par = IntPar(ln1, Pt);
1421 if(par>0) Concavite = 1; //concave
1425 // ---Construction of the profile face
1426 if(Concavite == 1) {
1427 // if concave : it is possible to extend first and last edges of the wire
1428 // to the bounding box
1429 BRepLib_MakeEdge e1(myLastPnt, Pt);
1431 BRepLib_MakeEdge e2(Pt, myFirstPnt);
1434 else if(Concavite == 3) {
1435 // BndEdge : edges of intersection with the bounding box
1436 TopoDS_Edge BndEdge1, BndEdge2;
1437 // Points of intersection with the bounding box / Find Profile
1438 gp_Pnt BndPnt1, BndPnt2, LastPnt;
1439 TopExp_Explorer expl;
1440 expl.Init(BndFace, TopAbs_WIRE);
1441 BRepTools_WireExplorer explo;
1442 TopoDS_Wire BndWire = TopoDS::Wire(expl.Current());
1443 explo.Init(BndWire);
1444 for(; explo.More(); explo.Next()) {
1445 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1446 Standard_Real first, last;
1447 Handle(Geom_Curve) c = BRep_Tool::Curve(e, first, last);
1448 Handle(Geom2d_Curve) c2d = GeomAPI::To2d(c, myPln->Pln());
1449 Geom2dAPI_InterCurveCurve intcln1(ln2d1, c2d,
1450 Precision::Confusion());
1451 if(intcln1.NbPoints() > 0) {
1452 gp_Pnt2d p2d = intcln1.Point(1);
1454 myPln->D0(p2d.X(), p2d.Y(), p);
1455 Standard_Real parl = IntPar(ln1, p);
1456 Standard_Real parc = IntPar(c, p);
1457 if(parc >= first && parc <= last && parl >= 0) {
1463 Geom2dAPI_InterCurveCurve intcln2(ln2d2, c2d,
1464 Precision::Confusion());
1465 if(intcln2.NbPoints() > 0) {
1466 gp_Pnt2d p2d = intcln2.Point(1);
1468 myPln->D0(p2d.X(), p2d.Y(), p);
1469 Standard_Real parl = IntPar(ln2, p);
1470 Standard_Real parc = IntPar(c, p);
1471 if(parc >= first && parc <= last && parl >= 0) {
1476 if(!BndEdge1.IsNull() && !BndEdge2.IsNull()) break;
1479 if(BndEdge1.IsNull() || BndEdge2.IsNull()) {
1481 if (trc) cout << " Null bounding edge" << endl;
1483 ProfileOK = Standard_False;
1488 BRepLib_MakeEdge e1(myLastPnt, BndPnt1);
1491 if(BndEdge1.IsSame(BndEdge2)) {
1492 // Particular case : same edge -> simply determined path
1493 BRepLib_MakeEdge e2(BndPnt1, BndPnt2);
1495 BRepLib_MakeEdge e3(BndPnt2, myFirstPnt);
1499 explo.Init(BndWire);
1500 for(; explo.More(); explo.Next()) {
1501 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1502 if(e.IsSame(BndEdge1)) {
1504 pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True));
1505 if(pp.Distance(BndPnt1) >= BRep_Tool::Tolerance(e)) {
1508 // else { //LinearForm
1509 // gp_Pnt ppp = BRep_Tool::Pnt(TopExp::FirstVertex(e,Standard_True));
1512 BRepLib_MakeEdge e2(BndPnt1, LastPnt);
1520 if(explo.Current().IsNull()) explo.Init(BndWire);
1522 else explo.Init(BndWire);
1524 // Check if this is BndEdge2
1525 // -> if yes : it is required to turn to join FirstPnt
1526 // -> if no : add edges
1527 Standard_Boolean Fin = Standard_False;
1529 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1530 if(!e.IsSame(BndEdge2)) {
1532 pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True));
1533 BRepLib_MakeEdge ee(LastPnt, pp);
1538 // the path is closed
1539 // -> since met BndEdge2, end of borders on BndFace
1540 Fin = Standard_True;
1541 BRepLib_MakeEdge ee(LastPnt, BndPnt2);
1547 if(explo.Current().IsNull()) {
1548 explo.Init(BndWire);
1551 else explo.Init(BndWire);
1554 BRepLib_MakeEdge e3(BndPnt2, myFirstPnt);
1559 // ---Construction of the profile
1561 // Explore the wire provided by the user
1562 // BRepTools_WireExplorer : correct order - without repetition <> TopExp : non ordered
1563 BRepTools_WireExplorer EX(myWire);
1565 Standard_Real ff, ll;
1566 Handle(Geom_Curve) FirstCurve = BRep_Tool::Curve(FirstEdge, ff, ll);
1568 if(!FirstEdge.IsSame(LastEdge)) {
1569 TopoDS_Vertex FLVert = TopExp::LastVertex(FirstEdge,Standard_True);
1570 gp_Pnt FLPnt = BRep_Tool::Pnt(FLVert);
1571 BRepLib_MakeEdge ef(FirstCurve, myFirstPnt, FLPnt);
1573 for(; EX.More(); EX.Next()) {
1574 const TopoDS_Edge& E = EX.Current();
1575 if(E.IsSame(FirstEdge)) break;
1578 for(; EX.More(); EX.Next()) {
1579 const TopoDS_Edge& E = EX.Current();
1580 if(!E.IsSame(LastEdge)) {
1585 Handle(Geom_Curve) LastCurve = BRep_Tool::Curve(LastEdge, ff, ll);
1586 TopoDS_Vertex LFVert = TopExp::FirstVertex(LastEdge,Standard_True);
1587 gp_Pnt LFPnt = BRep_Tool::Pnt(LFVert);
1588 BRepLib_MakeEdge el(LastCurve, LFPnt, myLastPnt);
1592 // only one edge : particular processing
1593 Standard_Real fpar = IntPar(FirstCurve, myFirstPnt);
1594 Standard_Real lpar = IntPar(FirstCurve, myLastPnt);
1595 Handle(Geom_Curve) c;
1597 c = Handle(Geom_Curve)::DownCast(FirstCurve->Reversed());
1601 BRepLib_MakeEdge ef(c, myFirstPnt, myLastPnt);
1605 BRepLib_MakeFace f(myPln->Pln(), WW, Standard_True);
1606 TopoDS_Face fac = TopoDS::Face(f.Shape());
1608 if (!BRepAlgo::IsValid(fac)) {
1610 if (trc) cout << " Invalid Face" << endl;
1612 ProfileOK = Standard_False;
1616 if(Concavite != 3) {
1617 // if concave : face is OK
1622 // CheckPnt : point slightly inside the material side
1623 // Bndface : face/cut of the bounding box in the plane of the profile
1624 BRepTopAdaptor_FClass2d Cl(fac, BRep_Tool::Tolerance(fac));
1626 ElSLib::Parameters(myPln->Pln(), CheckPnt, u, v);
1627 gp_Pnt2d checkpnt2d(u, v);
1628 if(Cl.Perform(checkpnt2d, Standard_True) == TopAbs_OUT) {
1629 // If face is not the correct part of BndFace take the complementary
1630 //modified by NIZNHY-PKV Fri Mar 22 16:46:20 2002 f
1631 //BRepAlgo_Cut c(BndFace, fac);
1632 BRepAlgoAPI_Cut c(BndFace, fac);
1633 //modified by NIZNHY-PKV Fri Mar 22 16:46:23 2002 t
1634 TopExp_Explorer exp(c.Shape(), TopAbs_WIRE);
1635 const TopoDS_Wire& w = TopoDS::Wire(exp.Current());
1636 BRepLib_MakeFace ffx(w);//modified by NIZNHY-PKV Fri Mar 22 17:10:43 2002 ffx/ff
1637 Prof = TopoDS::Face(ffx.Shape());
1640 // If face is the correct part of BndFace : face is OK
1645 if (!BRepAlgo::IsValid(Prof)) {
1647 if (trc) cout << " Invalid Face Profile" << endl;
1649 ProfileOK = Standard_False;
1654 //=======================================================================
1655 //function : NoSlidingProfile
1656 //purpose : construction of the face profile in case of sliding
1657 //=======================================================================
1659 Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof,
1660 const Standard_Boolean RevolRib,
1661 const Standard_Real myTol,
1662 Standard_Integer& Concavite,
1663 const Handle(Geom_Plane)& myPln,
1664 const Standard_Real bnd,
1665 const TopoDS_Face& BndFace,
1666 const gp_Pnt& CheckPnt,
1667 const TopoDS_Face& ,//FirstFace,
1668 const TopoDS_Face& ,//LastFace,
1669 const TopoDS_Vertex& ,//FirstVertex,
1670 const TopoDS_Vertex& ,//LastVertex,
1671 const TopoDS_Edge& FirstEdge,
1672 const TopoDS_Edge& LastEdge,
1673 const Standard_Boolean OnFirstFace,
1674 const Standard_Boolean OnLastFace)
1678 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1679 if (trc) cout << "BRepFeat_RibSlot::NoSlidingProfile" << endl;
1681 Standard_Boolean ProfileOK = Standard_True;
1683 Standard_Real l1, f1, f2, l2;//, p;
1684 TopoDS_Vertex theFV; theFV.Nullify();
1685 gp_Pnt theFirstpoint;
1686 TopoDS_Edge theLastEdge; theLastEdge.Nullify();
1687 gp_Pnt firstpoint, lastpoint;//, pp1, pp2;
1688 gp_Vec firstvect, lastvect;
1693 TopoDS_Edge FalseFirstEdge, FalseLastEdge, FalseOnlyOne;
1695 Handle(Geom_Curve) FirstCurve = BRep_Tool::Curve(FirstEdge, f1, l1);
1696 Handle(Geom_Curve) LastCurve = BRep_Tool::Curve(LastEdge, f2, l2);
1698 Handle(Geom_Line) firstln, lastln;
1699 FirstCurve->D1(f1, firstpoint, firstvect);
1700 lastln = new Geom_Line(firstpoint, -firstvect);
1701 LastCurve->D1(l2, lastpoint, lastvect);
1702 firstln = new Geom_Line(lastpoint, lastvect);
1706 Handle(Geom2d_Curve) ln2d1 = GeomAPI::To2d(firstln, myPln->Pln());
1707 Handle(Geom2d_Curve) ln2d2 = GeomAPI::To2d(lastln, myPln->Pln());
1709 Geom2dAPI_InterCurveCurve inter(ln2d1, ln2d2, Precision::Confusion());
1711 Standard_Boolean TestOK = Standard_True;
1714 d1 = firstln->Position().Direction();
1715 d2 = lastln->Position().Direction();
1716 if(d1.IsOpposite(d2, myTol)) {
1717 Standard_Real par1 = ElCLib::Parameter(firstln->Lin(), myFirstPnt);
1718 Standard_Real par2 = ElCLib::Parameter(lastln->Lin(), myLastPnt);
1719 if(par1 >= myTol || par2 >= myTol)
1720 Concavite = 2; //parallel and concave
1722 if(d1.IsEqual(d2, myTol)) {
1723 if(Concavite == 3) TestOK = Standard_False;
1728 if(inter.NbPoints() > 0) {
1729 gp_Pnt2d P = inter.Point(1);
1730 myPln->D0(P.X(), P.Y(), Pt);
1731 Standard_Real par = IntPar(firstln, Pt);
1732 if(par>0) Concavite = 1; //concave
1736 // ---Construction of the face profile
1737 if(Concavite == 3) {
1740 FalseFirstEdge = FirstEdge;
1741 EdgeExtention(FalseFirstEdge, bnd, Standard_True);
1742 const TopoDS_Vertex& vv1 = TopExp::FirstVertex(FalseFirstEdge,Standard_True);
1743 firstpoint = BRep_Tool::Pnt(vv1);
1744 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseFirstEdge, f, l);
1745 cc->D1(f, firstpoint, firstvect);
1746 lastln = new Geom_Line(firstpoint, -firstvect);
1747 if(FirstEdge.IsSame(LastEdge)) FalseOnlyOne = FalseFirstEdge;
1748 ln2d2 = GeomAPI::To2d(lastln, myPln->Pln());
1752 if(!FirstEdge.IsSame(LastEdge)) {
1753 FalseLastEdge = LastEdge;
1756 if(FalseOnlyOne.IsNull()) FalseOnlyOne = LastEdge;
1757 FalseLastEdge = FalseOnlyOne;
1759 EdgeExtention(FalseLastEdge, bnd, Standard_False);
1760 if(FirstEdge.IsSame(LastEdge)) {
1761 FalseOnlyOne = FalseLastEdge;
1763 const TopoDS_Vertex& vv2 = TopExp::LastVertex(FalseLastEdge,Standard_True);
1764 lastpoint = BRep_Tool::Pnt(vv2);
1765 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseLastEdge, f, l);
1766 cc->D1(l, lastpoint, lastvect);
1767 lastpoint = BRep_Tool::Pnt(vv2);
1768 firstln = new Geom_Line(lastpoint, lastvect);
1769 ln2d1 = GeomAPI::To2d(firstln, myPln->Pln());
1772 TopoDS_Edge BndEdge1, BndEdge2;
1773 gp_Pnt BndPnt1, BndPnt2, LastPnt;
1774 TopExp_Explorer expl;
1775 expl.Init(BndFace, TopAbs_WIRE);
1776 BRepTools_WireExplorer explo;
1777 TopoDS_Wire BndWire = TopoDS::Wire(expl.Current());
1778 explo.Init(BndWire);
1779 for(; explo.More(); explo.Next()) {
1780 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1781 Standard_Real first, last;
1782 Handle(Geom_Curve) c = BRep_Tool::Curve(e, first, last);
1783 Handle(Geom2d_Curve) c2d = GeomAPI::To2d(c, myPln->Pln());
1784 Geom2dAPI_InterCurveCurve intcln1(ln2d1, c2d,
1785 Precision::Confusion());
1786 if(intcln1.NbPoints() > 0) {
1787 gp_Pnt2d p2d = intcln1.Point(1);
1789 myPln->D0(p2d.X(), p2d.Y(), p);
1790 Standard_Real parl = IntPar(firstln, p);
1791 Standard_Real parc = IntPar(c, p);
1792 if(parc >= first && parc <= last && parl >= 0) {
1798 Geom2dAPI_InterCurveCurve intcln2(ln2d2, c2d,
1799 Precision::Confusion());
1800 if(intcln2.NbPoints() > 0) {
1801 gp_Pnt2d p2d = intcln2.Point(1);
1803 myPln->D0(p2d.X(), p2d.Y(), p);
1804 Standard_Real parl = IntPar(lastln, p);
1805 Standard_Real parc = IntPar(c, p);
1806 if(parc >= first && parc <= last && parl >= 0) {
1811 if(!BndEdge1.IsNull() && !BndEdge2.IsNull()) break;
1814 if(BndEdge1.IsNull() || BndEdge2.IsNull()) {
1816 if (trc) cout << " Null bounding edge" << endl;
1818 ProfileOK = Standard_False;
1823 if(theLastEdge.IsNull()) {
1824 BRepLib_MakeEdge e1(lastpoint, BndPnt1);
1825 ee1 = TopoDS::Edge(e1.Shape());
1828 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1829 BRepLib_MakeVertex v2(BndPnt1);
1830 BRepLib_MakeEdge e1(v1, v2);
1831 ee1 = TopoDS::Edge(e1.Shape());
1835 if(theFV.IsNull()) {
1836 theFV = TopExp::FirstVertex(ee1,Standard_True);
1837 theFirstpoint = BRep_Tool::Pnt(theFV);
1840 if(BndEdge1.IsSame(BndEdge2)) {
1841 TopoDS_Edge ee2, ee3;
1842 if(theLastEdge.IsNull()) {
1843 BRepLib_MakeEdge e2(BndPnt1, BndPnt2);
1844 ee2 = TopoDS::Edge(e2.Shape());
1847 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1848 BRepLib_MakeVertex v2(BndPnt2);
1849 BRepLib_MakeEdge e2(v1, v2);
1850 ee2 = TopoDS::Edge(e2.Shape());
1854 if(theFV.IsNull()) {
1855 theFV = TopExp::FirstVertex(ee2,Standard_True);
1856 theFirstpoint = BRep_Tool::Pnt(theFV);
1858 if(theLastEdge.IsNull()) {
1859 BRepLib_MakeEdge e3(BndPnt2, firstpoint);
1860 ee3 = TopoDS::Edge(e3.Shape());
1863 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1864 BRepLib_MakeVertex v2(firstpoint);
1865 BRepLib_MakeEdge e3(v1, v2);
1866 ee3 = TopoDS::Edge(e3.Shape());
1870 if(theFV.IsNull()) {
1871 theFV = TopExp::FirstVertex(ee3,Standard_True);
1872 theFirstpoint = BRep_Tool::Pnt(theFV);
1876 explo.Init(BndWire);
1877 for(; explo.More(); explo.Next()) {
1878 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1879 if(e.IsSame(BndEdge1)) {
1881 pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True));
1882 if(pp.Distance(BndPnt1) > BRep_Tool::Tolerance(e)) {
1886 if(theLastEdge.IsNull()) {
1887 BRepLib_MakeEdge e2(BndPnt1, LastPnt);
1888 eee = TopoDS::Edge(e2.Shape());
1891 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1892 BRepLib_MakeVertex v2(LastPnt);
1893 BRepLib_MakeEdge e2(v1, v2);
1894 eee = TopoDS::Edge(e2.Shape());
1898 if(theFV.IsNull()) {
1899 theFV = TopExp::FirstVertex(eee,Standard_True);
1900 theFirstpoint = BRep_Tool::Pnt(theFV);
1908 if(explo.Current().IsNull()) explo.Init(BndWire);
1910 else explo.Init(BndWire);
1911 Standard_Boolean Fin = Standard_False;
1913 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1914 if(!e.IsSame(BndEdge2)) {
1916 pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True));
1918 if(theLastEdge.IsNull()) {
1919 BRepLib_MakeEdge ee(LastPnt, pp);
1920 eee1 = TopoDS::Edge(ee.Shape());
1923 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1924 BRepLib_MakeVertex v2(pp);
1925 BRepLib_MakeEdge ee(v1, v2);
1926 eee1 = TopoDS::Edge(ee.Shape());
1930 if(theFV.IsNull()) {
1931 theFV = TopExp::FirstVertex(eee1,Standard_True);
1932 theFirstpoint = BRep_Tool::Pnt(theFV);
1937 Fin = Standard_True;
1939 if(theLastEdge.IsNull()) {
1940 BRepLib_MakeEdge ee(LastPnt, BndPnt2);
1941 eee2 = TopoDS::Edge(ee.Shape());
1944 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1945 BRepLib_MakeVertex v2(BndPnt2);
1946 BRepLib_MakeEdge ee(v1, v2);
1947 eee2 = TopoDS::Edge(ee.Shape());
1951 if(theFV.IsNull()) {
1952 theFV = TopExp::FirstVertex(eee2,Standard_True);
1953 theFirstpoint = BRep_Tool::Pnt(theFV);
1959 if(explo.Current().IsNull()) {
1960 explo.Init(BndWire);
1963 else explo.Init(BndWire);
1967 if(theLastEdge.IsNull()) {
1968 BRepLib_MakeEdge e3(BndPnt2, firstpoint);
1969 eee3 = TopoDS::Edge(e3.Shape());
1972 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1973 BRepLib_MakeVertex v2(firstpoint);
1974 BRepLib_MakeEdge e3(v1, v2);
1975 eee3 = TopoDS::Edge(e3.Shape());
1979 if(theFV.IsNull()) {
1980 theFV = TopExp::FirstVertex(eee3,Standard_True);
1981 theFirstpoint = BRep_Tool::Pnt(theFV);
1986 if(Concavite == 1) {
1988 if(theLastEdge.IsNull()) {
1989 BRepLib_MakeEdge e(Pt, firstpoint);
1990 eee4 = TopoDS::Edge(e.Shape());
1993 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1994 BRepLib_MakeVertex v2(firstpoint);
1995 BRepLib_MakeEdge e(v1, v2);
1996 eee4 = TopoDS::Edge(e.Shape());
1999 if(theFV.IsNull()) {
2000 theFV = TopExp::FirstVertex(eee4,Standard_True);
2001 theFirstpoint = BRep_Tool::Pnt(theFV);
2007 if(FirstEdge.IsSame(LastEdge)) {
2008 if(!myLFMap.IsBound(FirstEdge)) {
2009 TopTools_ListOfShape thelist;
2010 myLFMap.Bind(FirstEdge, thelist);
2012 if(OnFirstFace || OnLastFace) {
2013 TopoDS_Edge theEdge;
2015 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseOnlyOne, f, l);
2016 if(!theLastEdge.IsNull()) {
2017 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2019 const gp_Pnt& pp = BRep_Tool::
2020 Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True));
2021 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2024 else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True);
2025 BRepLib_MakeEdge e(cc, v1, v2);
2026 theEdge = TopoDS::Edge(e.Shape());
2029 const TopoDS_Vertex& v1 = TopExp::FirstVertex(FalseOnlyOne,Standard_True);
2031 const gp_Pnt& pp = BRep_Tool::
2032 Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True));
2033 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2036 else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True);
2037 BRepLib_MakeEdge e(cc, v1, v2);
2038 theEdge = TopoDS::Edge(e.Shape());
2040 myLFMap(FirstEdge).Append(theEdge);
2042 if(theFV.IsNull()) theFV = TopExp::FirstVertex(theEdge,Standard_True);
2043 theLastEdge = theEdge;
2047 Handle(Geom_Curve) cc = BRep_Tool::Curve(FirstEdge, f, l);
2048 TopoDS_Edge theEdge;
2049 if(!theLastEdge.IsNull()) {
2050 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2052 // Attention case Wire Reversed -> LastVertex without Standard_True
2053 const gp_Pnt& pp = BRep_Tool::Pnt(TopExp::LastVertex(FirstEdge));
2054 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2057 else v2 = TopExp::LastVertex(FirstEdge);
2058 BRepLib_MakeEdge e(cc, v1, v2);
2059 theEdge = TopoDS::Edge(e.Shape());
2062 const TopoDS_Vertex& v1 = TopExp::FirstVertex(FirstEdge,Standard_True);
2064 const gp_Pnt& pp = BRep_Tool::
2065 Pnt(TopExp::LastVertex(FirstEdge,Standard_True));
2066 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2069 else v2 = TopExp::LastVertex(FirstEdge,Standard_True);
2070 BRepLib_MakeEdge e(cc, v1, v2);
2071 theEdge = TopoDS::Edge(e.Shape());
2073 myLFMap(FirstEdge).Append(theEdge);
2075 if(theFV.IsNull()) theFV = TopExp::FirstVertex(theEdge,Standard_True);
2076 theLastEdge = theEdge;
2080 if(!myLFMap.IsBound(FirstEdge)) {
2081 TopTools_ListOfShape thelist1;
2082 myLFMap.Bind(FirstEdge, thelist1);
2085 TopoDS_Edge theEdge;
2087 Handle(Geom_Curve) cc = BRep_Tool::Curve(FirstEdge, f, l);
2088 if(!theLastEdge.IsNull()) {
2089 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2090 const TopoDS_Vertex& v2 = TopExp::LastVertex(FirstEdge,Standard_True);
2091 BRepLib_MakeEdge e(cc, v1, v2);
2092 theEdge = TopoDS::Edge(e.Shape());
2095 theEdge = FirstEdge;
2097 myLFMap(FirstEdge).Append(theEdge);
2099 if(theFV.IsNull()) theFV = TopExp::FirstVertex(theEdge,Standard_True);
2100 theLastEdge = theEdge;
2103 TopoDS_Edge theEdge;
2105 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseFirstEdge, f, l);
2106 if(!theLastEdge.IsNull()) {
2107 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2108 const TopoDS_Vertex& v2 = TopExp::LastVertex(FalseFirstEdge,Standard_True);
2109 BRepLib_MakeEdge e(cc, v1, v2);
2110 theEdge = TopoDS::Edge(e.Shape());
2113 theEdge = FalseFirstEdge;
2115 myLFMap(FirstEdge).Append(theEdge);
2117 if(theFV.IsNull()) theFV = TopExp::FirstVertex(theEdge,Standard_True);
2118 theLastEdge = theEdge;
2121 BRepTools_WireExplorer ex(myWire);
2122 for(; ex.More(); ex.Next()) {
2123 const TopoDS_Edge& E = ex.Current();
2124 if(E.IsSame(FirstEdge)) break;
2129 for(; ex.More(); ex.Next()) {
2130 const TopoDS_Edge& E = ex.Current();
2131 if(!E.IsSame(LastEdge)) {
2132 if(!myLFMap.IsBound(E)) {
2133 TopTools_ListOfShape thelist2;
2134 myLFMap.Bind(E, thelist2);
2138 Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l);
2139 if(!theLastEdge.IsNull()) {
2140 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2141 const TopoDS_Vertex& v2 = TopExp::LastVertex(E,Standard_True);
2142 BRepLib_MakeEdge e(cc, v1, v2);
2143 eee = TopoDS::Edge(e.Shape());
2148 myLFMap(E).Append(eee);
2150 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True);
2158 if(!FirstEdge.IsSame(LastEdge)) {
2159 const TopoDS_Edge& edg = TopoDS::Edge(ex.Current());
2160 if(!myLFMap.IsBound(edg)) {
2161 TopTools_ListOfShape thelist3;
2162 myLFMap.Bind(edg, thelist3);
2166 Handle(Geom_Curve) cc = BRep_Tool::Curve(edg, f, l);
2167 if(!theLastEdge.IsNull()) {
2168 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2170 const gp_Pnt& pp = BRep_Tool::
2171 Pnt(TopExp::LastVertex(edg,Standard_True));
2172 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2175 else v2 = TopExp::LastVertex(edg,Standard_True);
2176 BRepLib_MakeEdge e(cc, v1, v2);
2177 eee = TopoDS::Edge(e.Shape());
2180 const TopoDS_Vertex& v1 = TopExp::FirstVertex(edg,Standard_True);
2182 const gp_Pnt& pp = BRep_Tool::
2183 Pnt(TopExp::LastVertex(edg,Standard_True));
2184 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2187 else v2 = TopExp::LastVertex(edg,Standard_True);
2188 BRepLib_MakeEdge e(cc, v1, v2);
2189 eee = TopoDS::Edge(e.Shape());
2191 myLFMap(edg).Append(eee);
2193 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True);
2199 if(!myLFMap.IsBound(LastEdge)) {
2200 TopTools_ListOfShape thelist4;
2201 myLFMap.Bind(LastEdge, thelist4);
2203 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseOnlyOne, f, l);
2204 if(!theLastEdge.IsNull()) {
2205 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2207 const gp_Pnt& pp = BRep_Tool::
2208 Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True));
2209 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2212 else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True);
2213 BRepLib_MakeEdge e(cc, v1, v2);
2214 eee = TopoDS::Edge(e.Shape());
2217 const TopoDS_Vertex& v1 = TopExp::FirstVertex(FalseOnlyOne,Standard_True);
2219 const gp_Pnt& pp = BRep_Tool::
2220 Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True));
2221 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2224 else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True);
2225 BRepLib_MakeEdge e(cc, v1, v2);
2226 eee = TopoDS::Edge(e.Shape());
2228 myLFMap(LastEdge).Append(eee);
2230 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True);
2237 if(!myLFMap.IsBound(LastEdge)) {
2238 TopTools_ListOfShape thelist5;
2239 myLFMap.Bind(LastEdge, thelist5);
2241 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseLastEdge, f, l);
2242 if(!theLastEdge.IsNull()) {
2243 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2245 const gp_Pnt& pp = BRep_Tool::
2246 Pnt(TopExp::LastVertex(FalseLastEdge,Standard_True));
2247 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2250 else v2 = TopExp::LastVertex(FalseLastEdge,Standard_True);
2251 BRepLib_MakeEdge e(cc, v1, v2);
2252 eee = TopoDS::Edge(e.Shape());
2255 const TopoDS_Vertex& v1 = TopExp::FirstVertex(FalseLastEdge,Standard_True);
2257 const gp_Pnt& pp = BRep_Tool::
2258 Pnt(TopExp::LastVertex(FalseLastEdge,Standard_True));
2259 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2262 else v2 = TopExp::LastVertex(FalseLastEdge,Standard_True);
2263 BRepLib_MakeEdge e(cc, v1, v2);
2264 eee = TopoDS::Edge(e.Shape());
2266 myLFMap(LastEdge).Append(eee);
2268 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True);
2273 if(Concavite == 1) {
2275 if(theLastEdge.IsNull()) {
2276 BRepLib_MakeEdge ef(lastpoint, Pt);
2277 eef = TopoDS::Edge(ef.Shape());
2280 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2281 BRepLib_MakeVertex vv(Pt);
2282 TopoDS_Vertex v2 = TopoDS::Vertex(vv.Shape());
2283 if(!theFV.IsNull() &&
2284 Pt.Distance(theFirstpoint) <= myTol) v2 = theFV;
2286 BRepLib_MakeEdge ef(v1, v2);
2287 eef = TopoDS::Edge(ef.Shape());
2290 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eef,Standard_True);
2294 if(Concavite == 2) {
2295 BRepLib_MakeEdge ee(lastpoint, firstpoint);
2296 const TopoDS_Edge& e = ee.Edge();
2300 BRepLib_MakeFace fa(myPln->Pln(), w, Standard_True);
2301 TopoDS_Face fac = TopoDS::Face(fa.Shape());
2303 if (!BRepAlgo::IsValid(fac)) {
2305 if (trc) cout << " Invalid Face" << endl;
2307 ProfileOK = Standard_False;
2312 if(Concavite == 3) {
2313 BRepTopAdaptor_FClass2d Cl(fac, BRep_Tool::Tolerance(fac));
2315 ElSLib::Parameters(myPln->Pln(), CheckPnt, u, v);
2316 gp_Pnt2d checkpnt2d(u, v);
2317 if(Cl.Perform(checkpnt2d, Standard_True) == TopAbs_OUT) {
2318 //modified by NIZNHY-PKV Fri Mar 22 16:47:06 2002 f
2319 //BRepAlgo_Cut c(BndFace, fac);
2320 BRepAlgoAPI_Cut c(BndFace, fac);
2321 //modified by NIZNHY-PKV Fri Mar 22 16:47:09 2002 t
2322 TopExp_Explorer exp(c.Shape(), TopAbs_WIRE);
2323 //modified by NIZNHY-PKV Fri Mar 22 16:47:23 2002 f
2324 //UpdateDescendants(c.Builder(), c.Shape(), Standard_False);
2325 UpdateDescendants(c, c.Shape(), Standard_False);
2326 //modified by NIZNHY-PKV Fri Mar 22 16:47:28 2002 t
2327 const TopoDS_Wire& ww = TopoDS::Wire(exp.Current());//modified by NIZNHY-PKV Fri Mar 22 17:10:16 2002 ww/w
2328 BRepLib_MakeFace ff(ww);
2329 Prof = TopoDS::Face(ff.Shape());
2339 if (!BRepAlgo::IsValid(Prof)) {
2341 if (trc) cout << " Invalid Face Profile" << endl;
2343 ProfileOK = Standard_False;
2349 //modified by NIZNHY-PKV Thu Mar 21 18:43:18 2002 f
2350 //=======================================================================
2351 //function : UpdateDescendants
2353 //=======================================================================
2354 void BRepFeat_RibSlot::UpdateDescendants(const BRepAlgoAPI_BooleanOperation& aBOP,
2355 const TopoDS_Shape& S,
2356 const Standard_Boolean SkipFace)
2358 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm;
2359 TopTools_ListIteratorOfListOfShape it,it2;
2360 TopTools_MapIteratorOfMapOfShape itm;
2361 TopExp_Explorer exp;
2363 for (itdm.Initialize(myMap);itdm.More();itdm.Next()) {
2364 const TopoDS_Shape& orig = itdm.Key();
2365 if (SkipFace && orig.ShapeType() == TopAbs_FACE) {
2368 TopTools_MapOfShape newdsc;
2370 //if (itdm.Value().IsEmpty()) {myMap.ChangeFind(orig).Append(orig);}
2372 for (it.Initialize(itdm.Value());it.More();it.Next()) {
2373 const TopoDS_Shape& sh = it.Value();
2374 if(sh.ShapeType() != TopAbs_FACE) continue;
2375 const TopoDS_Face& fdsc = TopoDS::Face(it.Value());
2376 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
2377 if (exp.Current().IsSame(fdsc)) { // preserved
2383 BRepAlgoAPI_BooleanOperation* pBOP=(BRepAlgoAPI_BooleanOperation*)&aBOP;
2384 const TopTools_ListOfShape& aLM=pBOP->Modified(fdsc);
2385 it2.Initialize(aLM);
2386 for (; it2.More(); it2.Next()) {
2387 const TopoDS_Shape& aS=it2.Value();
2393 myMap.ChangeFind(orig).Clear();
2394 for (itm.Initialize(newdsc); itm.More(); itm.Next()) {
2395 // check the belonging to the shape...
2396 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
2397 if (exp.Current().IsSame(itm.Key())) {
2398 // const TopoDS_Shape& sh = itm.Key();
2399 myMap.ChangeFind(orig).Append(itm.Key());
2406 //modified by NIZNHY-PKV Thu Mar 21 18:43:36 2002 t