0021762: Integration of new Boolean Operation algorithm to OCCT.
[occt.git] / src / BRepFeat / BRepFeat_MakeLinearForm.cxx
1 // Created on: 1997-04-14
2 // Created by: Olga KOULECHOVA
3 // Copyright (c) 1997-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_MakeLinearForm.ixx>
24
25 #include <BRepFeat.hxx>
26
27 #include <LocOpe.hxx>
28 #include <LocOpe_LinearForm.hxx>
29 #include <LocOpe_Gluer.hxx>
30 #include <LocOpe_FindEdges.hxx>
31
32 #include <gp_Vec.hxx>
33 #include <gp_Pln.hxx>
34 #include <gp_Lin.hxx>
35 #include <gp_Dir.hxx>
36 #include <gp_Pnt.hxx>
37
38 #include <gp_Vec2d.hxx>
39 #include <gp_Pnt2d.hxx>
40
41 #include <Geom_Curve.hxx>
42
43 #include <Geom2d_Curve.hxx>
44 #include <Geom2d_Line.hxx>
45
46 #include <Geom_Plane.hxx>
47 #include <Geom_Surface.hxx>
48 #include <Geom_CylindricalSurface.hxx>
49 #include <Geom_RectangularTrimmedSurface.hxx>
50
51 #include <Geom_TrimmedCurve.hxx>
52 #include <GeomProjLib.hxx>
53
54 #include <Geom2d_Curve.hxx>
55 #include <Geom2d_Curve.hxx>
56
57 #include <TColgp_SequenceOfPnt.hxx>
58
59 #include <TColStd_Array1OfReal.hxx>
60 #include <IntRes2d_IntersectionPoint.hxx>
61
62 #include <BRepTools_WireExplorer.hxx>
63
64 #include <BRep_Tool.hxx>
65 #include <BRep_Builder.hxx>
66
67 #include <TopExp_Explorer.hxx>
68 #include <TopExp.hxx>
69
70 #include <TopTools_MapOfShape.hxx>
71 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
72 #include <TopTools_ListOfShape.hxx>
73 #include <TopTools_ListIteratorOfListOfShape.hxx>
74 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
75 #include <TopTools_MapIteratorOfMapOfShape.hxx>
76 #include <TopOpeBRepBuild_HBuilder.hxx>
77 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
78
79 #include <TColgp_Array1OfPnt.hxx>
80
81 #include <TColGeom_Array1OfCurve.hxx>
82
83 #include <TopoDS.hxx>
84 #include <TopoDS_Shape.hxx>
85 #include <TopoDS_Face.hxx>
86
87 #include <BRepLib_MakeVertex.hxx>
88 #include <BRepLib_MakeEdge.hxx>
89 #include <BRepLib_MakeFace.hxx>
90
91 #include <BRepTools.hxx>
92
93 #include <BRepBuilderAPI.hxx>
94 #include <BRepPrimAPI_MakeBox.hxx>
95 #include <BRepBuilderAPI_MakeFace.hxx>
96
97 //modified by NIZNHY-PKV Fri Mar 22 16:51:33 2002 f
98 //#include <BRepAlgo_Section.hxx>
99 //#include <BRepAlgo_Common.hxx>
100 #include <BRepAlgoAPI_Section.hxx>
101 #include <BRepAlgoAPI_Common.hxx>
102 //modified by NIZNHY-PKV Fri Mar 22 16:51:35 2002 t
103
104 #include <BRepExtrema_ExtPC.hxx>
105 #include <BRepExtrema_ExtPF.hxx>
106 #include <BRepExtrema_ExtCF.hxx>
107
108 #include <BRepTools_Modifier.hxx>
109 #include <BRepTools_TrsfModification.hxx>
110
111 #include <Standard_ConstructionError.hxx>
112
113 #include <Precision.hxx>
114
115 #include <GeomLProp_CLProps.hxx>
116
117 #include <BRepBuilderAPI_Transform.hxx>
118 #include <BRepLib_MakeWire.hxx>
119 //#include <DbgTools.hxx>
120
121 #ifdef DEB
122 extern Standard_Boolean BRepFeat_GettraceFEAT();
123 extern Standard_Boolean BRepFeat_GettraceFEATRIB();
124 #endif
125
126 static void MajMap(const TopoDS_Shape&, // base
127                    const LocOpe_LinearForm&,
128                    TopTools_DataMapOfShapeListOfShape&, // myMap
129                    TopoDS_Shape&,  // myFShape
130                    TopoDS_Shape&); // myLShape
131
132 static void SetGluedFaces(const TopTools_DataMapOfShapeListOfShape& theSlmap,
133                           LocOpe_LinearForm&,
134                           TopTools_DataMapOfShapeShape&);
135
136 //=======================================================================
137 //function : Init
138 //purpose  : 
139 //=======================================================================
140
141 void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase,
142                                    const TopoDS_Wire& W,
143                                    const Handle(Geom_Plane)& Plane,
144                                    const gp_Vec& Direc,
145                                    const gp_Vec& Direc1,
146                                    const Standard_Integer Mode,
147                                    const Standard_Boolean Modify)
148 {
149 #ifdef DEB
150   Standard_Boolean trc = BRepFeat_GettraceFEAT();
151   if (trc) cout << "BRepFeat_MakeLinearForm::Init" << endl;
152 #endif
153   Standard_Boolean RevolRib = Standard_False;
154   Done();
155   myGenerated.Clear();
156   
157 // modify = 0 if there is no intention to make sliding
158 //        = 1 if one tries to make sliding
159   Standard_Boolean Sliding = Modify;
160   myLFMap.Clear();
161
162   myShape.Nullify();
163   myMap.Clear();
164   myFShape.Nullify();
165   myLShape.Nullify();
166   mySbase  = Sbase;
167   mySkface.Nullify();
168   myPbase.Nullify();
169
170   myGShape.Nullify();
171   mySUntil.Nullify();
172   myListOfEdges.Clear();
173   mySlface.Clear();
174
175   TopoDS_Shape aLocalShape = W.Oriented(TopAbs_FORWARD);
176   myWire = TopoDS::Wire(aLocalShape);
177 //  myWire = TopoDS::Wire(W.Oriented(TopAbs_FORWARD));
178   myDir  = Direc;
179   myDir1 = Direc1;
180   myPln  = Plane;
181
182   if(Mode == 0) 
183     myFuse   = Standard_False;
184   else // if(Mode == 1) 
185     myFuse   = Standard_True;
186 #ifdef DEB
187   if (trc) {
188     if (myFuse)  cout << " Fuse" << endl;
189     if (!myFuse)  cout << " Cut" << endl;
190   }
191 #endif
192
193   
194 // ---Determine Tolerance : max tolerance on parameters
195   myTol = Precision::Confusion();
196
197   TopExp_Explorer exx;  
198   exx.Init(myWire, TopAbs_VERTEX);
199   for(; exx.More(); exx.Next()) {
200     const Standard_Real& tol = BRep_Tool::
201       Tolerance(TopoDS::Vertex(exx.Current()));
202     if(tol > myTol) myTol = tol;
203   }
204
205   exx.Init(Sbase, TopAbs_VERTEX);
206   for(; exx.More(); exx.Next()) {
207     const Standard_Real& tol = BRep_Tool::
208       Tolerance(TopoDS::Vertex(exx.Current()));
209     if(tol > myTol) myTol = tol;
210   }
211
212 // ---Control of directions
213 //    the wire should be in the rib
214   gp_Vec nulldir(0, 0, 0);
215   if(!myDir1.IsEqual(nulldir, myTol, myTol)) {
216     Standard_Real ang = myDir1.Angle(myDir);
217     if(ang != M_PI) {
218 #ifdef DEB
219       if (trc) cout << " Directions must be opposite" << endl;
220 #endif
221       myStatusError = BRepFeat_BadDirect;
222       NotDone();
223       return;
224     }
225   }
226   else {
227
228 // Rib is centre in the middle of translation
229 #ifdef DEB
230     if (trc)  cout << " Rib is centre" << endl;
231 #endif
232     const gp_Vec& DirTranslation = (Direc + Direc1) * 0.5;
233     gp_Trsf T;
234     T.SetTranslation(DirTranslation);
235     BRepBuilderAPI_Transform trf(T);
236     trf.Perform(myWire);
237     myWire = TopoDS::Wire(trf.Shape());
238     myDir  = Direc  - DirTranslation;
239     myDir1 = Direc1 - DirTranslation;
240     myPln->Transform(T);
241   }
242
243 // ---Calculate bounding box
244   BRep_Builder BB;
245
246   TopTools_ListOfShape theList;  
247   
248   TopoDS_Shape U;
249   U.Nullify();
250   gp_Pnt FirstCorner, LastCorner;
251   Standard_Real bnd = HeightMax(mySbase, U, FirstCorner, LastCorner);
252   myBnd = bnd;
253
254   BRepPrimAPI_MakeBox Bndbox(FirstCorner, LastCorner);
255   TopoDS_Solid BndBox = Bndbox.Solid();
256
257
258 // ---Construction of the face workplane (section bounding box)
259   BRepLib_MakeFace PlaneF(myPln->Pln(), -6.*myBnd, 
260                           6.*myBnd, -6.*myBnd, 6.*myBnd);
261   TopoDS_Face PlaneFace = TopoDS::Face(PlaneF.Shape());
262
263   //modified by NIZNHY-PKV Fri Mar 22 16:49:28 2002 f
264   //BRepAlgo_Common PlaneS(BndBox, PlaneFace);
265   BRepAlgoAPI_Common PlaneS(BndBox, PlaneFace);
266   //modified by NIZNHY-PKV Fri Mar 22 16:49:39 2002 t  
267   TopExp_Explorer EXP;
268   TopoDS_Shape PlaneSect = PlaneS.Shape();
269   EXP.Init(PlaneSect, TopAbs_WIRE);
270   TopoDS_Wire www = TopoDS::Wire(EXP.Current());
271   BRepLib_MakeFace Bndface(myPln->Pln(), www, Standard_True);
272   TopoDS_Face BndFace = TopoDS::Face(Bndface.Shape());
273
274
275 // ---Find support faces of the rib
276   TopoDS_Edge FirstEdge, LastEdge;
277   TopoDS_Face FirstFace, LastFace;
278   TopoDS_Vertex FirstVertex, LastVertex;
279
280   Standard_Boolean OnFirstFace = Standard_False;
281   Standard_Boolean OnLastFace = Standard_False;
282   Standard_Boolean PtOnFirstEdge = Standard_False;
283   Standard_Boolean PtOnLastEdge = Standard_False;
284   TopoDS_Edge OnFirstEdge, OnLastEdge;
285   OnFirstEdge.Nullify();
286   OnLastEdge.Nullify();
287
288   Standard_Boolean Data = ExtremeFaces(RevolRib, myBnd, myPln, FirstEdge, LastEdge, 
289                                        FirstFace, LastFace, FirstVertex, 
290                                        LastVertex, OnFirstFace, OnLastFace,
291                                        PtOnFirstEdge, PtOnLastEdge,
292                                        OnFirstEdge, OnLastEdge);
293  
294   if(!Data) {
295 #ifdef DEB
296     if (trc) cout << " No Extreme faces" << endl;
297 #endif
298     myStatusError = BRepFeat_NoExtFace;
299     NotDone();
300     return;
301   }
302
303
304 // ---Proofing Point for the side of the wire to be filled - side material
305   gp_Pnt CheckPnt = CheckPoint(FirstEdge, bnd/10., myPln);
306
307 //  Standard_Real f, l;
308
309 // ---Control sliding valuable
310 // Many cases when the sliding is abandoned
311   Standard_Integer Concavite = 3;  // a priori the profile is not concave
312
313   myFirstPnt = BRep_Tool::Pnt(FirstVertex);
314   myLastPnt  = BRep_Tool::Pnt(LastVertex);
315
316 // SliList : list of faces concerned by the rib
317   TopTools_ListOfShape SliList;
318   SliList.Append(FirstFace);
319
320   if(Sliding) {    // sliding
321 #ifdef DEB
322     if (trc) cout << " Sliding" << endl;
323 #endif
324     Standard_Boolean Sliding = Standard_False;
325     Handle(Geom_Surface) s = BRep_Tool::Surface(FirstFace);
326     if (s->DynamicType() == 
327         STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
328       s = Handle(Geom_RectangularTrimmedSurface)::
329         DownCast(s)->BasisSurface();
330     }
331     if(s->DynamicType() == STANDARD_TYPE(Geom_Plane) ||
332        s->DynamicType() == STANDARD_TYPE(Geom_CylindricalSurface)) {
333 // if plane or cylinder : sliding is possible
334       Sliding = Standard_True;
335     }
336   }
337
338 // Control only start and end points
339 // -> no control at the middle - improve
340 // Controle between Surface and segment between 2 limit points
341 // is too expensive - improve
342   if(Sliding) {
343     gp_Pnt p1(myFirstPnt.X()+myDir.X(),myFirstPnt.Y()+myDir.Y(),
344               myFirstPnt.Z()+myDir.Z());
345     BRepLib_MakeEdge ee1(myFirstPnt, p1);
346     BRepExtrema_ExtCF ext1(ee1, FirstFace);
347     if(ext1.NbExt() == 1 && ext1.SquareDistance(1)<=BRep_Tool::Tolerance(FirstFace) * BRep_Tool::Tolerance(FirstFace)) {
348       gp_Pnt p2(myLastPnt.X()+myDir.X(),myLastPnt.Y()+myDir.Y(),
349                 myLastPnt.Z()+myDir.Z());
350       BRepLib_MakeEdge ee2(myLastPnt, p2);
351       BRepExtrema_ExtCF ext2(ee2, LastFace); // ExtCF : curves and surfaces
352       if(ext2.NbExt() == 1 && ext2.SquareDistance(1)<=BRep_Tool::Tolerance(LastFace) * BRep_Tool::Tolerance(LastFace)) {
353         Sliding = Standard_True;
354       }
355       else {
356         Sliding = Standard_False;
357       }      
358     }
359     else {
360       Sliding = Standard_False;
361     }   
362   }
363
364   if(!myDir1.IsEqual(nulldir, Precision::Confusion(), Precision::Confusion())) {
365     if(Sliding) {
366       gp_Pnt p1(myFirstPnt.X()+myDir1.X(),myFirstPnt.Y()+myDir1.Y(),
367                 myFirstPnt.Z()+myDir1.Z());
368       BRepLib_MakeEdge ee1(myFirstPnt, p1);
369       BRepExtrema_ExtCF ext1(ee1, FirstFace);
370       if(ext1.NbExt() == 1 && ext1.SquareDistance(1)<=BRep_Tool::Tolerance(FirstFace) * BRep_Tool::Tolerance(FirstFace)) {
371         gp_Pnt p2(myLastPnt.X()+myDir1.X(),myLastPnt.Y()+myDir1.Y(),
372                   myLastPnt.Z()+myDir1.Z());
373         BRepLib_MakeEdge ee2(myLastPnt, p2);
374         BRepExtrema_ExtCF ext2(ee2, LastFace);
375         if(ext2.NbExt() == 1 && ext2.SquareDistance(1)<=BRep_Tool::Tolerance(LastFace) * BRep_Tool::Tolerance(LastFace)) {
376           Sliding = Standard_True;
377         }
378         else {
379           Sliding = Standard_False;
380         }      
381       }
382       else {
383         Sliding = Standard_False;
384       }   
385     }
386   }
387
388
389 // Construct a great profile that goes till the bounding box
390 // -> by tangency with the first and the last edge of the Wire
391 // -> by normals to the support faces : statistically better
392 // Intersect everything to find the final profile
393
394
395 // ---case of sliding : construction of the profile face 
396   if(Sliding) {
397 #ifdef DEB
398     if (trc) cout << " still Sliding" << endl;
399 #endif
400     TopoDS_Face Prof;
401     Standard_Boolean ProfileOK;
402     ProfileOK = SlidingProfile(Prof,RevolRib,myTol,Concavite,myPln,BndFace,CheckPnt,
403                                FirstFace,LastFace,FirstVertex,LastVertex,
404                                FirstEdge,LastEdge);
405     
406     if (!ProfileOK) {
407 #ifdef DEB
408       cout << "Not computable" << endl;
409       if (trc) cout << "Face profile not computable" << endl;
410 #endif
411       myStatusError = BRepFeat_NoFaceProf;
412       NotDone();
413       return;
414     }
415
416
417 // ---Propagation on faces of the initial shape 
418 // to find the faces concerned by the rib
419     Standard_Boolean falseside = Standard_True;
420     Sliding = Propagate(SliList, Prof, myFirstPnt, myLastPnt, falseside);
421 // Control if there is everything required to have the material at the proper side
422     if(falseside == Standard_False) {
423 #ifdef DEB
424       cout << "Verify plane and wire orientation" << endl;
425 #endif
426       myStatusError = BRepFeat_FalseSide;
427       NotDone();
428       return;
429     }
430   }
431
432
433 // ---Generation of the base of the rib profile 
434
435   TopoDS_Wire w;
436   BB.MakeWire(w);
437   TopoDS_Edge thePreviousEdge;
438   TopoDS_Vertex theFV;
439   thePreviousEdge.Nullify();
440
441 // calculate the number of edges to fill the map
442   Standard_Integer counter = 1;
443
444 // ---case of sliding
445   if(Sliding && !myListOfEdges.IsEmpty()) {
446     BRepTools_WireExplorer EX1(myWire);
447     for(; EX1.More(); EX1.Next()) {
448       const TopoDS_Edge& E = EX1.Current();
449       if(!myLFMap.IsBound(E)) {
450         TopTools_ListOfShape theTmpList;
451         myLFMap.Bind(E, theTmpList );
452       }      
453       if(E.IsSame(FirstEdge)) {
454         Standard_Real f, l;
455         Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l);
456         cc = new Geom_TrimmedCurve(cc, f, l);
457         gp_Pnt pt;
458         if(!FirstEdge.IsSame(LastEdge)) {
459           pt = BRep_Tool::Pnt(TopExp::LastVertex(E,Standard_True)); 
460         }
461         else {
462           pt = myLastPnt;
463           Standard_Real fpar = IntPar(cc, myFirstPnt);
464           Standard_Real lpar = IntPar(cc, pt);
465           Handle(Geom_Curve) ccc;
466           if(fpar > lpar) {
467             ccc = Handle(Geom_Curve)::DownCast(cc->Reversed());
468             cc = ccc;
469           }
470         }
471         TopoDS_Edge ee1;
472         if(thePreviousEdge.IsNull()) {
473           BRepLib_MakeVertex v1(myFirstPnt);
474           BRepLib_MakeVertex v2(pt);      
475           BRepLib_MakeEdge e(cc, v1, v2);
476           ee1 = TopoDS::Edge(e.Shape());
477         } 
478         else {
479           const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
480           BRepLib_MakeVertex v2(pt);
481           
482           BRepLib_MakeEdge e(cc, v1, v2);
483           ee1 = TopoDS::Edge(e.Shape());
484         }
485         TopoDS_Shape aLocalShape = ee1.Oriented(E.Orientation());
486         ee1 = TopoDS::Edge(aLocalShape);
487 //      ee1 = TopoDS::Edge(ee1.Oriented(E.Orientation()));
488         if(counter == 1) theFV = TopExp::FirstVertex(ee1,Standard_True);
489         myLFMap(E).Append(ee1);
490         BB.Add(w, ee1);
491         thePreviousEdge = ee1;
492         counter++;
493         EX1.Next();
494         break;
495       }
496     }
497  
498 // Case of several edges
499     if(!FirstEdge.IsSame(LastEdge)) {
500       for(; EX1.More(); EX1.Next()) {
501         const TopoDS_Edge& E = EX1.Current();
502         if(!myLFMap.IsBound(E)) {
503           TopTools_ListOfShape thelist1;
504           myLFMap.Bind(E, thelist1);
505         }      
506         theList.Append(E);
507         Standard_Real f, l;
508         if(!E.IsSame(LastEdge)) {
509           Handle(Geom_Curve) ccc = BRep_Tool::Curve(E, f, l);
510           TopoDS_Vertex v1, v2;
511           if(!thePreviousEdge.IsNull()) {
512             v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
513             v2 = TopExp::LastVertex(E,Standard_True);
514           }
515           else {
516 //          v1 = TopExp::LastVertex(E,Standard_True);
517             v1 = TopExp::FirstVertex(E,Standard_True);
518             v2 = TopExp::LastVertex(E,Standard_True);
519           }
520           BRepLib_MakeEdge E1(ccc, v1, v2);
521           TopoDS_Edge E11 = TopoDS::Edge(E1.Shape());
522           TopoDS_Shape aLocalShape = E11.Oriented(E.Orientation());
523           E11 = TopoDS::Edge(aLocalShape);
524 //        E11 = TopoDS::Edge(E11.Oriented(E.Orientation()));
525           thePreviousEdge = E11;
526           myLFMap(E).Append(E11);
527           BB.Add(w, E11);
528           if(counter == 1) theFV = TopExp::FirstVertex(E11,Standard_True);
529           counter++;
530         }
531         else {
532           Standard_Real f, l;
533           Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l);
534           gp_Pnt pf = BRep_Tool::Pnt(TopExp::FirstVertex(E,Standard_True));
535           gp_Pnt pl = myLastPnt;
536           TopoDS_Edge ee;
537           if(thePreviousEdge.IsNull()) {
538             BRepLib_MakeEdge e(cc, pf , pl); 
539             ee = TopoDS::Edge(e.Shape());
540           }
541           else {
542             const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
543             BRepLib_MakeVertex v2(pl);
544             BRepLib_MakeEdge e(cc, v1, v2);
545             ee = TopoDS::Edge(e.Shape());
546           }
547           TopoDS_Shape aLocalShape = ee.Oriented(E.Orientation());
548           ee = TopoDS::Edge(aLocalShape);
549 //        ee = TopoDS::Edge(ee.Oriented(E.Orientation()));
550           BB.Add(w, ee);
551           myLFMap(E).Append(ee);
552           if(counter == 1) theFV = TopExp::FirstVertex(ee,Standard_True);
553           thePreviousEdge = ee;
554           counter++;
555           break;
556         }
557       }
558     }
559     
560     TopTools_ListIteratorOfListOfShape it(myListOfEdges);
561     Standard_Boolean FirstOK = Standard_False;
562     Standard_Boolean LastOK = Standard_False;
563     
564     gp_Pnt theLastPnt = myLastPnt;
565     Standard_Integer sens = 0;
566     TopoDS_Edge theEdge, theLEdge, theFEdge;
567     Standard_Integer counter1 = counter;
568     TopTools_ListOfShape NewListOfEdges;
569     NewListOfEdges.Clear();
570     while (!FirstOK) {
571       const TopoDS_Edge& edg = TopoDS::Edge(it.Value());
572       gp_Pnt fp, lp;
573       Standard_Real f, l;
574       Handle(Geom_Curve) ccc = BRep_Tool::Curve(edg, f, l);
575       Handle(Geom_TrimmedCurve) cc = new Geom_TrimmedCurve(ccc, f, l);
576       if ( edg.Orientation() == TopAbs_REVERSED) cc->Reverse();
577
578       fp = cc->Value(cc->FirstParameter());
579       lp = cc->Value(cc->LastParameter());
580       Standard_Real dist = fp.Distance(theLastPnt);
581       if(dist <= myTol) {
582         sens = 1;
583         LastOK = Standard_True;
584       }
585       else {
586         dist = lp.Distance(theLastPnt);
587         if(dist <= myTol) {
588           sens = 2;
589           LastOK = Standard_True;
590           cc->Reverse();
591         }
592       }
593       Standard_Integer FirstFlag = 0;
594       if(sens==1 && lp.Distance(myFirstPnt) <= myTol) {
595         FirstOK = Standard_True;
596         FirstFlag = 1;
597       }
598       else if(sens==2 && fp.Distance(myFirstPnt) <= myTol) {
599         FirstOK = Standard_True;
600         FirstFlag = 2;
601       }
602       
603       if (LastOK) {
604         TopoDS_Edge eeee;
605         Standard_Real fpar = cc->FirstParameter();
606         Standard_Real lpar = cc->LastParameter();
607         if(!FirstOK) {
608           if(thePreviousEdge.IsNull()) {
609             BRepLib_MakeEdge e(cc, fpar, lpar);
610             eeee = TopoDS::Edge(e.Shape());
611           }
612           else {
613             const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
614             BB.UpdateVertex(v1, dist);
615             BRepLib_MakeVertex v2(cc->Value(lpar));
616             TopoDS_Vertex nv=v2.Vertex();
617             BRepLib_MakeEdge e(cc, v1, nv);
618             eeee = TopoDS::Edge(e.Shape());
619           }
620         }
621         else {
622           if(thePreviousEdge.IsNull()) {
623             BRepLib_MakeVertex v1(cc->Value(fpar)); 
624             BRepLib_MakeEdge e(cc, v1, theFV);
625             eeee = TopoDS::Edge(e.Shape());
626           }
627           else {
628             const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
629             BRepLib_MakeEdge e(cc, v1, theFV);
630             eeee = TopoDS::Edge(e.Shape());
631           }
632         }
633
634         thePreviousEdge = eeee;
635         BB.Add(w, eeee);
636         if(counter == 1) theFV = TopExp::FirstVertex(eeee,Standard_True);
637         counter1++;
638         NewListOfEdges.Append(edg);
639         theEdge = eeee;
640
641         if(dist <= myTol) 
642           theFEdge = edg;
643         theLastPnt = BRep_Tool::Pnt(TopExp::LastVertex(theEdge,Standard_True));
644       }
645
646       if(FirstFlag == 1) {
647         theLEdge = edg;
648       }
649       else if(FirstFlag == 2) {
650         theLEdge = theEdge;
651       }
652
653       if(LastOK) {
654         myListOfEdges.Remove(it);
655         it.Initialize(myListOfEdges);
656         LastOK = Standard_False;
657       }
658       else if(it.More()) it.Next();
659       else {
660         Sliding = Standard_False;
661         break;
662       } 
663       sens = 0;
664     }
665
666
667     TopTools_DataMapOfShapeListOfShape SlidMap;
668     SlidMap.Clear();
669     
670     if(Sliding && counter1 > counter) {
671       TopTools_ListIteratorOfListOfShape it;
672       TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm;
673       TopExp_Explorer EX2(w, TopAbs_EDGE);
674       Standard_Integer ii = 0;
675       for(; EX2.More(); EX2.Next()) {
676         const TopoDS_Edge& E = TopoDS::Edge(EX2.Current());
677         ii++;   
678         if(ii >= counter && ii <= counter1) {
679           it.Initialize(NewListOfEdges);
680           Standard_Integer jj = 0;
681           for(; it.More(); it.Next()) {
682             const TopoDS_Edge& e2 = TopoDS::Edge(it.Value());
683             jj++;
684             if(jj== (ii - counter +1)) {          
685               itm.Initialize(mySlface);
686               for(; itm.More(); itm.Next()) {
687                 const TopoDS_Face& fac = TopoDS::Face(itm.Key());
688                 const TopTools_ListOfShape& ledg = itm.Value();
689                 TopTools_ListIteratorOfListOfShape itedg(ledg);
690                 //Standard_Integer iiii = 0;
691                 for(; itedg.More(); itedg.Next()) {
692                   const TopoDS_Edge& e1 = TopoDS::Edge(itedg.Value());
693                   if(e1.IsSame(e2)){
694                     if(!SlidMap.IsBound(fac)) {
695                       TopTools_ListOfShape thelist2;
696                       SlidMap.Bind(fac, thelist2);
697                     }
698                     SlidMap(fac).Append(E);
699                   }
700                 }               
701               }
702             }
703           } 
704         }
705       }
706     }
707
708     mySlface.Clear();
709     mySlface = SlidMap;
710   }
711
712 // ---Arguments of LocOpe_LinearForm : arguments of the prism sliding
713   if(Sliding) {
714     TopoDS_Face F;
715     BB.MakeFace(F, myPln, myTol);
716     BB.Add(F, w);
717 //    BRepLib_MakeFace F(myPln->Pln(),w, Standard_True);
718     mySkface = F;
719     myPbase  = mySkface;
720     mySUntil.Nullify();
721   }
722   
723
724 // ---Case without sliding : construction of the profile face   
725   if(!Sliding) {
726 #ifdef DEB
727     if (trc) {
728       if (Modify) cout << " Sliding failure" << endl;
729       cout << " no Sliding" << endl;
730     }
731 #endif
732     TopoDS_Face Prof;
733     Standard_Boolean ProfileOK;
734     ProfileOK = NoSlidingProfile(Prof,RevolRib,myTol,Concavite,myPln,
735                                  bnd,BndFace,CheckPnt,
736                                  FirstFace,LastFace,FirstVertex,LastVertex,
737                                  FirstEdge,LastEdge,OnFirstFace,OnLastFace);
738     
739     if (!ProfileOK) {
740 #ifdef DEB
741       cout << "Not computable" << endl;
742       if (trc) cout << " Face profile not computable" << endl;
743 #endif
744       myStatusError = BRepFeat_NoFaceProf;
745       NotDone();
746       return;
747     }
748
749
750 // ---Propagation on faces of the initial shape
751 // to find the faces concerned by the rib
752     Standard_Boolean falseside = Standard_True;
753     Propagate(SliList, Prof, myFirstPnt, myLastPnt, falseside);
754 // Control if there is everything required to have the material at the proper side
755     if(falseside == Standard_False) {
756 #ifdef DEB
757       cout << "Verify plane and wire orientation" << endl;
758 #endif
759       myStatusError = BRepFeat_FalseSide;
760       NotDone();
761       return;
762     }
763
764     mySlface.Clear();
765
766     TopTools_ListIteratorOfListOfShape it;
767     it.Initialize(SliList);
768     
769     TopoDS_Shape comp;
770     
771     BRep_Builder BB;
772     BB.MakeShell(TopoDS::Shell(comp));
773     
774     for(; it.More(); it.Next()) {
775       BB.Add(comp, it.Value());
776     }
777     
778     mySUntil = comp;
779
780     mySkface = Prof;
781     myPbase  = Prof;
782   }
783
784   mySliding = Sliding;
785
786   TopExp_Explorer exp;
787   for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
788     TopTools_ListOfShape thelist3;
789     myMap.Bind(exp.Current(), thelist3);
790     myMap(exp.Current()).Append(exp.Current());
791   }
792 }
793
794
795 //=======================================================================
796 //function : Add
797 //purpose  : add des element de collage
798 //=======================================================================
799
800 void BRepFeat_MakeLinearForm::Add(const TopoDS_Edge& E,
801                                   const TopoDS_Face& F)
802 {
803 #ifdef DEB
804   Standard_Boolean trc = BRepFeat_GettraceFEAT();
805   if (trc) cout << "BRepFeat_MakeLinearForm::Add" << endl;
806 #endif
807   if(mySlface.IsEmpty()) {
808     TopExp_Explorer exp;
809     for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
810       if (exp.Current().IsSame(F)) {
811         break;
812       }
813     }
814     if (!exp.More()) {
815       Standard_ConstructionError::Raise();
816     }
817   
818     if (!mySlface.IsBound(F)) {
819       TopTools_ListOfShape thelist;
820       mySlface.Bind(F, thelist);
821     }
822     TopTools_ListIteratorOfListOfShape itl(mySlface(F));
823     for (; itl.More();itl.Next()) {
824       if (itl.Value().IsSame(E)) {
825         break;
826       }
827     }
828     if (!itl.More()) {
829       mySlface(F).Append(E);
830     }
831   } 
832 }
833
834   
835
836 //=======================================================================
837 //function : Perform
838 //purpose  : construction of rib from a profile and the initial shape
839 //=======================================================================
840
841 void BRepFeat_MakeLinearForm::Perform()
842 {
843 #ifdef DEB
844   Standard_Boolean trc = BRepFeat_GettraceFEAT();
845   if (trc) cout << "BRepFeat_MakeLinearForm::Perform()" << endl;
846 #endif
847   if(mySbase.IsNull() || mySkface.IsNull() || myPbase.IsNull()) {
848 #ifdef DEB
849     if (trc) cout << " Fields not initialized" << endl;
850 #endif
851     myStatusError = BRepFeat_NotInitialized;
852     NotDone();
853     return;
854   }
855
856   gp_Vec nulldir(0, 0, 0);
857
858   Standard_Real Length = myDir.Magnitude() +  myDir1.Magnitude();
859
860   myGluedF.Clear();
861  
862   if(!mySUntil.IsNull()) 
863     myPerfSelection = BRepFeat_SelectionU;
864   else 
865     myPerfSelection = BRepFeat_NoSelection;
866
867   gp_Dir dir(myDir);
868   gp_Vec V = Length*dir;
869
870   LocOpe_LinearForm theForm;
871
872   if(myDir1.IsEqual(nulldir, Precision::Confusion(), Precision::Confusion())) 
873     theForm.Perform(myPbase, V, myFirstPnt, myLastPnt);
874   else 
875     theForm.Perform(myPbase, V, myDir1, myFirstPnt, myLastPnt);
876
877   TopoDS_Shape VraiForm = theForm.Shape();   // primitive of the rib
878
879   myFacesForDraft.Append(theForm.FirstShape());
880   myFacesForDraft.Append(theForm.LastShape());
881   MajMap(myPbase,theForm,myMap,myFShape,myLShape);   // management of descendants
882
883   TopExp_Explorer exx(myPbase, TopAbs_EDGE);
884   for(; exx.More(); exx.Next()) {
885     const TopoDS_Edge& e = TopoDS::Edge(exx.Current());
886     if(!myMap.IsBound(e)) {
887 #ifdef DEB
888       if (trc) cout << " Sliding face not in Base shape" << endl;
889 #endif
890       myStatusError = BRepFeat_IncSlidFace;
891       NotDone();
892       return;
893     }
894   }
895
896   myGShape = VraiForm;
897   SetGluedFaces(mySlface, theForm, myGluedF);  // management of sliding faces  
898
899   if(!myGluedF.IsEmpty() && !mySUntil.IsNull()) {
900 #ifdef DEB
901     cout << "The case is not computable" << endl;
902     if (trc) cout << " Glued faces not empty and Until shape not null" << endl;
903 #endif
904     myStatusError = BRepFeat_InvShape;
905     NotDone();
906     return;
907   }
908
909   LFPerform();
910
911 /*
912
913   TopExp_Explorer expr(mySbase, TopAbs_FACE);
914   char nom1[20], nom2[20];
915   Standard_Integer ii = 0;
916   for(; expr.More(); expr.Next()) {
917     ii++;
918     sprintf(nom1, "faceinitial_%d", ii);
919     DBRep::Set(nom1, expr.Current());
920     Standard_Integer jj = 0;
921     const TopTools_ListOfShape& list = Modified(expr.Current());
922     TopTools_ListIteratorOfListOfShape ite(list);
923     for(; ite.More(); ite.Next()) {
924       jj++;
925       sprintf(nom2, "facemodifie_%d_%d", ii, jj);
926       DBRep::Set(nom2, ite.Value());
927     }
928   }
929
930   expr.Init(myWire, TopAbs_EDGE);
931   ii=0;
932   for(; expr.More(); expr.Next()) {
933     ii++;
934     sprintf(nom1, "edgeinitial_%d", ii);
935     DBRep::Set(nom1, expr.Current());
936     Standard_Integer jj = 0;
937     const TopTools_ListOfShape& genf = Generated(expr.Current());
938     TopTools_ListIteratorOfListOfShape ite(genf);
939     for(; ite.More(); ite.Next()) {
940       jj++;
941       sprintf(nom2, "egdegeneree_%d_%d", ii, jj);
942       DBRep::Set(nom2, ite.Value());
943     }
944   }
945 */
946 }
947
948 //=======================================================================
949 //function : Propagate
950 //purpose  : propagation on faces of the initial shape, find 
951 // faces concerned by the rib
952 //=======================================================================
953   Standard_Boolean BRepFeat_MakeLinearForm::Propagate(TopTools_ListOfShape& SliList,
954                                                       const TopoDS_Face& fac,
955                                                       const gp_Pnt& Firstpnt, 
956                                                       const gp_Pnt& Lastpnt, 
957                                                       Standard_Boolean& falseside)
958 {
959 #ifdef DEB
960   Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
961   if (trc) cout << "BRepFeat_MakeLinearForm::Propagate" << endl;
962 #endif
963   gp_Pnt Firstpoint = Firstpnt;
964   gp_Pnt Lastpoint = Lastpnt;
965
966   Standard_Boolean result = Standard_True;
967   TopoDS_Face CurrentFace, saveFace;
968   CurrentFace = TopoDS::Face(SliList.First());
969   saveFace = CurrentFace;
970
971   Standard_Boolean LastOK = Standard_False, FirstOK= Standard_False;
972   Standard_Boolean v1OK = Standard_False, v2OK= Standard_False;
973   TopoDS_Vertex v1, v2, v3, v4, ve1, ve2;
974
975   //modified by NIZNHY-PKV Fri Mar 22 16:50:24 2002 f
976   //BRepAlgo_Section sect (fac, CurrentFace, Standard_False);
977   BRepAlgoAPI_Section sect (fac, CurrentFace, Standard_False);
978   //modified by NIZNHY-PKV Fri Mar 22 16:50:32 2002 t
979
980   sect.Approximation(Standard_True);
981   sect.Build();
982
983   TopExp_Explorer Ex;
984   TopoDS_Edge eb, ec;
985   gp_Pnt p1, p2;
986   Standard_Real t1 = 0., t2 = 0.;
987   Standard_Boolean c1f, c2f, c1l, c2l;
988
989   for (Ex.Init(sect.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) {
990     ec = TopoDS::Edge(Ex.Current());
991     v1 = TopExp::FirstVertex(ec,Standard_True); 
992     v2 = TopExp::LastVertex(ec,Standard_True); 
993     p1 = BRep_Tool::Pnt(v1);
994     p2 = BRep_Tool::Pnt(v2);
995     t1 = BRep_Tool::Tolerance(v1);
996     t2 = BRep_Tool::Tolerance(v2);
997     c1f = p1.Distance(Firstpoint)<=t1;
998     c2f = p2.Distance(Firstpoint)<=t2;
999     c1l = p1.Distance(Lastpoint)<=t1;
1000     c2l = p2.Distance(Lastpoint)<=t2;
1001     if (c1f || c2f || c1l|| c2l) {
1002       eb = ec;
1003       if (c1f || c1l) v1OK=Standard_True;
1004       if (c2f || c2l) v2OK=Standard_True;
1005       if (c1f || c2f) FirstOK=Standard_True;
1006       if (c1l || c2l) LastOK=Standard_True;
1007       break;
1008     }
1009   }
1010
1011   if(eb.IsNull()) {
1012     falseside = Standard_False;
1013     return Standard_False;
1014   }
1015   TopTools_ListOfShape thelist;
1016   mySlface.Bind(CurrentFace, thelist);
1017   mySlface(CurrentFace).Append(eb);
1018     
1019   myListOfEdges.Clear();
1020   myListOfEdges.Append(eb);
1021     
1022   // two points are on the same face.
1023   if(LastOK && FirstOK) {
1024     return result;
1025   }
1026   
1027   TopTools_IndexedDataMapOfShapeListOfShape mapedges;
1028   TopExp::MapShapesAndAncestors(mySbase, TopAbs_EDGE, TopAbs_FACE, mapedges);
1029   TopExp_Explorer ex;
1030   TopoDS_Edge FirstEdge;
1031   BRep_Builder BB;
1032
1033   TopoDS_Vertex Vprevious;
1034   gp_Pnt ptprev;
1035   Standard_Real tvp, dp;
1036
1037   while (!(LastOK && FirstOK)) {
1038     if (v1OK) {
1039       Vprevious=v2;
1040       ptprev=p2;
1041       tvp=t2;
1042     }
1043     else {
1044       Vprevious=v1;
1045       ptprev=p1;
1046       tvp=t1;
1047     }
1048     
1049     // find edge connected to v1 or v2:
1050     for (ex.Init(CurrentFace, TopAbs_EDGE); ex.More(); ex.Next()) {
1051       const TopoDS_Edge& rfe = TopoDS::Edge(ex.Current());
1052
1053       BRepExtrema_ExtPC projF(Vprevious, rfe);
1054
1055       if(projF.IsDone() && projF.NbExt() >=1) {
1056         Standard_Real dist2min = RealLast();
1057         Standard_Integer index = 0;
1058         for (Standard_Integer sol =1 ; sol <= projF.NbExt(); sol++) {
1059           if (projF.SquareDistance(sol) <= dist2min) {
1060             index = sol;
1061             dist2min = projF.SquareDistance(sol);
1062           }
1063         }
1064         if (index != 0) {
1065           if (dist2min <= BRep_Tool::Tolerance(rfe) * BRep_Tool::Tolerance(rfe)) {
1066             FirstEdge = rfe;
1067             // If the edge is not perpendicular to the plane of the rib
1068             // it is required to set Sliding(result) to false.
1069             if (result) {
1070               result=Standard_False;
1071               ve1 = TopExp::FirstVertex(rfe,Standard_True);
1072               ve2 = TopExp::LastVertex(rfe,Standard_True);
1073               BRepExtrema_ExtPF perp(ve1, fac);
1074               if (perp.IsDone()) {
1075                 gp_Pnt pe1=perp.Point(1);
1076                 perp.Perform(ve2, fac);
1077                 if (perp.IsDone()) {
1078                   gp_Pnt pe2=perp.Point(1);
1079                   if (pe1.Distance(pe2)<=BRep_Tool::Tolerance(rfe)) 
1080                     result=Standard_True;
1081                 }
1082               }
1083             }
1084             break;
1085           }
1086         }
1087       }
1088     }
1089     
1090     const TopTools_ListOfShape& L = mapedges.FindFromKey(FirstEdge);
1091     TopTools_ListIteratorOfListOfShape It(L);
1092
1093     for (; It.More(); It.Next()) {
1094       const TopoDS_Face& FF = TopoDS::Face(It.Value());
1095       if (!FF.IsSame(CurrentFace)) {
1096         CurrentFace = FF;
1097         break;
1098       }
1099     }
1100
1101     //modified by NIZNHY-PKV Fri Mar 22 16:50:53 2002 f
1102     //BRepAlgo_Section sectf (fac, CurrentFace, Standard_False);
1103     BRepAlgoAPI_Section sectf (fac, CurrentFace, Standard_False);
1104     //modified by NIZNHY-PKV Fri Mar 22 16:51:03 2002 t
1105     sectf.Approximation(Standard_True);
1106     sectf.Build();
1107
1108     TopoDS_Edge edg1;
1109     for (Ex.Init(sectf.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) {
1110       edg1 = TopoDS::Edge(Ex.Current());
1111       v1=TopExp::FirstVertex(edg1,Standard_True);
1112       v2=TopExp::LastVertex(edg1,Standard_True);
1113       t1 = BRep_Tool::Tolerance(v1);
1114       t2 = BRep_Tool::Tolerance(v2);
1115       p1 = BRep_Tool::Pnt(v1);
1116       p2 = BRep_Tool::Pnt(v2);
1117       v1OK = p1.Distance(ptprev)<=t1;
1118       v2OK = p2.Distance(ptprev)<=t2;
1119       if (v1OK || v2OK) break;
1120     }    
1121     
1122     if (v1OK) {
1123       if (!FirstOK) {
1124         dp = p2.Distance(Firstpoint);
1125         if(dp <= 2*t2) {
1126           FirstOK = Standard_True;
1127           BB.UpdateVertex(v2, dp);
1128         }
1129       }
1130       if (!LastOK) {
1131         dp = p2.Distance(Lastpoint);
1132         if(dp <= 2*t2) {
1133           LastOK = Standard_True;
1134           BB.UpdateVertex(v2, dp);
1135         }
1136       }
1137     }
1138     else if (v2OK) {
1139       if (!FirstOK) {
1140         dp = p1.Distance(Firstpoint);
1141         if(dp <= 2*t1) {
1142           FirstOK = Standard_True;
1143           BB.UpdateVertex(v1, dp);
1144         }
1145       }
1146       if (!LastOK) {
1147         dp = p1.Distance(Lastpoint);
1148         if(dp <= 2*t1) {
1149           LastOK = Standard_True;
1150           BB.UpdateVertex(v1, dp);
1151         }
1152       }
1153     }
1154     else {
1155       // end by chaining the section
1156       return Standard_False;
1157     }
1158     TopTools_ListOfShape thelist1;
1159     mySlface.Bind(CurrentFace, thelist1);
1160     mySlface(CurrentFace).Append(edg1);
1161     myListOfEdges.Append(edg1);
1162   }
1163
1164   return result;
1165   
1166 }
1167
1168 //=======================================================================
1169 //function : MajMap
1170 //purpose  : management of descendants
1171 //=======================================================================
1172
1173 static void MajMap(const TopoDS_Shape& theB,
1174                    const LocOpe_LinearForm& theP,
1175                    TopTools_DataMapOfShapeListOfShape& theMap, // myMap
1176                    TopoDS_Shape& theFShape,  // myFShape
1177                    TopoDS_Shape& theLShape) // myLShape
1178 {
1179   TopExp_Explorer exp(theP.FirstShape(),TopAbs_WIRE);
1180   if (exp.More()) {
1181     theFShape = exp.Current();
1182     TopTools_ListOfShape thelist;
1183     theMap.Bind(theFShape, thelist);
1184     for (exp.Init(theP.FirstShape(),TopAbs_FACE);exp.More();exp.Next()) {
1185       theMap(theFShape).Append(exp.Current());
1186     }
1187   }
1188   
1189   exp.Init(theP.LastShape(),TopAbs_WIRE);
1190   if (exp.More()) {
1191     theLShape = exp.Current();
1192     TopTools_ListOfShape thelist1;
1193     theMap.Bind(theLShape, thelist1);
1194     for (exp.Init(theP.LastShape(),TopAbs_FACE);exp.More();exp.Next()) {
1195       theMap(theLShape).Append(exp.Current());
1196     }
1197   }
1198   
1199   for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) {
1200     if (!theMap.IsBound(exp.Current())) {
1201 #ifdef DEB
1202       const TopoDS_Edge& e = 
1203 #endif
1204       TopoDS::Edge(exp.Current());
1205       TopTools_ListOfShape thelist2; 
1206       theMap.Bind(exp.Current(), thelist2);
1207       theMap(exp.Current()) = theP.Shapes(exp.Current());
1208     }
1209   }
1210 }
1211
1212 //=======================================================================
1213 //function : SetGluedFaces
1214 //purpose  : management of faces of gluing
1215 //=======================================================================
1216
1217 static void SetGluedFaces(const TopTools_DataMapOfShapeListOfShape& theSlmap,
1218                           LocOpe_LinearForm& thePrism,
1219                           TopTools_DataMapOfShapeShape& theMap)
1220 {
1221   // Slidings
1222   TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(theSlmap);
1223   if(!theSlmap.IsEmpty()) {
1224     for (; itm.More(); itm.Next()) {
1225       const TopoDS_Face& fac = TopoDS::Face(itm.Key());
1226       const TopTools_ListOfShape& ledg = itm.Value();
1227       TopTools_ListIteratorOfListOfShape it;
1228       for (it.Initialize(ledg); it.More(); it.Next()) {
1229         const TopTools_ListOfShape& gfac = thePrism.Shapes(it.Value());
1230         if (gfac.Extent() != 1) {
1231 #ifdef DEB
1232           cout << "Pb SetGluedFace" << endl;
1233 #endif
1234         }
1235         theMap.Bind(gfac.First(),fac);
1236       }
1237     }
1238   }
1239 }
1240