1 // Created on: 1997-10-14
2 // Created by: Olga KOULECHOVA
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
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>
28 #include <BRepFeat.hxx>
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>
42 #include <Geom2d_Curve.hxx>
43 #include <Geom2d_Line.hxx>
44 #include <Geom2dAPI_ExtremaCurveCurve.hxx>
45 #include <Geom2dAPI_InterCurveCurve.hxx>
46 #include <Geom_Circle.hxx>
47 #include <Geom_ConicalSurface.hxx>
48 #include <Geom_Curve.hxx>
49 #include <Geom_CylindricalSurface.hxx>
50 #include <Geom_Line.hxx>
51 #include <Geom_Plane.hxx>
52 #include <Geom_RectangularTrimmedSurface.hxx>
53 #include <Geom_Surface.hxx>
54 #include <Geom_ToroidalSurface.hxx>
55 #include <Geom_TrimmedCurve.hxx>
56 #include <GeomAPI.hxx>
57 #include <GeomAPI_ProjectPointOnCurve.hxx>
58 #include <GeomLProp_CLProps.hxx>
59 #include <GeomProjLib.hxx>
64 #include <gp_Pnt2d.hxx>
66 #include <gp_Vec2d.hxx>
67 #include <IntRes2d_IntersectionPoint.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>
77 #include <TColGeom_SequenceOfCurve.hxx>
78 #include <TColgp_Array1OfPnt.hxx>
79 #include <TColgp_SequenceOfPnt.hxx>
80 #include <TColStd_Array1OfReal.hxx>
82 #include <TopExp_Explorer.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>
91 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
92 #include <TopTools_ListIteratorOfListOfShape.hxx>
93 #include <TopTools_ListOfShape.hxx>
94 #include <TopTools_MapIteratorOfMapOfShape.hxx>
95 #include <TopTools_MapOfShape.hxx>
97 //modified by NIZNHY-PKV Fri Mar 22 16:56:15 2002
98 //#include <BRepAlgo_Cut.hxx>
99 //#include <BRepAlgo_Section.hxx>
100 //#include <BRepAlgo_Common.hxx>
101 //modified by NIZNHY-PKV Fri Mar 22 16:56:17 2002 t
103 extern Standard_Boolean BRepFeat_GettraceFEAT();
104 extern Standard_Boolean BRepFeat_GettraceFEATRIB();
107 static void MajMap(const TopoDS_Shape&, // base
108 const LocOpe_RevolutionForm&,
109 TopTools_DataMapOfShapeListOfShape&, // myMap
110 TopoDS_Shape&, // myFShape
111 TopoDS_Shape&); // myLShape
113 static void SetGluedFaces(const TopTools_DataMapOfShapeListOfShape& theSlmap,
114 LocOpe_RevolutionForm&,
115 const TopTools_DataMapOfShapeListOfShape& SlidingMap,
116 TopTools_DataMapOfShapeShape&);
118 //=======================================================================
121 //=======================================================================
123 void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
124 const TopoDS_Wire& W,
125 const Handle(Geom_Plane)& Plane,
127 const Standard_Real H1,
128 const Standard_Real H2,
129 const Standard_Integer Mode,
130 Standard_Boolean& Modify)
133 Standard_Boolean trc = BRepFeat_GettraceFEAT();
134 if (trc) cout << "BRepFeat_MakeRevolutionForm::Init" << endl;
136 Standard_Boolean RevolRib = Standard_True;
139 // modify = 0 if it is not required to make sliding
140 // = 1 if it is intended to try to make sliding
141 Standard_Boolean Sliding = Modify;
144 Handle(Geom_Line) Line = new Geom_Line(Axis);
145 Standard_Real LineFirst, LineLast;
147 LocOpe_CSIntersector ASI(Sbase);
148 TColGeom_SequenceOfCurve 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();
157 LineFirst = RealFirst();
158 LineLast = RealLast();
161 Handle(Geom2d_Curve) ln2d = GeomAPI::To2d(Line, Plane->Pln());
164 Standard_Real Rad = RealLast();
166 exx.Init(W, TopAbs_EDGE);
167 for(; exx.More(); exx.Next()) {
168 const TopoDS_Edge& e = TopoDS::Edge(exx.Current());
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();
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) {
183 if (trc) cout << " No projection points" << endl;
185 myStatusError = BRepFeat_NoProjPt;
189 Standard_Real par1 = proj1.Distance(1);
190 Standard_Real par2 = proj2.Distance(1);
191 Standard_Real Par = Min(par1, par2);
193 if(L<Rad && L > 0.) Rad = L;
196 Standard_Real height = Min(H1, H2);
198 if(Rad <= height) Rad = height + 0.01*height;
200 myAngle1 = asin(H1/Rad) + M_PI/10.;
201 myAngle2 = asin(H2/Rad) + M_PI/10.;
203 if((myAngle1 - M_PI/2) > Precision::Confusion())
205 if((myAngle2 - M_PI/2) > Precision::Confusion())
212 myFuse = Standard_False;
213 else // if(Mode == 1)
214 myFuse = Standard_True;
217 if (myFuse) cout << " Fuse" << endl;
218 if (!myFuse) cout << " Cut" << endl;
222 // ---Determination Tolerance : tolerance max on parameters
223 myTol = Precision::Confusion();
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;
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;
239 TopoDS_Shape aLocalShapeW = W.Oriented(TopAbs_FORWARD);
240 myWire = TopoDS::Wire(aLocalShapeW);
241 // myWire = TopoDS::Wire(W.Oriented(TopAbs_FORWARD));
253 // ---Calculate bounding box
256 TopTools_ListOfShape theList;
260 gp_Pnt FirstCorner, LastCorner;
261 Standard_Real bnd = HeightMax(mySbase, U, FirstCorner, LastCorner);
264 BRepPrimAPI_MakeBox Bndbox(FirstCorner, LastCorner);
265 TopoDS_Solid BndBox = Bndbox.Solid();
268 // ---Construction of the working plane face (section bounding box)
269 BRepLib_MakeFace PlaneF(myPln->Pln(), -6.*myBnd,
270 6.*myBnd, -6.*myBnd, 6.*myBnd);
271 TopoDS_Face PlaneFace = TopoDS::Face(PlaneF.Shape());
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
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());
285 // ---Find base faces of the rib
286 TopoDS_Edge FirstEdge, LastEdge;
287 TopoDS_Face FirstFace, LastFace;
288 TopoDS_Vertex FirstVertex, LastVertex;
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();
298 Standard_Boolean Data = ExtremeFaces(RevolRib, myBnd, myPln, FirstEdge, LastEdge,
299 FirstFace, LastFace, FirstVertex,
300 LastVertex, OnFirstFace, OnLastFace,
301 PtOnFirstEdge, PtOnLastEdge,
302 OnFirstEdge, OnLastEdge);
306 if (trc) cout << " No Extreme faces" << endl;
308 myStatusError = BRepFeat_NoExtFace;
314 // ---Proofing Point for the side of the wire to be filled - material side
315 gp_Pnt CheckPnt = CheckPoint(FirstEdge, bnd/10., myPln);
317 // Standard_Real f, l;
319 // ---Control sliding valid
320 // Many cases when the sliding is abandoned
321 Standard_Integer Concavite = 3; // a priori the profile is not concave
323 myFirstPnt = BRep_Tool::Pnt(FirstVertex);
324 myLastPnt = BRep_Tool::Pnt(LastVertex);
326 // SliList : list of faces concerned by the rib
327 TopTools_ListOfShape SliList;
328 SliList.Append(FirstFace);
330 if(Sliding) { // sliding
332 if (trc) cout << " Sliding" << endl;
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();
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;
347 if(Sliding) { // sliding
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();
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;
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
364 //gp_Pnt FirstCenter, LastCenter;
365 gp_Circ FirstCircle, LastCircle;
366 Handle(Geom_Curve) FirstCrv, LastCrv;
368 if(Sliding) { // sliding
369 GeomAPI_ProjectPointOnCurve proj(myFirstPnt, Line);
370 if(proj.NbPoints() < 1) {
372 if (trc) cout << " No First Point projection" << endl;
374 myStatusError = BRepFeat_NoProjPt;
378 Standard_Real FirstRayon = proj.Distance(1);
379 gp_Pnt FirstCenter = proj.Point(1);
381 GeomAPI_ProjectPointOnCurve proj1(myLastPnt, Line);
382 if(proj.NbPoints() < 1) {
384 if (trc) cout << " No Last Point projection" << endl;
386 myStatusError = BRepFeat_NoProjPt;
390 Standard_Real LastRayon = proj1.Distance(1);
391 gp_Pnt LastCenter = proj1.Point(1);
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);
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);
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());
411 BRepLib_MakeEdge ee1(theFC, v1, v2);
412 BRepLib_MakeEdge ee2(theLC, v3, v4);
414 if(Sliding && !PtOnFirstEdge) {
415 BRepExtrema_ExtCF ext1(TopoDS::Edge(ee1.Shape()), FirstFace);
416 if(ext1.NbExt() < 1 || ext1.SquareDistance(1) > Precision::SquareConfusion())
417 Sliding = Standard_False;
419 if(Sliding && !PtOnLastEdge) {
420 BRepExtrema_ExtCF ext2(ee2, LastFace); // ExtCF : curves and surfaces
421 if(ext2.NbExt() < 1 || ext2.SquareDistance(1) > Precision::SquareConfusion())
422 Sliding = Standard_False;
424 if(Sliding && PtOnFirstEdge) {
426 FirstCrv = BRep_Tool::Curve(OnFirstEdge, f, l);
427 if(FirstCrv->DynamicType() != STANDARD_TYPE(Geom_Circle))
428 Sliding = Standard_False;
430 Handle(Geom_Circle) C1 = Handle(Geom_Circle)::DownCast(FirstCrv);
431 gp_Circ Circ = C1->Circ();
433 gp_Ax1 circax = FirstCircle.Axis();
434 if(!circax.IsCoaxial(myAxe, Precision::Confusion(),
435 Precision::Confusion()))
436 Sliding = Standard_False;
439 if(fabs(FirstCircle.Radius()-FirstRayon) >=
441 // if(abs(FirstCircle.Radius()-FirstRayon) >=
443 Precision::Confusion())
444 Sliding = Standard_False;
449 if(Sliding && PtOnLastEdge) {
451 LastCrv = BRep_Tool::Curve(OnLastEdge, f, l);
452 if(LastCrv->DynamicType() != STANDARD_TYPE(Geom_Circle))
453 Sliding = Standard_False;
455 Handle(Geom_Circle) C1 = Handle(Geom_Circle)::DownCast(LastCrv);
456 gp_Circ Circ = C1->Circ();
458 gp_Ax1 circax = LastCircle.Axis();
459 if(!circax.IsCoaxial(myAxe, Precision::Confusion(),
460 Precision::Confusion()))
461 Sliding = Standard_False;
463 Standard_Real rad = LastCircle.Radius();
465 if(fabs(rad - LastRayon) >= Precision::Confusion()) {
467 // if(abs(rad - LastRayon) >= Precision::Confusion()) {
469 Sliding = Standard_False;
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
483 // ---case of sliding : construction of the face profile
486 if (trc) cout << " still Sliding" << endl;
489 Standard_Boolean ProfileOK;
490 ProfileOK = SlidingProfile(Prof,RevolRib,myTol,Concavite,myPln,BndFace,CheckPnt,
491 FirstFace,LastFace,FirstVertex,LastVertex,
498 cout << "Not computable" << endl;
499 cout << "Face profile not computable" << endl;
502 myStatusError = BRepFeat_NoFaceProf;
508 // ---Propagation on faces of the initial shape
509 // to find the faces concerned by the rib
510 Standard_Boolean falseside = Standard_True;
511 Sliding = Propagate(SliList, Prof, myFirstPnt, myLastPnt, falseside);
512 // Control if there is everything required to have the material at the proper side
513 if(falseside == Standard_False) {
515 cout << " Verify plane and wire orientation" << endl;
517 myStatusError = BRepFeat_FalseSide;
524 // ---Generation of the base profile of the rib
528 TopoDS_Edge thePreviousEdge;
530 thePreviousEdge.Nullify();
532 // counter of the number of edges to fill the map
533 Standard_Integer counter = 1;
535 // ---case of sliding
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);
544 if(E.IsSame(FirstEdge)) {
546 Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l);
548 if(!FirstEdge.IsSame(LastEdge)) {
549 pt = BRep_Tool::Pnt(TopExp::LastVertex(E,Standard_True));
553 Standard_Real fpar = IntPar(cc, myFirstPnt);
554 Standard_Real lpar = IntPar(cc, pt);
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());
567 const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
568 BRepLib_MakeVertex v2(pt);
570 BRepLib_MakeEdge e(cc, v1, v2);
571 ee1 = TopoDS::Edge(e.Shape());
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);
579 thePreviousEdge = ee1;
586 // Case of several edges
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);
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);
604 // v1 = TopExp::LastVertex(E,Standard_True);
605 v1 = TopExp::FirstVertex(E,Standard_True);
606 v2 = TopExp::LastVertex(E,Standard_True);
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);
616 if(counter == 1) theFV = TopExp::FirstVertex(E11,Standard_True);
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;
624 if(thePreviousEdge.IsNull()) {
625 BRepLib_MakeEdge e(cc, pf , pl);
626 ee = TopoDS::Edge(e.Shape());
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());
634 TopoDS_Shape aLocalShape = ee.Oriented(E.Orientation());
635 ee = TopoDS::Edge(aLocalShape);
636 // ee = TopoDS::Edge(ee.Oriented(E.Orientation()));
638 myLFMap(E).Append(ee);
639 if(counter == 1) theFV = TopExp::FirstVertex(ee,Standard_True);
640 thePreviousEdge = ee;
647 TopTools_ListIteratorOfListOfShape it(myListOfEdges);
648 Standard_Boolean FirstOK = Standard_False;
649 Standard_Boolean LastOK = Standard_False;
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();
658 const TopoDS_Edge& edg = TopoDS::Edge(it.Value());
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();
665 fp = cc->Value(cc->FirstParameter());
666 lp = cc->Value(cc->LastParameter());
667 Standard_Real dist = fp.Distance(theLastPnt);
670 LastOK = Standard_True;
673 dist = lp.Distance(theLastPnt);
676 LastOK = Standard_True;
680 Standard_Integer FirstFlag = 0;
681 if(sens==1 && lp.Distance(myFirstPnt) <= myTol) {
682 FirstOK = Standard_True;
685 else if(sens==2 && fp.Distance(myFirstPnt) <= myTol) {
686 FirstOK = Standard_True;
692 Standard_Real fpar = cc->FirstParameter();
693 Standard_Real lpar = cc->LastParameter();
695 if(thePreviousEdge.IsNull()) {
696 BRepLib_MakeEdge e(cc, fpar, lpar);
697 eeee = TopoDS::Edge(e.Shape());
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());
707 if(thePreviousEdge.IsNull()) {
708 BRepLib_MakeVertex v1(cc->Value(fpar));
709 BRepLib_MakeEdge e(cc, v1, theFV);
710 eeee = TopoDS::Edge(e.Shape());
713 const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
714 BRepLib_MakeEdge e(cc, v1, theFV);
715 eeee = TopoDS::Edge(e.Shape());
719 thePreviousEdge = eeee;
721 if(counter == 1) theFV = TopExp::FirstVertex(eeee,Standard_True);
723 NewListOfEdges.Append(edg);
728 theLastPnt = BRep_Tool::Pnt(TopExp::LastVertex(theEdge,Standard_True));
734 else if(FirstFlag == 2) {
739 it.Initialize(myListOfEdges);
740 LastOK = Standard_False;
742 else if(it.More()) it.Next();
744 Sliding = Standard_False;
751 TopTools_DataMapOfShapeListOfShape SlidMap;
754 if(Sliding && counter1 > counter) {
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());
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());
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());
777 if(!SlidMap.IsBound(fac)) {
778 TopTools_ListOfShape thelist2;
779 SlidMap.Bind(fac, thelist2);
781 SlidMap(fac).Append(E);
795 // ---Arguments of LocOpe_LinearForm : arguments of the prism
799 BB.MakeFace(F, myPln, myTol);
800 w.Closed (BRep_Tool::IsClosed (w));
808 // ---Case without sliding : construction of the face profile
812 if (Modify) cout << " Sliding failure" << endl;
813 cout << " no Sliding" << endl;
816 TopExp_Explorer explo1(BndFace, TopAbs_WIRE);
817 TopoDS_Wire WWW = TopoDS::Wire(explo1.Current());
818 BRepTools_WireExplorer explo(WWW);
822 TopoDS_Vertex NewV1, NewV2, LastV, v;
823 NewV1.Nullify(); NewV2.Nullify(); LastV.Nullify();
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);
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));
842 Handle(Geom2d_Curve) l2d = GeomAPI::To2d(ln, Plane->Pln());
843 Geom2dAPI_InterCurveCurve intcc(l2d, ln2d, Precision::Confusion());
844 TopoDS_Vertex VV; VV.Nullify();
846 if(intcc.NbPoints() > 0) {
847 gp_Pnt2d P = intcc.Point(1);
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());
856 if(VV.IsNull() && NewV1.IsNull()) continue;
858 if(!VV.IsNull() && NewV1.IsNull()) {
861 BRepLib_MakeEdge ee1(NewV1, LastV);
866 if(VV.IsNull() && !NewV1.IsNull()) {
867 BRepLib_MakeEdge ee1(LastV, v2);
873 if(!VV.IsNull() && !NewV1.IsNull()) {
875 BRepLib_MakeEdge ee1(LastV, NewV2);
878 BRepLib_MakeEdge ee2(LastV, NewV1);
883 Wiwiwi.Closed (BRep_Tool::IsClosed (Wiwiwi));
885 BRepLib_MakeFace newbndface(myPln->Pln(), Wiwiwi, Standard_True);
886 TopoDS_Face NewBndFace = TopoDS::Face(newbndface.Shape());
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);
898 const TopoDS_Wire& aCurWire = TopoDS::Wire(exp.Current());
899 // akm 13/02/02 : we know the plane. Why not to use it?
900 // BRepLib_MakeFace ff(w);
901 BRepLib_MakeFace ff(myPln->Pln(), aCurWire, Standard_True);
902 NewBndFace = TopoDS::Face(ff.Shape());
906 if(!BRepAlgo::IsValid(NewBndFace)) {
908 cout << "Invalid new bounding face" << endl;
910 myStatusError = BRepFeat_InvShape;
915 BndFace = NewBndFace;
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);
929 cout << "Not computable" << endl;
930 cout << " Face profile not computable" << endl;
933 myStatusError = BRepFeat_NoFaceProf;
939 // ---Propagation on the faces of the initial shape
940 // to find the faces concerned by the rib
941 Standard_Boolean falseside = Standard_True;
942 Propagate(SliList, Prof, myFirstPnt, myLastPnt, falseside);
943 // Control if there is everything required to have the material at the proper side
944 if(falseside == Standard_False) {
946 cout << " Verify plane and wire orientation" << endl;
948 myStatusError = BRepFeat_FalseSide;
955 TopTools_ListIteratorOfListOfShape it;
956 it.Initialize(SliList);
960 BB.MakeShell(TopoDS::Shell(comp));
962 for(; it.More(); it.Next()) {
963 BB.Add(comp, it.Value());
965 comp.Closed (BRep_Tool::IsClosed (comp));
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());
985 //=======================================================================
987 //purpose : add elements of gluing
988 //=======================================================================
990 void BRepFeat_MakeRevolutionForm::Add(const TopoDS_Edge& E,
991 const TopoDS_Face& F)
994 Standard_Boolean trc = BRepFeat_GettraceFEAT();
995 if (trc) cout << "BRepFeat_MakeRevolutionForm::Add" << endl;
997 if(mySlface.IsEmpty()) {
999 for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
1000 if (exp.Current().IsSame(F)) {
1005 throw Standard_ConstructionError();
1008 if (!mySlface.IsBound(F)) {
1009 TopTools_ListOfShape thelist;
1010 mySlface.Bind(F, thelist);
1012 TopTools_ListIteratorOfListOfShape itl(mySlface(F));
1013 for (; itl.More();itl.Next()) {
1014 if (itl.Value().IsSame(E)) {
1019 mySlface(F).Append(E);
1026 //=======================================================================
1027 //function : Perform
1028 //purpose : construction
1029 //=======================================================================
1031 void BRepFeat_MakeRevolutionForm::Perform()
1034 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1035 if (trc) cout << "BRepFeat_MakeRevolutionForm::Perform()" << endl;
1037 if(mySbase.IsNull() || mySkface.IsNull() || myPbase.IsNull()) {
1039 if (trc) cout << " Fields not initialized" << endl;
1041 myStatusError = BRepFeat_NotInitialized;
1048 TopExp_Explorer exx(myPbase, TopAbs_VERTEX);
1049 for(; exx.More(); exx.Next()) {
1050 const TopoDS_Vertex& vv = TopoDS::Vertex(exx.Current());
1052 Pt = BRep_Tool::Pnt(vv);
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());
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();
1087 mySlface(f1).Clear();
1088 mySlface(f1).Append(E2);
1094 trsf.Perform(mySkface, Standard_False);
1095 // flo : check if it is required to reattributr the field mySkface
1096 // TopoDS_Face mySkface = TopoDS::Face(trsf.Shape());
1097 mySkface = TopoDS::Face(trsf.Shape());
1100 LocOpe_RevolutionForm theForm;
1101 theForm.Perform(myPbase, myAxe, (myAngle1+myAngle2));
1102 TopoDS_Shape VraiForm = theForm.Shape(); // uncut primitive
1104 // management of descendants
1105 MajMap(myPbase,theForm,myMap,myFShape,myLShape);
1111 gp_Pln Pln0 = myPln->Pln();
1112 BRepLib_MakeFace f(Pln0);
1115 gp_Vec vec1 = myHeight1*Normal(f, Pt);
1116 gp_Vec vec2 = -myHeight2*Normal(f, Pt);
1118 gp_Pln Pln1 = Pln0.Translated(vec1);
1119 gp_Pln Pln2 = Pln0.Translated(vec2);
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);
1128 LocOpe_CSIntersector ASI1(f1);
1129 LocOpe_CSIntersector ASI2(f2);
1131 Handle(Geom_Line) normale = new Geom_Line(Pt, vec1);
1132 TColGeom_SequenceOfCurve scur;
1133 scur.Append(normale);
1138 if(!ASI1.IsDone() || !ASI2.IsDone() ||
1139 ASI1.NbPoints(1) != 1 || ASI2.NbPoints(1) != 1) {
1141 if (trc) cout << " Intersection failure" << endl;
1143 myStatusError = BRepFeat_BadIntersect;
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();
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);
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;
1168 // management of descendants
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;
1186 else if(thew.IsSame(myLShape)) {
1187 const TopTools_ListOfShape& desfaces = trP.Modified(f1);
1188 myMap(myLShape) = desfaces;
1191 if(fac.IsSame(sh)) {
1192 if (trP.IsDeleted(fac)) {
1195 const TopTools_ListOfShape& desfaces = trP.Modified(fac);
1196 if(!desfaces.IsEmpty()) {
1197 myMap(orig).Clear();
1198 myMap(orig) = trP.Modified(fac);
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)) {
1213 const TopTools_ListOfShape& desfaces = trP.Modified(fac);
1214 if(!desfaces.IsEmpty())
1215 SlidingMap(fac) = desfaces;
1217 SlidingMap(fac).Append(fac);
1222 // gestion of faces of sliding
1223 SetGluedFaces(mySlface, theForm, SlidingMap, myGluedF);
1225 VraiForm = trP.Shape(); // primitive cut
1227 if(!myGluedF.IsEmpty())
1228 myPerfSelection = BRepFeat_NoSelection;
1230 myPerfSelection = BRepFeat_SelectionSh;
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)) {
1237 if (trc) cout << " Sliding face not in Base shape" << endl;
1239 myStatusError = BRepFeat_IncSlidFace;
1245 myGShape = VraiForm;
1247 if(!myGluedF.IsEmpty() && !mySUntil.IsNull()) {
1251 cout << "The case is not computable" << endl;
1252 cout << " Glued faces not empty and Until shape not null" << endl;
1255 myStatusError = BRepFeat_InvShape;
1260 LFPerform(); // topological reconstruction
1264 //=======================================================================
1265 //function : Propagate
1266 //purpose : propagation on the faces of the inital shape, find faces
1267 // concerned by the rib
1268 //=======================================================================
1270 Standard_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)
1277 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
1278 if (trc) cout << "BRepFeat_MakeRevolutionForm::Propagate" << endl;
1280 gp_Pnt Firstpoint = Firstpnt;
1281 gp_Pnt Lastpoint = Lastpnt;
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);
1299 Standard_Integer ii = 0;
1300 for (Ex.Init(sect.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) {
1303 e = TopoDS::Edge(Ex.Current());
1306 e1 = TopoDS::Edge(Ex.Current());
1311 falseside = Standard_False;
1312 return Standard_False;
1315 //modified by NIZNHY-PKV Tue Apr 2 15:08:23 2002 f
1317 Standard_Real aTolV1, aTolV2;
1318 myListOfEdges.Clear();
1319 TopTools_ListOfShape thelist;
1320 mySlface.Bind(CurrentFace, thelist);
1321 mySlface(CurrentFace).Append(e1);
1323 myListOfEdges.Append(e1);
1325 v1 = TopExp::FirstVertex(e1,Standard_True);
1326 v2 = TopExp::LastVertex (e1,Standard_True);
1328 FP = BRep_Tool::Pnt(v1);
1329 LP = BRep_Tool::Pnt(v2);
1331 aTolV1=BRep_Tool::Tolerance(v1);
1332 aTolV2=BRep_Tool::Tolerance(v2);
1334 if(FP.Distance(Firstpoint) <= aTolV1 ||
1335 FP.Distance(Lastpoint) <= aTolV1) {
1336 FirstOK = Standard_True;
1338 if(LP.Distance(Firstpoint)<= aTolV2 ||
1339 LP.Distance(Lastpoint) <= aTolV2) {
1340 LastOK = Standard_True;
1343 if(LastOK && FirstOK) {
1348 myListOfEdges.Clear();
1351 //modified by NIZNHY-PKV Tue Apr 2 15:08:26 2002 t
1354 myListOfEdges.Clear();
1355 TopTools_ListOfShape thelist1;
1356 mySlface.Bind(CurrentFace, thelist1);
1357 mySlface(CurrentFace).Append(e);
1359 myListOfEdges.Append(e);
1361 // mySlface.Bind(CurrentFace,TopTools_ListOfShape());
1362 mySlface(CurrentFace).Append(e1);
1363 // myListOfEdges.Append(e1);
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;
1379 else if(p4.Distance(Lastpoint) <= BRep_Tool::Tolerance(v4)) {
1380 FirstOK = Standard_True;
1387 else if(p1.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) {
1388 if(p3.Distance(Firstpoint) <= BRep_Tool::Tolerance(v3)) {
1389 FirstOK = Standard_True;
1392 else if(p4.Distance(Firstpoint) <= BRep_Tool::Tolerance(v4)) {
1393 FirstOK = Standard_True;
1400 else if(p2.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2)) {
1401 if(p3.Distance(Lastpoint) <= BRep_Tool::Tolerance(v3)) {
1402 LastOK = Standard_True;
1405 else if(p4.Distance(Lastpoint) <= BRep_Tool::Tolerance(v4)) {
1406 LastOK = Standard_True;
1413 else if(p2.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) {
1414 if(p3.Distance(Firstpoint) <= BRep_Tool::Tolerance(v3)) {
1415 LastOK = Standard_True;
1418 else if(p4.Distance(Firstpoint) <= BRep_Tool::Tolerance(v4)) {
1419 LastOK = Standard_True;
1432 myListOfEdges.Clear();
1433 TopTools_ListOfShape thelist2;
1434 mySlface.Bind(CurrentFace, thelist2);
1435 mySlface(CurrentFace).Append(e);
1437 myListOfEdges.Append(e);
1439 v1 = TopExp::FirstVertex(e,Standard_True);
1440 v2 = TopExp::LastVertex(e,Standard_True);
1442 FP = BRep_Tool::Pnt(v1);
1443 LP = BRep_Tool::Pnt(v2);
1445 if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1)
1446 || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) {
1447 FirstOK = Standard_True;
1449 if(LP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2)
1450 || LP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) {
1451 LastOK = Standard_True;
1454 if(LastOK && FirstOK) {
1459 TopTools_IndexedDataMapOfShapeListOfShape mapedges;
1460 TopExp::MapShapesAndAncestors(mySbase, TopAbs_EDGE, TopAbs_FACE, mapedges);
1462 TopoDS_Edge FirstEdge;
1464 TopoDS_Vertex Vprevious; Vprevious.Nullify();
1465 TopoDS_Vertex Vpreprevious; Vpreprevious.Nullify();
1468 // find edge connected to v1:
1470 if(!v1.IsNull()) pt= BRep_Tool::Pnt(v1);
1472 if(!Vprevious.IsNull()) ptprev = BRep_Tool::Pnt(Vprevious);
1474 if(!Vpreprevious.IsNull()) ptpreprev = BRep_Tool::Pnt(Vpreprevious);
1476 if((!Vprevious.IsNull() && ptprev.Distance(pt) <= myTol) ||
1477 (!Vpreprevious.IsNull() && ptpreprev.Distance(pt) <= myTol)) {
1478 falseside = Standard_False;
1479 return Standard_False;
1482 for (ex.Init(CurrentFace, TopAbs_EDGE); ex.More(); ex.Next()) {
1483 const TopoDS_Edge& aCurEdge = TopoDS::Edge(ex.Current());
1485 BRepExtrema_ExtPC projF(v1, aCurEdge);
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) {
1493 dist2min = projF.SquareDistance(sol);
1497 if (dist2min <= BRep_Tool::Tolerance(aCurEdge) * BRep_Tool::Tolerance(aCurEdge)) {
1498 FirstEdge = aCurEdge;
1505 const TopTools_ListOfShape& L = mapedges.FindFromKey(FirstEdge);
1506 TopTools_ListIteratorOfListOfShape It(L);
1508 for (; It.More(); It.Next()) {
1509 const TopoDS_Face& FF = TopoDS::Face(It.Value());
1510 if (!FF.IsSame(CurrentFace)) {
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);
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))
1533 TopTools_ListOfShape thelist3;
1534 mySlface.Bind(CurrentFace, thelist3);
1535 mySlface(CurrentFace).Append(edg1);
1536 myListOfEdges.Append(edg1);
1538 if (!edg1.IsNull()) SliList.Prepend(CurrentFace);
1539 else return Standard_False;
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);
1549 Vpreprevious = Vprevious;
1551 v1 = TopExp::LastVertex(edg1,Standard_True);
1554 Vpreprevious = Vprevious;
1559 FP = BRep_Tool::Pnt(v1);
1561 if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1)
1562 || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) {
1563 FirstOK = Standard_True;
1567 CurrentFace = saveFace;
1568 Vprevious.Nullify();
1569 Vpreprevious.Nullify();
1572 // find edge connected to v2:
1574 if(!v2.IsNull()) pt= BRep_Tool::Pnt(v2);
1576 if(!Vprevious.IsNull()) ptprev = BRep_Tool::Pnt(Vprevious);
1578 if(!Vpreprevious.IsNull()) ptpreprev = BRep_Tool::Pnt(Vpreprevious);
1580 if((!Vprevious.IsNull() && ptprev.Distance(pt) <= myTol) ||
1581 (!Vpreprevious.IsNull() && ptpreprev.Distance(pt) <= myTol)) {
1582 falseside = Standard_False;
1583 return Standard_False;
1586 for (ex.Init(CurrentFace, TopAbs_EDGE); ex.More(); ex.Next()) {
1587 const TopoDS_Edge& aCurEdge = TopoDS::Edge(ex.Current());
1588 BRepExtrema_ExtPC projF(v2, aCurEdge);
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) {
1596 dist2min = projF.SquareDistance(sol);
1600 if (dist2min <= BRep_Tool::Tolerance(aCurEdge) * BRep_Tool::Tolerance(aCurEdge)) {
1601 FirstEdge = aCurEdge;
1608 const TopTools_ListOfShape& L = mapedges.FindFromKey(FirstEdge);
1609 TopTools_ListIteratorOfListOfShape It(L);
1611 for (; It.More(); It.Next()) {
1612 const TopoDS_Face& FF = TopoDS::Face(It.Value());
1613 if (!FF.IsSame(CurrentFace)) {
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);
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))
1637 TopTools_ListOfShape thelist4;
1638 mySlface.Bind(CurrentFace, thelist4);
1639 mySlface(CurrentFace).Append(edg2);
1640 myListOfEdges.Append(edg2);
1642 if (!edg2.IsNull()) SliList.Append(CurrentFace);
1643 else return Standard_False;
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;
1651 v2 = TopExp::LastVertex(edg2,Standard_True);
1656 FP = BRep_Tool::Pnt(v2);
1659 if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2)
1660 || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) {
1661 LastOK = Standard_True;
1664 if(!e1.IsNull()) myListOfEdges.Append(e1);
1670 //=======================================================================
1672 //purpose : management of descendants
1673 //=======================================================================
1675 static 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
1681 TopExp_Explorer exp(theP.FirstShape(),TopAbs_WIRE);
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);
1692 exp.Init(theP.LastShape(),TopAbs_WIRE);
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);
1703 for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) {
1704 if (!theMap.IsBound(exp.Current())) {
1705 TopTools_ListOfShape thelist2;
1706 theMap.Bind(exp.Current(), thelist2);
1707 theMap(exp.Current()) = theP.Shapes(exp.Current());
1713 //=======================================================================
1714 //function : SetGluedFaces
1715 //purpose : managemnet of sliding faces
1716 //=======================================================================
1718 static void SetGluedFaces(const TopTools_DataMapOfShapeListOfShape& theSlmap,
1719 LocOpe_RevolutionForm& thePrism,
1720 const TopTools_DataMapOfShapeListOfShape& SlidingMap,
1721 TopTools_DataMapOfShapeShape& theMap)
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) {
1734 cout << "Pb SetGluedFace" << endl;
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);