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