1 // Created on: 1996-02-13
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <BRepFeat_MakeRevol.ixx>
19 #include <BRepFeat.hxx>
21 #include <LocOpe_Revol.hxx>
22 #include <LocOpe_Gluer.hxx>
23 #include <LocOpe_FindEdges.hxx>
24 #include <LocOpe_SequenceOfCirc.hxx>
25 #include <LocOpe_BuildShape.hxx>
26 #include <LocOpe_CSIntersector.hxx>
27 #include <LocOpe_PntFace.hxx>
32 #include <gp_Pnt2d.hxx>
33 #include <TColgp_SequenceOfPnt.hxx>
34 #include <Geom_Surface.hxx>
35 #include <Geom_Curve.hxx>
36 #include <Geom_Circle.hxx>
37 #include <Geom2d_Curve.hxx>
38 #include <Geom_RectangularTrimmedSurface.hxx>
39 #include <Bnd_Box.hxx>
41 #include <BRepSweep_Revol.hxx>
42 #include <BRep_Builder.hxx>
43 #include <BRep_Tool.hxx>
44 #include <TopExp_Explorer.hxx>
45 #include <TopTools_MapOfShape.hxx>
46 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
47 #include <TopTools_ListIteratorOfListOfShape.hxx>
48 #include <TopTools_MapIteratorOfMapOfShape.hxx>
49 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
51 #include <BRepAlgoAPI_Cut.hxx>
52 #include <BRepAlgoAPI_Fuse.hxx>
54 #include <BRepLib_MakeFace.hxx>
55 #include <BRepTools_Modifier.hxx>
56 #include <BRepTools_TrsfModification.hxx>
58 #include <Standard_ConstructionError.hxx>
60 #include <TopoDS_Solid.hxx>
61 #include <TopoDS_Compound.hxx>
62 #include <TopoDS_Shell.hxx>
65 #include <Geom_Plane.hxx>
69 #include <Precision.hxx>
70 #include <BRepBndLib.hxx>
71 #include <BRepBuilderAPI.hxx>
72 #include <BRepFeat.hxx>
77 extern Standard_Boolean BRepFeat_GettraceFEAT();
80 static void MajMap(const TopoDS_Shape&, // base
82 TopTools_DataMapOfShapeListOfShape&, // myMap
83 TopoDS_Shape&, // myFShape
84 TopoDS_Shape&); // myLShape
87 static void VerifGluedFaces(const TopoDS_Face& theSkface,
88 const TopoDS_Shape& thePbase,
89 Handle(Geom_Curve)& theBCurve,
90 TColGeom_SequenceOfCurve& theCurves,
91 LocOpe_Revol& theRevol,
92 TopTools_DataMapOfShapeShape& theMap);
95 static Standard_Boolean ToFuse(const TopoDS_Face& ,
101 //=======================================================================
104 //=======================================================================
106 void BRepFeat_MakeRevol::Init(const TopoDS_Shape& Sbase,
107 const TopoDS_Shape& Pbase,
108 const TopoDS_Face& Skface,
110 const Standard_Integer Mode,
111 const Standard_Boolean Modify)
114 Standard_Boolean trc = BRepFeat_GettraceFEAT();
115 if (trc) cout << "BRepFeat_MakeRevol::Init" << endl;
126 myFuse = Standard_False;
127 myJustFeat = Standard_False;
130 myFuse = Standard_True;
131 myJustFeat = Standard_False;
134 myFuse = Standard_True;
135 myJustFeat = Standard_True;
140 myJustGluer = Standard_False;
143 // mySkface.Nullify();
152 for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
153 TopTools_ListOfShape thelist;
154 myMap.Bind(exp.Current(), thelist);
155 myMap(exp.Current()).Append(exp.Current());
159 if (myJustFeat) cout << " Just Feature" << endl;
160 if (myFuse) cout << " Fuse" << endl;
161 if (!myFuse) cout << " Cut" << endl;
162 if (!myModify) cout << " Modify = 0" << endl;
168 //=======================================================================
170 //purpose : add faces add edges of sliding
171 //=======================================================================
173 void BRepFeat_MakeRevol::Add(const TopoDS_Edge& E,
174 const TopoDS_Face& F)
177 Standard_Boolean trc = BRepFeat_GettraceFEAT();
178 if (trc) cout << "BRepFeat_MakeRevol::Add(Edge,face)" << endl;
181 for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
182 if (exp.Current().IsSame(F)) {
187 Standard_ConstructionError::Raise();
190 for (exp.Init(myPbase,TopAbs_EDGE);exp.More();exp.Next()) {
191 if (exp.Current().IsSame(E)) {
196 Standard_ConstructionError::Raise();
199 if (!mySlface.IsBound(F)) {
200 TopTools_ListOfShape thelist;
201 mySlface.Bind(F, thelist);
203 TopTools_ListIteratorOfListOfShape itl(mySlface(F));
204 for (; itl.More();itl.Next()) {
205 if (itl.Value().IsSame(E)) {
210 mySlface(F).Append(E);
215 //=======================================================================
218 //=======================================================================
220 void BRepFeat_MakeRevol::Perform(const Standard_Real Angle)
223 Standard_Boolean trc = BRepFeat_GettraceFEAT();
224 if (trc) cout << "BRepFeat_MakeRevol::Perform(Angle)" << endl;
231 myPerfSelection = BRepFeat_NoSelection;
232 PerfSelectionValid();
233 Standard_Boolean RevolComp = (2*M_PI-Abs(Angle) <= Precision::Angular());
234 LocOpe_Revol theRevol;
235 Standard_Real angledec = 0.;
239 if (!mySkface.IsNull() || !mySlface.IsEmpty()) {
240 for (exp.Init(mySbase,TopAbs_FACE); exp.More(); exp.Next()) {
241 if (exp.Current().IsSame(mySkface)) {
242 angledec = M_PI/5; // pourquoi pas
243 if (myFuse) angledec = -angledec;
251 if(angledec == 0.) theRevol.Perform(myPbase, myAxis, Angle);
252 else theRevol.Perform(myPbase, myAxis, Angle, angledec);
254 TopoDS_Shape VraiRevol = theRevol.Shape();
256 MajMap(myPbase,theRevol,myMap,myFShape,myLShape);
258 myGShape = VraiRevol;
259 GeneratedShapeValid();
260 TopoDS_Shape Base = theRevol.FirstShape();
261 exp.Init(Base, TopAbs_FACE);
262 TopoDS_Face theBase = TopoDS::Face(exp.Current());
266 myStatusError = BRepFeat_InvFirstShape;
272 Standard_Boolean found = Standard_False;
274 if(!mySkface.IsNull() || !mySlface.IsEmpty()) {
275 if(myLShape.ShapeType() == TopAbs_WIRE) {
276 TopExp_Explorer ex1(VraiRevol, TopAbs_FACE);
277 for(; ex1.More(); ex1.Next()) {
278 TopExp_Explorer ex2(ex1.Current(), TopAbs_WIRE);
279 for(; ex2.More(); ex2.Next()) {
280 if(ex2.Current().IsSame(myLShape)) {
281 FFace = TopoDS::Face(ex1.Current());
282 found = Standard_True;
290 TopExp_Explorer exp(mySbase, TopAbs_FACE);
291 for(; exp.More(); exp.Next()) {
292 const TopoDS_Face& ff = TopoDS::Face(exp.Current());
293 if(ToFuse(ff, FFace)) {
294 TopTools_DataMapOfShapeListOfShape sl;
295 if(!FFace.IsSame(myPbase) && BRepFeat::IsInside(ff, FFace))
301 if (!mySkface.IsNull()) {
302 VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF);
305 if(myGluedF.IsEmpty()) {
307 //modified by NIZNHY-PKV Thu Mar 21 18:15:06 2002 f
308 //BRepAlgo_Fuse f(mySbase, myGShape);
309 //myShape = f.Shape();
310 //UpdateDescendants(f.Builder(), myShape, Standard_False);
311 BRepAlgoAPI_Fuse f(mySbase, myGShape);
313 UpdateDescendants(f, myShape, Standard_False);
314 //modified by NIZNHY-PKV Thu Mar 21 18:15:11 2002 t
317 else if(myFuse == 0) {
318 //modified by NIZNHY-PKV Thu Mar 21 18:15:37 2002 f
319 //BRepAlgo_Cut c(mySbase, myGShape);
320 //myShape = c.Shape();
321 //UpdateDescendants(c.Builder(), myShape, Standard_False);
322 BRepAlgoAPI_Cut c(mySbase, myGShape);
324 UpdateDescendants(c, myShape, Standard_False);
325 //modified by NIZNHY-PKV Thu Mar 21 18:15:47 2002 t
334 theRevol.Curves(myCurves);
335 myBCurve = theRevol.BarycCurve();
341 //=======================================================================
343 //purpose : feature till shape Until
344 //=======================================================================
346 void BRepFeat_MakeRevol::Perform(const TopoDS_Shape& Until)
349 Standard_Boolean trc = BRepFeat_GettraceFEAT();
350 if (trc) cout << "BRepFeat_MakeRevol::Perform(Until)" << endl;
352 Standard_Real Angle = 0.;
353 Standard_Boolean TourComplet = Standard_False;
355 if (Until.IsNull()) {
356 Standard_ConstructionError::Raise();
358 TopExp_Explorer exp(Until, TopAbs_FACE);
360 Standard_ConstructionError::Raise();
362 if (!mySkface.IsNull() && Until.IsSame(mySkface)) {
364 TourComplet = Standard_True;
367 myPerfSelection = BRepFeat_SelectionU;
368 PerfSelectionValid();
372 Standard_Boolean Trf = TransformShapeFU(1);
375 // Do systematically almost complete revolution
376 // BRepSweep_Revol theRevol(myPbase,myAxis,2.*M_PI-10.*Precision::Angular());
377 LocOpe_Revol theRevol;
379 Angle = 2.*M_PI- 3*M_PI/180.;
381 if (trc) cout << " No complete Revolution" << endl;
384 theRevol.Perform(myPbase, myAxis, Angle);
385 TopoDS_Shape VraiRevol = theRevol.Shape();
386 MajMap(myPbase,theRevol,myMap,myFShape,myLShape);
391 myGShape = VraiRevol;
392 GeneratedShapeValid();
394 TopoDS_Shape Base = theRevol.FirstShape();
395 exp.Init(Base, TopAbs_FACE);
396 TopoDS_Face theBase = TopoDS::Face(exp.Current());
400 myStatusError = BRepFeat_InvFirstShape;
404 //VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF);
406 theRevol.Curves(myCurves);
407 myBCurve = theRevol.BarycCurve();
411 TColGeom_SequenceOfCurve scur;
412 theRevol.Curves(myCurves);
413 myBCurve = theRevol.BarycCurve();
415 scur.Append(myBCurve);
416 LocOpe_CSIntersector ASI(mySUntil);
418 if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
419 TopAbs_Orientation Or = ASI.Point(1,1).Orientation();
420 TopoDS_Face FUntil = ASI.Point(1,1).Face();
423 B.MakeCompound(TopoDS::Compound(Comp));
424 TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or);
425 if (!S.IsNull()) B.Add(Comp,S);
426 //modified by NIZNHY-PKV Thu Mar 21 18:17:31 2002 f
427 //BRepAlgo_Cut trP(VraiRevol,Comp);
428 BRepAlgoAPI_Cut trP(VraiRevol,Comp);
429 //modified by NIZNHY-PKV Thu Mar 21 18:17:37 2002 t
430 TopoDS_Shape Cutsh = trP.Shape();
431 TopExp_Explorer ex(Cutsh, TopAbs_SOLID);
432 for(; ex.More(); ex.Next()) {
433 TopExp_Explorer ex1(ex.Current(), TopAbs_FACE);
434 for(; ex1.More(); ex1.Next()) {
435 const TopoDS_Face& fac = TopoDS::Face(ex1.Current());
436 if(fac.IsSame(myPbase)) {
437 VraiRevol = ex.Current();
443 //modified by NIZNHY-PKV Thu Mar 21 18:17:53 2002 f
444 //BRepAlgo_Fuse f(mySbase, VraiRevol);
445 //myShape = f.Shape();
446 //UpdateDescendants(f.Builder(), myShape, Standard_False);
447 BRepAlgoAPI_Fuse f(mySbase, VraiRevol);
449 UpdateDescendants(f, myShape, Standard_False);
450 //modified by NIZNHY-PKV Thu Mar 21 18:17:57 2002 t
453 else if(myFuse == 0) {
454 //modified by NIZNHY-PKV Thu Mar 21 18:18:23 2002 f
455 //BRepAlgo_Cut c(mySbase, VraiRevol);
456 //myShape = c.Shape();
457 //UpdateDescendants(c.Builder(), myShape, Standard_False);
458 BRepAlgoAPI_Cut c(mySbase, VraiRevol);
460 UpdateDescendants(c, myShape, Standard_False);
461 //modified by NIZNHY-PKV Thu Mar 21 18:18:28 2002 t
470 // Loop of control of descendance
472 TopExp_Explorer expr(mySbase, TopAbs_FACE);
473 char nom1[20], nom2[20];
474 Standard_Integer ii = 0;
475 for(; expr.More(); expr.Next()) {
477 sprintf(nom1, "faceinitial_%d", ii);
478 DBRep::Set(nom1, expr.Current());
479 Standard_Integer jj = 0;
480 const TopTools_ListOfShape& list = Modified(expr.Current());
481 TopTools_ListIteratorOfListOfShape ite(list);
482 for(; ite.More(); ite.Next()) {
484 sprintf(nom2, "facemodifie_%d_%d", ii, jj);
485 DBRep::Set(nom2, ite.Value());
489 expr.Init(myPbase, TopAbs_EDGE);
491 for(; expr.More(); expr.Next()) {
493 sprintf(nom1, "edgeinitial_%d", ii);
494 DBRep::Set(nom1, expr.Current());
495 Standard_Integer jj = 0;
496 const TopTools_ListOfShape& list = Generated(expr.Current());
497 TopTools_ListIteratorOfListOfShape ite(list);
498 for(; ite.More(); ite.Next()) {
500 sprintf(nom2, "facegeneree_%d_%d", ii, jj);
501 DBRep::Set(nom2, ite.Value());
508 //=======================================================================
510 //purpose : feature limited by two shapes
511 //=======================================================================
513 void BRepFeat_MakeRevol::Perform(const TopoDS_Shape& From,
514 const TopoDS_Shape& Until)
517 Standard_Boolean trc = BRepFeat_GettraceFEAT();
518 if (trc) cout << "BRepFeat_MakeRevol::Perform(From,Until)" << endl;
520 if (From.IsNull() || Until.IsNull()) {
521 Standard_ConstructionError::Raise();
523 if (!mySkface.IsNull()) {
524 if (From.IsSame(mySkface)) {
525 myJustGluer = Standard_True;
527 if (myJustGluer) return;
529 else if (Until.IsSame(mySkface)) {
530 myJustGluer = Standard_True;
533 if (myJustGluer) return;
538 myPerfSelection = BRepFeat_SelectionFU;
539 PerfSelectionValid();
541 TopExp_Explorer exp(From, TopAbs_FACE);
543 Standard_ConstructionError::Raise();
545 exp.Init(Until, TopAbs_FACE);
547 Standard_ConstructionError::Raise();
551 Standard_Boolean Trff = TransformShapeFU(0);
554 Standard_Boolean Trfu = TransformShapeFU(1);
559 myStatusError = BRepFeat_IncTypes;
563 LocOpe_Revol theRevol;
564 theRevol.Perform(myPbase, myAxis, 2*M_PI);
565 TopoDS_Shape VraiRevol = theRevol.Shape();
567 MajMap(myPbase,theRevol,myMap,myFShape,myLShape);
570 myGShape = VraiRevol;
571 GeneratedShapeValid();
573 // VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF);
575 theRevol.Curves(myCurves);
576 myBCurve = theRevol.BarycCurve();
580 theRevol.Curves(myCurves);
581 myBCurve = theRevol.BarycCurve();
582 TColGeom_SequenceOfCurve scur;
584 scur.Append(myBCurve);
585 LocOpe_CSIntersector ASI1(mySUntil);
586 LocOpe_CSIntersector ASI2(mySFrom);
589 TopAbs_Orientation OrU, OrF;
590 TopoDS_Face FFrom, FUntil;
591 Standard_Real PrF, PrU;
592 if (ASI1.IsDone() && ASI1.NbPoints(1) >=1) {
593 OrU = ASI1.Point(1,1).Orientation();
594 FUntil = ASI1.Point(1,1).Face();
595 PrU = ASI1.Point(1,1).Parameter();
599 myStatusError = BRepFeat_NoIntersectU;
602 if (ASI2.IsDone() && ASI2.NbPoints(1) >=1) {
603 Standard_Real pr1 = ASI2.Point(1,1).Parameter();
604 pr1 = ElCLib::InPeriod(pr1,PrU-2*M_PI,PrU);
605 Standard_Real pr2 = ASI2.Point(1,ASI2.NbPoints(1)).Parameter();
606 pr2 = ElCLib::InPeriod(pr2,PrU-2*M_PI,PrU);
608 FFrom = ASI2.Point(1,1).Face();
613 myStatusError = BRepFeat_NoIntersectF;
618 myStatusError = BRepFeat_IncParameter;
623 B.MakeCompound(TopoDS::Compound(Comp));
624 TopoDS_Solid SF = BRepFeat::Tool(mySFrom, FFrom, OrF);
625 if (!SF.IsNull()) B.Add(Comp,SF);
626 TopoDS_Solid SU = BRepFeat::Tool(mySUntil, FUntil, OrU);
627 if (!SU.IsNull()) B.Add(Comp,SU);
628 //modified by NIZNHY-PKV Thu Mar 21 18:18:54 2002 f
629 //BRepAlgo_Cut trP(VraiRevol,Comp);
630 BRepAlgoAPI_Cut trP(VraiRevol,Comp);
631 //modified by NIZNHY-PKV Thu Mar 21 18:18:57 2002 t
632 TopoDS_Shape Cutsh = trP.Shape();
633 TopExp_Explorer ex(Cutsh, TopAbs_SOLID);
634 // Standard_Real PrF = BRepFeat::ParametricBarycenter(mySFrom, myBCurve);
635 // Standard_Real PrU = BRepFeat::ParametricBarycenter(mySUntil, myBCurve);
636 VraiRevol = ex.Current();
637 for(; ex.More(); ex.Next()) {
638 Standard_Real PrCur = BRepFeat::
639 ParametricBarycenter(ex.Current(), myBCurve);
640 if(PrF <= PrCur && PrU >= PrCur) {
641 VraiRevol = ex.Current();
646 //modified by NIZNHY-PKV Thu Mar 21 18:19:14 2002 f
647 //BRepAlgo_Fuse f(mySbase, VraiRevol);
648 //myShape = f.Shape();
649 //UpdateDescendants(f.Builder(), myShape, Standard_False);
650 BRepAlgoAPI_Fuse f(mySbase, VraiRevol);
652 UpdateDescendants(f, myShape, Standard_False);
653 //modified by NIZNHY-PKV Thu Mar 21 18:19:18 2002 t
656 else if(myFuse == 0) {
657 //modified by NIZNHY-PKV Thu Mar 21 18:19:46 2002 f
658 //BRepAlgo_Cut c(mySbase, VraiRevol);
659 //myShape = c.Shape();
660 //UpdateDescendants(c.Builder(), myShape, Standard_False);
661 BRepAlgoAPI_Cut c(mySbase, VraiRevol);
663 UpdateDescendants(c, myShape, Standard_False);
664 //modified by NIZNHY-PKV Thu Mar 21 18:19:50 2002 t
675 //=======================================================================
676 //function : PerformThruAll
677 //purpose : feature throughout the initial shape
678 //=======================================================================
680 void BRepFeat_MakeRevol::PerformThruAll()
683 Standard_Boolean trc = BRepFeat_GettraceFEAT();
684 if (trc) cout << "BRepFeat_MakeRevol::PerformThruAll()" << endl;
689 //=======================================================================
690 //function : PerformUntilAngle
691 //purpose : feature till shape Until defined with the angle
692 //=======================================================================
694 void BRepFeat_MakeRevol::PerformUntilAngle(const TopoDS_Shape& Until,
695 const Standard_Real Angle)
698 Standard_Boolean trc = BRepFeat_GettraceFEAT();
699 if (trc) cout << "BRepFeat_MakeRevol::PerformUntilAngle(Until,Angle)" << endl;
701 if (Until.IsNull()) {
707 TopExp_Explorer exp(Until, TopAbs_FACE);
709 Standard_ConstructionError::Raise();
711 if (!mySkface.IsNull() && Until.IsSame(mySkface)) {
716 myPerfSelection = BRepFeat_NoSelection;
717 PerfSelectionValid();
721 Standard_Boolean Trf = TransformShapeFU(1);
724 // Produce systematicallt an almost complete revolution
725 // BRepSweep_Revol theRevol(myPbase,myAxis,2.*M_PI-10.*Precision::Angular());
726 LocOpe_Revol theRevol;
727 theRevol.Perform(myPbase, myAxis, Angle);
728 TopoDS_Shape VraiRevol = theRevol.Shape();
730 MajMap(myPbase,theRevol,myMap,myFShape,myLShape);
733 myGShape = VraiRevol;
734 GeneratedShapeValid();
736 TopoDS_Shape Base = theRevol.FirstShape();
737 exp.Init(Base, TopAbs_FACE);
738 TopoDS_Face theBase = TopoDS::Face(exp.Current());
742 myStatusError = BRepFeat_InvFirstShape;
746 //VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF);
749 theRevol.Curves(myCurves);
750 myBCurve = theRevol.BarycCurve();
754 TColGeom_SequenceOfCurve scur;
755 theRevol.Curves(myCurves);
756 myBCurve = theRevol.BarycCurve();
758 scur.Append(myBCurve);
759 LocOpe_CSIntersector ASI(mySUntil);
761 if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
762 TopAbs_Orientation Or = ASI.Point(1,1).Orientation();
763 TopoDS_Face FUntil = ASI.Point(1,1).Face();
766 B.MakeCompound(TopoDS::Compound(Comp));
767 TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or);
768 if (!S.IsNull()) B.Add(Comp,S);
769 //modified by NIZNHY-PKV Thu Mar 21 18:20:14 2002 f
770 //BRepAlgo_Cut trP(VraiRevol,Comp);
771 BRepAlgoAPI_Cut trP(VraiRevol,Comp);
772 //modified by NIZNHY-PKV Thu Mar 21 18:20:19 2002 t
773 TopoDS_Shape Cutsh = trP.Shape();
774 TopExp_Explorer ex(Cutsh, TopAbs_SOLID);
775 for(; ex.More(); ex.Next()) {
776 TopExp_Explorer ex1(ex.Current(), TopAbs_FACE);
777 for(; ex1.More(); ex1.Next()) {
778 const TopoDS_Face& fac = TopoDS::Face(ex1.Current());
779 if(fac.IsSame(myPbase)) {
780 VraiRevol = ex.Current();
786 //modified by NIZNHY-PKV Thu Mar 21 18:20:36 2002 f
787 //BRepAlgo_Fuse f(mySbase, VraiRevol);
788 //myShape = f.Shape();
789 //UpdateDescendants(f.Builder(), myShape, Standard_False);
790 BRepAlgoAPI_Fuse f(mySbase, VraiRevol);
792 UpdateDescendants(f, myShape, Standard_False);
793 //modified by NIZNHY-PKV Thu Mar 21 18:20:40 2002 t
796 else if(myFuse == 0) {
797 //modified by NIZNHY-PKV Thu Mar 21 18:21:07 2002 f
798 //BRepAlgo_Cut c(mySbase, VraiRevol);
799 //myShape = c.Shape();
800 //UpdateDescendants(c.Builder(), myShape, Standard_False);
801 BRepAlgoAPI_Cut c(mySbase, VraiRevol);
803 UpdateDescendants(c, myShape, Standard_False);
804 //modified by NIZNHY-PKV Thu Mar 21 18:21:26 2002 t
814 //=======================================================================
816 //purpose : circles parallel to the generating edge of revolution
817 //=======================================================================
819 void BRepFeat_MakeRevol::Curves(TColGeom_SequenceOfCurve& scur)
824 //=======================================================================
825 //function : BarycCurve
826 //purpose : pass through the center of mass of the primitive
827 //=======================================================================
829 Handle(Geom_Curve) BRepFeat_MakeRevol::BarycCurve()
834 //=======================================================================
835 //function : VerifGluedFaces
836 //purpose : Check intersection Tool/theSkface = thePbase
837 // if yes -> OK otherwise -> case without gluing
838 //=======================================================================
840 static void VerifGluedFaces(const TopoDS_Face& theSkface,
841 const TopoDS_Shape& thePbase,
842 Handle(Geom_Curve)& theBCurve,
843 TColGeom_SequenceOfCurve& theCurves,
844 LocOpe_Revol& theRevol,
845 TopTools_DataMapOfShapeShape& theMap)
847 Standard_Boolean GluedFaces = Standard_True;
848 TopoDS_Shape VraiRevol = theRevol.Shape();
850 TColGeom_SequenceOfCurve scur;
851 theRevol.Curves(theCurves);
852 theBCurve = theRevol.BarycCurve();
854 scur.Append(theBCurve);
855 LocOpe_CSIntersector ASI(theSkface);
857 if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
858 TopAbs_Orientation Or = ASI.Point(1,1).Orientation();
859 TopoDS_Face FSk = ASI.Point(1,1).Face();
862 B.MakeCompound(TopoDS::Compound(Comp));
863 TopoDS_Solid S = BRepFeat::Tool(theSkface, FSk, Or);
864 if (!S.IsNull()) B.Add(Comp,S);
865 //modified by NIZNHY-PKV Thu Mar 21 18:21:54 2002 f
866 //BRepAlgo_Cut trP(VraiRevol,Comp);
867 BRepAlgoAPI_Cut trP(VraiRevol,Comp);
868 //modified by NIZNHY-PKV Thu Mar 21 18:21:58 2002 t
869 TopoDS_Shape Cutsh = trP.Shape();
870 TopExp_Explorer ex(Cutsh, TopAbs_SOLID);
871 for(; ex.More(); ex.Next()) {
872 TopExp_Explorer ex1(ex.Current(), TopAbs_FACE);
873 for(; ex1.More(); ex1.Next()) {
874 const TopoDS_Face& fac1 = TopoDS::Face(ex1.Current());
875 TopExp_Explorer ex2(thePbase, TopAbs_FACE);
876 for(; ex2.More(); ex2.Next()) {
877 const TopoDS_Face& fac2 = TopoDS::Face(ex2.Current());
878 if(fac1.IsSame(fac2)) break;
880 if (ex2.More()) break;
882 if (ex1.More()) continue;
883 GluedFaces = Standard_False;
888 Standard_Boolean trc = BRepFeat_GettraceFEAT();
889 if (trc) cout << " Intersection Revol/skface : no gluing" << endl;
896 //=======================================================================
898 //purpose : management of descendants
899 //=======================================================================
901 static void MajMap(const TopoDS_Shape& theB,
902 const LocOpe_Revol& theP,
903 TopTools_DataMapOfShapeListOfShape& theMap, // myMap
904 TopoDS_Shape& theFShape, // myFShape
905 TopoDS_Shape& theLShape) // myLShape
907 TopExp_Explorer exp(theP.FirstShape(),TopAbs_WIRE);
909 theFShape = exp.Current();
910 TopTools_ListOfShape thelist;
911 theMap.Bind(theFShape, thelist);
912 for (exp.Init(theP.FirstShape(),TopAbs_FACE);exp.More();exp.Next()) {
913 theMap(theFShape).Append(exp.Current());
917 exp.Init(theP.LastShape(),TopAbs_WIRE);
919 theLShape = exp.Current();
920 TopTools_ListOfShape thelist1;
921 theMap.Bind(theLShape, thelist1);
922 for (exp.Init(theP.LastShape(),TopAbs_FACE);exp.More();exp.Next()) {
923 theMap(theLShape).Append(exp.Current());
927 for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) {
928 if (!theMap.IsBound(exp.Current())) {
929 TopTools_ListOfShape thelist2;
930 theMap.Bind(exp.Current(), thelist2);
931 theMap(exp.Current()) = theP.Shapes(exp.Current());
938 //=======================================================================
940 //purpose : two faces samedomaine or not
941 //=======================================================================
943 Standard_Boolean ToFuse(const TopoDS_Face& F1,
944 const TopoDS_Face& F2)
946 if (F1.IsNull() || F2.IsNull()) {
947 return Standard_False;
950 Handle(Geom_Surface) S1,S2;
951 TopLoc_Location loc1, loc2;
952 Handle(Standard_Type) typS1,typS2;
953 const Standard_Real tollin = Precision::Confusion();
954 const Standard_Real tolang = Precision::Angular();
956 S1 = BRep_Tool::Surface(F1,loc1);
957 S2 = BRep_Tool::Surface(F2,loc2);
959 typS1 = S1->DynamicType();
960 typS2 = S2->DynamicType();
962 if (typS1 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
963 S1 = (*((Handle(Geom_RectangularTrimmedSurface)*)&S1))->BasisSurface();
964 typS1 = S1->DynamicType();
967 if (typS2 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
968 S2 = (*((Handle(Geom_RectangularTrimmedSurface)*)&S2))->BasisSurface();
969 typS2 = S2->DynamicType();
972 if (typS1 != typS2) {
973 return Standard_False;
977 Standard_Boolean ValRet = Standard_False;
978 if (typS1 == STANDARD_TYPE(Geom_Plane)) {
979 S1 = BRep_Tool::Surface(F1); // to apply the location.
980 S2 = BRep_Tool::Surface(F2);
981 gp_Pln pl1( (*((Handle(Geom_Plane)*)&S1))->Pln());
982 gp_Pln pl2( (*((Handle(Geom_Plane)*)&S2))->Pln());
984 if (pl1.Position().IsCoplanar(pl2.Position(),tollin,tolang)) {
985 ValRet = Standard_True;