1 // Created on: 1996-09-03
2 // Created by: Olga KOULECHOVA
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_MakeDPrism.ixx>
25 #include <BRepFeat.hxx>
27 #include <LocOpe_CSIntersector.hxx>
28 #include <TColGeom_SequenceOfCurve.hxx>
29 #include <LocOpe_DPrism.hxx>
30 #include <LocOpe_SequenceOfLin.hxx>
31 #include <LocOpe_PntFace.hxx>
35 #include <gp_Pnt2d.hxx>
38 #include <Precision.hxx>
40 #include <Geom_Surface.hxx>
41 #include <Geom_Curve.hxx>
42 #include <Geom_Line.hxx>
43 #include <Geom2d_Curve.hxx>
44 #include <Geom_Plane.hxx>
45 #include <Geom_RectangularTrimmedSurface.hxx>
46 #include <TColgp_SequenceOfPnt.hxx>
47 #include <TColGeom_SequenceOfCurve.hxx>
48 #include <Bnd_Box.hxx>
50 #include <BRepBndLib.hxx>
51 #include <BRep_Builder.hxx>
52 #include <BRep_Tool.hxx>
53 #include <BRepTools.hxx>
54 #include <BRepPrimAPI_MakeBox.hxx>
55 #include <BRepLib.hxx>
57 #include <BRepAlgo.hxx>
58 //modified by NIZNHY-PKV Thu Mar 21 17:49:46 2002 f
59 //#include <BRepAlgo_Cut.hxx>
60 //#include <BRepAlgo_Fuse.hxx>
61 #include <BRepAlgoAPI_Cut.hxx>
62 #include <BRepAlgoAPI_Fuse.hxx>
63 //modified by NIZNHY-PKV Thu Mar 21 17:50:04 2002 t
65 #include <BRepLib_MakeFace.hxx>
67 #include <TopExp_Explorer.hxx>
68 #include <TopTools_MapOfShape.hxx>
69 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
70 #include <TopTools_ListIteratorOfListOfShape.hxx>
71 #include <TopTools_MapIteratorOfMapOfShape.hxx>
72 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
73 #include <TopoDS_Solid.hxx>
74 #include <TopoDS_Compound.hxx>
75 #include <TopoDS_Shell.hxx>
76 #include <TopoDS_Shape.hxx>
77 #include <TopoDS_Face.hxx>
80 #include <Standard_ConstructionError.hxx>
84 #include <BRepFeat.hxx>
88 Standard_IMPORT Standard_Boolean BRepFeat_GettraceFEAT();
91 static void MajMap(const TopoDS_Shape&,
93 TopTools_DataMapOfShapeListOfShape&, // myMap
94 TopoDS_Shape&, // myFShape
95 TopoDS_Shape&); // myLShape
98 static void SetGluedFaces(const TopoDS_Face& theSkface,
99 const TopoDS_Shape& theSbase,
100 const TopoDS_Shape& thePbase,
101 const TopTools_DataMapOfShapeListOfShape& theSlmap,
103 TopTools_DataMapOfShapeShape&);
106 static void VerifGluedFaces(const TopoDS_Face& theSkface,
107 const TopoDS_Shape& thePbase,
108 Handle(Geom_Curve)& theBCurve,
109 TColGeom_SequenceOfCurve& theCurves,
110 LocOpe_DPrism& theDPrism,
111 TopTools_DataMapOfShapeShape& theMap);
114 static Standard_Real HeightMax(const TopoDS_Shape& theSbase,
115 const TopoDS_Face& theSkface,
116 const TopoDS_Shape& theSFrom,
117 const TopoDS_Shape& theSUntil);
119 static Standard_Integer SensOfPrism(const Handle(Geom_Curve) C,
120 const TopoDS_Shape& Until);
122 static Handle(Geom_Curve) TestCurve(const TopoDS_Face&);
124 static Standard_Boolean ToFuse(const TopoDS_Face& ,
129 //=======================================================================
132 //=======================================================================
134 void BRepFeat_MakeDPrism::Init(const TopoDS_Shape& Sbase,
135 const TopoDS_Face& Pbase,
136 const TopoDS_Face& Skface,
137 const Standard_Real Angle,
138 const Standard_Integer Mode,
139 const Standard_Boolean Modify)
143 Standard_Boolean trc = BRepFeat_GettraceFEAT();
144 if (trc) cout << "BRepFeat_MakeDPrism::Init" << endl;
153 myFuse = Standard_False;
154 myJustFeat = Standard_False;
157 myFuse = Standard_True;
158 myJustFeat = Standard_False;
161 myFuse = Standard_True;
162 myJustFeat = Standard_True;
167 myJustGluer = Standard_False;
171 //mySkface.Nullify();
181 for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
182 TopTools_ListOfShape thelist;
183 myMap.Bind(exp.Current(), thelist);
184 myMap(exp.Current()).Append(exp.Current());
189 if (myJustFeat) cout << " Just Feature" << endl;
190 if (myFuse) cout << " Fuse" << endl;
191 if (!myFuse) cout << " Cut" << endl;
192 if (!myModify) cout << " Modify = 0" << endl;
193 // cout <<" Angle = " << myAngle << endl;
199 //=======================================================================
201 //purpose : add sliding faces and edges
202 //=======================================================================
204 void BRepFeat_MakeDPrism::Add(const TopoDS_Edge& E,
205 const TopoDS_Face& F)
208 Standard_Boolean trc = BRepFeat_GettraceFEAT();
209 if (trc) cout << "BRepFeat_MakeDPrism::Add(Edge,face)" << endl;
212 for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
213 if (exp.Current().IsSame(F)) {
218 Standard_ConstructionError::Raise();
221 for (exp.Init(myPbase,TopAbs_EDGE);exp.More();exp.Next()) {
222 if (exp.Current().IsSame(E)) {
227 Standard_ConstructionError::Raise();
230 if (!mySlface.IsBound(F)) {
231 TopTools_ListOfShape thelist;
232 mySlface.Bind(F, thelist);
234 TopTools_ListIteratorOfListOfShape itl(mySlface(F));
235 for (; itl.More();itl.Next()) {
236 if (itl.Value().IsSame(E)) {
241 mySlface(F).Append(E);
246 //=======================================================================
248 //purpose : feature of Height
249 //=======================================================================
251 void BRepFeat_MakeDPrism::Perform(const Standard_Real Height)
254 Standard_Boolean trc = BRepFeat_GettraceFEAT();
255 if (trc) cout << "BRepFeat_MakeDPrism::Perform(Height)" << endl;
262 myPerfSelection = BRepFeat_NoSelection;
263 PerfSelectionValid();
265 Standard_Real theheight = Height/cos(myAngle);
266 // myPbase.Orientation(TopAbs_FORWARD);
268 LocOpe_DPrism theDPrism(myPbase,theheight,myAngle);
269 TopoDS_Shape VraiDPrism = theDPrism.Shape();
271 MajMap(myPbase,theDPrism,myMap,myFShape,myLShape);
273 myGShape = VraiDPrism;
274 GeneratedShapeValid();
275 TopoDS_Shape Base = theDPrism.FirstShape();
276 TopExp_Explorer exp(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(VraiDPrism, 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 //SetGluedFaces(ff, mySbase, FFace, sl, theDPrism, myGluedF);
316 // management of gluing faces
318 //SetGluedFaces(mySkface, mySbase, theBase, mySlface, theDPrism, myGluedF);
320 // VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theDPrism, myGluedF);
322 if(!myGluedF.IsEmpty()) { // case gluing
323 myJustGluer = Standard_True;
324 theDPrism.Curves(myCurves);
325 myBCurve = theDPrism.BarycCurve();
329 // if there is no gluing -> call topological operations
332 //modified by NIZNHY-PKV Thu Mar 21 17:32:17 2002 f
333 //BRepAlgo_Fuse f(mySbase, myGShape);
334 //myShape = f.Shape();
335 //UpdateDescendants(f.Builder(), myShape, Standard_False);
336 BRepAlgoAPI_Fuse f(mySbase, myGShape);
338 UpdateDescendants(f, myShape, Standard_False);
339 //modified by NIZNHY-PKV Thu Mar 21 17:32:23 2002 t
342 else if(myFuse == 0) {
343 //modified by NIZNHY-PKV Thu Mar 21 17:32:57 2002 f
344 //BRepAlgo_Cut c(mySbase, myGShape);
345 //myShape = c.Shape();
346 //UpdateDescendants(c.Builder(), myShape, Standard_False);
347 BRepAlgoAPI_Cut c(mySbase, myGShape);
349 UpdateDescendants(c, myShape, Standard_False);
350 //modified by NIZNHY-PKV Thu Mar 21 17:33:00 2002 t
360 //=======================================================================
362 //purpose : feature limited by the shape Until
363 //=======================================================================
365 void BRepFeat_MakeDPrism::Perform(const TopoDS_Shape& Until)
368 Standard_Boolean trc = BRepFeat_GettraceFEAT();
369 if (trc) cout << "BRepFeat_MakeDPrism::Perform(Until)" << endl;
371 if (Until.IsNull()) {
372 Standard_ConstructionError::Raise();
374 TopExp_Explorer exp(Until, TopAbs_FACE);
376 Standard_ConstructionError::Raise();
378 // myPbase.Orientation(TopAbs_FORWARD);
381 myPerfSelection = BRepFeat_SelectionU;
382 PerfSelectionValid();
386 Standard_Boolean Trf = TransformShapeFU(1);
388 Handle(Geom_Curve) C = TestCurve(myPbase);
389 Standard_Integer sens = SensOfPrism(C, mySUntil);
392 Standard_Real Height =
393 sens*HeightMax(mySbase, mySkface, mySFrom, mySUntil);
394 LocOpe_DPrism theDPrism(myPbase,Height,myAngle);
395 TopoDS_Shape VraiDPrism = theDPrism.Shape();
397 MajMap(myPbase,theDPrism,myMap,myFShape,myLShape);
398 myGShape = VraiDPrism;
399 GeneratedShapeValid();
400 TopoDS_Shape Base = theDPrism.FirstShape();
401 exp.Init(Base, TopAbs_FACE);
402 TopoDS_Face theBase = TopoDS::Face(exp.Current());
406 myStatusError = BRepFeat_InvFirstShape;
410 //SetGluedFaces(mySkface, mySbase, theBase, mySlface, theDPrism, myGluedF);
412 // VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theDPrism, myGluedF);
415 theDPrism.Curves(myCurves);
416 myBCurve = theDPrism.BarycCurve();
420 MajMap(myPbase,theDPrism,myMap,myFShape,myLShape);
421 Handle(Geom_Curve) C1;
429 TColGeom_SequenceOfCurve scur;
432 LocOpe_CSIntersector ASI(mySUntil);
434 TopAbs_Orientation Or;
435 if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
437 Or = ASI.Point(1,1).Orientation();
440 Or = ASI.Point(1,ASI.NbPoints(1)).Orientation();
442 // Standard_Real prm = ASI.Point(1,1).Parameter();
443 // if(prm < 0) Or = TopAbs::Reverse(Or);
444 TopoDS_Face FUntil = ASI.Point(1,1).Face();
446 bB.MakeCompound(TopoDS::Compound(Comp));
447 TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or);
448 if (!S.IsNull()) bB.Add(Comp,S);
450 //modified by NIZNHY-PKV Thu Mar 21 17:33:27 2002
451 //BRepAlgo_Cut trP(VraiDPrism,Comp);
452 //UpdateDescendants(trP.Builder(),trP.Shape(), Standard_False);
453 BRepAlgoAPI_Cut trP(VraiDPrism,Comp);
454 UpdateDescendants(trP, trP.Shape(), Standard_False);
455 //modified by NIZNHY-PKV Thu Mar 21 17:33:32 2002 t
457 TopExp_Explorer ex(trP.Shape(), TopAbs_SOLID);
458 TopoDS_Shape Cutsh = ex.Current();
460 //modified by NIZNHY-PKV Thu Mar 21 17:34:09 2002 f
461 //BRepAlgo_Fuse f(mySbase, Cutsh);
462 //myShape = f.Shape();
463 //UpdateDescendants(f.Builder(), myShape, Standard_False);
464 BRepAlgoAPI_Fuse f(mySbase, Cutsh);
466 UpdateDescendants(f, myShape, Standard_False);
467 //modified by NIZNHY-PKV Thu Mar 21 17:34:13 2002 t
470 else if(myFuse == 0) {
471 //modified by NIZNHY-PKV Thu Mar 21 17:34:56 2002 f
472 //BRepAlgo_Cut c(mySbase, Cutsh);
473 //myShape = c.Shape();
474 //UpdateDescendants(c.Builder(), myShape, Standard_False);
475 BRepAlgoAPI_Cut c(mySbase, Cutsh);
477 UpdateDescendants(c, myShape, Standard_False);
478 //modified by NIZNHY-PKV Thu Mar 21 17:34:59 2002 t
487 TopTools_ListIteratorOfListOfShape ited(myNewEdges);
488 for (; ited.More();ited.Next()) {
489 const TopoDS_Edge& ledg=TopoDS::Edge(ited.Value());
490 if (!BRepAlgo::IsValid(ledg)) {
491 bB.SameRange(ledg, Standard_False);
492 bB.SameParameter(ledg, Standard_False);
493 BRepLib::SameParameter(ledg, BRep_Tool::Tolerance(ledg));
499 //=======================================================================
501 //purpose : feature limited by two shapes
502 //=======================================================================
504 void BRepFeat_MakeDPrism::Perform(const TopoDS_Shape& From,
505 const TopoDS_Shape& Until)
508 Standard_Boolean trc = BRepFeat_GettraceFEAT();
509 if (trc) cout << "BRepFeat_MakeDPrism::Perform(From,Until)" << endl;
511 if (From.IsNull() || Until.IsNull()) {
512 Standard_ConstructionError::Raise();
515 if (!mySkface.IsNull()) {
516 if (From.IsSame(mySkface)) {
517 myJustGluer = Standard_True;
519 if (myJustGluer) return;
521 else if (Until.IsSame(mySkface)) {
522 myJustGluer = Standard_True;
524 if (myJustGluer) return;
527 // myPbase.Orientation(TopAbs_FORWARD);
530 myPerfSelection = BRepFeat_SelectionFU;
531 PerfSelectionValid();
533 TopExp_Explorer exp(From, TopAbs_FACE);
535 Standard_ConstructionError::Raise();
537 exp.Init(Until, TopAbs_FACE);
539 Standard_ConstructionError::Raise();
542 Standard_Boolean Trff = TransformShapeFU(0);
545 Standard_Boolean Trfu = TransformShapeFU(1);
549 myStatusError = BRepFeat_IncTypes;
552 Handle(Geom_Curve) C = TestCurve(myPbase);
553 Standard_Integer sens;
554 if(From.IsSame(Until)) {
558 sens = SensOfPrism(C, mySUntil);
561 Standard_Real Height =
562 sens*HeightMax(mySbase, myPbase, mySFrom, mySUntil);
563 LocOpe_DPrism theDPrism(myPbase, Height, Height, myAngle);
564 TopoDS_Shape VraiDPrism = theDPrism.Shape();
568 MajMap(myPbase,theDPrism,myMap,myFShape,myLShape);
570 // Make systematically dprism
571 myGShape = VraiDPrism;
572 GeneratedShapeValid();
574 // management of gluing faces
575 //SetGluedFaces(TopoDS_Face(), // on ne veut pas binder mySkface
576 // mySbase, myPbase, mySlface, theDPrism, myGluedF);
578 theDPrism.Curves(myCurves);
579 myBCurve = theDPrism.BarycCurve();
581 // topologic reconstruction
585 // management of descendants
586 MajMap(myPbase,theDPrism,myMap,myFShape,myLShape);
587 Handle(Geom_Curve) C1;
594 TColGeom_SequenceOfCurve scur;
597 LocOpe_CSIntersector ASI1(mySUntil);
598 LocOpe_CSIntersector ASI2(mySFrom);
601 TopAbs_Orientation OrU, OrF;
602 TopoDS_Face FFrom, FUntil;
603 //direction of dprism
604 if (ASI1.IsDone() && ASI1.NbPoints(1) >=1) {
606 OrU = ASI1.Point(1,1).Orientation();
609 OrU = ASI1.Point(1,ASI1.NbPoints(1)).Orientation();
611 // Standard_Real prm = ASI1.Point(1,1).Parameter();
612 // if(prm < 0) OrU = TopAbs::Reverse(OrU);
613 FUntil = ASI1.Point(1,1).Face();
617 myStatusError = BRepFeat_NoIntersectU;
620 if (ASI2.IsDone() && ASI2.NbPoints(1) >=1) {
621 OrF = ASI2.Point(1,1).Orientation();
622 // Standard_Real prm = ASI2.Point(1,1).Parameter();
623 OrF = TopAbs::Reverse(OrF);
624 FFrom = ASI2.Point(1,1).Face();
628 myStatusError = BRepFeat_NoIntersectF;
633 B.MakeCompound(TopoDS::Compound(Comp));
634 TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, OrU);
635 if (!S.IsNull()) B.Add(Comp,S);
638 myStatusError = BRepFeat_NullToolU;
641 TopoDS_Solid SS = BRepFeat::Tool(mySFrom, FFrom, OrF);
642 if (!SS.IsNull()) B.Add(Comp,SS);
645 myStatusError = BRepFeat_NullToolF;
649 //modified by NIZNHY-PKV Thu Mar 21 17:35:48 2002 f
650 //BRepAlgo_Cut trP(VraiDPrism,Comp);
651 BRepAlgoAPI_Cut trP(VraiDPrism,Comp);
652 //modified by NIZNHY-PKV Thu Mar 21 17:35:59 2002 t
655 //modified by NIZNHY-PKV Thu Mar 21 17:36:06 2002 f
656 //BRepAlgo_Fuse f(mySbase, trP.Shape());
657 //myShape = f.Shape();
658 //UpdateDescendants(f.Builder(), myShape, Standard_False);
659 BRepAlgoAPI_Fuse f(mySbase, trP.Shape());
661 UpdateDescendants(f, myShape, Standard_False);
662 //modified by NIZNHY-PKV Thu Mar 21 17:36:33 2002 t
666 else if(myFuse == 0) {
667 //modified by NIZNHY-PKV Thu Mar 21 17:37:16 2002 f
668 //BRepAlgo_Cut c(mySbase, trP.Shape());
669 //myShape = c.Shape();
670 //UpdateDescendants(c.Builder(), myShape, Standard_False);
671 BRepAlgoAPI_Cut c(mySbase, trP.Shape());
673 UpdateDescendants(c, myShape, Standard_False);
674 //modified by NIZNHY-PKV Thu Mar 21 17:37:49 2002 t
678 myShape = trP.Shape();
685 //=======================================================================
687 //purpose : feature semi-infinie
688 //=======================================================================
690 void BRepFeat_MakeDPrism::PerformUntilEnd()
693 Standard_Boolean trc = BRepFeat_GettraceFEAT();
694 if (trc) cout << "BRepFeat_MakeDPrism::PerformUntilEnd()" << endl;
696 myPerfSelection = BRepFeat_SelectionSh;
697 PerfSelectionValid();
703 Standard_Real Height = HeightMax(mySbase, mySkface, mySFrom, mySUntil);
704 // myPbase.Orientation(TopAbs_FORWARD);
706 LocOpe_DPrism theDPrism(myPbase, Height, myAngle);
707 TopoDS_Shape VraiDPrism = theDPrism.Shape();
709 MajMap(myPbase,theDPrism,myMap,myFShape,myLShape);
711 myGShape = VraiDPrism;
712 GeneratedShapeValid();
714 theDPrism.Curves(myCurves);
715 myBCurve = theDPrism.BarycCurve();
719 //=======================================================================
720 //function : PerformFromEnd
721 //purpose : feature semiinfinite limited by the shape Until from the other side
722 //=======================================================================
724 void BRepFeat_MakeDPrism::PerformFromEnd(const TopoDS_Shape& Until)
727 Standard_Boolean trc = BRepFeat_GettraceFEAT();
728 if (trc) cout << "BRepFeat_MakeDPrism::PerformFromEnd(From,Until)" << endl;
730 if (Until.IsNull()) {
731 Standard_ConstructionError::Raise();
733 if (!mySkface.IsNull() && Until.IsSame(mySkface)) {
738 exp.Init(Until, TopAbs_FACE);
740 Standard_ConstructionError::Raise();
742 // myPbase.Orientation(TopAbs_FORWARD);
743 myPerfSelection = BRepFeat_SelectionShU;
744 PerfSelectionValid();
748 Standard_Boolean Trf = TransformShapeFU(1);
750 Handle(Geom_Curve) C = TestCurve(myPbase);
751 Standard_Integer sens = SensOfPrism(C, mySUntil);
752 Standard_Real Height =
753 sens*HeightMax(mySbase, mySkface, mySFrom, mySUntil);
755 LocOpe_DPrism theDPrism(myPbase, Height, Height, myAngle);
756 TopoDS_Shape VraiDPrism = theDPrism.Shape();
757 if(VraiDPrism.IsNull()) {
759 myStatusError = BRepFeat_NullRealTool;
763 if(!Trf) { // case finite face
764 MajMap(myPbase,theDPrism,myMap,myFShape,myLShape);
765 myGShape = VraiDPrism;
766 GeneratedShapeValid();
769 theDPrism.Curves(myCurves);
770 myBCurve = theDPrism.BarycCurve();
773 else { // case support
774 MajMap(myPbase,theDPrism,myMap,myFShape,myLShape);
775 Handle(Geom_Curve) C2;
782 TColGeom_SequenceOfCurve scur;
785 LocOpe_CSIntersector ASI1(mySUntil);
786 LocOpe_CSIntersector ASI2(mySbase);
790 TopAbs_Orientation OrU = TopAbs_FORWARD, OrF = TopAbs_FORWARD;
792 TopAbs_Orientation OrU, OrF;
794 TopoDS_Face FUntil, FFrom;
795 if (ASI1.IsDone() && ASI1.NbPoints(1) >=1) {
796 OrU = ASI1.Point(1,1).Orientation();
797 Standard_Real prm = ASI1.Point(1,1).Parameter();
798 if(prm < 0) OrU = TopAbs::Reverse(OrU);
799 FUntil = ASI1.Point(1,1).Face();
802 if (ASI2.IsDone() && ASI2.NbPoints(1) >=1) {
803 Standard_Integer jj = ASI2.NbPoints(1);
804 Standard_Real prm = ASI2.Point(1,1).Parameter();
805 FFrom = ASI2.Point(1, 1).Face();
806 OrF = ASI2.Point(1,1).Orientation();
807 OrF = TopAbs::Reverse(OrF);
808 for(Standard_Integer iii = 1; iii <= jj; iii++) {
809 if(ASI2.Point(1,iii).Parameter() < prm) {
810 prm = ASI2.Point(1,iii).Parameter();
811 FFrom = ASI2.Point(1, iii).Face();
812 OrF = ASI2.Point(1,iii).Orientation();
813 OrF = TopAbs::Reverse(OrF);
816 Handle(Geom_Surface) S = BRep_Tool::Surface(FFrom);
817 if (S->DynamicType() ==
818 STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
819 S = Handle(Geom_RectangularTrimmedSurface)::
820 DownCast(S)->BasisSurface();
822 BRepLib_MakeFace fac(S, Precision::Confusion());
823 mySFrom = fac.Face();
824 Trf = TransformShapeFU(0);
825 // FFrom = TopoDS::Face(mySFrom);
830 B.MakeCompound(TopoDS::Compound(Comp));
831 TopoDS_Solid Sol = BRepFeat::Tool(mySUntil, FUntil, OrU);
832 if (!Sol.IsNull()) B.Add(Comp,Sol);
835 myStatusError = BRepFeat_NullToolU;
839 TopoDS_Solid Sol1 = BRepFeat::Tool(mySFrom, FFrom, OrF);
840 if (!Sol1.IsNull()) B.Add(Comp,Sol1);
843 myStatusError = BRepFeat_NullToolF;
847 //modified by NIZNHY-PKV Thu Mar 21 17:38:33 2002 f
848 //BRepAlgo_Cut trP(VraiDPrism,Comp);
849 BRepAlgoAPI_Cut trP(VraiDPrism,Comp);
850 //modified by NIZNHY-PKV Thu Mar 21 17:38:37 2002 t
852 //modified by NIZNHY-PKV Thu Mar 21 17:40:03 2002 f
853 //BRepAlgo_Fuse f(mySbase, trP.Shape());
854 //myShape = f.Shape();
855 //UpdateDescendants(f.Builder(), myShape, Standard_False);
856 BRepAlgoAPI_Fuse f(mySbase, trP.Shape());
858 UpdateDescendants(f, myShape, Standard_False);
859 //modified by NIZNHY-PKV Thu Mar 21 17:40:07 2002 t
862 else if(myFuse == 0) {
863 //modified by NIZNHY-PKV Thu Mar 21 17:40:33 2002 t
864 //BRepAlgo_Cut c(mySbase, trP.Shape());
865 //myShape = c.Shape();
866 //UpdateDescendants(c.Builder(), myShape, Standard_False);
867 BRepAlgoAPI_Cut c(mySbase, trP.Shape());
869 UpdateDescendants(c, myShape, Standard_False);
870 //modified by NIZNHY-PKV Thu Mar 21 17:40:44 2002 t
874 myShape = trP.Shape();
882 //=======================================================================
883 //function : PerformThruAll
884 //purpose : feature throughout the entire initial shape
885 //=======================================================================
887 void BRepFeat_MakeDPrism::PerformThruAll()
890 Standard_Boolean trc = BRepFeat_GettraceFEAT();
891 if (trc) cout << "BRepFeat_MakeDPrism::PerformThruAll()" << endl;
898 myPerfSelection = BRepFeat_NoSelection;
901 myPerfSelection = BRepFeat_SelectionSh;
904 PerfSelectionValid();
905 // myPbase.Orientation(TopAbs_FORWARD);
909 Standard_Real Height = HeightMax(mySbase, mySkface, mySFrom, mySUntil);
910 LocOpe_DPrism theDPrism(myPbase, Height, Height, myAngle);
911 TopoDS_Shape VraiDPrism = theDPrism.Shape();
912 MajMap(myPbase,theDPrism,myMap,myFShape,myLShape);
914 myGShape = VraiDPrism;
915 GeneratedShapeValid();
918 //modified by NIZNHY-PKV Thu Mar 21 17:46:16 2002 f
919 //BRepAlgo_Cut c(mySbase, myGShape);
920 BRepAlgoAPI_Cut c(mySbase, myGShape);
921 //modified by NIZNHY-PKV Thu Mar 21 17:46:26 2002 t
924 //modified by NIZNHY-PKV Thu Mar 21 17:46:39 2002 f
925 //UpdateDescendants(c.Builder(), myShape, Standard_False);
926 UpdateDescendants(c, myShape, Standard_False);
927 //modified by NIZNHY-PKV Thu Mar 21 17:46:43 2002 t
932 theDPrism.Curves(myCurves);
933 myBCurve = theDPrism.BarycCurve();
939 //=======================================================================
940 //function : PerformUntilHeight
941 //purpose : feature until the shape is of the given height
942 //=======================================================================
944 void BRepFeat_MakeDPrism::PerformUntilHeight(const TopoDS_Shape& Until,
945 const Standard_Real Height)
948 Standard_Boolean trc = BRepFeat_GettraceFEAT();
949 if (trc) cout << "BRepFeat_MakeDPrism::PerformUntilHeight(Until,Height)" << endl;
951 if (Until.IsNull()) {
957 TopExp_Explorer exp(Until, TopAbs_FACE);
959 Standard_ConstructionError::Raise();
961 // myPbase.Orientation(TopAbs_FORWARD);
963 myPerfSelection = BRepFeat_NoSelection;
964 PerfSelectionValid();
968 Standard_Boolean Trf = TransformShapeFU(1);
970 Handle(Geom_Curve) C = TestCurve(myPbase);
971 Standard_Integer sens = SensOfPrism(C, mySUntil);
973 LocOpe_DPrism theDPrism(myPbase,sens*Height,myAngle);
974 TopoDS_Shape VraiDPrism = theDPrism.Shape();
976 if(!Trf) { // case face finished
977 MajMap(myPbase,theDPrism,myMap,myFShape,myLShape);
978 myGShape = VraiDPrism;
979 GeneratedShapeValid();
980 TopoDS_Shape Base = theDPrism.FirstShape();
981 exp.Init(Base, TopAbs_FACE);
982 TopoDS_Face theBase = TopoDS::Face(exp.Current());
986 myStatusError = BRepFeat_InvFirstShape;
990 //SetGluedFaces(mySkface, mySbase, theBase, mySlface, theDPrism, myGluedF);
992 // VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theDPrism, myGluedF);
994 theDPrism.Curves(myCurves);
995 myBCurve = theDPrism.BarycCurve();
998 else { // case support
999 MajMap(myPbase,theDPrism,myMap,myFShape,myLShape);
1000 Handle(Geom_Curve) C1;
1007 TColGeom_SequenceOfCurve scur;
1010 LocOpe_CSIntersector ASI(mySUntil);
1012 TopAbs_Orientation Or;
1013 if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
1015 Or = ASI.Point(1,1).Orientation();
1018 Or = ASI.Point(1,ASI.NbPoints(1)).Orientation();
1020 // Standard_Real prm = ASI.Point(1,1).Parameter();
1021 // if(prm < 0) Or = TopAbs::Reverse(Or);
1022 TopoDS_Face FUntil = ASI.Point(1,1).Face();
1025 B.MakeCompound(TopoDS::Compound(Comp));
1026 TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or);
1027 if (!S.IsNull()) B.Add(Comp,S);
1028 //modified by NIZNHY-PKV Thu Mar 21 17:47:14 2002 f
1029 //BRepAlgo_Cut trP(VraiDPrism,Comp);
1030 BRepAlgoAPI_Cut trP(VraiDPrism,Comp);
1031 //modified by NIZNHY-PKV Thu Mar 21 17:47:21 2002 t
1033 //modified by NIZNHY-PKV Thu Mar 21 17:47:42 2002 f
1034 //BRepAlgo_Fuse f(mySbase, trP.Shape());
1035 //myShape = f.Shape();
1036 //UpdateDescendants(f.Builder(), myShape, Standard_False);
1037 BRepAlgoAPI_Fuse f(mySbase, trP.Shape());
1038 myShape = f.Shape();
1039 UpdateDescendants(f, myShape, Standard_False);
1040 //modified by NIZNHY-PKV Thu Mar 21 17:47:49 2002 t
1043 else if(myFuse == 0) {
1044 //modified by NIZNHY-PKV Thu Mar 21 17:48:18 2002 f
1045 //BRepAlgo_Cut c(mySbase, trP.Shape());
1046 //myShape = c.Shape();
1047 //UpdateDescendants(c.Builder(), myShape, Standard_False);
1048 BRepAlgoAPI_Cut c(mySbase, trP.Shape());
1049 myShape = c.Shape();
1050 UpdateDescendants(c, myShape, Standard_False);
1051 //modified by NIZNHY-PKV Thu Mar 21 17:48:26 2002 t
1055 myShape = trP.Shape();
1063 //=======================================================================
1065 //purpose : curves parallel to the axis of the prism
1066 //=======================================================================
1068 void BRepFeat_MakeDPrism::Curves(TColGeom_SequenceOfCurve& scur)
1073 //============================================================================
1074 // function : BRepFeat_BossEgdes
1075 // purpose: Determination of TopEdges and LatEdges.
1076 // sig = 1 -> TopEdges = FirstShape of the DPrism
1077 // sig = 2 -> TOpEdges = LastShape of the DPrism
1078 //============================================================================
1079 void BRepFeat_MakeDPrism::BossEdges (const Standard_Integer signature)
1082 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1083 if (trc) cout << "BRepFeat_MakeDPrism::BossEdges (integer)" << endl;
1085 TopTools_ListOfShape theLastShape;
1086 theLastShape.Clear();
1087 if (signature == 1 || signature == -1) {
1088 theLastShape = FirstShape();
1090 else if (signature == 2 || signature == -2) {
1091 theLastShape = LastShape();
1098 TopTools_ListIteratorOfListOfShape itLS;
1099 TopExp_Explorer ExpE;
1100 for (itLS.Initialize(theLastShape);itLS.More();itLS.Next()) {
1101 const TopoDS_Face& FF = TopoDS::Face(itLS.Value());
1102 for (ExpE.Init(FF,TopAbs_EDGE);ExpE.More();ExpE.Next()) {
1103 const TopoDS_Edge& EE = TopoDS::Edge(ExpE.Current());
1104 myTopEdges.Append(EE);
1109 if (signature < 0) {
1110 // Attention check if TgtEdges is important
1111 myLatEdges = NewEdges();
1113 else if (signature > 0) {
1114 if ( !myShape.IsNull() ) {
1115 TopTools_MapOfShape MapE;
1116 Standard_Boolean Found;
1118 TopExp_Explorer ExpF;
1119 for (ExpF.Init(myShape,TopAbs_FACE);ExpF.More();ExpF.Next()) {
1120 Found = Standard_False;
1121 const TopoDS_Face& FF = TopoDS::Face(ExpF.Current());
1122 for (itLS.Initialize(theLastShape);itLS.More();itLS.Next()) {
1123 const TopoDS_Face& TopFace = TopoDS::Face(itLS.Value());
1124 if (!FF.IsSame(TopFace)) {
1125 TopExp_Explorer ExpE;
1126 for (ExpE.Init(FF,TopAbs_EDGE);ExpE.More() && !Found ;ExpE.Next()) {
1127 const TopoDS_Edge& E1 = TopoDS::Edge(ExpE.Current());
1128 TopoDS_Vertex V1,V2;
1129 TopExp::Vertices (E1,V1,V2);
1130 TopTools_ListIteratorOfListOfShape it(myTopEdges);
1131 for (;it.More() && !Found ; it.Next()) {
1132 TopoDS_Edge E2 = TopoDS::Edge(it.Value());
1133 TopoDS_Vertex VT1,VT2;
1134 TopExp::Vertices (E2,VT1,VT2);
1136 if (V1.IsSame(VT1) || V1.IsSame(VT2) || V2.IsSame(VT1) || V2.IsSame(VT2)) {
1137 Found = Standard_True;
1138 TopExp_Explorer ExpE2;
1139 for (ExpE2.Init(FF,TopAbs_EDGE);ExpE2.More();ExpE2.Next()) {
1140 const TopoDS_Edge& E3 = TopoDS::Edge(ExpE2.Current());
1141 if (MapE.Contains(E3)) {
1153 TopTools_ListIteratorOfListOfShape it(myTopEdges);
1154 for (;it.More() ; it.Next()) {
1155 if (MapE.Contains(it.Value())) {MapE.Remove(it.Value()); }
1158 TopTools_MapIteratorOfMapOfShape itMap;
1159 for (itMap.Initialize(MapE);itMap.More();itMap.Next()) {
1160 if (!BRep_Tool::Degenerated(TopoDS::Edge(itMap.Key())))
1161 myLatEdges.Append(itMap.Key());
1169 //============================================================================
1170 // function : BRepFeat_TopEgdes
1171 // Purpose: Returns the list of TopoDS Edges of the top of the boss
1172 //============================================================================
1173 const TopTools_ListOfShape& BRepFeat_MakeDPrism::TopEdges ()
1178 //============================================================================
1179 // function : BRepFeat_LatEgdes
1180 // Purpose: Returns the list of TopoDS Edges of the top of the boss
1181 //============================================================================
1182 const TopTools_ListOfShape& BRepFeat_MakeDPrism::LatEdges ()
1187 //=======================================================================
1188 //function : BarycCurve
1189 //purpose : passe par le centre de masses de la primitive
1190 //=======================================================================
1192 Handle(Geom_Curve) BRepFeat_MakeDPrism::BarycCurve()
1198 //=======================================================================
1199 //function : HeightMax
1200 //purpose : Calculate the height of the prism following the parameters of the bounding box
1201 //=======================================================================
1203 static Standard_Real HeightMax(const TopoDS_Shape& theSbase, // shape initial
1204 const TopoDS_Face& theSkface, // face de sketch
1205 const TopoDS_Shape& theSFrom, // shape from
1206 const TopoDS_Shape& theSUntil) // shape until
1209 BRepBndLib::Add(theSbase,Box);
1210 BRepBndLib::Add(theSkface,Box);
1211 if(!theSFrom.IsNull()) {
1212 BRepBndLib::Add(theSFrom,Box);
1214 if(!theSUntil.IsNull()) {
1215 BRepBndLib::Add(theSUntil,Box);
1219 Box.Get(c[0],c[2],c[4],c[1],c[3],c[5]);
1220 // Standard_Real parmin=c[0], parmax = c[0];
1221 // for(Standard_Integer i = 0 ; i < 6; i++) {
1222 // if(c[i] > parmax) parmax = c[i];
1223 // if(c[i] < parmin ) parmin = c[i];
1225 // Standard_Real Height = abs(2.*(parmax - parmin));
1226 // return(2.*Height);
1228 Standard_Real par = Max( Max( fabs(c[1] - c[0]), fabs(c[3] - c[2]) ), fabs(c[5] - c[4]) );
1230 // Standard_Real par = Max( Max( abs(c[1] - c[0]), abs(c[3] - c[2]) ), abs(c[5] - c[4]) );
1233 cout << "Height = > " << par << endl;
1242 //=======================================================================
1243 //function : SensOfPrism
1244 //purpose : determine the direction of prism generation
1245 //=======================================================================
1246 Standard_Integer SensOfPrism(const Handle(Geom_Curve) C,
1247 const TopoDS_Shape& Until)
1249 LocOpe_CSIntersector ASI1(Until);
1250 TColGeom_SequenceOfCurve scur;
1253 Standard_Integer sens = 1;
1254 if(ASI1.IsDone() && ASI1.NbPoints(1) >= 1) {
1255 Standard_Integer nb = ASI1.NbPoints(1);
1256 Standard_Real prm1 = ASI1.Point(1, 1).Parameter();
1257 Standard_Real prm2 = ASI1.Point(1, nb).Parameter();
1258 if(prm1 < 0. && prm2 < 0.) {
1262 else if(BRepFeat::ParametricBarycenter(Until,C) < 0) {
1270 //=======================================================================
1271 //function : SetGluedFaces
1273 //=======================================================================
1275 static void SetGluedFaces(const TopoDS_Face& theSkface,
1276 const TopoDS_Shape& theSbase,
1277 const TopoDS_Shape& thePbase,
1278 const TopTools_DataMapOfShapeListOfShape& theSlmap,
1279 LocOpe_DPrism& theDPrism,
1280 TopTools_DataMapOfShapeShape& theMap)
1282 TopExp_Explorer exp;
1283 if (!theSkface.IsNull() && thePbase.ShapeType() == TopAbs_FACE) {
1284 for (exp.Init(theSbase,TopAbs_FACE); exp.More(); exp.Next()) {
1285 if (exp.Current().IsSame(theSkface)) {
1286 theMap.Bind(thePbase,theSkface);
1292 TopExp_Explorer exp2;
1293 for (exp.Init(thePbase,TopAbs_FACE);exp.More();exp.Next()) {
1294 const TopoDS_Face& fac = TopoDS::Face(exp.Current());
1295 for (exp2.Init(theSbase,TopAbs_FACE);exp2.More();exp2.Next()) {
1296 if (exp2.Current().IsSame(fac)) {
1297 theMap.Bind(fac,fac);
1305 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(theSlmap);
1306 if(!theSlmap.IsEmpty()) {
1307 for (; itm.More(); itm.Next()) {
1308 const TopoDS_Face& fac = TopoDS::Face(itm.Key());
1309 const TopTools_ListOfShape& ledg = itm.Value();
1310 for (TopTools_ListIteratorOfListOfShape it(ledg); it.More(); it.Next()) {
1311 const TopTools_ListOfShape& gfac = theDPrism.Shapes(it.Value());
1312 if (gfac.Extent() != 1) {
1314 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1315 if (trc) cout << " BRepFeat_MakeDPrism : Pb SetGluedFace" << endl;
1318 theMap.Bind(gfac.First(),fac);
1325 //=======================================================================
1326 //function : VerifGluedFaces
1327 //purpose : Checking intersection Tool/theSkface = thePbase
1328 // if yes -> OK if no -> case without gluing
1329 //=======================================================================
1331 static void VerifGluedFaces(const TopoDS_Face& theSkface,
1332 const TopoDS_Shape& thePbase,
1333 Handle(Geom_Curve)& theBCurve,
1334 TColGeom_SequenceOfCurve& theCurves,
1335 LocOpe_DPrism& theDPrism,
1336 TopTools_DataMapOfShapeShape& theMap)
1338 Standard_Boolean GluedFaces = Standard_True;
1339 TopoDS_Shape VraiDPrism = theDPrism.Shape();
1341 TColGeom_SequenceOfCurve scur;
1342 theDPrism.Curves(theCurves);
1343 theBCurve = theDPrism.BarycCurve();
1345 scur.Append(theBCurve);
1346 LocOpe_CSIntersector ASI(theSkface);
1348 if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
1349 TopAbs_Orientation Or = ASI.Point(1,1).Orientation();
1350 TopoDS_Face FSk = ASI.Point(1,1).Face();
1353 B.MakeCompound(TopoDS::Compound(Comp));
1354 TopoDS_Solid S = BRepFeat::Tool(theSkface, FSk, Or);
1355 if (!S.IsNull()) B.Add(Comp,S);
1356 //modified by NIZNHY-PKV Thu Mar 21 17:48:45 2002 f
1357 //BRepAlgo_Cut trP(VraiDPrism,Comp);
1358 BRepAlgoAPI_Cut trP(VraiDPrism,Comp);
1359 //modified by NIZNHY-PKV Thu Mar 21 17:48:49 2002 t
1360 TopoDS_Shape Cutsh = trP.Shape();
1361 TopExp_Explorer ex(Cutsh, TopAbs_SOLID);
1362 for(; ex.More(); ex.Next()) {
1363 TopExp_Explorer ex1(ex.Current(), TopAbs_FACE);
1364 for(; ex1.More(); ex1.Next()) {
1365 const TopoDS_Face& fac1 = TopoDS::Face(ex1.Current());
1366 TopExp_Explorer ex2(thePbase, TopAbs_FACE);
1367 for(; ex2.More(); ex2.Next()) {
1368 const TopoDS_Face& fac2 = TopoDS::Face(ex2.Current());
1369 if(fac1.IsSame(fac2)) break;
1371 if (ex2.More()) break;
1373 if (ex1.More()) continue;
1374 GluedFaces = Standard_False;
1379 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1380 if (trc) cout << " Intersection DPrism/skface : no gluing" << endl;
1388 //=======================================================================
1391 //=======================================================================
1393 static void MajMap(const TopoDS_Shape& theB,
1394 const LocOpe_DPrism& theP,
1395 TopTools_DataMapOfShapeListOfShape& theMap, // myMap
1396 TopoDS_Shape& theFShape, // myFShape
1397 TopoDS_Shape& theLShape) // myLShape
1399 TopExp_Explorer exp;
1400 if(!theP.FirstShape().IsNull()) {
1401 exp.Init(theP.FirstShape(),TopAbs_WIRE);
1403 theFShape = exp.Current();
1404 TopTools_ListOfShape thelist;
1405 theMap.Bind(theFShape, thelist);
1406 for (exp.Init(theP.FirstShape(),TopAbs_FACE);exp.More();exp.Next()) {
1407 theMap(theFShape).Append(exp.Current());
1412 if(!theP.LastShape().IsNull()) {
1413 exp.Init(theP.LastShape(),TopAbs_WIRE);
1415 theLShape = exp.Current();
1416 TopTools_ListOfShape thelist1;
1417 theMap.Bind(theLShape, thelist1);
1418 for (exp.Init(theP.LastShape(),TopAbs_FACE);exp.More();exp.Next()) {
1419 theMap(theLShape).Append(exp.Current());
1424 for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) {
1425 if (!theMap.IsBound(exp.Current())) {
1426 const TopoDS_Edge& edg = TopoDS::Edge(exp.Current());
1427 TopTools_ListOfShape thelist2;
1428 theMap.Bind(edg, thelist2);
1429 theMap(edg) = theP.Shapes(edg);
1435 //=======================================================================
1438 //=======================================================================
1440 static Handle(Geom_Curve) TestCurve(const TopoDS_Face& Base)
1442 gp_Pnt bar(0., 0., 0.);
1443 TColgp_SequenceOfPnt spt;
1444 LocOpe::SampleEdges(Base,spt);
1445 for (Standard_Integer jj=1;jj<=spt.Length(); jj++) {
1446 const gp_Pnt& pvt = spt(jj);
1447 bar.ChangeCoord() += pvt.XYZ();
1449 bar.ChangeCoord().Divide(spt.Length());
1450 Handle(Geom_Surface) s = BRep_Tool::Surface(Base);
1451 if (s->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
1452 s = Handle(Geom_RectangularTrimmedSurface)::
1453 DownCast(s)->BasisSurface();
1455 Handle (Geom_Plane) P = Handle(Geom_Plane)::DownCast(s);
1457 Handle(Geom_Curve) toto;
1460 gp_Pln pp = P->Pln();
1461 gp_Dir Normale(pp.Position().XDirection()^pp.Position().YDirection());
1462 gp_Ax1 theAx(bar, Normale);
1463 Handle(Geom_Line) theLin = new Geom_Line(theAx);
1471 //=======================================================================
1474 //=======================================================================
1476 Standard_Boolean ToFuse(const TopoDS_Face& F1,
1477 const TopoDS_Face& F2)
1479 if (F1.IsNull() || F2.IsNull()) {
1480 return Standard_False;
1483 Handle(Geom_Surface) S1,S2;
1484 TopLoc_Location loc1, loc2;
1485 Handle(Standard_Type) typS1,typS2;
1486 const Standard_Real tollin = Precision::Confusion();
1487 const Standard_Real tolang = Precision::Angular();
1489 S1 = BRep_Tool::Surface(F1,loc1);
1490 S2 = BRep_Tool::Surface(F2,loc2);
1492 typS1 = S1->DynamicType();
1493 typS2 = S2->DynamicType();
1495 if (typS1 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
1496 S1 = (*((Handle(Geom_RectangularTrimmedSurface)*)&S1))->BasisSurface();
1497 typS1 = S1->DynamicType();
1500 if (typS2 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
1501 S2 = (*((Handle(Geom_RectangularTrimmedSurface)*)&S2))->BasisSurface();
1502 typS2 = S2->DynamicType();
1505 if (typS1 != typS2) {
1506 return Standard_False;
1510 Standard_Boolean ValRet = Standard_False;
1511 if (typS1 == STANDARD_TYPE(Geom_Plane)) {
1512 S1 = BRep_Tool::Surface(F1); // to apply the location.
1513 S2 = BRep_Tool::Surface(F2);
1514 gp_Pln pl1( (*((Handle(Geom_Plane)*)&S1))->Pln());
1515 gp_Pln pl2( (*((Handle(Geom_Plane)*)&S2))->Pln());
1517 if (pl1.Position().IsCoplanar(pl2.Position(),tollin,tolang)) {
1518 ValRet = Standard_True;