0024624: Lost word in license statement in source files
[occt.git] / src / BRepFeat / BRepFeat_MakeRevolutionForm.cxx
1 // Created on: 1997-10-14
2 // Created by: Olga KOULECHOVA
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <BRepFeat_MakeRevolutionForm.ixx>
18
19 #include <BRepFeat.hxx>
20
21 #include <LocOpe.hxx>
22 #include <LocOpe_RevolutionForm.hxx>
23 #include <LocOpe_CSIntersector.hxx>
24 #include <LocOpe_PntFace.hxx>
25 #include <LocOpe_Gluer.hxx>
26 #include <LocOpe_FindEdges.hxx>
27
28 #include <gp_Vec.hxx>
29 #include <gp_Ax1.hxx>
30 #include <gp_Pln.hxx>
31 #include <gp_Lin.hxx>
32 #include <gp_Pnt.hxx>
33
34 #include <gp_Vec2d.hxx>
35 #include <gp_Pnt2d.hxx>
36
37 #include <Geom_Curve.hxx>
38
39 #include <Geom2d_Curve.hxx>
40 #include <Geom2d_Line.hxx>
41
42 #include <Geom_Line.hxx>
43 #include <Geom_Circle.hxx>
44 #include <Geom_Plane.hxx>
45 #include <Geom_Surface.hxx>
46 #include <Geom_CylindricalSurface.hxx>
47 #include <Geom_ConicalSurface.hxx>
48 #include <Geom_ToroidalSurface.hxx>
49 #include <Geom_RectangularTrimmedSurface.hxx>
50
51 #include <Geom_TrimmedCurve.hxx>
52 #include <GeomProjLib.hxx>
53
54 #include <Geom2dAPI_InterCurveCurve.hxx>
55 #include <Geom2dAPI_ExtremaCurveCurve.hxx>
56 #include <Geom2d_Curve.hxx>
57 #include <Geom2d_Curve.hxx>
58
59
60 #include <GeomAPI.hxx>
61 #include <GeomAPI_ProjectPointOnCurve.hxx>
62
63 #include <TColgp_SequenceOfPnt.hxx>
64
65 #include <TColGeom_SequenceOfCurve.hxx>
66
67 #include <TColStd_Array1OfReal.hxx>
68 #include <IntRes2d_IntersectionPoint.hxx>
69
70 #include <BRepTools_WireExplorer.hxx>
71
72 #include <BRep_Tool.hxx>
73 #include <BRep_Builder.hxx>
74
75 #include <TopExp_Explorer.hxx>
76 #include <TopExp.hxx>
77
78 #include <TopTools_MapOfShape.hxx>
79 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
80 #include <TopTools_ListOfShape.hxx>
81 #include <TopTools_ListIteratorOfListOfShape.hxx>
82 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
83 #include <TopTools_MapIteratorOfMapOfShape.hxx>
84 #include <TopOpeBRepBuild_HBuilder.hxx>
85 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
86
87 #include <TColgp_Array1OfPnt.hxx>
88
89 #include <TColGeom_Array1OfCurve.hxx>
90
91 #include <TopoDS.hxx>
92 #include <TopoDS_Shape.hxx>
93 #include <TopoDS_Face.hxx>
94
95 #include <BRepLib_MakeVertex.hxx>
96 #include <BRepLib_MakeEdge.hxx>
97 #include <BRepLib_MakeFace.hxx>
98
99 #include <BRepTools.hxx>
100
101 #include <BRepPrimAPI_MakeBox.hxx>
102 #include <BRepBuilderAPI_MakeFace.hxx>
103
104 #include <BRepAlgo.hxx>
105
106 //modified by NIZNHY-PKV Fri Mar 22 16:56:15 2002
107 //#include <BRepAlgo_Cut.hxx>
108 //#include <BRepAlgo_Section.hxx>
109 //#include <BRepAlgo_Common.hxx>
110 #include <BRepAlgoAPI_Cut.hxx>
111 #include <BRepAlgoAPI_Section.hxx>
112 #include <BRepAlgoAPI_Common.hxx>
113 //modified by NIZNHY-PKV Fri Mar 22 16:56:17 2002 t
114
115 #include <BRepBuilderAPI_Transform.hxx>
116 #include <BRepExtrema_ExtPC.hxx>
117 #include <BRepExtrema_ExtCF.hxx>
118
119 #include <BRepTools_Modifier.hxx>
120 #include <BRepTools_TrsfModification.hxx>
121
122 #include <BRepTopAdaptor_FClass2d.hxx>
123
124 #include <Standard_ConstructionError.hxx>
125
126 #include <Precision.hxx>
127
128
129 #include <ElCLib.hxx>
130 #include <ElSLib.hxx>
131 #include <CSLib.hxx>
132
133 #include <GeomLProp_CLProps.hxx>
134
135 #ifdef DEB
136 extern Standard_Boolean BRepFeat_GettraceFEAT();
137 extern Standard_Boolean BRepFeat_GettraceFEATRIB();
138 #endif
139
140 static void MajMap(const TopoDS_Shape&, // base
141                    const LocOpe_RevolutionForm&,
142                    TopTools_DataMapOfShapeListOfShape&, // myMap
143                    TopoDS_Shape&,  // myFShape
144                    TopoDS_Shape&); // myLShape
145
146 static void SetGluedFaces(const TopTools_DataMapOfShapeListOfShape& theSlmap,
147                           LocOpe_RevolutionForm&,
148                           const TopTools_DataMapOfShapeListOfShape& SlidingMap,
149                           TopTools_DataMapOfShapeShape&);
150
151 //=======================================================================
152 //function : Init
153 //purpose  : 
154 //=======================================================================
155
156 void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
157                                        const TopoDS_Wire& W,
158                                        const Handle(Geom_Plane)& Plane,
159                                        const gp_Ax1& Axis,
160                                        const Standard_Real H1,
161                                        const Standard_Real H2,
162                                        const Standard_Integer Mode,
163                                        Standard_Boolean& Modify)
164
165 #ifdef DEB
166   Standard_Boolean trc = BRepFeat_GettraceFEAT();
167   if (trc) cout << "BRepFeat_MakeRevolutionForm::Init" << endl;
168 #endif
169   Standard_Boolean RevolRib = Standard_True;
170   Done();
171
172 // modify = 0 if it is not required to make sliding
173 //        = 1 if it is intended to try to make sliding
174   Standard_Boolean Sliding = Modify;
175
176   myAxe = Axis;
177   Handle(Geom_Line) Line = new Geom_Line(Axis); 
178   Standard_Real LineFirst, LineLast;
179   
180   LocOpe_CSIntersector ASI(Sbase);
181   TColGeom_SequenceOfCurve scur;
182   scur.Clear();
183   scur.Append(Line);
184   ASI.Perform(scur);
185   if(ASI.IsDone() && ASI.NbPoints(1) >= 2) {
186     LineLast = ASI.Point(1, ASI.NbPoints(1)).Parameter();
187     LineFirst = ASI.Point(1, 1).Parameter();
188   }
189   else {
190     LineFirst = RealFirst();
191     LineLast = RealLast();
192   }
193   
194   Handle(Geom2d_Curve) ln2d = GeomAPI::To2d(Line, Plane->Pln());
195   
196   TopExp_Explorer exx;
197   Standard_Real Rad = RealLast();
198   
199   exx.Init(W, TopAbs_EDGE);
200   for(; exx.More(); exx.Next()) {
201     const TopoDS_Edge& e = TopoDS::Edge(exx.Current());
202     Standard_Real f, l;
203     Handle(Geom_Curve) c = BRep_Tool::Curve(e, f, l);
204     Handle(Geom2d_Curve) c2d = GeomAPI::To2d(c, Plane->Pln());
205     Geom2dAPI_ExtremaCurveCurve extr(ln2d, c2d, LineFirst, LineLast,f,l);
206     Quantity_Length L = RealLast();
207     if(extr.NbExtrema() >= 1) {
208       L = extr.LowerDistance();
209     }
210     gp_Pnt p1 = c->Value(f);
211     gp_Pnt p2 = c->Value(l);
212     GeomAPI_ProjectPointOnCurve proj1(p1, Line);
213     GeomAPI_ProjectPointOnCurve proj2(p2, Line);
214     if(proj1.NbPoints() < 1 || proj2.NbPoints() < 1) {
215 #ifdef DEB
216       if (trc) cout << " No projection points" << endl;
217 #endif
218       myStatusError = BRepFeat_NoProjPt;
219       NotDone();
220       return;
221     }
222     Standard_Real par1 = proj1.Distance(1);
223     Standard_Real par2 = proj2.Distance(1);
224     Standard_Real Par  = Min(par1, par2);
225     if(Par<L) L = Par;
226     if(L<Rad && L > 0.) Rad = L;
227   }
228   
229   Standard_Real height = Min(H1, H2);
230   
231   if(Rad <= height) Rad = height + 0.01*height;  
232   
233   myAngle1 = asin(H1/Rad) + M_PI/10.;
234   myAngle2 = asin(H2/Rad) + M_PI/10.;
235   
236   if((myAngle1 - M_PI/2) > Precision::Confusion())
237     myAngle1 = M_PI/2;
238   if((myAngle2 - M_PI/2) > Precision::Confusion())
239     myAngle2 = M_PI/2;
240   
241   mySkface.Nullify();
242   myPbase.Nullify();
243
244   if(Mode == 0) 
245     myFuse   = Standard_False;
246   else // if(Mode == 1) 
247     myFuse   = Standard_True;
248 #ifdef DEB
249   if (trc) {
250     if (myFuse)  cout << " Fuse" << endl;
251     if (!myFuse)  cout << " Cut" << endl;
252   }
253 #endif
254
255 // ---Determination Tolerance : tolerance max on parameters
256   myTol = Precision::Confusion();
257   
258   exx.Init(W, TopAbs_VERTEX);
259   for(; exx.More(); exx.Next()) {
260     const Standard_Real& tol = BRep_Tool::
261       Tolerance(TopoDS::Vertex(exx.Current()));
262     if(tol > myTol) myTol = tol;
263   }
264   
265   exx.Init(Sbase, TopAbs_VERTEX);
266   for(; exx.More(); exx.Next()) {
267     const Standard_Real& tol = BRep_Tool::
268       Tolerance(TopoDS::Vertex(exx.Current()));
269     if(tol > myTol) myTol = tol;
270   }
271
272   TopoDS_Shape aLocalShape = W.Oriented(TopAbs_FORWARD);
273   myWire = TopoDS::Wire(aLocalShape);
274 //  myWire = TopoDS::Wire(W.Oriented(TopAbs_FORWARD));
275   myPln = Plane;
276   myHeight1 = H1;
277   myHeight2 = H2;
278   
279   mySbase  = Sbase;
280   mySlface.Clear();
281   myShape.Nullify();
282   myMap.Clear();
283   myFShape.Nullify();
284   myLShape.Nullify();
285
286 // ---Calculate bounding box
287   BRep_Builder BB;
288   
289   TopTools_ListOfShape theList;  
290   
291   TopoDS_Shape U;
292   U.Nullify();
293   gp_Pnt FirstCorner, LastCorner;
294   Standard_Real bnd = HeightMax(mySbase, U, FirstCorner, LastCorner);
295   myBnd = bnd;
296   
297   BRepPrimAPI_MakeBox Bndbox(FirstCorner, LastCorner);
298   TopoDS_Solid BndBox = Bndbox.Solid();
299
300
301 // ---Construction of the working plane face (section bounding box)
302   BRepLib_MakeFace PlaneF(myPln->Pln(), -6.*myBnd, 
303                           6.*myBnd, -6.*myBnd, 6.*myBnd);
304   TopoDS_Face PlaneFace = TopoDS::Face(PlaneF.Shape());
305   
306   //modified by NIZNHY-PKV Fri Mar 22 16:52:26 2002 f
307   //BRepAlgo_Common PlaneS(BndBox, PlaneFace);
308   BRepAlgoAPI_Common PlaneS(BndBox, PlaneFace);
309   //modified by NIZNHY-PKV Fri Mar 22 16:52:31 2002 t
310   TopExp_Explorer EXP;
311   TopoDS_Shape PlaneSect = PlaneS.Shape();
312   EXP.Init(PlaneSect, TopAbs_WIRE);
313   TopoDS_Wire www = TopoDS::Wire(EXP.Current());
314   BRepLib_MakeFace Bndface(myPln->Pln(), www, Standard_True);
315   TopoDS_Face BndFace = TopoDS::Face(Bndface.Shape());
316
317
318 // ---Find base faces of the rib    
319   TopoDS_Edge FirstEdge, LastEdge;
320   TopoDS_Face FirstFace, LastFace;
321   TopoDS_Vertex FirstVertex, LastVertex;
322   
323   Standard_Boolean OnFirstFace = Standard_False;
324   Standard_Boolean OnLastFace = Standard_False;
325   Standard_Boolean PtOnFirstEdge = Standard_False;
326   Standard_Boolean PtOnLastEdge = Standard_False;
327   TopoDS_Edge OnFirstEdge, OnLastEdge;
328   OnFirstEdge.Nullify();
329   OnLastEdge.Nullify();
330
331   Standard_Boolean Data = ExtremeFaces(RevolRib, myBnd, myPln, FirstEdge, LastEdge, 
332                                        FirstFace, LastFace, FirstVertex, 
333                                        LastVertex, OnFirstFace, OnLastFace,
334                                        PtOnFirstEdge, PtOnLastEdge,
335                                        OnFirstEdge, OnLastEdge);
336   
337   if(!Data) {
338 #ifdef DEB
339     if (trc) cout << " No Extreme faces" << endl;
340 #endif
341     myStatusError = BRepFeat_NoExtFace;
342     NotDone();
343     return;
344   }
345
346
347 // ---Proofing Point for the side of the wire to be filled - material side
348   gp_Pnt CheckPnt = CheckPoint(FirstEdge, bnd/10., myPln);
349   
350 //  Standard_Real f, l;
351
352 // ---Control sliding valid
353 // Many cases when the sliding is abandoned
354   Standard_Integer Concavite = 3;  // a priori the profile is not concave
355   
356   myFirstPnt = BRep_Tool::Pnt(FirstVertex);
357   myLastPnt  = BRep_Tool::Pnt(LastVertex);
358
359 // SliList : list of faces concerned by the rib
360   TopTools_ListOfShape SliList;
361   SliList.Append(FirstFace);
362   
363   if(Sliding) {    // sliding
364 #ifdef DEB
365     if (trc) cout << " Sliding" << endl;
366 #endif
367     Handle(Geom_Surface) s = BRep_Tool::Surface(FirstFace);
368     if (s->DynamicType() == 
369         STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
370       s = Handle(Geom_RectangularTrimmedSurface)::
371         DownCast(s)->BasisSurface();
372     }
373     if(s->DynamicType() != STANDARD_TYPE(Geom_Plane) && 
374        s->DynamicType() != STANDARD_TYPE(Geom_CylindricalSurface) &&
375        s->DynamicType() != STANDARD_TYPE(Geom_ConicalSurface) &&
376        s->DynamicType() != STANDARD_TYPE(Geom_ToroidalSurface)) 
377       Sliding = Standard_False;
378   }
379
380   if(Sliding) {     // sliding
381     Handle(Geom_Surface) ss = BRep_Tool::Surface(LastFace);
382     if (ss->DynamicType() == 
383         STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
384       ss = Handle(Geom_RectangularTrimmedSurface)::
385         DownCast(ss)->BasisSurface();
386     }
387     if(ss->DynamicType() != STANDARD_TYPE(Geom_Plane) && 
388        ss->DynamicType() != STANDARD_TYPE(Geom_CylindricalSurface) &&
389        ss->DynamicType() != STANDARD_TYPE(Geom_ConicalSurface) &&
390        ss->DynamicType() != STANDARD_TYPE(Geom_ToroidalSurface)) 
391       Sliding = Standard_False;
392   }
393
394 // Control only start and end points no control at the middle to improve
395 // If make a control between Surface and segment 2 points limited
396 // -> too expensive - to improve  
397   //gp_Pnt FirstCenter, LastCenter;
398   gp_Circ FirstCircle, LastCircle;
399   Handle(Geom_Curve) FirstCrv, LastCrv;
400   
401   if(Sliding) {    // sliding
402     GeomAPI_ProjectPointOnCurve proj(myFirstPnt, Line);
403     if(proj.NbPoints() < 1) {
404 #ifdef DEB
405       if (trc) cout << " No First Point projection" << endl;
406 #endif
407       myStatusError = BRepFeat_NoProjPt;
408       NotDone();
409       return;
410     }
411     Standard_Real FirstRayon = proj.Distance(1);
412     gp_Pnt FirstCenter = proj.Point(1);
413     
414     GeomAPI_ProjectPointOnCurve proj1(myLastPnt, Line);
415     if(proj.NbPoints() < 1) {
416 #ifdef DEB
417       if (trc) cout << " No Last Point projection" << endl;
418 #endif
419       myStatusError = BRepFeat_NoProjPt;
420       NotDone();
421       return;
422     }
423     Standard_Real LastRayon = proj1.Distance(1);
424     gp_Pnt LastCenter = proj1.Point(1);
425     
426     gp_Vec axv(myAxe.Direction());
427     gp_Ax2 ax2(FirstCenter, axv);
428     gp_Ax2 ax2p(LastCenter, axv);
429     gp_Circ theFC(ax2, FirstRayon);
430     gp_Circ theLC(ax2p, LastRayon);
431     
432     gp_Pnt RFirstPnt1 = myFirstPnt.Rotated(myAxe, myAngle1);
433     gp_Pnt RLastPnt1 = myLastPnt.Rotated(myAxe, myAngle1);
434     gp_Pnt RFirstPnt2 = myFirstPnt.Rotated(myAxe, -myAngle2);
435     gp_Pnt RLastPnt2 = myLastPnt.Rotated(myAxe, -myAngle2);
436     
437     BRep_Builder Bu;
438     TopoDS_Vertex v1, v2, v3, v4;
439     Bu.MakeVertex(v1, RFirstPnt2, Precision::Confusion());
440     Bu.MakeVertex(v2, RFirstPnt1, Precision::Confusion());
441     Bu.MakeVertex(v3, RLastPnt2, Precision::Confusion());
442     Bu.MakeVertex(v4, RLastPnt1, Precision::Confusion());
443     
444     BRepLib_MakeEdge ee1(theFC, v1, v2);
445     BRepLib_MakeEdge ee2(theLC, v3, v4);
446     
447     if(Sliding && !PtOnFirstEdge) {
448       BRepExtrema_ExtCF ext1(TopoDS::Edge(ee1.Shape()), FirstFace);
449       if(ext1.NbExt() < 1 || ext1.SquareDistance(1) > Precision::SquareConfusion())
450         Sliding = Standard_False;
451     }
452     if(Sliding && !PtOnLastEdge) {
453       BRepExtrema_ExtCF ext2(ee2, LastFace); // ExtCF : curves and surfaces
454       if(ext2.NbExt() < 1 || ext2.SquareDistance(1) > Precision::SquareConfusion())
455         Sliding = Standard_False;
456     }
457     if(Sliding && PtOnFirstEdge) {
458       Standard_Real f, l;
459       FirstCrv = BRep_Tool::Curve(OnFirstEdge, f, l);
460       if(FirstCrv->DynamicType() != STANDARD_TYPE(Geom_Circle)) 
461         Sliding = Standard_False;
462       else {
463         Handle(Geom_Circle) C1 = Handle(Geom_Circle)::DownCast(FirstCrv);
464         gp_Circ Circ = C1->Circ();
465         FirstCircle = Circ;
466         gp_Ax1 circax = FirstCircle.Axis();
467         if(!circax.IsCoaxial(myAxe, Precision::Confusion(), 
468                              Precision::Confusion())) 
469           Sliding = Standard_False;
470         else {
471 //#ifndef DEB
472           if(fabs(FirstCircle.Radius()-FirstRayon) >=
473 //#else
474 //        if(abs(FirstCircle.Radius()-FirstRayon) >=
475 //#endif
476              Precision::Confusion()) 
477             Sliding = Standard_False;
478         }       
479       }
480     }
481     
482     if(Sliding && PtOnLastEdge) {
483       Standard_Real f, l;
484       LastCrv = BRep_Tool::Curve(OnLastEdge, f, l);
485       if(LastCrv->DynamicType() != STANDARD_TYPE(Geom_Circle)) 
486         Sliding = Standard_False;
487       else {
488         Handle(Geom_Circle) C1 = Handle(Geom_Circle)::DownCast(LastCrv);
489         gp_Circ Circ = C1->Circ();
490         LastCircle = Circ;
491         gp_Ax1 circax = LastCircle.Axis();
492         if(!circax.IsCoaxial(myAxe, Precision::Confusion(), 
493                              Precision::Confusion())) 
494           Sliding = Standard_False;
495         else {
496           Standard_Real rad = LastCircle.Radius();
497 //#ifndef DEB
498           if(fabs(rad - LastRayon) >= Precision::Confusion()) { 
499 //#else
500 //        if(abs(rad - LastRayon) >= Precision::Confusion()) { 
501 //#endif
502             Sliding = Standard_False;
503           }     
504         }
505       }
506     }
507   }
508
509
510 // Construct a great profile that goes till the bounding box
511 // -> by tangency with first and last edge of the Wire
512 // -> by normals to base faces : statistically better
513 // Intersect everythin to find the final profile
514
515
516 // ---case of sliding : construction of the face profile
517   if(Sliding) {
518 #ifdef DEB
519     if (trc) cout << " still Sliding" << endl;
520 #endif
521     TopoDS_Face Prof;
522     Standard_Boolean ProfileOK;
523     ProfileOK = SlidingProfile(Prof,RevolRib,myTol,Concavite,myPln,BndFace,CheckPnt,
524                                FirstFace,LastFace,FirstVertex,LastVertex,
525                                FirstEdge,LastEdge);
526
527     if (!ProfileOK) {
528 #ifdef DEB
529       cout << "Not computable" << endl;
530       if (trc) cout << "Face profile not computable" << endl;
531 #endif
532       myStatusError = BRepFeat_NoFaceProf;
533       NotDone();
534       return;
535     }
536
537
538 // ---Propagation on faces of the initial shape
539 // to find the faces concerned by the rib
540     Standard_Boolean falseside = Standard_True;
541     Sliding = Propagate(SliList, Prof, myFirstPnt, myLastPnt, falseside);
542 // Control if there is everything required to have the material at the proper side
543     if(falseside == Standard_False) {
544 #ifdef DEB
545       cout << " Verify plane and wire orientation" << endl;
546 #endif
547       myStatusError = BRepFeat_FalseSide;
548       NotDone();
549       return;
550     }
551   }
552
553
554 // ---Generation of the base profile of the rib
555
556   TopoDS_Wire w;
557   BB.MakeWire(w);
558   TopoDS_Edge thePreviousEdge;
559   TopoDS_Vertex theFV;
560   thePreviousEdge.Nullify();
561
562 // counter of the number of edges to fill the map
563   Standard_Integer counter = 1;
564
565 // ---case of sliding 
566   if(Sliding && !myListOfEdges.IsEmpty()) {
567     BRepTools_WireExplorer EX1(myWire);
568     for(; EX1.More(); EX1.Next()) {
569       const TopoDS_Edge& E = EX1.Current();
570       if(!myLFMap.IsBound(E)) {
571         TopTools_ListOfShape theTmpList;
572         myLFMap.Bind(E, theTmpList);
573       }      
574       if(E.IsSame(FirstEdge)) {
575         Standard_Real f, l;
576         Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l);
577         gp_Pnt pt;
578         if(!FirstEdge.IsSame(LastEdge)) {
579           pt = BRep_Tool::Pnt(TopExp::LastVertex(E,Standard_True)); 
580         }
581         else {
582           pt = myLastPnt;
583           Standard_Real fpar = IntPar(cc, myFirstPnt);
584           Standard_Real lpar = IntPar(cc, pt);
585           Handle(Geom_Curve) ccc;
586           if(fpar > lpar) {
587             ccc = Handle(Geom_Curve)::DownCast(cc->Reversed());
588             cc = ccc;
589           }
590         }
591         TopoDS_Edge ee1;
592         if(thePreviousEdge.IsNull()) {
593           BRepLib_MakeVertex v1(myFirstPnt);
594           BRepLib_MakeVertex v2(pt);      
595           BRepLib_MakeEdge e(cc, v1, v2);
596           ee1 = TopoDS::Edge(e.Shape());
597         } 
598         else {
599           const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
600           BRepLib_MakeVertex v2(pt);
601           
602           BRepLib_MakeEdge e(cc, v1, v2);
603           ee1 = TopoDS::Edge(e.Shape());
604         }
605         TopoDS_Shape aLocalShape = ee1.Oriented(E.Orientation());
606         ee1 = TopoDS::Edge(aLocalShape);
607 //      ee1 = TopoDS::Edge(ee1.Oriented(E.Orientation()));
608         if(counter == 1) theFV = TopExp::FirstVertex(ee1,Standard_True);
609         myLFMap(E).Append(ee1);
610         BB.Add(w, ee1);
611         thePreviousEdge = ee1;
612         counter++;
613         EX1.Next();
614         break;
615       }
616     }
617
618 // Case of several edges
619     if(!FirstEdge.IsSame(LastEdge)) {
620       for(; EX1.More(); EX1.Next()) {
621         const TopoDS_Edge& E = EX1.Current();
622         if(!myLFMap.IsBound(E)) {
623           TopTools_ListOfShape thelist1;
624           myLFMap.Bind(E, thelist1);
625         }      
626         theList.Append(E);
627         Standard_Real f, l;
628         if(!E.IsSame(LastEdge)) {
629           Handle(Geom_Curve) ccc = BRep_Tool::Curve(E, f, l);
630           TopoDS_Vertex v1, v2;
631           if(!thePreviousEdge.IsNull()) {
632             v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
633             v2 = TopExp::LastVertex(E,Standard_True);
634           }
635           else {
636 //          v1 = TopExp::LastVertex(E,Standard_True);
637             v1 = TopExp::FirstVertex(E,Standard_True);
638             v2 = TopExp::LastVertex(E,Standard_True);
639           }
640           BRepLib_MakeEdge E1(ccc, v1, v2);
641           TopoDS_Edge E11 = TopoDS::Edge(E1.Shape());
642           TopoDS_Shape aLocalShape = E11.Oriented(E.Orientation());
643           E11 = TopoDS::Edge(aLocalShape);
644 //        E11 = TopoDS::Edge(E11.Oriented(E.Orientation()));
645           thePreviousEdge = E11;
646           myLFMap(E).Append(E11);
647           BB.Add(w, E11);
648           if(counter == 1) theFV = TopExp::FirstVertex(E11,Standard_True);
649           counter++;
650         }
651         else {
652           Standard_Real f, l;
653           Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l);
654           gp_Pnt pf = BRep_Tool::Pnt(TopExp::FirstVertex(E,Standard_True));
655           gp_Pnt pl = myLastPnt;
656           TopoDS_Edge ee;
657           if(thePreviousEdge.IsNull()) {
658             BRepLib_MakeEdge e(cc, pf , pl); 
659             ee = TopoDS::Edge(e.Shape());
660           }
661           else {
662             const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
663             BRepLib_MakeVertex v2(pl);
664             BRepLib_MakeEdge e(cc, v1, v2);
665             ee = TopoDS::Edge(e.Shape());
666           }
667           TopoDS_Shape aLocalShape = ee.Oriented(E.Orientation());
668           ee = TopoDS::Edge(aLocalShape);
669 //        ee = TopoDS::Edge(ee.Oriented(E.Orientation()));
670           BB.Add(w, ee);
671           myLFMap(E).Append(ee);
672           if(counter == 1) theFV = TopExp::FirstVertex(ee,Standard_True);
673           thePreviousEdge = ee;
674           counter++;
675           break;
676         }
677       }
678     }
679     
680     TopTools_ListIteratorOfListOfShape it(myListOfEdges);
681     Standard_Boolean FirstOK = Standard_False;
682     Standard_Boolean LastOK = Standard_False;
683     
684     gp_Pnt theLastPnt = myLastPnt;
685     Standard_Integer sens = 0;
686     TopoDS_Edge theEdge, theLEdge, theFEdge;
687     Standard_Integer counter1 = counter;
688     TopTools_ListOfShape NewListOfEdges;
689     NewListOfEdges.Clear();
690     while (!FirstOK) {
691       const TopoDS_Edge& edg = TopoDS::Edge(it.Value());
692       gp_Pnt fp, lp;
693       Standard_Real f, l;
694       Handle(Geom_Curve) ccc = BRep_Tool::Curve(edg, f, l);
695       Handle(Geom_TrimmedCurve) cc = new Geom_TrimmedCurve(ccc, f, l);
696       if ( edg.Orientation() == TopAbs_REVERSED) cc->Reverse();
697       
698       fp = cc->Value(cc->FirstParameter());
699       lp = cc->Value(cc->LastParameter());
700       Standard_Real dist = fp.Distance(theLastPnt);
701       if(dist <= myTol) {
702         sens = 1;
703         LastOK = Standard_True;
704       }
705       else {
706         dist = lp.Distance(theLastPnt);
707         if(dist <= myTol) {
708           sens = 2;
709           LastOK = Standard_True;
710           cc->Reverse();
711         }
712       }
713       Standard_Integer FirstFlag = 0;
714       if(sens==1 && lp.Distance(myFirstPnt) <= myTol) {
715         FirstOK = Standard_True;
716         FirstFlag = 1;
717       }
718       else if(sens==2 && fp.Distance(myFirstPnt) <= myTol) {
719         FirstOK = Standard_True;
720         FirstFlag = 2;
721       }
722       
723       if (LastOK) {
724         TopoDS_Edge eeee;
725         Standard_Real fpar = cc->FirstParameter();
726         Standard_Real lpar = cc->LastParameter();
727         if(!FirstOK) {
728           if(thePreviousEdge.IsNull()) {
729             BRepLib_MakeEdge e(cc, fpar, lpar);
730             eeee = TopoDS::Edge(e.Shape());
731           }
732           else {
733             const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
734             BRepLib_MakeVertex v2(cc->Value(lpar));
735             BRepLib_MakeEdge e(cc, v1, v2);
736             eeee = TopoDS::Edge(e.Shape());
737           }
738         }
739         else {
740           if(thePreviousEdge.IsNull()) {
741             BRepLib_MakeVertex v1(cc->Value(fpar)); 
742             BRepLib_MakeEdge e(cc, v1, theFV);
743             eeee = TopoDS::Edge(e.Shape());
744           }
745           else {
746             const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
747             BRepLib_MakeEdge e(cc, v1, theFV);
748             eeee = TopoDS::Edge(e.Shape());
749           }
750         }
751
752         thePreviousEdge = eeee;
753         BB.Add(w, eeee);
754         if(counter == 1) theFV = TopExp::FirstVertex(eeee,Standard_True);
755         counter1++;
756         NewListOfEdges.Append(edg);
757         theEdge = eeee;
758
759         if(dist <= myTol) 
760           theFEdge = edg;
761         theLastPnt = BRep_Tool::Pnt(TopExp::LastVertex(theEdge,Standard_True));
762       }
763
764       if(FirstFlag == 1) {
765         theLEdge = edg;
766       }
767       else if(FirstFlag == 2) {
768         theLEdge = theEdge;
769       }
770
771       if(LastOK) {
772         it.Initialize(myListOfEdges);
773         LastOK = Standard_False;
774       }
775       else if(it.More()) it.Next();
776       else {
777         Sliding = Standard_False;
778         break;
779       } 
780       sens = 0;
781     }
782     
783     
784     TopTools_DataMapOfShapeListOfShape SlidMap;
785     SlidMap.Clear();
786     
787     if(Sliding && counter1 > counter) {
788       TopTools_ListIteratorOfListOfShape it;
789       TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm;
790       TopExp_Explorer EX2(w, TopAbs_EDGE);
791       Standard_Integer ii = 0;
792       for(; EX2.More(); EX2.Next()) {
793         const TopoDS_Edge& E = TopoDS::Edge(EX2.Current());
794         ii++;   
795         if(ii >= counter && ii <= counter1) {
796           it.Initialize(NewListOfEdges);
797           Standard_Integer jj = 0;
798           for(; it.More(); it.Next()) {
799             const TopoDS_Edge& e2 = TopoDS::Edge(it.Value());
800             jj++;
801             if(jj== (ii - counter +1)) {          
802               itm.Initialize(mySlface);
803               for(; itm.More(); itm.Next()) {
804                 const TopoDS_Face& fac = TopoDS::Face(itm.Key());
805                 const TopTools_ListOfShape& ledg = itm.Value();
806                 TopTools_ListIteratorOfListOfShape itedg(ledg);
807                 //Standard_Integer iiii = 0;
808                 for(; itedg.More(); itedg.Next()) {
809                   const TopoDS_Edge& e1 = TopoDS::Edge(itedg.Value());
810                   if(e1.IsSame(e2)){
811                     if(!SlidMap.IsBound(fac)) {
812                       TopTools_ListOfShape thelist2;
813                       SlidMap.Bind(fac, thelist2);
814                     }
815                     SlidMap(fac).Append(E);
816                   }
817                 }               
818               }
819             }
820           } 
821         }
822       }
823     }
824     
825     mySlface.Clear();
826     mySlface = SlidMap;
827   }
828
829 // ---Arguments of LocOpe_LinearForm : arguments of the prism
830 // sliding
831   if(Sliding) {
832     TopoDS_Face F;
833     BB.MakeFace(F, myPln, myTol);
834     BB.Add(F, w);
835     mySkface = F;
836     myPbase  = mySkface;
837     mySUntil.Nullify();
838   }
839
840
841 // ---Case without sliding : construction of the face profile  
842   if(!Sliding) {
843 #ifdef DEB
844     if (trc) {
845       if (Modify) cout << " Sliding failure" << endl;
846       cout << " no Sliding" << endl;
847     }
848 #endif
849     TopExp_Explorer explo1(BndFace, TopAbs_WIRE);
850     TopoDS_Wire WWW = TopoDS::Wire(explo1.Current());
851     BRepTools_WireExplorer explo(WWW);
852     BRep_Builder Bu;
853     TopoDS_Wire Wiwiwi;
854     Bu.MakeWire(Wiwiwi);
855     TopoDS_Vertex NewV1, NewV2, LastV, v; 
856     NewV1.Nullify(); NewV2.Nullify(); LastV.Nullify();
857
858     for(; explo.More(); explo.Next()) {
859       const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
860       TopoDS_Vertex v1 = TopExp::FirstVertex(e,Standard_True);
861       TopoDS_Vertex v2 = TopExp::LastVertex(e,Standard_True);
862             
863       Standard_Real f, l;//, t;
864       Handle(Geom_Curve) ln = BRep_Tool::Curve(e, f, l);
865 //      Handle(Geom_Curve) lln = BRep_Tool::Curve(e, f, l);
866 //      Handle(Geom_Curve) ln;
867 //      if(e.Orientation() == TopAbs_REVERSED) {
868 //      ln = Handle(Geom_Curve)::DownCast(lln->Reversed());
869 //      v = v1; v1 = v2; v2= v;
870 //      f = IntPar(ln, BRep_Tool::Pnt(v1));
871 //      l = IntPar(ln, BRep_Tool::Pnt(v2));
872 //      }
873 //      else ln = lln;
874
875       Handle(Geom2d_Curve) l2d = GeomAPI::To2d(ln, Plane->Pln());
876       Geom2dAPI_InterCurveCurve intcc(l2d, ln2d, Precision::Confusion());
877       TopoDS_Vertex VV; VV.Nullify();
878       TopoDS_Edge ee1, ee2;
879
880       if(intcc.NbPoints() > 0) {
881         gp_Pnt2d P = intcc.Point(1);
882         gp_Pnt point;
883         myPln->D0(P.X(), P.Y(), point);
884         Standard_Real par = IntPar(ln, point);
885         if(f <= par && l >= par) {
886           Bu.MakeVertex(VV, point, Precision::Confusion());
887         }
888       }
889       
890       if(VV.IsNull() && NewV1.IsNull()) continue;
891
892       if(!VV.IsNull() && NewV1.IsNull()) {
893         NewV1 = VV;
894         LastV = v2;
895         BRepLib_MakeEdge ee1(NewV1, LastV);
896         Bu.Add(Wiwiwi, ee1); 
897         continue;
898       } 
899
900       if(VV.IsNull() && !NewV1.IsNull()) {
901         BRepLib_MakeEdge ee1(LastV, v2);
902         LastV = v2;
903         Bu.Add(Wiwiwi, e); 
904         continue;
905       } 
906       
907       if(!VV.IsNull() && !NewV1.IsNull()) {
908         NewV2 = VV;
909         BRepLib_MakeEdge ee1(LastV, NewV2);
910         LastV = NewV2;
911         Bu.Add(Wiwiwi, ee1); 
912         BRepLib_MakeEdge ee2(LastV, NewV1);
913         Bu.Add(Wiwiwi, ee2);
914         break;
915       } 
916     }
917     
918     BRepLib_MakeFace newbndface(myPln->Pln(), Wiwiwi, Standard_True);
919     TopoDS_Face NewBndFace = TopoDS::Face(newbndface.Shape());
920
921     BRepTopAdaptor_FClass2d Cl(NewBndFace, Precision::Confusion());
922     Standard_Real paru, parv;
923     ElSLib::Parameters(myPln->Pln(), CheckPnt, paru, parv);
924     gp_Pnt2d checkpnt2d(paru, parv);
925     if(Cl.Perform(checkpnt2d, Standard_True) == TopAbs_OUT) {
926       //modified by NIZNHY-PKV Fri Mar 22 16:52:52 2002 f
927       //BRepAlgo_Cut c(BndFace, NewBndFace);     
928       BRepAlgoAPI_Cut c(BndFace, NewBndFace);     
929       //modified by NIZNHY-PKV Fri Mar 22 16:52:57 2002 t
930       TopExp_Explorer exp(c.Shape(), TopAbs_WIRE);
931       const TopoDS_Wire& w = TopoDS::Wire(exp.Current());
932       // akm 13/02/02 : we know the plane. Why not to use it?
933       // BRepLib_MakeFace ff(w);
934       BRepLib_MakeFace ff(myPln->Pln(), w, Standard_True);
935       NewBndFace = TopoDS::Face(ff.Shape());
936     }
937    
938     
939     if(!BRepAlgo::IsValid(NewBndFace)) {
940 #ifdef DEB
941       cout << "Invalid new bounding face" << endl;
942 #endif
943       myStatusError = BRepFeat_InvShape;
944       NotDone();
945       return;      
946     }
947     
948     BndFace = NewBndFace;
949
950
951     TopoDS_Face Prof;
952     Standard_Boolean ProfileOK;
953     ProfileOK = NoSlidingProfile(Prof,RevolRib,myTol,Concavite,myPln,
954                                  bnd,BndFace,CheckPnt,
955                                  FirstFace,LastFace,FirstVertex,LastVertex,
956                                  FirstEdge,LastEdge,OnFirstFace,OnLastFace);
957
958     if (!ProfileOK) {
959 #ifdef DEB
960       cout << "Not computable" << endl;
961       if (trc) cout << " Face profile not computable" << endl;
962 #endif
963       myStatusError = BRepFeat_NoFaceProf;
964       NotDone();
965       return;
966     }
967
968
969 // ---Propagation on the faces of the initial shape
970 // to find the faces concerned by the rib
971     Standard_Boolean falseside = Standard_True;
972     Propagate(SliList, Prof, myFirstPnt, myLastPnt, falseside);
973 // Control if there is everything required to have the material at the proper side
974     if(falseside == Standard_False) {
975 #ifdef DEB
976       cout << " Verify plane and wire orientation" << endl;
977 #endif
978       myStatusError = BRepFeat_FalseSide;
979       NotDone();
980       return;
981     }
982     
983     mySlface.Clear();
984
985     TopTools_ListIteratorOfListOfShape it;
986     it.Initialize(SliList);
987     
988     TopoDS_Shape comp;
989     
990     BRep_Builder BB;
991     BB.MakeShell(TopoDS::Shell(comp));
992     
993     for(; it.More(); it.Next()) {
994       BB.Add(comp, it.Value());
995     }
996     
997     mySUntil = comp;
998    
999     mySkface = Prof;
1000     myPbase  = Prof;
1001   }
1002
1003   mySliding = Sliding;
1004
1005   TopExp_Explorer exp;
1006   for ( exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
1007     TopTools_ListOfShape thelist3;
1008     myMap.Bind(exp.Current(), thelist3);
1009     myMap(exp.Current()).Append(exp.Current());
1010   }
1011 }
1012
1013
1014
1015 //=======================================================================
1016 //function : Add
1017 //purpose  : add elements of gluing
1018 //=======================================================================
1019
1020 void BRepFeat_MakeRevolutionForm::Add(const TopoDS_Edge& E,
1021                              const TopoDS_Face& F)
1022 {
1023 #ifdef DEB
1024   Standard_Boolean trc = BRepFeat_GettraceFEAT();
1025   if (trc) cout << "BRepFeat_MakeRevolutionForm::Add" << endl;
1026 #endif 
1027   if(mySlface.IsEmpty()) {
1028     TopExp_Explorer exp;
1029     for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
1030       if (exp.Current().IsSame(F)) {
1031         break;
1032       }
1033     }
1034     if (!exp.More()) {
1035       Standard_ConstructionError::Raise();
1036     }
1037   
1038     if (!mySlface.IsBound(F)) {
1039       TopTools_ListOfShape thelist;
1040       mySlface.Bind(F, thelist);
1041     }
1042     TopTools_ListIteratorOfListOfShape itl(mySlface(F));
1043     for (; itl.More();itl.Next()) {
1044       if (itl.Value().IsSame(E)) {
1045         break;
1046       }
1047     }
1048     if (!itl.More()) {
1049       mySlface(F).Append(E);
1050     }
1051   } 
1052 }
1053
1054   
1055
1056 //=======================================================================
1057 //function : Perform
1058 //purpose  : construction
1059 //=======================================================================
1060
1061 void BRepFeat_MakeRevolutionForm::Perform()
1062 {
1063 #ifdef DEB
1064   Standard_Boolean trc = BRepFeat_GettraceFEAT();
1065   if (trc) cout << "BRepFeat_MakeRevolutionForm::Perform()" << endl;
1066 #endif
1067   if(mySbase.IsNull() || mySkface.IsNull() || myPbase.IsNull()) {
1068 #ifdef DEB
1069     if (trc) cout << " Fields not initialized" << endl;
1070 #endif
1071     myStatusError = BRepFeat_NotInitialized;
1072     NotDone();
1073     return;
1074   }
1075
1076   gp_Pnt Pt;
1077
1078   TopExp_Explorer exx(myPbase, TopAbs_VERTEX);
1079   for(; exx.More(); exx.Next()) {
1080     const TopoDS_Vertex& vv = TopoDS::Vertex(exx.Current());
1081     if(!vv.IsNull()) {
1082       Pt = BRep_Tool::Pnt(vv);
1083       break;
1084     }
1085   }
1086
1087   if(myAngle2 != 0) {
1088     gp_Trsf T;
1089     T.SetRotation(myAxe, -myAngle2);
1090     BRepBuilderAPI_Transform trsf(T);
1091     trsf.Perform(myPbase, Standard_False);
1092     TopoDS_Face Pbase = TopoDS::Face(trsf.Shape());
1093     TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iter(myLFMap);
1094     for(; iter.More(); iter.Next()) {
1095       const TopoDS_Shape& e1 = iter.Value().First();
1096       TopExp_Explorer ex1(myPbase, TopAbs_EDGE); 
1097       TopExp_Explorer ex2(Pbase, TopAbs_EDGE);
1098       for(; ex1.More(); ex1.Next()) {
1099         if(ex1.Current().IsSame(e1)) {
1100           myLFMap(iter.Key()).Clear();
1101           myLFMap(iter.Key()).Append(ex2.Current());
1102         }
1103         ex2.Next();       
1104       }
1105     }
1106
1107     TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iter1(mySlface);
1108     for(; iter1.More(); iter1.Next()) {
1109       const TopoDS_Shape& f1 = iter1.Key();
1110       const TopoDS_Shape& e1 = iter1.Value().First();
1111       TopExp_Explorer ex1(myPbase, TopAbs_EDGE); 
1112       TopExp_Explorer ex2(Pbase, TopAbs_EDGE);
1113       for(; ex1.More(); ex1.Next()) {
1114         const TopoDS_Shape& E1 = ex1.Current();
1115         const TopoDS_Shape& E2 = ex2.Current();
1116         if(E1.IsSame(e1)) {
1117           mySlface(f1).Clear();
1118           mySlface(f1).Append(E2);
1119         }
1120         ex2.Next();       
1121       }
1122     }
1123     myPbase = Pbase;
1124     trsf.Perform(mySkface, Standard_False);
1125 // flo : check if it is required to reattributr the field mySkface
1126 //    TopoDS_Face mySkface = TopoDS::Face(trsf.Shape());
1127     mySkface = TopoDS::Face(trsf.Shape());
1128   }
1129
1130   LocOpe_RevolutionForm theForm;
1131   theForm.Perform(myPbase, myAxe, (myAngle1+myAngle2));
1132   TopoDS_Shape VraiForm = theForm.Shape();   // uncut  primitive
1133
1134 // management of descendants
1135   MajMap(myPbase,theForm,myMap,myFShape,myLShape);
1136
1137   myGluedF.Clear();
1138
1139
1140
1141   gp_Pln Pln0 = myPln->Pln();
1142   BRepLib_MakeFace f(Pln0);
1143   
1144
1145   gp_Vec vec1 = myHeight1*Normal(f, Pt);
1146   gp_Vec vec2 = -myHeight2*Normal(f, Pt);
1147
1148   gp_Pln Pln1 = Pln0.Translated(vec1);
1149   gp_Pln Pln2 = Pln0.Translated(vec2);
1150   
1151   BRepLib_MakeFace ff1(Pln1);
1152   BRepLib_MakeFace ff2(Pln2);
1153   TopoDS_Face f1 = TopoDS::Face(ff1.Shape());
1154   TopoDS_Face f2 = TopoDS::Face(ff2.Shape());
1155   BRepFeat::FaceUntil(mySbase, f1);
1156   BRepFeat::FaceUntil(mySbase, f2);
1157
1158   LocOpe_CSIntersector ASI1(f1);
1159   LocOpe_CSIntersector ASI2(f2);
1160
1161   Handle(Geom_Line) normale = new Geom_Line(Pt, vec1);
1162   TColGeom_SequenceOfCurve scur;
1163   scur.Append(normale);
1164
1165   ASI1.Perform(scur);
1166   ASI2.Perform(scur);
1167
1168   if(!ASI1.IsDone() || !ASI2.IsDone() ||
1169      ASI1.NbPoints(1) != 1 || ASI2.NbPoints(1) != 1) {
1170 #ifdef DEB
1171     if (trc) cout << " Intersection failure" << endl;
1172 #endif
1173     myStatusError = BRepFeat_BadIntersect;
1174     NotDone();
1175     return;
1176   }
1177
1178   TopAbs_Orientation Ori1 = ASI1.Point(1,1).Orientation();
1179   TopAbs_Orientation Ori2 = TopAbs::Reverse(ASI2.Point(1,1).Orientation());
1180   TopoDS_Face FF1 = ASI1.Point(1,1).Face();
1181   TopoDS_Face FF2 = ASI2.Point(1,1).Face();
1182
1183   TopoDS_Shape Comp;
1184   BRep_Builder B;
1185   B.MakeCompound(TopoDS::Compound(Comp));
1186   TopoDS_Solid S1 = BRepFeat::Tool(f1,FF1,Ori1);
1187   TopoDS_Solid S2 = BRepFeat::Tool(f2,FF2,Ori2);
1188   if (!S1.IsNull()) B.Add(Comp,S1);
1189   if (!S2.IsNull()) B.Add(Comp,S2);
1190
1191   //modified by NIZNHY-PKV Fri Mar 22 16:53:20 2002 f
1192   //BRepAlgo_Cut trP(VraiForm,Comp);    
1193   BRepAlgoAPI_Cut trP(VraiForm,Comp);    
1194   //modified by NIZNHY-PKV Fri Mar 22 16:53:23 2002 t
1195   // coupe de la nervure par deux plans parallels
1196   TopTools_DataMapOfShapeListOfShape SlidingMap;
1197
1198 // management of descendants
1199
1200   TopTools_DataMapIteratorOfDataMapOfShapeListOfShape it1;
1201   it1.Initialize(myMap);
1202   for(; it1.More(); it1.Next()) {
1203     const TopoDS_Shape& orig = it1.Key();
1204     if(it1.Value().IsEmpty()) continue;
1205     const TopoDS_Shape& sh = it1.Value().First();
1206     exx.Init(VraiForm, TopAbs_FACE);
1207     for(; exx.More(); exx.Next()) {
1208       const TopoDS_Face& fac = TopoDS::Face(exx.Current());
1209       TopExp_Explorer exx1(fac, TopAbs_WIRE);
1210       const TopoDS_Wire& thew = TopoDS::Wire(exx1.Current());
1211       if(thew.IsSame(myFShape)) {
1212         const TopTools_ListOfShape& desfaces = trP.Modified(f2);
1213         myMap(myFShape) = desfaces;
1214         continue;
1215       }
1216       else if(thew.IsSame(myLShape)) {
1217         const TopTools_ListOfShape& desfaces = trP.Modified(f1);
1218         myMap(myLShape) = desfaces;
1219         continue;
1220       }
1221       if(fac.IsSame(sh)) { 
1222         if (trP.IsDeleted(fac)) {
1223         }
1224         else {
1225           const TopTools_ListOfShape& desfaces = trP.Modified(fac);
1226           if(!desfaces.IsEmpty()) {
1227             myMap(orig).Clear();
1228             myMap(orig) = trP.Modified(fac);
1229           }
1230         }
1231       }
1232     }
1233   }
1234
1235   exx.Init(VraiForm, TopAbs_FACE);
1236   for(; exx.More(); exx.Next()) {
1237     const TopoDS_Face& fac = TopoDS::Face(exx.Current());
1238     TopTools_ListOfShape thelist;
1239     SlidingMap.Bind(fac, thelist);
1240     if (trP.IsDeleted(fac)) {
1241     }
1242     else {
1243       const TopTools_ListOfShape& desfaces = trP.Modified(fac);
1244       if(!desfaces.IsEmpty()) 
1245         SlidingMap(fac) = desfaces;
1246       else 
1247         SlidingMap(fac).Append(fac);
1248     }
1249   }
1250
1251
1252 // gestion of faces of sliding
1253   SetGluedFaces(mySlface, theForm, SlidingMap, myGluedF);
1254
1255   VraiForm = trP.Shape();   // primitive cut
1256
1257   if(!myGluedF.IsEmpty()) 
1258     myPerfSelection = BRepFeat_NoSelection;
1259   else 
1260     myPerfSelection = BRepFeat_SelectionSh;
1261
1262   exx.Init(myPbase, TopAbs_EDGE);
1263   for(; exx.More(); exx.Next()) {
1264     const TopoDS_Edge& e = TopoDS::Edge(exx.Current());
1265     if(!myMap.IsBound(e)) {
1266 #ifdef DEB
1267       if (trc) cout << " Sliding face not in Base shape" << endl;
1268 #endif
1269       myStatusError = BRepFeat_IncSlidFace;
1270       NotDone();
1271       return;
1272     }
1273   }
1274
1275   myGShape = VraiForm;
1276
1277   if(!myGluedF.IsEmpty() && !mySUntil.IsNull()) {
1278 #ifdef DEB
1279     cout << "The case is not computable" << endl;
1280     if (trc) cout << " Glued faces not empty and Until shape not null" << endl;
1281 #endif
1282     myStatusError = BRepFeat_InvShape;
1283     NotDone();
1284     return;
1285   }
1286
1287   LFPerform();    // topological reconstruction
1288 }
1289
1290
1291 //=======================================================================
1292 //function : Propagate
1293 //purpose  : propagation on the faces of the inital shape, find faces 
1294 // concerned by the rib
1295 //=======================================================================
1296
1297 Standard_Boolean BRepFeat_MakeRevolutionForm::Propagate(TopTools_ListOfShape& SliList,
1298                                                         const TopoDS_Face& fac,
1299                                                         const gp_Pnt& Firstpnt, 
1300                                                         const gp_Pnt& Lastpnt, 
1301                                                         Standard_Boolean& falseside)
1302 {
1303 #ifdef DEB
1304   Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
1305   if (trc) cout << "BRepFeat_MakeRevolutionForm::Propagate" << endl;
1306 #endif
1307   gp_Pnt Firstpoint = Firstpnt;
1308   gp_Pnt Lastpoint = Lastpnt;
1309
1310   Standard_Boolean result = Standard_True;
1311   TopoDS_Face CurrentFace, saveFace;
1312   CurrentFace = TopoDS::Face(SliList.First());
1313   saveFace = CurrentFace;
1314   //  BRepBuilderAPI_MakeFace fac(myPln);
1315   Standard_Boolean LastOK = Standard_False, FirstOK= Standard_False;
1316   TopoDS_Vertex v1, v2, v3, v4, Vert;
1317   //modified by NIZNHY-PKV Fri Mar 22 16:54:09 2002 f
1318   //BRepAlgo_Section sect (fac, CurrentFace, Standard_False);
1319   BRepAlgoAPI_Section sect (fac, CurrentFace, Standard_False);
1320   //modified by NIZNHY-PKV Fri Mar 22 16:54:14 2002 t
1321   sect.Approximation(Standard_True);
1322   sect.Build();
1323   TopExp_Explorer Ex;
1324   TopoDS_Edge e, e1;
1325   gp_Pnt FP, LP;
1326   Standard_Integer ii = 0;
1327   for (Ex.Init(sect.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) {
1328     ii++;
1329     if(ii==1){
1330       e = TopoDS::Edge(Ex.Current());
1331     }    
1332     else if (ii > 1) {
1333       e1 = TopoDS::Edge(Ex.Current());
1334       break;
1335     }
1336   }
1337   if(e.IsNull()) {
1338     falseside = Standard_False;
1339     return Standard_False;
1340   }
1341   //
1342   //modified by NIZNHY-PKV Tue Apr  2 15:08:23 2002 f
1343   if(!e1.IsNull()) {
1344     Standard_Real aTolV1, aTolV2;
1345     myListOfEdges.Clear();
1346     TopTools_ListOfShape thelist;
1347     mySlface.Bind(CurrentFace, thelist);
1348     mySlface(CurrentFace).Append(e1);
1349     
1350     myListOfEdges.Append(e1);
1351     
1352     v1 = TopExp::FirstVertex(e1,Standard_True);
1353     v2 = TopExp::LastVertex (e1,Standard_True);
1354
1355     FP = BRep_Tool::Pnt(v1);
1356     LP = BRep_Tool::Pnt(v2);
1357
1358     aTolV1=BRep_Tool::Tolerance(v1);
1359     aTolV2=BRep_Tool::Tolerance(v2);
1360
1361     if(FP.Distance(Firstpoint) <= aTolV1 || 
1362        FP.Distance(Lastpoint)  <= aTolV1) {
1363       FirstOK = Standard_True;
1364     }
1365     if(LP.Distance(Firstpoint)<= aTolV2 || 
1366        LP.Distance(Lastpoint) <= aTolV2) {
1367       LastOK = Standard_True;
1368     }
1369     
1370     if(LastOK && FirstOK) {
1371       return result;
1372     }
1373     
1374     else {
1375       myListOfEdges.Clear();
1376     }
1377   }
1378   //modified by NIZNHY-PKV Tue Apr  2 15:08:26 2002 t
1379   //
1380   if(!e1.IsNull()) {
1381     myListOfEdges.Clear();
1382     TopTools_ListOfShape thelist1;    
1383     mySlface.Bind(CurrentFace, thelist1);
1384     mySlface(CurrentFace).Append(e);
1385     
1386     myListOfEdges.Append(e);
1387
1388 //    mySlface.Bind(CurrentFace,TopTools_ListOfShape());
1389     mySlface(CurrentFace).Append(e1);    
1390 //    myListOfEdges.Append(e1);
1391
1392     v1 = TopExp::FirstVertex(e,Standard_True); 
1393     v2 = TopExp::LastVertex(e,Standard_True);
1394     v3 = TopExp::FirstVertex(e1,Standard_True); 
1395     v4 = TopExp::LastVertex(e1,Standard_True);
1396     gp_Pnt p1, p2, p3, p4;
1397     p1 = BRep_Tool::Pnt(v1); FP = p1;
1398     p2 = BRep_Tool::Pnt(v2);  LP = p2;
1399     p3 = BRep_Tool::Pnt(v3);
1400     p4 = BRep_Tool::Pnt(v4);
1401     if(p1.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1)) {
1402       if(p3.Distance(Lastpoint) <= BRep_Tool::Tolerance(v3)) {
1403         FirstOK = Standard_True;
1404         Lastpoint = p4;
1405       } 
1406       else if(p4.Distance(Lastpoint) <= BRep_Tool::Tolerance(v4)) {
1407         FirstOK = Standard_True;
1408         Lastpoint = p3;
1409       } 
1410       else {
1411         e1.Nullify();
1412       }
1413     }
1414     else if(p1.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) {
1415       if(p3.Distance(Firstpoint) <= BRep_Tool::Tolerance(v3)) {
1416         FirstOK = Standard_True;
1417         Firstpoint = p4;
1418       } 
1419       else if(p4.Distance(Firstpoint) <= BRep_Tool::Tolerance(v4)) {
1420         FirstOK = Standard_True;
1421         Firstpoint = p3;
1422       } 
1423       else {
1424         e1.Nullify();
1425       }
1426     }
1427     else if(p2.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2)) {
1428       if(p3.Distance(Lastpoint) <= BRep_Tool::Tolerance(v3)) {
1429         LastOK = Standard_True;
1430         Lastpoint = p4;
1431       } 
1432       else if(p4.Distance(Lastpoint) <= BRep_Tool::Tolerance(v4)) {
1433         LastOK = Standard_True;
1434         Lastpoint = p3;
1435       } 
1436       else {
1437         e1.Nullify();
1438       }
1439     }
1440     else if(p2.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) {
1441       if(p3.Distance(Firstpoint) <= BRep_Tool::Tolerance(v3)) {
1442         LastOK = Standard_True;
1443         Firstpoint = p4;
1444       } 
1445       else if(p4.Distance(Firstpoint) <= BRep_Tool::Tolerance(v4)) {
1446         LastOK = Standard_True;
1447         Firstpoint = p3;
1448       } 
1449       else {
1450         e1.Nullify();
1451       }
1452     }
1453     else {
1454       e = e1;
1455       e1.Nullify();
1456     }
1457   }
1458   if(e1.IsNull()) {
1459     myListOfEdges.Clear();
1460     TopTools_ListOfShape thelist2;    
1461     mySlface.Bind(CurrentFace, thelist2);
1462     mySlface(CurrentFace).Append(e);
1463     
1464     myListOfEdges.Append(e);
1465     
1466     v1 = TopExp::FirstVertex(e,Standard_True);
1467     v2 = TopExp::LastVertex(e,Standard_True);
1468
1469     FP = BRep_Tool::Pnt(v1);
1470     LP = BRep_Tool::Pnt(v2);
1471     
1472     if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1)
1473        || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) {
1474       FirstOK = Standard_True;
1475     }
1476     if(LP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2)
1477        || LP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) {
1478       LastOK = Standard_True;
1479     }
1480     
1481     if(LastOK && FirstOK) {
1482       return result;
1483     }
1484   }
1485   
1486   TopTools_IndexedDataMapOfShapeListOfShape mapedges;
1487   TopExp::MapShapesAndAncestors(mySbase, TopAbs_EDGE, TopAbs_FACE, mapedges);
1488   TopExp_Explorer ex;
1489   TopoDS_Edge FirstEdge;
1490
1491   TopoDS_Vertex Vprevious;  Vprevious.Nullify();
1492   TopoDS_Vertex Vpreprevious;  Vpreprevious.Nullify();
1493
1494   while(!FirstOK) {
1495    // find edge connected to v1:
1496     gp_Pnt pt;
1497     if(!v1.IsNull()) pt= BRep_Tool::Pnt(v1);
1498     gp_Pnt ptprev;
1499     if(!Vprevious.IsNull()) ptprev = BRep_Tool::Pnt(Vprevious);
1500     gp_Pnt ptpreprev;
1501     if(!Vpreprevious.IsNull()) ptpreprev = BRep_Tool::Pnt(Vpreprevious);
1502     
1503     if((!Vprevious.IsNull() && ptprev.Distance(pt) <= myTol) ||
1504        (!Vpreprevious.IsNull() && ptpreprev.Distance(pt) <= myTol)) {
1505       falseside = Standard_False;
1506       return Standard_False;
1507     }
1508
1509     for (ex.Init(CurrentFace, TopAbs_EDGE); ex.More(); ex.Next()) {
1510       const TopoDS_Edge& e = TopoDS::Edge(ex.Current());
1511
1512       BRepExtrema_ExtPC projF(v1, e);
1513
1514       if(projF.IsDone() && projF.NbExt() >=1) {
1515         Standard_Real dist2min = RealLast();
1516         Standard_Integer index = 0;
1517         for (Standard_Integer sol =1 ; sol <= projF.NbExt(); sol++) {
1518           if (projF.SquareDistance(sol) <= dist2min) {
1519             index = sol;
1520             dist2min = projF.SquareDistance(sol);
1521           }
1522         }
1523         if (index != 0) {
1524           if (dist2min <= BRep_Tool::Tolerance(e) * BRep_Tool::Tolerance(e)) {
1525             FirstEdge = e;
1526             break;
1527           }
1528         }
1529       }
1530     }
1531     
1532     const TopTools_ListOfShape& L = mapedges.FindFromKey(FirstEdge);
1533     TopTools_ListIteratorOfListOfShape It(L);
1534
1535     for (; It.More(); It.Next()) {
1536       const TopoDS_Face& FF = TopoDS::Face(It.Value());
1537       if (!FF.IsSame(CurrentFace)) {
1538         CurrentFace = FF;
1539         break;
1540       }
1541     }
1542
1543     //modified by NIZNHY-PKV Fri Mar 22 16:54:28 2002 f
1544     //BRepAlgo_Section sectf (fac, CurrentFace, Standard_False);
1545     BRepAlgoAPI_Section sectf (fac, CurrentFace, Standard_False);
1546     //modified by NIZNHY-PKV Fri Mar 22 16:54:33 2002 t
1547     sectf.Approximation(Standard_True);
1548     sectf.Build();
1549
1550     TopoDS_Edge edg1;
1551     for (Ex.Init(sectf.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) {
1552       edg1 = TopoDS::Edge(Ex.Current());
1553       gp_Pnt ppp1 = BRep_Tool::Pnt(TopExp::FirstVertex(edg1,Standard_True));
1554       gp_Pnt ppp2 = BRep_Tool::Pnt(TopExp::LastVertex(edg1,Standard_True));
1555       if(ppp1.Distance(BRep_Tool::Pnt(v1)) <= BRep_Tool::Tolerance(v1) ||
1556          ppp2.Distance(BRep_Tool::Pnt(v1)) <= BRep_Tool::Tolerance(v1))
1557         break;      
1558     }    
1559
1560     TopTools_ListOfShape thelist3;
1561     mySlface.Bind(CurrentFace, thelist3);
1562     mySlface(CurrentFace).Append(edg1);
1563     myListOfEdges.Append(edg1);
1564
1565     if (!edg1.IsNull()) SliList.Prepend(CurrentFace);
1566     else return Standard_False;
1567
1568     Vert = TopExp::FirstVertex(edg1,Standard_True);
1569     gp_Pnt PP = BRep_Tool::Pnt(Vert);
1570     FP = BRep_Tool::Pnt(v1);
1571     Standard_Real tol = BRep_Tool::Tolerance(edg1);
1572     Standard_Real tol1 = BRep_Tool::Tolerance(v1);
1573     if(tol1 > tol) tol = tol1;
1574     Standard_Real dist = PP.Distance(FP);
1575     if (dist <= tol) {
1576       Vpreprevious = Vprevious;
1577       Vprevious = v1;
1578       v1 = TopExp::LastVertex(edg1,Standard_True);
1579     }
1580     else {
1581       Vpreprevious = Vprevious;
1582       Vprevious = v1;
1583       v1 = Vert;
1584     }
1585
1586     FP = BRep_Tool::Pnt(v1);
1587     
1588     if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1)
1589        || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) {
1590       FirstOK = Standard_True;
1591     }
1592   }
1593
1594   CurrentFace = saveFace;
1595   Vprevious.Nullify();
1596   Vpreprevious.Nullify();
1597
1598   while(!LastOK) {
1599     // find edge connected to v2:
1600     gp_Pnt pt;
1601     if(!v2.IsNull()) pt= BRep_Tool::Pnt(v2);
1602     gp_Pnt ptprev;
1603     if(!Vprevious.IsNull()) ptprev = BRep_Tool::Pnt(Vprevious);
1604     gp_Pnt ptpreprev;
1605     if(!Vpreprevious.IsNull()) ptpreprev = BRep_Tool::Pnt(Vpreprevious);
1606     
1607     if((!Vprevious.IsNull() && ptprev.Distance(pt) <= myTol) ||
1608        (!Vpreprevious.IsNull() && ptpreprev.Distance(pt) <= myTol)) {
1609       falseside = Standard_False;
1610       return Standard_False;
1611     }
1612     
1613     for (ex.Init(CurrentFace, TopAbs_EDGE); ex.More(); ex.Next()) {
1614       const TopoDS_Edge& e = TopoDS::Edge(ex.Current());
1615       BRepExtrema_ExtPC projF(v2, e);
1616
1617       if(projF.IsDone() && projF.NbExt() >=1) {
1618         Standard_Real dist2min = RealLast();
1619         Standard_Integer index = 0;
1620         for (Standard_Integer sol =1 ; sol <= projF.NbExt(); sol++) {
1621           if (projF.SquareDistance(sol) <= dist2min) {
1622             index = sol;
1623             dist2min = projF.SquareDistance(sol);
1624           }
1625         }
1626         if (index != 0) {
1627           if (dist2min <= BRep_Tool::Tolerance(e) * BRep_Tool::Tolerance(e)) {
1628             FirstEdge = e;
1629             break;
1630           }
1631         }
1632       }
1633     }
1634     
1635     const TopTools_ListOfShape& L = mapedges.FindFromKey(FirstEdge);
1636     TopTools_ListIteratorOfListOfShape It(L);
1637
1638     for (; It.More(); It.Next()) {
1639       const TopoDS_Face& FF = TopoDS::Face(It.Value());
1640       if (!FF.IsSame(CurrentFace)) {
1641         CurrentFace = FF;
1642         break;
1643       }
1644     }
1645
1646     ii = 0;
1647  
1648     //modified by NIZNHY-PKV Fri Mar 22 16:54:45 2002 f
1649     //BRepAlgo_Section sectf (fac, CurrentFace, Standard_False);
1650     BRepAlgoAPI_Section sectf (fac, CurrentFace, Standard_False);
1651     //modified by NIZNHY-PKV Fri Mar 22 16:54:52 2002 t
1652     sectf.Approximation(Standard_True);
1653     sectf.Build();
1654
1655     TopoDS_Edge edg2;
1656     for (Ex.Init(sectf.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) {      
1657       edg2 = TopoDS::Edge(Ex.Current());
1658       gp_Pnt ppp1 = BRep_Tool::Pnt(TopExp::FirstVertex(edg2,Standard_True));
1659       gp_Pnt ppp2 = BRep_Tool::Pnt(TopExp::LastVertex(edg2,Standard_True));
1660       if(ppp1.Distance(BRep_Tool::Pnt(v2)) <= BRep_Tool::Tolerance(v2) ||
1661          ppp2.Distance(BRep_Tool::Pnt(v2)) <= BRep_Tool::Tolerance(v2))
1662         break;
1663     }    
1664     TopTools_ListOfShape thelist4;
1665     mySlface.Bind(CurrentFace, thelist4);
1666     mySlface(CurrentFace).Append(edg2);
1667     myListOfEdges.Append(edg2);
1668
1669     if (!edg2.IsNull()) SliList.Append(CurrentFace);
1670     else return Standard_False;
1671
1672     Vert = TopExp::FirstVertex(edg2,Standard_True);
1673     gp_Pnt PP = BRep_Tool::Pnt(Vert);
1674     FP = BRep_Tool::Pnt(v2);
1675     if (PP.Distance(FP)<= BRep_Tool::Tolerance(v2)) {
1676       Vpreprevious = Vprevious;
1677       Vprevious = v2;
1678       v2 = TopExp::LastVertex(edg2,Standard_True);
1679     }
1680     else {
1681       v2 = Vert;
1682     }
1683     FP = BRep_Tool::Pnt(v2);
1684
1685     
1686     if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2)
1687        || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) {
1688       LastOK = Standard_True;
1689     }
1690   }
1691   if(!e1.IsNull())     myListOfEdges.Append(e1);
1692   return result;
1693   
1694 }
1695
1696
1697 //=======================================================================
1698 //function : MajMap
1699 //purpose  : management of descendants
1700 //=======================================================================
1701
1702 static void MajMap(const TopoDS_Shape& theB,
1703                    const LocOpe_RevolutionForm& theP,
1704                    TopTools_DataMapOfShapeListOfShape& theMap, // myMap
1705                    TopoDS_Shape& theFShape,  // myFShape
1706                    TopoDS_Shape& theLShape) // myLShape
1707 {
1708   TopExp_Explorer exp(theP.FirstShape(),TopAbs_WIRE);
1709   if (exp.More()) {
1710     theFShape = exp.Current();
1711     TopTools_ListOfShape thelist;
1712     theMap.Bind(theFShape, thelist);
1713     for (exp.Init(theP.FirstShape(),TopAbs_FACE);exp.More();exp.Next()) {
1714       const TopoDS_Shape& sh = exp.Current();
1715       theMap(theFShape).Append(sh);
1716     }
1717   }
1718   
1719   exp.Init(theP.LastShape(),TopAbs_WIRE);
1720   if (exp.More()) {
1721     theLShape = exp.Current();
1722     TopTools_ListOfShape thelist1;
1723     theMap.Bind(theLShape, thelist1);
1724     for (exp.Init(theP.LastShape(),TopAbs_FACE);exp.More();exp.Next()) {
1725       const TopoDS_Shape& sh = exp.Current();
1726       theMap(theLShape).Append(sh);
1727     }
1728   }
1729
1730   for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) {
1731     if (!theMap.IsBound(exp.Current())) {
1732       TopTools_ListOfShape thelist2;
1733       theMap.Bind(exp.Current(), thelist2);
1734       theMap(exp.Current()) = theP.Shapes(exp.Current());
1735     }
1736   }
1737 }
1738
1739
1740  //=======================================================================
1741 //function : SetGluedFaces
1742 //purpose  : managemnet of sliding faces
1743 //=======================================================================
1744
1745 static void SetGluedFaces(const TopTools_DataMapOfShapeListOfShape& theSlmap,
1746                           LocOpe_RevolutionForm& thePrism,
1747                           const TopTools_DataMapOfShapeListOfShape& SlidingMap,
1748                           TopTools_DataMapOfShapeShape& theMap)
1749 {
1750   // Slidings
1751   TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(theSlmap);
1752   if(!theSlmap.IsEmpty()) {
1753     for (; itm.More(); itm.Next()) {
1754       const TopoDS_Face& fac = TopoDS::Face(itm.Key());
1755       const TopTools_ListOfShape& ledg = itm.Value();
1756       TopTools_ListIteratorOfListOfShape it;
1757       for (it.Initialize(ledg); it.More(); it.Next()) {
1758         const TopTools_ListOfShape& gfac = thePrism.Shapes(it.Value());
1759         if (gfac.Extent() != 1) {
1760 #ifdef DEB
1761           cout << "Pb SetGluedFace" << endl;
1762 #endif
1763         }
1764         TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iterm(SlidingMap);
1765         for(; iterm.More(); iterm.Next()) {
1766           const TopoDS_Face& ff = TopoDS::Face(iterm.Key());
1767           const TopTools_ListOfShape& lfaces = iterm.Value();
1768           if(lfaces.IsEmpty()) continue;
1769           const TopoDS_Face& fff = TopoDS::Face(lfaces.First());
1770           if(gfac.First().IsSame(ff)) theMap.Bind(fff,fac);
1771         }
1772       }
1773     }
1774   }
1775 }
1776