0024002: Overall code and build procedure refactoring -- automatic
[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
239 TopoDS_Shape aLocalShape = W.Oriented(TopAbs_FORWARD);
240 myWire = TopoDS::Wire(aLocalShape);
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);
555 Handle(Geom_Curve) ccc;
556 if(fpar > lpar) {
557 ccc = Handle(Geom_Curve)::DownCast(cc->Reversed());
558 cc = ccc;
559 }
560 }
561 TopoDS_Edge ee1;
562 if(thePreviousEdge.IsNull()) {
563 BRepLib_MakeVertex v1(myFirstPnt);
564 BRepLib_MakeVertex v2(pt);
565 BRepLib_MakeEdge e(cc, v1, v2);
566 ee1 = TopoDS::Edge(e.Shape());
567 }
568 else {
569 const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
570 BRepLib_MakeVertex v2(pt);
571
572 BRepLib_MakeEdge e(cc, v1, v2);
573 ee1 = TopoDS::Edge(e.Shape());
574 }
575 TopoDS_Shape aLocalShape = ee1.Oriented(E.Orientation());
576 ee1 = TopoDS::Edge(aLocalShape);
577// ee1 = TopoDS::Edge(ee1.Oriented(E.Orientation()));
578 if(counter == 1) theFV = TopExp::FirstVertex(ee1,Standard_True);
579 myLFMap(E).Append(ee1);
580 BB.Add(w, ee1);
581 thePreviousEdge = ee1;
582 counter++;
583 EX1.Next();
584 break;
585 }
586 }
587
0d969553 588// Case of several edges
7fd59977 589 if(!FirstEdge.IsSame(LastEdge)) {
590 for(; EX1.More(); EX1.Next()) {
591 const TopoDS_Edge& E = EX1.Current();
592 if(!myLFMap.IsBound(E)) {
593 TopTools_ListOfShape thelist1;
594 myLFMap.Bind(E, thelist1);
595 }
596 theList.Append(E);
597 Standard_Real f, l;
598 if(!E.IsSame(LastEdge)) {
599 Handle(Geom_Curve) ccc = BRep_Tool::Curve(E, f, l);
600 TopoDS_Vertex v1, v2;
601 if(!thePreviousEdge.IsNull()) {
602 v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
603 v2 = TopExp::LastVertex(E,Standard_True);
604 }
605 else {
606// v1 = TopExp::LastVertex(E,Standard_True);
607 v1 = TopExp::FirstVertex(E,Standard_True);
608 v2 = TopExp::LastVertex(E,Standard_True);
609 }
610 BRepLib_MakeEdge E1(ccc, v1, v2);
611 TopoDS_Edge E11 = TopoDS::Edge(E1.Shape());
612 TopoDS_Shape aLocalShape = E11.Oriented(E.Orientation());
613 E11 = TopoDS::Edge(aLocalShape);
614// E11 = TopoDS::Edge(E11.Oriented(E.Orientation()));
615 thePreviousEdge = E11;
616 myLFMap(E).Append(E11);
617 BB.Add(w, E11);
618 if(counter == 1) theFV = TopExp::FirstVertex(E11,Standard_True);
619 counter++;
620 }
621 else {
622 Standard_Real f, l;
623 Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l);
624 gp_Pnt pf = BRep_Tool::Pnt(TopExp::FirstVertex(E,Standard_True));
625 gp_Pnt pl = myLastPnt;
626 TopoDS_Edge ee;
627 if(thePreviousEdge.IsNull()) {
628 BRepLib_MakeEdge e(cc, pf , pl);
629 ee = TopoDS::Edge(e.Shape());
630 }
631 else {
632 const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
633 BRepLib_MakeVertex v2(pl);
634 BRepLib_MakeEdge e(cc, v1, v2);
635 ee = TopoDS::Edge(e.Shape());
636 }
637 TopoDS_Shape aLocalShape = ee.Oriented(E.Orientation());
638 ee = TopoDS::Edge(aLocalShape);
639// ee = TopoDS::Edge(ee.Oriented(E.Orientation()));
640 BB.Add(w, ee);
641 myLFMap(E).Append(ee);
642 if(counter == 1) theFV = TopExp::FirstVertex(ee,Standard_True);
643 thePreviousEdge = ee;
644 counter++;
645 break;
646 }
647 }
648 }
649
650 TopTools_ListIteratorOfListOfShape it(myListOfEdges);
651 Standard_Boolean FirstOK = Standard_False;
652 Standard_Boolean LastOK = Standard_False;
653
654 gp_Pnt theLastPnt = myLastPnt;
655 Standard_Integer sens = 0;
656 TopoDS_Edge theEdge, theLEdge, theFEdge;
657 Standard_Integer counter1 = counter;
658 TopTools_ListOfShape NewListOfEdges;
659 NewListOfEdges.Clear();
660 while (!FirstOK) {
661 const TopoDS_Edge& edg = TopoDS::Edge(it.Value());
662 gp_Pnt fp, lp;
663 Standard_Real f, l;
664 Handle(Geom_Curve) ccc = BRep_Tool::Curve(edg, f, l);
665 Handle(Geom_TrimmedCurve) cc = new Geom_TrimmedCurve(ccc, f, l);
666 if ( edg.Orientation() == TopAbs_REVERSED) cc->Reverse();
667
668 fp = cc->Value(cc->FirstParameter());
669 lp = cc->Value(cc->LastParameter());
670 Standard_Real dist = fp.Distance(theLastPnt);
671 if(dist <= myTol) {
672 sens = 1;
673 LastOK = Standard_True;
674 }
675 else {
676 dist = lp.Distance(theLastPnt);
677 if(dist <= myTol) {
678 sens = 2;
679 LastOK = Standard_True;
680 cc->Reverse();
681 }
682 }
683 Standard_Integer FirstFlag = 0;
684 if(sens==1 && lp.Distance(myFirstPnt) <= myTol) {
685 FirstOK = Standard_True;
686 FirstFlag = 1;
687 }
688 else if(sens==2 && fp.Distance(myFirstPnt) <= myTol) {
689 FirstOK = Standard_True;
690 FirstFlag = 2;
691 }
692
693 if (LastOK) {
694 TopoDS_Edge eeee;
695 Standard_Real fpar = cc->FirstParameter();
696 Standard_Real lpar = cc->LastParameter();
697 if(!FirstOK) {
698 if(thePreviousEdge.IsNull()) {
699 BRepLib_MakeEdge e(cc, fpar, lpar);
700 eeee = TopoDS::Edge(e.Shape());
701 }
702 else {
703 const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
704 BRepLib_MakeVertex v2(cc->Value(lpar));
705 BRepLib_MakeEdge e(cc, v1, v2);
706 eeee = TopoDS::Edge(e.Shape());
707 }
708 }
709 else {
710 if(thePreviousEdge.IsNull()) {
711 BRepLib_MakeVertex v1(cc->Value(fpar));
712 BRepLib_MakeEdge e(cc, v1, theFV);
713 eeee = TopoDS::Edge(e.Shape());
714 }
715 else {
716 const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
717 BRepLib_MakeEdge e(cc, v1, theFV);
718 eeee = TopoDS::Edge(e.Shape());
719 }
720 }
721
722 thePreviousEdge = eeee;
723 BB.Add(w, eeee);
724 if(counter == 1) theFV = TopExp::FirstVertex(eeee,Standard_True);
725 counter1++;
726 NewListOfEdges.Append(edg);
727 theEdge = eeee;
6e6cd5d9 728
7fd59977 729 if(dist <= myTol)
730 theFEdge = edg;
731 theLastPnt = BRep_Tool::Pnt(TopExp::LastVertex(theEdge,Standard_True));
732 }
733
734 if(FirstFlag == 1) {
735 theLEdge = edg;
736 }
737 else if(FirstFlag == 2) {
738 theLEdge = theEdge;
739 }
740
741 if(LastOK) {
742 it.Initialize(myListOfEdges);
743 LastOK = Standard_False;
744 }
745 else if(it.More()) it.Next();
746 else {
747 Sliding = Standard_False;
748 break;
749 }
750 sens = 0;
751 }
752
753
754 TopTools_DataMapOfShapeListOfShape SlidMap;
755 SlidMap.Clear();
756
757 if(Sliding && counter1 > counter) {
758 TopTools_ListIteratorOfListOfShape it;
759 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm;
760 TopExp_Explorer EX2(w, TopAbs_EDGE);
761 Standard_Integer ii = 0;
762 for(; EX2.More(); EX2.Next()) {
763 const TopoDS_Edge& E = TopoDS::Edge(EX2.Current());
764 ii++;
765 if(ii >= counter && ii <= counter1) {
766 it.Initialize(NewListOfEdges);
767 Standard_Integer jj = 0;
768 for(; it.More(); it.Next()) {
769 const TopoDS_Edge& e2 = TopoDS::Edge(it.Value());
770 jj++;
771 if(jj== (ii - counter +1)) {
772 itm.Initialize(mySlface);
773 for(; itm.More(); itm.Next()) {
774 const TopoDS_Face& fac = TopoDS::Face(itm.Key());
775 const TopTools_ListOfShape& ledg = itm.Value();
776 TopTools_ListIteratorOfListOfShape itedg(ledg);
777 //Standard_Integer iiii = 0;
778 for(; itedg.More(); itedg.Next()) {
779 const TopoDS_Edge& e1 = TopoDS::Edge(itedg.Value());
780 if(e1.IsSame(e2)){
781 if(!SlidMap.IsBound(fac)) {
782 TopTools_ListOfShape thelist2;
783 SlidMap.Bind(fac, thelist2);
784 }
785 SlidMap(fac).Append(E);
786 }
787 }
788 }
789 }
790 }
791 }
792 }
793 }
794
795 mySlface.Clear();
796 mySlface = SlidMap;
797 }
798
0d969553
Y
799// ---Arguments of LocOpe_LinearForm : arguments of the prism
800// sliding
7fd59977 801 if(Sliding) {
802 TopoDS_Face F;
803 BB.MakeFace(F, myPln, myTol);
ab860031 804 w.Closed (BRep_Tool::IsClosed (w));
7fd59977 805 BB.Add(F, w);
806 mySkface = F;
807 myPbase = mySkface;
808 mySUntil.Nullify();
809 }
810
811
0d969553 812// ---Case without sliding : construction of the face profile
7fd59977 813 if(!Sliding) {
0797d9d3 814#ifdef OCCT_DEBUG
7fd59977 815 if (trc) {
816 if (Modify) cout << " Sliding failure" << endl;
817 cout << " no Sliding" << endl;
818 }
819#endif
820 TopExp_Explorer explo1(BndFace, TopAbs_WIRE);
821 TopoDS_Wire WWW = TopoDS::Wire(explo1.Current());
822 BRepTools_WireExplorer explo(WWW);
823 BRep_Builder Bu;
824 TopoDS_Wire Wiwiwi;
825 Bu.MakeWire(Wiwiwi);
826 TopoDS_Vertex NewV1, NewV2, LastV, v;
827 NewV1.Nullify(); NewV2.Nullify(); LastV.Nullify();
828
829 for(; explo.More(); explo.Next()) {
830 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
831 TopoDS_Vertex v1 = TopExp::FirstVertex(e,Standard_True);
832 TopoDS_Vertex v2 = TopExp::LastVertex(e,Standard_True);
833
834 Standard_Real f, l;//, t;
835 Handle(Geom_Curve) ln = BRep_Tool::Curve(e, f, l);
836// Handle(Geom_Curve) lln = BRep_Tool::Curve(e, f, l);
837// Handle(Geom_Curve) ln;
838// if(e.Orientation() == TopAbs_REVERSED) {
839// ln = Handle(Geom_Curve)::DownCast(lln->Reversed());
840// v = v1; v1 = v2; v2= v;
841// f = IntPar(ln, BRep_Tool::Pnt(v1));
842// l = IntPar(ln, BRep_Tool::Pnt(v2));
843// }
844// else ln = lln;
845
846 Handle(Geom2d_Curve) l2d = GeomAPI::To2d(ln, Plane->Pln());
847 Geom2dAPI_InterCurveCurve intcc(l2d, ln2d, Precision::Confusion());
848 TopoDS_Vertex VV; VV.Nullify();
849 TopoDS_Edge ee1, ee2;
850
851 if(intcc.NbPoints() > 0) {
852 gp_Pnt2d P = intcc.Point(1);
853 gp_Pnt point;
854 myPln->D0(P.X(), P.Y(), point);
855 Standard_Real par = IntPar(ln, point);
856 if(f <= par && l >= par) {
857 Bu.MakeVertex(VV, point, Precision::Confusion());
858 }
859 }
860
861 if(VV.IsNull() && NewV1.IsNull()) continue;
862
863 if(!VV.IsNull() && NewV1.IsNull()) {
864 NewV1 = VV;
865 LastV = v2;
866 BRepLib_MakeEdge ee1(NewV1, LastV);
867 Bu.Add(Wiwiwi, ee1);
868 continue;
869 }
870
871 if(VV.IsNull() && !NewV1.IsNull()) {
872 BRepLib_MakeEdge ee1(LastV, v2);
873 LastV = v2;
874 Bu.Add(Wiwiwi, e);
875 continue;
876 }
877
878 if(!VV.IsNull() && !NewV1.IsNull()) {
879 NewV2 = VV;
880 BRepLib_MakeEdge ee1(LastV, NewV2);
881 LastV = NewV2;
882 Bu.Add(Wiwiwi, ee1);
883 BRepLib_MakeEdge ee2(LastV, NewV1);
884 Bu.Add(Wiwiwi, ee2);
885 break;
886 }
887 }
ab860031 888 Wiwiwi.Closed (BRep_Tool::IsClosed (Wiwiwi));
7fd59977 889
890 BRepLib_MakeFace newbndface(myPln->Pln(), Wiwiwi, Standard_True);
891 TopoDS_Face NewBndFace = TopoDS::Face(newbndface.Shape());
892
893 BRepTopAdaptor_FClass2d Cl(NewBndFace, Precision::Confusion());
894 Standard_Real paru, parv;
895 ElSLib::Parameters(myPln->Pln(), CheckPnt, paru, parv);
896 gp_Pnt2d checkpnt2d(paru, parv);
897 if(Cl.Perform(checkpnt2d, Standard_True) == TopAbs_OUT) {
898 //modified by NIZNHY-PKV Fri Mar 22 16:52:52 2002 f
899 //BRepAlgo_Cut c(BndFace, NewBndFace);
900 BRepAlgoAPI_Cut c(BndFace, NewBndFace);
901 //modified by NIZNHY-PKV Fri Mar 22 16:52:57 2002 t
902 TopExp_Explorer exp(c.Shape(), TopAbs_WIRE);
903 const TopoDS_Wire& w = TopoDS::Wire(exp.Current());
904 // akm 13/02/02 : we know the plane. Why not to use it?
905 // BRepLib_MakeFace ff(w);
906 BRepLib_MakeFace ff(myPln->Pln(), w, Standard_True);
907 NewBndFace = TopoDS::Face(ff.Shape());
908 }
909
910
911 if(!BRepAlgo::IsValid(NewBndFace)) {
0797d9d3 912#ifdef OCCT_DEBUG
7fd59977 913 cout << "Invalid new bounding face" << endl;
914#endif
915 myStatusError = BRepFeat_InvShape;
916 NotDone();
917 return;
918 }
919
920 BndFace = NewBndFace;
921
922
923 TopoDS_Face Prof;
924 Standard_Boolean ProfileOK;
925 ProfileOK = NoSlidingProfile(Prof,RevolRib,myTol,Concavite,myPln,
926 bnd,BndFace,CheckPnt,
927 FirstFace,LastFace,FirstVertex,LastVertex,
928 FirstEdge,LastEdge,OnFirstFace,OnLastFace);
929
930 if (!ProfileOK) {
0797d9d3 931#ifdef OCCT_DEBUG
63c629aa 932 if (trc)
933 {
934 cout << "Not computable" << endl;
935 cout << " Face profile not computable" << endl;
936 }
7fd59977 937#endif
938 myStatusError = BRepFeat_NoFaceProf;
939 NotDone();
940 return;
941 }
942
943
0d969553
Y
944// ---Propagation on the faces of the initial shape
945// to find the faces concerned by the rib
7fd59977 946 Standard_Boolean falseside = Standard_True;
947 Propagate(SliList, Prof, myFirstPnt, myLastPnt, falseside);
0d969553 948// Control if there is everything required to have the material at the proper side
7fd59977 949 if(falseside == Standard_False) {
0797d9d3 950#ifdef OCCT_DEBUG
7fd59977 951 cout << " Verify plane and wire orientation" << endl;
952#endif
953 myStatusError = BRepFeat_FalseSide;
954 NotDone();
955 return;
956 }
957
958 mySlface.Clear();
959
960 TopTools_ListIteratorOfListOfShape it;
961 it.Initialize(SliList);
962
963 TopoDS_Shape comp;
964
965 BRep_Builder BB;
966 BB.MakeShell(TopoDS::Shell(comp));
967
968 for(; it.More(); it.Next()) {
969 BB.Add(comp, it.Value());
970 }
ab860031 971 comp.Closed (BRep_Tool::IsClosed (comp));
7fd59977 972
973 mySUntil = comp;
974
975 mySkface = Prof;
976 myPbase = Prof;
977 }
978
979 mySliding = Sliding;
980
981 TopExp_Explorer exp;
982 for ( exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
983 TopTools_ListOfShape thelist3;
984 myMap.Bind(exp.Current(), thelist3);
985 myMap(exp.Current()).Append(exp.Current());
986 }
987}
988
989
990
991//=======================================================================
992//function : Add
0d969553 993//purpose : add elements of gluing
7fd59977 994//=======================================================================
995
996void BRepFeat_MakeRevolutionForm::Add(const TopoDS_Edge& E,
997 const TopoDS_Face& F)
998{
0797d9d3 999#ifdef OCCT_DEBUG
7fd59977 1000 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1001 if (trc) cout << "BRepFeat_MakeRevolutionForm::Add" << endl;
1002#endif
1003 if(mySlface.IsEmpty()) {
1004 TopExp_Explorer exp;
1005 for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
1006 if (exp.Current().IsSame(F)) {
1007 break;
1008 }
1009 }
1010 if (!exp.More()) {
1011 Standard_ConstructionError::Raise();
1012 }
1013
1014 if (!mySlface.IsBound(F)) {
1015 TopTools_ListOfShape thelist;
1016 mySlface.Bind(F, thelist);
1017 }
1018 TopTools_ListIteratorOfListOfShape itl(mySlface(F));
1019 for (; itl.More();itl.Next()) {
1020 if (itl.Value().IsSame(E)) {
1021 break;
1022 }
1023 }
1024 if (!itl.More()) {
1025 mySlface(F).Append(E);
1026 }
1027 }
1028}
1029
1030
1031
1032//=======================================================================
1033//function : Perform
1034//purpose : construction
1035//=======================================================================
1036
1037void BRepFeat_MakeRevolutionForm::Perform()
1038{
0797d9d3 1039#ifdef OCCT_DEBUG
7fd59977 1040 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1041 if (trc) cout << "BRepFeat_MakeRevolutionForm::Perform()" << endl;
1042#endif
1043 if(mySbase.IsNull() || mySkface.IsNull() || myPbase.IsNull()) {
0797d9d3 1044#ifdef OCCT_DEBUG
7fd59977 1045 if (trc) cout << " Fields not initialized" << endl;
1046#endif
1047 myStatusError = BRepFeat_NotInitialized;
1048 NotDone();
1049 return;
1050 }
1051
1052 gp_Pnt Pt;
1053
1054 TopExp_Explorer exx(myPbase, TopAbs_VERTEX);
1055 for(; exx.More(); exx.Next()) {
1056 const TopoDS_Vertex& vv = TopoDS::Vertex(exx.Current());
1057 if(!vv.IsNull()) {
1058 Pt = BRep_Tool::Pnt(vv);
1059 break;
1060 }
1061 }
1062
1063 if(myAngle2 != 0) {
1064 gp_Trsf T;
1065 T.SetRotation(myAxe, -myAngle2);
1066 BRepBuilderAPI_Transform trsf(T);
1067 trsf.Perform(myPbase, Standard_False);
1068 TopoDS_Face Pbase = TopoDS::Face(trsf.Shape());
1069 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iter(myLFMap);
1070 for(; iter.More(); iter.Next()) {
1071 const TopoDS_Shape& e1 = iter.Value().First();
1072 TopExp_Explorer ex1(myPbase, TopAbs_EDGE);
1073 TopExp_Explorer ex2(Pbase, TopAbs_EDGE);
1074 for(; ex1.More(); ex1.Next()) {
1075 if(ex1.Current().IsSame(e1)) {
1076 myLFMap(iter.Key()).Clear();
1077 myLFMap(iter.Key()).Append(ex2.Current());
1078 }
1079 ex2.Next();
1080 }
1081 }
1082
1083 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iter1(mySlface);
1084 for(; iter1.More(); iter1.Next()) {
1085 const TopoDS_Shape& f1 = iter1.Key();
1086 const TopoDS_Shape& e1 = iter1.Value().First();
1087 TopExp_Explorer ex1(myPbase, TopAbs_EDGE);
1088 TopExp_Explorer ex2(Pbase, TopAbs_EDGE);
1089 for(; ex1.More(); ex1.Next()) {
1090 const TopoDS_Shape& E1 = ex1.Current();
1091 const TopoDS_Shape& E2 = ex2.Current();
1092 if(E1.IsSame(e1)) {
1093 mySlface(f1).Clear();
1094 mySlface(f1).Append(E2);
1095 }
1096 ex2.Next();
1097 }
1098 }
1099 myPbase = Pbase;
1100 trsf.Perform(mySkface, Standard_False);
0d969553 1101// flo : check if it is required to reattributr the field mySkface
7fd59977 1102// TopoDS_Face mySkface = TopoDS::Face(trsf.Shape());
1103 mySkface = TopoDS::Face(trsf.Shape());
1104 }
1105
1106 LocOpe_RevolutionForm theForm;
1107 theForm.Perform(myPbase, myAxe, (myAngle1+myAngle2));
0d969553 1108 TopoDS_Shape VraiForm = theForm.Shape(); // uncut primitive
7fd59977 1109
0d969553 1110// management of descendants
7fd59977 1111 MajMap(myPbase,theForm,myMap,myFShape,myLShape);
1112
1113 myGluedF.Clear();
1114
1115
1116
1117 gp_Pln Pln0 = myPln->Pln();
1118 BRepLib_MakeFace f(Pln0);
1119
1120
1121 gp_Vec vec1 = myHeight1*Normal(f, Pt);
1122 gp_Vec vec2 = -myHeight2*Normal(f, Pt);
1123
1124 gp_Pln Pln1 = Pln0.Translated(vec1);
1125 gp_Pln Pln2 = Pln0.Translated(vec2);
1126
1127 BRepLib_MakeFace ff1(Pln1);
1128 BRepLib_MakeFace ff2(Pln2);
1129 TopoDS_Face f1 = TopoDS::Face(ff1.Shape());
1130 TopoDS_Face f2 = TopoDS::Face(ff2.Shape());
1131 BRepFeat::FaceUntil(mySbase, f1);
1132 BRepFeat::FaceUntil(mySbase, f2);
1133
1134 LocOpe_CSIntersector ASI1(f1);
1135 LocOpe_CSIntersector ASI2(f2);
1136
1137 Handle(Geom_Line) normale = new Geom_Line(Pt, vec1);
1138 TColGeom_SequenceOfCurve scur;
1139 scur.Append(normale);
1140
1141 ASI1.Perform(scur);
1142 ASI2.Perform(scur);
1143
1144 if(!ASI1.IsDone() || !ASI2.IsDone() ||
1145 ASI1.NbPoints(1) != 1 || ASI2.NbPoints(1) != 1) {
0797d9d3 1146#ifdef OCCT_DEBUG
7fd59977 1147 if (trc) cout << " Intersection failure" << endl;
1148#endif
1149 myStatusError = BRepFeat_BadIntersect;
1150 NotDone();
1151 return;
1152 }
1153
1154 TopAbs_Orientation Ori1 = ASI1.Point(1,1).Orientation();
1155 TopAbs_Orientation Ori2 = TopAbs::Reverse(ASI2.Point(1,1).Orientation());
1156 TopoDS_Face FF1 = ASI1.Point(1,1).Face();
1157 TopoDS_Face FF2 = ASI2.Point(1,1).Face();
1158
1159 TopoDS_Shape Comp;
1160 BRep_Builder B;
1161 B.MakeCompound(TopoDS::Compound(Comp));
1162 TopoDS_Solid S1 = BRepFeat::Tool(f1,FF1,Ori1);
1163 TopoDS_Solid S2 = BRepFeat::Tool(f2,FF2,Ori2);
1164 if (!S1.IsNull()) B.Add(Comp,S1);
1165 if (!S2.IsNull()) B.Add(Comp,S2);
1166
1167 //modified by NIZNHY-PKV Fri Mar 22 16:53:20 2002 f
1168 //BRepAlgo_Cut trP(VraiForm,Comp);
1169 BRepAlgoAPI_Cut trP(VraiForm,Comp);
1170 //modified by NIZNHY-PKV Fri Mar 22 16:53:23 2002 t
1171 // coupe de la nervure par deux plans parallels
1172 TopTools_DataMapOfShapeListOfShape SlidingMap;
1173
0d969553 1174// management of descendants
7fd59977 1175
1176 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape it1;
1177 it1.Initialize(myMap);
1178 for(; it1.More(); it1.Next()) {
1179 const TopoDS_Shape& orig = it1.Key();
1180 if(it1.Value().IsEmpty()) continue;
1181 const TopoDS_Shape& sh = it1.Value().First();
1182 exx.Init(VraiForm, TopAbs_FACE);
1183 for(; exx.More(); exx.Next()) {
1184 const TopoDS_Face& fac = TopoDS::Face(exx.Current());
1185 TopExp_Explorer exx1(fac, TopAbs_WIRE);
1186 const TopoDS_Wire& thew = TopoDS::Wire(exx1.Current());
1187 if(thew.IsSame(myFShape)) {
1188 const TopTools_ListOfShape& desfaces = trP.Modified(f2);
1189 myMap(myFShape) = desfaces;
1190 continue;
1191 }
1192 else if(thew.IsSame(myLShape)) {
1193 const TopTools_ListOfShape& desfaces = trP.Modified(f1);
1194 myMap(myLShape) = desfaces;
1195 continue;
1196 }
1197 if(fac.IsSame(sh)) {
1198 if (trP.IsDeleted(fac)) {
1199 }
1200 else {
1201 const TopTools_ListOfShape& desfaces = trP.Modified(fac);
1202 if(!desfaces.IsEmpty()) {
1203 myMap(orig).Clear();
1204 myMap(orig) = trP.Modified(fac);
1205 }
1206 }
1207 }
1208 }
1209 }
1210
1211 exx.Init(VraiForm, TopAbs_FACE);
1212 for(; exx.More(); exx.Next()) {
1213 const TopoDS_Face& fac = TopoDS::Face(exx.Current());
1214 TopTools_ListOfShape thelist;
1215 SlidingMap.Bind(fac, thelist);
1216 if (trP.IsDeleted(fac)) {
1217 }
1218 else {
1219 const TopTools_ListOfShape& desfaces = trP.Modified(fac);
1220 if(!desfaces.IsEmpty())
1221 SlidingMap(fac) = desfaces;
1222 else
1223 SlidingMap(fac).Append(fac);
1224 }
1225 }
1226
1227
0d969553 1228// gestion of faces of sliding
7fd59977 1229 SetGluedFaces(mySlface, theForm, SlidingMap, myGluedF);
1230
0d969553 1231 VraiForm = trP.Shape(); // primitive cut
7fd59977 1232
1233 if(!myGluedF.IsEmpty())
1234 myPerfSelection = BRepFeat_NoSelection;
1235 else
1236 myPerfSelection = BRepFeat_SelectionSh;
1237
1238 exx.Init(myPbase, TopAbs_EDGE);
1239 for(; exx.More(); exx.Next()) {
1240 const TopoDS_Edge& e = TopoDS::Edge(exx.Current());
1241 if(!myMap.IsBound(e)) {
0797d9d3 1242#ifdef OCCT_DEBUG
7fd59977 1243 if (trc) cout << " Sliding face not in Base shape" << endl;
1244#endif
1245 myStatusError = BRepFeat_IncSlidFace;
1246 NotDone();
1247 return;
1248 }
1249 }
1250
1251 myGShape = VraiForm;
1252
1253 if(!myGluedF.IsEmpty() && !mySUntil.IsNull()) {
0797d9d3 1254#ifdef OCCT_DEBUG
63c629aa 1255 if (trc)
1256 {
1257 cout << "The case is not computable" << endl;
1258 cout << " Glued faces not empty and Until shape not null" << endl;
1259 }
7fd59977 1260#endif
1261 myStatusError = BRepFeat_InvShape;
1262 NotDone();
1263 return;
1264 }
1265
0d969553 1266 LFPerform(); // topological reconstruction
7fd59977 1267}
1268
1269
1270//=======================================================================
1271//function : Propagate
0d969553
Y
1272//purpose : propagation on the faces of the inital shape, find faces
1273// concerned by the rib
7fd59977 1274//=======================================================================
1275
1276Standard_Boolean BRepFeat_MakeRevolutionForm::Propagate(TopTools_ListOfShape& SliList,
1277 const TopoDS_Face& fac,
1278 const gp_Pnt& Firstpnt,
1279 const gp_Pnt& Lastpnt,
1280 Standard_Boolean& falseside)
1281{
0797d9d3 1282#ifdef OCCT_DEBUG
7fd59977 1283 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
1284 if (trc) cout << "BRepFeat_MakeRevolutionForm::Propagate" << endl;
1285#endif
1286 gp_Pnt Firstpoint = Firstpnt;
1287 gp_Pnt Lastpoint = Lastpnt;
1288
1289 Standard_Boolean result = Standard_True;
1290 TopoDS_Face CurrentFace, saveFace;
1291 CurrentFace = TopoDS::Face(SliList.First());
1292 saveFace = CurrentFace;
1293 // BRepBuilderAPI_MakeFace fac(myPln);
1294 Standard_Boolean LastOK = Standard_False, FirstOK= Standard_False;
1295 TopoDS_Vertex v1, v2, v3, v4, Vert;
1296 //modified by NIZNHY-PKV Fri Mar 22 16:54:09 2002 f
1297 //BRepAlgo_Section sect (fac, CurrentFace, Standard_False);
1298 BRepAlgoAPI_Section sect (fac, CurrentFace, Standard_False);
1299 //modified by NIZNHY-PKV Fri Mar 22 16:54:14 2002 t
1300 sect.Approximation(Standard_True);
1301 sect.Build();
1302 TopExp_Explorer Ex;
1303 TopoDS_Edge e, e1;
1304 gp_Pnt FP, LP;
1305 Standard_Integer ii = 0;
1306 for (Ex.Init(sect.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) {
1307 ii++;
1308 if(ii==1){
1309 e = TopoDS::Edge(Ex.Current());
1310 }
1311 else if (ii > 1) {
1312 e1 = TopoDS::Edge(Ex.Current());
1313 break;
1314 }
1315 }
1316 if(e.IsNull()) {
1317 falseside = Standard_False;
1318 return Standard_False;
1319 }
1320 //
1321 //modified by NIZNHY-PKV Tue Apr 2 15:08:23 2002 f
1322 if(!e1.IsNull()) {
1323 Standard_Real aTolV1, aTolV2;
1324 myListOfEdges.Clear();
1325 TopTools_ListOfShape thelist;
1326 mySlface.Bind(CurrentFace, thelist);
1327 mySlface(CurrentFace).Append(e1);
1328
1329 myListOfEdges.Append(e1);
1330
1331 v1 = TopExp::FirstVertex(e1,Standard_True);
1332 v2 = TopExp::LastVertex (e1,Standard_True);
1333
1334 FP = BRep_Tool::Pnt(v1);
1335 LP = BRep_Tool::Pnt(v2);
1336
1337 aTolV1=BRep_Tool::Tolerance(v1);
1338 aTolV2=BRep_Tool::Tolerance(v2);
1339
1340 if(FP.Distance(Firstpoint) <= aTolV1 ||
1341 FP.Distance(Lastpoint) <= aTolV1) {
1342 FirstOK = Standard_True;
1343 }
1344 if(LP.Distance(Firstpoint)<= aTolV2 ||
1345 LP.Distance(Lastpoint) <= aTolV2) {
1346 LastOK = Standard_True;
1347 }
1348
1349 if(LastOK && FirstOK) {
1350 return result;
1351 }
1352
1353 else {
1354 myListOfEdges.Clear();
1355 }
1356 }
1357 //modified by NIZNHY-PKV Tue Apr 2 15:08:26 2002 t
1358 //
1359 if(!e1.IsNull()) {
1360 myListOfEdges.Clear();
1361 TopTools_ListOfShape thelist1;
1362 mySlface.Bind(CurrentFace, thelist1);
1363 mySlface(CurrentFace).Append(e);
1364
1365 myListOfEdges.Append(e);
1366
1367// mySlface.Bind(CurrentFace,TopTools_ListOfShape());
1368 mySlface(CurrentFace).Append(e1);
1369// myListOfEdges.Append(e1);
1370
1371 v1 = TopExp::FirstVertex(e,Standard_True);
1372 v2 = TopExp::LastVertex(e,Standard_True);
1373 v3 = TopExp::FirstVertex(e1,Standard_True);
1374 v4 = TopExp::LastVertex(e1,Standard_True);
1375 gp_Pnt p1, p2, p3, p4;
1376 p1 = BRep_Tool::Pnt(v1); FP = p1;
1377 p2 = BRep_Tool::Pnt(v2); LP = p2;
1378 p3 = BRep_Tool::Pnt(v3);
1379 p4 = BRep_Tool::Pnt(v4);
1380 if(p1.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1)) {
1381 if(p3.Distance(Lastpoint) <= BRep_Tool::Tolerance(v3)) {
1382 FirstOK = Standard_True;
1383 Lastpoint = p4;
1384 }
1385 else if(p4.Distance(Lastpoint) <= BRep_Tool::Tolerance(v4)) {
1386 FirstOK = Standard_True;
1387 Lastpoint = p3;
1388 }
1389 else {
1390 e1.Nullify();
1391 }
1392 }
1393 else if(p1.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) {
1394 if(p3.Distance(Firstpoint) <= BRep_Tool::Tolerance(v3)) {
1395 FirstOK = Standard_True;
1396 Firstpoint = p4;
1397 }
1398 else if(p4.Distance(Firstpoint) <= BRep_Tool::Tolerance(v4)) {
1399 FirstOK = Standard_True;
1400 Firstpoint = p3;
1401 }
1402 else {
1403 e1.Nullify();
1404 }
1405 }
1406 else if(p2.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2)) {
1407 if(p3.Distance(Lastpoint) <= BRep_Tool::Tolerance(v3)) {
1408 LastOK = Standard_True;
1409 Lastpoint = p4;
1410 }
1411 else if(p4.Distance(Lastpoint) <= BRep_Tool::Tolerance(v4)) {
1412 LastOK = Standard_True;
1413 Lastpoint = p3;
1414 }
1415 else {
1416 e1.Nullify();
1417 }
1418 }
1419 else if(p2.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) {
1420 if(p3.Distance(Firstpoint) <= BRep_Tool::Tolerance(v3)) {
1421 LastOK = Standard_True;
1422 Firstpoint = p4;
1423 }
1424 else if(p4.Distance(Firstpoint) <= BRep_Tool::Tolerance(v4)) {
1425 LastOK = Standard_True;
1426 Firstpoint = p3;
1427 }
1428 else {
1429 e1.Nullify();
1430 }
1431 }
1432 else {
4e57c75e 1433 e = e1;
7fd59977 1434 e1.Nullify();
1435 }
1436 }
1437 if(e1.IsNull()) {
7fd59977 1438 myListOfEdges.Clear();
1439 TopTools_ListOfShape thelist2;
1440 mySlface.Bind(CurrentFace, thelist2);
1441 mySlface(CurrentFace).Append(e);
1442
1443 myListOfEdges.Append(e);
1444
1445 v1 = TopExp::FirstVertex(e,Standard_True);
1446 v2 = TopExp::LastVertex(e,Standard_True);
1447
1448 FP = BRep_Tool::Pnt(v1);
1449 LP = BRep_Tool::Pnt(v2);
1450
1451 if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1)
1452 || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) {
1453 FirstOK = Standard_True;
1454 }
1455 if(LP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2)
1456 || LP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) {
1457 LastOK = Standard_True;
1458 }
1459
1460 if(LastOK && FirstOK) {
1461 return result;
1462 }
1463 }
1464
1465 TopTools_IndexedDataMapOfShapeListOfShape mapedges;
1466 TopExp::MapShapesAndAncestors(mySbase, TopAbs_EDGE, TopAbs_FACE, mapedges);
1467 TopExp_Explorer ex;
1468 TopoDS_Edge FirstEdge;
1469
1470 TopoDS_Vertex Vprevious; Vprevious.Nullify();
1471 TopoDS_Vertex Vpreprevious; Vpreprevious.Nullify();
1472
1473 while(!FirstOK) {
0d969553 1474 // find edge connected to v1:
7fd59977 1475 gp_Pnt pt;
1476 if(!v1.IsNull()) pt= BRep_Tool::Pnt(v1);
1477 gp_Pnt ptprev;
1478 if(!Vprevious.IsNull()) ptprev = BRep_Tool::Pnt(Vprevious);
1479 gp_Pnt ptpreprev;
1480 if(!Vpreprevious.IsNull()) ptpreprev = BRep_Tool::Pnt(Vpreprevious);
1481
1482 if((!Vprevious.IsNull() && ptprev.Distance(pt) <= myTol) ||
1483 (!Vpreprevious.IsNull() && ptpreprev.Distance(pt) <= myTol)) {
1484 falseside = Standard_False;
1485 return Standard_False;
1486 }
1487
1488 for (ex.Init(CurrentFace, TopAbs_EDGE); ex.More(); ex.Next()) {
1489 const TopoDS_Edge& e = TopoDS::Edge(ex.Current());
1490
1491 BRepExtrema_ExtPC projF(v1, e);
1492
1493 if(projF.IsDone() && projF.NbExt() >=1) {
1494 Standard_Real dist2min = RealLast();
1495 Standard_Integer index = 0;
1496 for (Standard_Integer sol =1 ; sol <= projF.NbExt(); sol++) {
1497 if (projF.SquareDistance(sol) <= dist2min) {
1498 index = sol;
1499 dist2min = projF.SquareDistance(sol);
1500 }
1501 }
1502 if (index != 0) {
1503 if (dist2min <= BRep_Tool::Tolerance(e) * BRep_Tool::Tolerance(e)) {
1504 FirstEdge = e;
1505 break;
1506 }
1507 }
1508 }
1509 }
1510
1511 const TopTools_ListOfShape& L = mapedges.FindFromKey(FirstEdge);
1512 TopTools_ListIteratorOfListOfShape It(L);
1513
1514 for (; It.More(); It.Next()) {
1515 const TopoDS_Face& FF = TopoDS::Face(It.Value());
1516 if (!FF.IsSame(CurrentFace)) {
1517 CurrentFace = FF;
1518 break;
1519 }
1520 }
1521
1522 //modified by NIZNHY-PKV Fri Mar 22 16:54:28 2002 f
1523 //BRepAlgo_Section sectf (fac, CurrentFace, Standard_False);
1524 BRepAlgoAPI_Section sectf (fac, CurrentFace, Standard_False);
1525 //modified by NIZNHY-PKV Fri Mar 22 16:54:33 2002 t
1526 sectf.Approximation(Standard_True);
1527 sectf.Build();
1528
1529 TopoDS_Edge edg1;
1530 for (Ex.Init(sectf.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) {
1531 edg1 = TopoDS::Edge(Ex.Current());
1532 gp_Pnt ppp1 = BRep_Tool::Pnt(TopExp::FirstVertex(edg1,Standard_True));
1533 gp_Pnt ppp2 = BRep_Tool::Pnt(TopExp::LastVertex(edg1,Standard_True));
1534 if(ppp1.Distance(BRep_Tool::Pnt(v1)) <= BRep_Tool::Tolerance(v1) ||
1535 ppp2.Distance(BRep_Tool::Pnt(v1)) <= BRep_Tool::Tolerance(v1))
1536 break;
1537 }
1538
1539 TopTools_ListOfShape thelist3;
1540 mySlface.Bind(CurrentFace, thelist3);
1541 mySlface(CurrentFace).Append(edg1);
1542 myListOfEdges.Append(edg1);
1543
1544 if (!edg1.IsNull()) SliList.Prepend(CurrentFace);
1545 else return Standard_False;
1546
1547 Vert = TopExp::FirstVertex(edg1,Standard_True);
1548 gp_Pnt PP = BRep_Tool::Pnt(Vert);
1549 FP = BRep_Tool::Pnt(v1);
1550 Standard_Real tol = BRep_Tool::Tolerance(edg1);
1551 Standard_Real tol1 = BRep_Tool::Tolerance(v1);
1552 if(tol1 > tol) tol = tol1;
1553 Standard_Real dist = PP.Distance(FP);
1554 if (dist <= tol) {
1555 Vpreprevious = Vprevious;
1556 Vprevious = v1;
1557 v1 = TopExp::LastVertex(edg1,Standard_True);
1558 }
1559 else {
1560 Vpreprevious = Vprevious;
1561 Vprevious = v1;
1562 v1 = Vert;
1563 }
1564
1565 FP = BRep_Tool::Pnt(v1);
1566
1567 if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1)
1568 || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) {
1569 FirstOK = Standard_True;
1570 }
1571 }
1572
1573 CurrentFace = saveFace;
1574 Vprevious.Nullify();
1575 Vpreprevious.Nullify();
1576
1577 while(!LastOK) {
0d969553 1578 // find edge connected to v2:
7fd59977 1579 gp_Pnt pt;
1580 if(!v2.IsNull()) pt= BRep_Tool::Pnt(v2);
1581 gp_Pnt ptprev;
1582 if(!Vprevious.IsNull()) ptprev = BRep_Tool::Pnt(Vprevious);
1583 gp_Pnt ptpreprev;
1584 if(!Vpreprevious.IsNull()) ptpreprev = BRep_Tool::Pnt(Vpreprevious);
1585
1586 if((!Vprevious.IsNull() && ptprev.Distance(pt) <= myTol) ||
1587 (!Vpreprevious.IsNull() && ptpreprev.Distance(pt) <= myTol)) {
1588 falseside = Standard_False;
1589 return Standard_False;
1590 }
1591
1592 for (ex.Init(CurrentFace, TopAbs_EDGE); ex.More(); ex.Next()) {
1593 const TopoDS_Edge& e = TopoDS::Edge(ex.Current());
1594 BRepExtrema_ExtPC projF(v2, e);
1595
1596 if(projF.IsDone() && projF.NbExt() >=1) {
1597 Standard_Real dist2min = RealLast();
1598 Standard_Integer index = 0;
1599 for (Standard_Integer sol =1 ; sol <= projF.NbExt(); sol++) {
1600 if (projF.SquareDistance(sol) <= dist2min) {
1601 index = sol;
1602 dist2min = projF.SquareDistance(sol);
1603 }
1604 }
1605 if (index != 0) {
1606 if (dist2min <= BRep_Tool::Tolerance(e) * BRep_Tool::Tolerance(e)) {
1607 FirstEdge = e;
1608 break;
1609 }
1610 }
1611 }
1612 }
1613
1614 const TopTools_ListOfShape& L = mapedges.FindFromKey(FirstEdge);
1615 TopTools_ListIteratorOfListOfShape It(L);
1616
1617 for (; It.More(); It.Next()) {
1618 const TopoDS_Face& FF = TopoDS::Face(It.Value());
1619 if (!FF.IsSame(CurrentFace)) {
1620 CurrentFace = FF;
1621 break;
1622 }
1623 }
1624
1625 ii = 0;
1626
1627 //modified by NIZNHY-PKV Fri Mar 22 16:54:45 2002 f
1628 //BRepAlgo_Section sectf (fac, CurrentFace, Standard_False);
1629 BRepAlgoAPI_Section sectf (fac, CurrentFace, Standard_False);
1630 //modified by NIZNHY-PKV Fri Mar 22 16:54:52 2002 t
1631 sectf.Approximation(Standard_True);
1632 sectf.Build();
1633
1634 TopoDS_Edge edg2;
1635 for (Ex.Init(sectf.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) {
1636 edg2 = TopoDS::Edge(Ex.Current());
1637 gp_Pnt ppp1 = BRep_Tool::Pnt(TopExp::FirstVertex(edg2,Standard_True));
1638 gp_Pnt ppp2 = BRep_Tool::Pnt(TopExp::LastVertex(edg2,Standard_True));
1639 if(ppp1.Distance(BRep_Tool::Pnt(v2)) <= BRep_Tool::Tolerance(v2) ||
1640 ppp2.Distance(BRep_Tool::Pnt(v2)) <= BRep_Tool::Tolerance(v2))
1641 break;
1642 }
1643 TopTools_ListOfShape thelist4;
1644 mySlface.Bind(CurrentFace, thelist4);
1645 mySlface(CurrentFace).Append(edg2);
1646 myListOfEdges.Append(edg2);
1647
1648 if (!edg2.IsNull()) SliList.Append(CurrentFace);
1649 else return Standard_False;
1650
1651 Vert = TopExp::FirstVertex(edg2,Standard_True);
1652 gp_Pnt PP = BRep_Tool::Pnt(Vert);
1653 FP = BRep_Tool::Pnt(v2);
1654 if (PP.Distance(FP)<= BRep_Tool::Tolerance(v2)) {
1655 Vpreprevious = Vprevious;
1656 Vprevious = v2;
1657 v2 = TopExp::LastVertex(edg2,Standard_True);
1658 }
1659 else {
1660 v2 = Vert;
1661 }
1662 FP = BRep_Tool::Pnt(v2);
1663
1664
1665 if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2)
1666 || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) {
1667 LastOK = Standard_True;
1668 }
1669 }
1670 if(!e1.IsNull()) myListOfEdges.Append(e1);
1671 return result;
1672
1673}
1674
1675
1676//=======================================================================
1677//function : MajMap
0d969553 1678//purpose : management of descendants
7fd59977 1679//=======================================================================
1680
1681static void MajMap(const TopoDS_Shape& theB,
1682 const LocOpe_RevolutionForm& theP,
1683 TopTools_DataMapOfShapeListOfShape& theMap, // myMap
1684 TopoDS_Shape& theFShape, // myFShape
1685 TopoDS_Shape& theLShape) // myLShape
1686{
1687 TopExp_Explorer exp(theP.FirstShape(),TopAbs_WIRE);
1688 if (exp.More()) {
1689 theFShape = exp.Current();
1690 TopTools_ListOfShape thelist;
1691 theMap.Bind(theFShape, thelist);
1692 for (exp.Init(theP.FirstShape(),TopAbs_FACE);exp.More();exp.Next()) {
1693 const TopoDS_Shape& sh = exp.Current();
1694 theMap(theFShape).Append(sh);
1695 }
1696 }
1697
1698 exp.Init(theP.LastShape(),TopAbs_WIRE);
1699 if (exp.More()) {
1700 theLShape = exp.Current();
1701 TopTools_ListOfShape thelist1;
1702 theMap.Bind(theLShape, thelist1);
1703 for (exp.Init(theP.LastShape(),TopAbs_FACE);exp.More();exp.Next()) {
1704 const TopoDS_Shape& sh = exp.Current();
1705 theMap(theLShape).Append(sh);
1706 }
1707 }
1708
1709 for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) {
1710 if (!theMap.IsBound(exp.Current())) {
7fd59977 1711 TopTools_ListOfShape thelist2;
1712 theMap.Bind(exp.Current(), thelist2);
1713 theMap(exp.Current()) = theP.Shapes(exp.Current());
1714 }
1715 }
1716}
1717
1718
1719 //=======================================================================
1720//function : SetGluedFaces
0d969553 1721//purpose : managemnet of sliding faces
7fd59977 1722//=======================================================================
1723
1724static void SetGluedFaces(const TopTools_DataMapOfShapeListOfShape& theSlmap,
1725 LocOpe_RevolutionForm& thePrism,
1726 const TopTools_DataMapOfShapeListOfShape& SlidingMap,
1727 TopTools_DataMapOfShapeShape& theMap)
1728{
0d969553 1729 // Slidings
7fd59977 1730 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(theSlmap);
1731 if(!theSlmap.IsEmpty()) {
1732 for (; itm.More(); itm.Next()) {
1733 const TopoDS_Face& fac = TopoDS::Face(itm.Key());
1734 const TopTools_ListOfShape& ledg = itm.Value();
1735 TopTools_ListIteratorOfListOfShape it;
1736 for (it.Initialize(ledg); it.More(); it.Next()) {
1737 const TopTools_ListOfShape& gfac = thePrism.Shapes(it.Value());
1738 if (gfac.Extent() != 1) {
0797d9d3 1739#ifdef OCCT_DEBUG
7fd59977 1740 cout << "Pb SetGluedFace" << endl;
1741#endif
1742 }
1743 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iterm(SlidingMap);
1744 for(; iterm.More(); iterm.Next()) {
1745 const TopoDS_Face& ff = TopoDS::Face(iterm.Key());
1746 const TopTools_ListOfShape& lfaces = iterm.Value();
1747 if(lfaces.IsEmpty()) continue;
1748 const TopoDS_Face& fff = TopoDS::Face(lfaces.First());
1749 if(gfac.First().IsSame(ff)) theMap.Bind(fff,fac);
1750 }
1751 }
1752 }
1753 }
1754}
1755