0024059: Eliminate compiler warning C4701 in MSVC++ with warning level 4
[occt.git] / src / BRepFeat / BRepFeat_MakePrism.cxx
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
5 //
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.
10 //
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.
13 //
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.
20
21
22
23 #include <BRepFeat_MakePrism.ixx>
24
25 #include <BRepFeat.hxx>
26 #include <LocOpe.hxx>
27 #include <LocOpe_Prism.hxx>
28 #include <LocOpe_CSIntersector.hxx>
29 #include <LocOpe_PntFace.hxx>
30
31 #include <gp_Vec.hxx>
32 #include <gp_Pnt.hxx>
33 #include <gp_Ax1.hxx>
34 #include <gp_Pnt2d.hxx>
35 #include <Geom_Curve.hxx>
36 #include <Geom_Line.hxx>
37 #include <Geom_RectangularTrimmedSurface.hxx>
38 #include <Geom_Surface.hxx>
39
40 #include <BRepLib_MakeFace.hxx>
41
42 #include <TColgp_SequenceOfPnt.hxx>
43 #include <TColGeom_SequenceOfCurve.hxx>
44 #include <Bnd_Box.hxx>
45
46 #include <BRep_Tool.hxx>
47
48 #include <BRepTools.hxx>
49
50
51 #include <TopExp_Explorer.hxx>
52 #include <TopTools_MapOfShape.hxx>
53 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
54 #include <TopTools_ListIteratorOfListOfShape.hxx>
55 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
56 #include <TopTools_ListIteratorOfListOfShape.hxx>
57 #include <TopTools_ListOfShape.hxx>
58
59 #include <BRepBuilderAPI.hxx>
60 #include <BRepPrimAPI_MakeBox.hxx>
61
62 //modified by NIZNHY-PKV Thu Mar 21 18:14:23 2002 f
63 //#include <BRepAlgo_Cut.hxx>
64 //#include <BRepAlgo_Fuse.hxx>
65 #include <BRepAlgoAPI_Cut.hxx>
66 #include <BRepAlgoAPI_Fuse.hxx>
67 //modified by NIZNHY-PKV Thu Mar 21 18:14:26 2002 t
68
69 #include <Standard_ConstructionError.hxx>
70 #include <TopoDS.hxx>
71
72
73 #include <TopoDS_Face.hxx>
74 #include <TopoDS_Solid.hxx>
75 #include <TopoDS_Compound.hxx>
76
77 #include <TopExp.hxx>
78 #include <BRepBndLib.hxx>
79
80 #include <Precision.hxx>
81 #include <gp_Pln.hxx>
82 #include <Geom_Plane.hxx>
83
84 #ifdef DEB
85 extern Standard_Boolean BRepFeat_GettraceFEAT();
86 #endif
87
88 static void MajMap(const TopoDS_Shape&, // base
89                    const LocOpe_Prism&,
90                    TopTools_DataMapOfShapeListOfShape&, // myMap
91                    TopoDS_Shape&,  // myFShape
92                    TopoDS_Shape&); // myLShape
93
94 static Standard_Boolean ToFuse(const TopoDS_Face& ,
95                                const TopoDS_Face&);
96
97 static Standard_Real HeightMax(const TopoDS_Shape& theSbase,
98                                const TopoDS_Face& theSkface,
99                                const TopoDS_Shape& theSFrom,
100                                const TopoDS_Shape& theSUntil);
101
102 static Standard_Integer SensOfPrism(const Handle(Geom_Curve) C,
103                                     const TopoDS_Shape& Until);
104
105 static Handle(Geom_Curve) TestCurve(const TopoDS_Shape&,
106                                     const gp_Vec&);
107
108
109 //=======================================================================
110 //function : Init
111 //purpose  : 
112 //=======================================================================
113
114 void BRepFeat_MakePrism::Init(const TopoDS_Shape& Sbase,
115                               const TopoDS_Shape& Pbase,
116                               const TopoDS_Face& Skface,
117                               const gp_Dir& Direc,
118                               const Standard_Integer Mode,
119                               const Standard_Boolean Modify)
120 {
121 #ifdef DEB
122   Standard_Boolean trc = BRepFeat_GettraceFEAT();
123   if (trc) cout << "BRepFeat_MakePrism::Init" << endl;
124 #endif
125   mySkface = Skface;
126   SketchFaceValid();
127   mySbase  = Sbase;
128   BasisShapeValid();
129   myPbase  = Pbase;
130   mySlface.Clear();
131   myDir    = Direc;
132   if(Mode == 0) {
133     myFuse   = Standard_False;
134     myJustFeat = Standard_False;
135   }
136   else if(Mode == 1) {
137     myFuse   = Standard_True;
138     myJustFeat = Standard_False;
139   }
140   else if(Mode == 2) {
141     myFuse   = Standard_True;
142     myJustFeat = Standard_True;
143   }
144   else {    
145   }
146   myModify = Modify;
147   myJustGluer = Standard_False;
148
149
150   //-------------- ifv
151   //mySkface.Nullify();
152   //-------------- ifv
153
154
155   myShape.Nullify();
156   myNewEdges.Clear();
157   myTgtEdges.Clear();
158   myMap.Clear();
159   myFShape.Nullify();
160   myLShape.Nullify();
161   TopExp_Explorer exp;
162   for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
163     TopTools_ListOfShape thelist;
164     myMap.Bind(exp.Current(), thelist);
165     myMap(exp.Current()).Append(exp.Current());
166   }
167 #ifdef DEB
168   if (trc) {
169     if (myJustFeat)  cout << " Just Feature" << endl;
170     if (myFuse)  cout << " Fuse" << endl;
171     if (!myFuse)  cout << " Cut" << endl;
172     if (!myModify) cout << " Modify = 0" << endl;
173   }
174 #endif 
175 }
176
177
178 //=======================================================================
179 //function : Add
180 //purpose  : add elements of sliding (edge on face)
181 //=======================================================================
182
183 void BRepFeat_MakePrism::Add(const TopoDS_Edge& E,
184                              const TopoDS_Face& F)
185 {
186 #ifdef DEB
187   Standard_Boolean trc = BRepFeat_GettraceFEAT();
188   if (trc) cout << "BRepFeat_MakePrism::Add(Edge,face)" << endl;
189 #endif
190   TopExp_Explorer exp;
191   for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
192     if (exp.Current().IsSame(F)) {
193       break;
194     }
195   }
196   if (!exp.More()) {
197     Standard_ConstructionError::Raise();
198   }
199   
200   for (exp.Init(myPbase,TopAbs_EDGE);exp.More();exp.Next()) {
201     if (exp.Current().IsSame(E)) {
202       break;
203     }
204   }
205   if (!exp.More()) {
206     Standard_ConstructionError::Raise();
207   }
208   
209   if (!mySlface.IsBound(F)) {
210     TopTools_ListOfShape thelist1;
211     mySlface.Bind(F, thelist1);
212   }
213   TopTools_ListIteratorOfListOfShape itl(mySlface(F));
214   for (; itl.More();itl.Next()) {
215     if (itl.Value().IsSame(E)) {
216       break;
217     }
218   }
219   if (!itl.More()) {
220     mySlface(F).Append(E);
221   }
222 }
223
224
225 //=======================================================================
226 //function : Perform
227 //purpose  : construction of prism of length Length and 
228 //           call of reconstruction topo
229 //=======================================================================
230
231 void BRepFeat_MakePrism::Perform(const Standard_Real Length)
232 {
233 #ifdef DEB
234   Standard_Boolean trc = BRepFeat_GettraceFEAT();
235   if (trc) cout << "BRepFeat_MakePrism::Perform(Length)" << endl;
236 #endif
237   mySFrom.Nullify();
238   ShapeFromValid();
239   mySUntil.Nullify();
240   ShapeUntilValid();
241   myGluedF.Clear();
242   myPerfSelection = BRepFeat_NoSelection;
243   PerfSelectionValid();
244   gp_Vec V(Length*myDir);
245   
246 //construction of prism of height Length
247
248   LocOpe_Prism thePrism(myPbase,V);
249   TopoDS_Shape VraiPrism = thePrism.Shape();
250   
251 // management of descendants
252   MajMap(myPbase,thePrism,myMap,myFShape,myLShape);
253   
254
255   myGShape = VraiPrism;    // the primitive
256   GeneratedShapeValid();
257   
258   TopoDS_Face FFace;
259   
260   Standard_Boolean found = Standard_False;
261
262 // try to detect the faces of gluing 
263 // in case if the top of the prism is tangent to the initial shape
264
265   if(!mySkface.IsNull() || !mySlface.IsEmpty()) {
266     if(myLShape.ShapeType() == TopAbs_WIRE) {
267       TopExp_Explorer ex1(VraiPrism, TopAbs_FACE);
268       for(; ex1.More(); ex1.Next()) {
269         TopExp_Explorer ex2(ex1.Current(), TopAbs_WIRE);
270         for(; ex2.More(); ex2.Next()) {
271           if(ex2.Current().IsSame(myLShape)) {
272             FFace = TopoDS::Face(ex1.Current());
273             found = Standard_True;
274             break;
275           }
276         }
277         if(found) break;
278       }
279     }
280     
281     TopExp_Explorer exp(mySbase, TopAbs_FACE);
282     for(; exp.More(); exp.Next()) {
283       const TopoDS_Face& ff = TopoDS::Face(exp.Current());
284       if(ToFuse(ff, FFace)) {
285         TopTools_DataMapOfShapeListOfShape sl;
286         if(!FFace.IsSame(myPbase) && BRepFeat::IsInside(ff, FFace)) 
287         break;
288       }
289     }
290   }
291
292 // management of faces of gluing given by the user
293
294   GluedFacesValid();
295
296   if(!myGluedF.IsEmpty()) {   // case gluing
297     myJustGluer = Standard_True;
298     thePrism.Curves(myCurves);
299     myBCurve = thePrism.BarycCurve();    
300     GlobalPerform();  // topological reconstruction 
301   }
302
303 // if there is no gluing  -> call of ope topo
304   if(!myJustGluer) {
305     if(myFuse == 1 && !myJustFeat) {
306       //modified by NIZNHY-PKV Thu Mar 21 17:55:30 2002 f
307       //BRepAlgo_Fuse f(mySbase, myGShape);
308       //myShape = f.Shape();
309       //UpdateDescendants(f.Builder(), myShape, Standard_False);
310       BRepAlgoAPI_Fuse f(mySbase, myGShape);
311       myShape = f.Shape();
312       UpdateDescendants(f, myShape, Standard_False);
313       //modified by NIZNHY-PKV Thu Mar 21 17:55:34 2002 t
314       Done();
315     }
316     else if(myFuse == 0) {
317       //modified by NIZNHY-PKV Thu Mar 21 17:55:59 2002 f
318       //BRepAlgo_Cut c(mySbase, myGShape);
319       //myShape = c.Shape();
320       //UpdateDescendants(c.Builder(), myShape, Standard_False);
321       BRepAlgoAPI_Cut c(mySbase, myGShape);
322       myShape = c.Shape();
323       UpdateDescendants(c, myShape, Standard_False);
324       //modified by NIZNHY-PKV Thu Mar 21 17:56:02 2002 t
325       Done();
326     }
327     else {
328       myShape = myGShape;
329       Done();
330     }
331   }
332 }
333
334
335 //=======================================================================
336 //function : Perform
337 //purpose  : construction of prism oriented at the face Until, sufficiently 
338 //           long; call of topological reconstruction          
339 //=======================================================================
340
341 void BRepFeat_MakePrism::Perform(const TopoDS_Shape& Until)
342 {
343 #ifdef DEB
344   Standard_Boolean trc = BRepFeat_GettraceFEAT();
345   if (trc) cout << "BRepFeat_MakePrism::Perform(Until)" << endl;
346 #endif
347   if (Until.IsNull()) {
348     Standard_ConstructionError::Raise();
349   }
350   TopExp_Explorer exp(Until, TopAbs_FACE);
351   if (!exp.More()) {
352     Standard_ConstructionError::Raise();
353   }
354   myGluedF.Clear();
355   myPerfSelection = BRepFeat_SelectionU;
356   PerfSelectionValid();
357   mySFrom.Nullify();
358   ShapeFromValid();
359   mySUntil = Until;
360   Standard_Boolean Trf = TransformShapeFU(1);  
361   ShapeUntilValid();
362   Handle(Geom_Curve) C = TestCurve(myPbase,myDir);  
363   Standard_Integer sens = SensOfPrism(C, mySUntil);
364   Standard_Real Height = HeightMax(mySbase, mySkface, mySFrom, mySUntil);
365   gp_Vec V(2*sens*Height*myDir);
366
367 // construction of long prism
368   LocOpe_Prism thePrism(myPbase,V);
369   TopoDS_Shape VraiPrism = thePrism.Shape();
370
371 // in case of support of face Until
372   if(!Trf) {    
373     MajMap(myPbase,thePrism,myMap,myFShape,myLShape);    
374     myGShape = VraiPrism;
375     GeneratedShapeValid();
376     GluedFacesValid();
377     thePrism.Curves(myCurves);
378     myBCurve = thePrism.BarycCurve();
379     GlobalPerform();
380   }
381   else {    // until support -> passage to topological operations
382     MajMap(myPbase,thePrism,myMap,myFShape,myLShape);    
383     TColGeom_SequenceOfCurve scur;
384     scur.Clear();    
385     scur.Append(C);
386
387 // direction of the prism depending on Until
388
389     LocOpe_CSIntersector ASI(mySUntil);
390     ASI.Perform(scur);
391     TopAbs_Orientation Or;
392     if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
393       if (myFuse == 1) {
394         Or = ASI.Point(1,1).Orientation();
395       }
396       else {
397         Or = ASI.Point(1,ASI.NbPoints(1)).Orientation();
398       }
399       if(sens==-1) Or=TopAbs::Reverse(Or);
400       TopoDS_Face FUntil = ASI.Point(1,1).Face();
401       TopoDS_Shape Comp;
402       BRep_Builder B;
403       B.MakeCompound(TopoDS::Compound(Comp));
404       TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or);
405       if (!S.IsNull()) B.Add(Comp,S);
406       //modified by NIZNHY-PKV Thu Mar 21 17:56:31 2002 f
407       //BRepAlgo_Cut trP(VraiPrism,Comp);
408       //UpdateDescendants(trP.Builder(),trP.Shape(), Standard_False);
409       BRepAlgoAPI_Cut trP(VraiPrism,Comp);
410       UpdateDescendants(trP, trP.Shape(), Standard_False);
411       //modified by NIZNHY-PKV Thu Mar 21 17:56:38 2002 t
412       TopExp_Explorer ex(trP.Shape(), TopAbs_SOLID);
413       TopoDS_Shape Cutsh = ex.Current();
414       if(myFuse == 1 && !myJustFeat) {
415         //modified by NIZNHY-PKV Thu Mar 21 17:57:49 2002 f
416         //BRepAlgo_Fuse f(mySbase, Cutsh);
417         //myShape = f.Shape();
418         //UpdateDescendants(f.Builder(), myShape, Standard_False);
419         BRepAlgoAPI_Fuse f(mySbase, Cutsh);
420         myShape = f.Shape();
421         UpdateDescendants(f, myShape, Standard_False);
422         //modified by NIZNHY-PKV Thu Mar 21 17:57:53 2002 t
423         Done();
424       }
425       else if(myFuse == 0) {
426         //modified by NIZNHY-PKV Thu Mar 21 17:59:33 2002 f
427         //BRepAlgo_Cut c(mySbase, Cutsh);
428         //myShape = c.Shape();
429         //UpdateDescendants(c.Builder(), myShape, Standard_False);
430         BRepAlgoAPI_Cut c(mySbase, Cutsh);
431         myShape = c.Shape();
432         UpdateDescendants(c, myShape, Standard_False);
433         //modified by NIZNHY-PKV Thu Mar 21 17:59:43 2002 t
434         Done();
435       }
436       else {
437         myShape = Cutsh;
438         Done(); 
439       }
440     }         
441   }
442 /*   // loop of control of descendance
443
444   TopExp_Explorer expr(mySbase, TopAbs_FACE);
445   char nom1[20], nom2[20];
446   Standard_Integer ii = 0;
447   for(; expr.More(); expr.Next()) {
448     ii++;
449     sprintf(nom1, "faceinitial_%d", ii);
450     DBRep::Set(nom1, expr.Current());
451     Standard_Integer jj = 0;
452     const TopTools_ListOfShape& list = Modified(expr.Current());
453     TopTools_ListIteratorOfListOfShape ite(list);
454     for(; ite.More(); ite.Next()) {
455       jj++;
456       sprintf(nom2, "facemodifie_%d_%d", ii, jj);
457       DBRep::Set(nom2, ite.Value());
458     }
459   }
460
461   expr.Init(myPbase, TopAbs_EDGE);
462   ii=0;
463   for(; expr.More(); expr.Next()) {
464     ii++;
465     sprintf(nom1, "edgeinitial_%d", ii);
466     DBRep::Set(nom1, expr.Current());
467     Standard_Integer jj = 0;
468     const TopTools_ListOfShape& list = Generated(expr.Current());
469     TopTools_ListIteratorOfListOfShape ite(list);
470     for(; ite.More(); ite.Next()) {
471       jj++;
472       sprintf(nom2, "facegeneree_%d_%d", ii, jj);
473       DBRep::Set(nom2, ite.Value());
474     }
475   }
476 */
477 }
478
479
480 //=======================================================================
481 //function : Perform
482 //purpose  : construction of a sufficiently long and properly oriented prism
483 //           call of topological reconstruction
484 //=======================================================================
485
486 void BRepFeat_MakePrism::Perform(const TopoDS_Shape& From,
487                                  const TopoDS_Shape& Until)
488 {
489 #ifdef DEB
490   Standard_Boolean trc = BRepFeat_GettraceFEAT();
491   if (trc) cout << "BRepFeat_MakePrism::Perform(From,Until)" << endl;
492 #endif
493   if (From.IsNull() || Until.IsNull()) {
494     Standard_ConstructionError::Raise();
495   }
496
497   if (!mySkface.IsNull()) {
498     if (From.IsSame(mySkface)) {
499       myJustGluer = Standard_True;
500       Perform(Until);
501       if (myJustGluer) return;
502     }
503     else if (Until.IsSame(mySkface)) {
504       myJustGluer = Standard_True;
505       Perform(From);
506       if (myJustGluer) return;
507     } 
508   }
509   
510   myGluedF.Clear();
511   myPerfSelection = BRepFeat_SelectionFU;
512   PerfSelectionValid();
513   
514   TopExp_Explorer exp(From, TopAbs_FACE);
515   if (!exp.More()) {
516     Standard_ConstructionError::Raise();
517   }
518   exp.Init(Until, TopAbs_FACE);
519   if (!exp.More()) {
520     Standard_ConstructionError::Raise();
521   }
522   mySFrom = From;
523   Standard_Boolean Trff = TransformShapeFU(0);
524   ShapeFromValid();
525   mySUntil = Until;
526   Standard_Boolean Trfu = TransformShapeFU(1);
527   ShapeUntilValid();  
528   if(Trfu != Trff) {
529     NotDone();
530     myStatusError = BRepFeat_IncTypes;
531     return;
532   }
533
534 // length depending on bounding boxes
535
536   Standard_Real Height = HeightMax(mySbase, mySkface, mySFrom, mySUntil);
537   Handle(Geom_Curve) C = TestCurve(myPbase,myDir);  
538   Standard_Integer sens;  // direction of prism
539   Standard_Integer tran;  // transfer of prism
540   if(From.IsSame(Until)) {
541     sens = 1;
542     tran = -1;
543   }
544   else {
545     sens = SensOfPrism(C, mySUntil);
546     tran = sens*SensOfPrism(C, mySFrom);
547   }
548   LocOpe_Prism thePrism;   
549   if(tran < 0) {
550     gp_Vec Vtra(-3*Height*sens/2.*myDir);
551     thePrism.Perform(myPbase,3*sens*Height*myDir,Vtra);
552   }
553   else {
554     thePrism.Perform(myPbase,2*sens*Height*myDir);
555   }
556   TopoDS_Shape VraiPrism = thePrism.Shape();
557   
558   if(!Trff) {
559     MajMap(myPbase,thePrism,myMap,myFShape,myLShape);
560     
561     myGShape = VraiPrism;
562     GeneratedShapeValid();
563     GluedFacesValid();
564     thePrism.Curves(myCurves);
565     myBCurve = thePrism.BarycCurve();
566     GlobalPerform();
567   }
568   else {    // case until support -> topological operation
569     MajMap(myPbase,thePrism,myMap,myFShape,myLShape);    
570     TColGeom_SequenceOfCurve scur;
571     scur.Clear();    
572     scur.Append(C);
573     LocOpe_CSIntersector ASI1(mySUntil);
574     LocOpe_CSIntersector ASI2(mySFrom);
575     ASI1.Perform(scur);
576     ASI2.Perform(scur);
577     TopAbs_Orientation OrU, OrF;
578     TopoDS_Face FFrom, FUntil;
579     if (ASI1.IsDone() && ASI1.NbPoints(1) >=1) {
580       if (myFuse == 1) {
581         OrU = ASI1.Point(1,1).Orientation();
582       }
583       else {
584         OrU = ASI1.Point(1,ASI1.NbPoints(1)).Orientation();
585       }
586       if(sens==-1) OrU = TopAbs::Reverse(OrU);
587       FUntil = ASI1.Point(1,1).Face();
588     }
589     else {
590       NotDone();
591       myStatusError = BRepFeat_NoIntersectU;
592       return;
593     }
594     if (ASI2.IsDone() && ASI2.NbPoints(1) >=1) {
595       OrF = ASI2.Point(1,1).Orientation();
596       if(sens==1) OrF = TopAbs::Reverse(OrF);
597       FFrom = ASI2.Point(1,1).Face();
598     }
599     else {
600       NotDone();
601       myStatusError = BRepFeat_NoIntersectF;
602       return;
603     }
604     TopoDS_Shape Comp;
605     BRep_Builder B;
606     B.MakeCompound(TopoDS::Compound(Comp));
607     TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, OrU);
608     if (!S.IsNull()) {
609       B.Add(Comp,S);
610     }
611     else {
612       NotDone();
613       myStatusError = BRepFeat_NullToolU;
614       return;
615     }
616     TopoDS_Solid SS = BRepFeat::Tool(mySFrom, FFrom, OrF);
617     if (!SS.IsNull()) {
618       B.Add(Comp,SS);
619     }
620     else {
621       NotDone();
622       myStatusError = BRepFeat_NullToolF;
623       return;
624     }
625     //modified by NIZNHY-PKV Thu Mar 21 18:00:10 2002 f
626     //BRepAlgo_Cut trP(VraiPrism,Comp);
627     //UpdateDescendants(trP.Builder(), trP.Shape(), Standard_False);
628     BRepAlgoAPI_Cut trP(VraiPrism,Comp);
629     UpdateDescendants(trP, trP.Shape(), Standard_False);
630     //modified by NIZNHY-PKV Thu Mar 21 18:00:16 2002 t
631     if(myFuse == 1 && !myJustFeat) {
632       //modified by NIZNHY-PKV Thu Mar 21 18:00:35 2002 f
633       //BRepAlgo_Fuse f(mySbase, trP.Shape());
634       //myShape = f.Shape();
635       //UpdateDescendants(f.Builder(), myShape, Standard_False);
636       BRepAlgoAPI_Fuse f(mySbase, trP.Shape());
637       myShape = f.Shape();
638       UpdateDescendants(f, myShape, Standard_False);
639       //modified by NIZNHY-PKV Thu Mar 21 18:00:40 2002 t
640       Done();
641     }
642     else if(myFuse == 0) {
643       //modified by NIZNHY-PKV Thu Mar 21 18:01:01 2002 f
644       //BRepAlgo_Cut c(mySbase, trP.Shape());
645       //myShape = c.Shape();
646       //UpdateDescendants(c.Builder(), myShape, Standard_False);
647       BRepAlgoAPI_Cut c(mySbase, trP.Shape());
648       myShape = c.Shape();
649       UpdateDescendants(c, myShape, Standard_False);
650       //modified by NIZNHY-PKV Thu Mar 21 18:01:13 2002 t
651       Done();
652     }
653     else {
654       myShape = trP.Shape();
655       Done();   
656     }
657   }         
658 // control history
659 /*
660   TopExp_Explorer expr(mySbase, TopAbs_FACE);
661   char nom1[20], nom2[20];
662   Standard_Integer ii = 0;
663   for(; expr.More(); expr.Next()) {
664     ii++;
665     sprintf(nom1, "faceinitial_%d", ii);
666     DBRep::Set(nom1, expr.Current());
667     Standard_Integer jj = 0;
668     const TopTools_ListOfShape& list = Modified(expr.Current());
669     TopTools_ListIteratorOfListOfShape ite(list);
670     for(; ite.More(); ite.Next()) {
671       jj++;
672       sprintf(nom2, "facemodifie_%d_%d", ii, jj);
673       DBRep::Set(nom2, ite.Value());
674     }
675   }
676
677   expr.Init(myPbase, TopAbs_EDGE);
678   ii=0;
679   for(; expr.More(); expr.Next()) {
680     ii++;
681     sprintf(nom1, "edgeinitial_%d", ii);
682     DBRep::Set(nom1, expr.Current());
683     Standard_Integer jj = 0;
684     const TopTools_ListOfShape& list = Generated(expr.Current());
685     TopTools_ListIteratorOfListOfShape ite(list);
686     for(; ite.More(); ite.Next()) {
687       jj++;
688       sprintf(nom2, "egdegeneree_%d_%d", ii, jj);
689       DBRep::Set(nom2, ite.Value());
690     }
691   }
692 */
693 }
694
695
696
697 //=======================================================================
698 //function : PerformUntilEnd
699 //purpose  : construction of a prism and reconstruction
700 //=======================================================================
701
702 void BRepFeat_MakePrism::PerformUntilEnd()
703 {
704 #ifdef DEB
705   Standard_Boolean trc = BRepFeat_GettraceFEAT();
706   if (trc) cout << "BRepFeat_MakePrism::PerformUntilEnd()" << endl;
707 #endif
708   myPerfSelection = BRepFeat_SelectionSh;
709   PerfSelectionValid();
710   myGluedF.Clear();
711   mySUntil.Nullify();
712   ShapeUntilValid();
713   mySFrom.Nullify();
714   ShapeFromValid();
715   Standard_Real Height = HeightMax(mySbase, mySkface, mySFrom, mySUntil);
716   gp_Vec V(2*Height*myDir);
717   
718   LocOpe_Prism thePrism(myPbase,V);
719   TopoDS_Shape VraiPrism = thePrism.Shape();
720   
721   MajMap(myPbase,thePrism,myMap,myFShape,myLShape);
722   
723   myGShape = VraiPrism;
724   GeneratedShapeValid();
725   GluedFacesValid();
726
727   if(myFuse == 0) {
728     //modified by NIZNHY-PKV Thu Mar 21 18:02:46 2002 f
729     //BRepAlgo_Cut c(mySbase, myGShape);
730     BRepAlgoAPI_Cut c(mySbase, myGShape);
731     //modified by NIZNHY-PKV Thu Mar 21 18:03:15 2002 t
732     if (c.IsDone()) {
733       myShape = c.Shape();
734       //modified by NIZNHY-PKV Thu Mar 21 18:03:38 2002 f
735       //UpdateDescendants(c.Builder(), myShape, Standard_False);
736       UpdateDescendants(c, myShape, Standard_False);
737       //modified by NIZNHY-PKV Thu Mar 21 18:03:42 2002 t
738       Done();
739     }
740   }
741   else {
742     thePrism.Curves(myCurves);
743     myBCurve = thePrism.BarycCurve();
744     GlobalPerform();
745   }
746 }
747
748 //=======================================================================
749 //function : PerformFromEnd
750 //purpose  : 
751 //=======================================================================
752
753 void BRepFeat_MakePrism::PerformFromEnd(const TopoDS_Shape& Until)
754 {
755 #ifdef DEB
756   Standard_Boolean trc = BRepFeat_GettraceFEAT();
757   if (trc) cout << "BRepFeat_MakePrism::PerformFromEnd(From,Until)" << endl;
758 #endif
759   if (Until.IsNull()) {
760     Standard_ConstructionError::Raise();
761   }
762   if (!mySkface.IsNull() && Until.IsSame(mySkface)) {
763     myDir.Reverse();
764     PerformUntilEnd();
765     return;
766   }
767   TopExp_Explorer exp;
768   exp.Init(Until, TopAbs_FACE);
769   if (!exp.More()) {
770     Standard_ConstructionError::Raise();
771   }
772   myPerfSelection = BRepFeat_SelectionShU;
773   PerfSelectionValid();
774   mySFrom.Nullify();
775   ShapeFromValid();
776   mySUntil = Until;
777   Standard_Boolean Trf = TransformShapeFU(1);
778   ShapeUntilValid();
779   Handle(Geom_Curve) C = TestCurve(myPbase,myDir);  
780   Standard_Integer sens = SensOfPrism(C, mySUntil);
781   Standard_Real Height = HeightMax(mySbase, mySkface, mySFrom, mySUntil);
782   gp_Vec Vtra(-3*Height*sens/2.*myDir);
783   gp_Vec Vect(3*sens*Height*myDir);
784   LocOpe_Prism thePrism(myPbase,Vect,Vtra);
785   TopoDS_Shape VraiPrism = thePrism.Shape();
786   
787   if(!Trf) {  // case face until 
788     MajMap(myPbase,thePrism,myMap,myFShape,myLShape);
789     myGShape = VraiPrism;
790     GeneratedShapeValid();
791     myGluedF.Clear();
792     GluedFacesValid();
793     thePrism.Curves(myCurves);
794     myBCurve = thePrism.BarycCurve();
795     GlobalPerform();
796   }
797   else {   // case support
798     MajMap(myPbase,thePrism,myMap,myFShape,myLShape);    
799     TColGeom_SequenceOfCurve scur;
800     scur.Clear();    
801     scur.Append(C);
802     LocOpe_CSIntersector ASI1(mySUntil);
803     LocOpe_CSIntersector ASI2(mySbase);
804     ASI1.Perform(scur);
805     ASI2.Perform(scur);
806     TopAbs_Orientation OrU = TopAbs_FORWARD, OrF = TopAbs_FORWARD;
807     TopoDS_Face FUntil, FFrom;
808     if (ASI1.IsDone() && ASI1.NbPoints(1) >=1) {
809       OrU = ASI1.Point(1,1).Orientation();
810       if(sens==-1) {
811         OrU = TopAbs::Reverse(OrU);
812       }
813       FUntil = ASI1.Point(1,1).Face();
814     }
815     if (ASI2.IsDone() && ASI2.NbPoints(1) >=1) {
816       OrF = ASI2.Point(1,1).Orientation();
817 //      if(sens==1) OrF = TopAbs::Reverse(OrF);
818       FFrom = ASI2.Point(1 ,1).Face();
819       Handle(Geom_Surface) S = BRep_Tool::Surface(FFrom);
820       if (S->DynamicType() == 
821           STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
822         S = Handle(Geom_RectangularTrimmedSurface)::
823           DownCast(S)->BasisSurface();
824       }
825       BRepLib_MakeFace fac(S, Precision::Confusion());
826       mySFrom = fac.Face();  
827       Trf = TransformShapeFU(0);
828       FFrom = TopoDS::Face(mySFrom);
829     }
830 //    else {
831 //      NotDone();
832 //      return;
833 //    }
834     TopoDS_Shape Comp;
835     BRep_Builder B;
836     B.MakeCompound(TopoDS::Compound(Comp));
837     TopoDS_Solid Sol = BRepFeat::Tool(mySUntil, FUntil, OrU);
838     if (!Sol.IsNull()) {
839       B.Add(Comp,Sol);
840     }
841     else {
842       NotDone();
843       myStatusError = BRepFeat_NullToolU;
844       return;
845     }
846
847     TopoDS_Solid Sol1 = BRepFeat::Tool(mySFrom, FFrom, OrF);
848     if (!Sol1.IsNull()) {
849       B.Add(Comp,Sol1);
850     }
851     else {
852       NotDone();
853       myStatusError = BRepFeat_NullToolF;
854       return;
855     }
856     //modified by NIZNHY-PKV Thu Mar 21 18:03:57 2002 f
857     //BRepAlgo_Cut trP(VraiPrism,Comp);
858     //UpdateDescendants(trP.Builder(), trP.Shape(), Standard_False);
859     BRepAlgoAPI_Cut trP(VraiPrism,Comp);
860     UpdateDescendants(trP, trP.Shape(), Standard_False);
861     //modified by NIZNHY-PKV Thu Mar 21 18:04:08 2002 t
862     if(myFuse == 1 && !myJustFeat) {
863       //modified by NIZNHY-PKV Thu Mar 21 18:04:33 2002 f
864       //BRepAlgo_Fuse f(mySbase, trP.Shape());
865       //myShape = f.Shape();
866       //UpdateDescendants(f.Builder(), myShape, Standard_False);
867       BRepAlgoAPI_Fuse f(mySbase, trP.Shape());
868       myShape = f.Shape();
869       UpdateDescendants(f, myShape, Standard_False);
870       //modified by NIZNHY-PKV Thu Mar 21 18:04:41 2002 t
871       Done();
872     }
873     else if(myFuse == 0) {
874       //modified by NIZNHY-PKV Thu Mar 21 18:04:54 2002 f
875       //BRepAlgo_Cut c(mySbase, trP.Shape());
876       //myShape = c.Shape();
877       //UpdateDescendants(c.Builder(), myShape, Standard_False);
878       BRepAlgoAPI_Cut c(mySbase, trP.Shape());
879       myShape = c.Shape();
880       UpdateDescendants(c, myShape, Standard_False);
881       //modified by NIZNHY-PKV Thu Mar 21 18:05:00 2002 t
882       Done();
883     }
884     else {
885       myShape = trP.Shape();
886       Done();   
887     }
888   }         
889 }
890
891
892
893 //=======================================================================
894 //function : PerformThruAll
895 //purpose  : 
896 //=======================================================================
897
898 void BRepFeat_MakePrism::PerformThruAll()
899 {
900 #ifdef DEB
901   Standard_Boolean trc = BRepFeat_GettraceFEAT();
902   if (trc) cout << "BRepFeat_MakePrism::PerformThruAll()" << endl;
903 #endif
904   mySUntil.Nullify();
905   ShapeUntilValid();
906   mySFrom.Nullify();
907   ShapeFromValid();
908   if(myFuse == 0) {
909     myPerfSelection = BRepFeat_NoSelection;
910   }
911   else {
912     myPerfSelection = BRepFeat_SelectionSh;
913   }
914   PerfSelectionValid();
915   myGluedF.Clear();
916   GluedFacesValid();
917
918   Standard_Real Height = HeightMax(mySbase, mySkface, mySFrom, mySUntil);
919   gp_Vec V(3*Height*myDir);
920   gp_Vec Vtra(-3*Height/2.*myDir);
921   LocOpe_Prism thePrism(myPbase,V,Vtra);
922   TopoDS_Shape VraiPrism = thePrism.Shape();
923   MajMap(myPbase,thePrism,myMap,myFShape,myLShape);
924
925   myGShape = VraiPrism;
926   GeneratedShapeValid();  
927
928   if(myFuse == 0) {
929     //modified by NIZNHY-PKV Thu Mar 21 18:05:31 2002 f
930     //BRepAlgo_Cut c(mySbase, myGShape);
931     BRepAlgoAPI_Cut c(mySbase, myGShape);
932     //modified by NIZNHY-PKV Thu Mar 21 18:05:33 2002 t
933     if (c.IsDone()) {
934       myShape = c.Shape();
935       //modified by NIZNHY-PKV Thu Mar 21 18:05:46 2002 f
936       //UpdateDescendants(c.Builder(), myShape, Standard_False);
937       UpdateDescendants(c, myShape, Standard_False);
938       //modified by NIZNHY-PKV Thu Mar 21 18:05:50 2002 t
939       Done();
940     }
941   }
942   else {
943     thePrism.Curves(myCurves);
944     myBCurve = thePrism.BarycCurve();
945     GlobalPerform();
946   }
947 }
948
949
950 //=======================================================================
951 //function : PerformUntilHauteur
952 //purpose  : 
953 //=======================================================================
954
955 void BRepFeat_MakePrism::PerformUntilHeight(const TopoDS_Shape& Until,
956                                              const Standard_Real Length)
957 {
958 #ifdef DEB
959   Standard_Boolean trc = BRepFeat_GettraceFEAT();
960   if (trc) cout << "BRepFeat_MakePrism::PerformUntilHeight(Until,Length)" << endl;
961 #endif
962   if (Until.IsNull()) {
963     Perform(Length);
964   }
965   if(Length == 0) {
966     Perform(Until);
967   }
968   TopExp_Explorer exp(Until, TopAbs_FACE);
969   if (!exp.More()) {
970     Standard_ConstructionError::Raise();
971   }
972   myGluedF.Clear();
973   myPerfSelection = BRepFeat_NoSelection;
974   PerfSelectionValid();
975   mySFrom.Nullify();
976   ShapeFromValid();
977   mySUntil = Until;
978   Standard_Boolean Trf = TransformShapeFU(1);
979   ShapeUntilValid();
980   Handle(Geom_Curve) C = TestCurve(myPbase,myDir);  
981   Standard_Integer sens = SensOfPrism(C, mySUntil);
982   gp_Vec V(sens*Length*myDir);
983   LocOpe_Prism thePrism(myPbase,V);
984   TopoDS_Shape VraiPrism = thePrism.Shape();
985
986   if(!Trf) {
987     MajMap(myPbase,thePrism,myMap,myFShape,myLShape);
988     
989     myGShape = VraiPrism;
990     GeneratedShapeValid();
991     GluedFacesValid();
992     thePrism.Curves(myCurves);
993     myBCurve = thePrism.BarycCurve();
994     GlobalPerform();
995   }
996   else {
997     MajMap(myPbase,thePrism,myMap,myFShape,myLShape);    
998     TColGeom_SequenceOfCurve scur;
999     scur.Clear();    
1000     scur.Append(C);
1001     LocOpe_CSIntersector ASI(mySUntil);
1002     ASI.Perform(scur);
1003     TopAbs_Orientation Or;
1004     if (ASI.IsDone() && ASI.NbPoints(1) >=1) {
1005       if (myFuse == 1) {
1006         Or = ASI.Point(1,1).Orientation();
1007       }
1008       else {
1009         Or = ASI.Point(1,ASI.NbPoints(1)).Orientation();
1010       }
1011       if(sens==-1) Or=TopAbs::Reverse(Or);
1012       TopoDS_Face FUntil = ASI.Point(1,1).Face();
1013       TopoDS_Shape Comp;
1014       BRep_Builder B;
1015       B.MakeCompound(TopoDS::Compound(Comp));
1016       TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or);
1017       if (!S.IsNull()) B.Add(Comp,S);
1018
1019       //modified by NIZNHY-PKV Thu Mar 21 18:06:09 2002 f
1020       //BRepAlgo_Cut trP(VraiPrism,Comp);
1021       //UpdateDescendants(trP.Builder(), trP.Shape(), Standard_False);
1022       BRepAlgoAPI_Cut trP(VraiPrism,Comp);
1023       UpdateDescendants(trP, trP.Shape(), Standard_False);
1024       //modified by NIZNHY-PKV Thu Mar 21 18:06:15 2002 t
1025       if(myFuse == 1 && !myJustFeat) {
1026         //modified by NIZNHY-PKV Thu Mar 21 18:06:36 2002 f
1027         //BRepAlgo_Fuse f(mySbase, trP.Shape());
1028         //myShape = f.Shape();
1029         //UpdateDescendants(f.Builder(), myShape, Standard_False);
1030         BRepAlgoAPI_Fuse f(mySbase, trP.Shape());
1031         myShape = f.Shape();
1032         UpdateDescendants(f, myShape, Standard_False);
1033         //modified by NIZNHY-PKV Thu Mar 21 18:06:41 2002 t
1034         Done();
1035       }
1036       else if(myFuse == 0) {
1037         //modified by NIZNHY-PKV Thu Mar 21 18:07:06 2002 f
1038         //BRepAlgo_Cut c(mySbase, trP.Shape());
1039         //myShape = c.Shape();
1040         //UpdateDescendants(c.Builder(), myShape, Standard_False);
1041         BRepAlgoAPI_Cut c(mySbase, trP.Shape());
1042         myShape = c.Shape();
1043         UpdateDescendants(c, myShape, Standard_False);
1044         //modified by NIZNHY-PKV Thu Mar 21 18:07:12 2002 t
1045         Done();
1046       }
1047       else {
1048         myShape = trP.Shape();
1049         Done(); 
1050       }
1051     }         
1052   }
1053 }
1054
1055 //=======================================================================
1056 //function : Curves
1057 //purpose  : sequence of curves parallel to the axis of prism 
1058 //=======================================================================
1059
1060 void BRepFeat_MakePrism::Curves(TColGeom_SequenceOfCurve& scur)
1061 {
1062   scur = myCurves;
1063 }
1064
1065 //=======================================================================
1066 //function : BarycCurve
1067 //purpose  : curve parallel to the axis of the prism passing through the center  
1068 //           of masses
1069 //=======================================================================
1070
1071 Handle(Geom_Curve) BRepFeat_MakePrism::BarycCurve()
1072 {
1073   return myBCurve;
1074 }
1075
1076
1077 //=======================================================================
1078 //function : HeightMax
1079 //purpose  : Calculate the height of the prism following the parameters of
1080 //           bounding box
1081 //=======================================================================
1082
1083 static Standard_Real HeightMax(const TopoDS_Shape& theSbase,
1084                                const TopoDS_Face&  theSkface,
1085                                const TopoDS_Shape& theSFrom,
1086                                const TopoDS_Shape& theSUntil)
1087 {
1088   Bnd_Box Box;
1089   BRepBndLib::Add(theSbase,Box);
1090   BRepBndLib::Add(theSkface,Box);
1091   if(!theSFrom.IsNull()) {
1092     Standard_Boolean FacRevolInfini = Standard_False;
1093     TopExp_Explorer exp;
1094     exp.Init(theSFrom, TopAbs_EDGE);
1095     for(; exp.More(); exp.Next()) {
1096       TopExp_Explorer exp1;
1097       exp1.Init(exp.Current(), TopAbs_VERTEX);
1098       if(!exp1.More()) {
1099         FacRevolInfini = Standard_True;
1100         break;
1101       }
1102     }
1103     if(!FacRevolInfini)
1104       BRepBndLib::Add(theSFrom,Box);
1105   }
1106   if(!theSUntil.IsNull()) 
1107   {
1108     Standard_Boolean FacRevolInfini = Standard_False;
1109     TopExp_Explorer exp;
1110     exp.Init(theSUntil, TopAbs_EDGE);
1111     for(; exp.More(); exp.Next()) 
1112     {
1113       TopExp_Explorer exp1;
1114       exp1.Init(exp.Current(), TopAbs_VERTEX);
1115       if(!exp1.More()) 
1116       {
1117         FacRevolInfini = Standard_True;
1118         break;
1119       }
1120     }
1121     if(!FacRevolInfini)
1122       BRepBndLib::Add(theSUntil,Box);
1123   }
1124
1125   Standard_Real c[6];
1126
1127   Box.Get(c[0],c[2],c[4],c[1],c[3],c[5]);
1128   Standard_Real parmin=c[0], parmax = c[0];
1129   for(Standard_Integer i = 0 ; i < 6; i++) {
1130     if(c[i] > parmax) parmax = c[i];
1131     if(c[i] < parmin ) parmin = c[i];    
1132   }
1133 //#ifndef DEB
1134   Standard_Real Height = fabs(2.*(parmax - parmin));
1135 //#else
1136 //  Standard_Real Height = abs(2.*(parmax - parmin));
1137 //#endif
1138   return(Height);
1139 }
1140
1141
1142 //=======================================================================
1143 //function : SensOfPrism
1144 //purpose  : Direction of the prism depending on the shape Until
1145 //=======================================================================
1146 Standard_Integer SensOfPrism(const Handle(Geom_Curve) C,
1147                              const TopoDS_Shape& Until)
1148 {
1149   LocOpe_CSIntersector ASI1(Until);
1150   TColGeom_SequenceOfCurve scur;
1151   scur.Append(C);
1152   ASI1.Perform(scur);
1153   Standard_Integer sens = 1;
1154   if(ASI1.IsDone() && ASI1.NbPoints(1) >= 1) {
1155     if(ASI1.Point(1, 1).Parameter() < 0. && 
1156        ASI1.Point(1, ASI1.NbPoints(1)).Parameter() < 0.) {
1157       sens = -1;
1158     }
1159   }
1160   else if(BRepFeat::ParametricBarycenter(Until,C) < 0) {
1161       sens = -1;
1162   }
1163   else {}
1164   return sens;
1165 }
1166
1167 //=======================================================================
1168 //function : MajMap
1169 //purpose  : management of descendants
1170 //=======================================================================
1171
1172 static void MajMap(const TopoDS_Shape& theB,
1173                    const LocOpe_Prism& theP,
1174                    TopTools_DataMapOfShapeListOfShape& theMap, // myMap
1175                    TopoDS_Shape& theFShape,  // myFShape
1176                    TopoDS_Shape& theLShape) // myLShape
1177 {
1178   TopExp_Explorer exp(theP.FirstShape(),TopAbs_WIRE);
1179   if (exp.More()) {
1180     theFShape = exp.Current();
1181     TopTools_ListOfShape thelist2;
1182     theMap.Bind(theFShape, thelist2);
1183     for (exp.Init(theP.FirstShape(),TopAbs_FACE);exp.More();exp.Next()) {
1184       theMap(theFShape).Append(exp.Current());
1185     }
1186   }
1187   
1188   exp.Init(theP.LastShape(),TopAbs_WIRE);
1189   if (exp.More()) {
1190     theLShape = exp.Current();
1191     TopTools_ListOfShape thelist3;
1192     theMap.Bind(theLShape, thelist3);
1193     for (exp.Init(theP.LastShape(),TopAbs_FACE);exp.More();exp.Next()) {
1194       theMap(theLShape).Append(exp.Current());
1195     }
1196   }
1197
1198   for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) {
1199     if (!theMap.IsBound(exp.Current())) {
1200       TopTools_ListOfShape thelist4;
1201       theMap.Bind(exp.Current(), thelist4);
1202       theMap(exp.Current()) = theP.Shapes(exp.Current());
1203     }
1204   }
1205 }
1206
1207
1208 //=======================================================================
1209 //function : MajMap
1210 //purpose  : management of descendants
1211 //=======================================================================
1212
1213 static Handle(Geom_Curve) TestCurve(const TopoDS_Shape& Base,
1214                                     const gp_Vec& V)
1215 {
1216   gp_Pnt bar(0., 0., 0.);
1217   TColgp_SequenceOfPnt spt;
1218   LocOpe::SampleEdges(Base,spt);
1219   for (Standard_Integer jj=1;jj<=spt.Length(); jj++) {
1220     const gp_Pnt& pvt = spt(jj);
1221     bar.ChangeCoord() += pvt.XYZ();
1222   }
1223   bar.ChangeCoord().Divide(spt.Length());
1224   gp_Ax1 newAx(bar,V);
1225   Handle(Geom_Line) theLin = new Geom_Line(newAx);
1226   return theLin;
1227 }
1228
1229
1230
1231
1232 //=======================================================================
1233 //function : ToFuse
1234 //purpose  : face SameDomaine or not
1235 //=======================================================================
1236
1237 Standard_Boolean ToFuse(const TopoDS_Face& F1,
1238                         const TopoDS_Face& F2)
1239 {
1240   if (F1.IsNull() || F2.IsNull()) {
1241     return Standard_False;
1242   }
1243
1244   Handle(Geom_Surface) S1,S2;
1245   TopLoc_Location loc1, loc2;
1246   Handle(Standard_Type) typS1,typS2;
1247   const Standard_Real tollin = Precision::Confusion();
1248   const Standard_Real tolang = Precision::Angular();
1249
1250   S1 = BRep_Tool::Surface(F1,loc1);
1251   S2 = BRep_Tool::Surface(F2,loc2);
1252
1253   typS1 = S1->DynamicType();
1254   typS2 = S2->DynamicType();
1255
1256   if (typS1 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
1257     S1 =  (*((Handle(Geom_RectangularTrimmedSurface)*)&S1))->BasisSurface();
1258     typS1 = S1->DynamicType();
1259   }
1260
1261   if (typS2 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
1262     S2 =  (*((Handle(Geom_RectangularTrimmedSurface)*)&S2))->BasisSurface();
1263     typS2 = S2->DynamicType();
1264   }
1265
1266   if (typS1 != typS2) {
1267     return Standard_False;
1268   }
1269
1270
1271   Standard_Boolean ValRet = Standard_False;
1272   if (typS1 == STANDARD_TYPE(Geom_Plane)) {
1273     S1 = BRep_Tool::Surface(F1);  // to apply the location.
1274     S2 = BRep_Tool::Surface(F2);
1275     gp_Pln pl1( (*((Handle(Geom_Plane)*)&S1))->Pln());
1276     gp_Pln pl2( (*((Handle(Geom_Plane)*)&S2))->Pln());
1277
1278     if (pl1.Position().IsCoplanar(pl2.Position(),tollin,tolang)) {
1279       ValRet = Standard_True;
1280     }
1281   }
1282
1283   return ValRet;
1284 }
1285
1286
1287
1288
1289
1290