1 // Created on: 1996-02-13
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1996-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_MakeRevol.ixx>
25 #include <BRepFeat.hxx>
27 #include <LocOpe_Revol.hxx>
28 #include <LocOpe_Builder.hxx>
29 #include <LocOpe_Gluer.hxx>
30 #include <LocOpe_FindEdges.hxx>
31 #include <LocOpe_SequenceOfCirc.hxx>
32 #include <LocOpe_BuildShape.hxx>
33 #include <LocOpe_CSIntersector.hxx>
34 #include <LocOpe_PntFace.hxx>
39 #include <gp_Pnt2d.hxx>
40 #include <TColgp_SequenceOfPnt.hxx>
41 #include <Geom_Surface.hxx>
42 #include <Geom_Curve.hxx>
43 #include <Geom_Circle.hxx>
44 #include <Geom2d_Curve.hxx>
45 #include <Geom_RectangularTrimmedSurface.hxx>
46 #include <Bnd_Box.hxx>
48 #include <BRepSweep_Revol.hxx>
49 #include <BRep_Builder.hxx>
50 #include <BRep_Tool.hxx>
51 #include <TopExp_Explorer.hxx>
52 #include <TopTools_MapOfShape.hxx>
53 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
54 #include <TopTools_ListIteratorOfListOfShape.hxx>
55 #include <TopTools_MapIteratorOfMapOfShape.hxx>
56 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
58 #include <BRepAlgoAPI_Cut.hxx>
59 #include <BRepAlgoAPI_Fuse.hxx>
61 #include <BRepLib_MakeFace.hxx>
62 #include <BRepTools_Modifier.hxx>
63 #include <BRepTools_TrsfModification.hxx>
65 #include <Standard_ConstructionError.hxx>
67 #include <TopoDS_Solid.hxx>
68 #include <TopoDS_Compound.hxx>
69 #include <TopoDS_Shell.hxx>
72 #include <Geom_Plane.hxx>
76 #include <Precision.hxx>
77 #include <BRepBndLib.hxx>
78 #include <BRepBuilderAPI.hxx>
79 #include <BRepFeat.hxx>
84 Standard_IMPORT Standard_Boolean BRepFeat_GettraceFEAT();
87 static void MajMap(const TopoDS_Shape&, // base
89 TopTools_DataMapOfShapeListOfShape&, // myMap
90 TopoDS_Shape&, // myFShape
91 TopoDS_Shape&); // myLShape
94 static void SetGluedFaces(const TopoDS_Face& theSkface,
95 const TopoDS_Shape& theSbase,
96 const TopoDS_Shape& thePbase,
97 const TopTools_DataMapOfShapeListOfShape& theSlmap,
99 TopTools_DataMapOfShapeShape&);
102 static void VerifGluedFaces(const TopoDS_Face& theSkface,
103 const TopoDS_Shape& thePbase,
104 Handle(Geom_Curve)& theBCurve,
105 TColGeom_SequenceOfCurve& theCurves,
106 LocOpe_Revol& theRevol,
107 TopTools_DataMapOfShapeShape& theMap);
110 static Standard_Boolean ToFuse(const TopoDS_Face& ,
116 //=======================================================================
119 //=======================================================================
121 void BRepFeat_MakeRevol::Init(const TopoDS_Shape& Sbase,
122 const TopoDS_Shape& Pbase,
123 const TopoDS_Face& Skface,
125 const Standard_Integer Mode,
126 const Standard_Boolean Modify)
129 Standard_Boolean trc = BRepFeat_GettraceFEAT();
130 if (trc) cout << "BRepFeat_MakeRevol::Init" << endl;
141 myFuse = Standard_False;
142 myJustFeat = Standard_False;
145 myFuse = Standard_True;
146 myJustFeat = Standard_False;
149 myFuse = Standard_True;
150 myJustFeat = Standard_True;
155 myJustGluer = Standard_False;
158 // mySkface.Nullify();
167 for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
168 TopTools_ListOfShape thelist;
169 myMap.Bind(exp.Current(), thelist);
170 myMap(exp.Current()).Append(exp.Current());
174 if (myJustFeat) cout << " Just Feature" << endl;
175 if (myFuse) cout << " Fuse" << endl;
176 if (!myFuse) cout << " Cut" << endl;
177 if (!myModify) cout << " Modify = 0" << endl;
183 //=======================================================================
185 //purpose : add faces add edges of sliding
186 //=======================================================================
188 void BRepFeat_MakeRevol::Add(const TopoDS_Edge& E,
189 const TopoDS_Face& F)
192 Standard_Boolean trc = BRepFeat_GettraceFEAT();
193 if (trc) cout << "BRepFeat_MakeRevol::Add(Edge,face)" << endl;
196 for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
197 if (exp.Current().IsSame(F)) {
202 Standard_ConstructionError::Raise();
205 for (exp.Init(myPbase,TopAbs_EDGE);exp.More();exp.Next()) {
206 if (exp.Current().IsSame(E)) {
211 Standard_ConstructionError::Raise();
214 if (!mySlface.IsBound(F)) {
215 TopTools_ListOfShape thelist;
216 mySlface.Bind(F, thelist);
218 TopTools_ListIteratorOfListOfShape itl(mySlface(F));
219 for (; itl.More();itl.Next()) {
220 if (itl.Value().IsSame(E)) {
225 mySlface(F).Append(E);
230 //=======================================================================
233 //=======================================================================
235 void BRepFeat_MakeRevol::Perform(const Standard_Real Angle)
238 Standard_Boolean trc = BRepFeat_GettraceFEAT();
239 if (trc) cout << "BRepFeat_MakeRevol::Perform(Angle)" << endl;
246 myPerfSelection = BRepFeat_NoSelection;
247 PerfSelectionValid();
248 Standard_Boolean RevolComp = (2*M_PI-Abs(Angle) <= Precision::Angular());
249 LocOpe_Revol theRevol;
250 Standard_Real angledec = 0.;
254 if (!mySkface.IsNull() || !mySlface.IsEmpty()) {
255 for (exp.Init(mySbase,TopAbs_FACE); exp.More(); exp.Next()) {
256 if (exp.Current().IsSame(mySkface)) {
257 angledec = M_PI/5; // pourquoi pas
258 if (myFuse) angledec = -angledec;
266 if(angledec == 0.) theRevol.Perform(myPbase, myAxis, Angle);
267 else theRevol.Perform(myPbase, myAxis, Angle, angledec);
269 TopoDS_Shape VraiRevol = theRevol.Shape();
271 MajMap(myPbase,theRevol,myMap,myFShape,myLShape);
273 myGShape = VraiRevol;
274 GeneratedShapeValid();
275 TopoDS_Shape Base = theRevol.FirstShape();
276 exp.Init(Base, TopAbs_FACE);
277 TopoDS_Face theBase = TopoDS::Face(exp.Current());
281 myStatusError = BRepFeat_InvFirstShape;
287 Standard_Boolean found = Standard_False;
289 if(!mySkface.IsNull() || !mySlface.IsEmpty()) {
290 if(myLShape.ShapeType() == TopAbs_WIRE) {
291 TopExp_Explorer ex1(VraiRevol, TopAbs_FACE);
292 for(; ex1.More(); ex1.Next()) {
293 TopExp_Explorer ex2(ex1.Current(), TopAbs_WIRE);
294 for(; ex2.More(); ex2.Next()) {
295 if(ex2.Current().IsSame(myLShape)) {
296 FFace = TopoDS::Face(ex1.Current());
297 found = Standard_True;
305 TopExp_Explorer exp(mySbase, TopAbs_FACE);
306 for(; exp.More(); exp.Next()) {
307 const TopoDS_Face& ff = TopoDS::Face(exp.Current());
308 if(ToFuse(ff, FFace)) {
309 TopTools_DataMapOfShapeListOfShape sl;
310 if(!FFace.IsSame(myPbase) && BRepFeat::IsInside(ff, FFace))
311 //SetGluedFaces(ff, mySbase, FFace, sl, theRevol, myGluedF);
317 //SetGluedFaces(mySkface, mySbase, theBase, mySlface, theRevol, myGluedF);
319 if (!mySkface.IsNull()) {
320 VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF);
323 if(myGluedF.IsEmpty()) {
325 //modified by NIZNHY-PKV Thu Mar 21 18:15:06 2002 f
326 //BRepAlgo_Fuse f(mySbase, myGShape);
327 //myShape = f.Shape();
328 //UpdateDescendants(f.Builder(), myShape, Standard_False);
329 BRepAlgoAPI_Fuse f(mySbase, myGShape);
331 UpdateDescendants(f, myShape, Standard_False);
332 //modified by NIZNHY-PKV Thu Mar 21 18:15:11 2002 t
335 else if(myFuse == 0) {
336 //modified by NIZNHY-PKV Thu Mar 21 18:15:37 2002 f
337 //BRepAlgo_Cut c(mySbase, myGShape);
338 //myShape = c.Shape();
339 //UpdateDescendants(c.Builder(), myShape, Standard_False);
340 BRepAlgoAPI_Cut c(mySbase, myGShape);
342 UpdateDescendants(c, myShape, Standard_False);
343 //modified by NIZNHY-PKV Thu Mar 21 18:15:47 2002 t
352 theRevol.Curves(myCurves);
353 myBCurve = theRevol.BarycCurve();
359 //=======================================================================
361 //purpose : feature till shape Until
362 //=======================================================================
364 void BRepFeat_MakeRevol::Perform(const TopoDS_Shape& Until)
367 Standard_Boolean trc = BRepFeat_GettraceFEAT();
368 if (trc) cout << "BRepFeat_MakeRevol::Perform(Until)" << endl;
370 Standard_Real Angle = 0.;
371 Standard_Boolean TourComplet = Standard_False;
373 if (Until.IsNull()) {
374 Standard_ConstructionError::Raise();
376 TopExp_Explorer exp(Until, TopAbs_FACE);
378 Standard_ConstructionError::Raise();
380 if (!mySkface.IsNull() && Until.IsSame(mySkface)) {
382 TourComplet = Standard_True;
385 myPerfSelection = BRepFeat_SelectionU;
386 PerfSelectionValid();
390 Standard_Boolean Trf = TransformShapeFU(1);
393 // Do systematically almost complete revolution
394 // BRepSweep_Revol theRevol(myPbase,myAxis,2.*M_PI-10.*Precision::Angular());
395 LocOpe_Revol theRevol;
397 Angle = 2.*M_PI- 3*M_PI/180.;
399 if (trc) cout << " No complete Revolution" << endl;
402 theRevol.Perform(myPbase, myAxis, Angle);
403 TopoDS_Shape VraiRevol = theRevol.Shape();
404 MajMap(myPbase,theRevol,myMap,myFShape,myLShape);
409 myGShape = VraiRevol;
410 GeneratedShapeValid();
412 TopoDS_Shape Base = theRevol.FirstShape();
413 exp.Init(Base, TopAbs_FACE);
414 TopoDS_Face theBase = TopoDS::Face(exp.Current());
418 myStatusError = BRepFeat_InvFirstShape;
422 //SetGluedFaces(mySkface, mySbase, theBase, mySlface, theRevol, myGluedF);
424 //VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF);
426 theRevol.Curves(myCurves);
427 myBCurve = theRevol.BarycCurve();
431 TColGeom_SequenceOfCurve scur;
432 theRevol.Curves(myCurves);
433 myBCurve = theRevol.BarycCurve();
435 scur.Append(myBCurve);
436 LocOpe_CSIntersector ASI(mySUntil);
438 if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
439 TopAbs_Orientation Or = ASI.Point(1,1).Orientation();
440 TopoDS_Face FUntil = ASI.Point(1,1).Face();
443 B.MakeCompound(TopoDS::Compound(Comp));
444 TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or);
445 if (!S.IsNull()) B.Add(Comp,S);
446 //modified by NIZNHY-PKV Thu Mar 21 18:17:31 2002 f
447 //BRepAlgo_Cut trP(VraiRevol,Comp);
448 BRepAlgoAPI_Cut trP(VraiRevol,Comp);
449 //modified by NIZNHY-PKV Thu Mar 21 18:17:37 2002 t
450 TopoDS_Shape Cutsh = trP.Shape();
451 TopExp_Explorer ex(Cutsh, TopAbs_SOLID);
452 for(; ex.More(); ex.Next()) {
453 TopExp_Explorer ex1(ex.Current(), TopAbs_FACE);
454 for(; ex1.More(); ex1.Next()) {
455 const TopoDS_Face& fac = TopoDS::Face(ex1.Current());
456 if(fac.IsSame(myPbase)) {
457 VraiRevol = ex.Current();
463 //modified by NIZNHY-PKV Thu Mar 21 18:17:53 2002 f
464 //BRepAlgo_Fuse f(mySbase, VraiRevol);
465 //myShape = f.Shape();
466 //UpdateDescendants(f.Builder(), myShape, Standard_False);
467 BRepAlgoAPI_Fuse f(mySbase, VraiRevol);
469 UpdateDescendants(f, myShape, Standard_False);
470 //modified by NIZNHY-PKV Thu Mar 21 18:17:57 2002 t
473 else if(myFuse == 0) {
474 //modified by NIZNHY-PKV Thu Mar 21 18:18:23 2002 f
475 //BRepAlgo_Cut c(mySbase, VraiRevol);
476 //myShape = c.Shape();
477 //UpdateDescendants(c.Builder(), myShape, Standard_False);
478 BRepAlgoAPI_Cut c(mySbase, VraiRevol);
480 UpdateDescendants(c, myShape, Standard_False);
481 //modified by NIZNHY-PKV Thu Mar 21 18:18:28 2002 t
490 // Loop of control of descendance
492 TopExp_Explorer expr(mySbase, TopAbs_FACE);
493 char nom1[20], nom2[20];
494 Standard_Integer ii = 0;
495 for(; expr.More(); expr.Next()) {
497 sprintf(nom1, "faceinitial_%d", ii);
498 DBRep::Set(nom1, expr.Current());
499 Standard_Integer jj = 0;
500 const TopTools_ListOfShape& list = Modified(expr.Current());
501 TopTools_ListIteratorOfListOfShape ite(list);
502 for(; ite.More(); ite.Next()) {
504 sprintf(nom2, "facemodifie_%d_%d", ii, jj);
505 DBRep::Set(nom2, ite.Value());
509 expr.Init(myPbase, TopAbs_EDGE);
511 for(; expr.More(); expr.Next()) {
513 sprintf(nom1, "edgeinitial_%d", ii);
514 DBRep::Set(nom1, expr.Current());
515 Standard_Integer jj = 0;
516 const TopTools_ListOfShape& list = Generated(expr.Current());
517 TopTools_ListIteratorOfListOfShape ite(list);
518 for(; ite.More(); ite.Next()) {
520 sprintf(nom2, "facegeneree_%d_%d", ii, jj);
521 DBRep::Set(nom2, ite.Value());
528 //=======================================================================
530 //purpose : feature limited by two shapes
531 //=======================================================================
533 void BRepFeat_MakeRevol::Perform(const TopoDS_Shape& From,
534 const TopoDS_Shape& Until)
537 Standard_Boolean trc = BRepFeat_GettraceFEAT();
538 if (trc) cout << "BRepFeat_MakeRevol::Perform(From,Until)" << endl;
540 if (From.IsNull() || Until.IsNull()) {
541 Standard_ConstructionError::Raise();
543 if (!mySkface.IsNull()) {
544 if (From.IsSame(mySkface)) {
545 myJustGluer = Standard_True;
547 if (myJustGluer) return;
549 else if (Until.IsSame(mySkface)) {
550 myJustGluer = Standard_True;
553 if (myJustGluer) return;
558 myPerfSelection = BRepFeat_SelectionFU;
559 PerfSelectionValid();
561 TopExp_Explorer exp(From, TopAbs_FACE);
563 Standard_ConstructionError::Raise();
565 exp.Init(Until, TopAbs_FACE);
567 Standard_ConstructionError::Raise();
571 Standard_Boolean Trff = TransformShapeFU(0);
574 Standard_Boolean Trfu = TransformShapeFU(1);
579 myStatusError = BRepFeat_IncTypes;
583 LocOpe_Revol theRevol;
584 theRevol.Perform(myPbase, myAxis, 2*M_PI);
585 TopoDS_Shape VraiRevol = theRevol.Shape();
587 MajMap(myPbase,theRevol,myMap,myFShape,myLShape);
590 myGShape = VraiRevol;
591 GeneratedShapeValid();
593 //SetGluedFaces(TopoDS_Face(), mySbase, myPbase, mySlface, theRevol, myGluedF);
595 // VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF);
597 theRevol.Curves(myCurves);
598 myBCurve = theRevol.BarycCurve();
602 theRevol.Curves(myCurves);
603 myBCurve = theRevol.BarycCurve();
604 TColGeom_SequenceOfCurve scur;
606 scur.Append(myBCurve);
607 LocOpe_CSIntersector ASI1(mySUntil);
608 LocOpe_CSIntersector ASI2(mySFrom);
611 TopAbs_Orientation OrU, OrF;
612 TopoDS_Face FFrom, FUntil;
613 Standard_Real PrF, PrU;
614 if (ASI1.IsDone() && ASI1.NbPoints(1) >=1) {
615 OrU = ASI1.Point(1,1).Orientation();
616 FUntil = ASI1.Point(1,1).Face();
617 PrU = ASI1.Point(1,1).Parameter();
621 myStatusError = BRepFeat_NoIntersectU;
624 if (ASI2.IsDone() && ASI2.NbPoints(1) >=1) {
625 Standard_Real pr1 = ASI2.Point(1,1).Parameter();
626 pr1 = ElCLib::InPeriod(pr1,PrU-2*M_PI,PrU);
627 Standard_Real pr2 = ASI2.Point(1,ASI2.NbPoints(1)).Parameter();
628 pr2 = ElCLib::InPeriod(pr2,PrU-2*M_PI,PrU);
630 FFrom = ASI2.Point(1,1).Face();
635 myStatusError = BRepFeat_NoIntersectF;
640 myStatusError = BRepFeat_IncParameter;
645 B.MakeCompound(TopoDS::Compound(Comp));
646 TopoDS_Solid SF = BRepFeat::Tool(mySFrom, FFrom, OrF);
647 if (!SF.IsNull()) B.Add(Comp,SF);
648 TopoDS_Solid SU = BRepFeat::Tool(mySUntil, FUntil, OrU);
649 if (!SU.IsNull()) B.Add(Comp,SU);
650 //modified by NIZNHY-PKV Thu Mar 21 18:18:54 2002 f
651 //BRepAlgo_Cut trP(VraiRevol,Comp);
652 BRepAlgoAPI_Cut trP(VraiRevol,Comp);
653 //modified by NIZNHY-PKV Thu Mar 21 18:18:57 2002 t
654 TopoDS_Shape Cutsh = trP.Shape();
655 TopExp_Explorer ex(Cutsh, TopAbs_SOLID);
656 // Standard_Real PrF = BRepFeat::ParametricBarycenter(mySFrom, myBCurve);
657 // Standard_Real PrU = BRepFeat::ParametricBarycenter(mySUntil, myBCurve);
658 VraiRevol = ex.Current();
659 for(; ex.More(); ex.Next()) {
660 Standard_Real PrCur = BRepFeat::
661 ParametricBarycenter(ex.Current(), myBCurve);
662 if(PrF <= PrCur && PrU >= PrCur) {
663 VraiRevol = ex.Current();
668 //modified by NIZNHY-PKV Thu Mar 21 18:19:14 2002 f
669 //BRepAlgo_Fuse f(mySbase, VraiRevol);
670 //myShape = f.Shape();
671 //UpdateDescendants(f.Builder(), myShape, Standard_False);
672 BRepAlgoAPI_Fuse f(mySbase, VraiRevol);
674 UpdateDescendants(f, myShape, Standard_False);
675 //modified by NIZNHY-PKV Thu Mar 21 18:19:18 2002 t
678 else if(myFuse == 0) {
679 //modified by NIZNHY-PKV Thu Mar 21 18:19:46 2002 f
680 //BRepAlgo_Cut c(mySbase, VraiRevol);
681 //myShape = c.Shape();
682 //UpdateDescendants(c.Builder(), myShape, Standard_False);
683 BRepAlgoAPI_Cut c(mySbase, VraiRevol);
685 UpdateDescendants(c, myShape, Standard_False);
686 //modified by NIZNHY-PKV Thu Mar 21 18:19:50 2002 t
697 //=======================================================================
698 //function : PerformThruAll
699 //purpose : feature throughout the initial shape
700 //=======================================================================
702 void BRepFeat_MakeRevol::PerformThruAll()
705 Standard_Boolean trc = BRepFeat_GettraceFEAT();
706 if (trc) cout << "BRepFeat_MakeRevol::PerformThruAll()" << endl;
711 //=======================================================================
712 //function : PerformUntilAngle
713 //purpose : feature till shape Until defined with the angle
714 //=======================================================================
716 void BRepFeat_MakeRevol::PerformUntilAngle(const TopoDS_Shape& Until,
717 const Standard_Real Angle)
720 Standard_Boolean trc = BRepFeat_GettraceFEAT();
721 if (trc) cout << "BRepFeat_MakeRevol::PerformUntilAngle(Until,Angle)" << endl;
723 if (Until.IsNull()) {
729 TopExp_Explorer exp(Until, TopAbs_FACE);
731 Standard_ConstructionError::Raise();
733 if (!mySkface.IsNull() && Until.IsSame(mySkface)) {
738 myPerfSelection = BRepFeat_NoSelection;
739 PerfSelectionValid();
743 Standard_Boolean Trf = TransformShapeFU(1);
746 // Produce systematicallt an almost complete revolution
747 // BRepSweep_Revol theRevol(myPbase,myAxis,2.*M_PI-10.*Precision::Angular());
748 LocOpe_Revol theRevol;
749 theRevol.Perform(myPbase, myAxis, Angle);
750 TopoDS_Shape VraiRevol = theRevol.Shape();
752 MajMap(myPbase,theRevol,myMap,myFShape,myLShape);
755 myGShape = VraiRevol;
756 GeneratedShapeValid();
758 TopoDS_Shape Base = theRevol.FirstShape();
759 exp.Init(Base, TopAbs_FACE);
760 TopoDS_Face theBase = TopoDS::Face(exp.Current());
764 myStatusError = BRepFeat_InvFirstShape;
768 //SetGluedFaces(mySkface, mySbase, theBase, mySlface, theRevol, myGluedF);
770 //VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF);
773 theRevol.Curves(myCurves);
774 myBCurve = theRevol.BarycCurve();
778 TColGeom_SequenceOfCurve scur;
779 theRevol.Curves(myCurves);
780 myBCurve = theRevol.BarycCurve();
782 scur.Append(myBCurve);
783 LocOpe_CSIntersector ASI(mySUntil);
785 if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
786 TopAbs_Orientation Or = ASI.Point(1,1).Orientation();
787 TopoDS_Face FUntil = ASI.Point(1,1).Face();
790 B.MakeCompound(TopoDS::Compound(Comp));
791 TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or);
792 if (!S.IsNull()) B.Add(Comp,S);
793 //modified by NIZNHY-PKV Thu Mar 21 18:20:14 2002 f
794 //BRepAlgo_Cut trP(VraiRevol,Comp);
795 BRepAlgoAPI_Cut trP(VraiRevol,Comp);
796 //modified by NIZNHY-PKV Thu Mar 21 18:20:19 2002 t
797 TopoDS_Shape Cutsh = trP.Shape();
798 TopExp_Explorer ex(Cutsh, TopAbs_SOLID);
799 for(; ex.More(); ex.Next()) {
800 TopExp_Explorer ex1(ex.Current(), TopAbs_FACE);
801 for(; ex1.More(); ex1.Next()) {
802 const TopoDS_Face& fac = TopoDS::Face(ex1.Current());
803 if(fac.IsSame(myPbase)) {
804 VraiRevol = ex.Current();
810 //modified by NIZNHY-PKV Thu Mar 21 18:20:36 2002 f
811 //BRepAlgo_Fuse f(mySbase, VraiRevol);
812 //myShape = f.Shape();
813 //UpdateDescendants(f.Builder(), myShape, Standard_False);
814 BRepAlgoAPI_Fuse f(mySbase, VraiRevol);
816 UpdateDescendants(f, myShape, Standard_False);
817 //modified by NIZNHY-PKV Thu Mar 21 18:20:40 2002 t
820 else if(myFuse == 0) {
821 //modified by NIZNHY-PKV Thu Mar 21 18:21:07 2002 f
822 //BRepAlgo_Cut c(mySbase, VraiRevol);
823 //myShape = c.Shape();
824 //UpdateDescendants(c.Builder(), myShape, Standard_False);
825 BRepAlgoAPI_Cut c(mySbase, VraiRevol);
827 UpdateDescendants(c, myShape, Standard_False);
828 //modified by NIZNHY-PKV Thu Mar 21 18:21:26 2002 t
838 //=======================================================================
840 //purpose : circles parallel to the generating edge of revolution
841 //=======================================================================
843 void BRepFeat_MakeRevol::Curves(TColGeom_SequenceOfCurve& scur)
848 //=======================================================================
849 //function : BarycCurve
850 //purpose : pass through the center of mass of the primitive
851 //=======================================================================
853 Handle(Geom_Curve) BRepFeat_MakeRevol::BarycCurve()
859 //=======================================================================
860 //function : SetGluedFaces
861 //purpose : management of gluing faces
862 //=======================================================================
864 static void SetGluedFaces(const TopoDS_Face& theSkface,
865 const TopoDS_Shape& theSbase,
866 const TopoDS_Shape& thePbase,
867 const TopTools_DataMapOfShapeListOfShape& theSlmap,
868 LocOpe_Revol& theRevol,
869 TopTools_DataMapOfShapeShape& theMap)
872 if (!theSkface.IsNull() && thePbase.ShapeType() == TopAbs_FACE) {
873 for (exp.Init(theSbase,TopAbs_FACE); exp.More(); exp.Next()) {
874 if (exp.Current().IsSame(theSkface)) {
875 theMap.Bind(thePbase,theSkface);
881 TopExp_Explorer exp2;
882 for (exp.Init(thePbase,TopAbs_FACE);exp.More();exp.Next()) {
883 const TopoDS_Face& fac = TopoDS::Face(exp.Current());
884 for (exp2.Init(theSbase,TopAbs_FACE);exp2.More();exp2.Next()) {
885 if (exp2.Current().IsSame(fac)) {
886 theMap.Bind(fac,fac);
894 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(theSlmap);
895 if(!theSlmap.IsEmpty()) {
896 for (; itm.More(); itm.Next()) {
897 const TopoDS_Face& fac = TopoDS::Face(itm.Key());
898 const TopTools_ListOfShape& ledg = itm.Value();
899 TopTools_ListIteratorOfListOfShape it;
900 for (it.Initialize(ledg); it.More(); it.Next()) {
901 const TopTools_ListOfShape& gfac = theRevol.Shapes(it.Value());
902 if (gfac.Extent() != 1) {
904 Standard_Boolean trc = BRepFeat_GettraceFEAT();
905 if (trc) cout << " BRepFeat_MakeRevol : Pb SetGluedFace" << endl;
908 theMap.Bind(gfac.First(),fac);
914 //=======================================================================
915 //function : VerifGluedFaces
916 //purpose : Check intersection Tool/theSkface = thePbase
917 // if yes -> OK otherwise -> case without gluing
918 //=======================================================================
920 static void VerifGluedFaces(const TopoDS_Face& theSkface,
921 const TopoDS_Shape& thePbase,
922 Handle(Geom_Curve)& theBCurve,
923 TColGeom_SequenceOfCurve& theCurves,
924 LocOpe_Revol& theRevol,
925 TopTools_DataMapOfShapeShape& theMap)
927 Standard_Boolean GluedFaces = Standard_True;
928 TopoDS_Shape VraiRevol = theRevol.Shape();
930 TColGeom_SequenceOfCurve scur;
931 theRevol.Curves(theCurves);
932 theBCurve = theRevol.BarycCurve();
934 scur.Append(theBCurve);
935 LocOpe_CSIntersector ASI(theSkface);
937 if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
938 TopAbs_Orientation Or = ASI.Point(1,1).Orientation();
939 TopoDS_Face FSk = ASI.Point(1,1).Face();
942 B.MakeCompound(TopoDS::Compound(Comp));
943 TopoDS_Solid S = BRepFeat::Tool(theSkface, FSk, Or);
944 if (!S.IsNull()) B.Add(Comp,S);
945 //modified by NIZNHY-PKV Thu Mar 21 18:21:54 2002 f
946 //BRepAlgo_Cut trP(VraiRevol,Comp);
947 BRepAlgoAPI_Cut trP(VraiRevol,Comp);
948 //modified by NIZNHY-PKV Thu Mar 21 18:21:58 2002 t
949 TopoDS_Shape Cutsh = trP.Shape();
950 TopExp_Explorer ex(Cutsh, TopAbs_SOLID);
951 for(; ex.More(); ex.Next()) {
952 TopExp_Explorer ex1(ex.Current(), TopAbs_FACE);
953 for(; ex1.More(); ex1.Next()) {
954 const TopoDS_Face& fac1 = TopoDS::Face(ex1.Current());
955 TopExp_Explorer ex2(thePbase, TopAbs_FACE);
956 for(; ex2.More(); ex2.Next()) {
957 const TopoDS_Face& fac2 = TopoDS::Face(ex2.Current());
958 if(fac1.IsSame(fac2)) break;
960 if (ex2.More()) break;
962 if (ex1.More()) continue;
963 GluedFaces = Standard_False;
968 Standard_Boolean trc = BRepFeat_GettraceFEAT();
969 if (trc) cout << " Intersection Revol/skface : no gluing" << endl;
976 //=======================================================================
978 //purpose : management of descendants
979 //=======================================================================
981 static void MajMap(const TopoDS_Shape& theB,
982 const LocOpe_Revol& theP,
983 TopTools_DataMapOfShapeListOfShape& theMap, // myMap
984 TopoDS_Shape& theFShape, // myFShape
985 TopoDS_Shape& theLShape) // myLShape
987 TopExp_Explorer exp(theP.FirstShape(),TopAbs_WIRE);
989 theFShape = exp.Current();
990 TopTools_ListOfShape thelist;
991 theMap.Bind(theFShape, thelist);
992 for (exp.Init(theP.FirstShape(),TopAbs_FACE);exp.More();exp.Next()) {
993 theMap(theFShape).Append(exp.Current());
997 exp.Init(theP.LastShape(),TopAbs_WIRE);
999 theLShape = exp.Current();
1000 TopTools_ListOfShape thelist1;
1001 theMap.Bind(theLShape, thelist1);
1002 for (exp.Init(theP.LastShape(),TopAbs_FACE);exp.More();exp.Next()) {
1003 theMap(theLShape).Append(exp.Current());
1007 for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) {
1008 if (!theMap.IsBound(exp.Current())) {
1009 TopTools_ListOfShape thelist2;
1010 theMap.Bind(exp.Current(), thelist2);
1011 theMap(exp.Current()) = theP.Shapes(exp.Current());
1018 //=======================================================================
1020 //purpose : two faces samedomaine or not
1021 //=======================================================================
1023 Standard_Boolean ToFuse(const TopoDS_Face& F1,
1024 const TopoDS_Face& F2)
1026 if (F1.IsNull() || F2.IsNull()) {
1027 return Standard_False;
1030 Handle(Geom_Surface) S1,S2;
1031 TopLoc_Location loc1, loc2;
1032 Handle(Standard_Type) typS1,typS2;
1033 const Standard_Real tollin = Precision::Confusion();
1034 const Standard_Real tolang = Precision::Angular();
1036 S1 = BRep_Tool::Surface(F1,loc1);
1037 S2 = BRep_Tool::Surface(F2,loc2);
1039 typS1 = S1->DynamicType();
1040 typS2 = S2->DynamicType();
1042 if (typS1 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
1043 S1 = (*((Handle(Geom_RectangularTrimmedSurface)*)&S1))->BasisSurface();
1044 typS1 = S1->DynamicType();
1047 if (typS2 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
1048 S2 = (*((Handle(Geom_RectangularTrimmedSurface)*)&S2))->BasisSurface();
1049 typS2 = S2->DynamicType();
1052 if (typS1 != typS2) {
1053 return Standard_False;
1057 Standard_Boolean ValRet = Standard_False;
1058 if (typS1 == STANDARD_TYPE(Geom_Plane)) {
1059 S1 = BRep_Tool::Surface(F1); // to apply the location.
1060 S2 = BRep_Tool::Surface(F2);
1061 gp_Pln pl1( (*((Handle(Geom_Plane)*)&S1))->Pln());
1062 gp_Pln pl2( (*((Handle(Geom_Plane)*)&S2))->Pln());
1064 if (pl1.Position().IsCoplanar(pl2.Position(),tollin,tolang)) {
1065 ValRet = Standard_True;