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_Gluer.hxx>
29 #include <LocOpe_FindEdges.hxx>
30 #include <LocOpe_SequenceOfCirc.hxx>
31 #include <LocOpe_BuildShape.hxx>
32 #include <LocOpe_CSIntersector.hxx>
33 #include <LocOpe_PntFace.hxx>
38 #include <gp_Pnt2d.hxx>
39 #include <TColgp_SequenceOfPnt.hxx>
40 #include <Geom_Surface.hxx>
41 #include <Geom_Curve.hxx>
42 #include <Geom_Circle.hxx>
43 #include <Geom2d_Curve.hxx>
44 #include <Geom_RectangularTrimmedSurface.hxx>
45 #include <Bnd_Box.hxx>
47 #include <BRepSweep_Revol.hxx>
48 #include <BRep_Builder.hxx>
49 #include <BRep_Tool.hxx>
50 #include <TopExp_Explorer.hxx>
51 #include <TopTools_MapOfShape.hxx>
52 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
53 #include <TopTools_ListIteratorOfListOfShape.hxx>
54 #include <TopTools_MapIteratorOfMapOfShape.hxx>
55 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
57 #include <BRepAlgoAPI_Cut.hxx>
58 #include <BRepAlgoAPI_Fuse.hxx>
60 #include <BRepLib_MakeFace.hxx>
61 #include <BRepTools_Modifier.hxx>
62 #include <BRepTools_TrsfModification.hxx>
64 #include <Standard_ConstructionError.hxx>
66 #include <TopoDS_Solid.hxx>
67 #include <TopoDS_Compound.hxx>
68 #include <TopoDS_Shell.hxx>
71 #include <Geom_Plane.hxx>
75 #include <Precision.hxx>
76 #include <BRepBndLib.hxx>
77 #include <BRepBuilderAPI.hxx>
78 #include <BRepFeat.hxx>
83 extern Standard_Boolean BRepFeat_GettraceFEAT();
86 static void MajMap(const TopoDS_Shape&, // base
88 TopTools_DataMapOfShapeListOfShape&, // myMap
89 TopoDS_Shape&, // myFShape
90 TopoDS_Shape&); // myLShape
93 static void VerifGluedFaces(const TopoDS_Face& theSkface,
94 const TopoDS_Shape& thePbase,
95 Handle(Geom_Curve)& theBCurve,
96 TColGeom_SequenceOfCurve& theCurves,
97 LocOpe_Revol& theRevol,
98 TopTools_DataMapOfShapeShape& theMap);
101 static Standard_Boolean ToFuse(const TopoDS_Face& ,
107 //=======================================================================
110 //=======================================================================
112 void BRepFeat_MakeRevol::Init(const TopoDS_Shape& Sbase,
113 const TopoDS_Shape& Pbase,
114 const TopoDS_Face& Skface,
116 const Standard_Integer Mode,
117 const Standard_Boolean Modify)
120 Standard_Boolean trc = BRepFeat_GettraceFEAT();
121 if (trc) cout << "BRepFeat_MakeRevol::Init" << endl;
132 myFuse = Standard_False;
133 myJustFeat = Standard_False;
136 myFuse = Standard_True;
137 myJustFeat = Standard_False;
140 myFuse = Standard_True;
141 myJustFeat = Standard_True;
146 myJustGluer = Standard_False;
149 // mySkface.Nullify();
158 for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
159 TopTools_ListOfShape thelist;
160 myMap.Bind(exp.Current(), thelist);
161 myMap(exp.Current()).Append(exp.Current());
165 if (myJustFeat) cout << " Just Feature" << endl;
166 if (myFuse) cout << " Fuse" << endl;
167 if (!myFuse) cout << " Cut" << endl;
168 if (!myModify) cout << " Modify = 0" << endl;
174 //=======================================================================
176 //purpose : add faces add edges of sliding
177 //=======================================================================
179 void BRepFeat_MakeRevol::Add(const TopoDS_Edge& E,
180 const TopoDS_Face& F)
183 Standard_Boolean trc = BRepFeat_GettraceFEAT();
184 if (trc) cout << "BRepFeat_MakeRevol::Add(Edge,face)" << endl;
187 for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
188 if (exp.Current().IsSame(F)) {
193 Standard_ConstructionError::Raise();
196 for (exp.Init(myPbase,TopAbs_EDGE);exp.More();exp.Next()) {
197 if (exp.Current().IsSame(E)) {
202 Standard_ConstructionError::Raise();
205 if (!mySlface.IsBound(F)) {
206 TopTools_ListOfShape thelist;
207 mySlface.Bind(F, thelist);
209 TopTools_ListIteratorOfListOfShape itl(mySlface(F));
210 for (; itl.More();itl.Next()) {
211 if (itl.Value().IsSame(E)) {
216 mySlface(F).Append(E);
221 //=======================================================================
224 //=======================================================================
226 void BRepFeat_MakeRevol::Perform(const Standard_Real Angle)
229 Standard_Boolean trc = BRepFeat_GettraceFEAT();
230 if (trc) cout << "BRepFeat_MakeRevol::Perform(Angle)" << endl;
237 myPerfSelection = BRepFeat_NoSelection;
238 PerfSelectionValid();
239 Standard_Boolean RevolComp = (2*M_PI-Abs(Angle) <= Precision::Angular());
240 LocOpe_Revol theRevol;
241 Standard_Real angledec = 0.;
245 if (!mySkface.IsNull() || !mySlface.IsEmpty()) {
246 for (exp.Init(mySbase,TopAbs_FACE); exp.More(); exp.Next()) {
247 if (exp.Current().IsSame(mySkface)) {
248 angledec = M_PI/5; // pourquoi pas
249 if (myFuse) angledec = -angledec;
257 if(angledec == 0.) theRevol.Perform(myPbase, myAxis, Angle);
258 else theRevol.Perform(myPbase, myAxis, Angle, angledec);
260 TopoDS_Shape VraiRevol = theRevol.Shape();
262 MajMap(myPbase,theRevol,myMap,myFShape,myLShape);
264 myGShape = VraiRevol;
265 GeneratedShapeValid();
266 TopoDS_Shape Base = theRevol.FirstShape();
267 exp.Init(Base, TopAbs_FACE);
268 TopoDS_Face theBase = TopoDS::Face(exp.Current());
272 myStatusError = BRepFeat_InvFirstShape;
278 Standard_Boolean found = Standard_False;
280 if(!mySkface.IsNull() || !mySlface.IsEmpty()) {
281 if(myLShape.ShapeType() == TopAbs_WIRE) {
282 TopExp_Explorer ex1(VraiRevol, TopAbs_FACE);
283 for(; ex1.More(); ex1.Next()) {
284 TopExp_Explorer ex2(ex1.Current(), TopAbs_WIRE);
285 for(; ex2.More(); ex2.Next()) {
286 if(ex2.Current().IsSame(myLShape)) {
287 FFace = TopoDS::Face(ex1.Current());
288 found = Standard_True;
296 TopExp_Explorer exp(mySbase, TopAbs_FACE);
297 for(; exp.More(); exp.Next()) {
298 const TopoDS_Face& ff = TopoDS::Face(exp.Current());
299 if(ToFuse(ff, FFace)) {
300 TopTools_DataMapOfShapeListOfShape sl;
301 if(!FFace.IsSame(myPbase) && BRepFeat::IsInside(ff, FFace))
307 if (!mySkface.IsNull()) {
308 VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF);
311 if(myGluedF.IsEmpty()) {
313 //modified by NIZNHY-PKV Thu Mar 21 18:15:06 2002 f
314 //BRepAlgo_Fuse f(mySbase, myGShape);
315 //myShape = f.Shape();
316 //UpdateDescendants(f.Builder(), myShape, Standard_False);
317 BRepAlgoAPI_Fuse f(mySbase, myGShape);
319 UpdateDescendants(f, myShape, Standard_False);
320 //modified by NIZNHY-PKV Thu Mar 21 18:15:11 2002 t
323 else if(myFuse == 0) {
324 //modified by NIZNHY-PKV Thu Mar 21 18:15:37 2002 f
325 //BRepAlgo_Cut c(mySbase, myGShape);
326 //myShape = c.Shape();
327 //UpdateDescendants(c.Builder(), myShape, Standard_False);
328 BRepAlgoAPI_Cut c(mySbase, myGShape);
330 UpdateDescendants(c, myShape, Standard_False);
331 //modified by NIZNHY-PKV Thu Mar 21 18:15:47 2002 t
340 theRevol.Curves(myCurves);
341 myBCurve = theRevol.BarycCurve();
347 //=======================================================================
349 //purpose : feature till shape Until
350 //=======================================================================
352 void BRepFeat_MakeRevol::Perform(const TopoDS_Shape& Until)
355 Standard_Boolean trc = BRepFeat_GettraceFEAT();
356 if (trc) cout << "BRepFeat_MakeRevol::Perform(Until)" << endl;
358 Standard_Real Angle = 0.;
359 Standard_Boolean TourComplet = Standard_False;
361 if (Until.IsNull()) {
362 Standard_ConstructionError::Raise();
364 TopExp_Explorer exp(Until, TopAbs_FACE);
366 Standard_ConstructionError::Raise();
368 if (!mySkface.IsNull() && Until.IsSame(mySkface)) {
370 TourComplet = Standard_True;
373 myPerfSelection = BRepFeat_SelectionU;
374 PerfSelectionValid();
378 Standard_Boolean Trf = TransformShapeFU(1);
381 // Do systematically almost complete revolution
382 // BRepSweep_Revol theRevol(myPbase,myAxis,2.*M_PI-10.*Precision::Angular());
383 LocOpe_Revol theRevol;
385 Angle = 2.*M_PI- 3*M_PI/180.;
387 if (trc) cout << " No complete Revolution" << endl;
390 theRevol.Perform(myPbase, myAxis, Angle);
391 TopoDS_Shape VraiRevol = theRevol.Shape();
392 MajMap(myPbase,theRevol,myMap,myFShape,myLShape);
397 myGShape = VraiRevol;
398 GeneratedShapeValid();
400 TopoDS_Shape Base = theRevol.FirstShape();
401 exp.Init(Base, TopAbs_FACE);
402 TopoDS_Face theBase = TopoDS::Face(exp.Current());
406 myStatusError = BRepFeat_InvFirstShape;
410 //VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF);
412 theRevol.Curves(myCurves);
413 myBCurve = theRevol.BarycCurve();
417 TColGeom_SequenceOfCurve scur;
418 theRevol.Curves(myCurves);
419 myBCurve = theRevol.BarycCurve();
421 scur.Append(myBCurve);
422 LocOpe_CSIntersector ASI(mySUntil);
424 if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
425 TopAbs_Orientation Or = ASI.Point(1,1).Orientation();
426 TopoDS_Face FUntil = ASI.Point(1,1).Face();
429 B.MakeCompound(TopoDS::Compound(Comp));
430 TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or);
431 if (!S.IsNull()) B.Add(Comp,S);
432 //modified by NIZNHY-PKV Thu Mar 21 18:17:31 2002 f
433 //BRepAlgo_Cut trP(VraiRevol,Comp);
434 BRepAlgoAPI_Cut trP(VraiRevol,Comp);
435 //modified by NIZNHY-PKV Thu Mar 21 18:17:37 2002 t
436 TopoDS_Shape Cutsh = trP.Shape();
437 TopExp_Explorer ex(Cutsh, TopAbs_SOLID);
438 for(; ex.More(); ex.Next()) {
439 TopExp_Explorer ex1(ex.Current(), TopAbs_FACE);
440 for(; ex1.More(); ex1.Next()) {
441 const TopoDS_Face& fac = TopoDS::Face(ex1.Current());
442 if(fac.IsSame(myPbase)) {
443 VraiRevol = ex.Current();
449 //modified by NIZNHY-PKV Thu Mar 21 18:17:53 2002 f
450 //BRepAlgo_Fuse f(mySbase, VraiRevol);
451 //myShape = f.Shape();
452 //UpdateDescendants(f.Builder(), myShape, Standard_False);
453 BRepAlgoAPI_Fuse f(mySbase, VraiRevol);
455 UpdateDescendants(f, myShape, Standard_False);
456 //modified by NIZNHY-PKV Thu Mar 21 18:17:57 2002 t
459 else if(myFuse == 0) {
460 //modified by NIZNHY-PKV Thu Mar 21 18:18:23 2002 f
461 //BRepAlgo_Cut c(mySbase, VraiRevol);
462 //myShape = c.Shape();
463 //UpdateDescendants(c.Builder(), myShape, Standard_False);
464 BRepAlgoAPI_Cut c(mySbase, VraiRevol);
466 UpdateDescendants(c, myShape, Standard_False);
467 //modified by NIZNHY-PKV Thu Mar 21 18:18:28 2002 t
476 // Loop of control of descendance
478 TopExp_Explorer expr(mySbase, TopAbs_FACE);
479 char nom1[20], nom2[20];
480 Standard_Integer ii = 0;
481 for(; expr.More(); expr.Next()) {
483 sprintf(nom1, "faceinitial_%d", ii);
484 DBRep::Set(nom1, expr.Current());
485 Standard_Integer jj = 0;
486 const TopTools_ListOfShape& list = Modified(expr.Current());
487 TopTools_ListIteratorOfListOfShape ite(list);
488 for(; ite.More(); ite.Next()) {
490 sprintf(nom2, "facemodifie_%d_%d", ii, jj);
491 DBRep::Set(nom2, ite.Value());
495 expr.Init(myPbase, TopAbs_EDGE);
497 for(; expr.More(); expr.Next()) {
499 sprintf(nom1, "edgeinitial_%d", ii);
500 DBRep::Set(nom1, expr.Current());
501 Standard_Integer jj = 0;
502 const TopTools_ListOfShape& list = Generated(expr.Current());
503 TopTools_ListIteratorOfListOfShape ite(list);
504 for(; ite.More(); ite.Next()) {
506 sprintf(nom2, "facegeneree_%d_%d", ii, jj);
507 DBRep::Set(nom2, ite.Value());
514 //=======================================================================
516 //purpose : feature limited by two shapes
517 //=======================================================================
519 void BRepFeat_MakeRevol::Perform(const TopoDS_Shape& From,
520 const TopoDS_Shape& Until)
523 Standard_Boolean trc = BRepFeat_GettraceFEAT();
524 if (trc) cout << "BRepFeat_MakeRevol::Perform(From,Until)" << endl;
526 if (From.IsNull() || Until.IsNull()) {
527 Standard_ConstructionError::Raise();
529 if (!mySkface.IsNull()) {
530 if (From.IsSame(mySkface)) {
531 myJustGluer = Standard_True;
533 if (myJustGluer) return;
535 else if (Until.IsSame(mySkface)) {
536 myJustGluer = Standard_True;
539 if (myJustGluer) return;
544 myPerfSelection = BRepFeat_SelectionFU;
545 PerfSelectionValid();
547 TopExp_Explorer exp(From, TopAbs_FACE);
549 Standard_ConstructionError::Raise();
551 exp.Init(Until, TopAbs_FACE);
553 Standard_ConstructionError::Raise();
557 Standard_Boolean Trff = TransformShapeFU(0);
560 Standard_Boolean Trfu = TransformShapeFU(1);
565 myStatusError = BRepFeat_IncTypes;
569 LocOpe_Revol theRevol;
570 theRevol.Perform(myPbase, myAxis, 2*M_PI);
571 TopoDS_Shape VraiRevol = theRevol.Shape();
573 MajMap(myPbase,theRevol,myMap,myFShape,myLShape);
576 myGShape = VraiRevol;
577 GeneratedShapeValid();
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*M_PI,PrU);
611 Standard_Real pr2 = ASI2.Point(1,ASI2.NbPoints(1)).Parameter();
612 pr2 = ElCLib::InPeriod(pr2,PrU-2*M_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 throughout the initial shape
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 till shape Until defined with the 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 // Produce systematicallt an almost complete revolution
731 // BRepSweep_Revol theRevol(myPbase,myAxis,2.*M_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 //VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF);
755 theRevol.Curves(myCurves);
756 myBCurve = theRevol.BarycCurve();
760 TColGeom_SequenceOfCurve scur;
761 theRevol.Curves(myCurves);
762 myBCurve = theRevol.BarycCurve();
764 scur.Append(myBCurve);
765 LocOpe_CSIntersector ASI(mySUntil);
767 if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
768 TopAbs_Orientation Or = ASI.Point(1,1).Orientation();
769 TopoDS_Face FUntil = ASI.Point(1,1).Face();
772 B.MakeCompound(TopoDS::Compound(Comp));
773 TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or);
774 if (!S.IsNull()) B.Add(Comp,S);
775 //modified by NIZNHY-PKV Thu Mar 21 18:20:14 2002 f
776 //BRepAlgo_Cut trP(VraiRevol,Comp);
777 BRepAlgoAPI_Cut trP(VraiRevol,Comp);
778 //modified by NIZNHY-PKV Thu Mar 21 18:20:19 2002 t
779 TopoDS_Shape Cutsh = trP.Shape();
780 TopExp_Explorer ex(Cutsh, TopAbs_SOLID);
781 for(; ex.More(); ex.Next()) {
782 TopExp_Explorer ex1(ex.Current(), TopAbs_FACE);
783 for(; ex1.More(); ex1.Next()) {
784 const TopoDS_Face& fac = TopoDS::Face(ex1.Current());
785 if(fac.IsSame(myPbase)) {
786 VraiRevol = ex.Current();
792 //modified by NIZNHY-PKV Thu Mar 21 18:20:36 2002 f
793 //BRepAlgo_Fuse f(mySbase, VraiRevol);
794 //myShape = f.Shape();
795 //UpdateDescendants(f.Builder(), myShape, Standard_False);
796 BRepAlgoAPI_Fuse f(mySbase, VraiRevol);
798 UpdateDescendants(f, myShape, Standard_False);
799 //modified by NIZNHY-PKV Thu Mar 21 18:20:40 2002 t
802 else if(myFuse == 0) {
803 //modified by NIZNHY-PKV Thu Mar 21 18:21:07 2002 f
804 //BRepAlgo_Cut c(mySbase, VraiRevol);
805 //myShape = c.Shape();
806 //UpdateDescendants(c.Builder(), myShape, Standard_False);
807 BRepAlgoAPI_Cut c(mySbase, VraiRevol);
809 UpdateDescendants(c, myShape, Standard_False);
810 //modified by NIZNHY-PKV Thu Mar 21 18:21:26 2002 t
820 //=======================================================================
822 //purpose : circles parallel to the generating edge of revolution
823 //=======================================================================
825 void BRepFeat_MakeRevol::Curves(TColGeom_SequenceOfCurve& scur)
830 //=======================================================================
831 //function : BarycCurve
832 //purpose : pass through the center of mass of the primitive
833 //=======================================================================
835 Handle(Geom_Curve) BRepFeat_MakeRevol::BarycCurve()
840 //=======================================================================
841 //function : VerifGluedFaces
842 //purpose : Check intersection Tool/theSkface = thePbase
843 // if yes -> OK otherwise -> case without gluing
844 //=======================================================================
846 static void VerifGluedFaces(const TopoDS_Face& theSkface,
847 const TopoDS_Shape& thePbase,
848 Handle(Geom_Curve)& theBCurve,
849 TColGeom_SequenceOfCurve& theCurves,
850 LocOpe_Revol& theRevol,
851 TopTools_DataMapOfShapeShape& theMap)
853 Standard_Boolean GluedFaces = Standard_True;
854 TopoDS_Shape VraiRevol = theRevol.Shape();
856 TColGeom_SequenceOfCurve scur;
857 theRevol.Curves(theCurves);
858 theBCurve = theRevol.BarycCurve();
860 scur.Append(theBCurve);
861 LocOpe_CSIntersector ASI(theSkface);
863 if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
864 TopAbs_Orientation Or = ASI.Point(1,1).Orientation();
865 TopoDS_Face FSk = ASI.Point(1,1).Face();
868 B.MakeCompound(TopoDS::Compound(Comp));
869 TopoDS_Solid S = BRepFeat::Tool(theSkface, FSk, Or);
870 if (!S.IsNull()) B.Add(Comp,S);
871 //modified by NIZNHY-PKV Thu Mar 21 18:21:54 2002 f
872 //BRepAlgo_Cut trP(VraiRevol,Comp);
873 BRepAlgoAPI_Cut trP(VraiRevol,Comp);
874 //modified by NIZNHY-PKV Thu Mar 21 18:21:58 2002 t
875 TopoDS_Shape Cutsh = trP.Shape();
876 TopExp_Explorer ex(Cutsh, TopAbs_SOLID);
877 for(; ex.More(); ex.Next()) {
878 TopExp_Explorer ex1(ex.Current(), TopAbs_FACE);
879 for(; ex1.More(); ex1.Next()) {
880 const TopoDS_Face& fac1 = TopoDS::Face(ex1.Current());
881 TopExp_Explorer ex2(thePbase, TopAbs_FACE);
882 for(; ex2.More(); ex2.Next()) {
883 const TopoDS_Face& fac2 = TopoDS::Face(ex2.Current());
884 if(fac1.IsSame(fac2)) break;
886 if (ex2.More()) break;
888 if (ex1.More()) continue;
889 GluedFaces = Standard_False;
894 Standard_Boolean trc = BRepFeat_GettraceFEAT();
895 if (trc) cout << " Intersection Revol/skface : no gluing" << endl;
902 //=======================================================================
904 //purpose : management of descendants
905 //=======================================================================
907 static void MajMap(const TopoDS_Shape& theB,
908 const LocOpe_Revol& theP,
909 TopTools_DataMapOfShapeListOfShape& theMap, // myMap
910 TopoDS_Shape& theFShape, // myFShape
911 TopoDS_Shape& theLShape) // myLShape
913 TopExp_Explorer exp(theP.FirstShape(),TopAbs_WIRE);
915 theFShape = exp.Current();
916 TopTools_ListOfShape thelist;
917 theMap.Bind(theFShape, thelist);
918 for (exp.Init(theP.FirstShape(),TopAbs_FACE);exp.More();exp.Next()) {
919 theMap(theFShape).Append(exp.Current());
923 exp.Init(theP.LastShape(),TopAbs_WIRE);
925 theLShape = exp.Current();
926 TopTools_ListOfShape thelist1;
927 theMap.Bind(theLShape, thelist1);
928 for (exp.Init(theP.LastShape(),TopAbs_FACE);exp.More();exp.Next()) {
929 theMap(theLShape).Append(exp.Current());
933 for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) {
934 if (!theMap.IsBound(exp.Current())) {
935 TopTools_ListOfShape thelist2;
936 theMap.Bind(exp.Current(), thelist2);
937 theMap(exp.Current()) = theP.Shapes(exp.Current());
944 //=======================================================================
946 //purpose : two faces samedomaine or not
947 //=======================================================================
949 Standard_Boolean ToFuse(const TopoDS_Face& F1,
950 const TopoDS_Face& F2)
952 if (F1.IsNull() || F2.IsNull()) {
953 return Standard_False;
956 Handle(Geom_Surface) S1,S2;
957 TopLoc_Location loc1, loc2;
958 Handle(Standard_Type) typS1,typS2;
959 const Standard_Real tollin = Precision::Confusion();
960 const Standard_Real tolang = Precision::Angular();
962 S1 = BRep_Tool::Surface(F1,loc1);
963 S2 = BRep_Tool::Surface(F2,loc2);
965 typS1 = S1->DynamicType();
966 typS2 = S2->DynamicType();
968 if (typS1 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
969 S1 = (*((Handle(Geom_RectangularTrimmedSurface)*)&S1))->BasisSurface();
970 typS1 = S1->DynamicType();
973 if (typS2 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
974 S2 = (*((Handle(Geom_RectangularTrimmedSurface)*)&S2))->BasisSurface();
975 typS2 = S2->DynamicType();
978 if (typS1 != typS2) {
979 return Standard_False;
983 Standard_Boolean ValRet = Standard_False;
984 if (typS1 == STANDARD_TYPE(Geom_Plane)) {
985 S1 = BRep_Tool::Surface(F1); // to apply the location.
986 S2 = BRep_Tool::Surface(F2);
987 gp_Pln pl1( (*((Handle(Geom_Plane)*)&S1))->Pln());
988 gp_Pln pl2( (*((Handle(Geom_Plane)*)&S2))->Pln());
990 if (pl1.Position().IsCoplanar(pl2.Position(),tollin,tolang)) {
991 ValRet = Standard_True;