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