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.
17 #include <BRepFeat_MakeRevolutionForm.ixx>
19 #include <BRepFeat.hxx>
22 #include <LocOpe_RevolutionForm.hxx>
23 #include <LocOpe_CSIntersector.hxx>
24 #include <LocOpe_PntFace.hxx>
25 #include <LocOpe_Gluer.hxx>
26 #include <LocOpe_FindEdges.hxx>
34 #include <gp_Vec2d.hxx>
35 #include <gp_Pnt2d.hxx>
37 #include <Geom_Curve.hxx>
39 #include <Geom2d_Curve.hxx>
40 #include <Geom2d_Line.hxx>
42 #include <Geom_Line.hxx>
43 #include <Geom_Circle.hxx>
44 #include <Geom_Plane.hxx>
45 #include <Geom_Surface.hxx>
46 #include <Geom_CylindricalSurface.hxx>
47 #include <Geom_ConicalSurface.hxx>
48 #include <Geom_ToroidalSurface.hxx>
49 #include <Geom_RectangularTrimmedSurface.hxx>
51 #include <Geom_TrimmedCurve.hxx>
52 #include <GeomProjLib.hxx>
54 #include <Geom2dAPI_InterCurveCurve.hxx>
55 #include <Geom2dAPI_ExtremaCurveCurve.hxx>
56 #include <Geom2d_Curve.hxx>
57 #include <Geom2d_Curve.hxx>
60 #include <GeomAPI.hxx>
61 #include <GeomAPI_ProjectPointOnCurve.hxx>
63 #include <TColgp_SequenceOfPnt.hxx>
65 #include <TColGeom_SequenceOfCurve.hxx>
67 #include <TColStd_Array1OfReal.hxx>
68 #include <IntRes2d_IntersectionPoint.hxx>
70 #include <BRepTools_WireExplorer.hxx>
72 #include <BRep_Tool.hxx>
73 #include <BRep_Builder.hxx>
75 #include <TopExp_Explorer.hxx>
78 #include <TopTools_MapOfShape.hxx>
79 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
80 #include <TopTools_ListOfShape.hxx>
81 #include <TopTools_ListIteratorOfListOfShape.hxx>
82 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
83 #include <TopTools_MapIteratorOfMapOfShape.hxx>
84 #include <TopOpeBRepBuild_HBuilder.hxx>
85 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
87 #include <TColgp_Array1OfPnt.hxx>
89 #include <TColGeom_Array1OfCurve.hxx>
92 #include <TopoDS_Shape.hxx>
93 #include <TopoDS_Face.hxx>
95 #include <BRepLib_MakeVertex.hxx>
96 #include <BRepLib_MakeEdge.hxx>
97 #include <BRepLib_MakeFace.hxx>
99 #include <BRepTools.hxx>
101 #include <BRepPrimAPI_MakeBox.hxx>
102 #include <BRepBuilderAPI_MakeFace.hxx>
104 #include <BRepAlgo.hxx>
106 //modified by NIZNHY-PKV Fri Mar 22 16:56:15 2002
107 //#include <BRepAlgo_Cut.hxx>
108 //#include <BRepAlgo_Section.hxx>
109 //#include <BRepAlgo_Common.hxx>
110 #include <BRepAlgoAPI_Cut.hxx>
111 #include <BRepAlgoAPI_Section.hxx>
112 #include <BRepAlgoAPI_Common.hxx>
113 //modified by NIZNHY-PKV Fri Mar 22 16:56:17 2002 t
115 #include <BRepBuilderAPI_Transform.hxx>
116 #include <BRepExtrema_ExtPC.hxx>
117 #include <BRepExtrema_ExtCF.hxx>
119 #include <BRepTools_Modifier.hxx>
120 #include <BRepTools_TrsfModification.hxx>
122 #include <BRepTopAdaptor_FClass2d.hxx>
124 #include <Standard_ConstructionError.hxx>
126 #include <Precision.hxx>
129 #include <ElCLib.hxx>
130 #include <ElSLib.hxx>
133 #include <GeomLProp_CLProps.hxx>
136 extern Standard_Boolean BRepFeat_GettraceFEAT();
137 extern Standard_Boolean BRepFeat_GettraceFEATRIB();
140 static void MajMap(const TopoDS_Shape&, // base
141 const LocOpe_RevolutionForm&,
142 TopTools_DataMapOfShapeListOfShape&, // myMap
143 TopoDS_Shape&, // myFShape
144 TopoDS_Shape&); // myLShape
146 static void SetGluedFaces(const TopTools_DataMapOfShapeListOfShape& theSlmap,
147 LocOpe_RevolutionForm&,
148 const TopTools_DataMapOfShapeListOfShape& SlidingMap,
149 TopTools_DataMapOfShapeShape&);
151 //=======================================================================
154 //=======================================================================
156 void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
157 const TopoDS_Wire& W,
158 const Handle(Geom_Plane)& Plane,
160 const Standard_Real H1,
161 const Standard_Real H2,
162 const Standard_Integer Mode,
163 Standard_Boolean& Modify)
166 Standard_Boolean trc = BRepFeat_GettraceFEAT();
167 if (trc) cout << "BRepFeat_MakeRevolutionForm::Init" << endl;
169 Standard_Boolean RevolRib = Standard_True;
172 // modify = 0 if it is not required to make sliding
173 // = 1 if it is intended to try to make sliding
174 Standard_Boolean Sliding = Modify;
177 Handle(Geom_Line) Line = new Geom_Line(Axis);
178 Standard_Real LineFirst, LineLast;
180 LocOpe_CSIntersector ASI(Sbase);
181 TColGeom_SequenceOfCurve scur;
185 if(ASI.IsDone() && ASI.NbPoints(1) >= 2) {
186 LineLast = ASI.Point(1, ASI.NbPoints(1)).Parameter();
187 LineFirst = ASI.Point(1, 1).Parameter();
190 LineFirst = RealFirst();
191 LineLast = RealLast();
194 Handle(Geom2d_Curve) ln2d = GeomAPI::To2d(Line, Plane->Pln());
197 Standard_Real Rad = RealLast();
199 exx.Init(W, TopAbs_EDGE);
200 for(; exx.More(); exx.Next()) {
201 const TopoDS_Edge& e = TopoDS::Edge(exx.Current());
203 Handle(Geom_Curve) c = BRep_Tool::Curve(e, f, l);
204 Handle(Geom2d_Curve) c2d = GeomAPI::To2d(c, Plane->Pln());
205 Geom2dAPI_ExtremaCurveCurve extr(ln2d, c2d, LineFirst, LineLast,f,l);
206 Quantity_Length L = RealLast();
207 if(extr.NbExtrema() >= 1) {
208 L = extr.LowerDistance();
210 gp_Pnt p1 = c->Value(f);
211 gp_Pnt p2 = c->Value(l);
212 GeomAPI_ProjectPointOnCurve proj1(p1, Line);
213 GeomAPI_ProjectPointOnCurve proj2(p2, Line);
214 if(proj1.NbPoints() < 1 || proj2.NbPoints() < 1) {
216 if (trc) cout << " No projection points" << endl;
218 myStatusError = BRepFeat_NoProjPt;
222 Standard_Real par1 = proj1.Distance(1);
223 Standard_Real par2 = proj2.Distance(1);
224 Standard_Real Par = Min(par1, par2);
226 if(L<Rad && L > 0.) Rad = L;
229 Standard_Real height = Min(H1, H2);
231 if(Rad <= height) Rad = height + 0.01*height;
233 myAngle1 = asin(H1/Rad) + M_PI/10.;
234 myAngle2 = asin(H2/Rad) + M_PI/10.;
236 if((myAngle1 - M_PI/2) > Precision::Confusion())
238 if((myAngle2 - M_PI/2) > Precision::Confusion())
245 myFuse = Standard_False;
246 else // if(Mode == 1)
247 myFuse = Standard_True;
250 if (myFuse) cout << " Fuse" << endl;
251 if (!myFuse) cout << " Cut" << endl;
255 // ---Determination Tolerance : tolerance max on parameters
256 myTol = Precision::Confusion();
258 exx.Init(W, TopAbs_VERTEX);
259 for(; exx.More(); exx.Next()) {
260 const Standard_Real& tol = BRep_Tool::
261 Tolerance(TopoDS::Vertex(exx.Current()));
262 if(tol > myTol) myTol = tol;
265 exx.Init(Sbase, TopAbs_VERTEX);
266 for(; exx.More(); exx.Next()) {
267 const Standard_Real& tol = BRep_Tool::
268 Tolerance(TopoDS::Vertex(exx.Current()));
269 if(tol > myTol) myTol = tol;
272 TopoDS_Shape aLocalShape = W.Oriented(TopAbs_FORWARD);
273 myWire = TopoDS::Wire(aLocalShape);
274 // myWire = TopoDS::Wire(W.Oriented(TopAbs_FORWARD));
286 // ---Calculate bounding box
289 TopTools_ListOfShape theList;
293 gp_Pnt FirstCorner, LastCorner;
294 Standard_Real bnd = HeightMax(mySbase, U, FirstCorner, LastCorner);
297 BRepPrimAPI_MakeBox Bndbox(FirstCorner, LastCorner);
298 TopoDS_Solid BndBox = Bndbox.Solid();
301 // ---Construction of the working plane face (section bounding box)
302 BRepLib_MakeFace PlaneF(myPln->Pln(), -6.*myBnd,
303 6.*myBnd, -6.*myBnd, 6.*myBnd);
304 TopoDS_Face PlaneFace = TopoDS::Face(PlaneF.Shape());
306 //modified by NIZNHY-PKV Fri Mar 22 16:52:26 2002 f
307 //BRepAlgo_Common PlaneS(BndBox, PlaneFace);
308 BRepAlgoAPI_Common PlaneS(BndBox, PlaneFace);
309 //modified by NIZNHY-PKV Fri Mar 22 16:52:31 2002 t
311 TopoDS_Shape PlaneSect = PlaneS.Shape();
312 EXP.Init(PlaneSect, TopAbs_WIRE);
313 TopoDS_Wire www = TopoDS::Wire(EXP.Current());
314 BRepLib_MakeFace Bndface(myPln->Pln(), www, Standard_True);
315 TopoDS_Face BndFace = TopoDS::Face(Bndface.Shape());
318 // ---Find base faces of the rib
319 TopoDS_Edge FirstEdge, LastEdge;
320 TopoDS_Face FirstFace, LastFace;
321 TopoDS_Vertex FirstVertex, LastVertex;
323 Standard_Boolean OnFirstFace = Standard_False;
324 Standard_Boolean OnLastFace = Standard_False;
325 Standard_Boolean PtOnFirstEdge = Standard_False;
326 Standard_Boolean PtOnLastEdge = Standard_False;
327 TopoDS_Edge OnFirstEdge, OnLastEdge;
328 OnFirstEdge.Nullify();
329 OnLastEdge.Nullify();
331 Standard_Boolean Data = ExtremeFaces(RevolRib, myBnd, myPln, FirstEdge, LastEdge,
332 FirstFace, LastFace, FirstVertex,
333 LastVertex, OnFirstFace, OnLastFace,
334 PtOnFirstEdge, PtOnLastEdge,
335 OnFirstEdge, OnLastEdge);
339 if (trc) cout << " No Extreme faces" << endl;
341 myStatusError = BRepFeat_NoExtFace;
347 // ---Proofing Point for the side of the wire to be filled - material side
348 gp_Pnt CheckPnt = CheckPoint(FirstEdge, bnd/10., myPln);
350 // Standard_Real f, l;
352 // ---Control sliding valid
353 // Many cases when the sliding is abandoned
354 Standard_Integer Concavite = 3; // a priori the profile is not concave
356 myFirstPnt = BRep_Tool::Pnt(FirstVertex);
357 myLastPnt = BRep_Tool::Pnt(LastVertex);
359 // SliList : list of faces concerned by the rib
360 TopTools_ListOfShape SliList;
361 SliList.Append(FirstFace);
363 if(Sliding) { // sliding
365 if (trc) cout << " Sliding" << endl;
367 Handle(Geom_Surface) s = BRep_Tool::Surface(FirstFace);
368 if (s->DynamicType() ==
369 STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
370 s = Handle(Geom_RectangularTrimmedSurface)::
371 DownCast(s)->BasisSurface();
373 if(s->DynamicType() != STANDARD_TYPE(Geom_Plane) &&
374 s->DynamicType() != STANDARD_TYPE(Geom_CylindricalSurface) &&
375 s->DynamicType() != STANDARD_TYPE(Geom_ConicalSurface) &&
376 s->DynamicType() != STANDARD_TYPE(Geom_ToroidalSurface))
377 Sliding = Standard_False;
380 if(Sliding) { // sliding
381 Handle(Geom_Surface) ss = BRep_Tool::Surface(LastFace);
382 if (ss->DynamicType() ==
383 STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
384 ss = Handle(Geom_RectangularTrimmedSurface)::
385 DownCast(ss)->BasisSurface();
387 if(ss->DynamicType() != STANDARD_TYPE(Geom_Plane) &&
388 ss->DynamicType() != STANDARD_TYPE(Geom_CylindricalSurface) &&
389 ss->DynamicType() != STANDARD_TYPE(Geom_ConicalSurface) &&
390 ss->DynamicType() != STANDARD_TYPE(Geom_ToroidalSurface))
391 Sliding = Standard_False;
394 // Control only start and end points no control at the middle to improve
395 // If make a control between Surface and segment 2 points limited
396 // -> too expensive - to improve
397 //gp_Pnt FirstCenter, LastCenter;
398 gp_Circ FirstCircle, LastCircle;
399 Handle(Geom_Curve) FirstCrv, LastCrv;
401 if(Sliding) { // sliding
402 GeomAPI_ProjectPointOnCurve proj(myFirstPnt, Line);
403 if(proj.NbPoints() < 1) {
405 if (trc) cout << " No First Point projection" << endl;
407 myStatusError = BRepFeat_NoProjPt;
411 Standard_Real FirstRayon = proj.Distance(1);
412 gp_Pnt FirstCenter = proj.Point(1);
414 GeomAPI_ProjectPointOnCurve proj1(myLastPnt, Line);
415 if(proj.NbPoints() < 1) {
417 if (trc) cout << " No Last Point projection" << endl;
419 myStatusError = BRepFeat_NoProjPt;
423 Standard_Real LastRayon = proj1.Distance(1);
424 gp_Pnt LastCenter = proj1.Point(1);
426 gp_Vec axv(myAxe.Direction());
427 gp_Ax2 ax2(FirstCenter, axv);
428 gp_Ax2 ax2p(LastCenter, axv);
429 gp_Circ theFC(ax2, FirstRayon);
430 gp_Circ theLC(ax2p, LastRayon);
432 gp_Pnt RFirstPnt1 = myFirstPnt.Rotated(myAxe, myAngle1);
433 gp_Pnt RLastPnt1 = myLastPnt.Rotated(myAxe, myAngle1);
434 gp_Pnt RFirstPnt2 = myFirstPnt.Rotated(myAxe, -myAngle2);
435 gp_Pnt RLastPnt2 = myLastPnt.Rotated(myAxe, -myAngle2);
438 TopoDS_Vertex v1, v2, v3, v4;
439 Bu.MakeVertex(v1, RFirstPnt2, Precision::Confusion());
440 Bu.MakeVertex(v2, RFirstPnt1, Precision::Confusion());
441 Bu.MakeVertex(v3, RLastPnt2, Precision::Confusion());
442 Bu.MakeVertex(v4, RLastPnt1, Precision::Confusion());
444 BRepLib_MakeEdge ee1(theFC, v1, v2);
445 BRepLib_MakeEdge ee2(theLC, v3, v4);
447 if(Sliding && !PtOnFirstEdge) {
448 BRepExtrema_ExtCF ext1(TopoDS::Edge(ee1.Shape()), FirstFace);
449 if(ext1.NbExt() < 1 || ext1.SquareDistance(1) > Precision::SquareConfusion())
450 Sliding = Standard_False;
452 if(Sliding && !PtOnLastEdge) {
453 BRepExtrema_ExtCF ext2(ee2, LastFace); // ExtCF : curves and surfaces
454 if(ext2.NbExt() < 1 || ext2.SquareDistance(1) > Precision::SquareConfusion())
455 Sliding = Standard_False;
457 if(Sliding && PtOnFirstEdge) {
459 FirstCrv = BRep_Tool::Curve(OnFirstEdge, f, l);
460 if(FirstCrv->DynamicType() != STANDARD_TYPE(Geom_Circle))
461 Sliding = Standard_False;
463 Handle(Geom_Circle) C1 = Handle(Geom_Circle)::DownCast(FirstCrv);
464 gp_Circ Circ = C1->Circ();
466 gp_Ax1 circax = FirstCircle.Axis();
467 if(!circax.IsCoaxial(myAxe, Precision::Confusion(),
468 Precision::Confusion()))
469 Sliding = Standard_False;
472 if(fabs(FirstCircle.Radius()-FirstRayon) >=
474 // if(abs(FirstCircle.Radius()-FirstRayon) >=
476 Precision::Confusion())
477 Sliding = Standard_False;
482 if(Sliding && PtOnLastEdge) {
484 LastCrv = BRep_Tool::Curve(OnLastEdge, f, l);
485 if(LastCrv->DynamicType() != STANDARD_TYPE(Geom_Circle))
486 Sliding = Standard_False;
488 Handle(Geom_Circle) C1 = Handle(Geom_Circle)::DownCast(LastCrv);
489 gp_Circ Circ = C1->Circ();
491 gp_Ax1 circax = LastCircle.Axis();
492 if(!circax.IsCoaxial(myAxe, Precision::Confusion(),
493 Precision::Confusion()))
494 Sliding = Standard_False;
496 Standard_Real rad = LastCircle.Radius();
498 if(fabs(rad - LastRayon) >= Precision::Confusion()) {
500 // if(abs(rad - LastRayon) >= Precision::Confusion()) {
502 Sliding = Standard_False;
510 // Construct a great profile that goes till the bounding box
511 // -> by tangency with first and last edge of the Wire
512 // -> by normals to base faces : statistically better
513 // Intersect everythin to find the final profile
516 // ---case of sliding : construction of the face profile
519 if (trc) cout << " still Sliding" << endl;
522 Standard_Boolean ProfileOK;
523 ProfileOK = SlidingProfile(Prof,RevolRib,myTol,Concavite,myPln,BndFace,CheckPnt,
524 FirstFace,LastFace,FirstVertex,LastVertex,
529 cout << "Not computable" << endl;
530 if (trc) cout << "Face profile not computable" << endl;
532 myStatusError = BRepFeat_NoFaceProf;
538 // ---Propagation on faces of the initial shape
539 // to find the faces concerned by the rib
540 Standard_Boolean falseside = Standard_True;
541 Sliding = Propagate(SliList, Prof, myFirstPnt, myLastPnt, falseside);
542 // Control if there is everything required to have the material at the proper side
543 if(falseside == Standard_False) {
545 cout << " Verify plane and wire orientation" << endl;
547 myStatusError = BRepFeat_FalseSide;
554 // ---Generation of the base profile of the rib
558 TopoDS_Edge thePreviousEdge;
560 thePreviousEdge.Nullify();
562 // counter of the number of edges to fill the map
563 Standard_Integer counter = 1;
565 // ---case of sliding
566 if(Sliding && !myListOfEdges.IsEmpty()) {
567 BRepTools_WireExplorer EX1(myWire);
568 for(; EX1.More(); EX1.Next()) {
569 const TopoDS_Edge& E = EX1.Current();
570 if(!myLFMap.IsBound(E)) {
571 TopTools_ListOfShape theTmpList;
572 myLFMap.Bind(E, theTmpList);
574 if(E.IsSame(FirstEdge)) {
576 Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l);
578 if(!FirstEdge.IsSame(LastEdge)) {
579 pt = BRep_Tool::Pnt(TopExp::LastVertex(E,Standard_True));
583 Standard_Real fpar = IntPar(cc, myFirstPnt);
584 Standard_Real lpar = IntPar(cc, pt);
585 Handle(Geom_Curve) ccc;
587 ccc = Handle(Geom_Curve)::DownCast(cc->Reversed());
592 if(thePreviousEdge.IsNull()) {
593 BRepLib_MakeVertex v1(myFirstPnt);
594 BRepLib_MakeVertex v2(pt);
595 BRepLib_MakeEdge e(cc, v1, v2);
596 ee1 = TopoDS::Edge(e.Shape());
599 const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
600 BRepLib_MakeVertex v2(pt);
602 BRepLib_MakeEdge e(cc, v1, v2);
603 ee1 = TopoDS::Edge(e.Shape());
605 TopoDS_Shape aLocalShape = ee1.Oriented(E.Orientation());
606 ee1 = TopoDS::Edge(aLocalShape);
607 // ee1 = TopoDS::Edge(ee1.Oriented(E.Orientation()));
608 if(counter == 1) theFV = TopExp::FirstVertex(ee1,Standard_True);
609 myLFMap(E).Append(ee1);
611 thePreviousEdge = ee1;
618 // Case of several edges
619 if(!FirstEdge.IsSame(LastEdge)) {
620 for(; EX1.More(); EX1.Next()) {
621 const TopoDS_Edge& E = EX1.Current();
622 if(!myLFMap.IsBound(E)) {
623 TopTools_ListOfShape thelist1;
624 myLFMap.Bind(E, thelist1);
628 if(!E.IsSame(LastEdge)) {
629 Handle(Geom_Curve) ccc = BRep_Tool::Curve(E, f, l);
630 TopoDS_Vertex v1, v2;
631 if(!thePreviousEdge.IsNull()) {
632 v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
633 v2 = TopExp::LastVertex(E,Standard_True);
636 // v1 = TopExp::LastVertex(E,Standard_True);
637 v1 = TopExp::FirstVertex(E,Standard_True);
638 v2 = TopExp::LastVertex(E,Standard_True);
640 BRepLib_MakeEdge E1(ccc, v1, v2);
641 TopoDS_Edge E11 = TopoDS::Edge(E1.Shape());
642 TopoDS_Shape aLocalShape = E11.Oriented(E.Orientation());
643 E11 = TopoDS::Edge(aLocalShape);
644 // E11 = TopoDS::Edge(E11.Oriented(E.Orientation()));
645 thePreviousEdge = E11;
646 myLFMap(E).Append(E11);
648 if(counter == 1) theFV = TopExp::FirstVertex(E11,Standard_True);
653 Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l);
654 gp_Pnt pf = BRep_Tool::Pnt(TopExp::FirstVertex(E,Standard_True));
655 gp_Pnt pl = myLastPnt;
657 if(thePreviousEdge.IsNull()) {
658 BRepLib_MakeEdge e(cc, pf , pl);
659 ee = TopoDS::Edge(e.Shape());
662 const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
663 BRepLib_MakeVertex v2(pl);
664 BRepLib_MakeEdge e(cc, v1, v2);
665 ee = TopoDS::Edge(e.Shape());
667 TopoDS_Shape aLocalShape = ee.Oriented(E.Orientation());
668 ee = TopoDS::Edge(aLocalShape);
669 // ee = TopoDS::Edge(ee.Oriented(E.Orientation()));
671 myLFMap(E).Append(ee);
672 if(counter == 1) theFV = TopExp::FirstVertex(ee,Standard_True);
673 thePreviousEdge = ee;
680 TopTools_ListIteratorOfListOfShape it(myListOfEdges);
681 Standard_Boolean FirstOK = Standard_False;
682 Standard_Boolean LastOK = Standard_False;
684 gp_Pnt theLastPnt = myLastPnt;
685 Standard_Integer sens = 0;
686 TopoDS_Edge theEdge, theLEdge, theFEdge;
687 Standard_Integer counter1 = counter;
688 TopTools_ListOfShape NewListOfEdges;
689 NewListOfEdges.Clear();
691 const TopoDS_Edge& edg = TopoDS::Edge(it.Value());
694 Handle(Geom_Curve) ccc = BRep_Tool::Curve(edg, f, l);
695 Handle(Geom_TrimmedCurve) cc = new Geom_TrimmedCurve(ccc, f, l);
696 if ( edg.Orientation() == TopAbs_REVERSED) cc->Reverse();
698 fp = cc->Value(cc->FirstParameter());
699 lp = cc->Value(cc->LastParameter());
700 Standard_Real dist = fp.Distance(theLastPnt);
703 LastOK = Standard_True;
706 dist = lp.Distance(theLastPnt);
709 LastOK = Standard_True;
713 Standard_Integer FirstFlag = 0;
714 if(sens==1 && lp.Distance(myFirstPnt) <= myTol) {
715 FirstOK = Standard_True;
718 else if(sens==2 && fp.Distance(myFirstPnt) <= myTol) {
719 FirstOK = Standard_True;
725 Standard_Real fpar = cc->FirstParameter();
726 Standard_Real lpar = cc->LastParameter();
728 if(thePreviousEdge.IsNull()) {
729 BRepLib_MakeEdge e(cc, fpar, lpar);
730 eeee = TopoDS::Edge(e.Shape());
733 const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
734 BRepLib_MakeVertex v2(cc->Value(lpar));
735 BRepLib_MakeEdge e(cc, v1, v2);
736 eeee = TopoDS::Edge(e.Shape());
740 if(thePreviousEdge.IsNull()) {
741 BRepLib_MakeVertex v1(cc->Value(fpar));
742 BRepLib_MakeEdge e(cc, v1, theFV);
743 eeee = TopoDS::Edge(e.Shape());
746 const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
747 BRepLib_MakeEdge e(cc, v1, theFV);
748 eeee = TopoDS::Edge(e.Shape());
752 thePreviousEdge = eeee;
754 if(counter == 1) theFV = TopExp::FirstVertex(eeee,Standard_True);
756 NewListOfEdges.Append(edg);
761 theLastPnt = BRep_Tool::Pnt(TopExp::LastVertex(theEdge,Standard_True));
767 else if(FirstFlag == 2) {
772 it.Initialize(myListOfEdges);
773 LastOK = Standard_False;
775 else if(it.More()) it.Next();
777 Sliding = Standard_False;
784 TopTools_DataMapOfShapeListOfShape SlidMap;
787 if(Sliding && counter1 > counter) {
788 TopTools_ListIteratorOfListOfShape it;
789 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm;
790 TopExp_Explorer EX2(w, TopAbs_EDGE);
791 Standard_Integer ii = 0;
792 for(; EX2.More(); EX2.Next()) {
793 const TopoDS_Edge& E = TopoDS::Edge(EX2.Current());
795 if(ii >= counter && ii <= counter1) {
796 it.Initialize(NewListOfEdges);
797 Standard_Integer jj = 0;
798 for(; it.More(); it.Next()) {
799 const TopoDS_Edge& e2 = TopoDS::Edge(it.Value());
801 if(jj== (ii - counter +1)) {
802 itm.Initialize(mySlface);
803 for(; itm.More(); itm.Next()) {
804 const TopoDS_Face& fac = TopoDS::Face(itm.Key());
805 const TopTools_ListOfShape& ledg = itm.Value();
806 TopTools_ListIteratorOfListOfShape itedg(ledg);
807 //Standard_Integer iiii = 0;
808 for(; itedg.More(); itedg.Next()) {
809 const TopoDS_Edge& e1 = TopoDS::Edge(itedg.Value());
811 if(!SlidMap.IsBound(fac)) {
812 TopTools_ListOfShape thelist2;
813 SlidMap.Bind(fac, thelist2);
815 SlidMap(fac).Append(E);
829 // ---Arguments of LocOpe_LinearForm : arguments of the prism
833 BB.MakeFace(F, myPln, myTol);
841 // ---Case without sliding : construction of the face profile
845 if (Modify) cout << " Sliding failure" << endl;
846 cout << " no Sliding" << endl;
849 TopExp_Explorer explo1(BndFace, TopAbs_WIRE);
850 TopoDS_Wire WWW = TopoDS::Wire(explo1.Current());
851 BRepTools_WireExplorer explo(WWW);
855 TopoDS_Vertex NewV1, NewV2, LastV, v;
856 NewV1.Nullify(); NewV2.Nullify(); LastV.Nullify();
858 for(; explo.More(); explo.Next()) {
859 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
860 TopoDS_Vertex v1 = TopExp::FirstVertex(e,Standard_True);
861 TopoDS_Vertex v2 = TopExp::LastVertex(e,Standard_True);
863 Standard_Real f, l;//, t;
864 Handle(Geom_Curve) ln = BRep_Tool::Curve(e, f, l);
865 // Handle(Geom_Curve) lln = BRep_Tool::Curve(e, f, l);
866 // Handle(Geom_Curve) ln;
867 // if(e.Orientation() == TopAbs_REVERSED) {
868 // ln = Handle(Geom_Curve)::DownCast(lln->Reversed());
869 // v = v1; v1 = v2; v2= v;
870 // f = IntPar(ln, BRep_Tool::Pnt(v1));
871 // l = IntPar(ln, BRep_Tool::Pnt(v2));
875 Handle(Geom2d_Curve) l2d = GeomAPI::To2d(ln, Plane->Pln());
876 Geom2dAPI_InterCurveCurve intcc(l2d, ln2d, Precision::Confusion());
877 TopoDS_Vertex VV; VV.Nullify();
878 TopoDS_Edge ee1, ee2;
880 if(intcc.NbPoints() > 0) {
881 gp_Pnt2d P = intcc.Point(1);
883 myPln->D0(P.X(), P.Y(), point);
884 Standard_Real par = IntPar(ln, point);
885 if(f <= par && l >= par) {
886 Bu.MakeVertex(VV, point, Precision::Confusion());
890 if(VV.IsNull() && NewV1.IsNull()) continue;
892 if(!VV.IsNull() && NewV1.IsNull()) {
895 BRepLib_MakeEdge ee1(NewV1, LastV);
900 if(VV.IsNull() && !NewV1.IsNull()) {
901 BRepLib_MakeEdge ee1(LastV, v2);
907 if(!VV.IsNull() && !NewV1.IsNull()) {
909 BRepLib_MakeEdge ee1(LastV, NewV2);
912 BRepLib_MakeEdge ee2(LastV, NewV1);
918 BRepLib_MakeFace newbndface(myPln->Pln(), Wiwiwi, Standard_True);
919 TopoDS_Face NewBndFace = TopoDS::Face(newbndface.Shape());
921 BRepTopAdaptor_FClass2d Cl(NewBndFace, Precision::Confusion());
922 Standard_Real paru, parv;
923 ElSLib::Parameters(myPln->Pln(), CheckPnt, paru, parv);
924 gp_Pnt2d checkpnt2d(paru, parv);
925 if(Cl.Perform(checkpnt2d, Standard_True) == TopAbs_OUT) {
926 //modified by NIZNHY-PKV Fri Mar 22 16:52:52 2002 f
927 //BRepAlgo_Cut c(BndFace, NewBndFace);
928 BRepAlgoAPI_Cut c(BndFace, NewBndFace);
929 //modified by NIZNHY-PKV Fri Mar 22 16:52:57 2002 t
930 TopExp_Explorer exp(c.Shape(), TopAbs_WIRE);
931 const TopoDS_Wire& w = TopoDS::Wire(exp.Current());
932 // akm 13/02/02 : we know the plane. Why not to use it?
933 // BRepLib_MakeFace ff(w);
934 BRepLib_MakeFace ff(myPln->Pln(), w, Standard_True);
935 NewBndFace = TopoDS::Face(ff.Shape());
939 if(!BRepAlgo::IsValid(NewBndFace)) {
941 cout << "Invalid new bounding face" << endl;
943 myStatusError = BRepFeat_InvShape;
948 BndFace = NewBndFace;
952 Standard_Boolean ProfileOK;
953 ProfileOK = NoSlidingProfile(Prof,RevolRib,myTol,Concavite,myPln,
954 bnd,BndFace,CheckPnt,
955 FirstFace,LastFace,FirstVertex,LastVertex,
956 FirstEdge,LastEdge,OnFirstFace,OnLastFace);
960 cout << "Not computable" << endl;
961 if (trc) cout << " Face profile not computable" << endl;
963 myStatusError = BRepFeat_NoFaceProf;
969 // ---Propagation on the faces of the initial shape
970 // to find the faces concerned by the rib
971 Standard_Boolean falseside = Standard_True;
972 Propagate(SliList, Prof, myFirstPnt, myLastPnt, falseside);
973 // Control if there is everything required to have the material at the proper side
974 if(falseside == Standard_False) {
976 cout << " Verify plane and wire orientation" << endl;
978 myStatusError = BRepFeat_FalseSide;
985 TopTools_ListIteratorOfListOfShape it;
986 it.Initialize(SliList);
991 BB.MakeShell(TopoDS::Shell(comp));
993 for(; it.More(); it.Next()) {
994 BB.Add(comp, it.Value());
1003 mySliding = Sliding;
1005 TopExp_Explorer exp;
1006 for ( exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
1007 TopTools_ListOfShape thelist3;
1008 myMap.Bind(exp.Current(), thelist3);
1009 myMap(exp.Current()).Append(exp.Current());
1015 //=======================================================================
1017 //purpose : add elements of gluing
1018 //=======================================================================
1020 void BRepFeat_MakeRevolutionForm::Add(const TopoDS_Edge& E,
1021 const TopoDS_Face& F)
1024 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1025 if (trc) cout << "BRepFeat_MakeRevolutionForm::Add" << endl;
1027 if(mySlface.IsEmpty()) {
1028 TopExp_Explorer exp;
1029 for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
1030 if (exp.Current().IsSame(F)) {
1035 Standard_ConstructionError::Raise();
1038 if (!mySlface.IsBound(F)) {
1039 TopTools_ListOfShape thelist;
1040 mySlface.Bind(F, thelist);
1042 TopTools_ListIteratorOfListOfShape itl(mySlface(F));
1043 for (; itl.More();itl.Next()) {
1044 if (itl.Value().IsSame(E)) {
1049 mySlface(F).Append(E);
1056 //=======================================================================
1057 //function : Perform
1058 //purpose : construction
1059 //=======================================================================
1061 void BRepFeat_MakeRevolutionForm::Perform()
1064 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1065 if (trc) cout << "BRepFeat_MakeRevolutionForm::Perform()" << endl;
1067 if(mySbase.IsNull() || mySkface.IsNull() || myPbase.IsNull()) {
1069 if (trc) cout << " Fields not initialized" << endl;
1071 myStatusError = BRepFeat_NotInitialized;
1078 TopExp_Explorer exx(myPbase, TopAbs_VERTEX);
1079 for(; exx.More(); exx.Next()) {
1080 const TopoDS_Vertex& vv = TopoDS::Vertex(exx.Current());
1082 Pt = BRep_Tool::Pnt(vv);
1089 T.SetRotation(myAxe, -myAngle2);
1090 BRepBuilderAPI_Transform trsf(T);
1091 trsf.Perform(myPbase, Standard_False);
1092 TopoDS_Face Pbase = TopoDS::Face(trsf.Shape());
1093 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iter(myLFMap);
1094 for(; iter.More(); iter.Next()) {
1095 const TopoDS_Shape& e1 = iter.Value().First();
1096 TopExp_Explorer ex1(myPbase, TopAbs_EDGE);
1097 TopExp_Explorer ex2(Pbase, TopAbs_EDGE);
1098 for(; ex1.More(); ex1.Next()) {
1099 if(ex1.Current().IsSame(e1)) {
1100 myLFMap(iter.Key()).Clear();
1101 myLFMap(iter.Key()).Append(ex2.Current());
1107 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iter1(mySlface);
1108 for(; iter1.More(); iter1.Next()) {
1109 const TopoDS_Shape& f1 = iter1.Key();
1110 const TopoDS_Shape& e1 = iter1.Value().First();
1111 TopExp_Explorer ex1(myPbase, TopAbs_EDGE);
1112 TopExp_Explorer ex2(Pbase, TopAbs_EDGE);
1113 for(; ex1.More(); ex1.Next()) {
1114 const TopoDS_Shape& E1 = ex1.Current();
1115 const TopoDS_Shape& E2 = ex2.Current();
1117 mySlface(f1).Clear();
1118 mySlface(f1).Append(E2);
1124 trsf.Perform(mySkface, Standard_False);
1125 // flo : check if it is required to reattributr the field mySkface
1126 // TopoDS_Face mySkface = TopoDS::Face(trsf.Shape());
1127 mySkface = TopoDS::Face(trsf.Shape());
1130 LocOpe_RevolutionForm theForm;
1131 theForm.Perform(myPbase, myAxe, (myAngle1+myAngle2));
1132 TopoDS_Shape VraiForm = theForm.Shape(); // uncut primitive
1134 // management of descendants
1135 MajMap(myPbase,theForm,myMap,myFShape,myLShape);
1141 gp_Pln Pln0 = myPln->Pln();
1142 BRepLib_MakeFace f(Pln0);
1145 gp_Vec vec1 = myHeight1*Normal(f, Pt);
1146 gp_Vec vec2 = -myHeight2*Normal(f, Pt);
1148 gp_Pln Pln1 = Pln0.Translated(vec1);
1149 gp_Pln Pln2 = Pln0.Translated(vec2);
1151 BRepLib_MakeFace ff1(Pln1);
1152 BRepLib_MakeFace ff2(Pln2);
1153 TopoDS_Face f1 = TopoDS::Face(ff1.Shape());
1154 TopoDS_Face f2 = TopoDS::Face(ff2.Shape());
1155 BRepFeat::FaceUntil(mySbase, f1);
1156 BRepFeat::FaceUntil(mySbase, f2);
1158 LocOpe_CSIntersector ASI1(f1);
1159 LocOpe_CSIntersector ASI2(f2);
1161 Handle(Geom_Line) normale = new Geom_Line(Pt, vec1);
1162 TColGeom_SequenceOfCurve scur;
1163 scur.Append(normale);
1168 if(!ASI1.IsDone() || !ASI2.IsDone() ||
1169 ASI1.NbPoints(1) != 1 || ASI2.NbPoints(1) != 1) {
1171 if (trc) cout << " Intersection failure" << endl;
1173 myStatusError = BRepFeat_BadIntersect;
1178 TopAbs_Orientation Ori1 = ASI1.Point(1,1).Orientation();
1179 TopAbs_Orientation Ori2 = TopAbs::Reverse(ASI2.Point(1,1).Orientation());
1180 TopoDS_Face FF1 = ASI1.Point(1,1).Face();
1181 TopoDS_Face FF2 = ASI2.Point(1,1).Face();
1185 B.MakeCompound(TopoDS::Compound(Comp));
1186 TopoDS_Solid S1 = BRepFeat::Tool(f1,FF1,Ori1);
1187 TopoDS_Solid S2 = BRepFeat::Tool(f2,FF2,Ori2);
1188 if (!S1.IsNull()) B.Add(Comp,S1);
1189 if (!S2.IsNull()) B.Add(Comp,S2);
1191 //modified by NIZNHY-PKV Fri Mar 22 16:53:20 2002 f
1192 //BRepAlgo_Cut trP(VraiForm,Comp);
1193 BRepAlgoAPI_Cut trP(VraiForm,Comp);
1194 //modified by NIZNHY-PKV Fri Mar 22 16:53:23 2002 t
1195 // coupe de la nervure par deux plans parallels
1196 TopTools_DataMapOfShapeListOfShape SlidingMap;
1198 // management of descendants
1200 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape it1;
1201 it1.Initialize(myMap);
1202 for(; it1.More(); it1.Next()) {
1203 const TopoDS_Shape& orig = it1.Key();
1204 if(it1.Value().IsEmpty()) continue;
1205 const TopoDS_Shape& sh = it1.Value().First();
1206 exx.Init(VraiForm, TopAbs_FACE);
1207 for(; exx.More(); exx.Next()) {
1208 const TopoDS_Face& fac = TopoDS::Face(exx.Current());
1209 TopExp_Explorer exx1(fac, TopAbs_WIRE);
1210 const TopoDS_Wire& thew = TopoDS::Wire(exx1.Current());
1211 if(thew.IsSame(myFShape)) {
1212 const TopTools_ListOfShape& desfaces = trP.Modified(f2);
1213 myMap(myFShape) = desfaces;
1216 else if(thew.IsSame(myLShape)) {
1217 const TopTools_ListOfShape& desfaces = trP.Modified(f1);
1218 myMap(myLShape) = desfaces;
1221 if(fac.IsSame(sh)) {
1222 if (trP.IsDeleted(fac)) {
1225 const TopTools_ListOfShape& desfaces = trP.Modified(fac);
1226 if(!desfaces.IsEmpty()) {
1227 myMap(orig).Clear();
1228 myMap(orig) = trP.Modified(fac);
1235 exx.Init(VraiForm, TopAbs_FACE);
1236 for(; exx.More(); exx.Next()) {
1237 const TopoDS_Face& fac = TopoDS::Face(exx.Current());
1238 TopTools_ListOfShape thelist;
1239 SlidingMap.Bind(fac, thelist);
1240 if (trP.IsDeleted(fac)) {
1243 const TopTools_ListOfShape& desfaces = trP.Modified(fac);
1244 if(!desfaces.IsEmpty())
1245 SlidingMap(fac) = desfaces;
1247 SlidingMap(fac).Append(fac);
1252 // gestion of faces of sliding
1253 SetGluedFaces(mySlface, theForm, SlidingMap, myGluedF);
1255 VraiForm = trP.Shape(); // primitive cut
1257 if(!myGluedF.IsEmpty())
1258 myPerfSelection = BRepFeat_NoSelection;
1260 myPerfSelection = BRepFeat_SelectionSh;
1262 exx.Init(myPbase, TopAbs_EDGE);
1263 for(; exx.More(); exx.Next()) {
1264 const TopoDS_Edge& e = TopoDS::Edge(exx.Current());
1265 if(!myMap.IsBound(e)) {
1267 if (trc) cout << " Sliding face not in Base shape" << endl;
1269 myStatusError = BRepFeat_IncSlidFace;
1275 myGShape = VraiForm;
1277 if(!myGluedF.IsEmpty() && !mySUntil.IsNull()) {
1279 cout << "The case is not computable" << endl;
1280 if (trc) cout << " Glued faces not empty and Until shape not null" << endl;
1282 myStatusError = BRepFeat_InvShape;
1287 LFPerform(); // topological reconstruction
1291 //=======================================================================
1292 //function : Propagate
1293 //purpose : propagation on the faces of the inital shape, find faces
1294 // concerned by the rib
1295 //=======================================================================
1297 Standard_Boolean BRepFeat_MakeRevolutionForm::Propagate(TopTools_ListOfShape& SliList,
1298 const TopoDS_Face& fac,
1299 const gp_Pnt& Firstpnt,
1300 const gp_Pnt& Lastpnt,
1301 Standard_Boolean& falseside)
1304 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
1305 if (trc) cout << "BRepFeat_MakeRevolutionForm::Propagate" << endl;
1307 gp_Pnt Firstpoint = Firstpnt;
1308 gp_Pnt Lastpoint = Lastpnt;
1310 Standard_Boolean result = Standard_True;
1311 TopoDS_Face CurrentFace, saveFace;
1312 CurrentFace = TopoDS::Face(SliList.First());
1313 saveFace = CurrentFace;
1314 // BRepBuilderAPI_MakeFace fac(myPln);
1315 Standard_Boolean LastOK = Standard_False, FirstOK= Standard_False;
1316 TopoDS_Vertex v1, v2, v3, v4, Vert;
1317 //modified by NIZNHY-PKV Fri Mar 22 16:54:09 2002 f
1318 //BRepAlgo_Section sect (fac, CurrentFace, Standard_False);
1319 BRepAlgoAPI_Section sect (fac, CurrentFace, Standard_False);
1320 //modified by NIZNHY-PKV Fri Mar 22 16:54:14 2002 t
1321 sect.Approximation(Standard_True);
1326 Standard_Integer ii = 0;
1327 for (Ex.Init(sect.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) {
1330 e = TopoDS::Edge(Ex.Current());
1333 e1 = TopoDS::Edge(Ex.Current());
1338 falseside = Standard_False;
1339 return Standard_False;
1342 //modified by NIZNHY-PKV Tue Apr 2 15:08:23 2002 f
1344 Standard_Real aTolV1, aTolV2;
1345 myListOfEdges.Clear();
1346 TopTools_ListOfShape thelist;
1347 mySlface.Bind(CurrentFace, thelist);
1348 mySlface(CurrentFace).Append(e1);
1350 myListOfEdges.Append(e1);
1352 v1 = TopExp::FirstVertex(e1,Standard_True);
1353 v2 = TopExp::LastVertex (e1,Standard_True);
1355 FP = BRep_Tool::Pnt(v1);
1356 LP = BRep_Tool::Pnt(v2);
1358 aTolV1=BRep_Tool::Tolerance(v1);
1359 aTolV2=BRep_Tool::Tolerance(v2);
1361 if(FP.Distance(Firstpoint) <= aTolV1 ||
1362 FP.Distance(Lastpoint) <= aTolV1) {
1363 FirstOK = Standard_True;
1365 if(LP.Distance(Firstpoint)<= aTolV2 ||
1366 LP.Distance(Lastpoint) <= aTolV2) {
1367 LastOK = Standard_True;
1370 if(LastOK && FirstOK) {
1375 myListOfEdges.Clear();
1378 //modified by NIZNHY-PKV Tue Apr 2 15:08:26 2002 t
1381 myListOfEdges.Clear();
1382 TopTools_ListOfShape thelist1;
1383 mySlface.Bind(CurrentFace, thelist1);
1384 mySlface(CurrentFace).Append(e);
1386 myListOfEdges.Append(e);
1388 // mySlface.Bind(CurrentFace,TopTools_ListOfShape());
1389 mySlface(CurrentFace).Append(e1);
1390 // myListOfEdges.Append(e1);
1392 v1 = TopExp::FirstVertex(e,Standard_True);
1393 v2 = TopExp::LastVertex(e,Standard_True);
1394 v3 = TopExp::FirstVertex(e1,Standard_True);
1395 v4 = TopExp::LastVertex(e1,Standard_True);
1396 gp_Pnt p1, p2, p3, p4;
1397 p1 = BRep_Tool::Pnt(v1); FP = p1;
1398 p2 = BRep_Tool::Pnt(v2); LP = p2;
1399 p3 = BRep_Tool::Pnt(v3);
1400 p4 = BRep_Tool::Pnt(v4);
1401 if(p1.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1)) {
1402 if(p3.Distance(Lastpoint) <= BRep_Tool::Tolerance(v3)) {
1403 FirstOK = Standard_True;
1406 else if(p4.Distance(Lastpoint) <= BRep_Tool::Tolerance(v4)) {
1407 FirstOK = Standard_True;
1414 else if(p1.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) {
1415 if(p3.Distance(Firstpoint) <= BRep_Tool::Tolerance(v3)) {
1416 FirstOK = Standard_True;
1419 else if(p4.Distance(Firstpoint) <= BRep_Tool::Tolerance(v4)) {
1420 FirstOK = Standard_True;
1427 else if(p2.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2)) {
1428 if(p3.Distance(Lastpoint) <= BRep_Tool::Tolerance(v3)) {
1429 LastOK = Standard_True;
1432 else if(p4.Distance(Lastpoint) <= BRep_Tool::Tolerance(v4)) {
1433 LastOK = Standard_True;
1440 else if(p2.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) {
1441 if(p3.Distance(Firstpoint) <= BRep_Tool::Tolerance(v3)) {
1442 LastOK = Standard_True;
1445 else if(p4.Distance(Firstpoint) <= BRep_Tool::Tolerance(v4)) {
1446 LastOK = Standard_True;
1459 myListOfEdges.Clear();
1460 TopTools_ListOfShape thelist2;
1461 mySlface.Bind(CurrentFace, thelist2);
1462 mySlface(CurrentFace).Append(e);
1464 myListOfEdges.Append(e);
1466 v1 = TopExp::FirstVertex(e,Standard_True);
1467 v2 = TopExp::LastVertex(e,Standard_True);
1469 FP = BRep_Tool::Pnt(v1);
1470 LP = BRep_Tool::Pnt(v2);
1472 if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1)
1473 || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) {
1474 FirstOK = Standard_True;
1476 if(LP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2)
1477 || LP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) {
1478 LastOK = Standard_True;
1481 if(LastOK && FirstOK) {
1486 TopTools_IndexedDataMapOfShapeListOfShape mapedges;
1487 TopExp::MapShapesAndAncestors(mySbase, TopAbs_EDGE, TopAbs_FACE, mapedges);
1489 TopoDS_Edge FirstEdge;
1491 TopoDS_Vertex Vprevious; Vprevious.Nullify();
1492 TopoDS_Vertex Vpreprevious; Vpreprevious.Nullify();
1495 // find edge connected to v1:
1497 if(!v1.IsNull()) pt= BRep_Tool::Pnt(v1);
1499 if(!Vprevious.IsNull()) ptprev = BRep_Tool::Pnt(Vprevious);
1501 if(!Vpreprevious.IsNull()) ptpreprev = BRep_Tool::Pnt(Vpreprevious);
1503 if((!Vprevious.IsNull() && ptprev.Distance(pt) <= myTol) ||
1504 (!Vpreprevious.IsNull() && ptpreprev.Distance(pt) <= myTol)) {
1505 falseside = Standard_False;
1506 return Standard_False;
1509 for (ex.Init(CurrentFace, TopAbs_EDGE); ex.More(); ex.Next()) {
1510 const TopoDS_Edge& e = TopoDS::Edge(ex.Current());
1512 BRepExtrema_ExtPC projF(v1, e);
1514 if(projF.IsDone() && projF.NbExt() >=1) {
1515 Standard_Real dist2min = RealLast();
1516 Standard_Integer index = 0;
1517 for (Standard_Integer sol =1 ; sol <= projF.NbExt(); sol++) {
1518 if (projF.SquareDistance(sol) <= dist2min) {
1520 dist2min = projF.SquareDistance(sol);
1524 if (dist2min <= BRep_Tool::Tolerance(e) * BRep_Tool::Tolerance(e)) {
1532 const TopTools_ListOfShape& L = mapedges.FindFromKey(FirstEdge);
1533 TopTools_ListIteratorOfListOfShape It(L);
1535 for (; It.More(); It.Next()) {
1536 const TopoDS_Face& FF = TopoDS::Face(It.Value());
1537 if (!FF.IsSame(CurrentFace)) {
1543 //modified by NIZNHY-PKV Fri Mar 22 16:54:28 2002 f
1544 //BRepAlgo_Section sectf (fac, CurrentFace, Standard_False);
1545 BRepAlgoAPI_Section sectf (fac, CurrentFace, Standard_False);
1546 //modified by NIZNHY-PKV Fri Mar 22 16:54:33 2002 t
1547 sectf.Approximation(Standard_True);
1551 for (Ex.Init(sectf.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) {
1552 edg1 = TopoDS::Edge(Ex.Current());
1553 gp_Pnt ppp1 = BRep_Tool::Pnt(TopExp::FirstVertex(edg1,Standard_True));
1554 gp_Pnt ppp2 = BRep_Tool::Pnt(TopExp::LastVertex(edg1,Standard_True));
1555 if(ppp1.Distance(BRep_Tool::Pnt(v1)) <= BRep_Tool::Tolerance(v1) ||
1556 ppp2.Distance(BRep_Tool::Pnt(v1)) <= BRep_Tool::Tolerance(v1))
1560 TopTools_ListOfShape thelist3;
1561 mySlface.Bind(CurrentFace, thelist3);
1562 mySlface(CurrentFace).Append(edg1);
1563 myListOfEdges.Append(edg1);
1565 if (!edg1.IsNull()) SliList.Prepend(CurrentFace);
1566 else return Standard_False;
1568 Vert = TopExp::FirstVertex(edg1,Standard_True);
1569 gp_Pnt PP = BRep_Tool::Pnt(Vert);
1570 FP = BRep_Tool::Pnt(v1);
1571 Standard_Real tol = BRep_Tool::Tolerance(edg1);
1572 Standard_Real tol1 = BRep_Tool::Tolerance(v1);
1573 if(tol1 > tol) tol = tol1;
1574 Standard_Real dist = PP.Distance(FP);
1576 Vpreprevious = Vprevious;
1578 v1 = TopExp::LastVertex(edg1,Standard_True);
1581 Vpreprevious = Vprevious;
1586 FP = BRep_Tool::Pnt(v1);
1588 if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1)
1589 || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) {
1590 FirstOK = Standard_True;
1594 CurrentFace = saveFace;
1595 Vprevious.Nullify();
1596 Vpreprevious.Nullify();
1599 // find edge connected to v2:
1601 if(!v2.IsNull()) pt= BRep_Tool::Pnt(v2);
1603 if(!Vprevious.IsNull()) ptprev = BRep_Tool::Pnt(Vprevious);
1605 if(!Vpreprevious.IsNull()) ptpreprev = BRep_Tool::Pnt(Vpreprevious);
1607 if((!Vprevious.IsNull() && ptprev.Distance(pt) <= myTol) ||
1608 (!Vpreprevious.IsNull() && ptpreprev.Distance(pt) <= myTol)) {
1609 falseside = Standard_False;
1610 return Standard_False;
1613 for (ex.Init(CurrentFace, TopAbs_EDGE); ex.More(); ex.Next()) {
1614 const TopoDS_Edge& e = TopoDS::Edge(ex.Current());
1615 BRepExtrema_ExtPC projF(v2, e);
1617 if(projF.IsDone() && projF.NbExt() >=1) {
1618 Standard_Real dist2min = RealLast();
1619 Standard_Integer index = 0;
1620 for (Standard_Integer sol =1 ; sol <= projF.NbExt(); sol++) {
1621 if (projF.SquareDistance(sol) <= dist2min) {
1623 dist2min = projF.SquareDistance(sol);
1627 if (dist2min <= BRep_Tool::Tolerance(e) * BRep_Tool::Tolerance(e)) {
1635 const TopTools_ListOfShape& L = mapedges.FindFromKey(FirstEdge);
1636 TopTools_ListIteratorOfListOfShape It(L);
1638 for (; It.More(); It.Next()) {
1639 const TopoDS_Face& FF = TopoDS::Face(It.Value());
1640 if (!FF.IsSame(CurrentFace)) {
1648 //modified by NIZNHY-PKV Fri Mar 22 16:54:45 2002 f
1649 //BRepAlgo_Section sectf (fac, CurrentFace, Standard_False);
1650 BRepAlgoAPI_Section sectf (fac, CurrentFace, Standard_False);
1651 //modified by NIZNHY-PKV Fri Mar 22 16:54:52 2002 t
1652 sectf.Approximation(Standard_True);
1656 for (Ex.Init(sectf.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) {
1657 edg2 = TopoDS::Edge(Ex.Current());
1658 gp_Pnt ppp1 = BRep_Tool::Pnt(TopExp::FirstVertex(edg2,Standard_True));
1659 gp_Pnt ppp2 = BRep_Tool::Pnt(TopExp::LastVertex(edg2,Standard_True));
1660 if(ppp1.Distance(BRep_Tool::Pnt(v2)) <= BRep_Tool::Tolerance(v2) ||
1661 ppp2.Distance(BRep_Tool::Pnt(v2)) <= BRep_Tool::Tolerance(v2))
1664 TopTools_ListOfShape thelist4;
1665 mySlface.Bind(CurrentFace, thelist4);
1666 mySlface(CurrentFace).Append(edg2);
1667 myListOfEdges.Append(edg2);
1669 if (!edg2.IsNull()) SliList.Append(CurrentFace);
1670 else return Standard_False;
1672 Vert = TopExp::FirstVertex(edg2,Standard_True);
1673 gp_Pnt PP = BRep_Tool::Pnt(Vert);
1674 FP = BRep_Tool::Pnt(v2);
1675 if (PP.Distance(FP)<= BRep_Tool::Tolerance(v2)) {
1676 Vpreprevious = Vprevious;
1678 v2 = TopExp::LastVertex(edg2,Standard_True);
1683 FP = BRep_Tool::Pnt(v2);
1686 if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2)
1687 || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) {
1688 LastOK = Standard_True;
1691 if(!e1.IsNull()) myListOfEdges.Append(e1);
1697 //=======================================================================
1699 //purpose : management of descendants
1700 //=======================================================================
1702 static void MajMap(const TopoDS_Shape& theB,
1703 const LocOpe_RevolutionForm& theP,
1704 TopTools_DataMapOfShapeListOfShape& theMap, // myMap
1705 TopoDS_Shape& theFShape, // myFShape
1706 TopoDS_Shape& theLShape) // myLShape
1708 TopExp_Explorer exp(theP.FirstShape(),TopAbs_WIRE);
1710 theFShape = exp.Current();
1711 TopTools_ListOfShape thelist;
1712 theMap.Bind(theFShape, thelist);
1713 for (exp.Init(theP.FirstShape(),TopAbs_FACE);exp.More();exp.Next()) {
1714 const TopoDS_Shape& sh = exp.Current();
1715 theMap(theFShape).Append(sh);
1719 exp.Init(theP.LastShape(),TopAbs_WIRE);
1721 theLShape = exp.Current();
1722 TopTools_ListOfShape thelist1;
1723 theMap.Bind(theLShape, thelist1);
1724 for (exp.Init(theP.LastShape(),TopAbs_FACE);exp.More();exp.Next()) {
1725 const TopoDS_Shape& sh = exp.Current();
1726 theMap(theLShape).Append(sh);
1730 for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) {
1731 if (!theMap.IsBound(exp.Current())) {
1732 TopTools_ListOfShape thelist2;
1733 theMap.Bind(exp.Current(), thelist2);
1734 theMap(exp.Current()) = theP.Shapes(exp.Current());
1740 //=======================================================================
1741 //function : SetGluedFaces
1742 //purpose : managemnet of sliding faces
1743 //=======================================================================
1745 static void SetGluedFaces(const TopTools_DataMapOfShapeListOfShape& theSlmap,
1746 LocOpe_RevolutionForm& thePrism,
1747 const TopTools_DataMapOfShapeListOfShape& SlidingMap,
1748 TopTools_DataMapOfShapeShape& theMap)
1751 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(theSlmap);
1752 if(!theSlmap.IsEmpty()) {
1753 for (; itm.More(); itm.Next()) {
1754 const TopoDS_Face& fac = TopoDS::Face(itm.Key());
1755 const TopTools_ListOfShape& ledg = itm.Value();
1756 TopTools_ListIteratorOfListOfShape it;
1757 for (it.Initialize(ledg); it.More(); it.Next()) {
1758 const TopTools_ListOfShape& gfac = thePrism.Shapes(it.Value());
1759 if (gfac.Extent() != 1) {
1761 cout << "Pb SetGluedFace" << endl;
1764 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iterm(SlidingMap);
1765 for(; iterm.More(); iterm.Next()) {
1766 const TopoDS_Face& ff = TopoDS::Face(iterm.Key());
1767 const TopTools_ListOfShape& lfaces = iterm.Value();
1768 if(lfaces.IsEmpty()) continue;
1769 const TopoDS_Face& fff = TopoDS::Face(lfaces.First());
1770 if(gfac.First().IsSame(ff)) theMap.Bind(fff,fac);