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 OrF = TopAbs::Reverse(OrU);
609 FFrom = ASI2.Point(1,1).Face();
614 myStatusError = BRepFeat_NoIntersectF;
619 myStatusError = BRepFeat_IncParameter;
624 B.MakeCompound(TopoDS::Compound(Comp));
625 TopoDS_Solid SF = BRepFeat::Tool(mySFrom, FFrom, OrF);
626 if (!SF.IsNull()) B.Add(Comp,SF);
627 TopoDS_Solid SU = BRepFeat::Tool(mySUntil, FUntil, OrU);
628 if (!SU.IsNull()) B.Add(Comp,SU);
629 //modified by NIZNHY-PKV Thu Mar 21 18:18:54 2002 f
630 //BRepAlgo_Cut trP(VraiRevol,Comp);
631 BRepAlgoAPI_Cut trP(VraiRevol,Comp);
632 //modified by NIZNHY-PKV Thu Mar 21 18:18:57 2002 t
633 TopoDS_Shape Cutsh = trP.Shape();
634 TopExp_Explorer ex(Cutsh, TopAbs_SOLID);
635 // Standard_Real PrF = BRepFeat::ParametricBarycenter(mySFrom, myBCurve);
636 // Standard_Real PrU = BRepFeat::ParametricBarycenter(mySUntil, myBCurve);
637 VraiRevol = ex.Current();
638 for(; ex.More(); ex.Next()) {
639 Standard_Real PrCur = BRepFeat::
640 ParametricBarycenter(ex.Current(), myBCurve);
641 if(PrF <= PrCur && PrU >= PrCur) {
642 VraiRevol = ex.Current();
646 if(myFuse == 1 && !myJustFeat) {
647 //modified by NIZNHY-PKV Thu Mar 21 18:19:14 2002 f
648 //BRepAlgo_Fuse f(mySbase, VraiRevol);
649 //myShape = f.Shape();
650 //UpdateDescendants(f.Builder(), myShape, Standard_False);
651 BRepAlgoAPI_Fuse f(mySbase, VraiRevol);
653 UpdateDescendants(f, myShape, Standard_False);
654 //modified by NIZNHY-PKV Thu Mar 21 18:19:18 2002 t
657 else if(myFuse == 0 && !myJustFeat) {
658 //modified by NIZNHY-PKV Thu Mar 21 18:19:46 2002 f
659 //BRepAlgo_Cut c(mySbase, VraiRevol);
660 //myShape = c.Shape();
661 //UpdateDescendants(c.Builder(), myShape, Standard_False);
662 BRepAlgoAPI_Cut c(mySbase, VraiRevol);
664 UpdateDescendants(c, myShape, Standard_False);
665 //modified by NIZNHY-PKV Thu Mar 21 18:19:50 2002 t
676 //=======================================================================
677 //function : PerformThruAll
678 //purpose : feature throughout the initial shape
679 //=======================================================================
681 void BRepFeat_MakeRevol::PerformThruAll()
684 Standard_Boolean trc = BRepFeat_GettraceFEAT();
685 if (trc) cout << "BRepFeat_MakeRevol::PerformThruAll()" << endl;
690 //=======================================================================
691 //function : PerformUntilAngle
692 //purpose : feature till shape Until defined with the angle
693 //=======================================================================
695 void BRepFeat_MakeRevol::PerformUntilAngle(const TopoDS_Shape& Until,
696 const Standard_Real Angle)
699 Standard_Boolean trc = BRepFeat_GettraceFEAT();
700 if (trc) cout << "BRepFeat_MakeRevol::PerformUntilAngle(Until,Angle)" << endl;
702 if (Until.IsNull()) {
708 TopExp_Explorer exp(Until, TopAbs_FACE);
710 Standard_ConstructionError::Raise();
712 if (!mySkface.IsNull() && Until.IsSame(mySkface)) {
717 myPerfSelection = BRepFeat_NoSelection;
718 PerfSelectionValid();
722 Standard_Boolean Trf = TransformShapeFU(1);
725 // Produce systematicallt an almost complete revolution
726 // BRepSweep_Revol theRevol(myPbase,myAxis,2.*M_PI-10.*Precision::Angular());
727 LocOpe_Revol theRevol;
728 theRevol.Perform(myPbase, myAxis, Angle);
729 TopoDS_Shape VraiRevol = theRevol.Shape();
731 MajMap(myPbase,theRevol,myMap,myFShape,myLShape);
734 myGShape = VraiRevol;
735 GeneratedShapeValid();
737 TopoDS_Shape Base = theRevol.FirstShape();
738 exp.Init(Base, TopAbs_FACE);
739 TopoDS_Face theBase = TopoDS::Face(exp.Current());
743 myStatusError = BRepFeat_InvFirstShape;
747 //VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF);
750 theRevol.Curves(myCurves);
751 myBCurve = theRevol.BarycCurve();
755 TColGeom_SequenceOfCurve scur;
756 theRevol.Curves(myCurves);
757 myBCurve = theRevol.BarycCurve();
759 scur.Append(myBCurve);
760 LocOpe_CSIntersector ASI(mySUntil);
762 if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
763 TopAbs_Orientation Or = ASI.Point(1,1).Orientation();
764 TopoDS_Face FUntil = ASI.Point(1,1).Face();
767 B.MakeCompound(TopoDS::Compound(Comp));
768 TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or);
769 if (!S.IsNull()) B.Add(Comp,S);
770 //modified by NIZNHY-PKV Thu Mar 21 18:20:14 2002 f
771 //BRepAlgo_Cut trP(VraiRevol,Comp);
772 BRepAlgoAPI_Cut trP(VraiRevol,Comp);
773 //modified by NIZNHY-PKV Thu Mar 21 18:20:19 2002 t
774 TopoDS_Shape Cutsh = trP.Shape();
775 TopExp_Explorer ex(Cutsh, TopAbs_SOLID);
776 for(; ex.More(); ex.Next()) {
777 TopExp_Explorer ex1(ex.Current(), TopAbs_FACE);
778 for(; ex1.More(); ex1.Next()) {
779 const TopoDS_Face& fac = TopoDS::Face(ex1.Current());
780 if(fac.IsSame(myPbase)) {
781 VraiRevol = ex.Current();
787 //modified by NIZNHY-PKV Thu Mar 21 18:20:36 2002 f
788 //BRepAlgo_Fuse f(mySbase, VraiRevol);
789 //myShape = f.Shape();
790 //UpdateDescendants(f.Builder(), myShape, Standard_False);
791 BRepAlgoAPI_Fuse f(mySbase, VraiRevol);
793 UpdateDescendants(f, myShape, Standard_False);
794 //modified by NIZNHY-PKV Thu Mar 21 18:20:40 2002 t
797 else if(myFuse == 0) {
798 //modified by NIZNHY-PKV Thu Mar 21 18:21:07 2002 f
799 //BRepAlgo_Cut c(mySbase, VraiRevol);
800 //myShape = c.Shape();
801 //UpdateDescendants(c.Builder(), myShape, Standard_False);
802 BRepAlgoAPI_Cut c(mySbase, VraiRevol);
804 UpdateDescendants(c, myShape, Standard_False);
805 //modified by NIZNHY-PKV Thu Mar 21 18:21:26 2002 t
815 //=======================================================================
817 //purpose : circles parallel to the generating edge of revolution
818 //=======================================================================
820 void BRepFeat_MakeRevol::Curves(TColGeom_SequenceOfCurve& scur)
825 //=======================================================================
826 //function : BarycCurve
827 //purpose : pass through the center of mass of the primitive
828 //=======================================================================
830 Handle(Geom_Curve) BRepFeat_MakeRevol::BarycCurve()
835 //=======================================================================
836 //function : VerifGluedFaces
837 //purpose : Check intersection Tool/theSkface = thePbase
838 // if yes -> OK otherwise -> case without gluing
839 //=======================================================================
841 static void VerifGluedFaces(const TopoDS_Face& theSkface,
842 const TopoDS_Shape& thePbase,
843 Handle(Geom_Curve)& theBCurve,
844 TColGeom_SequenceOfCurve& theCurves,
845 LocOpe_Revol& theRevol,
846 TopTools_DataMapOfShapeShape& theMap)
848 Standard_Boolean GluedFaces = Standard_True;
849 TopoDS_Shape VraiRevol = theRevol.Shape();
851 TColGeom_SequenceOfCurve scur;
852 theRevol.Curves(theCurves);
853 theBCurve = theRevol.BarycCurve();
855 scur.Append(theBCurve);
856 LocOpe_CSIntersector ASI(theSkface);
858 if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
859 TopAbs_Orientation Or = ASI.Point(1,1).Orientation();
860 TopoDS_Face FSk = ASI.Point(1,1).Face();
863 B.MakeCompound(TopoDS::Compound(Comp));
864 TopoDS_Solid S = BRepFeat::Tool(theSkface, FSk, Or);
865 if (!S.IsNull()) B.Add(Comp,S);
866 //modified by NIZNHY-PKV Thu Mar 21 18:21:54 2002 f
867 //BRepAlgo_Cut trP(VraiRevol,Comp);
868 BRepAlgoAPI_Cut trP(VraiRevol,Comp);
869 //modified by NIZNHY-PKV Thu Mar 21 18:21:58 2002 t
870 TopoDS_Shape Cutsh = trP.Shape();
871 TopExp_Explorer ex(Cutsh, TopAbs_SOLID);
872 for(; ex.More(); ex.Next()) {
873 TopExp_Explorer ex1(ex.Current(), TopAbs_FACE);
874 for(; ex1.More(); ex1.Next()) {
875 const TopoDS_Face& fac1 = TopoDS::Face(ex1.Current());
876 TopExp_Explorer ex2(thePbase, TopAbs_FACE);
877 for(; ex2.More(); ex2.Next()) {
878 const TopoDS_Face& fac2 = TopoDS::Face(ex2.Current());
879 if(fac1.IsSame(fac2)) break;
881 if (ex2.More()) break;
883 if (ex1.More()) continue;
884 GluedFaces = Standard_False;
889 Standard_Boolean trc = BRepFeat_GettraceFEAT();
890 if (trc) cout << " Intersection Revol/skface : no gluing" << endl;
897 //=======================================================================
899 //purpose : management of descendants
900 //=======================================================================
902 static void MajMap(const TopoDS_Shape& theB,
903 const LocOpe_Revol& theP,
904 TopTools_DataMapOfShapeListOfShape& theMap, // myMap
905 TopoDS_Shape& theFShape, // myFShape
906 TopoDS_Shape& theLShape) // myLShape
908 TopExp_Explorer exp(theP.FirstShape(),TopAbs_WIRE);
910 theFShape = exp.Current();
911 TopTools_ListOfShape thelist;
912 theMap.Bind(theFShape, thelist);
913 for (exp.Init(theP.FirstShape(),TopAbs_FACE);exp.More();exp.Next()) {
914 theMap(theFShape).Append(exp.Current());
918 exp.Init(theP.LastShape(),TopAbs_WIRE);
920 theLShape = exp.Current();
921 TopTools_ListOfShape thelist1;
922 theMap.Bind(theLShape, thelist1);
923 for (exp.Init(theP.LastShape(),TopAbs_FACE);exp.More();exp.Next()) {
924 theMap(theLShape).Append(exp.Current());
928 for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) {
929 if (!theMap.IsBound(exp.Current())) {
930 TopTools_ListOfShape thelist2;
931 theMap.Bind(exp.Current(), thelist2);
932 theMap(exp.Current()) = theP.Shapes(exp.Current());
939 //=======================================================================
941 //purpose : two faces samedomaine or not
942 //=======================================================================
944 Standard_Boolean ToFuse(const TopoDS_Face& F1,
945 const TopoDS_Face& F2)
947 if (F1.IsNull() || F2.IsNull()) {
948 return Standard_False;
951 Handle(Geom_Surface) S1,S2;
952 TopLoc_Location loc1, loc2;
953 Handle(Standard_Type) typS1,typS2;
954 const Standard_Real tollin = Precision::Confusion();
955 const Standard_Real tolang = Precision::Angular();
957 S1 = BRep_Tool::Surface(F1,loc1);
958 S2 = BRep_Tool::Surface(F2,loc2);
960 typS1 = S1->DynamicType();
961 typS2 = S2->DynamicType();
963 if (typS1 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
964 S1 = Handle(Geom_RectangularTrimmedSurface)::DownCast (S1)->BasisSurface();
965 typS1 = S1->DynamicType();
968 if (typS2 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
969 S2 = Handle(Geom_RectangularTrimmedSurface)::DownCast (S2)->BasisSurface();
970 typS2 = S2->DynamicType();
973 if (typS1 != typS2) {
974 return Standard_False;
978 Standard_Boolean ValRet = Standard_False;
979 if (typS1 == STANDARD_TYPE(Geom_Plane)) {
980 S1 = BRep_Tool::Surface(F1); // to apply the location.
981 S2 = BRep_Tool::Surface(F2);
982 gp_Pln pl1( Handle(Geom_Plane)::DownCast (S1)->Pln());
983 gp_Pln pl2( Handle(Geom_Plane)::DownCast (S2)->Pln());
985 if (pl1.Position().IsCoplanar(pl2.Position(),tollin,tolang)) {
986 ValRet = Standard_True;