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_Builder.hxx>
28 #include <LocOpe_Gluer.hxx>
29 #include <LocOpe_FindEdges.hxx>
30 #include <LocOpe_CSIntersector.hxx>
31 #include <LocOpe_PntFace.hxx>
35 #include <TopExp_Explorer.hxx>
39 #include <TopoDS_Shape.hxx>
40 #include <TopoDS_Face.hxx>
42 #include <TopTools_ListOfShape.hxx>
43 #include <TopTools_ListIteratorOfListOfShape.hxx>
44 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
45 #include <TopTools_MapIteratorOfMapOfShape.hxx>
46 #include <TopTools_MapOfShape.hxx>
47 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
49 #include <TopOpeBRepBuild_HBuilder.hxx>
51 #include <BRep_Tool.hxx>
53 #include <BRepAlgo.hxx>
54 //modified by NIZNHY-PKV Fri Mar 22 16:48:13 2002 f
55 //#include <BRepAlgo_Cut.hxx>
56 //#include <BRepAlgo_Fuse.hxx>
57 #include <BRepAlgoAPI_Cut.hxx>
58 #include <BRepAlgoAPI_Fuse.hxx>
59 //modified by NIZNHY-PKV Fri Mar 22 16:48:16 2002 t
61 #include <BRepAdaptor_Surface.hxx>
62 #include <BRepBndLib.hxx>
63 #include <BRepIntCurveSurface_Inter.hxx>
64 #include <BRepTools_WireExplorer.hxx>
65 #include <BRepTopAdaptor_FClass2d.hxx>
66 #include <BRepClass3d_SolidClassifier.hxx>
68 #include <BRepLib_MakeVertex.hxx>
69 #include <BRepLib_MakeEdge.hxx>
70 #include <BRepLib_MakeWire.hxx>
71 #include <BRepLib_MakeFace.hxx>
72 #include <BRepLib.hxx>
74 #include <Bnd_Box.hxx>
76 #include <Standard_ConstructionError.hxx>
77 #include <Standard_NoSuchObject.hxx>
79 #include <GeomLib.hxx>
80 #include <GeomAdaptor_Curve.hxx>
82 #include <Geom_Curve.hxx>
83 #include <Geom_TrimmedCurve.hxx>
84 #include <Geom_Line.hxx>
85 #include <Geom_Circle.hxx>
86 #include <Geom_Plane.hxx>
87 #include <Geom_Ellipse.hxx>
88 #include <Geom_Parabola.hxx>
89 #include <Geom_Hyperbola.hxx>
91 #include <Geom2dAPI_InterCurveCurve.hxx>
92 #include <GeomAPI.hxx>
93 #include <GeomAPI_ProjectPointOnCurve.hxx>
102 #include <ElCLib.hxx>
103 #include <ElSLib.hxx>
106 #include <Precision.hxx>
108 #include <TColGeom_SequenceOfCurve.hxx>
112 Standard_IMPORT Standard_Boolean BRepFeat_GettraceFEAT();
113 Standard_IMPORT 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 TopTools_MapOfShape M;
150 TopTools_ListOfShape LShape;
151 TopTools_ListOfShape LTool;
153 if (!mySUntil.IsNull()) {
154 UntilInShape = Standard_True;
155 for (exp2.Init(mySUntil,TopAbs_FACE); exp2.More(); exp2.Next()) {
156 const TopoDS_Shape& funtil = exp2.Current();
157 for (exp.Init(mySbase,TopAbs_FACE); exp.More(); exp.Next()) {
158 if (exp.Current().IsSame(funtil)) {
163 UntilInShape = Standard_False;
168 LShape.Append(funtil);
174 TopTools_ListIteratorOfListOfShape it,it2;
175 TopTools_DataMapIteratorOfDataMapOfShapeShape itm;
176 //Standard_Integer sens = 0;
178 for (itm.Initialize(myGluedF);itm.More();itm.Next()) {
183 if(!mySUntil.IsNull()) {
184 exp.Init(mySUntil, TopAbs_FACE);
185 for(; exp.More(); exp.Next()) {
186 if(M.Add(exp.Current()))
187 LShape.Append(exp.Current());
191 LocOpe_Gluer theGlue;
196 Standard_Boolean Collage = Standard_True;
199 LocOpe_FindEdges theFE;
200 TopTools_DataMapOfShapeListOfShape locmap;
201 theGlue.Init(mySbase,myGShape);
202 for (itm.Initialize(myGluedF); itm.More();itm.Next()) {
203 const TopoDS_Face& glface = TopoDS::Face(itm.Key());
204 const TopoDS_Face& fac = TopoDS::Face(myGluedF(glface));
205 for (exp.Init(myGShape,TopAbs_FACE); exp.More(); exp.Next()) {
206 if (exp.Current().IsSame(glface)) {
211 Collage = BRepFeat::IsInside(glface, fac);
214 ChangeOpe = Standard_True;
218 theGlue.Bind(glface, fac);
219 theFE.Set(glface, fac);
220 for (theFE.InitIterator(); theFE.More();theFE.Next()) {
221 theGlue.Bind(theFE.EdgeFrom(),theFE.EdgeTo());
227 LocOpe_Operation ope = theGlue.OpeType();
228 if (ope == LocOpe_INVALID ||
229 (myFuse && ope != LocOpe_FUSE) ||
230 (!myFuse && ope != LocOpe_CUT) ||
233 ChangeOpe = Standard_True;
235 cout << "Passage to topological operations" << endl;
240 // gluing is always applicable
244 if (theGlue.IsDone()) {
245 UpdateDescendants(theGlue);
246 myNewEdges = theGlue.Edges();
247 myTgtEdges = theGlue.TgtEdges();
248 //TopTools_ListIteratorOfListOfShape itt1;
249 if (!LShape.IsEmpty()) {
250 LocOpe_Builder theTOpe(theGlue.ResultingShape());
251 // Use of LTool is temporary
252 for (it2.Initialize(LShape);it2.More();it2.Next()) {
253 const TopTools_ListOfShape& ldf = myMap(it2.Value());
254 if (ldf.Extent() == 1 && ldf.First().IsSame(it2.Value())) {
255 LTool.Append(it2.Value());
258 for (it.Initialize(ldf);it.More();it.Next()) {
259 if (M.Add(it.Value())) {
260 LTool.Append(it.Value());
268 for (exp.Init(theGlue.GluedShape(),TopAbs_FACE);
269 exp.More();exp.Next()) {
270 for (it.Initialize(theGlue.DescendantFaces
271 (TopoDS::Face(exp.Current())));
272 it.More();it.Next()) {
273 if (M.Add(it.Value())) {
274 LTool.Append(it.Value());
279 if (!(LShape .IsEmpty() || LTool.IsEmpty())) {
280 //TopTools_ListIteratorOfListOfShape it1(LShape);
281 //TopTools_ListIteratorOfListOfShape it2(LTool);
282 theTOpe.Perform(LShape,LTool,myFuse);
283 theTOpe.PerformResult();
284 TopTools_ListOfShape TOpeNewEdges, TOpeTgtEdges;
285 TOpeNewEdges = theTOpe.Edges();
286 TOpeTgtEdges = theTOpe.TgtEdges();
287 TopTools_ListIteratorOfListOfShape itt1, itt2;
288 itt1.Initialize(TOpeNewEdges);
289 itt2.Initialize(myNewEdges);
290 for(; itt1.More(); itt1.Next()) {
291 TopoDS_Edge e1 = TopoDS::Edge(itt1.Value());
292 Standard_Boolean Adde1 = Standard_True;
293 for(; itt2.More(); itt2.Next()) {
294 TopoDS_Edge e2 = TopoDS::Edge(itt2.Value());
296 Adde1 = Standard_False;
301 myNewEdges.Append(e1);
304 itt1.Initialize(TOpeTgtEdges);
305 itt2.Initialize(myTgtEdges);
306 for(; itt1.More(); itt1.Next()) {
307 TopoDS_Edge e1 = TopoDS::Edge(itt1.Value());
308 Standard_Boolean Adde1 = Standard_True;
309 for(; itt2.More(); itt2.Next()) {
310 TopoDS_Edge e2 = TopoDS::Edge(itt2.Value());
312 Adde1 = Standard_False;
317 myTgtEdges.Append(e1);
321 if (theTOpe.IsDone()) {
323 if (BRepAlgo::IsValid(theTOpe.ResultingShape())) {
325 myShape = theTOpe.ResultingShape();
326 // UpdateDescendants(theTOpe.Builder(),myShape);
327 UpdateDescendants(theTOpe.History(),myShape);
330 myShape = theGlue.ResultingShape();
335 ChangeOpe = Standard_True;
337 cout << "Passage to. topologic operation" << endl;
344 myShape = theGlue.ResultingShape();
349 myShape = theGlue.ResultingShape();
351 BRepLib::SameParameter(myShape, 1.e-7, Standard_True);
357 ChangeOpe = Standard_True;
359 cout << "Passage to topologic operation" << endl;
365 // case without gluing
368 // Attention, if gluing fails, myGShape with gluing is not correct
370 myStatusError = BRepFeat_NoGluer;
375 TopoDS_Shape theGShape = myGShape;
377 for (itm.Initialize(myGluedF); itm.More();itm.Next()) {
378 if(M.Add(itm.Value()))
379 LShape.Append(itm.Value());
385 if(!mySUntil.IsNull()) {
386 TopExp_Explorer ex(mySUntil, TopAbs_FACE);
387 for(; ex.More(); ex.Next()) {
388 const TopoDS_Face& fac = TopoDS::Face(ex.Current());
394 // LocOpe_Builder theTOpe(mySbase);
395 LocOpe_Builder theTOpe(mySbase, theGShape);
397 //TopTools_ListIteratorOfListOfShape it3;
398 //Standard_Real pmin, pmax, pbmin, pbmax;
399 //Standard_Integer flag1 = Standard_True;
401 // theTOpe.Perform(theGShape,LShape,myFuse);
402 if(!theGShape.IsNull()) {
403 TopExp_Explorer ex(theGShape, TopAbs_FACE);
404 for(; ex.More(); ex.Next()) {
405 const TopoDS_Face& fac = TopoDS::Face(ex.Current());
409 theTOpe.Perform(LShape, LTool, myFuse);
411 theTOpe.BuildPartsOfTool();
412 it.Initialize(theTOpe.PartsOfTool());
414 if (it.More() && myPerfSelection != BRepFeat_NoSelection) {
415 Standard_Real toler= (BRep_Tool::Tolerance(myPbase))*2;
416 BRepClass3d_SolidClassifier oussa;
418 TopoDS_Solid thePartsOfTool;
420 BB.MakeSolid(thePartsOfTool);
422 for(; it.More(); it.Next()) {
423 oussa.Load(it.Value());
424 oussa.Perform(myFirstPnt, toler);
425 TopAbs_State sp1=oussa.State();
426 oussa.Perform(myLastPnt, toler);
427 TopAbs_State sp2=oussa.State();
428 // if (sp1 != TopAbs_ON || sp2 != TopAbs_ON) {
429 if (sp1 == TopAbs_OUT || sp2 == TopAbs_OUT) {
430 theTOpe.RemovePart(it.Value());
433 const TopoDS_Shape& S = it.Value();
434 B.Add(thePartsOfTool,S);
440 /* TopTools_MapOfShape newdsc;
441 if(!mySUntil.IsNull()) {
442 TopTools_MapOfShape toTake;
444 const Handle(TopOpeBRepBuild_HBuilder) B = theTOpe.Builder();
446 TopExp_Explorer ex(mySUntil, TopAbs_FACE);
447 for(; ex.More(); ex.Next()) {
448 fdsc = TopoDS::Face(ex.Current());
450 if(B->IsSplit(fdsc, TopAbs_OUT)) {
451 for (it2.Initialize(B->Splits(fdsc,TopAbs_OUT));
452 it2.More();it2.Next()) {
453 newdsc.Add(it2.Value());
456 if (B->IsSplit(fdsc, TopAbs_IN)) {
457 for (it2.Initialize(B->Splits(fdsc,TopAbs_IN));
458 it2.More();it2.Next()) {
459 newdsc.Add(it2.Value());
462 if (B->IsSplit(fdsc, TopAbs_ON)) {
463 for (it2.Initialize(B->Splits(fdsc,TopAbs_ON));
464 it2.More();it2.Next()) {
465 newdsc.Add(it2.Value());
468 if (B->IsMerged(fdsc, TopAbs_OUT)) {
469 for (it2.Initialize(B->Merged(fdsc,TopAbs_OUT));
470 it2.More();it2.Next()) {
471 newdsc.Add(it2.Value());
474 if (B->IsMerged(fdsc, TopAbs_IN)) {
475 for (it2.Initialize(B->Merged(fdsc,TopAbs_IN));
476 it2.More();it2.Next()) {
477 newdsc.Add(it2.Value());
480 if (B->IsMerged(fdsc, TopAbs_ON)) {
481 for (it2.Initialize(B->Merged(fdsc,TopAbs_ON));
482 it2.More();it2.Next()) {
483 newdsc.Add(it2.Value());
488 Standard_Boolean removeflag;
489 for(; it.More(); it.Next()) {
490 removeflag = Standard_True;
491 TopExp_Explorer ex1(it.Value(), TopAbs_FACE);
492 for(; ex1.More(); ex1.Next()) {
493 const TopoDS_Face& f = TopoDS::Face(ex1.Current());
494 if (newdsc.Contains(f)) {
495 removeflag = Standard_False;
500 theTOpe.RemovePart(it.Value());
507 theTOpe.PerformResult();
508 if (theTOpe.IsDone()) {
510 myShape = theTOpe.ResultingShape();
511 // UpdateDescendants(theTOpe.Builder(),myShape);
512 UpdateDescendants(theTOpe.History(),myShape);
513 myNewEdges = theTOpe.Edges();
514 if(!theTOpe.TgtEdges().IsEmpty()) {
515 myTgtEdges = theTOpe.TgtEdges();
519 // if (theTOpe.IsInvDone()) {
520 // myStatusError = BRepFeat_LocOpeNotDone;
523 myStatusError = BRepFeat_LocOpeInvNotDone;// last resort (attention to new and tangent edges)
525 if (trc) cout << " Parts of Tool : direct Ope. Top." << endl;
528 //modified by NIZNHY-PKV Fri Mar 22 16:45:07 2002 f
529 //BRepAlgo_Fuse f(mySbase, thePartsOfTool);
530 //myShape = f.Shape();
531 //UpdateDescendants(f.Builder(), myShape, Standard_False);
532 BRepAlgoAPI_Fuse f(mySbase, thePartsOfTool);
534 UpdateDescendants(f, myShape, Standard_False);
535 //modified by NIZNHY-PKV Fri Mar 22 16:45:16 2002 t
540 else if(myFuse == 0) {
541 //modified by NIZNHY-PKV Fri Mar 22 16:45:47 2002 f
542 //BRepAlgo_Cut c(mySbase, thePartsOfTool);
543 //myShape = c.Shape();
544 //UpdateDescendants(c.Builder(), myShape, Standard_False);
545 BRepAlgoAPI_Cut c(mySbase, thePartsOfTool);
547 UpdateDescendants(c, myShape, Standard_False);
548 //modified by NIZNHY-PKV Fri Mar 22 16:45:51 2002 t
561 //=======================================================================
562 //function : IsDeleted
564 //=======================================================================
566 Standard_Boolean BRepFeat_RibSlot::IsDeleted(const TopoDS_Shape& F)
568 return (myMap(F).IsEmpty());
572 //=======================================================================
573 //function : Modified
575 //=======================================================================
577 const TopTools_ListOfShape& BRepFeat_RibSlot::Modified
578 (const TopoDS_Shape& F)
581 Standard_Boolean trc = BRepFeat_GettraceFEAT();
582 if (trc) cout << "BRepFeat_RibSlot::Modified" << endl;
584 if (myMap.IsBound(F)) {
585 static TopTools_ListOfShape list;
587 TopTools_ListIteratorOfListOfShape ite(myMap(F));
588 for(; ite.More(); ite.Next()) {
589 const TopoDS_Shape& sh = ite.Value();
595 return myGenerated; // empty list
598 //=======================================================================
599 //function : Generated
601 //=======================================================================
603 const TopTools_ListOfShape& BRepFeat_RibSlot::Generated
604 (const TopoDS_Shape& S)
607 Standard_Boolean trc = BRepFeat_GettraceFEAT();
608 if (trc) cout << "BRepFeat_RibSlot::Generated" << endl;
610 if(S.ShapeType() != TopAbs_FACE) {
612 if(myLFMap.IsEmpty() || !myLFMap.IsBound(S)) {
613 if (myMap.IsBound(S)) { // check if filter on face or not
614 static TopTools_ListOfShape list;
616 TopTools_ListIteratorOfListOfShape ite(myMap(S));
617 for(; ite.More(); ite.Next()) {
618 const TopoDS_Shape& sh = ite.Value();
624 else return myGenerated;
628 TopTools_ListIteratorOfListOfShape it(myLFMap(S));
629 static TopTools_ListOfShape list;
631 for(; it.More(); it.Next()) {
632 if(myMap.IsBound(it.Value())) {
633 TopTools_ListIteratorOfListOfShape it1(myMap(it.Value()));
634 for(; it1.More(); it1.Next()) {
635 const TopoDS_Shape& sh = it1.Value();
644 else return myGenerated;
648 //=======================================================================
649 //function : UpdateDescendants
651 //=======================================================================
653 void BRepFeat_RibSlot::UpdateDescendants(const LocOpe_Gluer& G)
655 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm;
656 TopTools_ListIteratorOfListOfShape it,it2;
657 TopTools_MapIteratorOfMapOfShape itm;
659 for (itdm.Initialize(myMap);itdm.More();itdm.Next()) {
660 const TopoDS_Shape& orig = itdm.Key();
661 TopTools_MapOfShape newdsc;
662 for (it.Initialize(itdm.Value());it.More();it.Next()) {
663 const TopoDS_Face& fdsc = TopoDS::Face(it.Value());
664 for (it2.Initialize(G.DescendantFaces(fdsc));
665 it2.More();it2.Next()) {
666 newdsc.Add(it2.Value());
669 myMap.ChangeFind(orig).Clear();
670 for (itm.Initialize(newdsc);itm.More();itm.Next()) {
671 myMap.ChangeFind(orig).Append(itm.Key());
676 //=======================================================================
677 //function : UpdateDescendants
679 //=======================================================================
680 void BRepFeat_RibSlot::UpdateDescendants (const Handle(TopOpeBRepBuild_HBuilder)& B,
681 const TopoDS_Shape& S,
682 const Standard_Boolean SkipFace)
684 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm;
685 TopTools_ListIteratorOfListOfShape it,it2;
686 TopTools_MapIteratorOfMapOfShape itm;
689 for (itdm.Initialize(myMap);itdm.More();itdm.Next()) {
690 const TopoDS_Shape& orig = itdm.Key();
691 if (SkipFace && orig.ShapeType() == TopAbs_FACE) {
694 TopTools_MapOfShape newdsc;
695 for (it.Initialize(itdm.Value());it.More();it.Next()) {
696 const TopoDS_Shape& sh = it.Value();
697 if(sh.ShapeType() != TopAbs_FACE) continue;
698 const TopoDS_Face& fdsc = TopoDS::Face(it.Value());
699 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
700 if (exp.Current().IsSame(fdsc)) { // preserved
706 if (B->IsSplit(fdsc, TopAbs_OUT)) {
707 for (it2.Initialize(B->Splits(fdsc,TopAbs_OUT));
708 it2.More();it2.Next()) {
709 newdsc.Add(it2.Value());
712 if (B->IsSplit(fdsc, TopAbs_IN)) {
713 for (it2.Initialize(B->Splits(fdsc,TopAbs_IN));
714 it2.More();it2.Next()) {
715 newdsc.Add(it2.Value());
718 if (B->IsSplit(fdsc, TopAbs_ON)) {
719 for (it2.Initialize(B->Splits(fdsc,TopAbs_ON));
720 it2.More();it2.Next()) {
721 newdsc.Add(it2.Value());
724 if (B->IsMerged(fdsc, TopAbs_OUT)) {
725 for (it2.Initialize(B->Merged(fdsc,TopAbs_OUT));
726 it2.More();it2.Next()) {
727 newdsc.Add(it2.Value());
730 if (B->IsMerged(fdsc, TopAbs_IN)) {
731 for (it2.Initialize(B->Merged(fdsc,TopAbs_IN));
732 it2.More();it2.Next()) {
733 newdsc.Add(it2.Value());
736 if (B->IsMerged(fdsc, TopAbs_ON)) {
737 for (it2.Initialize(B->Merged(fdsc,TopAbs_ON));
738 it2.More();it2.Next()) {
739 newdsc.Add(it2.Value());
744 myMap.ChangeFind(orig).Clear();
745 for (itm.Initialize(newdsc); itm.More(); itm.Next()) {
746 // check the belonging to the shape...
747 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
748 if (exp.Current().IsSame(itm.Key())) {
749 myMap.ChangeFind(orig).Append(itm.Key());
759 //=======================================================================
760 //function : FirstShape
762 //=======================================================================
764 const TopTools_ListOfShape& BRepFeat_RibSlot::FirstShape() const
766 if (!myFShape.IsNull()) {
767 return myMap(myFShape);
769 return myGenerated; // empty list
773 //=======================================================================
774 //function : LastShape
776 //=======================================================================
778 const TopTools_ListOfShape& BRepFeat_RibSlot::LastShape() const
780 if (!myLShape.IsNull()) {
781 return myMap(myLShape);
783 return myGenerated; // empty list
786 //=======================================================================
787 //function : FacesForDraft
789 //=======================================================================
791 const TopTools_ListOfShape& BRepFeat_RibSlot::FacesForDraft() const
793 return myFacesForDraft;
797 //=======================================================================
798 //function : NewEdges
800 //=======================================================================
802 const TopTools_ListOfShape& BRepFeat_RibSlot::NewEdges() const
807 //=======================================================================
808 //function : TgtEdges
810 //=======================================================================
812 const TopTools_ListOfShape& BRepFeat_RibSlot::TgtEdges() const
818 //=======================================================================
819 //function : CurrentStatusError
821 //=======================================================================
823 BRepFeat_StatusError BRepFeat_RibSlot::CurrentStatusError() const
825 return myStatusError;
829 //=======================================================================
830 //function : CheckPoint
831 //purpose : Proofing point material side (side of extrusion)
832 //=======================================================================
834 gp_Pnt BRepFeat_RibSlot::CheckPoint(const TopoDS_Edge& e,
835 const Standard_Real ,//bnd,
836 const Handle(Geom_Plane)& Pln)
840 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
841 if (trc) cout << "BRepFeat_RibSlot::CheckPoint" << endl;
843 // Vector product : normal to plane X direction Wire
844 // -> gives the material side
845 // Proofing point somewhat inside the material side
847 Handle(Geom_Curve) cc = BRep_Tool::Curve(e, f, l);
849 gp_Vec tgt; gp_Pnt pp;
850 Standard_Real par = ( f + l) / 2.;
852 cc->D1(par, pp, tgt);
854 if ( e.Orientation() == TopAbs_REVERSED) tgt.Reverse();
856 gp_Vec D = -tgt.Crossed(Pln->Pln().Position().Direction())/10.;
864 //=======================================================================
866 //purpose : calculate the normal to a face in a point
867 //=======================================================================
869 gp_Dir BRepFeat_RibSlot::Normal(const TopoDS_Face& F,const gp_Pnt& P)
873 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
874 if (trc) cout << "BRepFeat_RibSlot::Normal" << endl;
879 BRepAdaptor_Surface AS(F, Standard_True);
881 switch ( AS.GetType()) {
884 ElSLib::Parameters(AS.Plane(),P,U,V); break;
886 case GeomAbs_Cylinder:
887 ElSLib::Parameters(AS.Cylinder(),P,U,V); break;
890 ElSLib::Parameters(AS.Cone(),P,U,V); break;
893 ElSLib::Parameters(AS.Torus(),P,U,V); break;
897 return gp_Dir(1., 0., 0.);
903 AS.D1(U, V, pt, D1U, D1V);
905 CSLib_DerivativeStatus St;
906 CSLib::Normal(D1U, D1V, Precision::Confusion(), St, N);
907 if(F.Orientation() == TopAbs_FORWARD) N.Reverse();
911 //=======================================================================
913 //purpose : calculate the parameter of a point on a curve
914 //=======================================================================
916 Standard_Real BRepFeat_RibSlot::IntPar(const Handle(Geom_Curve)& C,
920 if ( C.IsNull()) return 0.;
922 GeomAdaptor_Curve AC(C);
925 switch ( AC.GetType()) {
928 U = ElCLib::Parameter(AC.Line(),P); break;
931 U = ElCLib::Parameter(AC.Circle(),P); break;
933 case GeomAbs_Ellipse:
934 U = ElCLib::Parameter(AC.Ellipse(),P); break;
936 case GeomAbs_Hyperbola:
937 U = ElCLib::Parameter(AC.Hyperbola(),P); break;
939 case GeomAbs_Parabola:
940 U = ElCLib::Parameter(AC.Parabola(),P); break;
950 //=======================================================================
951 //function : EdgeExtention
952 //purpose : extention of a edge by tangence
953 //=======================================================================
955 void BRepFeat_RibSlot::EdgeExtention(TopoDS_Edge& e,
956 const Standard_Real bnd,
957 const Standard_Boolean FirstLast)
960 Standard_Boolean trc = BRepFeat_GettraceFEAT();
961 if (trc) cout << "BRepFeat_RibSlot::EdgeExtention" << endl;
964 Handle(Geom_Curve) cu = BRep_Tool::Curve(e, f, l);
965 Handle(Geom_TrimmedCurve) C =
966 new Geom_TrimmedCurve(cu, f, l);
970 if(cu->DynamicType() == STANDARD_TYPE(Geom_Line) ||
971 cu->DynamicType() == STANDARD_TYPE(Geom_Circle) ||
972 cu->DynamicType() == STANDARD_TYPE(Geom_Ellipse) ||
973 cu->DynamicType() == STANDARD_TYPE(Geom_Hyperbola) ||
974 cu->DynamicType() == STANDARD_TYPE(Geom_Parabola)) {
976 BRepLib_MakeEdge Edg(cu, f-bnd/10., l);
977 E = TopoDS::Edge(Edg.Shape());
980 BRepLib_MakeEdge Edg(cu, f, l+bnd/10.);
981 E = TopoDS::Edge(Edg.Shape());
985 Handle(Geom_Line) ln;
991 ln = new Geom_Line(pnt, -vct);
992 ln->D0(bnd/1000., Pt);
993 GeomLib::ExtendCurveToPoint(C, Pt, GeomAbs_G1, Standard_False);
994 BRepLib_MakeEdge Edg(C, Pt, BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True)));
995 E = TopoDS::Edge(Edg.Shape());
999 ln = new Geom_Line(pnt, vct);
1000 ln->D0(bnd/1000., Pt);
1001 GeomLib::ExtendCurveToPoint(C, Pt, GeomAbs_G1, Standard_True);
1002 BRepLib_MakeEdge Edg(C, BRep_Tool::Pnt(TopExp::FirstVertex(e,Standard_True)), Pt);
1003 E = TopoDS::Edge(Edg.Shape());
1010 //=======================================================================
1011 //function : ChoiceOfFaces
1012 //purpose : choose face of support in case of support on an edge
1013 //=======================================================================
1015 TopoDS_Face BRepFeat_RibSlot::ChoiceOfFaces(TopTools_ListOfShape& faces,
1016 const Handle(Geom_Curve)& cc,
1017 const Standard_Real par,
1018 const Standard_Real ,//bnd,
1019 const Handle(Geom_Plane)& Pln)
1023 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
1024 if (trc) cout << "BRepFeat_RibSlot::ChoiceOfFaces" << endl;
1031 cc->D1(par, pp, tgt);
1033 Handle(Geom_Line) l1 = new Geom_Line(pp, tgt);
1035 TColGeom_SequenceOfCurve scur;
1036 Standard_Integer Counter = 0;
1039 gp_Ax1 Axe(pp, Pln->Position().Direction());
1040 for ( Standard_Integer i = 1; i <=8; i++) {
1041 Handle(Geom_Curve) L =
1042 Handle(Geom_Curve)::DownCast(l1->Rotated(Axe, i*M_PI/9.));
1047 TopTools_ListIteratorOfListOfShape it;
1048 it.Initialize(faces);
1049 Standard_Real Par = RealLast();
1050 for(; it.More(); it.Next()) {
1051 const TopoDS_Face& f = TopoDS::Face(it.Value());
1052 LocOpe_CSIntersector ASI(f);
1054 if(!ASI.IsDone()) continue;
1055 for(Standard_Integer jj = 1; jj<=Counter; jj++) {
1056 if(ASI.NbPoints(jj) >= 1) {
1057 Standard_Real app = ASI.Point(jj,1).Parameter();//modified by NIZNHY-PKV Fri Mar 22 17:05:23 2002 pp
1058 if(app >= 0 && app < Par) {
1070 //=======================================================================
1071 //function : HeightMax
1072 //purpose : Calculate the height of the prism following the parameters of a bounding box
1073 //=======================================================================
1075 Standard_Real BRepFeat_RibSlot::HeightMax(const TopoDS_Shape& theSbase,
1076 const TopoDS_Shape& theSUntil,
1081 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
1082 if (trc) cout << "BRepFeat_RibSlot::HeightMax" << endl;
1085 BRepBndLib::Add(theSbase,Box);
1086 if(!theSUntil.IsNull()) {
1087 BRepBndLib::Add(theSUntil,Box);
1089 Standard_Real c[6], bnd;
1090 Box.Get(c[0],c[2],c[4],c[1],c[3],c[5]);
1092 for(Standard_Integer i = 0 ; i < 6; i++) {
1093 if(c[i] > bnd) bnd = c[i];
1095 p1.SetCoord(c[0]-2.*bnd, c[1]-2.*bnd, c[2]-2.*bnd);
1096 p2.SetCoord(c[3]+2.*bnd, c[4]+2.*bnd, c[5]+2.*bnd);
1100 //=======================================================================
1101 //function : ExtremeFaces
1102 //purpose : Calculate the base faces of the rib
1103 //=======================================================================
1105 Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib,
1106 const Standard_Real bnd,
1107 const Handle(Geom_Plane)& Pln,
1108 TopoDS_Edge& FirstEdge,
1109 TopoDS_Edge& LastEdge,
1110 TopoDS_Face& FirstFace,
1111 TopoDS_Face& LastFace,
1112 TopoDS_Vertex& FirstVertex,
1113 TopoDS_Vertex& LastVertex,
1114 Standard_Boolean& OnFirstFace,
1115 Standard_Boolean& OnLastFace,
1116 Standard_Boolean& PtOnFirstEdge,
1117 Standard_Boolean& PtOnLastEdge,
1118 TopoDS_Edge& OnFirstEdge,
1119 TopoDS_Edge& OnLastEdge)
1123 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1124 if (trc) cout << "BRepFeat_RibSlot::ExtremeFaces" << endl;
1126 Standard_Boolean Data = Standard_True;
1127 FirstFace.Nullify();
1129 FirstEdge.Nullify();
1131 PtOnFirstEdge = Standard_False;
1132 PtOnLastEdge = Standard_False;
1133 OnFirstEdge.Nullify();
1134 OnLastEdge.Nullify();
1136 BRepIntCurveSurface_Inter inter;
1138 TopExp_Explorer ex1;
1140 Standard_Boolean FirstOK = Standard_False, LastOK = Standard_False;
1142 Standard_Integer NumberOfEdges = 0;
1143 TopExp_Explorer exp(myWire, TopAbs_EDGE);
1145 for(; exp.More(); exp.Next()) {
1149 // ---the wire includes only one edge
1150 if(NumberOfEdges == 1) {
1152 if (trc) cout << " One Edge" << endl;
1155 Standard_Real f, l;//, f1, l1, temp;
1156 gp_Pnt firstpoint, lastpoint;
1158 // Points limit the unique edge
1159 const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
1160 Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l);
1161 gp_Pnt p1 = BRep_Tool::Pnt(TopExp::FirstVertex(E,Standard_True));
1162 gp_Pnt p2 = BRep_Tool::Pnt(TopExp::LastVertex(E,Standard_True));
1164 Standard_Real FirstPar = f; Standard_Real LastPar = l;
1167 // ---Find if 2 points limiting the unique edge of the wire
1168 // are on an edge or a vertex of the base shape
1169 Standard_Boolean PtOnFirstVertex = Standard_False;
1170 Standard_Boolean PtOnLastVertex = Standard_False;
1171 TopoDS_Vertex OnFirstVertex, OnLastVertex;
1172 PtOnEdgeVertex(RevolRib, mySbase, p1, FirstVertex, LastVertex,
1173 PtOnFirstEdge, OnFirstEdge, PtOnFirstVertex, OnFirstVertex);
1174 PtOnEdgeVertex(RevolRib, mySbase, p2, FirstVertex, LastVertex,
1175 PtOnLastEdge, OnLastEdge, PtOnLastVertex, OnLastVertex);
1177 TopTools_MapOfShape Map;
1180 if (!PtOnFirstVertex) {
1181 // Find FirstFace : face of the base shape containing OnFirstEdge
1182 // meeting ChoiceOfFaces
1183 TopExp_Explorer ex4, ex5;
1184 ex4.Init(mySbase, TopAbs_FACE);
1185 TopTools_ListOfShape faces;
1188 for(; ex4.More(); ex4.Next()) {
1189 const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:04 2002 fx instead f
1190 if ( !Map.Add(fx)) continue;
1191 ex5.Init(ex4.Current(), TopAbs_EDGE);
1192 for(; ex5.More(); ex5.Next()) {
1193 const TopoDS_Edge& ee = TopoDS::Edge(ex5.Current());
1194 if(ee.IsSame(OnFirstEdge)) {
1199 if(!faces.IsEmpty()) {
1200 TopoDS_Face FFF = ChoiceOfFaces(faces, cc, FirstPar+bnd/50., bnd/50., Pln);
1201 if(!FFF.IsNull()) FirstFace = FFF;
1204 else if(PtOnFirstVertex) {
1205 // Find FirstFace : face of the base shape containing OnFirstVertex
1206 // meeting ChoiceOfFaces
1207 TopExp_Explorer ex4, ex5;
1208 ex4.Init(mySbase, TopAbs_FACE);
1209 TopTools_ListOfShape faces;
1212 for(; ex4.More(); ex4.Next()) {
1213 const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:36 2002 fx instead of f
1214 if ( !Map.Add(fx)) continue;
1215 ex5.Init(ex4.Current(), TopAbs_VERTEX);
1216 for(; ex5.More(); ex5.Next()) {
1217 const TopoDS_Vertex& vv = TopoDS::Vertex(ex5.Current());
1218 if(vv.IsSame(OnFirstVertex)) {
1224 if(!faces.IsEmpty()) {
1225 TopoDS_Face FFF = ChoiceOfFaces(faces, cc, FirstPar+bnd/50., bnd/50., Pln);
1226 if(!FFF.IsNull()) FirstFace = FFF;
1230 BRepLib_MakeVertex v(p1);
1232 OnFirstFace = Standard_True;
1236 if (!PtOnLastVertex) {
1237 // Find LastFace : face of the base shape containing OnLastEdge
1238 // meeting ChoiceOfFaces
1239 TopExp_Explorer ex4, ex5;
1240 ex4.Init(mySbase, TopAbs_FACE);
1241 TopTools_ListOfShape faces;
1244 for(; ex4.More(); ex4.Next()) {
1245 const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:36 2002 fx instead of f
1246 if ( !Map.Add(fx)) continue;
1247 ex5.Init(ex4.Current(), TopAbs_EDGE);
1248 for(; ex5.More(); ex5.Next()) {
1249 const TopoDS_Edge& ee = TopoDS::Edge(ex5.Current());
1250 if(ee.IsSame(OnLastEdge)) {
1256 if(!faces.IsEmpty()) {
1257 TopoDS_Face FFF = ChoiceOfFaces(faces, cc, LastPar-bnd/50., bnd/50., Pln);
1258 if(!FFF.IsNull()) LastFace = FFF;
1261 else if(PtOnLastEdge && PtOnLastVertex) {
1262 // Find LastFace : face of the base shape containing OnLastVertex
1263 // meeting ChoiceOfFaces
1264 TopExp_Explorer ex4, ex5;
1265 ex4.Init(mySbase, TopAbs_FACE);
1266 TopTools_ListOfShape faces;
1269 for(; ex4.More(); ex4.Next()) {
1270 const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:36 2002 fx instead of f
1271 if ( !Map.Add(fx)) continue;
1272 ex5.Init(ex4.Current(), TopAbs_VERTEX);
1273 for(; ex5.More(); ex5.Next()) {
1274 const TopoDS_Vertex& vv = TopoDS::Vertex(ex5.Current());
1275 if(vv.IsSame(OnLastVertex)) {
1281 if(!faces.IsEmpty()) {
1282 TopoDS_Face FFF = ChoiceOfFaces(faces, cc, LastPar-bnd/50., bnd/50., Pln);
1283 if(!FFF.IsNull()) LastFace = FFF;
1287 BRepLib_MakeVertex v(p2);
1289 OnLastFace = Standard_True;
1292 if(!FirstFace.IsNull() && !LastFace.IsNull()) {
1293 return Standard_True;
1296 //--- FirstFace or LastFace was not found
1298 if (trc) cout << " FirstFace or LastFace null" << endl;
1300 LocOpe_CSIntersector ASI(mySbase);
1301 TColGeom_SequenceOfCurve scur;
1305 Standard_Real lastpar, firstpar;
1306 if(ASI.IsDone() && ASI.NbPoints(1) >= 2) {
1307 lastpar = ASI.Point(1, ASI.NbPoints(1)).Parameter();
1308 Standard_Integer lastindex = ASI.NbPoints(1);
1310 for(Standard_Integer jj=ASI.NbPoints(1)-1; jj>=1; jj--) {
1311 Standard_Real par = ASI.Point(1,jj).Parameter();
1319 Standard_Integer firstindex = lastindex -1;
1320 firstpar = ASI.Point(1,firstindex).Parameter();
1322 if(FirstFace.IsNull()) {
1323 FirstFace = ASI.Point(1, firstindex).Face();
1324 cc->D0(firstpar, firstpoint);
1325 BRepLib_MakeVertex v1(firstpoint);
1326 FirstVertex = TopoDS::Vertex(v1.Shape());
1330 if(LastFace.IsNull()) {
1331 LastFace = ASI.Point(1, lastindex).Face();
1332 cc->D0(lastpar, lastpoint);
1333 BRepLib_MakeVertex v2(lastpoint);
1334 LastVertex = TopoDS::Vertex(v2.Shape());
1340 if (trc) cout << " Less than 2 intersection points" << endl;
1342 Data = Standard_False;
1347 if(p1.Distance(firstpoint) <= Precision::Confusion())
1348 OnFirstFace = Standard_True;
1349 else OnFirstFace = Standard_False;
1353 if(p2.Distance(lastpoint) <= Precision::Confusion())
1354 OnLastFace = Standard_True;
1355 else OnLastFace = Standard_False;
1358 if(FirstFace.IsNull() || LastFace.IsNull()) {
1360 if (trc) cout << " First or Last Faces still null" << endl;
1362 Data = Standard_False;
1366 if (trc) cout << " FirstFace and LastFace OK" << endl;
1368 Data = Standard_True;
1373 // ---The wire consists of several edges
1376 if (trc) cout << " Multiple Edges" << endl;
1378 BRepTools_WireExplorer ex(myWire);
1379 for(; ex.More(); ex.Next()) {
1380 const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
1382 Handle(Geom_Curve) Cur = BRep_Tool::Curve(E, f, l);
1383 f = f - bnd/10000; l = l +bnd/10000;
1384 Handle(Geom_TrimmedCurve) curve;
1385 curve = new Geom_TrimmedCurve(Cur, f, l, Standard_True);
1389 BRep_Tool::Pnt(TopExp::FirstVertex(E,Standard_True));
1390 gp_Pnt P2 = BRep_Tool::Pnt(TopExp::LastVertex(E,Standard_True));
1391 ex1.Init(mySbase, TopAbs_FACE);
1392 TopoDS_Vertex theVertex;
1393 TopoDS_Edge theEdge;
1394 TopoDS_Face theFace;
1395 Standard_Boolean PtOnEdge = Standard_False;
1396 Standard_Boolean PtOnVertex = Standard_False;
1398 TopoDS_Vertex OnVertex;
1399 Standard_Real intpar;
1400 for(; ex1.More(); ex1.Next()) {
1401 const TopoDS_Face& f = TopoDS::Face(ex1.Current());
1402 inter.Init(f,curve, BRep_Tool::Tolerance(f));
1403 if(!inter.More()) continue;
1404 for(; inter.More(); inter.Next()) {
1405 gp_Pnt thePoint = inter.Pnt();
1406 if(!FirstVertex.IsNull()) {
1407 gp_Pnt point = BRep_Tool::Pnt(FirstVertex);
1408 if(point.Distance(thePoint) <= BRep_Tool::Tolerance(f)) {
1412 intpar = IntPar(curve, thePoint);
1415 B.MakeVertex(theVertex, thePoint, Precision::Confusion());
1417 if(thePoint.Distance(P2) <= Precision::Confusion()) {
1422 // ---Find thepoint on an edge or a vertex of face f
1423 PtOnEdgeVertex(RevolRib, f, thePoint, FirstVertex, LastVertex,
1424 PtOnEdge,OnEdge,PtOnVertex,OnVertex);
1427 // if(!theEdge.IsNull()) break;
1429 if (FirstEdge.IsNull() && !theEdge.IsNull() &&
1430 !theFace.IsNull() && !theVertex.IsNull()) {
1431 FirstEdge = theEdge;
1432 FirstFace = theFace;
1433 FirstVertex = theVertex;
1434 PtOnFirstEdge = PtOnEdge;
1435 OnFirstEdge = OnEdge;
1436 theEdge.Nullify(); theFace.Nullify(); theVertex.Nullify();
1437 if(PtOnEdge && !PtOnVertex) {
1438 TopTools_ListOfShape faces;
1440 faces.Append(FirstFace);
1441 TopExp_Explorer ex2;
1442 ex2.Init(mySbase, TopAbs_FACE);
1443 for(; ex2.More(); ex2.Next()) {
1444 TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:16:44 2002 fx/f
1445 TopExp_Explorer ex3;
1446 ex3.Init(fx, TopAbs_EDGE);
1447 for(; ex3.More(); ex3.Next()) {
1448 const TopoDS_Edge& e = TopoDS::Edge(ex3.Current());
1449 if(e.IsSame(OnEdge) && !fx.IsSame(FirstFace)) {
1454 TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar+bnd/10., bnd/10., Pln);
1455 if(!FFF.IsNull()) FirstFace = FFF;
1457 else if(PtOnEdge && PtOnVertex) {
1458 TopTools_ListOfShape faces;
1460 faces.Append(FirstFace);
1461 TopExp_Explorer ex2;
1462 ex2.Init(mySbase, TopAbs_FACE);
1463 for(; ex2.More(); ex2.Next()) {
1464 TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:13:08 2002 fx/f
1465 TopExp_Explorer ex3;
1466 ex3.Init(fx, TopAbs_VERTEX);
1467 for(; ex3.More(); ex3.Next()) {
1468 const TopoDS_Vertex& v = TopoDS::Vertex(ex3.Current());
1469 if(v.IsSame(OnVertex) && !fx.IsSame(FirstFace)) {
1474 TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar+bnd/10., bnd/10., Pln);
1475 if(!FFF.IsNull()) FirstFace = FFF;
1477 if(!FirstEdge.IsNull() && !FirstFace.IsNull()
1478 && !FirstVertex.IsNull()) {
1479 FirstOK = Standard_True;
1482 if(LastEdge.IsNull() && !theEdge.IsNull() &&
1483 !theFace.IsNull() && !theVertex.IsNull() &&
1484 !FirstEdge.IsNull()) {
1487 LastVertex = theVertex;
1488 PtOnLastEdge = PtOnEdge;
1489 OnLastEdge = OnEdge;
1490 if(PtOnEdge && !PtOnVertex) {
1491 TopTools_ListOfShape faces;
1493 faces.Append(LastFace);
1494 TopExp_Explorer ex2;
1495 ex2.Init(mySbase, TopAbs_FACE);
1496 for(; ex2.More(); ex2.Next()) {
1497 TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:12:06 2002 fx/f
1498 TopExp_Explorer ex3;
1499 ex3.Init(fx, TopAbs_EDGE);
1500 for(; ex3.More(); ex3.Next()) {
1501 const TopoDS_Edge& e = TopoDS::Edge(ex3.Current());
1502 if(e.IsSame(OnEdge) && !fx.IsSame(LastFace)) {
1507 TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar-bnd/10.,bnd/10., Pln);
1508 if(!FFF.IsNull()) LastFace = FFF;
1510 else if(PtOnEdge && PtOnVertex) {
1511 TopTools_ListOfShape faces;
1513 faces.Append(LastFace);
1514 TopExp_Explorer ex2;
1515 ex2.Init(mySbase, TopAbs_FACE);
1516 for(; ex2.More(); ex2.Next()) {
1517 TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:11:36 2002 fx/f
1518 TopExp_Explorer ex3;
1519 ex3.Init(fx, TopAbs_VERTEX);
1520 for(; ex3.More(); ex3.Next()) {
1521 const TopoDS_Vertex& v = TopoDS::Vertex(ex3.Current());
1522 if(v.IsSame(OnVertex) && !fx.IsSame(LastFace)) {
1527 TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar-bnd/10.,bnd/10., Pln);
1528 if(!FFF.IsNull()) LastFace = FFF;
1530 if(!LastEdge.IsNull() && !LastFace.IsNull()
1531 && !LastVertex.IsNull()) {
1532 LastOK = Standard_True;
1540 if(FirstOK && LastOK) {
1541 Data = Standard_True;
1542 gp_Pnt PP1 = BRep_Tool::Pnt(TopExp::FirstVertex(FirstEdge,Standard_True));
1543 gp_Pnt PP2 = BRep_Tool::Pnt(TopExp::LastVertex(LastEdge,Standard_True));
1544 gp_Pnt p1 = BRep_Tool::Pnt(FirstVertex);
1545 gp_Pnt p2 = BRep_Tool::Pnt(LastVertex);
1546 if(p1.Distance(PP1) <= BRep_Tool::Tolerance(FirstFace)) {
1547 OnFirstFace = Standard_True;
1549 if(p2.Distance(PP2) <= BRep_Tool::Tolerance(LastFace)) {
1550 OnLastFace = Standard_True;
1552 return Standard_True;
1556 if (trc) cout << " First or Last not OK" << endl;
1558 return Standard_False;
1564 //=======================================================================
1565 //function : PtOnEdgeVertex
1566 //purpose : Find if 2 limit points of the unique edge of a wire
1567 // are on an edge or a vertex of the base shape
1568 //=======================================================================
1570 void BRepFeat_RibSlot::PtOnEdgeVertex(const Standard_Boolean RevolRib,
1571 const TopoDS_Shape& shape,
1572 const gp_Pnt& point,
1573 const TopoDS_Vertex& ,//FirstVertex,
1574 const TopoDS_Vertex& ,//LastVertex,
1575 Standard_Boolean& PtOnEdge,
1576 TopoDS_Edge& OnEdge,
1577 Standard_Boolean& PtOnVertex,
1578 TopoDS_Vertex& OnVertex)
1582 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
1583 if (trc) cout << "BRepFeat_RibSlot::PtOnEdgeVertex" << endl;
1585 Standard_Boolean TestOK;
1586 // PtOnEdge = Standard_False;
1587 // OnEdge.Nullify();
1588 // PtOnVertex = Standard_False;
1589 // OnVertex.Nullify();
1591 TopExp_Explorer EXP;
1592 EXP.Init(shape, TopAbs_EDGE);
1593 TopTools_MapOfShape Map;
1594 for(; EXP.More(); EXP.Next()) {
1595 const TopoDS_Edge& e = TopoDS::Edge(EXP.Current());
1596 if ( !Map.Add(e)) continue;
1598 if (BRep_Tool::Degenerated(e)) continue;
1600 Standard_Real fff, lll;
1601 Handle(Geom_Curve) ccc = BRep_Tool::Curve(e, fff, lll);
1603 ccc = new Geom_TrimmedCurve(ccc, fff, lll);
1605 GeomAPI_ProjectPointOnCurve proj(point, ccc);
1606 TestOK = Standard_False;
1608 if(proj.NbPoints() == 1) TestOK = Standard_True;
1611 if(proj.NbPoints() >= 1) TestOK = Standard_True;
1613 if(TestOK && proj.Distance(1) <= BRep_Tool::Tolerance(e)) {
1614 PtOnEdge = Standard_True;
1616 TopoDS_Vertex ev1 = TopExp::FirstVertex(e,Standard_True);
1617 TopoDS_Vertex ev2 = TopExp::LastVertex(e,Standard_True);
1618 gp_Pnt ep1 = BRep_Tool::Pnt(ev1);
1619 gp_Pnt ep2 = BRep_Tool::Pnt(ev2);
1620 if(point.Distance(ep1) <= BRep_Tool::Tolerance(ev1)) {
1621 PtOnVertex = Standard_True;
1625 else if(point.Distance(ep2) <= BRep_Tool::Tolerance(ev1)) {
1626 PtOnVertex = Standard_True;
1636 //=======================================================================
1637 //function : SlidingProfile
1638 //purpose : construction of the profile face in case of sliding
1639 //=======================================================================
1641 Standard_Boolean BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof,
1642 const Standard_Boolean RevolRib,
1643 const Standard_Real myTol,
1644 Standard_Integer& Concavite,
1645 const Handle(Geom_Plane)& myPln,
1646 const TopoDS_Face& BndFace,
1647 const gp_Pnt& CheckPnt,
1648 const TopoDS_Face& FirstFace,
1649 const TopoDS_Face& LastFace,
1650 const TopoDS_Vertex& ,//FirstVertex,
1651 const TopoDS_Vertex& ,//LastVertex,
1652 const TopoDS_Edge& FirstEdge,
1653 const TopoDS_Edge& LastEdge)
1657 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1658 if (trc) cout << "BRepFeat_RibSlot::SlidingProfile" << endl;
1660 Standard_Boolean ProfileOK = Standard_True;
1661 // --case of sliding : construction of the wire of the profile
1662 // --> 1 part bounding box + 1 part wire
1663 // attention to the compatibility of orientations
1666 BRepLib_MakeWire WW;
1668 FN = Normal(FirstFace, myFirstPnt);
1669 LN = Normal(LastFace, myLastPnt);
1671 // Case of the groove (cut) <> rib (fuse)
1672 // -> we are in the material
1673 // -> make everything in 2d in the working plane : easier
1680 Handle(Geom_Line) ln1, ln2;
1681 gp_Pnt Pt;//,p1, p2;
1683 ln2 = new Geom_Line(myFirstPnt, FN);
1684 ln1 = new Geom_Line(myLastPnt, LN);
1686 Handle(Geom2d_Curve) ln2d1 = GeomAPI::To2d(ln1, myPln->Pln());
1687 Handle(Geom2d_Curve) ln2d2 = GeomAPI::To2d(ln2, myPln->Pln());
1689 Geom2dAPI_InterCurveCurve inter(ln2d1, ln2d2, Precision::Confusion());
1691 Standard_Boolean TestOK = Standard_True;
1694 d1 = ln1->Position().Direction();
1695 d2 = ln2->Position().Direction();
1696 if(d1.IsOpposite(d2, myTol)) {
1697 Standard_Real par1 = ElCLib::Parameter(ln1->Lin(), myFirstPnt);
1698 Standard_Real par2 = ElCLib::Parameter(ln2->Lin(), myLastPnt);
1699 if(par1 >= myTol || par2 >= myTol) {
1700 Concavite = 2; //paralel and concave
1701 BRepLib_MakeEdge e1(myLastPnt, myFirstPnt);
1705 if(d1.IsEqual(d2, myTol)) {
1706 if(Concavite == 3) TestOK = Standard_False;
1711 if(inter.NbPoints() > 0) {
1712 gp_Pnt2d P = inter.Point(1);
1713 myPln->D0(P.X(), P.Y(), Pt);
1714 Standard_Real par = IntPar(ln1, Pt);
1715 if(par>0) Concavite = 1; //concave
1719 // ---Construction of the profile face
1720 if(Concavite == 1) {
1721 // if concave : it is possible to extend first and last edges of the wire
1722 // to the bounding box
1723 BRepLib_MakeEdge e1(myLastPnt, Pt);
1725 BRepLib_MakeEdge e2(Pt, myFirstPnt);
1728 else if(Concavite == 3) {
1729 // BndEdge : edges of intersection with the bounding box
1730 TopoDS_Edge BndEdge1, BndEdge2;
1731 // Points of intersection with the bounding box / Find Profile
1732 gp_Pnt BndPnt1, BndPnt2, LastPnt;
1733 TopExp_Explorer expl;
1734 expl.Init(BndFace, TopAbs_WIRE);
1735 BRepTools_WireExplorer explo;
1736 TopoDS_Wire BndWire = TopoDS::Wire(expl.Current());
1737 explo.Init(BndWire);
1738 for(; explo.More(); explo.Next()) {
1739 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1740 Standard_Real first, last;
1741 Handle(Geom_Curve) c = BRep_Tool::Curve(e, first, last);
1742 Handle(Geom2d_Curve) c2d = GeomAPI::To2d(c, myPln->Pln());
1743 Geom2dAPI_InterCurveCurve intcln1(ln2d1, c2d,
1744 Precision::Confusion());
1745 if(intcln1.NbPoints() > 0) {
1746 gp_Pnt2d p2d = intcln1.Point(1);
1748 myPln->D0(p2d.X(), p2d.Y(), p);
1749 Standard_Real parl = IntPar(ln1, p);
1750 Standard_Real parc = IntPar(c, p);
1751 if(parc >= first && parc <= last && parl >= 0) {
1757 Geom2dAPI_InterCurveCurve intcln2(ln2d2, c2d,
1758 Precision::Confusion());
1759 if(intcln2.NbPoints() > 0) {
1760 gp_Pnt2d p2d = intcln2.Point(1);
1762 myPln->D0(p2d.X(), p2d.Y(), p);
1763 Standard_Real parl = IntPar(ln2, p);
1764 Standard_Real parc = IntPar(c, p);
1765 if(parc >= first && parc <= last && parl >= 0) {
1770 if(!BndEdge1.IsNull() && !BndEdge2.IsNull()) break;
1773 if(BndEdge1.IsNull() || BndEdge2.IsNull()) {
1775 if (trc) cout << " Null bounding edge" << endl;
1777 ProfileOK = Standard_False;
1782 BRepLib_MakeEdge e1(myLastPnt, BndPnt1);
1785 if(BndEdge1.IsSame(BndEdge2)) {
1786 // Particular case : same edge -> simply determined path
1787 BRepLib_MakeEdge e2(BndPnt1, BndPnt2);
1789 BRepLib_MakeEdge e3(BndPnt2, myFirstPnt);
1793 explo.Init(BndWire);
1794 for(; explo.More(); explo.Next()) {
1795 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1796 if(e.IsSame(BndEdge1)) {
1798 pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True));
1799 if(pp.Distance(BndPnt1) >= BRep_Tool::Tolerance(e)) {
1802 // else { //LinearForm
1803 // gp_Pnt ppp = BRep_Tool::Pnt(TopExp::FirstVertex(e,Standard_True));
1806 BRepLib_MakeEdge e2(BndPnt1, LastPnt);
1814 if(explo.Current().IsNull()) explo.Init(BndWire);
1816 else explo.Init(BndWire);
1818 // Check if this is BndEdge2
1819 // -> if yes : it is required to turn to join FirstPnt
1820 // -> if no : add edges
1821 Standard_Boolean Fin = Standard_False;
1823 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
1824 if(!e.IsSame(BndEdge2)) {
1826 pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True));
1827 BRepLib_MakeEdge ee(LastPnt, pp);
1832 // the path is closed
1833 // -> since met BndEdge2, end of borders on BndFace
1834 Fin = Standard_True;
1835 BRepLib_MakeEdge ee(LastPnt, BndPnt2);
1841 if(explo.Current().IsNull()) {
1842 explo.Init(BndWire);
1845 else explo.Init(BndWire);
1848 BRepLib_MakeEdge e3(BndPnt2, myFirstPnt);
1853 // ---Construction of the profile
1855 // Explore the wire provided by the user
1856 // BRepTools_WireExplorer : correct order - without repetition <> TopExp : non ordered
1857 BRepTools_WireExplorer EX(myWire);
1859 Standard_Real ff, ll;
1860 Handle(Geom_Curve) FirstCurve = BRep_Tool::Curve(FirstEdge, ff, ll);
1862 if(!FirstEdge.IsSame(LastEdge)) {
1863 TopoDS_Vertex FLVert = TopExp::LastVertex(FirstEdge,Standard_True);
1864 gp_Pnt FLPnt = BRep_Tool::Pnt(FLVert);
1865 BRepLib_MakeEdge ef(FirstCurve, myFirstPnt, FLPnt);
1867 for(; EX.More(); EX.Next()) {
1868 const TopoDS_Edge& E = EX.Current();
1869 if(E.IsSame(FirstEdge)) break;
1872 for(; EX.More(); EX.Next()) {
1873 const TopoDS_Edge& E = EX.Current();
1874 if(!E.IsSame(LastEdge)) {
1879 Handle(Geom_Curve) LastCurve = BRep_Tool::Curve(LastEdge, ff, ll);
1880 TopoDS_Vertex LFVert = TopExp::FirstVertex(LastEdge,Standard_True);
1881 gp_Pnt LFPnt = BRep_Tool::Pnt(LFVert);
1882 BRepLib_MakeEdge el(LastCurve, LFPnt, myLastPnt);
1886 // only one edge : particular processing
1887 Standard_Real fpar = IntPar(FirstCurve, myFirstPnt);
1888 Standard_Real lpar = IntPar(FirstCurve, myLastPnt);
1889 Handle(Geom_Curve) c;
1891 c = Handle(Geom_Curve)::DownCast(FirstCurve->Reversed());
1895 BRepLib_MakeEdge ef(c, myFirstPnt, myLastPnt);
1899 BRepLib_MakeFace f(myPln->Pln(), WW, Standard_True);
1900 TopoDS_Face fac = TopoDS::Face(f.Shape());
1902 if (!BRepAlgo::IsValid(fac)) {
1904 if (trc) cout << " Invalid Face" << endl;
1906 ProfileOK = Standard_False;
1910 if(Concavite != 3) {
1911 // if concave : face is OK
1916 // CheckPnt : point slightly inside the material side
1917 // Bndface : face/cut of the bounding box in the plane of the profile
1918 BRepTopAdaptor_FClass2d Cl(fac, BRep_Tool::Tolerance(fac));
1920 ElSLib::Parameters(myPln->Pln(), CheckPnt, u, v);
1921 gp_Pnt2d checkpnt2d(u, v);
1922 if(Cl.Perform(checkpnt2d, Standard_True) == TopAbs_OUT) {
1923 // If face is not the correct part of BndFace take the complementary
1924 //modified by NIZNHY-PKV Fri Mar 22 16:46:20 2002 f
1925 //BRepAlgo_Cut c(BndFace, fac);
1926 BRepAlgoAPI_Cut c(BndFace, fac);
1927 //modified by NIZNHY-PKV Fri Mar 22 16:46:23 2002 t
1928 TopExp_Explorer exp(c.Shape(), TopAbs_WIRE);
1929 const TopoDS_Wire& w = TopoDS::Wire(exp.Current());
1930 BRepLib_MakeFace ffx(w);//modified by NIZNHY-PKV Fri Mar 22 17:10:43 2002 ffx/ff
1931 Prof = TopoDS::Face(ffx.Shape());
1934 // If face is the correct part of BndFace : face is OK
1939 if (!BRepAlgo::IsValid(Prof)) {
1941 if (trc) cout << " Invalid Face Profile" << endl;
1943 ProfileOK = Standard_False;
1948 //=======================================================================
1949 //function : NoSlidingProfile
1950 //purpose : construction of the face profile in case of sliding
1951 //=======================================================================
1953 Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof,
1954 const Standard_Boolean RevolRib,
1955 const Standard_Real myTol,
1956 Standard_Integer& Concavite,
1957 const Handle(Geom_Plane)& myPln,
1958 const Standard_Real bnd,
1959 const TopoDS_Face& BndFace,
1960 const gp_Pnt& CheckPnt,
1961 const TopoDS_Face& ,//FirstFace,
1962 const TopoDS_Face& ,//LastFace,
1963 const TopoDS_Vertex& ,//FirstVertex,
1964 const TopoDS_Vertex& ,//LastVertex,
1965 const TopoDS_Edge& FirstEdge,
1966 const TopoDS_Edge& LastEdge,
1967 const Standard_Boolean OnFirstFace,
1968 const Standard_Boolean OnLastFace)
1972 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1973 if (trc) cout << "BRepFeat_RibSlot::NoSlidingProfile" << endl;
1975 Standard_Boolean ProfileOK = Standard_True;
1977 Standard_Real l1, f1, f2, l2;//, p;
1978 TopoDS_Vertex theFV; theFV.Nullify();
1979 gp_Pnt theFirstpoint;
1980 TopoDS_Edge theLastEdge; theLastEdge.Nullify();
1981 gp_Pnt firstpoint, lastpoint;//, pp1, pp2;
1982 gp_Vec firstvect, lastvect;
1987 TopoDS_Edge FalseFirstEdge, FalseLastEdge, FalseOnlyOne;
1989 Handle(Geom_Curve) FirstCurve = BRep_Tool::Curve(FirstEdge, f1, l1);
1990 Handle(Geom_Curve) LastCurve = BRep_Tool::Curve(LastEdge, f2, l2);
1992 Handle(Geom_Line) firstln, lastln;
1993 FirstCurve->D1(f1, firstpoint, firstvect);
1994 lastln = new Geom_Line(firstpoint, -firstvect);
1995 LastCurve->D1(l2, lastpoint, lastvect);
1996 firstln = new Geom_Line(lastpoint, lastvect);
2000 Handle(Geom2d_Curve) ln2d1 = GeomAPI::To2d(firstln, myPln->Pln());
2001 Handle(Geom2d_Curve) ln2d2 = GeomAPI::To2d(lastln, myPln->Pln());
2003 Geom2dAPI_InterCurveCurve inter(ln2d1, ln2d2, Precision::Confusion());
2005 Standard_Boolean TestOK = Standard_True;
2008 d1 = firstln->Position().Direction();
2009 d2 = lastln->Position().Direction();
2010 if(d1.IsOpposite(d2, myTol)) {
2011 Standard_Real par1 = ElCLib::Parameter(firstln->Lin(), myFirstPnt);
2012 Standard_Real par2 = ElCLib::Parameter(lastln->Lin(), myLastPnt);
2013 if(par1 >= myTol || par2 >= myTol)
2014 Concavite = 2; //parallel and concave
2016 if(d1.IsEqual(d2, myTol)) {
2017 if(Concavite == 3) TestOK = Standard_False;
2022 if(inter.NbPoints() > 0) {
2023 gp_Pnt2d P = inter.Point(1);
2024 myPln->D0(P.X(), P.Y(), Pt);
2025 Standard_Real par = IntPar(firstln, Pt);
2026 if(par>0) Concavite = 1; //concave
2030 // ---Construction of the face profile
2031 if(Concavite == 3) {
2034 FalseFirstEdge = FirstEdge;
2035 EdgeExtention(FalseFirstEdge, bnd, Standard_True);
2036 const TopoDS_Vertex& vv1 = TopExp::FirstVertex(FalseFirstEdge,Standard_True);
2037 firstpoint = BRep_Tool::Pnt(vv1);
2038 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseFirstEdge, f, l);
2039 cc->D1(f, firstpoint, firstvect);
2040 lastln = new Geom_Line(firstpoint, -firstvect);
2041 if(FirstEdge.IsSame(LastEdge)) FalseOnlyOne = FalseFirstEdge;
2042 ln2d2 = GeomAPI::To2d(lastln, myPln->Pln());
2046 if(!FirstEdge.IsSame(LastEdge)) {
2047 FalseLastEdge = LastEdge;
2050 if(FalseOnlyOne.IsNull()) FalseOnlyOne = LastEdge;
2051 FalseLastEdge = FalseOnlyOne;
2053 EdgeExtention(FalseLastEdge, bnd, Standard_False);
2054 if(FirstEdge.IsSame(LastEdge)) {
2055 FalseOnlyOne = FalseLastEdge;
2057 const TopoDS_Vertex& vv2 = TopExp::LastVertex(FalseLastEdge,Standard_True);
2058 lastpoint = BRep_Tool::Pnt(vv2);
2059 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseLastEdge, f, l);
2060 cc->D1(l, lastpoint, lastvect);
2061 lastpoint = BRep_Tool::Pnt(vv2);
2062 firstln = new Geom_Line(lastpoint, lastvect);
2063 ln2d1 = GeomAPI::To2d(firstln, myPln->Pln());
2066 TopoDS_Edge BndEdge1, BndEdge2;
2067 gp_Pnt BndPnt1, BndPnt2, LastPnt;
2068 TopExp_Explorer expl;
2069 expl.Init(BndFace, TopAbs_WIRE);
2070 BRepTools_WireExplorer explo;
2071 TopoDS_Wire BndWire = TopoDS::Wire(expl.Current());
2072 explo.Init(BndWire);
2073 for(; explo.More(); explo.Next()) {
2074 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
2075 Standard_Real first, last;
2076 Handle(Geom_Curve) c = BRep_Tool::Curve(e, first, last);
2077 Handle(Geom2d_Curve) c2d = GeomAPI::To2d(c, myPln->Pln());
2078 Geom2dAPI_InterCurveCurve intcln1(ln2d1, c2d,
2079 Precision::Confusion());
2080 if(intcln1.NbPoints() > 0) {
2081 gp_Pnt2d p2d = intcln1.Point(1);
2083 myPln->D0(p2d.X(), p2d.Y(), p);
2084 Standard_Real parl = IntPar(firstln, p);
2085 Standard_Real parc = IntPar(c, p);
2086 if(parc >= first && parc <= last && parl >= 0) {
2092 Geom2dAPI_InterCurveCurve intcln2(ln2d2, c2d,
2093 Precision::Confusion());
2094 if(intcln2.NbPoints() > 0) {
2095 gp_Pnt2d p2d = intcln2.Point(1);
2097 myPln->D0(p2d.X(), p2d.Y(), p);
2098 Standard_Real parl = IntPar(lastln, p);
2099 Standard_Real parc = IntPar(c, p);
2100 if(parc >= first && parc <= last && parl >= 0) {
2105 if(!BndEdge1.IsNull() && !BndEdge2.IsNull()) break;
2108 if(BndEdge1.IsNull() || BndEdge2.IsNull()) {
2110 if (trc) cout << " Null bounding edge" << endl;
2112 ProfileOK = Standard_False;
2117 if(theLastEdge.IsNull()) {
2118 BRepLib_MakeEdge e1(lastpoint, BndPnt1);
2119 ee1 = TopoDS::Edge(e1.Shape());
2122 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2123 BRepLib_MakeVertex v2(BndPnt1);
2124 BRepLib_MakeEdge e1(v1, v2);
2125 ee1 = TopoDS::Edge(e1.Shape());
2129 if(theFV.IsNull()) {
2130 theFV = TopExp::FirstVertex(ee1,Standard_True);
2131 theFirstpoint = BRep_Tool::Pnt(theFV);
2134 if(BndEdge1.IsSame(BndEdge2)) {
2135 TopoDS_Edge ee2, ee3;
2136 if(theLastEdge.IsNull()) {
2137 BRepLib_MakeEdge e2(BndPnt1, BndPnt2);
2138 ee2 = TopoDS::Edge(e2.Shape());
2141 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2142 BRepLib_MakeVertex v2(BndPnt2);
2143 BRepLib_MakeEdge e2(v1, v2);
2144 ee2 = TopoDS::Edge(e2.Shape());
2148 if(theFV.IsNull()) {
2149 theFV = TopExp::FirstVertex(ee2,Standard_True);
2150 theFirstpoint = BRep_Tool::Pnt(theFV);
2152 if(theLastEdge.IsNull()) {
2153 BRepLib_MakeEdge e3(BndPnt2, firstpoint);
2154 ee3 = TopoDS::Edge(e3.Shape());
2157 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2158 BRepLib_MakeVertex v2(firstpoint);
2159 BRepLib_MakeEdge e3(v1, v2);
2160 ee3 = TopoDS::Edge(e3.Shape());
2164 if(theFV.IsNull()) {
2165 theFV = TopExp::FirstVertex(ee3,Standard_True);
2166 theFirstpoint = BRep_Tool::Pnt(theFV);
2170 explo.Init(BndWire);
2171 for(; explo.More(); explo.Next()) {
2172 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
2173 if(e.IsSame(BndEdge1)) {
2175 pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True));
2176 if(pp.Distance(BndPnt1) > BRep_Tool::Tolerance(e)) {
2180 if(theLastEdge.IsNull()) {
2181 BRepLib_MakeEdge e2(BndPnt1, LastPnt);
2182 eee = TopoDS::Edge(e2.Shape());
2185 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2186 BRepLib_MakeVertex v2(LastPnt);
2187 BRepLib_MakeEdge e2(v1, v2);
2188 eee = TopoDS::Edge(e2.Shape());
2192 if(theFV.IsNull()) {
2193 theFV = TopExp::FirstVertex(eee,Standard_True);
2194 theFirstpoint = BRep_Tool::Pnt(theFV);
2202 if(explo.Current().IsNull()) explo.Init(BndWire);
2204 else explo.Init(BndWire);
2205 Standard_Boolean Fin = Standard_False;
2207 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
2208 if(!e.IsSame(BndEdge2)) {
2210 pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True));
2212 if(theLastEdge.IsNull()) {
2213 BRepLib_MakeEdge ee(LastPnt, pp);
2214 eee1 = TopoDS::Edge(ee.Shape());
2217 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2218 BRepLib_MakeVertex v2(pp);
2219 BRepLib_MakeEdge ee(v1, v2);
2220 eee1 = TopoDS::Edge(ee.Shape());
2224 if(theFV.IsNull()) {
2225 theFV = TopExp::FirstVertex(eee1,Standard_True);
2226 theFirstpoint = BRep_Tool::Pnt(theFV);
2231 Fin = Standard_True;
2233 if(theLastEdge.IsNull()) {
2234 BRepLib_MakeEdge ee(LastPnt, BndPnt2);
2235 eee2 = TopoDS::Edge(ee.Shape());
2238 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2239 BRepLib_MakeVertex v2(BndPnt2);
2240 BRepLib_MakeEdge ee(v1, v2);
2241 eee2 = TopoDS::Edge(ee.Shape());
2245 if(theFV.IsNull()) {
2246 theFV = TopExp::FirstVertex(eee2,Standard_True);
2247 theFirstpoint = BRep_Tool::Pnt(theFV);
2253 if(explo.Current().IsNull()) {
2254 explo.Init(BndWire);
2257 else explo.Init(BndWire);
2261 if(theLastEdge.IsNull()) {
2262 BRepLib_MakeEdge e3(BndPnt2, firstpoint);
2263 eee3 = TopoDS::Edge(e3.Shape());
2266 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2267 BRepLib_MakeVertex v2(firstpoint);
2268 BRepLib_MakeEdge e3(v1, v2);
2269 eee3 = TopoDS::Edge(e3.Shape());
2273 if(theFV.IsNull()) {
2274 theFV = TopExp::FirstVertex(eee3,Standard_True);
2275 theFirstpoint = BRep_Tool::Pnt(theFV);
2280 if(Concavite == 1) {
2282 if(theLastEdge.IsNull()) {
2283 BRepLib_MakeEdge e(Pt, firstpoint);
2284 eee4 = TopoDS::Edge(e.Shape());
2287 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2288 BRepLib_MakeVertex v2(firstpoint);
2289 BRepLib_MakeEdge e(v1, v2);
2290 eee4 = TopoDS::Edge(e.Shape());
2293 if(theFV.IsNull()) {
2294 theFV = TopExp::FirstVertex(eee4,Standard_True);
2295 theFirstpoint = BRep_Tool::Pnt(theFV);
2301 if(FirstEdge.IsSame(LastEdge)) {
2302 if(!myLFMap.IsBound(FirstEdge)) {
2303 TopTools_ListOfShape thelist;
2304 myLFMap.Bind(FirstEdge, thelist);
2306 if(OnFirstFace || OnLastFace) {
2307 TopoDS_Edge theEdge;
2309 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseOnlyOne, f, l);
2310 if(!theLastEdge.IsNull()) {
2311 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2313 const gp_Pnt& pp = BRep_Tool::
2314 Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True));
2315 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2318 else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True);
2319 BRepLib_MakeEdge e(cc, v1, v2);
2320 theEdge = TopoDS::Edge(e.Shape());
2323 const TopoDS_Vertex& v1 = TopExp::FirstVertex(FalseOnlyOne,Standard_True);
2325 const gp_Pnt& pp = BRep_Tool::
2326 Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True));
2327 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2330 else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True);
2331 BRepLib_MakeEdge e(cc, v1, v2);
2332 theEdge = TopoDS::Edge(e.Shape());
2334 myLFMap(FirstEdge).Append(theEdge);
2336 if(theFV.IsNull()) theFV = TopExp::FirstVertex(theEdge,Standard_True);
2337 theLastEdge = theEdge;
2341 Handle(Geom_Curve) cc = BRep_Tool::Curve(FirstEdge, f, l);
2342 TopoDS_Edge theEdge;
2343 if(!theLastEdge.IsNull()) {
2344 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2346 // Attention case Wire Reversed -> LastVertex without Standard_True
2347 const gp_Pnt& pp = BRep_Tool::Pnt(TopExp::LastVertex(FirstEdge));
2348 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2351 else v2 = TopExp::LastVertex(FirstEdge);
2352 BRepLib_MakeEdge e(cc, v1, v2);
2353 theEdge = TopoDS::Edge(e.Shape());
2356 const TopoDS_Vertex& v1 = TopExp::FirstVertex(FirstEdge,Standard_True);
2358 const gp_Pnt& pp = BRep_Tool::
2359 Pnt(TopExp::LastVertex(FirstEdge,Standard_True));
2360 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2363 else v2 = TopExp::LastVertex(FirstEdge,Standard_True);
2364 BRepLib_MakeEdge e(cc, v1, v2);
2365 theEdge = TopoDS::Edge(e.Shape());
2367 myLFMap(FirstEdge).Append(theEdge);
2369 if(theFV.IsNull()) theFV = TopExp::FirstVertex(theEdge,Standard_True);
2370 theLastEdge = theEdge;
2374 if(!myLFMap.IsBound(FirstEdge)) {
2375 TopTools_ListOfShape thelist1;
2376 myLFMap.Bind(FirstEdge, thelist1);
2379 TopoDS_Edge theEdge;
2381 Handle(Geom_Curve) cc = BRep_Tool::Curve(FirstEdge, f, l);
2382 if(!theLastEdge.IsNull()) {
2383 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2384 const TopoDS_Vertex& v2 = TopExp::LastVertex(FirstEdge,Standard_True);
2385 BRepLib_MakeEdge e(cc, v1, v2);
2386 theEdge = TopoDS::Edge(e.Shape());
2389 theEdge = FirstEdge;
2391 myLFMap(FirstEdge).Append(theEdge);
2393 if(theFV.IsNull()) theFV = TopExp::FirstVertex(theEdge,Standard_True);
2394 theLastEdge = theEdge;
2397 TopoDS_Edge theEdge;
2399 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseFirstEdge, f, l);
2400 if(!theLastEdge.IsNull()) {
2401 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2402 const TopoDS_Vertex& v2 = TopExp::LastVertex(FalseFirstEdge,Standard_True);
2403 BRepLib_MakeEdge e(cc, v1, v2);
2404 theEdge = TopoDS::Edge(e.Shape());
2407 theEdge = FalseFirstEdge;
2409 myLFMap(FirstEdge).Append(theEdge);
2411 if(theFV.IsNull()) theFV = TopExp::FirstVertex(theEdge,Standard_True);
2412 theLastEdge = theEdge;
2415 BRepTools_WireExplorer ex(myWire);
2416 for(; ex.More(); ex.Next()) {
2417 const TopoDS_Edge& E = ex.Current();
2418 if(E.IsSame(FirstEdge)) break;
2423 for(; ex.More(); ex.Next()) {
2424 const TopoDS_Edge& E = ex.Current();
2425 if(!E.IsSame(LastEdge)) {
2426 if(!myLFMap.IsBound(E)) {
2427 TopTools_ListOfShape thelist2;
2428 myLFMap.Bind(E, thelist2);
2432 Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l);
2433 if(!theLastEdge.IsNull()) {
2434 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2435 const TopoDS_Vertex& v2 = TopExp::LastVertex(E,Standard_True);
2436 BRepLib_MakeEdge e(cc, v1, v2);
2437 eee = TopoDS::Edge(e.Shape());
2442 myLFMap(E).Append(eee);
2444 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True);
2452 if(!FirstEdge.IsSame(LastEdge)) {
2453 const TopoDS_Edge& edg = TopoDS::Edge(ex.Current());
2454 if(!myLFMap.IsBound(edg)) {
2455 TopTools_ListOfShape thelist3;
2456 myLFMap.Bind(edg, thelist3);
2460 Handle(Geom_Curve) cc = BRep_Tool::Curve(edg, f, l);
2461 if(!theLastEdge.IsNull()) {
2462 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2464 const gp_Pnt& pp = BRep_Tool::
2465 Pnt(TopExp::LastVertex(edg,Standard_True));
2466 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2469 else v2 = TopExp::LastVertex(edg,Standard_True);
2470 BRepLib_MakeEdge e(cc, v1, v2);
2471 eee = TopoDS::Edge(e.Shape());
2474 const TopoDS_Vertex& v1 = TopExp::FirstVertex(edg,Standard_True);
2476 const gp_Pnt& pp = BRep_Tool::
2477 Pnt(TopExp::LastVertex(edg,Standard_True));
2478 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2481 else v2 = TopExp::LastVertex(edg,Standard_True);
2482 BRepLib_MakeEdge e(cc, v1, v2);
2483 eee = TopoDS::Edge(e.Shape());
2485 myLFMap(edg).Append(eee);
2487 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True);
2493 if(!myLFMap.IsBound(LastEdge)) {
2494 TopTools_ListOfShape thelist4;
2495 myLFMap.Bind(LastEdge, thelist4);
2497 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseOnlyOne, f, l);
2498 if(!theLastEdge.IsNull()) {
2499 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2501 const gp_Pnt& pp = BRep_Tool::
2502 Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True));
2503 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2506 else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True);
2507 BRepLib_MakeEdge e(cc, v1, v2);
2508 eee = TopoDS::Edge(e.Shape());
2511 const TopoDS_Vertex& v1 = TopExp::FirstVertex(FalseOnlyOne,Standard_True);
2513 const gp_Pnt& pp = BRep_Tool::
2514 Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True));
2515 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2518 else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True);
2519 BRepLib_MakeEdge e(cc, v1, v2);
2520 eee = TopoDS::Edge(e.Shape());
2522 myLFMap(LastEdge).Append(eee);
2524 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True);
2531 if(!myLFMap.IsBound(LastEdge)) {
2532 TopTools_ListOfShape thelist5;
2533 myLFMap.Bind(LastEdge, thelist5);
2535 Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseLastEdge, f, l);
2536 if(!theLastEdge.IsNull()) {
2537 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2539 const gp_Pnt& pp = BRep_Tool::
2540 Pnt(TopExp::LastVertex(FalseLastEdge,Standard_True));
2541 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2544 else v2 = TopExp::LastVertex(FalseLastEdge,Standard_True);
2545 BRepLib_MakeEdge e(cc, v1, v2);
2546 eee = TopoDS::Edge(e.Shape());
2549 const TopoDS_Vertex& v1 = TopExp::FirstVertex(FalseLastEdge,Standard_True);
2551 const gp_Pnt& pp = BRep_Tool::
2552 Pnt(TopExp::LastVertex(FalseLastEdge,Standard_True));
2553 if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) {
2556 else v2 = TopExp::LastVertex(FalseLastEdge,Standard_True);
2557 BRepLib_MakeEdge e(cc, v1, v2);
2558 eee = TopoDS::Edge(e.Shape());
2560 myLFMap(LastEdge).Append(eee);
2562 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True);
2567 if(Concavite == 1) {
2569 if(theLastEdge.IsNull()) {
2570 BRepLib_MakeEdge ef(lastpoint, Pt);
2571 eef = TopoDS::Edge(ef.Shape());
2574 const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True);
2575 BRepLib_MakeVertex vv(Pt);
2576 TopoDS_Vertex v2 = TopoDS::Vertex(vv.Shape());
2577 if(!theFV.IsNull() &&
2578 Pt.Distance(theFirstpoint) <= myTol) v2 = theFV;
2580 BRepLib_MakeEdge ef(v1, v2);
2581 eef = TopoDS::Edge(ef.Shape());
2584 if(theFV.IsNull()) theFV = TopExp::FirstVertex(eef,Standard_True);
2588 if(Concavite == 2) {
2589 BRepLib_MakeEdge ee(lastpoint, firstpoint);
2590 const TopoDS_Edge& e = ee.Edge();
2594 BRepLib_MakeFace fa(myPln->Pln(), w, Standard_True);
2595 TopoDS_Face fac = TopoDS::Face(fa.Shape());
2597 if (!BRepAlgo::IsValid(fac)) {
2599 if (trc) cout << " Invalid Face" << endl;
2601 ProfileOK = Standard_False;
2606 if(Concavite == 3) {
2607 BRepTopAdaptor_FClass2d Cl(fac, BRep_Tool::Tolerance(fac));
2609 ElSLib::Parameters(myPln->Pln(), CheckPnt, u, v);
2610 gp_Pnt2d checkpnt2d(u, v);
2611 if(Cl.Perform(checkpnt2d, Standard_True) == TopAbs_OUT) {
2612 //modified by NIZNHY-PKV Fri Mar 22 16:47:06 2002 f
2613 //BRepAlgo_Cut c(BndFace, fac);
2614 BRepAlgoAPI_Cut c(BndFace, fac);
2615 //modified by NIZNHY-PKV Fri Mar 22 16:47:09 2002 t
2616 TopExp_Explorer exp(c.Shape(), TopAbs_WIRE);
2617 //modified by NIZNHY-PKV Fri Mar 22 16:47:23 2002 f
2618 //UpdateDescendants(c.Builder(), c.Shape(), Standard_False);
2619 UpdateDescendants(c, c.Shape(), Standard_False);
2620 //modified by NIZNHY-PKV Fri Mar 22 16:47:28 2002 t
2621 const TopoDS_Wire& ww = TopoDS::Wire(exp.Current());//modified by NIZNHY-PKV Fri Mar 22 17:10:16 2002 ww/w
2622 BRepLib_MakeFace ff(ww);
2623 Prof = TopoDS::Face(ff.Shape());
2633 if (!BRepAlgo::IsValid(Prof)) {
2635 if (trc) cout << " Invalid Face Profile" << endl;
2637 ProfileOK = Standard_False;
2643 //modified by NIZNHY-PKV Thu Mar 21 18:43:18 2002 f
2644 //=======================================================================
2645 //function : UpdateDescendants
2647 //=======================================================================
2648 void BRepFeat_RibSlot::UpdateDescendants(const BRepAlgoAPI_BooleanOperation& aBOP,
2649 const TopoDS_Shape& S,
2650 const Standard_Boolean SkipFace)
2652 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm;
2653 TopTools_ListIteratorOfListOfShape it,it2;
2654 TopTools_MapIteratorOfMapOfShape itm;
2655 TopExp_Explorer exp;
2657 for (itdm.Initialize(myMap);itdm.More();itdm.Next()) {
2658 const TopoDS_Shape& orig = itdm.Key();
2659 if (SkipFace && orig.ShapeType() == TopAbs_FACE) {
2662 TopTools_MapOfShape newdsc;
2664 //if (itdm.Value().IsEmpty()) {myMap.ChangeFind(orig).Append(orig);}
2666 for (it.Initialize(itdm.Value());it.More();it.Next()) {
2667 const TopoDS_Shape& sh = it.Value();
2668 if(sh.ShapeType() != TopAbs_FACE) continue;
2669 const TopoDS_Face& fdsc = TopoDS::Face(it.Value());
2670 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
2671 if (exp.Current().IsSame(fdsc)) { // preserved
2677 BRepAlgoAPI_BooleanOperation* pBOP=(BRepAlgoAPI_BooleanOperation*)&aBOP;
2678 const TopTools_ListOfShape& aLM=pBOP->Modified(fdsc);
2679 it2.Initialize(aLM);
2680 for (; it2.More(); it2.Next()) {
2681 const TopoDS_Shape& aS=it2.Value();
2687 myMap.ChangeFind(orig).Clear();
2688 for (itm.Initialize(newdsc); itm.More(); itm.Next()) {
2689 // check the belonging to the shape...
2690 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
2691 if (exp.Current().IsSame(itm.Key())) {
2692 // const TopoDS_Shape& sh = itm.Key();
2693 myMap.ChangeFind(orig).Append(itm.Key());
2700 //modified by NIZNHY-PKV Thu Mar 21 18:43:36 2002 t
2702 //=======================================================================
2703 //function : UpdateDescendants
2705 //=======================================================================
2706 void BRepFeat_RibSlot::UpdateDescendants(const Handle(BOP_HistoryCollector)& aBOP,
2707 const TopoDS_Shape& S,
2708 const Standard_Boolean SkipFace)
2710 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm;
2711 TopTools_ListIteratorOfListOfShape it,it2;
2712 TopTools_MapIteratorOfMapOfShape itm;
2713 TopExp_Explorer exp;
2715 for (itdm.Initialize(myMap);itdm.More();itdm.Next()) {
2716 const TopoDS_Shape& orig = itdm.Key();
2717 if (SkipFace && orig.ShapeType() == TopAbs_FACE) {
2720 TopTools_MapOfShape newdsc;
2722 //if (itdm.Value().IsEmpty()) {myMap.ChangeFind(orig).Append(orig);}
2724 for (it.Initialize(itdm.Value());it.More();it.Next()) {
2725 const TopoDS_Shape& sh = it.Value();
2726 if(sh.ShapeType() != TopAbs_FACE) continue;
2727 const TopoDS_Face& fdsc = TopoDS::Face(it.Value());
2728 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
2729 if (exp.Current().IsSame(fdsc)) { // preserved
2735 const TopTools_ListOfShape& aLM=aBOP->Modified(fdsc);
2736 it2.Initialize(aLM);
2737 for (; it2.More(); it2.Next()) {
2738 const TopoDS_Shape& aS=it2.Value();
2744 myMap.ChangeFind(orig).Clear();
2745 for (itm.Initialize(newdsc); itm.More(); itm.Next()) {
2746 // check the belonging to the shape...
2747 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
2748 if (exp.Current().IsSame(itm.Key())) {
2749 // const TopoDS_Shape& sh = itm.Key();
2750 myMap.ChangeFind(orig).Append(itm.Key());