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