1 // File: BRepFeat_MakeRevol.cxx
2 // Created: Tue Feb 13 14:42:59 1996
3 // Author: Jacques GOUSSARD
7 #include <BRepFeat_MakeRevol.ixx>
9 #include <BRepFeat.hxx>
11 #include <LocOpe_Revol.hxx>
12 #include <LocOpe_Builder.hxx>
13 #include <LocOpe_Gluer.hxx>
14 #include <LocOpe_FindEdges.hxx>
15 #include <LocOpe_SequenceOfCirc.hxx>
16 #include <LocOpe_BuildShape.hxx>
17 #include <LocOpe_CSIntersector.hxx>
18 #include <LocOpe_PntFace.hxx>
23 #include <gp_Pnt2d.hxx>
24 #include <TColgp_SequenceOfPnt.hxx>
25 #include <Geom_Surface.hxx>
26 #include <Geom_Curve.hxx>
27 #include <Geom_Circle.hxx>
28 #include <Geom2d_Curve.hxx>
29 #include <Geom_RectangularTrimmedSurface.hxx>
30 #include <Bnd_Box.hxx>
32 #include <BRepSweep_Revol.hxx>
33 #include <BRep_Builder.hxx>
34 #include <BRep_Tool.hxx>
35 #include <TopExp_Explorer.hxx>
36 #include <TopTools_MapOfShape.hxx>
37 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
38 #include <TopTools_ListIteratorOfListOfShape.hxx>
39 #include <TopTools_MapIteratorOfMapOfShape.hxx>
40 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
42 #include <BRepAlgoAPI_Cut.hxx>
43 #include <BRepAlgoAPI_Fuse.hxx>
45 #include <BRepLib_MakeFace.hxx>
46 #include <BRepTools_Modifier.hxx>
47 #include <BRepTools_TrsfModification.hxx>
49 #include <Standard_ConstructionError.hxx>
51 #include <TopoDS_Solid.hxx>
52 #include <TopoDS_Compound.hxx>
53 #include <TopoDS_Shell.hxx>
56 #include <Geom_Plane.hxx>
60 #include <Precision.hxx>
61 #include <BRepBndLib.hxx>
62 #include <BRepBuilderAPI.hxx>
63 #include <BRepFeat.hxx>
68 Standard_IMPORT Standard_Boolean BRepFeat_GettraceFEAT();
71 static void MajMap(const TopoDS_Shape&, // base
73 TopTools_DataMapOfShapeListOfShape&, // myMap
74 TopoDS_Shape&, // myFShape
75 TopoDS_Shape&); // myLShape
78 static void SetGluedFaces(const TopoDS_Face& theSkface,
79 const TopoDS_Shape& theSbase,
80 const TopoDS_Shape& thePbase,
81 const TopTools_DataMapOfShapeListOfShape& theSlmap,
83 TopTools_DataMapOfShapeShape&);
86 static void VerifGluedFaces(const TopoDS_Face& theSkface,
87 const TopoDS_Shape& thePbase,
88 Handle(Geom_Curve)& theBCurve,
89 TColGeom_SequenceOfCurve& theCurves,
90 LocOpe_Revol& theRevol,
91 TopTools_DataMapOfShapeShape& theMap);
94 static Standard_Boolean ToFuse(const TopoDS_Face& ,
100 //=======================================================================
103 //=======================================================================
105 void BRepFeat_MakeRevol::Init(const TopoDS_Shape& Sbase,
106 const TopoDS_Shape& Pbase,
107 const TopoDS_Face& Skface,
109 const Standard_Integer Mode,
110 const Standard_Boolean Modify)
113 Standard_Boolean trc = BRepFeat_GettraceFEAT();
114 if (trc) cout << "BRepFeat_MakeRevol::Init" << endl;
125 myFuse = Standard_False;
126 myJustFeat = Standard_False;
129 myFuse = Standard_True;
130 myJustFeat = Standard_False;
133 myFuse = Standard_True;
134 myJustFeat = Standard_True;
139 myJustGluer = Standard_False;
142 // mySkface.Nullify();
151 for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
152 TopTools_ListOfShape thelist;
153 myMap.Bind(exp.Current(), thelist);
154 myMap(exp.Current()).Append(exp.Current());
158 if (myJustFeat) cout << " Just Feature" << endl;
159 if (myFuse) cout << " Fuse" << endl;
160 if (!myFuse) cout << " Cut" << endl;
161 if (!myModify) cout << " Modify = 0" << endl;
167 //=======================================================================
169 //purpose : add faces et edges de glissement
170 //=======================================================================
172 void BRepFeat_MakeRevol::Add(const TopoDS_Edge& E,
173 const TopoDS_Face& F)
176 Standard_Boolean trc = BRepFeat_GettraceFEAT();
177 if (trc) cout << "BRepFeat_MakeRevol::Add(Edge,face)" << endl;
180 for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
181 if (exp.Current().IsSame(F)) {
186 Standard_ConstructionError::Raise();
189 for (exp.Init(myPbase,TopAbs_EDGE);exp.More();exp.Next()) {
190 if (exp.Current().IsSame(E)) {
195 Standard_ConstructionError::Raise();
198 if (!mySlface.IsBound(F)) {
199 TopTools_ListOfShape thelist;
200 mySlface.Bind(F, thelist);
202 TopTools_ListIteratorOfListOfShape itl(mySlface(F));
203 for (; itl.More();itl.Next()) {
204 if (itl.Value().IsSame(E)) {
209 mySlface(F).Append(E);
214 //=======================================================================
217 //=======================================================================
219 void BRepFeat_MakeRevol::Perform(const Standard_Real Angle)
222 Standard_Boolean trc = BRepFeat_GettraceFEAT();
223 if (trc) cout << "BRepFeat_MakeRevol::Perform(Angle)" << endl;
230 myPerfSelection = BRepFeat_NoSelection;
231 PerfSelectionValid();
232 Standard_Boolean RevolComp = (2*PI-Abs(Angle) <= Precision::Angular());
233 LocOpe_Revol theRevol;
234 Standard_Real angledec = 0.;
238 if (!mySkface.IsNull() || !mySlface.IsEmpty()) {
239 for (exp.Init(mySbase,TopAbs_FACE); exp.More(); exp.Next()) {
240 if (exp.Current().IsSame(mySkface)) {
241 angledec = PI/5; // pourquoi pas
242 if (myFuse) angledec = -angledec;
250 if(angledec == 0.) theRevol.Perform(myPbase, myAxis, Angle);
251 else theRevol.Perform(myPbase, myAxis, Angle, angledec);
253 TopoDS_Shape VraiRevol = theRevol.Shape();
255 MajMap(myPbase,theRevol,myMap,myFShape,myLShape);
257 myGShape = VraiRevol;
258 GeneratedShapeValid();
259 TopoDS_Shape Base = theRevol.FirstShape();
260 exp.Init(Base, TopAbs_FACE);
261 TopoDS_Face theBase = TopoDS::Face(exp.Current());
265 myStatusError = BRepFeat_InvFirstShape;
271 Standard_Boolean found = Standard_False;
273 if(!mySkface.IsNull() || !mySlface.IsEmpty()) {
274 if(myLShape.ShapeType() == TopAbs_WIRE) {
275 TopExp_Explorer ex1(VraiRevol, TopAbs_FACE);
276 for(; ex1.More(); ex1.Next()) {
277 TopExp_Explorer ex2(ex1.Current(), TopAbs_WIRE);
278 for(; ex2.More(); ex2.Next()) {
279 if(ex2.Current().IsSame(myLShape)) {
280 FFace = TopoDS::Face(ex1.Current());
281 found = Standard_True;
289 TopExp_Explorer exp(mySbase, TopAbs_FACE);
290 for(; exp.More(); exp.Next()) {
291 const TopoDS_Face& ff = TopoDS::Face(exp.Current());
292 if(ToFuse(ff, FFace)) {
293 TopTools_DataMapOfShapeListOfShape sl;
294 if(!FFace.IsSame(myPbase) && BRepFeat::IsInside(ff, FFace))
295 //SetGluedFaces(ff, mySbase, FFace, sl, theRevol, myGluedF);
301 //SetGluedFaces(mySkface, mySbase, theBase, mySlface, theRevol, myGluedF);
303 if (!mySkface.IsNull()) {
304 VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF);
307 if(myGluedF.IsEmpty()) {
309 //modified by NIZNHY-PKV Thu Mar 21 18:15:06 2002 f
310 //BRepAlgo_Fuse f(mySbase, myGShape);
311 //myShape = f.Shape();
312 //UpdateDescendants(f.Builder(), myShape, Standard_False);
313 BRepAlgoAPI_Fuse f(mySbase, myGShape);
315 UpdateDescendants(f, myShape, Standard_False);
316 //modified by NIZNHY-PKV Thu Mar 21 18:15:11 2002 t
319 else if(myFuse == 0) {
320 //modified by NIZNHY-PKV Thu Mar 21 18:15:37 2002 f
321 //BRepAlgo_Cut c(mySbase, myGShape);
322 //myShape = c.Shape();
323 //UpdateDescendants(c.Builder(), myShape, Standard_False);
324 BRepAlgoAPI_Cut c(mySbase, myGShape);
326 UpdateDescendants(c, myShape, Standard_False);
327 //modified by NIZNHY-PKV Thu Mar 21 18:15:47 2002 t
336 theRevol.Curves(myCurves);
337 myBCurve = theRevol.BarycCurve();
343 //=======================================================================
345 //purpose : feature jusqu'au shape Until
346 //=======================================================================
348 void BRepFeat_MakeRevol::Perform(const TopoDS_Shape& Until)
351 Standard_Boolean trc = BRepFeat_GettraceFEAT();
352 if (trc) cout << "BRepFeat_MakeRevol::Perform(Until)" << endl;
354 Standard_Real Angle = 0.;
355 Standard_Boolean TourComplet = Standard_False;
357 if (Until.IsNull()) {
358 Standard_ConstructionError::Raise();
360 TopExp_Explorer exp(Until, TopAbs_FACE);
362 Standard_ConstructionError::Raise();
364 if (!mySkface.IsNull() && Until.IsSame(mySkface)) {
366 TourComplet = Standard_True;
369 myPerfSelection = BRepFeat_SelectionU;
370 PerfSelectionValid();
374 Standard_Boolean Trf = TransformShapeFU(1);
377 // On fait systematiquement un revol quasi-complet
378 // BRepSweep_Revol theRevol(myPbase,myAxis,2.*PI-10.*Precision::Angular());
379 LocOpe_Revol theRevol;
381 Angle = 2.*PI- 3*PI/180.;
383 if (trc) cout << " No complete Revol" << endl;
386 theRevol.Perform(myPbase, myAxis, Angle);
387 TopoDS_Shape VraiRevol = theRevol.Shape();
388 MajMap(myPbase,theRevol,myMap,myFShape,myLShape);
393 myGShape = VraiRevol;
394 GeneratedShapeValid();
396 TopoDS_Shape Base = theRevol.FirstShape();
397 exp.Init(Base, TopAbs_FACE);
398 TopoDS_Face theBase = TopoDS::Face(exp.Current());
402 myStatusError = BRepFeat_InvFirstShape;
406 //SetGluedFaces(mySkface, mySbase, theBase, mySlface, theRevol, myGluedF);
408 //VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF);
410 theRevol.Curves(myCurves);
411 myBCurve = theRevol.BarycCurve();
415 TColGeom_SequenceOfCurve scur;
416 theRevol.Curves(myCurves);
417 myBCurve = theRevol.BarycCurve();
419 scur.Append(myBCurve);
420 LocOpe_CSIntersector ASI(mySUntil);
422 if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
423 TopAbs_Orientation Or = ASI.Point(1,1).Orientation();
424 TopoDS_Face FUntil = ASI.Point(1,1).Face();
427 B.MakeCompound(TopoDS::Compound(Comp));
428 TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or);
429 if (!S.IsNull()) B.Add(Comp,S);
430 //modified by NIZNHY-PKV Thu Mar 21 18:17:31 2002 f
431 //BRepAlgo_Cut trP(VraiRevol,Comp);
432 BRepAlgoAPI_Cut trP(VraiRevol,Comp);
433 //modified by NIZNHY-PKV Thu Mar 21 18:17:37 2002 t
434 TopoDS_Shape Cutsh = trP.Shape();
435 TopExp_Explorer ex(Cutsh, TopAbs_SOLID);
436 for(; ex.More(); ex.Next()) {
437 TopExp_Explorer ex1(ex.Current(), TopAbs_FACE);
438 for(; ex1.More(); ex1.Next()) {
439 const TopoDS_Face& fac = TopoDS::Face(ex1.Current());
440 if(fac.IsSame(myPbase)) {
441 VraiRevol = ex.Current();
447 //modified by NIZNHY-PKV Thu Mar 21 18:17:53 2002 f
448 //BRepAlgo_Fuse f(mySbase, VraiRevol);
449 //myShape = f.Shape();
450 //UpdateDescendants(f.Builder(), myShape, Standard_False);
451 BRepAlgoAPI_Fuse f(mySbase, VraiRevol);
453 UpdateDescendants(f, myShape, Standard_False);
454 //modified by NIZNHY-PKV Thu Mar 21 18:17:57 2002 t
457 else if(myFuse == 0) {
458 //modified by NIZNHY-PKV Thu Mar 21 18:18:23 2002 f
459 //BRepAlgo_Cut c(mySbase, VraiRevol);
460 //myShape = c.Shape();
461 //UpdateDescendants(c.Builder(), myShape, Standard_False);
462 BRepAlgoAPI_Cut c(mySbase, VraiRevol);
464 UpdateDescendants(c, myShape, Standard_False);
465 //modified by NIZNHY-PKV Thu Mar 21 18:18:28 2002 t
474 // boucle de controle de descendance
476 TopExp_Explorer expr(mySbase, TopAbs_FACE);
477 char nom1[20], nom2[20];
478 Standard_Integer ii = 0;
479 for(; expr.More(); expr.Next()) {
481 sprintf(nom1, "faceinitial_%d", ii);
482 DBRep::Set(nom1, expr.Current());
483 Standard_Integer jj = 0;
484 const TopTools_ListOfShape& list = Modified(expr.Current());
485 TopTools_ListIteratorOfListOfShape ite(list);
486 for(; ite.More(); ite.Next()) {
488 sprintf(nom2, "facemodifie_%d_%d", ii, jj);
489 DBRep::Set(nom2, ite.Value());
493 expr.Init(myPbase, TopAbs_EDGE);
495 for(; expr.More(); expr.Next()) {
497 sprintf(nom1, "edgeinitial_%d", ii);
498 DBRep::Set(nom1, expr.Current());
499 Standard_Integer jj = 0;
500 const TopTools_ListOfShape& list = Generated(expr.Current());
501 TopTools_ListIteratorOfListOfShape ite(list);
502 for(; ite.More(); ite.Next()) {
504 sprintf(nom2, "facegeneree_%d_%d", ii, jj);
505 DBRep::Set(nom2, ite.Value());
512 //=======================================================================
514 //purpose : feature limitee par les deux shapes
515 //=======================================================================
517 void BRepFeat_MakeRevol::Perform(const TopoDS_Shape& From,
518 const TopoDS_Shape& Until)
521 Standard_Boolean trc = BRepFeat_GettraceFEAT();
522 if (trc) cout << "BRepFeat_MakeRevol::Perform(From,Until)" << endl;
524 if (From.IsNull() || Until.IsNull()) {
525 Standard_ConstructionError::Raise();
527 if (!mySkface.IsNull()) {
528 if (From.IsSame(mySkface)) {
529 myJustGluer = Standard_True;
531 if (myJustGluer) return;
533 else if (Until.IsSame(mySkface)) {
534 myJustGluer = Standard_True;
537 if (myJustGluer) return;
542 myPerfSelection = BRepFeat_SelectionFU;
543 PerfSelectionValid();
545 TopExp_Explorer exp(From, TopAbs_FACE);
547 Standard_ConstructionError::Raise();
549 exp.Init(Until, TopAbs_FACE);
551 Standard_ConstructionError::Raise();
555 Standard_Boolean Trff = TransformShapeFU(0);
558 Standard_Boolean Trfu = TransformShapeFU(1);
563 myStatusError = BRepFeat_IncTypes;
567 LocOpe_Revol theRevol;
568 theRevol.Perform(myPbase, myAxis, 2*PI);
569 TopoDS_Shape VraiRevol = theRevol.Shape();
571 MajMap(myPbase,theRevol,myMap,myFShape,myLShape);
574 myGShape = VraiRevol;
575 GeneratedShapeValid();
577 //SetGluedFaces(TopoDS_Face(), mySbase, myPbase, mySlface, theRevol, myGluedF);
579 // VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF);
581 theRevol.Curves(myCurves);
582 myBCurve = theRevol.BarycCurve();
586 theRevol.Curves(myCurves);
587 myBCurve = theRevol.BarycCurve();
588 TColGeom_SequenceOfCurve scur;
590 scur.Append(myBCurve);
591 LocOpe_CSIntersector ASI1(mySUntil);
592 LocOpe_CSIntersector ASI2(mySFrom);
595 TopAbs_Orientation OrU, OrF;
596 TopoDS_Face FFrom, FUntil;
597 Standard_Real PrF, PrU;
598 if (ASI1.IsDone() && ASI1.NbPoints(1) >=1) {
599 OrU = ASI1.Point(1,1).Orientation();
600 FUntil = ASI1.Point(1,1).Face();
601 PrU = ASI1.Point(1,1).Parameter();
605 myStatusError = BRepFeat_NoIntersectU;
608 if (ASI2.IsDone() && ASI2.NbPoints(1) >=1) {
609 Standard_Real pr1 = ASI2.Point(1,1).Parameter();
610 pr1 = ElCLib::InPeriod(pr1,PrU-2*PI,PrU);
611 Standard_Real pr2 = ASI2.Point(1,ASI2.NbPoints(1)).Parameter();
612 pr2 = ElCLib::InPeriod(pr2,PrU-2*PI,PrU);
614 FFrom = ASI2.Point(1,1).Face();
619 myStatusError = BRepFeat_NoIntersectF;
624 myStatusError = BRepFeat_IncParameter;
629 B.MakeCompound(TopoDS::Compound(Comp));
630 TopoDS_Solid SF = BRepFeat::Tool(mySFrom, FFrom, OrF);
631 if (!SF.IsNull()) B.Add(Comp,SF);
632 TopoDS_Solid SU = BRepFeat::Tool(mySUntil, FUntil, OrU);
633 if (!SU.IsNull()) B.Add(Comp,SU);
634 //modified by NIZNHY-PKV Thu Mar 21 18:18:54 2002 f
635 //BRepAlgo_Cut trP(VraiRevol,Comp);
636 BRepAlgoAPI_Cut trP(VraiRevol,Comp);
637 //modified by NIZNHY-PKV Thu Mar 21 18:18:57 2002 t
638 TopoDS_Shape Cutsh = trP.Shape();
639 TopExp_Explorer ex(Cutsh, TopAbs_SOLID);
640 // Standard_Real PrF = BRepFeat::ParametricBarycenter(mySFrom, myBCurve);
641 // Standard_Real PrU = BRepFeat::ParametricBarycenter(mySUntil, myBCurve);
642 VraiRevol = ex.Current();
643 for(; ex.More(); ex.Next()) {
644 Standard_Real PrCur = BRepFeat::
645 ParametricBarycenter(ex.Current(), myBCurve);
646 if(PrF <= PrCur && PrU >= PrCur) {
647 VraiRevol = ex.Current();
652 //modified by NIZNHY-PKV Thu Mar 21 18:19:14 2002 f
653 //BRepAlgo_Fuse f(mySbase, VraiRevol);
654 //myShape = f.Shape();
655 //UpdateDescendants(f.Builder(), myShape, Standard_False);
656 BRepAlgoAPI_Fuse f(mySbase, VraiRevol);
658 UpdateDescendants(f, myShape, Standard_False);
659 //modified by NIZNHY-PKV Thu Mar 21 18:19:18 2002 t
662 else if(myFuse == 0) {
663 //modified by NIZNHY-PKV Thu Mar 21 18:19:46 2002 f
664 //BRepAlgo_Cut c(mySbase, VraiRevol);
665 //myShape = c.Shape();
666 //UpdateDescendants(c.Builder(), myShape, Standard_False);
667 BRepAlgoAPI_Cut c(mySbase, VraiRevol);
669 UpdateDescendants(c, myShape, Standard_False);
670 //modified by NIZNHY-PKV Thu Mar 21 18:19:50 2002 t
681 //=======================================================================
682 //function : PerformThruAll
683 //purpose : feature a travers tout le shape initial
684 //=======================================================================
686 void BRepFeat_MakeRevol::PerformThruAll()
689 Standard_Boolean trc = BRepFeat_GettraceFEAT();
690 if (trc) cout << "BRepFeat_MakeRevol::PerformThruAll()" << endl;
695 //=======================================================================
696 //function : PerformUntilAngle
697 //purpose : feature jusqu'au shape Until definie avec l'angle
698 //=======================================================================
700 void BRepFeat_MakeRevol::PerformUntilAngle(const TopoDS_Shape& Until,
701 const Standard_Real Angle)
704 Standard_Boolean trc = BRepFeat_GettraceFEAT();
705 if (trc) cout << "BRepFeat_MakeRevol::PerformUntilAngle(Until,Angle)" << endl;
707 if (Until.IsNull()) {
713 TopExp_Explorer exp(Until, TopAbs_FACE);
715 Standard_ConstructionError::Raise();
717 if (!mySkface.IsNull() && Until.IsSame(mySkface)) {
722 myPerfSelection = BRepFeat_NoSelection;
723 PerfSelectionValid();
727 Standard_Boolean Trf = TransformShapeFU(1);
730 // On fait systematiquement un revol quasi-complet
731 // BRepSweep_Revol theRevol(myPbase,myAxis,2.*PI-10.*Precision::Angular());
732 LocOpe_Revol theRevol;
733 theRevol.Perform(myPbase, myAxis, Angle);
734 TopoDS_Shape VraiRevol = theRevol.Shape();
736 MajMap(myPbase,theRevol,myMap,myFShape,myLShape);
739 myGShape = VraiRevol;
740 GeneratedShapeValid();
742 TopoDS_Shape Base = theRevol.FirstShape();
743 exp.Init(Base, TopAbs_FACE);
744 TopoDS_Face theBase = TopoDS::Face(exp.Current());
748 myStatusError = BRepFeat_InvFirstShape;
752 //SetGluedFaces(mySkface, mySbase, theBase, mySlface, theRevol, myGluedF);
754 //VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF);
757 theRevol.Curves(myCurves);
758 myBCurve = theRevol.BarycCurve();
762 TColGeom_SequenceOfCurve scur;
763 theRevol.Curves(myCurves);
764 myBCurve = theRevol.BarycCurve();
766 scur.Append(myBCurve);
767 LocOpe_CSIntersector ASI(mySUntil);
769 if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
770 TopAbs_Orientation Or = ASI.Point(1,1).Orientation();
771 TopoDS_Face FUntil = ASI.Point(1,1).Face();
774 B.MakeCompound(TopoDS::Compound(Comp));
775 TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or);
776 if (!S.IsNull()) B.Add(Comp,S);
777 //modified by NIZNHY-PKV Thu Mar 21 18:20:14 2002 f
778 //BRepAlgo_Cut trP(VraiRevol,Comp);
779 BRepAlgoAPI_Cut trP(VraiRevol,Comp);
780 //modified by NIZNHY-PKV Thu Mar 21 18:20:19 2002 t
781 TopoDS_Shape Cutsh = trP.Shape();
782 TopExp_Explorer ex(Cutsh, TopAbs_SOLID);
783 for(; ex.More(); ex.Next()) {
784 TopExp_Explorer ex1(ex.Current(), TopAbs_FACE);
785 for(; ex1.More(); ex1.Next()) {
786 const TopoDS_Face& fac = TopoDS::Face(ex1.Current());
787 if(fac.IsSame(myPbase)) {
788 VraiRevol = ex.Current();
794 //modified by NIZNHY-PKV Thu Mar 21 18:20:36 2002 f
795 //BRepAlgo_Fuse f(mySbase, VraiRevol);
796 //myShape = f.Shape();
797 //UpdateDescendants(f.Builder(), myShape, Standard_False);
798 BRepAlgoAPI_Fuse f(mySbase, VraiRevol);
800 UpdateDescendants(f, myShape, Standard_False);
801 //modified by NIZNHY-PKV Thu Mar 21 18:20:40 2002 t
804 else if(myFuse == 0) {
805 //modified by NIZNHY-PKV Thu Mar 21 18:21:07 2002 f
806 //BRepAlgo_Cut c(mySbase, VraiRevol);
807 //myShape = c.Shape();
808 //UpdateDescendants(c.Builder(), myShape, Standard_False);
809 BRepAlgoAPI_Cut c(mySbase, VraiRevol);
811 UpdateDescendants(c, myShape, Standard_False);
812 //modified by NIZNHY-PKV Thu Mar 21 18:21:26 2002 t
822 //=======================================================================
824 //purpose : cercles parallels a la generatrice du revol
825 //=======================================================================
827 void BRepFeat_MakeRevol::Curves(TColGeom_SequenceOfCurve& scur)
832 //=======================================================================
833 //function : BarycCurve
834 //purpose : passe par le centre des masses de la primitive
835 //=======================================================================
837 Handle(Geom_Curve) BRepFeat_MakeRevol::BarycCurve()
843 //=======================================================================
844 //function : SetGluedFaces
845 //purpose : gestion des faces de collage
846 //=======================================================================
848 static void SetGluedFaces(const TopoDS_Face& theSkface,
849 const TopoDS_Shape& theSbase,
850 const TopoDS_Shape& thePbase,
851 const TopTools_DataMapOfShapeListOfShape& theSlmap,
852 LocOpe_Revol& theRevol,
853 TopTools_DataMapOfShapeShape& theMap)
856 if (!theSkface.IsNull() && thePbase.ShapeType() == TopAbs_FACE) {
857 for (exp.Init(theSbase,TopAbs_FACE); exp.More(); exp.Next()) {
858 if (exp.Current().IsSame(theSkface)) {
859 theMap.Bind(thePbase,theSkface);
865 TopExp_Explorer exp2;
866 for (exp.Init(thePbase,TopAbs_FACE);exp.More();exp.Next()) {
867 const TopoDS_Face& fac = TopoDS::Face(exp.Current());
868 for (exp2.Init(theSbase,TopAbs_FACE);exp2.More();exp2.Next()) {
869 if (exp2.Current().IsSame(fac)) {
870 theMap.Bind(fac,fac);
878 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(theSlmap);
879 if(!theSlmap.IsEmpty()) {
880 for (; itm.More(); itm.Next()) {
881 const TopoDS_Face& fac = TopoDS::Face(itm.Key());
882 const TopTools_ListOfShape& ledg = itm.Value();
883 TopTools_ListIteratorOfListOfShape it;
884 for (it.Initialize(ledg); it.More(); it.Next()) {
885 const TopTools_ListOfShape& gfac = theRevol.Shapes(it.Value());
886 if (gfac.Extent() != 1) {
888 Standard_Boolean trc = BRepFeat_GettraceFEAT();
889 if (trc) cout << " BRepFeat_MakeRevol : Pb SetGluedFace" << endl;
892 theMap.Bind(gfac.First(),fac);
898 //=======================================================================
899 //function : VerifGluedFaces
900 //purpose : Verification intersection Outil/theSkface = thePbase
901 // Si oui -> OK si non -> cas sans collage
902 //=======================================================================
904 static void VerifGluedFaces(const TopoDS_Face& theSkface,
905 const TopoDS_Shape& thePbase,
906 Handle(Geom_Curve)& theBCurve,
907 TColGeom_SequenceOfCurve& theCurves,
908 LocOpe_Revol& theRevol,
909 TopTools_DataMapOfShapeShape& theMap)
911 Standard_Boolean GluedFaces = Standard_True;
912 TopoDS_Shape VraiRevol = theRevol.Shape();
914 TColGeom_SequenceOfCurve scur;
915 theRevol.Curves(theCurves);
916 theBCurve = theRevol.BarycCurve();
918 scur.Append(theBCurve);
919 LocOpe_CSIntersector ASI(theSkface);
921 if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
922 TopAbs_Orientation Or = ASI.Point(1,1).Orientation();
923 TopoDS_Face FSk = ASI.Point(1,1).Face();
926 B.MakeCompound(TopoDS::Compound(Comp));
927 TopoDS_Solid S = BRepFeat::Tool(theSkface, FSk, Or);
928 if (!S.IsNull()) B.Add(Comp,S);
929 //modified by NIZNHY-PKV Thu Mar 21 18:21:54 2002 f
930 //BRepAlgo_Cut trP(VraiRevol,Comp);
931 BRepAlgoAPI_Cut trP(VraiRevol,Comp);
932 //modified by NIZNHY-PKV Thu Mar 21 18:21:58 2002 t
933 TopoDS_Shape Cutsh = trP.Shape();
934 TopExp_Explorer ex(Cutsh, TopAbs_SOLID);
935 for(; ex.More(); ex.Next()) {
936 TopExp_Explorer ex1(ex.Current(), TopAbs_FACE);
937 for(; ex1.More(); ex1.Next()) {
938 const TopoDS_Face& fac1 = TopoDS::Face(ex1.Current());
939 TopExp_Explorer ex2(thePbase, TopAbs_FACE);
940 for(; ex2.More(); ex2.Next()) {
941 const TopoDS_Face& fac2 = TopoDS::Face(ex2.Current());
942 if(fac1.IsSame(fac2)) break;
944 if (ex2.More()) break;
946 if (ex1.More()) continue;
947 GluedFaces = Standard_False;
952 Standard_Boolean trc = BRepFeat_GettraceFEAT();
953 if (trc) cout << " Intersection Revol/skface : pas de collage" << endl;
960 //=======================================================================
962 //purpose : gestion de descendants
963 //=======================================================================
965 static void MajMap(const TopoDS_Shape& theB,
966 const LocOpe_Revol& theP,
967 TopTools_DataMapOfShapeListOfShape& theMap, // myMap
968 TopoDS_Shape& theFShape, // myFShape
969 TopoDS_Shape& theLShape) // myLShape
971 TopExp_Explorer exp(theP.FirstShape(),TopAbs_WIRE);
973 theFShape = exp.Current();
974 TopTools_ListOfShape thelist;
975 theMap.Bind(theFShape, thelist);
976 for (exp.Init(theP.FirstShape(),TopAbs_FACE);exp.More();exp.Next()) {
977 theMap(theFShape).Append(exp.Current());
981 exp.Init(theP.LastShape(),TopAbs_WIRE);
983 theLShape = exp.Current();
984 TopTools_ListOfShape thelist1;
985 theMap.Bind(theLShape, thelist1);
986 for (exp.Init(theP.LastShape(),TopAbs_FACE);exp.More();exp.Next()) {
987 theMap(theLShape).Append(exp.Current());
991 for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) {
992 if (!theMap.IsBound(exp.Current())) {
993 TopTools_ListOfShape thelist2;
994 theMap.Bind(exp.Current(), thelist2);
995 theMap(exp.Current()) = theP.Shapes(exp.Current());
1002 //=======================================================================
1004 //purpose : deux faces samedomaine ou pas
1005 //=======================================================================
1007 Standard_Boolean ToFuse(const TopoDS_Face& F1,
1008 const TopoDS_Face& F2)
1010 if (F1.IsNull() || F2.IsNull()) {
1011 return Standard_False;
1014 Handle(Geom_Surface) S1,S2;
1015 TopLoc_Location loc1, loc2;
1016 Handle(Standard_Type) typS1,typS2;
1017 const Standard_Real tollin = Precision::Confusion();
1018 const Standard_Real tolang = Precision::Angular();
1020 S1 = BRep_Tool::Surface(F1,loc1);
1021 S2 = BRep_Tool::Surface(F2,loc2);
1023 typS1 = S1->DynamicType();
1024 typS2 = S2->DynamicType();
1026 if (typS1 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
1027 S1 = (*((Handle(Geom_RectangularTrimmedSurface)*)&S1))->BasisSurface();
1028 typS1 = S1->DynamicType();
1031 if (typS2 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
1032 S2 = (*((Handle(Geom_RectangularTrimmedSurface)*)&S2))->BasisSurface();
1033 typS2 = S2->DynamicType();
1036 if (typS1 != typS2) {
1037 return Standard_False;
1041 Standard_Boolean ValRet = Standard_False;
1042 if (typS1 == STANDARD_TYPE(Geom_Plane)) {
1043 S1 = BRep_Tool::Surface(F1); // pour appliquer la location.
1044 S2 = BRep_Tool::Surface(F2);
1045 gp_Pln pl1( (*((Handle(Geom_Plane)*)&S1))->Pln());
1046 gp_Pln pl2( (*((Handle(Geom_Plane)*)&S2))->Pln());
1048 if (pl1.Position().IsCoplanar(pl2.Position(),tollin,tolang)) {
1049 ValRet = Standard_True;