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