1 // Created on: 1997-10-08
2 // Created by: Olga KOULECHOVA
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 #include <BRepFeat_RibSlot.ixx>
24 #include <BRepFeat.hxx>
27 #include <LocOpe_Gluer.hxx>
28 #include <LocOpe_FindEdges.hxx>
29 #include <LocOpe_CSIntersector.hxx>
30 #include <LocOpe_PntFace.hxx>
34 #include <TopExp_Explorer.hxx>
38 #include <TopoDS_Shape.hxx>
39 #include <TopoDS_Face.hxx>
41 #include <TopTools_ListOfShape.hxx>
42 #include <TopTools_ListIteratorOfListOfShape.hxx>
43 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
44 #include <TopTools_MapIteratorOfMapOfShape.hxx>
45 #include <TopTools_MapOfShape.hxx>
46 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
48 #include <TopOpeBRepBuild_HBuilder.hxx>
50 #include <BRep_Tool.hxx>
52 #include <BRepAlgo.hxx>
53 //modified by NIZNHY-PKV Fri Mar 22 16:48:13 2002 f
54 //#include <BRepAlgo_Cut.hxx>
55 //#include <BRepAlgo_Fuse.hxx>
56 #include <BRepAlgoAPI_Cut.hxx>
57 #include <BRepAlgoAPI_Fuse.hxx>
58 //modified by NIZNHY-PKV Fri Mar 22 16:48:16 2002 t
60 #include <BRepAdaptor_Surface.hxx>
61 #include <BRepBndLib.hxx>
62 #include <BRepIntCurveSurface_Inter.hxx>
63 #include <BRepTools_WireExplorer.hxx>
64 #include <BRepTopAdaptor_FClass2d.hxx>
65 #include <BRepClass3d_SolidClassifier.hxx>
67 #include <BRepLib_MakeVertex.hxx>
68 #include <BRepLib_MakeEdge.hxx>
69 #include <BRepLib_MakeWire.hxx>
70 #include <BRepLib_MakeFace.hxx>
71 #include <BRepLib.hxx>
73 #include <Bnd_Box.hxx>
75 #include <Standard_ConstructionError.hxx>
76 #include <Standard_NoSuchObject.hxx>
78 #include <GeomLib.hxx>
79 #include <GeomAdaptor_Curve.hxx>
81 #include <Geom_Curve.hxx>
82 #include <Geom_TrimmedCurve.hxx>
83 #include <Geom_Line.hxx>
84 #include <Geom_Circle.hxx>
85 #include <Geom_Plane.hxx>
86 #include <Geom_Ellipse.hxx>
87 #include <Geom_Parabola.hxx>
88 #include <Geom_Hyperbola.hxx>
90 #include <Geom2dAPI_InterCurveCurve.hxx>
91 #include <GeomAPI.hxx>
92 #include <GeomAPI_ProjectPointOnCurve.hxx>
101 #include <ElCLib.hxx>
102 #include <ElSLib.hxx>
105 #include <Precision.hxx>
107 #include <TColGeom_SequenceOfCurve.hxx>
108 #include <BRepFeat_Builder.hxx>
112 extern Standard_Boolean BRepFeat_GettraceFEAT();
113 extern Standard_Boolean BRepFeat_GettraceFEATRIB();
116 //=======================================================================
117 //function : LFPerform
118 //purpose : topological reconstruction of ribs
119 //=======================================================================
121 void BRepFeat_RibSlot::LFPerform()
124 Standard_Boolean trc = BRepFeat_GettraceFEAT();
125 if (trc) cout << "BRepFeat_RibSlot::LFPerform()" << endl;
127 if (mySbase.IsNull() || myPbase.IsNull() || mySkface.IsNull()
128 || myGShape.IsNull() || myLFMap.IsEmpty()) {
130 cout << "Topological reconstruction is impossible" << endl;
131 if (trc) cout << " Fields not initialized" << endl;
133 myStatusError = BRepFeat_NotInitialized;
138 TopExp_Explorer exp,exp2;
139 Standard_Integer theOpe = 2;
141 if (!myGluedF.IsEmpty()) {
145 Standard_Boolean ChangeOpe = Standard_False;
146 // Hope that there is just a solid in the result
147 Standard_Boolean UntilInShape = Standard_False;
149 if (!mySUntil.IsNull()) {
150 UntilInShape = Standard_True;
151 for (exp2.Init(mySUntil,TopAbs_FACE); exp2.More(); exp2.Next()) {
152 const TopoDS_Shape& funtil = exp2.Current();
153 for (exp.Init(mySbase,TopAbs_FACE); exp.More(); exp.Next()) {
154 if (exp.Current().IsSame(funtil)) {
159 UntilInShape = Standard_False;
165 TopTools_ListIteratorOfListOfShape it,it2;
166 TopTools_DataMapIteratorOfDataMapOfShapeShape itm;
167 //Standard_Integer sens = 0;
169 LocOpe_Gluer theGlue;
174 Standard_Boolean Collage = Standard_True;
176 LocOpe_FindEdges theFE;
177 TopTools_DataMapOfShapeListOfShape locmap;
178 theGlue.Init(mySbase,myGShape);
179 for (itm.Initialize(myGluedF); itm.More();itm.Next()) {
180 const TopoDS_Face& glface = TopoDS::Face(itm.Key());
181 const TopoDS_Face& fac = TopoDS::Face(myGluedF(glface));
182 for (exp.Init(myGShape,TopAbs_FACE); exp.More(); exp.Next()) {
183 if (exp.Current().IsSame(glface)) {
188 Collage = BRepFeat::IsInside(glface, fac);
191 ChangeOpe = Standard_True;
195 theGlue.Bind(glface, fac);
196 theFE.Set(glface, fac);
197 for (theFE.InitIterator(); theFE.More();theFE.Next()) {
198 theGlue.Bind(theFE.EdgeFrom(),theFE.EdgeTo());
204 LocOpe_Operation ope = theGlue.OpeType();
205 if (ope == LocOpe_INVALID ||
206 (myFuse && ope != LocOpe_FUSE) ||
207 (!myFuse && ope != LocOpe_CUT) ||
210 ChangeOpe = Standard_True;
212 cout << "Passage to topological operations" << endl;
217 // gluing is always applicable
221 if (theGlue.IsDone()) {
222 UpdateDescendants(theGlue);
223 myNewEdges = theGlue.Edges();
224 myTgtEdges = theGlue.TgtEdges();
227 myShape = theGlue.ResultingShape();
228 BRepLib::SameParameter(myShape, 1.e-7, Standard_True);
232 ChangeOpe = Standard_True;
234 cout << "Passage to topologic operation" << endl;
239 // case without gluing
241 BRepFeat_Builder theBuilder;
242 TopTools_ListOfShape partsoftool;
243 BRepClass3d_SolidClassifier oussa;
244 Standard_Boolean bFlag;
245 TopTools_ListIteratorOfListOfShape aIt;
247 bFlag = (myPerfSelection == BRepFeat_NoSelection) ? 0 : 1;
249 theBuilder.Init(mySbase, myGShape);
250 theBuilder.SetOperation(myFuse, bFlag);
252 theBuilder.Perform();
254 theBuilder.PartsOfTool(partsoftool);
255 aIt.Initialize(partsoftool);
256 if (aIt.More() && myPerfSelection != BRepFeat_NoSelection) {
257 Standard_Real toler = (BRep_Tool::Tolerance(myPbase))*2;
259 for(; aIt.More(); aIt.Next()) {
260 oussa.Load(aIt.Value());
261 oussa.Perform(myFirstPnt, toler);
262 TopAbs_State sp1=oussa.State();
263 oussa.Perform(myLastPnt, toler);
264 TopAbs_State sp2=oussa.State();
265 if (!(sp1 == TopAbs_OUT || sp2 == TopAbs_OUT)) {
266 const TopoDS_Shape& S = aIt.Value();
267 theBuilder.KeepPart(S);
272 theBuilder.PerformResult();
273 myShape = theBuilder.Shape();
275 myShape = theBuilder.Shape();
281 //=======================================================================
282 //function : IsDeleted
284 //=======================================================================
286 Standard_Boolean BRepFeat_RibSlot::IsDeleted(const TopoDS_Shape& F)
288 return (myMap(F).IsEmpty());
292 //=======================================================================
293 //function : Modified
295 //=======================================================================
297 const TopTools_ListOfShape& BRepFeat_RibSlot::Modified
298 (const TopoDS_Shape& F)
301 Standard_Boolean trc = BRepFeat_GettraceFEAT();
302 if (trc) cout << "BRepFeat_RibSlot::Modified" << endl;
304 if (myMap.IsBound(F)) {
305 static TopTools_ListOfShape list;
307 TopTools_ListIteratorOfListOfShape ite(myMap(F));
308 for(; ite.More(); ite.Next()) {
309 const TopoDS_Shape& sh = ite.Value();
315 return myGenerated; // empty list
318 //=======================================================================
319 //function : Generated
321 //=======================================================================
323 const TopTools_ListOfShape& BRepFeat_RibSlot::Generated
324 (const TopoDS_Shape& S)
327 Standard_Boolean trc = BRepFeat_GettraceFEAT();
328 if (trc) cout << "BRepFeat_RibSlot::Generated" << endl;
330 if(S.ShapeType() != TopAbs_FACE) {
332 if(myLFMap.IsEmpty() || !myLFMap.IsBound(S)) {
333 if (myMap.IsBound(S)) { // check if filter on face or not
334 static TopTools_ListOfShape list;
336 TopTools_ListIteratorOfListOfShape ite(myMap(S));
337 for(; ite.More(); ite.Next()) {
338 const TopoDS_Shape& sh = ite.Value();
344 else return myGenerated;
348 TopTools_ListIteratorOfListOfShape it(myLFMap(S));
349 static TopTools_ListOfShape list;
351 for(; it.More(); it.Next()) {
352 if(myMap.IsBound(it.Value())) {
353 TopTools_ListIteratorOfListOfShape it1(myMap(it.Value()));
354 for(; it1.More(); it1.Next()) {
355 const TopoDS_Shape& sh = it1.Value();
364 else return myGenerated;
368 //=======================================================================
369 //function : UpdateDescendants
371 //=======================================================================
373 void BRepFeat_RibSlot::UpdateDescendants(const LocOpe_Gluer& G)
375 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm;
376 TopTools_ListIteratorOfListOfShape it,it2;
377 TopTools_MapIteratorOfMapOfShape itm;
379 for (itdm.Initialize(myMap);itdm.More();itdm.Next()) {
380 const TopoDS_Shape& orig = itdm.Key();
381 TopTools_MapOfShape newdsc;
382 for (it.Initialize(itdm.Value());it.More();it.Next()) {
383 const TopoDS_Face& fdsc = TopoDS::Face(it.Value());
384 for (it2.Initialize(G.DescendantFaces(fdsc));
385 it2.More();it2.Next()) {
386 newdsc.Add(it2.Value());
389 myMap.ChangeFind(orig).Clear();
390 for (itm.Initialize(newdsc);itm.More();itm.Next()) {
391 myMap.ChangeFind(orig).Append(itm.Key());
396 //=======================================================================
397 //function : UpdateDescendants
399 //=======================================================================
400 void BRepFeat_RibSlot::UpdateDescendants (const Handle(TopOpeBRepBuild_HBuilder)& B,
401 const TopoDS_Shape& S,
402 const Standard_Boolean SkipFace)
404 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm;
405 TopTools_ListIteratorOfListOfShape it,it2;
406 TopTools_MapIteratorOfMapOfShape itm;
409 for (itdm.Initialize(myMap);itdm.More();itdm.Next()) {
410 const TopoDS_Shape& orig = itdm.Key();
411 if (SkipFace && orig.ShapeType() == TopAbs_FACE) {
414 TopTools_MapOfShape newdsc;
415 for (it.Initialize(itdm.Value());it.More();it.Next()) {
416 const TopoDS_Shape& sh = it.Value();
417 if(sh.ShapeType() != TopAbs_FACE) continue;
418 const TopoDS_Face& fdsc = TopoDS::Face(it.Value());
419 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
420 if (exp.Current().IsSame(fdsc)) { // preserved
426 if (B->IsSplit(fdsc, TopAbs_OUT)) {
427 for (it2.Initialize(B->Splits(fdsc,TopAbs_OUT));
428 it2.More();it2.Next()) {
429 newdsc.Add(it2.Value());
432 if (B->IsSplit(fdsc, TopAbs_IN)) {
433 for (it2.Initialize(B->Splits(fdsc,TopAbs_IN));
434 it2.More();it2.Next()) {
435 newdsc.Add(it2.Value());
438 if (B->IsSplit(fdsc, TopAbs_ON)) {
439 for (it2.Initialize(B->Splits(fdsc,TopAbs_ON));
440 it2.More();it2.Next()) {
441 newdsc.Add(it2.Value());
444 if (B->IsMerged(fdsc, TopAbs_OUT)) {
445 for (it2.Initialize(B->Merged(fdsc,TopAbs_OUT));
446 it2.More();it2.Next()) {
447 newdsc.Add(it2.Value());
450 if (B->IsMerged(fdsc, TopAbs_IN)) {
451 for (it2.Initialize(B->Merged(fdsc,TopAbs_IN));
452 it2.More();it2.Next()) {
453 newdsc.Add(it2.Value());
456 if (B->IsMerged(fdsc, TopAbs_ON)) {
457 for (it2.Initialize(B->Merged(fdsc,TopAbs_ON));
458 it2.More();it2.Next()) {
459 newdsc.Add(it2.Value());
464 myMap.ChangeFind(orig).Clear();
465 for (itm.Initialize(newdsc); itm.More(); itm.Next()) {
466 // check the belonging to the shape...
467 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
468 if (exp.Current().IsSame(itm.Key())) {
469 myMap.ChangeFind(orig).Append(itm.Key());
479 //=======================================================================
480 //function : FirstShape
482 //=======================================================================
484 const TopTools_ListOfShape& BRepFeat_RibSlot::FirstShape() const
486 if (!myFShape.IsNull()) {
487 return myMap(myFShape);
489 return myGenerated; // empty list
493 //=======================================================================
494 //function : LastShape
496 //=======================================================================
498 const TopTools_ListOfShape& BRepFeat_RibSlot::LastShape() const
500 if (!myLShape.IsNull()) {
501 return myMap(myLShape);
503 return myGenerated; // empty list
506 //=======================================================================
507 //function : FacesForDraft
509 //=======================================================================
511 const TopTools_ListOfShape& BRepFeat_RibSlot::FacesForDraft() const
513 return myFacesForDraft;
517 //=======================================================================
518 //function : NewEdges
520 //=======================================================================
522 const TopTools_ListOfShape& BRepFeat_RibSlot::NewEdges() const
527 //=======================================================================
528 //function : TgtEdges
530 //=======================================================================
532 const TopTools_ListOfShape& BRepFeat_RibSlot::TgtEdges() const
538 //=======================================================================
539 //function : CurrentStatusError
541 //=======================================================================
543 BRepFeat_StatusError BRepFeat_RibSlot::CurrentStatusError() const
545 return myStatusError;
549 //=======================================================================
550 //function : CheckPoint
551 //purpose : Proofing point material side (side of extrusion)
552 //=======================================================================
554 gp_Pnt BRepFeat_RibSlot::CheckPoint(const TopoDS_Edge& e,
555 const Standard_Real ,//bnd,
556 const Handle(Geom_Plane)& Pln)
560 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
561 if (trc) cout << "BRepFeat_RibSlot::CheckPoint" << endl;
563 // Vector product : normal to plane X direction Wire
564 // -> gives the material side
565 // Proofing point somewhat inside the material side
567 Handle(Geom_Curve) cc = BRep_Tool::Curve(e, f, l);
569 gp_Vec tgt; gp_Pnt pp;
570 Standard_Real par = ( f + l) / 2.;
572 cc->D1(par, pp, tgt);
574 if ( e.Orientation() == TopAbs_REVERSED) tgt.Reverse();
576 gp_Vec D = -tgt.Crossed(Pln->Pln().Position().Direction())/10.;
584 //=======================================================================
586 //purpose : calculate the normal to a face in a point
587 //=======================================================================
589 gp_Dir BRepFeat_RibSlot::Normal(const TopoDS_Face& F,const gp_Pnt& P)
593 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
594 if (trc) cout << "BRepFeat_RibSlot::Normal" << endl;
599 BRepAdaptor_Surface AS(F, Standard_True);
601 switch ( AS.GetType()) {
604 ElSLib::Parameters(AS.Plane(),P,U,V); break;
606 case GeomAbs_Cylinder:
607 ElSLib::Parameters(AS.Cylinder(),P,U,V); break;
610 ElSLib::Parameters(AS.Cone(),P,U,V); break;
613 ElSLib::Parameters(AS.Torus(),P,U,V); break;
617 return gp_Dir(1., 0., 0.);
623 AS.D1(U, V, pt, D1U, D1V);
625 CSLib_DerivativeStatus St;
626 CSLib::Normal(D1U, D1V, Precision::Confusion(), St, N);
627 if(F.Orientation() == TopAbs_FORWARD) N.Reverse();
631 //=======================================================================
633 //purpose : calculate the parameter of a point on a curve
634 //=======================================================================
636 Standard_Real BRepFeat_RibSlot::IntPar(const Handle(Geom_Curve)& C,
640 if ( C.IsNull()) return 0.;
642 GeomAdaptor_Curve AC(C);
645 switch ( AC.GetType()) {
648 U = ElCLib::Parameter(AC.Line(),P); break;
651 U = ElCLib::Parameter(AC.Circle(),P); break;
653 case GeomAbs_Ellipse:
654 U = ElCLib::Parameter(AC.Ellipse(),P); break;
656 case GeomAbs_Hyperbola:
657 U = ElCLib::Parameter(AC.Hyperbola(),P); break;
659 case GeomAbs_Parabola:
660 U = ElCLib::Parameter(AC.Parabola(),P); break;
670 //=======================================================================
671 //function : EdgeExtention
672 //purpose : extention of a edge by tangence
673 //=======================================================================
675 void BRepFeat_RibSlot::EdgeExtention(TopoDS_Edge& e,
676 const Standard_Real bnd,
677 const Standard_Boolean FirstLast)
680 Standard_Boolean trc = BRepFeat_GettraceFEAT();
681 if (trc) cout << "BRepFeat_RibSlot::EdgeExtention" << endl;
684 Handle(Geom_Curve) cu = BRep_Tool::Curve(e, f, l);
685 Handle(Geom_TrimmedCurve) C =
686 new Geom_TrimmedCurve(cu, f, l);
690 if(cu->DynamicType() == STANDARD_TYPE(Geom_Line) ||
691 cu->DynamicType() == STANDARD_TYPE(Geom_Circle) ||
692 cu->DynamicType() == STANDARD_TYPE(Geom_Ellipse) ||
693 cu->DynamicType() == STANDARD_TYPE(Geom_Hyperbola) ||
694 cu->DynamicType() == STANDARD_TYPE(Geom_Parabola)) {
696 BRepLib_MakeEdge Edg(cu, f-bnd/10., l);
697 E = TopoDS::Edge(Edg.Shape());
700 BRepLib_MakeEdge Edg(cu, f, l+bnd/10.);
701 E = TopoDS::Edge(Edg.Shape());
705 Handle(Geom_Line) ln;
711 ln = new Geom_Line(pnt, -vct);
712 ln->D0(bnd/1000., Pt);
713 GeomLib::ExtendCurveToPoint(C, Pt, GeomAbs_G1, Standard_False);
714 BRepLib_MakeEdge Edg(C, Pt, BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True)));
715 E = TopoDS::Edge(Edg.Shape());
719 ln = new Geom_Line(pnt, vct);
720 ln->D0(bnd/1000., Pt);
721 GeomLib::ExtendCurveToPoint(C, Pt, GeomAbs_G1, Standard_True);
722 BRepLib_MakeEdge Edg(C, BRep_Tool::Pnt(TopExp::FirstVertex(e,Standard_True)), Pt);
723 E = TopoDS::Edge(Edg.Shape());
730 //=======================================================================
731 //function : ChoiceOfFaces
732 //purpose : choose face of support in case of support on an edge
733 //=======================================================================
735 TopoDS_Face BRepFeat_RibSlot::ChoiceOfFaces(TopTools_ListOfShape& faces,
736 const Handle(Geom_Curve)& cc,
737 const Standard_Real par,
738 const Standard_Real ,//bnd,
739 const Handle(Geom_Plane)& Pln)
743 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
744 if (trc) cout << "BRepFeat_RibSlot::ChoiceOfFaces" << endl;
751 cc->D1(par, pp, tgt);
753 Handle(Geom_Line) l1 = new Geom_Line(pp, tgt);
755 TColGeom_SequenceOfCurve scur;
756 Standard_Integer Counter = 0;
759 gp_Ax1 Axe(pp, Pln->Position().Direction());
760 for ( Standard_Integer i = 1; i <=8; i++) {
761 Handle(Geom_Curve) L =
762 Handle(Geom_Curve)::DownCast(l1->Rotated(Axe, i*M_PI/9.));
767 TopTools_ListIteratorOfListOfShape it;
768 it.Initialize(faces);
769 Standard_Real Par = RealLast();
770 for(; it.More(); it.Next()) {
771 const TopoDS_Face& f = TopoDS::Face(it.Value());
772 LocOpe_CSIntersector ASI(f);
774 if(!ASI.IsDone()) continue;
775 for(Standard_Integer jj = 1; jj<=Counter; jj++) {
776 if(ASI.NbPoints(jj) >= 1) {
777 Standard_Real app = ASI.Point(jj,1).Parameter();//modified by NIZNHY-PKV Fri Mar 22 17:05:23 2002 pp
778 if(app >= 0 && app < Par) {
790 //=======================================================================
791 //function : HeightMax
792 //purpose : Calculate the height of the prism following the parameters of a bounding box
793 //=======================================================================
795 Standard_Real BRepFeat_RibSlot::HeightMax(const TopoDS_Shape& theSbase,
796 const TopoDS_Shape& theSUntil,
801 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
802 if (trc) cout << "BRepFeat_RibSlot::HeightMax" << endl;
805 BRepBndLib::Add(theSbase,Box);
806 if(!theSUntil.IsNull()) {
807 BRepBndLib::Add(theSUntil,Box);
809 Standard_Real c[6], bnd;
810 Box.Get(c[0],c[2],c[4],c[1],c[3],c[5]);
812 for(Standard_Integer i = 0 ; i < 6; i++) {
813 if(c[i] > bnd) bnd = c[i];
815 p1.SetCoord(c[0]-2.*bnd, c[1]-2.*bnd, c[2]-2.*bnd);
816 p2.SetCoord(c[3]+2.*bnd, c[4]+2.*bnd, c[5]+2.*bnd);
820 //=======================================================================
821 //function : ExtremeFaces
822 //purpose : Calculate the base faces of the rib
823 //=======================================================================
825 Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib,
826 const Standard_Real bnd,
827 const Handle(Geom_Plane)& Pln,
828 TopoDS_Edge& FirstEdge,
829 TopoDS_Edge& LastEdge,
830 TopoDS_Face& FirstFace,
831 TopoDS_Face& LastFace,
832 TopoDS_Vertex& FirstVertex,
833 TopoDS_Vertex& LastVertex,
834 Standard_Boolean& OnFirstFace,
835 Standard_Boolean& OnLastFace,
836 Standard_Boolean& PtOnFirstEdge,
837 Standard_Boolean& PtOnLastEdge,
838 TopoDS_Edge& OnFirstEdge,
839 TopoDS_Edge& OnLastEdge)
843 Standard_Boolean trc = BRepFeat_GettraceFEAT();
844 if (trc) cout << "BRepFeat_RibSlot::ExtremeFaces" << endl;
846 Standard_Boolean Data = Standard_True;
851 PtOnFirstEdge = Standard_False;
852 PtOnLastEdge = Standard_False;
853 OnFirstEdge.Nullify();
854 OnLastEdge.Nullify();
856 BRepIntCurveSurface_Inter inter;
860 Standard_Boolean FirstOK = Standard_False, LastOK = Standard_False;
862 Standard_Integer NumberOfEdges = 0;
863 TopExp_Explorer exp(myWire, TopAbs_EDGE);
865 for(; exp.More(); exp.Next()) {
869 // ---the wire includes only one edge
870 if(NumberOfEdges == 1) {
872 if (trc) cout << " One Edge" << endl;
875 Standard_Real f, l;//, f1, l1, temp;
876 gp_Pnt firstpoint, lastpoint;
878 // Points limit the unique edge
879 const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
880 Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l);
881 gp_Pnt p1 = BRep_Tool::Pnt(TopExp::FirstVertex(E,Standard_True));
882 gp_Pnt p2 = BRep_Tool::Pnt(TopExp::LastVertex(E,Standard_True));
884 Standard_Real FirstPar = f; Standard_Real LastPar = l;
887 // ---Find if 2 points limiting the unique edge of the wire
888 // are on an edge or a vertex of the base shape
889 Standard_Boolean PtOnFirstVertex = Standard_False;
890 Standard_Boolean PtOnLastVertex = Standard_False;
891 TopoDS_Vertex OnFirstVertex, OnLastVertex;
892 PtOnEdgeVertex(RevolRib, mySbase, p1, FirstVertex, LastVertex,
893 PtOnFirstEdge, OnFirstEdge, PtOnFirstVertex, OnFirstVertex);
894 PtOnEdgeVertex(RevolRib, mySbase, p2, FirstVertex, LastVertex,
895 PtOnLastEdge, OnLastEdge, PtOnLastVertex, OnLastVertex);
897 TopTools_MapOfShape Map;
900 if (!PtOnFirstVertex) {
901 // Find FirstFace : face of the base shape containing OnFirstEdge
902 // meeting ChoiceOfFaces
903 TopExp_Explorer ex4, ex5;
904 ex4.Init(mySbase, TopAbs_FACE);
905 TopTools_ListOfShape faces;
908 for(; ex4.More(); ex4.Next()) {
909 const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:04 2002 fx instead f
910 if ( !Map.Add(fx)) continue;
911 ex5.Init(ex4.Current(), TopAbs_EDGE);
912 for(; ex5.More(); ex5.Next()) {
913 const TopoDS_Edge& ee = TopoDS::Edge(ex5.Current());
914 if(ee.IsSame(OnFirstEdge)) {
919 if(!faces.IsEmpty()) {
920 TopoDS_Face FFF = ChoiceOfFaces(faces, cc, FirstPar+bnd/50., bnd/50., Pln);
921 if(!FFF.IsNull()) FirstFace = FFF;
924 else if(PtOnFirstVertex) {
925 // Find FirstFace : face of the base shape containing OnFirstVertex
926 // meeting ChoiceOfFaces
927 TopExp_Explorer ex4, ex5;
928 ex4.Init(mySbase, TopAbs_FACE);
929 TopTools_ListOfShape faces;
932 for(; ex4.More(); ex4.Next()) {
933 const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:36 2002 fx instead of f
934 if ( !Map.Add(fx)) continue;
935 ex5.Init(ex4.Current(), TopAbs_VERTEX);
936 for(; ex5.More(); ex5.Next()) {
937 const TopoDS_Vertex& vv = TopoDS::Vertex(ex5.Current());
938 if(vv.IsSame(OnFirstVertex)) {
944 if(!faces.IsEmpty()) {
945 TopoDS_Face FFF = ChoiceOfFaces(faces, cc, FirstPar+bnd/50., bnd/50., Pln);
946 if(!FFF.IsNull()) FirstFace = FFF;
950 BRepLib_MakeVertex v(p1);
952 OnFirstFace = Standard_True;
956 if (!PtOnLastVertex) {
957 // Find LastFace : face of the base shape containing OnLastEdge
958 // meeting ChoiceOfFaces
959 TopExp_Explorer ex4, ex5;
960 ex4.Init(mySbase, TopAbs_FACE);
961 TopTools_ListOfShape faces;
964 for(; ex4.More(); ex4.Next()) {
965 const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:36 2002 fx instead of f
966 if ( !Map.Add(fx)) continue;
967 ex5.Init(ex4.Current(), TopAbs_EDGE);
968 for(; ex5.More(); ex5.Next()) {
969 const TopoDS_Edge& ee = TopoDS::Edge(ex5.Current());
970 if(ee.IsSame(OnLastEdge)) {
976 if(!faces.IsEmpty()) {
977 TopoDS_Face FFF = ChoiceOfFaces(faces, cc, LastPar-bnd/50., bnd/50., Pln);
978 if(!FFF.IsNull()) LastFace = FFF;
981 else if(PtOnLastEdge && PtOnLastVertex) {
982 // Find LastFace : face of the base shape containing OnLastVertex
983 // meeting ChoiceOfFaces
984 TopExp_Explorer ex4, ex5;
985 ex4.Init(mySbase, TopAbs_FACE);
986 TopTools_ListOfShape faces;
989 for(; ex4.More(); ex4.Next()) {
990 const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:36 2002 fx instead of f
991 if ( !Map.Add(fx)) continue;
992 ex5.Init(ex4.Current(), TopAbs_VERTEX);
993 for(; ex5.More(); ex5.Next()) {
994 const TopoDS_Vertex& vv = TopoDS::Vertex(ex5.Current());
995 if(vv.IsSame(OnLastVertex)) {
1001 if(!faces.IsEmpty()) {
1002 TopoDS_Face FFF = ChoiceOfFaces(faces, cc, LastPar-bnd/50., bnd/50., Pln);
1003 if(!FFF.IsNull()) LastFace = FFF;
1007 BRepLib_MakeVertex v(p2);
1009 OnLastFace = Standard_True;
1012 if(!FirstFace.IsNull() && !LastFace.IsNull()) {
1013 return Standard_True;
1016 //--- FirstFace or LastFace was not found
1018 if (trc) cout << " FirstFace or LastFace null" << endl;
1020 LocOpe_CSIntersector ASI(mySbase);
1021 TColGeom_SequenceOfCurve scur;
1025 Standard_Real lastpar, firstpar;
1026 if(ASI.IsDone() && ASI.NbPoints(1) >= 2) {
1027 lastpar = ASI.Point(1, ASI.NbPoints(1)).Parameter();
1028 Standard_Integer lastindex = ASI.NbPoints(1);
1030 for(Standard_Integer jj=ASI.NbPoints(1)-1; jj>=1; jj--) {
1031 Standard_Real par = ASI.Point(1,jj).Parameter();
1039 Standard_Integer firstindex = lastindex -1;
1040 firstpar = ASI.Point(1,firstindex).Parameter();
1042 if(FirstFace.IsNull()) {
1043 FirstFace = ASI.Point(1, firstindex).Face();
1044 cc->D0(firstpar, firstpoint);
1045 BRepLib_MakeVertex v1(firstpoint);
1046 FirstVertex = TopoDS::Vertex(v1.Shape());
1050 if(LastFace.IsNull()) {
1051 LastFace = ASI.Point(1, lastindex).Face();
1052 cc->D0(lastpar, lastpoint);
1053 BRepLib_MakeVertex v2(lastpoint);
1054 LastVertex = TopoDS::Vertex(v2.Shape());
1060 if (trc) cout << " Less than 2 intersection points" << endl;
1062 Data = Standard_False;
1067 if(p1.Distance(firstpoint) <= Precision::Confusion())
1068 OnFirstFace = Standard_True;
1069 else OnFirstFace = Standard_False;
1073 if(p2.Distance(lastpoint) <= Precision::Confusion())
1074 OnLastFace = Standard_True;
1075 else OnLastFace = Standard_False;
1078 if(FirstFace.IsNull() || LastFace.IsNull()) {
1080 if (trc) cout << " First or Last Faces still null" << endl;
1082 Data = Standard_False;
1086 if (trc) cout << " FirstFace and LastFace OK" << endl;
1088 Data = Standard_True;
1093 // ---The wire consists of several edges
1096 if (trc) cout << " Multiple Edges" << endl;
1098 BRepTools_WireExplorer ex(myWire);
1099 for(; ex.More(); ex.Next()) {
1100 const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
1102 Handle(Geom_Curve) Cur = BRep_Tool::Curve(E, f, l);
1103 f = f - bnd/10000; l = l +bnd/10000;
1104 Handle(Geom_TrimmedCurve) curve;
1105 curve = new Geom_TrimmedCurve(Cur, f, l, Standard_True);
1109 BRep_Tool::Pnt(TopExp::FirstVertex(E,Standard_True));
1110 gp_Pnt P2 = BRep_Tool::Pnt(TopExp::LastVertex(E,Standard_True));
1111 ex1.Init(mySbase, TopAbs_FACE);
1112 TopoDS_Vertex theVertex;
1113 TopoDS_Edge theEdge;
1114 TopoDS_Face theFace;
1115 Standard_Boolean PtOnEdge = Standard_False;
1116 Standard_Boolean PtOnVertex = Standard_False;
1118 TopoDS_Vertex OnVertex;
1119 Standard_Real intpar;
1120 for(; ex1.More(); ex1.Next()) {
1121 const TopoDS_Face& f = TopoDS::Face(ex1.Current());
1122 inter.Init(f,curve, BRep_Tool::Tolerance(f));
1123 if(!inter.More()) continue;
1124 for(; inter.More(); inter.Next()) {
1125 gp_Pnt thePoint = inter.Pnt();
1126 if(!FirstVertex.IsNull()) {
1127 gp_Pnt point = BRep_Tool::Pnt(FirstVertex);
1128 if(point.Distance(thePoint) <= BRep_Tool::Tolerance(f)) {
1132 intpar = IntPar(curve, thePoint);
1135 B.MakeVertex(theVertex, thePoint, Precision::Confusion());
1137 if(thePoint.Distance(P2) <= Precision::Confusion()) {
1142 // ---Find thepoint on an edge or a vertex of face f
1143 PtOnEdgeVertex(RevolRib, f, thePoint, FirstVertex, LastVertex,
1144 PtOnEdge,OnEdge,PtOnVertex,OnVertex);
1147 // if(!theEdge.IsNull()) break;
1149 if (FirstEdge.IsNull() && !theEdge.IsNull() &&
1150 !theFace.IsNull() && !theVertex.IsNull()) {
1151 FirstEdge = theEdge;
1152 FirstFace = theFace;
1153 FirstVertex = theVertex;
1154 PtOnFirstEdge = PtOnEdge;
1155 OnFirstEdge = OnEdge;
1156 theEdge.Nullify(); theFace.Nullify(); theVertex.Nullify();
1157 if(PtOnEdge && !PtOnVertex) {
1158 TopTools_ListOfShape faces;
1160 faces.Append(FirstFace);
1161 TopExp_Explorer ex2;
1162 ex2.Init(mySbase, TopAbs_FACE);
1163 for(; ex2.More(); ex2.Next()) {
1164 TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:16:44 2002 fx/f
1165 TopExp_Explorer ex3;
1166 ex3.Init(fx, TopAbs_EDGE);
1167 for(; ex3.More(); ex3.Next()) {
1168 const TopoDS_Edge& e = TopoDS::Edge(ex3.Current());
1169 if(e.IsSame(OnEdge) && !fx.IsSame(FirstFace)) {
1174 TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar+bnd/10., bnd/10., Pln);
1175 if(!FFF.IsNull()) FirstFace = FFF;
1177 else if(PtOnEdge && PtOnVertex) {
1178 TopTools_ListOfShape faces;
1180 faces.Append(FirstFace);
1181 TopExp_Explorer ex2;
1182 ex2.Init(mySbase, TopAbs_FACE);
1183 for(; ex2.More(); ex2.Next()) {
1184 TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:13:08 2002 fx/f
1185 TopExp_Explorer ex3;
1186 ex3.Init(fx, TopAbs_VERTEX);
1187 for(; ex3.More(); ex3.Next()) {
1188 const TopoDS_Vertex& v = TopoDS::Vertex(ex3.Current());
1189 if(v.IsSame(OnVertex) && !fx.IsSame(FirstFace)) {
1194 TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar+bnd/10., bnd/10., Pln);
1195 if(!FFF.IsNull()) FirstFace = FFF;
1197 if(!FirstEdge.IsNull() && !FirstFace.IsNull()
1198 && !FirstVertex.IsNull()) {
1199 FirstOK = Standard_True;
1202 if(LastEdge.IsNull() && !theEdge.IsNull() &&
1203 !theFace.IsNull() && !theVertex.IsNull() &&
1204 !FirstEdge.IsNull()) {
1207 LastVertex = theVertex;
1208 PtOnLastEdge = PtOnEdge;
1209 OnLastEdge = OnEdge;
1210 if(PtOnEdge && !PtOnVertex) {
1211 TopTools_ListOfShape faces;
1213 faces.Append(LastFace);
1214 TopExp_Explorer ex2;
1215 ex2.Init(mySbase, TopAbs_FACE);
1216 for(; ex2.More(); ex2.Next()) {
1217 TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:12:06 2002 fx/f
1218 TopExp_Explorer ex3;
1219 ex3.Init(fx, TopAbs_EDGE);
1220 for(; ex3.More(); ex3.Next()) {
1221 const TopoDS_Edge& e = TopoDS::Edge(ex3.Current());
1222 if(e.IsSame(OnEdge) && !fx.IsSame(LastFace)) {
1227 TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar-bnd/10.,bnd/10., Pln);
1228 if(!FFF.IsNull()) LastFace = FFF;
1230 else if(PtOnEdge && PtOnVertex) {
1231 TopTools_ListOfShape faces;
1233 faces.Append(LastFace);
1234 TopExp_Explorer ex2;
1235 ex2.Init(mySbase, TopAbs_FACE);
1236 for(; ex2.More(); ex2.Next()) {
1237 TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:11:36 2002 fx/f
1238 TopExp_Explorer ex3;
1239 ex3.Init(fx, TopAbs_VERTEX);
1240 for(; ex3.More(); ex3.Next()) {
1241 const TopoDS_Vertex& v = TopoDS::Vertex(ex3.Current());
1242 if(v.IsSame(OnVertex) && !fx.IsSame(LastFace)) {
1247 TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar-bnd/10.,bnd/10., Pln);
1248 if(!FFF.IsNull()) LastFace = FFF;
1250 if(!LastEdge.IsNull() && !LastFace.IsNull()
1251 && !LastVertex.IsNull()) {
1252 LastOK = Standard_True;
1260 if(FirstOK && LastOK) {
1261 Data = Standard_True;
1262 gp_Pnt PP1 = BRep_Tool::Pnt(TopExp::FirstVertex(FirstEdge,Standard_True));
1263 gp_Pnt PP2 = BRep_Tool::Pnt(TopExp::LastVertex(LastEdge,Standard_True));
1264 gp_Pnt p1 = BRep_Tool::Pnt(FirstVertex);
1265 gp_Pnt p2 = BRep_Tool::Pnt(LastVertex);
1266 if(p1.Distance(PP1) <= BRep_Tool::Tolerance(FirstFace)) {
1267 OnFirstFace = Standard_True;
1269 if(p2.Distance(PP2) <= BRep_Tool::Tolerance(LastFace)) {
1270 OnLastFace = Standard_True;
1272 return Standard_True;
1276 if (trc) cout << " First or Last not OK" << endl;
1278 return Standard_False;
1284 //=======================================================================
1285 //function : PtOnEdgeVertex
1286 //purpose : Find if 2 limit points of the unique edge of a wire
1287 // are on an edge or a vertex of the base shape
1288 //=======================================================================
1290 void BRepFeat_RibSlot::PtOnEdgeVertex(const Standard_Boolean RevolRib,
1291 const TopoDS_Shape& shape,
1292 const gp_Pnt& point,
1293 const TopoDS_Vertex& ,//FirstVertex,
1294 const TopoDS_Vertex& ,//LastVertex,
1295 Standard_Boolean& PtOnEdge,
1296 TopoDS_Edge& OnEdge,
1297 Standard_Boolean& PtOnVertex,
1298 TopoDS_Vertex& OnVertex)
1302 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
1303 if (trc) cout << "BRepFeat_RibSlot::PtOnEdgeVertex" << endl;
1305 Standard_Boolean TestOK;
1306 // PtOnEdge = Standard_False;
1307 // OnEdge.Nullify();
1308 // PtOnVertex = Standard_False;
1309 // OnVertex.Nullify();
1311 TopExp_Explorer EXP;
1312 EXP.Init(shape, TopAbs_EDGE);
1313 TopTools_MapOfShape Map;
1314 for(; EXP.More(); EXP.Next()) {
1315 const TopoDS_Edge& e = TopoDS::Edge(EXP.Current());
1316 if ( !Map.Add(e)) continue;
1318 if (BRep_Tool::Degenerated(e)) continue;
1320 Standard_Real fff, lll;
1321 Handle(Geom_Curve) ccc = BRep_Tool::Curve(e, fff, lll);
1323 ccc = new Geom_TrimmedCurve(ccc, fff, lll);
1325 GeomAPI_ProjectPointOnCurve proj(point, ccc);
1326 TestOK = Standard_False;
1328 if(proj.NbPoints() == 1) TestOK = Standard_True;
1331 if(proj.NbPoints() >= 1) TestOK = Standard_True;
1333 if(TestOK && proj.Distance(1) <= BRep_Tool::Tolerance(e)) {
1334 PtOnEdge = Standard_True;
1336 TopoDS_Vertex ev1 = TopExp::FirstVertex(e,Standard_True);
1337 TopoDS_Vertex ev2 = TopExp::LastVertex(e,Standard_True);
1338 gp_Pnt ep1 = BRep_Tool::Pnt(ev1);
1339 gp_Pnt ep2 = BRep_Tool::Pnt(ev2);
1340 if(point.Distance(ep1) <= BRep_Tool::Tolerance(ev1)) {
1341 PtOnVertex = Standard_True;
1345 else if(point.Distance(ep2) <= BRep_Tool::Tolerance(ev1)) {
1346 PtOnVertex = Standard_True;
1356 //=======================================================================
1357 //function : SlidingProfile
1358 //purpose : construction of the profile face in case of sliding
1359 //=======================================================================
1361 Standard_Boolean BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof,
1362 const Standard_Boolean RevolRib,
1363 const Standard_Real myTol,
1364 Standard_Integer& Concavite,
1365 const Handle(Geom_Plane)& myPln,
1366 const TopoDS_Face& BndFace,
1367 const gp_Pnt& CheckPnt,
1368 const TopoDS_Face& FirstFace,
1369 const TopoDS_Face& LastFace,
1370 const TopoDS_Vertex& ,//FirstVertex,
1371 const TopoDS_Vertex& ,//LastVertex,
1372 const TopoDS_Edge& FirstEdge,
1373 const TopoDS_Edge& LastEdge)
1377 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1378 if (trc) cout << "BRepFeat_RibSlot::SlidingProfile" << endl;
1380 Standard_Boolean ProfileOK = Standard_True;
1381 // --case of sliding : construction of the wire of the profile
1382 // --> 1 part bounding box + 1 part wire
1383 // attention to the compatibility of orientations
1386 BRepLib_MakeWire WW;
1388 FN = Normal(FirstFace, myFirstPnt);
1389 LN = Normal(LastFace, myLastPnt);
1391 // Case of the groove (cut) <> rib (fuse)
1392 // -> we are in the material
1393 // -> make everything in 2d in the working plane : easier
1400 Handle(Geom_Line) ln1, ln2;
1401 gp_Pnt Pt;//,p1, p2;
1403 ln2 = new Geom_Line(myFirstPnt, FN);
1404 ln1 = new Geom_Line(myLastPnt, LN);
1406 Handle(Geom2d_Curve) ln2d1 = GeomAPI::To2d(ln1, myPln->Pln());
1407 Handle(Geom2d_Curve) ln2d2 = GeomAPI::To2d(ln2, myPln->Pln());
1409 Geom2dAPI_InterCurveCurve inter(ln2d1, ln2d2, Precision::Confusion());
1411 Standard_Boolean TestOK = Standard_True;
1414 d1 = ln1->Position().Direction();
1415 d2 = ln2->Position().Direction();
1416 if(d1.IsOpposite(d2, myTol)) {
1417 Standard_Real par1 = ElCLib::Parameter(ln1->Lin(), myFirstPnt);
1418 Standard_Real par2 = ElCLib::Parameter(ln2->Lin(), myLastPnt);
1419 if(par1 >= myTol || par2 >= myTol) {
1420 Concavite = 2; //paralel and concave
1421 BRepLib_MakeEdge e1(myLastPnt, myFirstPnt);
1425 if(d1.IsEqual(d2, myTol)) {
1426 if(Concavite == 3) TestOK = Standard_False;
1431 if(inter.NbPoints() > 0) {
1432 gp_Pnt2d P = inter.Point(1);
1433 myPln->D0(P.X(), P.Y(), Pt);
1434 Standard_Real par = IntPar(ln1, Pt);
1435 if(par>0) Concavite = 1; //concave
1439 // ---Construction of the profile face
1440 if(Concavite == 1) {
1441 // if concave : it is possible to extend first and last edges of the wire
1442 // to the bounding box
1443 BRepLib_MakeEdge e1(myLastPnt, Pt);
1445 BRepLib_MakeEdge e2(Pt, myFirstPnt);
1448 else if(Concavite == 3) {
1449 // BndEdge : edges of intersection with the bounding box
1450 TopoDS_Edge BndEdge1, BndEdge2;
1451 // Points of intersection with the bounding box / Find Profile
1452 gp_Pnt BndPnt1, BndPnt2, LastPnt;
1453 TopExp_Explorer expl;
1454 expl.Init(BndFace, TopAbs_WIRE);
1455 BRepTools_WireExplorer explo;
1456 TopoDS_Wire BndWire = TopoDS::Wire(expl.Current());
1457 explo.Init(BndWire);
1458 for(; explo.More(); explo.Next()) {
1459 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1460 Standard_Real first, last;
1461 Handle(Geom_Curve) c = BRep_Tool::Curve(e, first, last);
1462 Handle(Geom2d_Curve) c2d = GeomAPI::To2d(c, myPln->Pln());
1463 Geom2dAPI_InterCurveCurve intcln1(ln2d1, c2d,
1464 Precision::Confusion());
1465 if(intcln1.NbPoints() > 0) {
1466 gp_Pnt2d p2d = intcln1.Point(1);
1468 myPln->D0(p2d.X(), p2d.Y(), p);
1469 Standard_Real parl = IntPar(ln1, p);
1470 Standard_Real parc = IntPar(c, p);
1471 if(parc >= first && parc <= last && parl >= 0) {
1477 Geom2dAPI_InterCurveCurve intcln2(ln2d2, c2d,
1478 Precision::Confusion());
1479 if(intcln2.NbPoints() > 0) {
1480 gp_Pnt2d p2d = intcln2.Point(1);
1482 myPln->D0(p2d.X(), p2d.Y(), p);
1483 Standard_Real parl = IntPar(ln2, p);
1484 Standard_Real parc = IntPar(c, p);
1485 if(parc >= first && parc <= last && parl >= 0) {
1490 if(!BndEdge1.IsNull() && !BndEdge2.IsNull()) break;
1493 if(BndEdge1.IsNull() || BndEdge2.IsNull()) {
1495 if (trc) cout << " Null bounding edge" << endl;
1497 ProfileOK = Standard_False;
1502 BRepLib_MakeEdge e1(myLastPnt, BndPnt1);
1505 if(BndEdge1.IsSame(BndEdge2)) {
1506 // Particular case : same edge -> simply determined path
1507 BRepLib_MakeEdge e2(BndPnt1, BndPnt2);
1509 BRepLib_MakeEdge e3(BndPnt2, myFirstPnt);
1513 explo.Init(BndWire);
1514 for(; explo.More(); explo.Next()) {
1515 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1516 if(e.IsSame(BndEdge1)) {
1518 pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True));
1519 if(pp.Distance(BndPnt1) >= BRep_Tool::Tolerance(e)) {
1522 // else { //LinearForm
1523 // gp_Pnt ppp = BRep_Tool::Pnt(TopExp::FirstVertex(e,Standard_True));
1526 BRepLib_MakeEdge e2(BndPnt1, LastPnt);
1534 if(explo.Current().IsNull()) explo.Init(BndWire);
1536 else explo.Init(BndWire);
1538 // Check if this is BndEdge2
1539 // -> if yes : it is required to turn to join FirstPnt
1540 // -> if no : add edges
1541 Standard_Boolean Fin = Standard_False;
1543 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1544 if(!e.IsSame(BndEdge2)) {
1546 pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True));
1547 BRepLib_MakeEdge ee(LastPnt, pp);
1552 // the path is closed
1553 // -> since met BndEdge2, end of borders on BndFace
1554 Fin = Standard_True;
1555 BRepLib_MakeEdge ee(LastPnt, BndPnt2);
1561 if(explo.Current().IsNull()) {
1562 explo.Init(BndWire);
1565 else explo.Init(BndWire);
1568 BRepLib_MakeEdge e3(BndPnt2, myFirstPnt);
1573 // ---Construction of the profile
1575 // Explore the wire provided by the user
1576 // BRepTools_WireExplorer : correct order - without repetition <> TopExp : non ordered
1577 BRepTools_WireExplorer EX(myWire);
1579 Standard_Real ff, ll;
1580 Handle(Geom_Curve) FirstCurve = BRep_Tool::Curve(FirstEdge, ff, ll);
1582 if(!FirstEdge.IsSame(LastEdge)) {
1583 TopoDS_Vertex FLVert = TopExp::LastVertex(FirstEdge,Standard_True);
1584 gp_Pnt FLPnt = BRep_Tool::Pnt(FLVert);
1585 BRepLib_MakeEdge ef(FirstCurve, myFirstPnt, FLPnt);
1587 for(; EX.More(); EX.Next()) {
1588 const TopoDS_Edge& E = EX.Current();
1589 if(E.IsSame(FirstEdge)) break;
1592 for(; EX.More(); EX.Next()) {
1593 const TopoDS_Edge& E = EX.Current();
1594 if(!E.IsSame(LastEdge)) {
1599 Handle(Geom_Curve) LastCurve = BRep_Tool::Curve(LastEdge, ff, ll);
1600 TopoDS_Vertex LFVert = TopExp::FirstVertex(LastEdge,Standard_True);
1601 gp_Pnt LFPnt = BRep_Tool::Pnt(LFVert);
1602 BRepLib_MakeEdge el(LastCurve, LFPnt, myLastPnt);
1606 // only one edge : particular processing
1607 Standard_Real fpar = IntPar(FirstCurve, myFirstPnt);
1608 Standard_Real lpar = IntPar(FirstCurve, myLastPnt);
1609 Handle(Geom_Curve) c;
1611 c = Handle(Geom_Curve)::DownCast(FirstCurve->Reversed());
1615 BRepLib_MakeEdge ef(c, myFirstPnt, myLastPnt);
1619 BRepLib_MakeFace f(myPln->Pln(), WW, Standard_True);
1620 TopoDS_Face fac = TopoDS::Face(f.Shape());
1622 if (!BRepAlgo::IsValid(fac)) {
1624 if (trc) cout << " Invalid Face" << endl;
1626 ProfileOK = Standard_False;
1630 if(Concavite != 3) {
1631 // if concave : face is OK
1636 // CheckPnt : point slightly inside the material side
1637 // Bndface : face/cut of the bounding box in the plane of the profile
1638 BRepTopAdaptor_FClass2d Cl(fac, BRep_Tool::Tolerance(fac));
1640 ElSLib::Parameters(myPln->Pln(), CheckPnt, u, v);
1641 gp_Pnt2d checkpnt2d(u, v);
1642 if(Cl.Perform(checkpnt2d, Standard_True) == TopAbs_OUT) {
1643 // If face is not the correct part of BndFace take the complementary
1644 //modified by NIZNHY-PKV Fri Mar 22 16:46:20 2002 f
1645 //BRepAlgo_Cut c(BndFace, fac);
1646 BRepAlgoAPI_Cut c(BndFace, fac);
1647 //modified by NIZNHY-PKV Fri Mar 22 16:46:23 2002 t
1648 TopExp_Explorer exp(c.Shape(), TopAbs_WIRE);
1649 const TopoDS_Wire& w = TopoDS::Wire(exp.Current());
1650 BRepLib_MakeFace ffx(w);//modified by NIZNHY-PKV Fri Mar 22 17:10:43 2002 ffx/ff
1651 Prof = TopoDS::Face(ffx.Shape());
1654 // If face is the correct part of BndFace : face is OK
1659 if (!BRepAlgo::IsValid(Prof)) {
1661 if (trc) cout << " Invalid Face Profile" << endl;
1663 ProfileOK = Standard_False;
1668 //=======================================================================
1669 //function : NoSlidingProfile
1670 //purpose : construction of the face profile in case of sliding
1671 //=======================================================================
1673 Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof,
1674 const Standard_Boolean RevolRib,
1675 const Standard_Real myTol,
1676 Standard_Integer& Concavite,
1677 const Handle(Geom_Plane)& myPln,
1678 const Standard_Real bnd,
1679 const TopoDS_Face& BndFace,
1680 const gp_Pnt& CheckPnt,
1681 const TopoDS_Face& ,//FirstFace,
1682 const TopoDS_Face& ,//LastFace,
1683 const TopoDS_Vertex& ,//FirstVertex,
1684 const TopoDS_Vertex& ,//LastVertex,
1685 const TopoDS_Edge& FirstEdge,
1686 const TopoDS_Edge& LastEdge,
1687 const Standard_Boolean OnFirstFace,
1688 const Standard_Boolean OnLastFace)
1692 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1693 if (trc) cout << "BRepFeat_RibSlot::NoSlidingProfile" << endl;
1695 Standard_Boolean ProfileOK = Standard_True;
1697 Standard_Real l1, f1, f2, l2;//, p;
1698 TopoDS_Vertex theFV; theFV.Nullify();
1699 gp_Pnt theFirstpoint;
1700 TopoDS_Edge theLastEdge; theLastEdge.Nullify();
1701 gp_Pnt firstpoint, lastpoint;//, pp1, pp2;
1702 gp_Vec firstvect, lastvect;
1707 TopoDS_Edge FalseFirstEdge, FalseLastEdge, FalseOnlyOne;
1709 Handle(Geom_Curve) FirstCurve = BRep_Tool::Curve(FirstEdge, f1, l1);
1710 Handle(Geom_Curve) LastCurve = BRep_Tool::Curve(LastEdge, f2, l2);
1712 Handle(Geom_Line) firstln, lastln;
1713 FirstCurve->D1(f1, firstpoint, firstvect);
1714 lastln = new Geom_Line(firstpoint, -firstvect);
1715 LastCurve->D1(l2, lastpoint, lastvect);
1716 firstln = new Geom_Line(lastpoint, lastvect);
1720 Handle(Geom2d_Curve) ln2d1 = GeomAPI::To2d(firstln, myPln->Pln());
1721 Handle(Geom2d_Curve) ln2d2 = GeomAPI::To2d(lastln, myPln->Pln());
1723 Geom2dAPI_InterCurveCurve inter(ln2d1, ln2d2, Precision::Confusion());
1725 Standard_Boolean TestOK = Standard_True;
1728 d1 = firstln->Position().Direction();
1729 d2 = lastln->Position().Direction();
1730 if(d1.IsOpposite(d2, myTol)) {
1731 Standard_Real par1 = ElCLib::Parameter(firstln->Lin(), myFirstPnt);
1732 Standard_Real par2 = ElCLib::Parameter(lastln->Lin(), myLastPnt);
1733 if(par1 >= myTol || par2 >= myTol)
1734 Concavite = 2; //parallel and concave
1736 if(d1.IsEqual(d2, myTol)) {
1737 if(Concavite == 3) TestOK = Standard_False;
1742 if(inter.NbPoints() > 0) {
1743 gp_Pnt2d P = inter.Point(1);
1744 myPln->D0(P.X(), P.Y(), Pt);
1745 Standard_Real par = IntPar(firstln, Pt);
1746 if(par>0) Concavite = 1; //concave
1750 // ---Construction of the face profile
1751 if(Concavite == 3) {
1754 FalseFirstEdge = FirstEdge;
1755 EdgeExtention(FalseFirstEdge, bnd, Standard_True);
1756 const TopoDS_Vertex& vv1 = TopExp::FirstVertex(FalseFirstEdge,Standard_True);
1757 firstpoint = BRep_Tool::Pnt(vv1);
1758 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseFirstEdge, f, l);
1759 cc->D1(f, firstpoint, firstvect);
1760 lastln = new Geom_Line(firstpoint, -firstvect);
1761 if(FirstEdge.IsSame(LastEdge)) FalseOnlyOne = FalseFirstEdge;
1762 ln2d2 = GeomAPI::To2d(lastln, myPln->Pln());
1766 if(!FirstEdge.IsSame(LastEdge)) {
1767 FalseLastEdge = LastEdge;
1770 if(FalseOnlyOne.IsNull()) FalseOnlyOne = LastEdge;
1771 FalseLastEdge = FalseOnlyOne;
1773 EdgeExtention(FalseLastEdge, bnd, Standard_False);
1774 if(FirstEdge.IsSame(LastEdge)) {
1775 FalseOnlyOne = FalseLastEdge;
1777 const TopoDS_Vertex& vv2 = TopExp::LastVertex(FalseLastEdge,Standard_True);
1778 lastpoint = BRep_Tool::Pnt(vv2);
1779 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseLastEdge, f, l);
1780 cc->D1(l, lastpoint, lastvect);
1781 lastpoint = BRep_Tool::Pnt(vv2);
1782 firstln = new Geom_Line(lastpoint, lastvect);
1783 ln2d1 = GeomAPI::To2d(firstln, myPln->Pln());
1786 TopoDS_Edge BndEdge1, BndEdge2;
1787 gp_Pnt BndPnt1, BndPnt2, LastPnt;
1788 TopExp_Explorer expl;
1789 expl.Init(BndFace, TopAbs_WIRE);
1790 BRepTools_WireExplorer explo;
1791 TopoDS_Wire BndWire = TopoDS::Wire(expl.Current());
1792 explo.Init(BndWire);
1793 for(; explo.More(); explo.Next()) {
1794 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1795 Standard_Real first, last;
1796 Handle(Geom_Curve) c = BRep_Tool::Curve(e, first, last);
1797 Handle(Geom2d_Curve) c2d = GeomAPI::To2d(c, myPln->Pln());
1798 Geom2dAPI_InterCurveCurve intcln1(ln2d1, c2d,
1799 Precision::Confusion());
1800 if(intcln1.NbPoints() > 0) {
1801 gp_Pnt2d p2d = intcln1.Point(1);
1803 myPln->D0(p2d.X(), p2d.Y(), p);
1804 Standard_Real parl = IntPar(firstln, p);
1805 Standard_Real parc = IntPar(c, p);
1806 if(parc >= first && parc <= last && parl >= 0) {
1812 Geom2dAPI_InterCurveCurve intcln2(ln2d2, c2d,
1813 Precision::Confusion());
1814 if(intcln2.NbPoints() > 0) {
1815 gp_Pnt2d p2d = intcln2.Point(1);
1817 myPln->D0(p2d.X(), p2d.Y(), p);
1818 Standard_Real parl = IntPar(lastln, p);
1819 Standard_Real parc = IntPar(c, p);
1820 if(parc >= first && parc <= last && parl >= 0) {
1825 if(!BndEdge1.IsNull() && !BndEdge2.IsNull()) break;
1828 if(BndEdge1.IsNull() || BndEdge2.IsNull()) {
1830 if (trc) cout << " Null bounding edge" << endl;
1832 ProfileOK = Standard_False;
1837 if(theLastEdge.IsNull()) {
1838 BRepLib_MakeEdge e1(lastpoint, BndPnt1);
1839 ee1 = TopoDS::Edge(e1.Shape());
1842 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1843 BRepLib_MakeVertex v2(BndPnt1);
1844 BRepLib_MakeEdge e1(v1, v2);
1845 ee1 = TopoDS::Edge(e1.Shape());
1849 if(theFV.IsNull()) {
1850 theFV = TopExp::FirstVertex(ee1,Standard_True);
1851 theFirstpoint = BRep_Tool::Pnt(theFV);
1854 if(BndEdge1.IsSame(BndEdge2)) {
1855 TopoDS_Edge ee2, ee3;
1856 if(theLastEdge.IsNull()) {
1857 BRepLib_MakeEdge e2(BndPnt1, BndPnt2);
1858 ee2 = TopoDS::Edge(e2.Shape());
1861 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1862 BRepLib_MakeVertex v2(BndPnt2);
1863 BRepLib_MakeEdge e2(v1, v2);
1864 ee2 = TopoDS::Edge(e2.Shape());
1868 if(theFV.IsNull()) {
1869 theFV = TopExp::FirstVertex(ee2,Standard_True);
1870 theFirstpoint = BRep_Tool::Pnt(theFV);
1872 if(theLastEdge.IsNull()) {
1873 BRepLib_MakeEdge e3(BndPnt2, firstpoint);
1874 ee3 = TopoDS::Edge(e3.Shape());
1877 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1878 BRepLib_MakeVertex v2(firstpoint);
1879 BRepLib_MakeEdge e3(v1, v2);
1880 ee3 = TopoDS::Edge(e3.Shape());
1884 if(theFV.IsNull()) {
1885 theFV = TopExp::FirstVertex(ee3,Standard_True);
1886 theFirstpoint = BRep_Tool::Pnt(theFV);
1890 explo.Init(BndWire);
1891 for(; explo.More(); explo.Next()) {
1892 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1893 if(e.IsSame(BndEdge1)) {
1895 pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True));
1896 if(pp.Distance(BndPnt1) > BRep_Tool::Tolerance(e)) {
1900 if(theLastEdge.IsNull()) {
1901 BRepLib_MakeEdge e2(BndPnt1, LastPnt);
1902 eee = TopoDS::Edge(e2.Shape());
1905 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1906 BRepLib_MakeVertex v2(LastPnt);
1907 BRepLib_MakeEdge e2(v1, v2);
1908 eee = TopoDS::Edge(e2.Shape());
1912 if(theFV.IsNull()) {
1913 theFV = TopExp::FirstVertex(eee,Standard_True);
1914 theFirstpoint = BRep_Tool::Pnt(theFV);
1922 if(explo.Current().IsNull()) explo.Init(BndWire);
1924 else explo.Init(BndWire);
1925 Standard_Boolean Fin = Standard_False;
1927 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1928 if(!e.IsSame(BndEdge2)) {
1930 pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True));
1932 if(theLastEdge.IsNull()) {
1933 BRepLib_MakeEdge ee(LastPnt, pp);
1934 eee1 = TopoDS::Edge(ee.Shape());
1937 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1938 BRepLib_MakeVertex v2(pp);
1939 BRepLib_MakeEdge ee(v1, v2);
1940 eee1 = TopoDS::Edge(ee.Shape());
1944 if(theFV.IsNull()) {
1945 theFV = TopExp::FirstVertex(eee1,Standard_True);
1946 theFirstpoint = BRep_Tool::Pnt(theFV);
1951 Fin = Standard_True;
1953 if(theLastEdge.IsNull()) {
1954 BRepLib_MakeEdge ee(LastPnt, BndPnt2);
1955 eee2 = TopoDS::Edge(ee.Shape());
1958 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1959 BRepLib_MakeVertex v2(BndPnt2);
1960 BRepLib_MakeEdge ee(v1, v2);
1961 eee2 = TopoDS::Edge(ee.Shape());
1965 if(theFV.IsNull()) {
1966 theFV = TopExp::FirstVertex(eee2,Standard_True);
1967 theFirstpoint = BRep_Tool::Pnt(theFV);
1973 if(explo.Current().IsNull()) {
1974 explo.Init(BndWire);
1977 else explo.Init(BndWire);
1981 if(theLastEdge.IsNull()) {
1982 BRepLib_MakeEdge e3(BndPnt2, firstpoint);
1983 eee3 = TopoDS::Edge(e3.Shape());
1986 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
1987 BRepLib_MakeVertex v2(firstpoint);
1988 BRepLib_MakeEdge e3(v1, v2);
1989 eee3 = TopoDS::Edge(e3.Shape());
1993 if(theFV.IsNull()) {
1994 theFV = TopExp::FirstVertex(eee3,Standard_True);
1995 theFirstpoint = BRep_Tool::Pnt(theFV);
2000 if(Concavite == 1) {
2002 if(theLastEdge.IsNull()) {
2003 BRepLib_MakeEdge e(Pt, firstpoint);
2004 eee4 = TopoDS::Edge(e.Shape());
2007 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2008 BRepLib_MakeVertex v2(firstpoint);
2009 BRepLib_MakeEdge e(v1, v2);
2010 eee4 = TopoDS::Edge(e.Shape());
2013 if(theFV.IsNull()) {
2014 theFV = TopExp::FirstVertex(eee4,Standard_True);
2015 theFirstpoint = BRep_Tool::Pnt(theFV);
2021 if(FirstEdge.IsSame(LastEdge)) {
2022 if(!myLFMap.IsBound(FirstEdge)) {
2023 TopTools_ListOfShape thelist;
2024 myLFMap.Bind(FirstEdge, thelist);
2026 if(OnFirstFace || OnLastFace) {
2027 TopoDS_Edge theEdge;
2029 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseOnlyOne, f, l);
2030 if(!theLastEdge.IsNull()) {
2031 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2033 const gp_Pnt& pp = BRep_Tool::
2034 Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True));
2035 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2038 else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True);
2039 BRepLib_MakeEdge e(cc, v1, v2);
2040 theEdge = TopoDS::Edge(e.Shape());
2043 const TopoDS_Vertex& v1 = TopExp::FirstVertex(FalseOnlyOne,Standard_True);
2045 const gp_Pnt& pp = BRep_Tool::
2046 Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True));
2047 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2050 else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True);
2051 BRepLib_MakeEdge e(cc, v1, v2);
2052 theEdge = TopoDS::Edge(e.Shape());
2054 myLFMap(FirstEdge).Append(theEdge);
2056 if(theFV.IsNull()) theFV = TopExp::FirstVertex(theEdge,Standard_True);
2057 theLastEdge = theEdge;
2061 Handle(Geom_Curve) cc = BRep_Tool::Curve(FirstEdge, f, l);
2062 TopoDS_Edge theEdge;
2063 if(!theLastEdge.IsNull()) {
2064 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2066 // Attention case Wire Reversed -> LastVertex without Standard_True
2067 const gp_Pnt& pp = BRep_Tool::Pnt(TopExp::LastVertex(FirstEdge));
2068 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2071 else v2 = TopExp::LastVertex(FirstEdge);
2072 BRepLib_MakeEdge e(cc, v1, v2);
2073 theEdge = TopoDS::Edge(e.Shape());
2076 const TopoDS_Vertex& v1 = TopExp::FirstVertex(FirstEdge,Standard_True);
2078 const gp_Pnt& pp = BRep_Tool::
2079 Pnt(TopExp::LastVertex(FirstEdge,Standard_True));
2080 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2083 else v2 = TopExp::LastVertex(FirstEdge,Standard_True);
2084 BRepLib_MakeEdge e(cc, v1, v2);
2085 theEdge = TopoDS::Edge(e.Shape());
2087 myLFMap(FirstEdge).Append(theEdge);
2089 if(theFV.IsNull()) theFV = TopExp::FirstVertex(theEdge,Standard_True);
2090 theLastEdge = theEdge;
2094 if(!myLFMap.IsBound(FirstEdge)) {
2095 TopTools_ListOfShape thelist1;
2096 myLFMap.Bind(FirstEdge, thelist1);
2099 TopoDS_Edge theEdge;
2101 Handle(Geom_Curve) cc = BRep_Tool::Curve(FirstEdge, f, l);
2102 if(!theLastEdge.IsNull()) {
2103 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2104 const TopoDS_Vertex& v2 = TopExp::LastVertex(FirstEdge,Standard_True);
2105 BRepLib_MakeEdge e(cc, v1, v2);
2106 theEdge = TopoDS::Edge(e.Shape());
2109 theEdge = FirstEdge;
2111 myLFMap(FirstEdge).Append(theEdge);
2113 if(theFV.IsNull()) theFV = TopExp::FirstVertex(theEdge,Standard_True);
2114 theLastEdge = theEdge;
2117 TopoDS_Edge theEdge;
2119 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseFirstEdge, f, l);
2120 if(!theLastEdge.IsNull()) {
2121 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2122 const TopoDS_Vertex& v2 = TopExp::LastVertex(FalseFirstEdge,Standard_True);
2123 BRepLib_MakeEdge e(cc, v1, v2);
2124 theEdge = TopoDS::Edge(e.Shape());
2127 theEdge = FalseFirstEdge;
2129 myLFMap(FirstEdge).Append(theEdge);
2131 if(theFV.IsNull()) theFV = TopExp::FirstVertex(theEdge,Standard_True);
2132 theLastEdge = theEdge;
2135 BRepTools_WireExplorer ex(myWire);
2136 for(; ex.More(); ex.Next()) {
2137 const TopoDS_Edge& E = ex.Current();
2138 if(E.IsSame(FirstEdge)) break;
2143 for(; ex.More(); ex.Next()) {
2144 const TopoDS_Edge& E = ex.Current();
2145 if(!E.IsSame(LastEdge)) {
2146 if(!myLFMap.IsBound(E)) {
2147 TopTools_ListOfShape thelist2;
2148 myLFMap.Bind(E, thelist2);
2152 Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l);
2153 if(!theLastEdge.IsNull()) {
2154 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2155 const TopoDS_Vertex& v2 = TopExp::LastVertex(E,Standard_True);
2156 BRepLib_MakeEdge e(cc, v1, v2);
2157 eee = TopoDS::Edge(e.Shape());
2162 myLFMap(E).Append(eee);
2164 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True);
2172 if(!FirstEdge.IsSame(LastEdge)) {
2173 const TopoDS_Edge& edg = TopoDS::Edge(ex.Current());
2174 if(!myLFMap.IsBound(edg)) {
2175 TopTools_ListOfShape thelist3;
2176 myLFMap.Bind(edg, thelist3);
2180 Handle(Geom_Curve) cc = BRep_Tool::Curve(edg, f, l);
2181 if(!theLastEdge.IsNull()) {
2182 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2184 const gp_Pnt& pp = BRep_Tool::
2185 Pnt(TopExp::LastVertex(edg,Standard_True));
2186 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2189 else v2 = TopExp::LastVertex(edg,Standard_True);
2190 BRepLib_MakeEdge e(cc, v1, v2);
2191 eee = TopoDS::Edge(e.Shape());
2194 const TopoDS_Vertex& v1 = TopExp::FirstVertex(edg,Standard_True);
2196 const gp_Pnt& pp = BRep_Tool::
2197 Pnt(TopExp::LastVertex(edg,Standard_True));
2198 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2201 else v2 = TopExp::LastVertex(edg,Standard_True);
2202 BRepLib_MakeEdge e(cc, v1, v2);
2203 eee = TopoDS::Edge(e.Shape());
2205 myLFMap(edg).Append(eee);
2207 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True);
2213 if(!myLFMap.IsBound(LastEdge)) {
2214 TopTools_ListOfShape thelist4;
2215 myLFMap.Bind(LastEdge, thelist4);
2217 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseOnlyOne, f, l);
2218 if(!theLastEdge.IsNull()) {
2219 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2221 const gp_Pnt& pp = BRep_Tool::
2222 Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True));
2223 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2226 else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True);
2227 BRepLib_MakeEdge e(cc, v1, v2);
2228 eee = TopoDS::Edge(e.Shape());
2231 const TopoDS_Vertex& v1 = TopExp::FirstVertex(FalseOnlyOne,Standard_True);
2233 const gp_Pnt& pp = BRep_Tool::
2234 Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True));
2235 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2238 else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True);
2239 BRepLib_MakeEdge e(cc, v1, v2);
2240 eee = TopoDS::Edge(e.Shape());
2242 myLFMap(LastEdge).Append(eee);
2244 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True);
2251 if(!myLFMap.IsBound(LastEdge)) {
2252 TopTools_ListOfShape thelist5;
2253 myLFMap.Bind(LastEdge, thelist5);
2255 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseLastEdge, f, l);
2256 if(!theLastEdge.IsNull()) {
2257 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2259 const gp_Pnt& pp = BRep_Tool::
2260 Pnt(TopExp::LastVertex(FalseLastEdge,Standard_True));
2261 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2264 else v2 = TopExp::LastVertex(FalseLastEdge,Standard_True);
2265 BRepLib_MakeEdge e(cc, v1, v2);
2266 eee = TopoDS::Edge(e.Shape());
2269 const TopoDS_Vertex& v1 = TopExp::FirstVertex(FalseLastEdge,Standard_True);
2271 const gp_Pnt& pp = BRep_Tool::
2272 Pnt(TopExp::LastVertex(FalseLastEdge,Standard_True));
2273 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2276 else v2 = TopExp::LastVertex(FalseLastEdge,Standard_True);
2277 BRepLib_MakeEdge e(cc, v1, v2);
2278 eee = TopoDS::Edge(e.Shape());
2280 myLFMap(LastEdge).Append(eee);
2282 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True);
2287 if(Concavite == 1) {
2289 if(theLastEdge.IsNull()) {
2290 BRepLib_MakeEdge ef(lastpoint, Pt);
2291 eef = TopoDS::Edge(ef.Shape());
2294 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2295 BRepLib_MakeVertex vv(Pt);
2296 TopoDS_Vertex v2 = TopoDS::Vertex(vv.Shape());
2297 if(!theFV.IsNull() &&
2298 Pt.Distance(theFirstpoint) <= myTol) v2 = theFV;
2300 BRepLib_MakeEdge ef(v1, v2);
2301 eef = TopoDS::Edge(ef.Shape());
2304 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eef,Standard_True);
2308 if(Concavite == 2) {
2309 BRepLib_MakeEdge ee(lastpoint, firstpoint);
2310 const TopoDS_Edge& e = ee.Edge();
2314 BRepLib_MakeFace fa(myPln->Pln(), w, Standard_True);
2315 TopoDS_Face fac = TopoDS::Face(fa.Shape());
2317 if (!BRepAlgo::IsValid(fac)) {
2319 if (trc) cout << " Invalid Face" << endl;
2321 ProfileOK = Standard_False;
2326 if(Concavite == 3) {
2327 BRepTopAdaptor_FClass2d Cl(fac, BRep_Tool::Tolerance(fac));
2329 ElSLib::Parameters(myPln->Pln(), CheckPnt, u, v);
2330 gp_Pnt2d checkpnt2d(u, v);
2331 if(Cl.Perform(checkpnt2d, Standard_True) == TopAbs_OUT) {
2332 //modified by NIZNHY-PKV Fri Mar 22 16:47:06 2002 f
2333 //BRepAlgo_Cut c(BndFace, fac);
2334 BRepAlgoAPI_Cut c(BndFace, fac);
2335 //modified by NIZNHY-PKV Fri Mar 22 16:47:09 2002 t
2336 TopExp_Explorer exp(c.Shape(), TopAbs_WIRE);
2337 //modified by NIZNHY-PKV Fri Mar 22 16:47:23 2002 f
2338 //UpdateDescendants(c.Builder(), c.Shape(), Standard_False);
2339 UpdateDescendants(c, c.Shape(), Standard_False);
2340 //modified by NIZNHY-PKV Fri Mar 22 16:47:28 2002 t
2341 const TopoDS_Wire& ww = TopoDS::Wire(exp.Current());//modified by NIZNHY-PKV Fri Mar 22 17:10:16 2002 ww/w
2342 BRepLib_MakeFace ff(ww);
2343 Prof = TopoDS::Face(ff.Shape());
2353 if (!BRepAlgo::IsValid(Prof)) {
2355 if (trc) cout << " Invalid Face Profile" << endl;
2357 ProfileOK = Standard_False;
2363 //modified by NIZNHY-PKV Thu Mar 21 18:43:18 2002 f
2364 //=======================================================================
2365 //function : UpdateDescendants
2367 //=======================================================================
2368 void BRepFeat_RibSlot::UpdateDescendants(const BRepAlgoAPI_BooleanOperation& aBOP,
2369 const TopoDS_Shape& S,
2370 const Standard_Boolean SkipFace)
2372 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm;
2373 TopTools_ListIteratorOfListOfShape it,it2;
2374 TopTools_MapIteratorOfMapOfShape itm;
2375 TopExp_Explorer exp;
2377 for (itdm.Initialize(myMap);itdm.More();itdm.Next()) {
2378 const TopoDS_Shape& orig = itdm.Key();
2379 if (SkipFace && orig.ShapeType() == TopAbs_FACE) {
2382 TopTools_MapOfShape newdsc;
2384 //if (itdm.Value().IsEmpty()) {myMap.ChangeFind(orig).Append(orig);}
2386 for (it.Initialize(itdm.Value());it.More();it.Next()) {
2387 const TopoDS_Shape& sh = it.Value();
2388 if(sh.ShapeType() != TopAbs_FACE) continue;
2389 const TopoDS_Face& fdsc = TopoDS::Face(it.Value());
2390 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
2391 if (exp.Current().IsSame(fdsc)) { // preserved
2397 BRepAlgoAPI_BooleanOperation* pBOP=(BRepAlgoAPI_BooleanOperation*)&aBOP;
2398 const TopTools_ListOfShape& aLM=pBOP->Modified(fdsc);
2399 it2.Initialize(aLM);
2400 for (; it2.More(); it2.Next()) {
2401 const TopoDS_Shape& aS=it2.Value();
2407 myMap.ChangeFind(orig).Clear();
2408 for (itm.Initialize(newdsc); itm.More(); itm.Next()) {
2409 // check the belonging to the shape...
2410 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
2411 if (exp.Current().IsSame(itm.Key())) {
2412 // const TopoDS_Shape& sh = itm.Key();
2413 myMap.ChangeFind(orig).Append(itm.Key());
2420 //modified by NIZNHY-PKV Thu Mar 21 18:43:36 2002 t