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.
18 #include <Bnd_Box.hxx>
19 #include <BRepAlgoAPI_Cut.hxx>
20 #include <BRepAlgoAPI_Fuse.hxx>
21 #include <BRepBndLib.hxx>
22 #include <BRepFeat.hxx>
23 #include <BRepFeat_MakePrism.hxx>
24 #include <BRepLib_MakeFace.hxx>
25 #include <BRepPrimAPI_MakeBox.hxx>
26 #include <BRepTools.hxx>
27 #include <Geom_Curve.hxx>
28 #include <Geom_Line.hxx>
29 #include <Geom_Plane.hxx>
30 #include <Geom_RectangularTrimmedSurface.hxx>
31 #include <Geom_Surface.hxx>
38 #include <LocOpe_CSIntersector.hxx>
39 #include <LocOpe_PntFace.hxx>
40 #include <LocOpe_Prism.hxx>
41 #include <Precision.hxx>
42 #include <Standard_ConstructionError.hxx>
43 #include <TColGeom_SequenceOfCurve.hxx>
44 #include <TColgp_SequenceOfPnt.hxx>
45 #include <TopExp_Explorer.hxx>
47 #include <TopoDS_Edge.hxx>
48 #include <TopoDS_Face.hxx>
49 #include <TopoDS_Shape.hxx>
50 #include <TopoDS_Solid.hxx>
51 #include <TopTools_ListOfShape.hxx>
54 extern Standard_Boolean BRepFeat_GettraceFEAT();
57 static void MajMap(const TopoDS_Shape&, // base
59 TopTools_DataMapOfShapeListOfShape&, // myMap
60 TopoDS_Shape&, // myFShape
61 TopoDS_Shape&); // myLShape
63 static Standard_Boolean ToFuse(const TopoDS_Face& ,
66 static Standard_Real HeightMax(const TopoDS_Shape& theSbase,
67 const TopoDS_Face& theSkface,
68 const TopoDS_Shape& theSFrom,
69 const TopoDS_Shape& theSUntil);
71 static Standard_Integer SensOfPrism(const Handle(Geom_Curve) C,
72 const TopoDS_Shape& Until);
74 static Handle(Geom_Curve) TestCurve(const TopoDS_Shape&,
78 //=======================================================================
81 //=======================================================================
83 void BRepFeat_MakePrism::Init(const TopoDS_Shape& Sbase,
84 const TopoDS_Shape& Pbase,
85 const TopoDS_Face& Skface,
87 const Standard_Integer Mode,
88 const Standard_Boolean Modify)
91 Standard_Boolean trc = BRepFeat_GettraceFEAT();
92 if (trc) std::cout << "BRepFeat_MakePrism::Init" << std::endl;
102 myFuse = Standard_False;
103 myJustFeat = Standard_False;
106 myFuse = Standard_True;
107 myJustFeat = Standard_False;
110 myFuse = Standard_True;
111 myJustFeat = Standard_True;
116 myJustGluer = Standard_False;
120 //mySkface.Nullify();
131 for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
132 TopTools_ListOfShape thelist;
133 myMap.Bind(exp.Current(), thelist);
134 myMap(exp.Current()).Append(exp.Current());
138 if (myJustFeat) std::cout << " Just Feature" << std::endl;
139 if (myFuse) std::cout << " Fuse" << std::endl;
140 if (!myFuse) std::cout << " Cut" << std::endl;
141 if (!myModify) std::cout << " Modify = 0" << std::endl;
147 //=======================================================================
149 //purpose : add elements of sliding (edge on face)
150 //=======================================================================
152 void BRepFeat_MakePrism::Add(const TopoDS_Edge& E,
153 const TopoDS_Face& F)
156 Standard_Boolean trc = BRepFeat_GettraceFEAT();
157 if (trc) std::cout << "BRepFeat_MakePrism::Add(Edge,face)" << std::endl;
160 for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
161 if (exp.Current().IsSame(F)) {
166 throw Standard_ConstructionError();
169 for (exp.Init(myPbase,TopAbs_EDGE);exp.More();exp.Next()) {
170 if (exp.Current().IsSame(E)) {
175 throw Standard_ConstructionError();
178 if (!mySlface.IsBound(F)) {
179 TopTools_ListOfShape thelist1;
180 mySlface.Bind(F, thelist1);
182 TopTools_ListIteratorOfListOfShape itl(mySlface(F));
183 for (; itl.More();itl.Next()) {
184 if (itl.Value().IsSame(E)) {
189 mySlface(F).Append(E);
194 //=======================================================================
196 //purpose : construction of prism of length Length and
197 // call of reconstruction topo
198 //=======================================================================
200 void BRepFeat_MakePrism::Perform(const Standard_Real Length)
203 Standard_Boolean trc = BRepFeat_GettraceFEAT();
204 if (trc) std::cout << "BRepFeat_MakePrism::Perform(Length)" << std::endl;
211 myPerfSelection = BRepFeat_NoSelection;
212 PerfSelectionValid();
213 gp_Vec V(Length*myDir);
215 //construction of prism of height Length
217 LocOpe_Prism thePrism(myPbase,V);
218 TopoDS_Shape VraiPrism = thePrism.Shape();
220 // management of descendants
221 MajMap(myPbase,thePrism,myMap,myFShape,myLShape);
224 myGShape = VraiPrism; // the primitive
225 GeneratedShapeValid();
229 Standard_Boolean found = Standard_False;
231 // try to detect the faces of gluing
232 // in case if the top of the prism is tangent to the initial shape
234 if(!mySkface.IsNull() || !mySlface.IsEmpty()) {
235 if(myLShape.ShapeType() == TopAbs_WIRE) {
236 TopExp_Explorer ex1(VraiPrism, TopAbs_FACE);
237 for(; ex1.More(); ex1.Next()) {
238 TopExp_Explorer ex2(ex1.Current(), TopAbs_WIRE);
239 for(; ex2.More(); ex2.Next()) {
240 if(ex2.Current().IsSame(myLShape)) {
241 FFace = TopoDS::Face(ex1.Current());
242 found = Standard_True;
250 TopExp_Explorer exp(mySbase, TopAbs_FACE);
251 for(; exp.More(); exp.Next()) {
252 const TopoDS_Face& ff = TopoDS::Face(exp.Current());
253 if(ToFuse(ff, FFace)) {
254 TopTools_DataMapOfShapeListOfShape sl;
255 if(!FFace.IsSame(myPbase) && BRepFeat::IsInside(ff, FFace))
261 // management of faces of gluing given by the user
265 if(!myGluedF.IsEmpty()) { // case gluing
266 myJustGluer = Standard_True;
267 thePrism.Curves(myCurves);
268 myBCurve = thePrism.BarycCurve();
269 GlobalPerform(); // topological reconstruction
272 // if there is no gluing -> call of ope topo
274 if(myFuse == 1 && !myJustFeat) {
275 BRepAlgoAPI_Fuse f(mySbase, myGShape);
277 UpdateDescendants(f, myShape, Standard_False);
280 else if(myFuse == 0) {
281 BRepAlgoAPI_Cut c(mySbase, myGShape);
283 UpdateDescendants(c, myShape, Standard_False);
294 //=======================================================================
296 //purpose : construction of prism oriented at the face Until, sufficiently
297 // long; call of topological reconstruction
298 //=======================================================================
300 void BRepFeat_MakePrism::Perform(const TopoDS_Shape& Until)
303 Standard_Boolean trc = BRepFeat_GettraceFEAT();
304 if (trc) std::cout << "BRepFeat_MakePrism::Perform(Until)" << std::endl;
306 if (Until.IsNull()) {
307 throw Standard_ConstructionError();
309 TopExp_Explorer exp(Until, TopAbs_FACE);
311 throw Standard_ConstructionError();
314 myPerfSelection = BRepFeat_SelectionU;
315 PerfSelectionValid();
319 Standard_Boolean Trf = TransformShapeFU(1);
321 Handle(Geom_Curve) C = TestCurve(myPbase,myDir);
322 Standard_Integer sens = SensOfPrism(C, mySUntil);
323 Standard_Real Height = HeightMax(mySbase, mySkface, mySFrom, mySUntil);
324 gp_Vec V(2*sens*Height*myDir);
326 // construction of long prism
327 LocOpe_Prism thePrism(myPbase,V);
328 TopoDS_Shape VraiPrism = thePrism.Shape();
330 // in case of support of face Until
332 MajMap(myPbase,thePrism,myMap,myFShape,myLShape);
333 myGShape = VraiPrism;
334 GeneratedShapeValid();
336 thePrism.Curves(myCurves);
337 myBCurve = thePrism.BarycCurve();
340 else { // until support -> passage to topological operations
341 MajMap(myPbase,thePrism,myMap,myFShape,myLShape);
342 TColGeom_SequenceOfCurve scur;
346 // direction of the prism depending on Until
348 LocOpe_CSIntersector ASI(mySUntil);
350 TopAbs_Orientation Or;
351 if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
353 Or = ASI.Point(1, 1).Orientation();
356 Or = ASI.Point(1, ASI.NbPoints(1)).Orientation();
358 if(sens==-1) Or=TopAbs::Reverse(Or);
359 TopoDS_Face FUntil = ASI.Point(1,1).Face();
362 B.MakeCompound(TopoDS::Compound(Comp));
363 TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or);
364 if (!S.IsNull()) B.Add(Comp,S);
365 BRepAlgoAPI_Cut trP(VraiPrism,Comp);
366 UpdateDescendants(trP, trP.Shape(), Standard_False);
368 TopExp_Explorer ex(trP.Shape(), TopAbs_SOLID);
369 TopoDS_Shape Cutsh = ex.Current();
370 if (myFuse == 1 && !myJustFeat) {
371 BRepAlgoAPI_Fuse f(mySbase, Cutsh);
373 UpdateDescendants(f, myShape, Standard_False);
376 else if(myFuse == 0) {
377 BRepAlgoAPI_Cut c(mySbase, Cutsh);
379 UpdateDescendants(c, myShape, Standard_False);
390 //=======================================================================
392 //purpose : construction of a sufficiently long and properly oriented prism
393 // call of topological reconstruction
394 //=======================================================================
396 void BRepFeat_MakePrism::Perform(const TopoDS_Shape& From,
397 const TopoDS_Shape& Until)
400 Standard_Boolean trc = BRepFeat_GettraceFEAT();
401 if (trc) std::cout << "BRepFeat_MakePrism::Perform(From,Until)" << std::endl;
403 if (From.IsNull() || Until.IsNull()) {
404 throw Standard_ConstructionError();
407 if (!mySkface.IsNull()) {
408 if (From.IsSame(mySkface)) {
409 myJustGluer = Standard_True;
411 if (myJustGluer) return;
413 else if (Until.IsSame(mySkface)) {
414 myJustGluer = Standard_True;
416 if (myJustGluer) return;
421 myPerfSelection = BRepFeat_SelectionFU;
422 PerfSelectionValid();
424 TopExp_Explorer exp(From, TopAbs_FACE);
426 throw Standard_ConstructionError();
428 exp.Init(Until, TopAbs_FACE);
430 throw Standard_ConstructionError();
433 Standard_Boolean Trff = TransformShapeFU(0);
436 Standard_Boolean Trfu = TransformShapeFU(1);
440 myStatusError = BRepFeat_IncTypes;
444 // length depending on bounding boxes
446 Standard_Real Height = HeightMax(mySbase, mySkface, mySFrom, mySUntil);
447 Handle(Geom_Curve) C = TestCurve(myPbase,myDir);
448 Standard_Integer sens; // direction of prism
449 Standard_Integer tran; // transfer of prism
450 if(From.IsSame(Until)) {
455 sens = SensOfPrism(C, mySUntil);
456 tran = sens*SensOfPrism(C, mySFrom);
458 LocOpe_Prism thePrism;
460 gp_Vec Vtra(-3*Height*sens/2.*myDir);
461 thePrism.Perform(myPbase,3*sens*Height*myDir,Vtra);
464 thePrism.Perform(myPbase,2*sens*Height*myDir);
466 TopoDS_Shape VraiPrism = thePrism.Shape();
469 MajMap(myPbase,thePrism,myMap,myFShape,myLShape);
471 myGShape = VraiPrism;
472 GeneratedShapeValid();
474 thePrism.Curves(myCurves);
475 myBCurve = thePrism.BarycCurve();
478 else { // case until support -> topological operation
479 MajMap(myPbase,thePrism,myMap,myFShape,myLShape);
480 TColGeom_SequenceOfCurve scur;
483 LocOpe_CSIntersector ASI1(mySUntil);
484 LocOpe_CSIntersector ASI2(mySFrom);
487 TopAbs_Orientation OrU, OrF;
488 TopoDS_Face FFrom, FUntil;
489 Standard_Real ParF, ParU;
490 if (ASI1.IsDone() && ASI1.NbPoints(1) >=1) {
492 OrU = ASI1.Point(1,1).Orientation();
495 OrU = ASI1.Point(1,ASI1.NbPoints(1)).Orientation();
497 if(sens==-1) OrU = TopAbs::Reverse(OrU);
498 FUntil = ASI1.Point(1,1).Face();
499 ParU = ASI1.Point(1,1).Parameter();
503 myStatusError = BRepFeat_NoIntersectU;
506 if (ASI2.IsDone() && ASI2.NbPoints(1) >=1) {
507 OrF = ASI2.Point(1,1).Orientation();
508 if(sens==1) OrF = TopAbs::Reverse(OrF);
509 FFrom = ASI2.Point(1,1).Face();
510 ParF = ASI2.Point(1,1).Parameter();
514 myStatusError = BRepFeat_NoIntersectF;
517 if(tran > 0 && (Abs(ParU) < Abs(ParF)))
519 TopAbs_Orientation Or;
525 TopTools_ListOfShape aLTools;
526 TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, OrU);
532 myStatusError = BRepFeat_NullToolU;
535 TopoDS_Solid SS = BRepFeat::Tool(mySFrom, FFrom, OrF);
541 myStatusError = BRepFeat_NullToolF;
545 TopTools_ListOfShape aLObj;
546 aLObj.Append(VraiPrism);
549 trP.SetArguments(aLObj);
550 trP.SetTools(aLTools);
552 UpdateDescendants(trP, trP.Shape(), Standard_False);
553 if(myFuse == 1 && !myJustFeat) {
554 BRepAlgoAPI_Fuse f(mySbase, trP.Shape());
556 UpdateDescendants(f, myShape, Standard_False);
559 else if(myFuse == 0) {
560 BRepAlgoAPI_Cut c(mySbase, trP.Shape());
562 UpdateDescendants(c, myShape, Standard_False);
566 myShape = trP.Shape();
572 //=======================================================================
573 //function : PerformUntilEnd
574 //purpose : construction of a prism and reconstruction
575 //=======================================================================
577 void BRepFeat_MakePrism::PerformUntilEnd()
580 Standard_Boolean trc = BRepFeat_GettraceFEAT();
581 if (trc) std::cout << "BRepFeat_MakePrism::PerformUntilEnd()" << std::endl;
583 myPerfSelection = BRepFeat_SelectionSh;
584 PerfSelectionValid();
590 Standard_Real Height = HeightMax(mySbase, mySkface, mySFrom, mySUntil);
591 gp_Vec V(2*Height*myDir);
593 LocOpe_Prism thePrism(myPbase,V);
594 TopoDS_Shape VraiPrism = thePrism.Shape();
596 MajMap(myPbase,thePrism,myMap,myFShape,myLShape);
598 myGShape = VraiPrism;
599 GeneratedShapeValid();
603 BRepAlgoAPI_Cut c(mySbase, myGShape);
606 UpdateDescendants(c, myShape, Standard_False);
611 thePrism.Curves(myCurves);
612 myBCurve = thePrism.BarycCurve();
617 //=======================================================================
618 //function : PerformFromEnd
620 //=======================================================================
622 void BRepFeat_MakePrism::PerformFromEnd(const TopoDS_Shape& Until)
625 Standard_Boolean trc = BRepFeat_GettraceFEAT();
626 if (trc) std::cout << "BRepFeat_MakePrism::PerformFromEnd(From,Until)" << std::endl;
628 if (Until.IsNull()) {
629 throw Standard_ConstructionError();
631 if (!mySkface.IsNull() && Until.IsSame(mySkface)) {
637 exp.Init(Until, TopAbs_FACE);
639 throw Standard_ConstructionError();
641 myPerfSelection = BRepFeat_SelectionShU;
642 PerfSelectionValid();
646 Standard_Boolean Trf = TransformShapeFU(1);
648 Handle(Geom_Curve) C = TestCurve(myPbase,myDir);
649 Standard_Integer sens = SensOfPrism(C, mySUntil);
650 Standard_Real Height = HeightMax(mySbase, mySkface, mySFrom, mySUntil);
651 gp_Vec Vtra(-3*Height*sens/2.*myDir);
652 gp_Vec Vect(3*sens*Height*myDir);
653 LocOpe_Prism thePrism(myPbase,Vect,Vtra);
654 TopoDS_Shape VraiPrism = thePrism.Shape();
656 if(!Trf) { // case face until
657 MajMap(myPbase,thePrism,myMap,myFShape,myLShape);
658 myGShape = VraiPrism;
659 GeneratedShapeValid();
662 thePrism.Curves(myCurves);
663 myBCurve = thePrism.BarycCurve();
666 else { // case support
667 MajMap(myPbase,thePrism,myMap,myFShape,myLShape);
668 TColGeom_SequenceOfCurve scur;
671 LocOpe_CSIntersector ASI1(mySUntil);
672 LocOpe_CSIntersector ASI2(mySbase);
675 TopAbs_Orientation OrU = TopAbs_FORWARD, OrF = TopAbs_FORWARD;
676 TopoDS_Face FUntil, FFrom;
677 if (ASI1.IsDone() && ASI1.NbPoints(1) >=1) {
678 OrU = ASI1.Point(1,1).Orientation();
680 OrU = TopAbs::Reverse(OrU);
682 FUntil = ASI1.Point(1,1).Face();
684 if (ASI2.IsDone() && ASI2.NbPoints(1) >=1) {
685 OrF = ASI2.Point(1,1).Orientation();
686 // if(sens==1) OrF = TopAbs::Reverse(OrF);
687 FFrom = ASI2.Point(1 ,1).Face();
688 Handle(Geom_Surface) S = BRep_Tool::Surface(FFrom);
689 if (S->DynamicType() ==
690 STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
691 S = Handle(Geom_RectangularTrimmedSurface)::
692 DownCast(S)->BasisSurface();
694 BRepLib_MakeFace fac(S, Precision::Confusion());
695 mySFrom = fac.Face();
696 Trf = TransformShapeFU(0);
697 FFrom = TopoDS::Face(mySFrom);
700 TopTools_ListOfShape aLTools;
701 TopoDS_Solid Sol = BRepFeat::Tool(mySUntil, FUntil, OrU);
707 myStatusError = BRepFeat_NullToolU;
711 TopoDS_Solid Sol1 = BRepFeat::Tool(mySFrom, FFrom, OrF);
712 if (!Sol1.IsNull()) {
713 aLTools.Append(Sol1);
717 myStatusError = BRepFeat_NullToolF;
721 TopTools_ListOfShape aLObj;
722 aLObj.Append(VraiPrism);
725 trP.SetArguments(aLObj);
726 trP.SetTools(aLTools);
729 UpdateDescendants(trP, trP.Shape(), Standard_False);
730 if(myFuse == 1 && !myJustFeat) {
731 BRepAlgoAPI_Fuse f(mySbase, trP.Shape());
733 UpdateDescendants(f, myShape, Standard_False);
736 else if(myFuse == 0) {
737 BRepAlgoAPI_Cut c(mySbase, trP.Shape());
739 UpdateDescendants(c, myShape, Standard_False);
743 myShape = trP.Shape();
749 //=======================================================================
750 //function : PerformThruAll
752 //=======================================================================
754 void BRepFeat_MakePrism::PerformThruAll()
757 Standard_Boolean trc = BRepFeat_GettraceFEAT();
758 if (trc) std::cout << "BRepFeat_MakePrism::PerformThruAll()" << std::endl;
765 myPerfSelection = BRepFeat_NoSelection;
768 myPerfSelection = BRepFeat_SelectionSh;
770 PerfSelectionValid();
774 Standard_Real Height = HeightMax(mySbase, mySkface, mySFrom, mySUntil);
775 gp_Vec V(3*Height*myDir);
776 gp_Vec Vtra(-3*Height/2.*myDir);
777 LocOpe_Prism thePrism(myPbase,V,Vtra);
778 TopoDS_Shape VraiPrism = thePrism.Shape();
779 MajMap(myPbase,thePrism,myMap,myFShape,myLShape);
781 myGShape = VraiPrism;
782 GeneratedShapeValid();
785 BRepAlgoAPI_Cut c(mySbase, myGShape);
788 UpdateDescendants(c, myShape, Standard_False);
793 thePrism.Curves(myCurves);
794 myBCurve = thePrism.BarycCurve();
799 //=======================================================================
800 //function : PerformUntilHauteur
802 //=======================================================================
804 void BRepFeat_MakePrism::PerformUntilHeight(const TopoDS_Shape& Until,
805 const Standard_Real Length)
808 Standard_Boolean trc = BRepFeat_GettraceFEAT();
809 if (trc) std::cout << "BRepFeat_MakePrism::PerformUntilHeight(Until,Length)" << std::endl;
811 if (Until.IsNull()) {
817 TopExp_Explorer exp(Until, TopAbs_FACE);
819 throw Standard_ConstructionError();
822 myPerfSelection = BRepFeat_NoSelection;
823 PerfSelectionValid();
827 Standard_Boolean Trf = TransformShapeFU(1);
829 Handle(Geom_Curve) C = TestCurve(myPbase,myDir);
830 Standard_Integer sens = SensOfPrism(C, mySUntil);
831 gp_Vec V(sens*Length*myDir);
832 LocOpe_Prism thePrism(myPbase,V);
833 TopoDS_Shape VraiPrism = thePrism.Shape();
836 MajMap(myPbase,thePrism,myMap,myFShape,myLShape);
838 myGShape = VraiPrism;
839 GeneratedShapeValid();
841 thePrism.Curves(myCurves);
842 myBCurve = thePrism.BarycCurve();
846 MajMap(myPbase,thePrism,myMap,myFShape,myLShape);
847 TColGeom_SequenceOfCurve scur;
850 LocOpe_CSIntersector ASI(mySUntil);
852 TopAbs_Orientation Or;
853 if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
855 Or = ASI.Point(1,1).Orientation();
858 Or = ASI.Point(1,ASI.NbPoints(1)).Orientation();
860 if(sens==-1) Or=TopAbs::Reverse(Or);
861 TopoDS_Face FUntil = ASI.Point(1,1).Face();
864 B.MakeCompound(TopoDS::Compound(Comp));
865 TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or);
866 if (!S.IsNull()) B.Add(Comp,S);
868 BRepAlgoAPI_Cut trP(VraiPrism,Comp);
869 UpdateDescendants(trP, trP.Shape(), Standard_False);
870 if(myFuse == 1 && !myJustFeat) {
871 BRepAlgoAPI_Fuse f(mySbase, trP.Shape());
873 UpdateDescendants(f, myShape, Standard_False);
876 else if(myFuse == 0) {
877 BRepAlgoAPI_Cut c(mySbase, trP.Shape());
879 UpdateDescendants(c, myShape, Standard_False);
883 myShape = trP.Shape();
890 //=======================================================================
892 //purpose : sequence of curves parallel to the axis of prism
893 //=======================================================================
895 void BRepFeat_MakePrism::Curves(TColGeom_SequenceOfCurve& scur)
900 //=======================================================================
901 //function : BarycCurve
902 //purpose : curve parallel to the axis of the prism passing through the center
904 //=======================================================================
906 Handle(Geom_Curve) BRepFeat_MakePrism::BarycCurve()
912 //=======================================================================
913 //function : HeightMax
914 //purpose : Calculate the height of the prism following the parameters of
916 //=======================================================================
918 static Standard_Real HeightMax(const TopoDS_Shape& theSbase,
919 const TopoDS_Face& theSkface,
920 const TopoDS_Shape& theSFrom,
921 const TopoDS_Shape& theSUntil)
924 BRepBndLib::Add(theSbase,Box);
925 BRepBndLib::Add(theSkface,Box);
926 if(!theSFrom.IsNull()) {
927 Standard_Boolean FacRevolInfini = Standard_False;
929 exp.Init(theSFrom, TopAbs_EDGE);
930 for(; exp.More(); exp.Next()) {
931 TopExp_Explorer exp1;
932 exp1.Init(exp.Current(), TopAbs_VERTEX);
934 FacRevolInfini = Standard_True;
939 BRepBndLib::Add(theSFrom,Box);
941 if(!theSUntil.IsNull())
943 Standard_Boolean FacRevolInfini = Standard_False;
945 exp.Init(theSUntil, TopAbs_EDGE);
946 for(; exp.More(); exp.Next())
948 TopExp_Explorer exp1;
949 exp1.Init(exp.Current(), TopAbs_VERTEX);
952 FacRevolInfini = Standard_True;
957 BRepBndLib::Add(theSUntil,Box);
962 Box.Get(c[0],c[2],c[4],c[1],c[3],c[5]);
963 Standard_Real parmin=c[0], parmax = c[0];
964 for(Standard_Integer i = 0 ; i < 6; i++) {
965 if(c[i] > parmax) parmax = c[i];
966 if(c[i] < parmin ) parmin = c[i];
969 Standard_Real Height = fabs(2.*(parmax - parmin));
971 // Standard_Real Height = abs(2.*(parmax - parmin));
977 //=======================================================================
978 //function : SensOfPrism
979 //purpose : Direction of the prism depending on the shape Until
980 //=======================================================================
981 Standard_Integer SensOfPrism(const Handle(Geom_Curve) C,
982 const TopoDS_Shape& Until)
984 LocOpe_CSIntersector ASI1(Until);
985 TColGeom_SequenceOfCurve scur;
988 Standard_Integer sens = 1;
989 if(ASI1.IsDone() && ASI1.NbPoints(1) >= 1) {
990 if(ASI1.Point(1, 1).Parameter() < 0. &&
991 ASI1.Point(1, ASI1.NbPoints(1)).Parameter() < 0.) {
995 else if(BRepFeat::ParametricBarycenter(Until,C) < 0) {
1002 //=======================================================================
1004 //purpose : management of descendants
1005 //=======================================================================
1007 static void MajMap(const TopoDS_Shape& theB,
1008 const LocOpe_Prism& theP,
1009 TopTools_DataMapOfShapeListOfShape& theMap, // myMap
1010 TopoDS_Shape& theFShape, // myFShape
1011 TopoDS_Shape& theLShape) // myLShape
1013 TopExp_Explorer exp(theP.FirstShape(),TopAbs_WIRE);
1015 theFShape = exp.Current();
1016 TopTools_ListOfShape thelist2;
1017 theMap.Bind(theFShape, thelist2);
1018 for (exp.Init(theP.FirstShape(),TopAbs_FACE);exp.More();exp.Next()) {
1019 theMap(theFShape).Append(exp.Current());
1023 exp.Init(theP.LastShape(),TopAbs_WIRE);
1025 theLShape = exp.Current();
1026 TopTools_ListOfShape thelist3;
1027 theMap.Bind(theLShape, thelist3);
1028 for (exp.Init(theP.LastShape(),TopAbs_FACE);exp.More();exp.Next()) {
1029 theMap(theLShape).Append(exp.Current());
1033 for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) {
1034 if (!theMap.IsBound(exp.Current())) {
1035 TopTools_ListOfShape thelist4;
1036 theMap.Bind(exp.Current(), thelist4);
1037 theMap(exp.Current()) = theP.Shapes(exp.Current());
1043 //=======================================================================
1045 //purpose : management of descendants
1046 //=======================================================================
1048 static Handle(Geom_Curve) TestCurve(const TopoDS_Shape& Base,
1051 gp_Pnt bar(0., 0., 0.);
1052 TColgp_SequenceOfPnt spt;
1053 LocOpe::SampleEdges(Base,spt);
1054 for (Standard_Integer jj=1;jj<=spt.Length(); jj++) {
1055 const gp_Pnt& pvt = spt(jj);
1056 bar.ChangeCoord() += pvt.XYZ();
1058 bar.ChangeCoord().Divide(spt.Length());
1059 gp_Ax1 newAx(bar,V);
1060 Handle(Geom_Line) theLin = new Geom_Line(newAx);
1067 //=======================================================================
1069 //purpose : face SameDomaine or not
1070 //=======================================================================
1072 static Standard_Boolean ToFuse (const TopoDS_Face& F1, const TopoDS_Face& F2)
1074 if (F1.IsNull() || F2.IsNull()) {
1075 return Standard_False;
1078 Handle(Geom_Surface) S1,S2;
1079 TopLoc_Location loc1, loc2;
1080 Handle(Standard_Type) typS1,typS2;
1081 const Standard_Real tollin = Precision::Confusion();
1082 const Standard_Real tolang = Precision::Angular();
1084 S1 = BRep_Tool::Surface(F1,loc1);
1085 S2 = BRep_Tool::Surface(F2,loc2);
1087 typS1 = S1->DynamicType();
1088 typS2 = S2->DynamicType();
1090 if (typS1 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
1091 S1 = Handle(Geom_RectangularTrimmedSurface)::DownCast (S1)->BasisSurface();
1092 typS1 = S1->DynamicType();
1095 if (typS2 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
1096 S2 = Handle(Geom_RectangularTrimmedSurface)::DownCast (S2)->BasisSurface();
1097 typS2 = S2->DynamicType();
1100 if (typS1 != typS2) {
1101 return Standard_False;
1105 Standard_Boolean ValRet = Standard_False;
1106 if (typS1 == STANDARD_TYPE(Geom_Plane)) {
1107 gp_Pln pl1( Handle(Geom_Plane)::DownCast (S1)->Pln());
1108 gp_Pln pl2( Handle(Geom_Plane)::DownCast (S2)->Pln());
1111 if (! loc1.IsIdentity())
1112 pl1.Transform (loc1.Transformation());
1113 if (! loc2.IsIdentity())
1114 pl2.Transform (loc2.Transformation());
1116 if (pl1.Position().IsCoplanar(pl2.Position(),tollin,tolang)) {
1117 ValRet = Standard_True;